Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:14:23

0001 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0002 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0003 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
0004 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0005 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0006 #include "CondFormats/DataRecord/interface/EcalIntercalibConstantsRcd.h"
0007 #include "Calibration/Tools/interface/calibXMLwriter.h"
0008 #include "CalibCalorimetry/CaloMiscalibTools/interface/CaloMiscalibTools.h"
0009 #include "CalibCalorimetry/CaloMiscalibTools/interface/CaloMiscalibMapEcal.h"
0010 #include "CalibCalorimetry/CaloMiscalibTools/interface/MiscalibReaderFromXMLEcalBarrel.h"
0011 #include "CalibCalorimetry/CaloMiscalibTools/interface/MiscalibReaderFromXMLEcalEndcap.h"
0012 #include "CondFormats/EcalObjects/interface/EcalIntercalibConstants.h"
0013 
0014 #include "Calibration/Tools/bin/trivialParser.h"
0015 
0016 #include "TH2.h"
0017 #include "TH1.h"
0018 #include "TFile.h"
0019 #include "TROOT.h"
0020 #include "TStyle.h"
0021 #include "TCanvas.h"
0022 
0023 #define PI_GRECO 3.14159265
0024 
0025 int main(int argc, char* argv[]) {
0026   std::string fileName = argv[1];
0027   std::cerr << "parsing coeff file: " << fileName << std::endl;
0028 
0029   int EEradStart = 15;
0030   int EEradEnd = 50;
0031   int EEphiStart = 20;
0032   int EEphiEnd = 45;
0033 
0034   //PG open the XML file
0035   CaloMiscalibMapEcal map;
0036   map.prefillMap();
0037   MiscalibReaderFromXMLEcalEndcap endcapreader(map);
0038   if (!fileName.empty())
0039     endcapreader.parseXMLMiscalibFile(fileName);
0040   EcalIntercalibConstants* constants = new EcalIntercalibConstants(map.get());
0041   const EcalIntercalibConstantMap& imap = constants->getMap();
0042 
0043   TH1F coeffDistr("coeffDistrEE", "coeffDistrEE", 500, 0, 2);
0044   TH2F coeffMap("coeffMapEE", "coeffMapEE", 101, 0, 101, 101, 0, 101);
0045   coeffMap.SetStats(false);
0046 
0047   // ECAL barrel
0048   for (int ix = 1; ix <= 100; ++ix)
0049     for (int iy = 1; iy <= 100; ++iy) {
0050       int rad = static_cast<int>(sqrt((ix - 50) * (ix - 50) + (iy - 50) * (iy - 50)));
0051       if (rad < EEradStart || rad > EEradEnd)
0052         continue;
0053       double phiTemp = atan2(iy - 50, ix - 50);
0054       if (phiTemp < 0)
0055         phiTemp += 2 * PI_GRECO;
0056       int phi = static_cast<int>(phiTemp * 180 / PI_GRECO);
0057       if (phi < EEphiStart || phi > EEphiEnd)
0058         continue;
0059 
0060       if (!EEDetId::validDetId(ix, iy, 1))
0061         continue;
0062       EEDetId det = EEDetId(ix, iy, 1, EEDetId::XYMODE);
0063       double coeff = (*(imap.find(det.rawId())));
0064       std::cerr << "found coeff " << ix << " " << iy << " " << coeff << std::endl;
0065       coeffDistr.Fill(coeff);
0066       coeffMap.Fill(ix, iy, coeff);
0067     }  // ECAL barrel
0068 
0069   gROOT->SetStyle("Plain");
0070   gStyle->SetPalette(1);
0071   TCanvas c1;
0072   c1.SetGrid();
0073 
0074   coeffMap.GetZaxis()->SetRangeUser(0, 2);
0075   coeffMap.GetXaxis()->SetTitle("ix");
0076   coeffMap.GetYaxis()->SetTitle("iy");
0077   coeffMap.Draw("COLZ");
0078   c1.Print("coeffMapEE.gif", "gif");
0079   c1.SetLogy();
0080   coeffDistr.GetXaxis()->SetTitle("calib coeff EE");
0081   coeffDistr.SetFillColor(8);
0082   coeffDistr.Draw();
0083   c1.Print("coeffDistrEE.gif", "gif");
0084 
0085   TFile out("coeffEE.root", "recreate");
0086   coeffDistr.Write();
0087   coeffMap.Write();
0088   out.Close();
0089 }