Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:10:46

0001 #include "DQM/L1TMonitor/interface/L1TStage2uGTCaloLayer2Comp.h"
0002 
0003 L1TStage2uGTCaloLayer2Comp::L1TStage2uGTCaloLayer2Comp(const edm::ParameterSet& ps)
0004     : monitorDir(ps.getUntrackedParameter<std::string>("monitorDir", "")),
0005       collection1Title(ps.getUntrackedParameter<std::string>("collection1Title")),
0006       collection2Title(ps.getUntrackedParameter<std::string>("collection2Title")),
0007       JetCollection1(consumes<l1t::JetBxCollection>(ps.getParameter<edm::InputTag>("JetCollection1"))),
0008       JetCollection2(consumes<l1t::JetBxCollection>(ps.getParameter<edm::InputTag>("JetCollection2"))),
0009       EGammaCollection1(consumes<l1t::EGammaBxCollection>(ps.getParameter<edm::InputTag>("EGammaCollection1"))),
0010       EGammaCollection2(consumes<l1t::EGammaBxCollection>(ps.getParameter<edm::InputTag>("EGammaCollection2"))),
0011       TauCollection1(consumes<l1t::TauBxCollection>(ps.getParameter<edm::InputTag>("TauCollection1"))),
0012       TauCollection2(consumes<l1t::TauBxCollection>(ps.getParameter<edm::InputTag>("TauCollection2"))),
0013       EtSumCollection1(consumes<l1t::EtSumBxCollection>(ps.getParameter<edm::InputTag>("EtSumCollection1"))),
0014       EtSumCollection2(consumes<l1t::EtSumBxCollection>(ps.getParameter<edm::InputTag>("EtSumCollection2"))),
0015       verbose(ps.getUntrackedParameter<bool>("verbose", false)) {}
0016 
0017 void L1TStage2uGTCaloLayer2Comp::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const&, edm::EventSetup const&) {
0018   ibooker.setCurrentFolder(monitorDir);
0019 
0020   // the index of the first bin in histogram should match value of first enum
0021   comparisonNum =
0022       ibooker.book1D("errorSummaryNum",
0023                      collection1Title + " vs " + collection2Title + " Comparison - Numerator (# Disagreements)",
0024                      15,
0025                      1,
0026                      16);
0027 
0028   comparisonNum->setBinLabel(EVENTBAD, "# bad evts");
0029   comparisonNum->setBinLabel(EVENTBADJETCOL, "# evts w/ bad jet col size");
0030   comparisonNum->setBinLabel(EVENTBADEGCOL, "# evts w/ bad eg col size");
0031   comparisonNum->setBinLabel(EVENTBADTAUCOL, "# evts w/ bad tau col size");
0032   comparisonNum->setBinLabel(EVENTBADSUMCOL, "# evts w/ bad sum col size");
0033   comparisonNum->setBinLabel(JETBADET, "# jets bad Et");
0034   comparisonNum->setBinLabel(JETBADPHI, "# jets bad phi");
0035   comparisonNum->setBinLabel(JETBADETA, "# jets bad eta");
0036   comparisonNum->setBinLabel(EGBADET, "# egs bad Et");
0037   comparisonNum->setBinLabel(EGBADPHI, "# egs bad phi");
0038   comparisonNum->setBinLabel(EGBADETA, "# egs bad eta");
0039   comparisonNum->setBinLabel(TAUBADET, "# taus bad Et");
0040   comparisonNum->setBinLabel(TAUBADPHI, "# taus bad phi");
0041   comparisonNum->setBinLabel(TAUBADETA, "# taus bad eta");
0042   comparisonNum->setBinLabel(BADSUM, "# bad sums");
0043 
0044   comparisonDenum =
0045       ibooker.book1D("errorSummaryDen",
0046                      collection1Title + " vs " + collection2Title + " Comparison - Denominator (# Objects)",
0047                      15,
0048                      1,
0049                      16);
0050 
0051   comparisonDenum->setBinLabel(EVENTS1, "# evts");
0052   comparisonDenum->setBinLabel(EVENTS2, "# evts");
0053   comparisonDenum->setBinLabel(EVENTS3, "# evts");
0054   comparisonDenum->setBinLabel(EVENTS4, "# evts");
0055   comparisonDenum->setBinLabel(EVENTS5, "# evts");
0056   comparisonDenum->setBinLabel(JETS1, "# jets");
0057   comparisonDenum->setBinLabel(JETS2, "# jets");
0058   comparisonDenum->setBinLabel(JETS3, "# jets");
0059   comparisonDenum->setBinLabel(EGS1, "# egs");
0060   comparisonDenum->setBinLabel(EGS2, "# egs");
0061   comparisonDenum->setBinLabel(EGS3, "# egs");
0062   comparisonDenum->setBinLabel(TAUS1, "# taus");
0063   comparisonDenum->setBinLabel(TAUS2, "# taus");
0064   comparisonDenum->setBinLabel(TAUS3, "# taus");
0065   comparisonDenum->setBinLabel(SUMS, "# sums");
0066   // Setting canExtend to false is needed to get the correct behaviour when running multithreaded.
0067   // Otherwise, when merging the histgrams of the threads, TH1::Merge sums bins that have the same label in one bin.
0068   // This needs to come after the calls to setBinLabel.
0069   comparisonDenum->getTH1F()->GetXaxis()->SetCanExtend(false);
0070 }
0071 void L1TStage2uGTCaloLayer2Comp::analyze(const edm::Event& e, const edm::EventSetup& c) {
0072   // define collections to hold lists of objects in event
0073   edm::Handle<l1t::JetBxCollection> jetCol1;
0074   edm::Handle<l1t::JetBxCollection> jetCol2;
0075   edm::Handle<l1t::EGammaBxCollection> egCol1;
0076   edm::Handle<l1t::EGammaBxCollection> egCol2;
0077   edm::Handle<l1t::TauBxCollection> tauCol1;
0078   edm::Handle<l1t::TauBxCollection> tauCol2;
0079   edm::Handle<l1t::EtSumBxCollection> sumCol1;
0080   edm::Handle<l1t::EtSumBxCollection> sumCol2;
0081 
0082   // map event contents to above collections
0083   e.getByToken(JetCollection1, jetCol1);
0084   e.getByToken(JetCollection2, jetCol2);
0085   e.getByToken(EGammaCollection1, egCol1);
0086   e.getByToken(EGammaCollection2, egCol2);
0087   e.getByToken(TauCollection1, tauCol1);
0088   e.getByToken(TauCollection2, tauCol2);
0089   e.getByToken(EtSumCollection1, sumCol1);
0090   e.getByToken(EtSumCollection2, sumCol2);
0091 
0092   bool eventGood = true;
0093 
0094   if (!compareJets(jetCol1, jetCol2)) {
0095     eventGood = false;
0096   }
0097 
0098   if (!compareEGs(egCol1, egCol2)) {
0099     eventGood = false;
0100   }
0101 
0102   if (!compareTaus(tauCol1, tauCol2)) {
0103     eventGood = false;
0104   }
0105 
0106   if (!compareSums(sumCol1, sumCol2)) {
0107     eventGood = false;
0108   }
0109 
0110   if (!eventGood) {
0111     comparisonNum->Fill(EVENTBAD);
0112   }
0113 
0114   comparisonDenum->Fill(EVENTS1);
0115   comparisonDenum->Fill(EVENTS2);
0116   comparisonDenum->Fill(EVENTS3);
0117   comparisonDenum->Fill(EVENTS4);
0118   comparisonDenum->Fill(EVENTS5);
0119 }
0120 
0121 // comparison method for jets
0122 bool L1TStage2uGTCaloLayer2Comp::compareJets(const edm::Handle<l1t::JetBxCollection>& col1,
0123                                              const edm::Handle<l1t::JetBxCollection>& col2) {
0124   bool eventGood = true;
0125 
0126   l1t::JetBxCollection::const_iterator col1It = col1->begin();
0127   l1t::JetBxCollection::const_iterator col2It = col2->begin();
0128 
0129   // process jets
0130   if (col1->size() != col2->size()) {
0131     comparisonNum->Fill(EVENTBADJETCOL);
0132     return false;
0133   }
0134 
0135   int nJets = 0;
0136   if (col1It != col1->end() || col2It != col2->end()) {
0137     while (true) {
0138       ++nJets;
0139 
0140       // object pt mismatch
0141       if (col1It->hwPt() != col2It->hwPt()) {
0142         comparisonNum->Fill(JETBADET);
0143         eventGood = false;
0144       }
0145 
0146       // object position mismatch (phi)
0147       if (col1It->hwPhi() != col2It->hwPhi()) {
0148         comparisonNum->Fill(JETBADPHI);
0149         eventGood = false;
0150       }
0151 
0152       // object position mismatch (eta)
0153       if (col1It->hwEta() != col2It->hwEta()) {
0154         comparisonNum->Fill(JETBADETA);
0155         eventGood = false;
0156       }
0157 
0158       // keep track of jets
0159       comparisonDenum->Fill(JETS1);
0160       comparisonDenum->Fill(JETS2);
0161       comparisonDenum->Fill(JETS3);
0162 
0163       // increment position of pointers
0164       ++col1It;
0165       ++col2It;
0166 
0167       if (col1It == col1->end() || col2It == col2->end())
0168         break;
0169     }
0170   } else {
0171     if (col1->size() != 0 || col2->size() != 0) {
0172       comparisonNum->Fill(EVENTBADJETCOL);
0173       return false;
0174     }
0175   }
0176 
0177   // return a boolean that states whether the jet data in the event is in
0178   // agreement
0179   return eventGood;
0180 }
0181 
0182 // comparison method for e/gammas
0183 bool L1TStage2uGTCaloLayer2Comp::compareEGs(const edm::Handle<l1t::EGammaBxCollection>& col1,
0184                                             const edm::Handle<l1t::EGammaBxCollection>& col2) {
0185   bool eventGood = true;
0186 
0187   l1t::EGammaBxCollection::const_iterator col1It = col1->begin();
0188   l1t::EGammaBxCollection::const_iterator col2It = col2->begin();
0189 
0190   // check length of collections
0191   if (col1->size() != col2->size()) {
0192     comparisonNum->Fill(EVENTBADEGCOL);
0193     return false;
0194   }
0195 
0196   // processing continues only of length of object collections is the same
0197   if (col1It != col1->end() || col2It != col2->end()) {
0198     while (true) {
0199       // object pt mismatch
0200       if (col1It->hwPt() != col2It->hwPt()) {
0201         comparisonNum->Fill(EGBADET);
0202         eventGood = false;
0203       }
0204 
0205       // object position mismatch (phi)
0206       if (col1It->hwPhi() != col2It->hwPhi()) {
0207         comparisonNum->Fill(EGBADPHI);
0208         eventGood = false;
0209       }
0210 
0211       // object position mismatch (eta)
0212       if (col1It->hwEta() != col2It->hwEta()) {
0213         comparisonNum->Fill(EGBADETA);
0214         eventGood = false;
0215       }
0216 
0217       // keep track of number of objects
0218       comparisonDenum->Fill(EGS1);
0219       comparisonDenum->Fill(EGS2);
0220       comparisonDenum->Fill(EGS3);
0221 
0222       // increment position of pointers
0223       ++col1It;
0224       ++col2It;
0225 
0226       if (col1It == col1->end() || col2It == col2->end())
0227         break;
0228     }
0229   } else {
0230     if (col1->size() != 0 || col2->size() != 0) {
0231       comparisonNum->Fill(EVENTBADEGCOL);
0232       return false;
0233     }
0234   }
0235 
0236   // return a boolean that states whether the eg data in the event is in
0237   // agreement
0238   return eventGood;
0239 }
0240 
0241 // comparison method for taus
0242 bool L1TStage2uGTCaloLayer2Comp::compareTaus(const edm::Handle<l1t::TauBxCollection>& col1,
0243                                              const edm::Handle<l1t::TauBxCollection>& col2) {
0244   bool eventGood = true;
0245 
0246   l1t::TauBxCollection::const_iterator col1It = col1->begin();
0247   l1t::TauBxCollection::const_iterator col2It = col2->begin();
0248 
0249   // check length of collections
0250   if (col1->size() != col2->size()) {
0251     comparisonNum->Fill(EVENTBADTAUCOL);
0252     return false;
0253   }
0254 
0255   // processing continues only of length of object collections is the same
0256   if (col1It != col1->end() || col2It != col2->end()) {
0257     while (true) {
0258       // object Et mismatch
0259       if (col1It->hwPt() != col2It->hwPt()) {
0260         comparisonNum->Fill(TAUBADET);
0261         eventGood = false;
0262       }
0263 
0264       // object position mismatch (phi)
0265       if (col1It->hwPhi() != col2It->hwPhi()) {
0266         comparisonNum->Fill(TAUBADPHI);
0267         eventGood = false;
0268       }
0269 
0270       // object position mismatch (eta)
0271       if (col1It->hwEta() != col2It->hwEta()) {
0272         comparisonNum->Fill(TAUBADETA);
0273         eventGood = false;
0274       }
0275 
0276       // keep track of number of objects
0277       comparisonDenum->Fill(TAUS1);
0278       comparisonDenum->Fill(TAUS2);
0279       comparisonDenum->Fill(TAUS3);
0280 
0281       // increment position of pointers
0282       ++col1It;
0283       ++col2It;
0284 
0285       if (col1It == col1->end() || col2It == col2->end())
0286         break;
0287     }
0288   } else {
0289     if (col1->size() != 0 || col2->size() != 0) {
0290       comparisonNum->Fill(EVENTBADTAUCOL);
0291       return false;
0292     }
0293   }
0294 
0295   // return a boolean that states whether the tau data in the event is in
0296   // agreement
0297   return eventGood;
0298 }
0299 
0300 // comparison method for sums
0301 bool L1TStage2uGTCaloLayer2Comp::compareSums(const edm::Handle<l1t::EtSumBxCollection>& col1,
0302                                              const edm::Handle<l1t::EtSumBxCollection>& col2) {
0303   bool eventGood = true;
0304 
0305   double col1Et = 0;
0306   double col2Et = 0;
0307   double col1Phi = 0;
0308   double col2Phi = 0;
0309 
0310   // if the calol2 or ugt collections have different size, mark the event as
0311   // bad (this should never occur in normal running)
0312   if (col1->size() != col2->size()) {
0313     comparisonNum->Fill(EVENTBADSUMCOL);
0314     return false;
0315   }
0316 
0317   l1t::EtSumBxCollection::const_iterator col1It = col1->begin();
0318   l1t::EtSumBxCollection::const_iterator col2It = col2->begin();
0319 
0320   while (col1It != col1->end() && col2It != col2->end()) {
0321     // ETT, ETTEM, HTT, TowCnt, MBHFP0, MBHFM0, MBHFP1 or MBHFM1
0322     if ((l1t::EtSum::EtSumType::kTotalEt == col1It->getType()) ||      // ETT
0323         (l1t::EtSum::EtSumType::kTotalEtEm == col1It->getType()) ||    // ETTEM
0324         (l1t::EtSum::EtSumType::kTotalHt == col1It->getType()) ||      // HTT
0325         (l1t::EtSum::EtSumType::kTowerCount == col1It->getType()) ||   // TowCnt
0326         (l1t::EtSum::EtSumType::kMinBiasHFP0 == col1It->getType()) ||  // MBHFP0
0327         (l1t::EtSum::EtSumType::kMinBiasHFM0 == col1It->getType()) ||  // MBHFM0
0328         (l1t::EtSum::EtSumType::kMinBiasHFP1 == col1It->getType()) ||  // MBHFP1
0329         (l1t::EtSum::EtSumType::kMinBiasHFM1 == col1It->getType())) {  // MBHFM1
0330 
0331       col1Et = col1It->hwPt();
0332       col2Et = col2It->hwPt();
0333 
0334       if (col1Et != col2Et) {
0335         eventGood = false;
0336         comparisonNum->Fill(BADSUM);
0337       }
0338 
0339       // update sum counters
0340       comparisonDenum->Fill(SUMS);
0341     }
0342 
0343     // MET, METHF, MHT or MHTHF
0344     if ((l1t::EtSum::EtSumType::kMissingEt == col1It->getType()) ||    // MET
0345         (l1t::EtSum::EtSumType::kMissingEtHF == col1It->getType()) ||  // METHF
0346         (l1t::EtSum::EtSumType::kMissingHt == col1It->getType()) ||    // MHT
0347         (l1t::EtSum::EtSumType::kMissingHtHF == col1It->getType())) {  // MHTHF
0348 
0349       col1Et = col1It->hwPt();
0350       col2Et = col2It->hwPt();
0351 
0352       col1Phi = col1It->hwPhi();
0353       col2Phi = col2It->hwPhi();
0354 
0355       if ((col1Et != col2Et) || (col1Phi != col2Phi)) {
0356         eventGood = false;
0357         comparisonNum->Fill(BADSUM);
0358       }
0359 
0360       // update sum counters
0361       comparisonDenum->Fill(SUMS);
0362     }
0363 
0364     ++col1It;
0365     ++col2It;
0366   }
0367 
0368   // return a boolean that states whether the sum data in the event is in
0369   // agreement
0370   return eventGood;
0371 }