Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:07:56

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   if (col1It != col1->end() || col2It != col2->end()) {
0136     while (true) {
0137       // object pt mismatch
0138       if (col1It->hwPt() != col2It->hwPt()) {
0139         comparisonNum->Fill(JETBADET);
0140         eventGood = false;
0141       }
0142 
0143       // object position mismatch (phi)
0144       if (col1It->hwPhi() != col2It->hwPhi()) {
0145         comparisonNum->Fill(JETBADPHI);
0146         eventGood = false;
0147       }
0148 
0149       // object position mismatch (eta)
0150       if (col1It->hwEta() != col2It->hwEta()) {
0151         comparisonNum->Fill(JETBADETA);
0152         eventGood = false;
0153       }
0154 
0155       // keep track of jets
0156       comparisonDenum->Fill(JETS1);
0157       comparisonDenum->Fill(JETS2);
0158       comparisonDenum->Fill(JETS3);
0159 
0160       // increment position of pointers
0161       ++col1It;
0162       ++col2It;
0163 
0164       if (col1It == col1->end() || col2It == col2->end())
0165         break;
0166     }
0167   } else {
0168     if (col1->size() != 0 || col2->size() != 0) {
0169       comparisonNum->Fill(EVENTBADJETCOL);
0170       return false;
0171     }
0172   }
0173 
0174   // return a boolean that states whether the jet data in the event is in
0175   // agreement
0176   return eventGood;
0177 }
0178 
0179 // comparison method for e/gammas
0180 bool L1TStage2uGTCaloLayer2Comp::compareEGs(const edm::Handle<l1t::EGammaBxCollection>& col1,
0181                                             const edm::Handle<l1t::EGammaBxCollection>& col2) {
0182   bool eventGood = true;
0183 
0184   l1t::EGammaBxCollection::const_iterator col1It = col1->begin();
0185   l1t::EGammaBxCollection::const_iterator col2It = col2->begin();
0186 
0187   // check length of collections
0188   if (col1->size() != col2->size()) {
0189     comparisonNum->Fill(EVENTBADEGCOL);
0190     return false;
0191   }
0192 
0193   // processing continues only of length of object collections is the same
0194   if (col1It != col1->end() || col2It != col2->end()) {
0195     while (true) {
0196       // object pt mismatch
0197       if (col1It->hwPt() != col2It->hwPt()) {
0198         comparisonNum->Fill(EGBADET);
0199         eventGood = false;
0200       }
0201 
0202       // object position mismatch (phi)
0203       if (col1It->hwPhi() != col2It->hwPhi()) {
0204         comparisonNum->Fill(EGBADPHI);
0205         eventGood = false;
0206       }
0207 
0208       // object position mismatch (eta)
0209       if (col1It->hwEta() != col2It->hwEta()) {
0210         comparisonNum->Fill(EGBADETA);
0211         eventGood = false;
0212       }
0213 
0214       // keep track of number of objects
0215       comparisonDenum->Fill(EGS1);
0216       comparisonDenum->Fill(EGS2);
0217       comparisonDenum->Fill(EGS3);
0218 
0219       // increment position of pointers
0220       ++col1It;
0221       ++col2It;
0222 
0223       if (col1It == col1->end() || col2It == col2->end())
0224         break;
0225     }
0226   } else {
0227     if (col1->size() != 0 || col2->size() != 0) {
0228       comparisonNum->Fill(EVENTBADEGCOL);
0229       return false;
0230     }
0231   }
0232 
0233   // return a boolean that states whether the eg data in the event is in
0234   // agreement
0235   return eventGood;
0236 }
0237 
0238 // comparison method for taus
0239 bool L1TStage2uGTCaloLayer2Comp::compareTaus(const edm::Handle<l1t::TauBxCollection>& col1,
0240                                              const edm::Handle<l1t::TauBxCollection>& col2) {
0241   bool eventGood = true;
0242 
0243   l1t::TauBxCollection::const_iterator col1It = col1->begin();
0244   l1t::TauBxCollection::const_iterator col2It = col2->begin();
0245 
0246   // check length of collections
0247   if (col1->size() != col2->size()) {
0248     comparisonNum->Fill(EVENTBADTAUCOL);
0249     return false;
0250   }
0251 
0252   // processing continues only of length of object collections is the same
0253   if (col1It != col1->end() || col2It != col2->end()) {
0254     while (true) {
0255       // object Et mismatch
0256       if (col1It->hwPt() != col2It->hwPt()) {
0257         comparisonNum->Fill(TAUBADET);
0258         eventGood = false;
0259       }
0260 
0261       // object position mismatch (phi)
0262       if (col1It->hwPhi() != col2It->hwPhi()) {
0263         comparisonNum->Fill(TAUBADPHI);
0264         eventGood = false;
0265       }
0266 
0267       // object position mismatch (eta)
0268       if (col1It->hwEta() != col2It->hwEta()) {
0269         comparisonNum->Fill(TAUBADETA);
0270         eventGood = false;
0271       }
0272 
0273       // keep track of number of objects
0274       comparisonDenum->Fill(TAUS1);
0275       comparisonDenum->Fill(TAUS2);
0276       comparisonDenum->Fill(TAUS3);
0277 
0278       // increment position of pointers
0279       ++col1It;
0280       ++col2It;
0281 
0282       if (col1It == col1->end() || col2It == col2->end())
0283         break;
0284     }
0285   } else {
0286     if (col1->size() != 0 || col2->size() != 0) {
0287       comparisonNum->Fill(EVENTBADTAUCOL);
0288       return false;
0289     }
0290   }
0291 
0292   // return a boolean that states whether the tau data in the event is in
0293   // agreement
0294   return eventGood;
0295 }
0296 
0297 // comparison method for sums
0298 bool L1TStage2uGTCaloLayer2Comp::compareSums(const edm::Handle<l1t::EtSumBxCollection>& col1,
0299                                              const edm::Handle<l1t::EtSumBxCollection>& col2) {
0300   bool eventGood = true;
0301 
0302   double col1Et = 0;
0303   double col2Et = 0;
0304   double col1Phi = 0;
0305   double col2Phi = 0;
0306 
0307   // if the calol2 or ugt collections have different size, mark the event as
0308   // bad (this should never occur in normal running)
0309   if (col1->size() != col2->size()) {
0310     comparisonNum->Fill(EVENTBADSUMCOL);
0311     return false;
0312   }
0313 
0314   l1t::EtSumBxCollection::const_iterator col1It = col1->begin();
0315   l1t::EtSumBxCollection::const_iterator col2It = col2->begin();
0316 
0317   while (col1It != col1->end() && col2It != col2->end()) {
0318     // ETT, ETTEM, HTT, TowCnt, MBHFP0, MBHFM0, MBHFP1 or MBHFM1
0319     if ((l1t::EtSum::EtSumType::kTotalEt == col1It->getType()) ||      // ETT
0320         (l1t::EtSum::EtSumType::kTotalEtEm == col1It->getType()) ||    // ETTEM
0321         (l1t::EtSum::EtSumType::kTotalHt == col1It->getType()) ||      // HTT
0322         (l1t::EtSum::EtSumType::kTowerCount == col1It->getType()) ||   // TowCnt
0323         (l1t::EtSum::EtSumType::kMinBiasHFP0 == col1It->getType()) ||  // MBHFP0
0324         (l1t::EtSum::EtSumType::kMinBiasHFM0 == col1It->getType()) ||  // MBHFM0
0325         (l1t::EtSum::EtSumType::kMinBiasHFP1 == col1It->getType()) ||  // MBHFP1
0326         (l1t::EtSum::EtSumType::kMinBiasHFM1 == col1It->getType())) {  // MBHFM1
0327 
0328       col1Et = col1It->hwPt();
0329       col2Et = col2It->hwPt();
0330 
0331       if (col1Et != col2Et) {
0332         eventGood = false;
0333         comparisonNum->Fill(BADSUM);
0334       }
0335 
0336       // update sum counters
0337       comparisonDenum->Fill(SUMS);
0338     }
0339 
0340     // MET, METHF, MHT or MHTHF
0341     if ((l1t::EtSum::EtSumType::kMissingEt == col1It->getType()) ||    // MET
0342         (l1t::EtSum::EtSumType::kMissingEtHF == col1It->getType()) ||  // METHF
0343         (l1t::EtSum::EtSumType::kMissingHt == col1It->getType()) ||    // MHT
0344         (l1t::EtSum::EtSumType::kMissingHtHF == col1It->getType())) {  // MHTHF
0345 
0346       col1Et = col1It->hwPt();
0347       col2Et = col2It->hwPt();
0348 
0349       col1Phi = col1It->hwPhi();
0350       col2Phi = col2It->hwPhi();
0351 
0352       if ((col1Et != col2Et) || (col1Phi != col2Phi)) {
0353         eventGood = false;
0354         comparisonNum->Fill(BADSUM);
0355       }
0356 
0357       // update sum counters
0358       comparisonDenum->Fill(SUMS);
0359     }
0360 
0361     ++col1It;
0362     ++col2It;
0363   }
0364 
0365   // return a boolean that states whether the sum data in the event is in
0366   // agreement
0367   return eventGood;
0368 }