File indexing completed on 2024-04-06 11:58:43
0001
0002 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0003
0004 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
0005 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0006 #include "DataFormats/DetId/interface/DetId.h"
0007 #include "CondFormats/EcalObjects/interface/EcalIntercalibConstants.h"
0008 #include "CondFormats/DataRecord/interface/EcalIntercalibConstantsRcd.h"
0009 #include "Calibration/Tools/interface/calibXMLwriter.h"
0010 #include "Calibration/Tools/interface/CalibrationCluster.h"
0011 #include "Calibration/Tools/interface/CalibElectron.h"
0012 #include "Calibration/Tools/interface/HouseholderDecomposition.h"
0013 #include "Calibration/Tools/interface/MinL3Algorithm.h"
0014 #include "Calibration/EcalCalibAlgos/interface/ZeePlots.h"
0015 #include "Calibration/EcalCalibAlgos/interface/ZeeKinematicTools.h"
0016 #include "DataFormats/EgammaCandidates/interface/Electron.h"
0017 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
0018 #include "DataFormats/TrackReco/interface/Track.h"
0019 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0020 #include "DataFormats/TrackReco/interface/TrackExtraFwd.h"
0021 #include "TFile.h"
0022 #include "TH1.h"
0023 #include "TH2.h"
0024 #include "TF1.h"
0025 #include "TRandom.h"
0026
0027 #include <iostream>
0028 #include <string>
0029 #include <stdexcept>
0030 #include <vector>
0031
0032 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
0033
0034 ZeePlots::ZeePlots(const char* fileName) {
0035 fileName_ = fileName;
0036 file_ = new TFile(fileName_, "RECREATE");
0037 }
0038
0039 ZeePlots::~ZeePlots() {
0040 file_->Close();
0041
0042 delete file_;
0043 }
0044
0045
0046
0047 void ZeePlots::openFile() { file_->cd(); }
0048
0049
0050 void ZeePlots::bookZMCHistograms() {
0051 file_->cd();
0052
0053 h1_gen_ZMass_ = new TH1F("gen_ZMass", "Generated Z mass", 200, 0., 150.);
0054 h1_gen_ZMass_->SetXTitle("gen_ZMass (GeV)");
0055 h1_gen_ZMass_->SetYTitle("events");
0056
0057 h1_gen_ZEta_ = new TH1F("gen_ZEta", "Eta of gen Z", 200, -6., 6.);
0058 h1_gen_ZEta_->SetXTitle("#eta");
0059 h1_gen_ZEta_->SetYTitle("events");
0060
0061 h1_gen_ZPhi_ = new TH1F("gen_ZPhi", "Phi of gen Z", 200, -4., 4.);
0062 h1_gen_ZPhi_->SetXTitle("#phi");
0063 h1_gen_ZPhi_->SetYTitle("events");
0064
0065 h1_gen_ZRapidity_ = new TH1F("gen_ZRapidity", "Rapidity of gen Z", 200, -6., 6.);
0066 h1_gen_ZRapidity_->SetXTitle("Y");
0067 h1_gen_ZRapidity_->SetYTitle("events");
0068
0069 h1_gen_ZPt_ = new TH1F("gen_ZPt", "Pt of gen Z", 200, 0., 100.);
0070 h1_gen_ZPt_->SetXTitle("p_{T} (GeV/c)");
0071 h1_gen_ZPt_->SetYTitle("events");
0072 }
0073
0074 void ZeePlots::bookZHistograms() {
0075 file_->cd();
0076
0077 h1_reco_ZEta_ = new TH1F("reco_ZEta", "Eta of reco Z", 200, -6., 6.);
0078 h1_reco_ZEta_->SetXTitle("#eta");
0079 h1_reco_ZEta_->SetYTitle("events");
0080
0081 h1_reco_ZTheta_ = new TH1F("reco_ZTheta", "Theta of reco Z", 200, 0., 4.);
0082 h1_reco_ZTheta_->SetXTitle("#theta");
0083 h1_reco_ZTheta_->SetYTitle("events");
0084
0085 h1_reco_ZRapidity_ = new TH1F("reco_ZRapidity", "Rapidity of reco Z", 200, -6., 6.);
0086 h1_reco_ZRapidity_->SetXTitle("Y");
0087 h1_reco_ZRapidity_->SetYTitle("events");
0088
0089 h1_reco_ZPhi_ = new TH1F("reco_ZPhi", "Phi of reco Z", 100, -4., 4.);
0090 h1_reco_ZPhi_->SetXTitle("#phi");
0091 h1_reco_ZPhi_->SetYTitle("events");
0092
0093 h1_reco_ZPt_ = new TH1F("reco_ZPt", "Pt of reco Z", 200, 0., 100.);
0094 h1_reco_ZPt_->SetXTitle("p_{T} (GeV/c)");
0095 h1_reco_ZPt_->SetYTitle("events");
0096 }
0097
0098
0099
0100 void ZeePlots::fillZInfo(std::pair<calib::CalibElectron*, calib::CalibElectron*> myZeeCandidate) {
0101 h1_reco_ZEta_->Fill(ZeeKinematicTools::calculateZEta(myZeeCandidate));
0102 h1_reco_ZTheta_->Fill(ZeeKinematicTools::calculateZTheta(myZeeCandidate));
0103 h1_reco_ZRapidity_->Fill(ZeeKinematicTools::calculateZRapidity(myZeeCandidate));
0104 h1_reco_ZPhi_->Fill(ZeeKinematicTools::calculateZPhi(myZeeCandidate));
0105 h1_reco_ZPt_->Fill(ZeeKinematicTools::calculateZPt(myZeeCandidate));
0106 }
0107
0108
0109
0110 void ZeePlots::writeZHistograms() {
0111 file_->cd();
0112
0113 h1_reco_ZEta_->Write();
0114 h1_reco_ZTheta_->Write();
0115 h1_reco_ZRapidity_->Write();
0116 h1_reco_ZPhi_->Write();
0117 h1_reco_ZPt_->Write();
0118 }
0119
0120
0121
0122 void ZeePlots::writeMCZHistograms() {
0123 file_->cd();
0124
0125 h1_gen_ZRapidity_->Write();
0126 h1_gen_ZPt_->Write();
0127 h1_gen_ZPhi_->Write();
0128 }
0129
0130
0131
0132 void ZeePlots::fillZMCInfo(const HepMC::GenEvent* myGenEvent) {
0133 file_->cd();
0134
0135 for (HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end();
0136 ++p) {
0137
0138 if ((*p)->pdg_id() == 23 && (*p)->status() == 2) {
0139 h1_gen_ZMass_->Fill((*p)->momentum().m());
0140 h1_gen_ZEta_->Fill((*p)->momentum().eta());
0141
0142 float genZ_Y =
0143 0.5 * log(((*p)->momentum().e() + (*p)->momentum().pz()) / ((*p)->momentum().e() - (*p)->momentum().pz()));
0144
0145 h1_gen_ZRapidity_->Fill(genZ_Y);
0146 h1_gen_ZPt_->Fill((*p)->momentum().perp());
0147 h1_gen_ZPhi_->Fill((*p)->momentum().phi());
0148 }
0149 }
0150
0151 return;
0152 }
0153
0154
0155
0156 void ZeePlots::bookEleMCHistograms() {
0157 file_->cd();
0158
0159 h1_mcEle_Energy_ = new TH1F("mcEleEnergy", "mc EleEnergy", 300, 0., 300.);
0160 h1_mcEle_Energy_->SetXTitle("E (GeV)");
0161 h1_mcEle_Energy_->SetYTitle("events");
0162
0163 h1_mcElePt_ = new TH1F("mcElePt", "p_{T} of MC electrons", 300, 0., 300.);
0164 h1_mcElePt_->SetXTitle("p_{T}(GeV/c)");
0165 h1_mcElePt_->SetYTitle("events");
0166
0167 h1_mcEleEta_ = new TH1F("mcEleEta", "Eta of MC electrons", 100, -4., 4.);
0168 h1_mcEleEta_->SetXTitle("#eta");
0169 h1_mcEleEta_->SetYTitle("events");
0170
0171 h1_mcElePhi_ = new TH1F("mcElePhi", "Phi of MC electrons", 100, -4., 4.);
0172 h1_mcElePhi_->SetXTitle("#phi");
0173 h1_mcElePhi_->SetYTitle("events");
0174 }
0175
0176
0177
0178 void ZeePlots::fillEleMCInfo(const HepMC::GenEvent* myGenEvent) {
0179 file_->cd();
0180
0181 for (HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end();
0182 ++p) {
0183 if (abs((*p)->pdg_id()) == 11) {
0184 h1_mcEle_Energy_->Fill((*p)->momentum().e());
0185 h1_mcElePt_->Fill((*p)->momentum().perp());
0186 h1_mcEleEta_->Fill((*p)->momentum().eta());
0187 h1_mcElePhi_->Fill((*p)->momentum().phi());
0188
0189 }
0190
0191 }
0192 }
0193
0194
0195 void ZeePlots::bookEleHistograms() {
0196 file_->cd();
0197
0198 h1_nEleReco_ = new TH1F("h1_nEleReco", "h1_nEleReco", 20, 0, 20);
0199 h1_nEleReco_->SetXTitle("Num. of reco electrons");
0200
0201 h1_recoEleEnergy_ = new TH1F("recoEleEnergy", "EleEnergy from SC", 300, 0., 300.);
0202 h1_recoEleEnergy_->SetXTitle("eleSCEnergy(GeV)");
0203 h1_recoEleEnergy_->SetYTitle("events");
0204
0205 h1_recoElePt_ = new TH1F("recoElePt", "p_{T} of reco electrons", 300, 0., 300.);
0206 h1_recoElePt_->SetXTitle("p_{T}(GeV/c)");
0207 h1_recoElePt_->SetYTitle("events");
0208
0209 h1_recoEleEta_ = new TH1F("recoEleEta", "Eta of reco electrons", 100, -4., 4.);
0210 h1_recoEleEta_->SetXTitle("#eta");
0211 h1_recoEleEta_->SetYTitle("events");
0212
0213 h1_recoElePhi_ = new TH1F("recoElePhi", "Phi of reco electrons", 100, -4., 4.);
0214 h1_recoElePhi_->SetXTitle("#phi");
0215 h1_recoElePhi_->SetYTitle("events");
0216 }
0217
0218
0219
0220 void ZeePlots::fillEleInfo(const reco::GsfElectronCollection* electronCollection) {
0221 file_->cd();
0222
0223 h1_nEleReco_->Fill(electronCollection->size());
0224
0225 for (reco::GsfElectronCollection::const_iterator eleIt = electronCollection->begin();
0226 eleIt != electronCollection->end();
0227 eleIt++) {
0228 file_->cd();
0229
0230 h1_recoEleEnergy_->Fill(eleIt->superCluster()->energy());
0231 h1_recoElePt_->Fill(eleIt->pt());
0232 h1_recoEleEta_->Fill(eleIt->eta());
0233 h1_recoElePhi_->Fill(eleIt->phi());
0234
0235 }
0236 }
0237
0238
0239
0240 void ZeePlots::writeEleHistograms() {
0241 file_->cd();
0242
0243 std::cout << "Start with ZeePlots::writeEleHistograms(), done file_->cd(); " << std::endl;
0244
0245 h1_recoEleEnergy_->Write();
0246 h1_recoElePt_->Write();
0247 h1_recoEleEta_->Write();
0248 h1_recoElePhi_->Write();
0249
0250 std::cout << "Done with ZeePlots::writeEleHistograms() " << std::endl;
0251 }
0252
0253
0254
0255 void ZeePlots::writeMCEleHistograms() {
0256 file_->cd();
0257
0258 std::cout << "Start with ZeePlots::writeMCEleHistograms(), done file_->cd(); " << std::endl;
0259
0260 h1_mcEle_Energy_->Write();
0261 h1_mcElePt_->Write();
0262 h1_mcEleEta_->Write();
0263 h1_mcElePhi_->Write();
0264
0265 std::cout << "Done with ZeePlots::writeMCEleHistograms() " << std::endl;
0266 }
0267
0268
0269
0270 void ZeePlots::bookHLTHistograms() {
0271 file_->cd();
0272
0273 h1_FiredTriggers_ = new TH1F("h1_FiredTriggers", "h1_FiredTriggers", 5, 0, 5);
0274
0275 h1_HLTVisitedEvents_ = new TH1F("h1_HLTVisitedEvents", "h1_HLTVisitedEvents", 5, 0, 5);
0276
0277 h1_HLT1Electron_FiredEvents_ = new TH1F("h1_HLT1Electron_FiredEvents", "h1_HLT1Electron_FiredEvents", 5, 0, 5);
0278 h1_HLT2Electron_FiredEvents_ = new TH1F("h1_HLT2Electron_FiredEvents", "h1_HLT2Electron_FiredEvents", 5, 0, 5);
0279 h1_HLT2ElectronRelaxed_FiredEvents_ =
0280 new TH1F("h1_HLT2ElectronRelaxed_FiredEvents", "h1_HLT2ElectronRelaxed_FiredEvents", 5, 0, 5);
0281
0282 h1_HLT1Electron_HLT2Electron_FiredEvents_ =
0283 new TH1F("h1_HLT1Electron_HLT2Electron_FiredEvents", "h1_HLT1Electron_HLT2Electron_FiredEvents", 5, 0, 5);
0284 h1_HLT1Electron_HLT2ElectronRelaxed_FiredEvents_ = new TH1F(
0285 "h1_HLT1Electron_HLT2ElectronRelaxed_FiredEvents", "h1_HLT1Electron_HLT2ElectronRelaxed_FiredEvents", 5, 0, 5);
0286 h1_HLT2Electron_HLT2ElectronRelaxed_FiredEvents_ = new TH1F(
0287 "h1_HLT2Electron_HLT2ElectronRelaxed_FiredEvents", "h1_HLT2Electron_HLT2ElectronRelaxed_FiredEvents", 5, 0, 5);
0288
0289 h1_HLT1Electron_HLT2Electron_HLT2ElectronRelaxed_FiredEvents_ =
0290 new TH1F("h1_HLT1Electron_HLT2Electron_HLT2ElectronRelaxed_FiredEvents",
0291 "h1_HLT1Electron_HLT2Electron_HLT2ElectronRelaxed_FiredEvents",
0292 5,
0293 0,
0294 5);
0295 }
0296
0297
0298
0299 void ZeePlots::fillHLTInfo(edm::Handle<edm::TriggerResults> hltTriggerResultHandle) {
0300 file_->cd();
0301
0302 int hltCount = hltTriggerResultHandle->size();
0303
0304 bool aHLTResults[200] = {false};
0305
0306 for (int i = 0; i < hltCount; i++) {
0307 aHLTResults[i] = hltTriggerResultHandle->accept(i);
0308 if (aHLTResults[i])
0309 h1_FiredTriggers_->Fill(i);
0310
0311
0312
0313
0314 }
0315
0316 h1_HLTVisitedEvents_->Fill(1);
0317
0318 if (aHLTResults[32] && !aHLTResults[34] && !aHLTResults[35])
0319 h1_HLT1Electron_FiredEvents_->Fill(1);
0320
0321 if (aHLTResults[34] && !aHLTResults[32] && !aHLTResults[35])
0322 h1_HLT2Electron_FiredEvents_->Fill(1);
0323
0324 if (aHLTResults[35] && !aHLTResults[32] && !aHLTResults[34])
0325 h1_HLT2ElectronRelaxed_FiredEvents_->Fill(1);
0326
0327 if (aHLTResults[32] && aHLTResults[34] && !aHLTResults[35])
0328 h1_HLT1Electron_HLT2Electron_FiredEvents_->Fill(1);
0329
0330 if (aHLTResults[32] && aHLTResults[35] && !aHLTResults[34])
0331 h1_HLT1Electron_HLT2ElectronRelaxed_FiredEvents_->Fill(1);
0332
0333 if (aHLTResults[34] && aHLTResults[35] && !aHLTResults[32])
0334 h1_HLT2Electron_HLT2ElectronRelaxed_FiredEvents_->Fill(1);
0335
0336 if (aHLTResults[32] && aHLTResults[34] && aHLTResults[35])
0337 h1_HLT1Electron_HLT2Electron_HLT2ElectronRelaxed_FiredEvents_->Fill(1);
0338 }
0339
0340 void ZeePlots::fillEleClassesPlots(calib::CalibElectron* myEle) {
0341 int myClass = myEle->getRecoElectron()->classification();
0342
0343 float myEta = myEle->getRecoElectron()->eta();
0344
0345 if (myClass == 0 || myClass == 100)
0346 h1_occupancyVsEtaGold_->Fill(myEta);
0347
0348 std::cout << "[ZeePlots::fillEleClassesPlots]Done gold" << std::endl;
0349
0350 if (myClass == 40 || myClass == 140)
0351 h1_occupancyVsEtaCrack_->Fill(myEta);
0352
0353 std::cout << "[ZeePlots::fillEleClassesPlots]Done crack" << std::endl;
0354
0355 if ((myClass >= 30 && myClass <= 34) || (myClass >= 130 && myClass <= 134))
0356 h1_occupancyVsEtaShower_->Fill(myEta);
0357
0358 std::cout << "[ZeePlots::fillEleClassesPlots]Done shower" << std::endl;
0359
0360 if (myClass == 10 || myClass == 20 || myClass == 110 || myClass == 120)
0361 h1_occupancyVsEtaSilver_->Fill(myEta);
0362
0363 std::cout << "[ZeePlots::fillEleClassesPlots]Done" << std::endl;
0364 }
0365
0366 void ZeePlots::bookEleClassesPlots() {
0367 file_->cd();
0368
0369 h1_occupancyVsEtaGold_ = new TH1F("occupancyVsEtaGold", "occupancyVsEtaGold", 200, -4., 4.);
0370 h1_occupancyVsEtaGold_->SetYTitle("Electron statistics");
0371 h1_occupancyVsEtaGold_->SetXTitle("Eta channel");
0372
0373 h1_occupancyVsEtaSilver_ = new TH1F("occupancyVsEtaSilver", "occupancyVsEtaSilver", 200, -4., 4.);
0374 h1_occupancyVsEtaSilver_->SetYTitle("Electron statistics");
0375 h1_occupancyVsEtaSilver_->SetXTitle("Eta channel");
0376
0377 h1_occupancyVsEtaShower_ = new TH1F("occupancyVsEtaShower", "occupancyVsEtaShower", 200, -4., 4.);
0378 h1_occupancyVsEtaShower_->SetYTitle("Electron statistics");
0379 h1_occupancyVsEtaShower_->SetXTitle("Eta channel");
0380
0381 h1_occupancyVsEtaCrack_ = new TH1F("occupancyVsEtaCrack", "occupancyVsEtaCrack", 200, -4., 4.);
0382 h1_occupancyVsEtaCrack_->SetYTitle("Electron statistics");
0383 h1_occupancyVsEtaCrack_->SetXTitle("Eta channel");
0384 }
0385
0386 void ZeePlots::writeEleClassesPlots() {
0387 file_->cd();
0388
0389 h1_occupancyVsEtaGold_->Write();
0390 h1_occupancyVsEtaSilver_->Write();
0391 h1_occupancyVsEtaShower_->Write();
0392 h1_occupancyVsEtaCrack_->Write();
0393 }