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 "TH2.h"
0015 #include "TH1.h"
0016 #include "TFile.h"
0017 #include "TROOT.h"
0018 #include "TStyle.h"
0019 #include "TCanvas.h"
0020 
0021 int main(int argc, char* argv[]) {
0022   std::string fileName = argv[1];
0023   std::cerr << "parsing coeff file: " << fileName << std::endl;
0024 
0025   CaloMiscalibMapEcal map;
0026   map.prefillMap();
0027   MiscalibReaderFromXMLEcalBarrel barrelreader(map);
0028   if (!fileName.empty())
0029     barrelreader.parseXMLMiscalibFile(fileName);
0030   EcalIntercalibConstants* constants = new EcalIntercalibConstants(map.get());
0031   const EcalIntercalibConstantMap& imap = constants->getMap();
0032 
0033   TH1F coeffDistr("coeffDistrEB", "coeffDistrEB", 500, 0, 2);
0034   TH2F coeffMap("coeffMapEB", "coeffMapEB", 171, -85, 86, 360, 1, 361);
0035   coeffMap.SetStats(false);
0036 
0037   // ECAL barrel

0038   for (int ieta = -85; ieta <= 85; ++ieta)
0039     for (int iphi = 1; iphi <= 360; ++iphi) {
0040       if (!EBDetId::validDetId(ieta, iphi))
0041         continue;
0042       EBDetId det = EBDetId(ieta, iphi, EBDetId::ETAPHIMODE);
0043       double coeff = (*(imap.find(det.rawId())));
0044       coeffDistr.Fill(coeff);
0045       coeffMap.Fill(ieta, iphi, coeff);
0046     }  // ECAL barrel

0047 
0048   gROOT->SetStyle("Plain");
0049   gStyle->SetPalette(1);
0050   TCanvas c1;
0051   c1.SetGrid();
0052 
0053   coeffMap.GetZaxis()->SetRangeUser(0, 2);
0054   coeffMap.GetXaxis()->SetTitle("eta");
0055   coeffMap.GetYaxis()->SetTitle("phi");
0056   coeffMap.Draw("COLZ");
0057   c1.Print("coeffMapEB.gif", "gif");
0058   c1.SetLogy();
0059   coeffDistr.GetXaxis()->SetTitle("calib coeff");
0060   coeffDistr.SetFillColor(8);
0061   coeffDistr.Draw();
0062   c1.Print("coeffDistrEB.gif", "gif");
0063 
0064   TFile out("coeffEB.root", "recreate");
0065   coeffDistr.Write();
0066   coeffMap.Write();
0067   out.Close();
0068 }