Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DQM/L1TMonitor/interface/L1TdeStage2CaloLayer2.h"
0002 
0003 L1TdeStage2CaloLayer2::L1TdeStage2CaloLayer2(const edm::ParameterSet& ps)
0004     : monitorDir(ps.getUntrackedParameter<std::string>("monitorDir", "")),
0005       calol2JetCollectionData(
0006           consumes<l1t::JetBxCollection>(ps.getParameter<edm::InputTag>("calol2JetCollectionData"))),
0007       calol2JetCollectionEmul(
0008           consumes<l1t::JetBxCollection>(ps.getParameter<edm::InputTag>("calol2JetCollectionEmul"))),
0009       calol2EGammaCollectionData(
0010           consumes<l1t::EGammaBxCollection>(ps.getParameter<edm::InputTag>("calol2EGammaCollectionData"))),
0011       calol2EGammaCollectionEmul(
0012           consumes<l1t::EGammaBxCollection>(ps.getParameter<edm::InputTag>("calol2EGammaCollectionEmul"))),
0013       calol2TauCollectionData(
0014           consumes<l1t::TauBxCollection>(ps.getParameter<edm::InputTag>("calol2TauCollectionData"))),
0015       calol2TauCollectionEmul(
0016           consumes<l1t::TauBxCollection>(ps.getParameter<edm::InputTag>("calol2TauCollectionEmul"))),
0017       calol2EtSumCollectionData(
0018           consumes<l1t::EtSumBxCollection>(ps.getParameter<edm::InputTag>("calol2EtSumCollectionData"))),
0019       calol2EtSumCollectionEmul(
0020           consumes<l1t::EtSumBxCollection>(ps.getParameter<edm::InputTag>("calol2EtSumCollectionEmul"))),
0021       verbose(ps.getUntrackedParameter<bool>("verbose", false)),
0022       enable2DComp(ps.getUntrackedParameter<bool>("enable2DComp",
0023                                                   false))  // When true eta-phi comparison plots are also produced
0024 {}
0025 
0026 void L1TdeStage2CaloLayer2::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const&, edm::EventSetup const&) {
0027   // DQM directory to store histograms with problematic jets
0028   ibooker.setCurrentFolder(monitorDir + "/Problematic Jets candidates");
0029 
0030   jetEtData = ibooker.book1D("Problematic Data Jet iEt", "Jet iE_{T}", 1400, 0, 1399);
0031   jetEtaData = ibooker.book1D("Problematic Data Jet iEta", "Jet i#eta", 227, -113.5, 113.5);
0032   jetPhiData = ibooker.book1D("Problematic Data Jet iPhi", "Jet i#phi", 288, -0.5, 143.5);
0033   jetEtEmul = ibooker.book1D("Problematic Emul Jet iEt", "Jet iE_{T}", 1400, 0, 1399);
0034   jetEtaEmul = ibooker.book1D("Problematic Emul Jet iEta", "Jet i#eta", 227, -113.5, 113.5);
0035   jetPhiEmul = ibooker.book1D("Problematic Emul Jet iPhi", "Jet i#phi", 288, -0.5, 143.5);
0036   //if enable2DComp is true book also 2D eta-phi plots
0037   if (enable2DComp) {
0038     jet2DEtaPhiData =
0039         ibooker.book2D("Problematic Data Jet Eta - Phi", "Jet #eta - #phi map", 50, -5., 5., 25, -3.2, 3.2);
0040     jet2DEtaPhiData->setAxisTitle("#eta", 1);
0041     jet2DEtaPhiData->setAxisTitle("#phi", 2);
0042 
0043     jet2DEtaPhiEmul =
0044         ibooker.book2D("Problematic Emul Jet Eta - Phi", "Jet #eta - #phi map", 50, -5., 5., 25, -3.2, 3.2);
0045     jet2DEtaPhiEmul->setAxisTitle("#eta", 1);
0046     jet2DEtaPhiEmul->setAxisTitle("#phi", 2);
0047   }
0048 
0049   // DQM directory to store histograms with problematic e/gs
0050   ibooker.setCurrentFolder(monitorDir + "/Problematic EG candidates");
0051 
0052   egEtData = ibooker.book1D("Problematic Data Eg iEt", "Eg iE_{T}", 1400, 0, 1399);
0053   egEtaData = ibooker.book1D("Problematic Data Eg iEta", "Eg i#eta", 227, -113.5, 113.5);
0054   egPhiData = ibooker.book1D("Problematic Data Eg iPhi", "Eg i#phi", 288, -0.5, 143.5);
0055   egEtEmul = ibooker.book1D("Problematic Emul Eg iEt", "Eg iE_{T}", 1400, 0, 1399);
0056   egEtaEmul = ibooker.book1D("Problematic Emul Eg iEta", "Eg i#eta", 227, -113.5, 113.5);
0057   egPhiEmul = ibooker.book1D("Problematic Emul Eg iPhi", "Eg i#phi", 288, -0.5, 143.5);
0058   //if enable2DComp is true book also 2D eta-phi plots
0059   if (enable2DComp) {
0060     eg2DEtaPhiData = ibooker.book2D("Problematic Data Eg Eta - Phi", "Eg #eta - #phi map", 30, -3., 3., 25, -3.2, 3.2);
0061     eg2DEtaPhiData->setAxisTitle("#eta", 1);
0062     eg2DEtaPhiData->setAxisTitle("#phi", 2);
0063 
0064     eg2DEtaPhiEmul = ibooker.book2D("Problematic Emul Eg Eta - Phi", "Eg #eta - #phi map", 30, -3., 3., 25, -3.2, 3.2);
0065     eg2DEtaPhiEmul->setAxisTitle("#eta", 1);
0066     eg2DEtaPhiEmul->setAxisTitle("#phi", 2);
0067   }
0068   isoEgEtData = ibooker.book1D("Problematic Isolated Data Eg iEt", "Iso Eg iE_{T}", 1400, 0, 1399);
0069   isoEgEtaData = ibooker.book1D("Problematic Isolated Data Eg iEta", "Iso Eg i#eta", 227, -113.5, 113.5);
0070   isoEgPhiData = ibooker.book1D("Problematic Isolated Data Eg iPhi", "Iso Eg i#phi", 288, -0.5, 143.5);
0071   isoEgEtEmul = ibooker.book1D("Problematic Isolated Emul Eg iEt", "Iso Eg iE_{T}", 1400, 0, 1399);
0072   isoEgEtaEmul = ibooker.book1D("Problematic Isolated Emul Eg iEta", "Iso Eg i#eta", 227, -113.5, 113.5);
0073   isoEgPhiEmul = ibooker.book1D("Problematic Isolated Emul Eg iPhi", "Iso Eg i#phi", 288, -0.5, 143.5);
0074   // enable2DComp is true book also 2D eta-phi plots
0075   if (enable2DComp) {
0076     isoEg2DEtaPhiData =
0077         ibooker.book2D("Problematic Isolated Data Eg Eta - Phi", "Iso Eg #eta - #phi map", 30, -3., 3., 25, -3.2, 3.2);
0078     isoEg2DEtaPhiData->setAxisTitle("#eta", 1);
0079     isoEg2DEtaPhiData->setAxisTitle("#phi", 2);
0080 
0081     isoEg2DEtaPhiEmul =
0082         ibooker.book2D("Problematic Isolated Emul Eg Eta - Phi", "Iso Eg #eta - #phi map", 30, -3., 3., 25, -3.2, 3.2);
0083     isoEg2DEtaPhiEmul->setAxisTitle("#eta", 1);
0084     isoEg2DEtaPhiEmul->setAxisTitle("#phi", 2);
0085   }
0086   // DQM directory to store histograms with problematic taus
0087   ibooker.setCurrentFolder(monitorDir + "/Problematic Tau candidates");
0088 
0089   tauEtData = ibooker.book1D("Problematic Data Tau iEt", "Tau iE_{T}", 1400, 0, 1399);
0090   tauEtaData = ibooker.book1D("Problematic Data Tau iEta", "Tau i#eta", 227, -113.5, 113.5);
0091   tauPhiData = ibooker.book1D("Problematic Data Tau iPhi", "Tau i#phi", 288, -0.5, 143.5);
0092   tauEtEmul = ibooker.book1D("Problematic Emul Tau iEt", "Tau iE_{T}", 1400, 0, 1399);
0093   tauEtaEmul = ibooker.book1D("Problematic Emul Tau iEta", "Tau i#eta", 227, -113.5, 113.5);
0094   tauPhiEmul = ibooker.book1D("Problematic Emul Tau iPhi", "Tau i#phi", 288, -0.5, 143.5);
0095   // enable2DComp is true book also 2D eta-phi plots
0096   if (enable2DComp) {
0097     tau2DEtaPhiData =
0098         ibooker.book2D("Problematic Data Tau Eta - Phi", "Tau #eta - #phi map", 30, -3., 3., 25, -3.2, 3.2);
0099     tau2DEtaPhiData->setAxisTitle("#eta", 1);
0100     tau2DEtaPhiData->setAxisTitle("#phi", 2);
0101 
0102     tau2DEtaPhiEmul =
0103         ibooker.book2D("Problematic Emul Tau Eta - Phi", "Tau #eta - #phi map", 30, -3., 3., 25, -3.2, 3.2);
0104     tau2DEtaPhiEmul->setAxisTitle("#eta", 1);
0105     tau2DEtaPhiEmul->setAxisTitle("#phi", 2);
0106   }
0107   isoTauEtData = ibooker.book1D("Problematic Isolated Data Tau iEt", "Iso Tau iE_{T}", 1400, 0, 1399);
0108   isoTauEtaData = ibooker.book1D("Problematic Isolated Data Tau iEta", "Iso Tau i#eta", 227, -113.5, 113.5);
0109   isoTauPhiData = ibooker.book1D("Problematic Isolated Data Tau iPhi", "Iso Tau i#phi", 288, -0.5, 143.5);
0110   isoTauEtEmul = ibooker.book1D("Problematic Isolated Emul Tau iEt", "Iso Tau iE_{T}", 1400, 0, 1399);
0111   isoTauEtaEmul = ibooker.book1D("Problematic Isolated Emul Tau iEta", "Iso Tau i#eta", 227, -113.5, 113.5);
0112   isoTauPhiEmul = ibooker.book1D("Problematic Isolated Emul Tau iPhi", "Iso Tau i#phi", 288, -0.5, 143.5);
0113   // enable2DComp is true book also 2D eta-phi plots
0114   if (enable2DComp) {
0115     isoTau2DEtaPhiData = ibooker.book2D(
0116         "Problematic Isolated Data Tau Eta - Phi", "Iso Tau #eta - #phi map", 30, -3., 3., 25, -3.2, 3.2);
0117     isoTau2DEtaPhiData->setAxisTitle("#eta", 1);
0118     isoTau2DEtaPhiData->setAxisTitle("#phi", 2);
0119 
0120     isoTau2DEtaPhiEmul = ibooker.book2D(
0121         "Problematic Isolated Emul Tau Eta - Phi", "Iso Tau #eta - #phi map", 30, -3., 3., 25, -3.2, 3.2);
0122     isoTau2DEtaPhiEmul->setAxisTitle("#eta", 1);
0123     isoTau2DEtaPhiEmul->setAxisTitle("#phi", 2);
0124   }
0125   // DQM directory to store histograms with problematic sums
0126   ibooker.setCurrentFolder(monitorDir + "/Problematic Sums");
0127 
0128   // book ETT type sums
0129   ettData = ibooker.book1D("Problematic ETT Sum - Data", "ETT iE_{T}", 7000, -0.5, 6999.5);
0130   ettEmul = ibooker.book1D("Problematic ETT Sum - Emulator", "ETT iE_{T}", 7000, -0.5, 6999.5);
0131   ettHFData = ibooker.book1D("Problematic ETTHF Sum - Data", "ETTHF iE_{T}", 7000, -0.5, 6999.5);
0132   ettHFEmul = ibooker.book1D("Problematic ETTHF Sum - Emulator", "ETTHF iE_{T}", 7000, -0.5, 6999.5);
0133   ettEmData = ibooker.book1D("Problematic ETTEM Sum - Data", "ETTEM iE_{T}", 7000, -0.5, 6999.5);
0134   ettEmEmul = ibooker.book1D("Problematic ETTEM Sum - Emulator", "ETTEM iE_{T}", 7000, -0.5, 6999.5);
0135 
0136   // book HTT type sums
0137   httData = ibooker.book1D("Problematic HTT Sum - Data", "HTT iE_{T}", 7000, -0.5, 6999.5);
0138   httEmul = ibooker.book1D("Problematic HTT Sum - Emulator", "HTT iE_{T}", 7000, -0.5, 6999.5);
0139   httHFData = ibooker.book1D("Problematic HTTHF Sum - Data", "HTTHF iE_{T}", 7000, -0.5, 6999.5);
0140   httHFEmul = ibooker.book1D("Problematic HTTHF Sum - Emulator", "HTTHF iE_{T}", 7000, -0.5, 6999.5);
0141 
0142   // book MET type sums
0143   metEtData = ibooker.book1D("Problematic MET Sum Et - Data", "MET iE_{T}", 7000, -0.5, 6999.5);
0144   metEtEmul = ibooker.book1D("Problematic MET Sum Et - Emulator", "MET iE_{T}", 7000, -0.5, 6999.5);
0145   metPhiData = ibooker.book1D("Problematic MET Sum phi - Data", "MET i#phi", 1008, -0.5, 1007.5);
0146   metPhiEmul = ibooker.book1D("Problematic MET Sum phi - Emulator", "MET i#phi", 1008, -0.5, 1007.5);
0147 
0148   metHFEtData = ibooker.book1D("Problematic METHF Sum Et - Data", "METHF iE_{T}", 7000, -0.5, 6999.5);
0149   metHFEtEmul = ibooker.book1D("Problematic METHF Sum Et - Emulator", "METHF iE_{T}", 7000, -0.5, 6999.5);
0150   metHFPhiData = ibooker.book1D("Problematic METHF Sum phi - Data", "METHF i#phi", 1008, -0.5, 1007.5);
0151   metHFPhiEmul = ibooker.book1D("Problematic METHF Sum phi - Emulator", "METHF i#phi", 1008, -0.5, 1007.5);
0152 
0153   // book MHT type sums
0154   mhtEtData = ibooker.book1D("Problematic MHT Sum Et - Data", "MHT iE_{T}", 7000, -0.5, 6999.5);
0155   mhtEtEmul = ibooker.book1D("Problematic MHT Sum Et - Emulator", "MHT iE_{T}", 7000, -0.5, 6999.5);
0156   mhtPhiData = ibooker.book1D("Problematic MHT Sum phi - Data", "MHT i#phi", 1008, -0.5, 1007.5);
0157   mhtPhiEmul = ibooker.book1D("Problematic MHT Sum phi - Emulator", "MHT i#phi", 1008, -0.5, 1007.5);
0158 
0159   mhtHFEtData = ibooker.book1D("Problematic MHTHF Sum Et - Data", "MHTHF iE_{T}", 7000, -0.5, 6999.5);
0160   mhtHFEtEmul = ibooker.book1D("Problematic MHTHF Sum Et - Emulator", "MHTHF iE_{T}", 7000, -0.5, 6999.5);
0161   mhtHFPhiData = ibooker.book1D("Problematic MHTHF Sum phi - Data", "MHTHF i#phi", 1008, -0.5, 1007.5);
0162   mhtHFPhiEmul = ibooker.book1D("Problematic MHTHF Sum phi - Emulator", "MHTHF i#phi", 1008, -0.5, 1007.5);
0163 
0164   // book minimum bias sums
0165   mbhfp0Data = ibooker.book1D("Problematic MBHFP0 Sum - Data", "", 16, -0.5, 15.5);
0166   mbhfp0Emul = ibooker.book1D("Problematic MBHFP0 Sum - Emulator", "", 16, -0.5, 15.5);
0167   mbhfm0Data = ibooker.book1D("Problematic MBHFM0 Sum - Data", "", 16, -0.5, 15.5);
0168   mbhfm0Emul = ibooker.book1D("Problematic MBHFM0 Sum - Emulator", "", 16, -0.5, 15.5);
0169   mbhfm1Data = ibooker.book1D("Problematic MBHFM1 Sum - Data", "", 16, -0.5, 15.5);
0170   mbhfm1Emul = ibooker.book1D("Problematic MBHFM1 Sum - Emulator", "", 16, -0.5, 15.5);
0171   mbhfp1Data = ibooker.book1D("Problematic MBHFP1 Sum - Data", "", 16, -0.5, 15.5);
0172   mbhfp1Emul = ibooker.book1D("Problematic MBHFP1 Sum - Emulator", "", 16, -0.5, 15.5);
0173 
0174   // book tower count sums
0175   towCountData = ibooker.book1D("Problematic Tower Count Sum - Data", "", 5904, -0.5, 5903.5);
0176   towCountEmul = ibooker.book1D("Problematic Tower Count Sum - Emulator", "", 5904, -0.5, 5903.5);
0177   // for reference on arguments of book2D, see
0178   // https://cmssdt.cern.ch/SDT/doxygen/CMSSW_8_0_24/doc/html/df/d26/DQMStore_8cc_source.html#l01070
0179 
0180   // book asymmetry count
0181 
0182   asymCountData = ibooker.book1D("Problematic Asymmetry Count - Data", "", 256, -0.5, 255.5);
0183   asymCountEmul = ibooker.book1D("Problematic Asymmetry Count - Emulator", "", 256, -0.5, 255.5);
0184 
0185   // book centrality sums
0186 
0187   centrCountData = ibooker.book1D("Problematic Centrality Count - Data", "", 9, -1.5, 7.5);
0188   centrCountEmul = ibooker.book1D("Problematic Centrality Count - Emulator", "", 9, -1.5, 7.5);
0189 
0190   // setup the directory where the histograms are to be visualised, value is set
0191   // in constructor and taken from python configuration file for module
0192   ibooker.setCurrentFolder(monitorDir + "/expert");
0193 
0194   // Jet energy in MP firmware is stored in 16 bits which sets the range of
0195   // jet energy to 2^16 * 0.5 GeV = 32768 GeV (65536 hardware units)
0196   // --- this is only for MP jets, the demux jets have much decreased precision
0197   // --- and this should be replaced
0198 
0199   // the index of the first bin in histogram should match value of first enum
0200   agreementSummary =
0201       ibooker.book1D("CaloL2 Object Agreement Summary", "CaloL2 event-by-event object agreement fractions", 10, 1, 11);
0202 
0203   agreementSummary->setBinLabel(EVENTGOOD, "good events");
0204   agreementSummary->setBinLabel(NEVENTS, "total events");
0205   agreementSummary->setBinLabel(NJETS_S, "total jets");
0206   agreementSummary->setBinLabel(JETGOOD_S, "good jets");
0207   agreementSummary->setBinLabel(NEGS_S, "total e/gs");
0208   agreementSummary->setBinLabel(EGGOOD_S, "good e/gs");
0209   agreementSummary->setBinLabel(NTAUS_S, "total taus");
0210   agreementSummary->setBinLabel(TAUGOOD_S, "good taus");
0211   agreementSummary->setBinLabel(NSUMS_S, "total sums");
0212   agreementSummary->setBinLabel(SUMGOOD_S, "good sums");
0213 
0214   jetSummary = ibooker.book1D("Jet Agreement Summary", "Jet Agreement Summary", 4, 1, 5);
0215   jetSummary->setBinLabel(NJETS, "total jets");
0216   jetSummary->setBinLabel(JETGOOD, "good jets");
0217   jetSummary->setBinLabel(JETPOSOFF, "jets pos off only");
0218   jetSummary->setBinLabel(JETETOFF, "jets Et off only ");
0219 
0220   egSummary = ibooker.book1D("EG Agreement Summary", "EG Agreement Summary", 8, 1, 9);
0221   egSummary->setBinLabel(NEGS, "total non-iso e/gs");
0222   egSummary->setBinLabel(EGGOOD, "good non-iso e/gs");
0223   egSummary->setBinLabel(EGPOSOFF, "non-iso e/gs pos off");
0224   egSummary->setBinLabel(EGETOFF, "non-iso e/gs Et off");
0225   egSummary->setBinLabel(NISOEGS, "total iso e/gs");
0226   egSummary->setBinLabel(ISOEGGOOD, "good iso e/gs");
0227   egSummary->setBinLabel(ISOEGPOSOFF, "iso e/gs pos off");
0228   egSummary->setBinLabel(ISOEGETOFF, "iso e/gs Et off");
0229 
0230   tauSummary = ibooker.book1D("Tau Agreement Summary", "Tau Agreement Summary", 8, 1, 9);
0231   tauSummary->setBinLabel(NTAUS, "total taus");
0232   tauSummary->setBinLabel(TAUGOOD, "good non-iso taus");
0233   tauSummary->setBinLabel(TAUPOSOFF, "non-iso taus pos off");
0234   tauSummary->setBinLabel(TAUETOFF, "non-iso taus Et off");
0235   tauSummary->setBinLabel(NISOTAUS, "total iso taus");
0236   tauSummary->setBinLabel(ISOTAUGOOD, "good iso taus");
0237   tauSummary->setBinLabel(ISOTAUPOSOFF, "iso taus pos off");
0238   tauSummary->setBinLabel(ISOTAUETOFF, "iso taus Et off");
0239 
0240   sumSummary = ibooker.book1D("Energy Sum Agreement Summary", "Sum Agreement Summary", 18, 1, 19);
0241   sumSummary->setBinLabel(NSUMS, "total sums");
0242   sumSummary->setBinLabel(SUMGOOD, "good sums");
0243   sumSummary->setBinLabel(NETTSUMS, "total ETT sums");
0244   sumSummary->setBinLabel(ETTSUMGOOD, "good ETT sums");
0245   sumSummary->setBinLabel(NHTTSUMS, "total HTT sums");
0246   sumSummary->setBinLabel(HTTSUMGOOD, "good HTT sums");
0247   sumSummary->setBinLabel(NMETSUMS, "total MET sums");
0248   sumSummary->setBinLabel(METSUMGOOD, "good MET sums");
0249   sumSummary->setBinLabel(NMHTSUMS, "total MHT sums");
0250   sumSummary->setBinLabel(MHTSUMGOOD, "good MHT sums");
0251   sumSummary->setBinLabel(NMBHFSUMS, "total MBHF sums");
0252   sumSummary->setBinLabel(MBHFSUMGOOD, "good MBHF sums");
0253   sumSummary->setBinLabel(NTOWCOUNTS, "total TowCount sums");
0254   sumSummary->setBinLabel(TOWCOUNTGOOD, "good TowCount sums");
0255   sumSummary->setBinLabel(NASYMCOUNTS, "total AsymCount sums");
0256   sumSummary->setBinLabel(ASYMCOUNTGOOD, "good AsymCount sums");
0257   sumSummary->setBinLabel(NCENTRCOUNTS, "total CentrCount sums");
0258   sumSummary->setBinLabel(CENTRCOUNTGOOD, "good CentrCount sums");
0259 
0260   // high level directory
0261   ibooker.setCurrentFolder(monitorDir);
0262 
0263   problemSummary = ibooker.book1D("Problem Summary", "Problematic Event Summary", 8, 1, 9);
0264   problemSummary->setBinLabel(NEVENTS_P, "total events");
0265   problemSummary->setBinLabel(JETCOLLSIZE, "jet collection size");
0266   problemSummary->setBinLabel(EGCOLLSIZE, "eg collection size");
0267   problemSummary->setBinLabel(TAUCOLLSIZE, "tau collection size");
0268   problemSummary->setBinLabel(JETMISMATCH, "jet mismatch");
0269   problemSummary->setBinLabel(EGMISMATCH, "eg mismatch");
0270   problemSummary->setBinLabel(TAUMISMATCH, "tau mismatch");
0271   problemSummary->setBinLabel(SUMMISMATCH, "sum mismatch");
0272 }
0273 void L1TdeStage2CaloLayer2::analyze(const edm::Event& e, const edm::EventSetup& c) {
0274   if (verbose)
0275     edm::LogInfo("L1TdeStage2CaloLayer2") << "L1TdeStage2CaloLayer2: analyse " << std::endl;
0276 
0277   // define collections to hold lists of objects in event
0278   edm::Handle<l1t::JetBxCollection> jetDataCol;
0279   edm::Handle<l1t::JetBxCollection> jetEmulCol;
0280   edm::Handle<l1t::EGammaBxCollection> egDataCol;
0281   edm::Handle<l1t::EGammaBxCollection> egEmulCol;
0282   edm::Handle<l1t::TauBxCollection> tauDataCol;
0283   edm::Handle<l1t::TauBxCollection> tauEmulCol;
0284   edm::Handle<l1t::EtSumBxCollection> sumDataCol;
0285   edm::Handle<l1t::EtSumBxCollection> sumEmulCol;
0286 
0287   // map event contents to above collections
0288   e.getByToken(calol2JetCollectionData, jetDataCol);
0289   e.getByToken(calol2JetCollectionEmul, jetEmulCol);
0290   e.getByToken(calol2EGammaCollectionData, egDataCol);
0291   e.getByToken(calol2EGammaCollectionEmul, egEmulCol);
0292   e.getByToken(calol2TauCollectionData, tauDataCol);
0293   e.getByToken(calol2TauCollectionEmul, tauEmulCol);
0294   e.getByToken(calol2EtSumCollectionData, sumDataCol);
0295   e.getByToken(calol2EtSumCollectionEmul, sumEmulCol);
0296 
0297   bool eventGood = true;
0298 
0299   // we assume that the first and last bx of the emulator data is 0 since it is
0300   // very unlikely to have received RAW data from more than just the triggered
0301   // bx
0302 
0303   /**
0304      Notes:
0305      - The hardware can send up to 12 jets due to bandwidth limitation so it
0306        will sort the jets it has found in order of decreasing pT and will send
0307        only the top 12. The emulator does not have similar constraint but can be
0308        configured to truncate the list of jets it has found. In the case that a
0309        small number of jets is found (less than 12), the full list will be sent.
0310      - Currently, the edge case where the number of jets/objects in data and
0311        emulator are different is being skipped but would need to be addressed
0312        before the module can be declared complete.
0313 
0314      Edge cases to consider:
0315      - there are more emulator jets than data jets
0316      - there are more data jets than emulator jets
0317      - missing jet is at beginning/end
0318      - missing jet is in the middle
0319   */
0320 
0321   if (!compareJets(jetDataCol, jetEmulCol)) {
0322     if (verbose)
0323       edm::LogInfo("L1TdeStage2CaloLayer2") << "l1t calol2 dqm: jet problem " << std::endl;
0324     problemSummary->Fill(JETMISMATCH);
0325     eventGood = false;
0326   }
0327 
0328   if (!compareEGs(egDataCol, egEmulCol)) {
0329     if (verbose)
0330       edm::LogInfo("L1TdeStage2CaloLayer2") << "l1t calol2 dqm: eg problem " << std::endl;
0331     problemSummary->Fill(EGMISMATCH);
0332     eventGood = false;
0333   }
0334 
0335   if (!compareTaus(tauDataCol, tauEmulCol)) {
0336     if (verbose)
0337       edm::LogInfo("L1TdeStage2CaloLayer2") << "l1t calol2 dqm: tau problem " << std::endl;
0338     problemSummary->Fill(TAUMISMATCH);
0339     eventGood = false;
0340   }
0341 
0342   if (!compareSums(sumDataCol, sumEmulCol)) {
0343     if (verbose)
0344       edm::LogInfo("L1TdeStage2CaloLayer2") << "l1t calol2 dqm: sum problem " << std::endl;
0345     problemSummary->Fill(SUMMISMATCH);
0346     eventGood = false;
0347   }
0348 
0349   /**
0350      Questions:
0351      - what could make the data and emul bx ranges to be different?
0352      - how can I confirm that the emulator data is being filled?
0353   */
0354 
0355   if (eventGood) {
0356     agreementSummary->Fill(EVENTGOOD);
0357   }
0358 
0359   agreementSummary->Fill(NEVENTS);
0360   problemSummary->Fill(NEVENTS_P);
0361 }
0362 
0363 // comparison method for jets
0364 bool L1TdeStage2CaloLayer2::compareJets(const edm::Handle<l1t::JetBxCollection>& dataCol,
0365                                         const edm::Handle<l1t::JetBxCollection>& emulCol) {
0366   bool eventGood = true;
0367 
0368   l1t::JetBxCollection::const_iterator dataIt = dataCol->begin(currBx);
0369   l1t::JetBxCollection::const_iterator emulIt = emulCol->begin(currBx);
0370 
0371   // process jets
0372   if (dataCol->size(currBx) != emulCol->size(currBx)) {
0373     if (dataCol->size(currBx) < emulCol->size(currBx)) {
0374       // if only the data collection is empty, declare event as bad
0375       if (dataCol->isEmpty(currBx))
0376         return false;
0377 
0378       while (true) {
0379         jetEtData->Fill(dataIt->hwPt());
0380         jetEtaData->Fill(dataIt->hwEta());
0381         jetPhiData->Fill(dataIt->hwPhi());
0382         if (enable2DComp)
0383           jet2DEtaPhiData->Fill(dataIt->eta(), dataIt->phi());
0384 
0385         ++dataIt;
0386 
0387         if (dataIt == dataCol->end(currBx))
0388           break;
0389       }
0390     } else {
0391       // if only the emul collection is empty, declare event as bad
0392       if (emulCol->isEmpty(currBx))
0393         return false;
0394 
0395       while (true) {
0396         jetEtEmul->Fill(emulIt->hwPt());
0397         jetEtaEmul->Fill(emulIt->hwEta());
0398         jetPhiEmul->Fill(emulIt->hwPhi());
0399         if (enable2DComp)
0400           jet2DEtaPhiEmul->Fill(emulIt->eta(), emulIt->phi());
0401 
0402         ++emulIt;
0403 
0404         if (emulIt == emulCol->end(currBx))
0405           break;
0406       }
0407     }
0408 
0409     problemSummary->Fill(JETCOLLSIZE);
0410     return false;
0411   }
0412 
0413   int nJets = 0;
0414   if (dataIt != dataCol->end(currBx) || emulIt != emulCol->end(currBx)) {
0415     while (true) {
0416       ++nJets;
0417 
0418       bool posGood = true;
0419       bool etGood = true;
0420 
0421       // object pt mismatch
0422       if (dataIt->hwPt() != emulIt->hwPt()) {
0423         etGood = false;
0424         eventGood = false;
0425       }
0426 
0427       // object position mismatch (phi)
0428       if (dataIt->hwPhi() != emulIt->hwPhi()) {
0429         posGood = false;
0430         eventGood = false;
0431       }
0432 
0433       // object position mismatch (eta)
0434       if (dataIt->hwEta() != emulIt->hwEta()) {
0435         posGood = false;
0436         eventGood = false;
0437       }
0438 
0439       // if both position and energy agree, jet is good
0440       if (etGood && posGood) {
0441         agreementSummary->Fill(JETGOOD_S);
0442         jetSummary->Fill(JETGOOD);
0443       } else {
0444         jetEtData->Fill(dataIt->hwPt());
0445         jetEtaData->Fill(dataIt->hwEta());
0446         jetPhiData->Fill(dataIt->hwPhi());
0447         if (enable2DComp)
0448           jet2DEtaPhiData->Fill(dataIt->eta(), dataIt->phi());
0449 
0450         jetEtEmul->Fill(emulIt->hwPt());
0451         jetEtaEmul->Fill(emulIt->hwEta());
0452         jetPhiEmul->Fill(emulIt->hwPhi());
0453         if (enable2DComp)
0454           jet2DEtaPhiEmul->Fill(emulIt->eta(), emulIt->phi());
0455 
0456         if (verbose) {
0457           edm::LogInfo("L1TdeStage2CaloLayer2") << "--- jet ---" << std::endl;
0458           edm::LogInfo("L1TdeStage2CaloLayer2") << "data jet Et = " << dataIt->hwPt() << std::endl;
0459           edm::LogInfo("L1TdeStage2CaloLayer2") << "emul jet Et = " << emulIt->hwPt() << std::endl;
0460           edm::LogInfo("L1TdeStage2CaloLayer2") << "data jet phi = " << dataIt->hwPhi() << std::endl;
0461           edm::LogInfo("L1TdeStage2CaloLayer2") << "emul jet phi = " << emulIt->hwPhi() << std::endl;
0462           edm::LogInfo("L1TdeStage2CaloLayer2") << "data jet eta = " << dataIt->hwEta() << std::endl;
0463           edm::LogInfo("L1TdeStage2CaloLayer2") << "emul jet eta = " << emulIt->hwEta() << std::endl;
0464           edm::LogInfo("L1TdeStage2CaloLayer2") << "---" << std::endl;
0465         }
0466       }
0467 
0468       // if only position agrees
0469       if (posGood && !etGood) {
0470         jetSummary->Fill(JETETOFF);
0471       }
0472 
0473       // if only energy agrees
0474       if (!posGood && etGood) {
0475         jetSummary->Fill(JETPOSOFF);
0476       }
0477 
0478       // keep track of jets
0479       agreementSummary->Fill(NJETS_S);
0480       jetSummary->Fill(NJETS);
0481 
0482       // increment position of pointers
0483       ++dataIt;
0484       ++emulIt;
0485 
0486       if (dataIt == dataCol->end(currBx) || emulIt == emulCol->end(currBx))
0487         break;
0488     }
0489   } else {
0490     if (dataCol->size(currBx) != 0 || emulCol->size(currBx) != 0)
0491       return false;
0492   }
0493 
0494   // return a boolean that states whether the jet data in the event is in
0495   // agreement
0496   return eventGood;
0497 }
0498 
0499 // comparison method for e/gammas
0500 bool L1TdeStage2CaloLayer2::compareEGs(const edm::Handle<l1t::EGammaBxCollection>& dataCol,
0501                                        const edm::Handle<l1t::EGammaBxCollection>& emulCol) {
0502   bool eventGood = true;
0503 
0504   l1t::EGammaBxCollection::const_iterator dataIt = dataCol->begin(currBx);
0505   l1t::EGammaBxCollection::const_iterator emulIt = emulCol->begin(currBx);
0506 
0507   // check length of collections
0508   if (dataCol->size(currBx) != emulCol->size(currBx)) {
0509     if (dataCol->size(currBx) < emulCol->size(currBx)) {
0510       // if only the data collection is empty, declare event as bad
0511       if (dataCol->isEmpty(currBx))
0512         return false;
0513 
0514       // if there are more events in data loop over the data collection
0515       while (true) {
0516         if (dataIt->hwIso()) {
0517           isoEgEtData->Fill(dataIt->hwPt());
0518           isoEgEtaData->Fill(dataIt->hwEta());
0519           isoEgPhiData->Fill(dataIt->hwPhi());
0520           if (enable2DComp)
0521             isoEg2DEtaPhiData->Fill(dataIt->eta(), dataIt->phi());
0522         } else {
0523           egEtData->Fill(dataIt->hwPt());
0524           egEtaData->Fill(dataIt->hwEta());
0525           egPhiData->Fill(dataIt->hwPhi());
0526           if (enable2DComp)
0527             eg2DEtaPhiData->Fill(dataIt->eta(), dataIt->phi());
0528         }
0529 
0530         ++dataIt;
0531 
0532         if (dataIt == dataCol->end(currBx))
0533           break;
0534       }
0535     } else {
0536       // if only the emul collection is empty, declare event as bad
0537       if (emulCol->isEmpty(currBx))
0538         return false;
0539 
0540       while (true) {
0541         if (emulIt->hwIso()) {
0542           isoEgEtEmul->Fill(emulIt->hwPt());
0543           isoEgEtaEmul->Fill(emulIt->hwEta());
0544           isoEgPhiEmul->Fill(emulIt->hwPhi());
0545           if (enable2DComp)
0546             isoEg2DEtaPhiEmul->Fill(emulIt->eta(), emulIt->phi());
0547         } else {
0548           egEtEmul->Fill(emulIt->hwPt());
0549           egEtaEmul->Fill(emulIt->hwEta());
0550           egPhiEmul->Fill(emulIt->hwPhi());
0551           if (enable2DComp)
0552             eg2DEtaPhiEmul->Fill(emulIt->eta(), emulIt->phi());
0553         }
0554 
0555         ++emulIt;
0556 
0557         if (emulIt == emulCol->end(currBx))
0558           break;
0559       }
0560     }
0561 
0562     problemSummary->Fill(EGCOLLSIZE);
0563     return false;
0564   }
0565 
0566   // processing continues only of length of data collections is the same
0567   if (dataIt != dataCol->end(currBx) || emulIt != emulCol->end(currBx)) {
0568     while (true) {
0569       bool posGood = true;
0570       bool etGood = true;
0571       bool iso = dataIt->hwIso();
0572 
0573       // object pt mismatch
0574       if (dataIt->hwPt() != emulIt->hwPt()) {
0575         etGood = false;
0576         eventGood = false;
0577       }
0578 
0579       // object position mismatch (phi)
0580       if (dataIt->hwPhi() != emulIt->hwPhi()) {
0581         posGood = false;
0582         eventGood = false;
0583       }
0584 
0585       // object position mismatch (eta)
0586       if (dataIt->hwEta() != emulIt->hwEta()) {
0587         posGood = false;
0588         eventGood = false;
0589       }
0590 
0591       // if both position and energy agree, object is good
0592       if (posGood && etGood) {
0593         agreementSummary->Fill(EGGOOD_S);
0594 
0595         if (iso) {
0596           egSummary->Fill(ISOEGGOOD);
0597         } else {
0598           egSummary->Fill(EGGOOD);
0599         }
0600 
0601       } else {
0602         if (iso) {
0603           isoEgEtData->Fill(dataIt->hwPt());
0604           isoEgEtaData->Fill(dataIt->hwEta());
0605           isoEgPhiData->Fill(dataIt->hwPhi());
0606           if (enable2DComp)
0607             isoEg2DEtaPhiData->Fill(dataIt->eta(), dataIt->phi());
0608 
0609           isoEgEtEmul->Fill(emulIt->hwPt());
0610           isoEgEtaEmul->Fill(emulIt->hwEta());
0611           isoEgPhiEmul->Fill(emulIt->hwPhi());
0612           if (enable2DComp)
0613             isoEg2DEtaPhiEmul->Fill(emulIt->eta(), emulIt->phi());
0614         } else {
0615           egEtData->Fill(dataIt->hwPt());
0616           egEtaData->Fill(dataIt->hwEta());
0617           egPhiData->Fill(dataIt->hwPhi());
0618           if (enable2DComp)
0619             eg2DEtaPhiData->Fill(dataIt->eta(), dataIt->phi());
0620 
0621           egEtEmul->Fill(emulIt->hwPt());
0622           egEtaEmul->Fill(emulIt->hwEta());
0623           egPhiEmul->Fill(emulIt->hwPhi());
0624           if (enable2DComp)
0625             eg2DEtaPhiEmul->Fill(emulIt->eta(), emulIt->phi());
0626         }
0627 
0628         if (verbose) {
0629           edm::LogInfo("L1TdeStage2CaloLayer2") << "--- eg ---" << std::endl;
0630           edm::LogInfo("L1TdeStage2CaloLayer2") << "data eg Et = " << dataIt->hwPt() << std::endl;
0631           edm::LogInfo("L1TdeStage2CaloLayer2") << "emul eg Et = " << emulIt->hwPt() << std::endl;
0632           edm::LogInfo("L1TdeStage2CaloLayer2") << "data eg phi = " << dataIt->hwPhi() << std::endl;
0633           edm::LogInfo("L1TdeStage2CaloLayer2") << "emul eg phi = " << emulIt->hwPhi() << std::endl;
0634           edm::LogInfo("L1TdeStage2CaloLayer2") << "data eg eta = " << dataIt->hwEta() << std::endl;
0635           edm::LogInfo("L1TdeStage2CaloLayer2") << "emul eg eta = " << emulIt->hwEta() << std::endl;
0636           edm::LogInfo("L1TdeStage2CaloLayer2") << "---" << std::endl;
0637         }
0638       }
0639 
0640       // if only position agrees
0641       if (posGood && !etGood) {
0642         if (iso) {
0643           egSummary->Fill(ISOEGETOFF);
0644         } else {
0645           egSummary->Fill(EGETOFF);
0646         }
0647       }
0648 
0649       // if only energy agrees
0650       if (!posGood && etGood) {
0651         if (iso) {
0652           egSummary->Fill(ISOEGPOSOFF);
0653         } else {
0654           egSummary->Fill(EGPOSOFF);
0655         }
0656       }
0657 
0658       // keep track of number of objects
0659       if (iso) {
0660         egSummary->Fill(NISOEGS);
0661       } else {
0662         egSummary->Fill(NEGS);
0663       }
0664       agreementSummary->Fill(NEGS_S);
0665 
0666       // increment position of pointers
0667       ++dataIt;
0668       ++emulIt;
0669 
0670       if (dataIt == dataCol->end(currBx) || emulIt == emulCol->end(currBx))
0671         break;
0672     }
0673   } else {
0674     if (dataCol->size(currBx) != 0 || emulCol->size(currBx) != 0)
0675       return false;
0676   }
0677 
0678   // return a boolean that states whether the jet data in the event is in
0679   // agreement
0680   return eventGood;
0681 }
0682 
0683 // comparison method for taus
0684 bool L1TdeStage2CaloLayer2::compareTaus(const edm::Handle<l1t::TauBxCollection>& dataCol,
0685                                         const edm::Handle<l1t::TauBxCollection>& emulCol) {
0686   bool eventGood = true;
0687 
0688   l1t::TauBxCollection::const_iterator dataIt = dataCol->begin(currBx);
0689   l1t::TauBxCollection::const_iterator emulIt = emulCol->begin(currBx);
0690 
0691   // check length of collections
0692   if (dataCol->size(currBx) != emulCol->size(currBx)) {
0693     if (dataCol->size(currBx) < emulCol->size(currBx)) {
0694       // if only the data collection is empty, declare event as bad
0695       if (dataCol->isEmpty(currBx))
0696         return false;
0697 
0698       // if there are more events in data loop over the data collection
0699       while (true) {
0700         // Populate different set of histograms if object is solated
0701 
0702         if (dataIt->hwIso()) {
0703           isoTauEtData->Fill(dataIt->hwPt());
0704           isoTauEtaData->Fill(dataIt->hwEta());
0705           isoTauPhiData->Fill(dataIt->hwPhi());
0706           if (enable2DComp)
0707             isoTau2DEtaPhiData->Fill(dataIt->eta(), dataIt->phi());
0708         } else {
0709           tauEtData->Fill(dataIt->hwPt());
0710           tauEtaData->Fill(dataIt->hwEta());
0711           tauPhiData->Fill(dataIt->hwPhi());
0712           if (enable2DComp)
0713             tau2DEtaPhiData->Fill(dataIt->eta(), dataIt->phi());
0714         }
0715 
0716         ++dataIt;
0717 
0718         if (dataIt == dataCol->end(currBx))
0719           break;
0720       }
0721     } else {
0722       // if only the emul collection is bad, declare the event as bad
0723       if (emulCol->isEmpty(currBx))
0724         return false;
0725 
0726       while (true) {
0727         // Populate different set of histograms if object is solated
0728 
0729         if (emulIt->hwIso()) {
0730           isoTauEtEmul->Fill(emulIt->hwPt());
0731           isoTauEtaEmul->Fill(emulIt->hwEta());
0732           isoTauPhiEmul->Fill(emulIt->hwPhi());
0733           if (enable2DComp)
0734             isoTau2DEtaPhiEmul->Fill(emulIt->eta(), emulIt->phi());
0735 
0736         } else {
0737           tauEtEmul->Fill(emulIt->hwPt());
0738           tauEtaEmul->Fill(emulIt->hwEta());
0739           tauPhiEmul->Fill(emulIt->hwPhi());
0740           if (enable2DComp)
0741             tau2DEtaPhiEmul->Fill(emulIt->eta(), emulIt->phi());
0742         }
0743 
0744         ++emulIt;
0745 
0746         if (emulIt == emulCol->end(currBx))
0747           break;
0748       }
0749     }
0750 
0751     problemSummary->Fill(TAUCOLLSIZE);
0752     return false;
0753   }
0754 
0755   // processing continues only of length of data collections is the same
0756   if (dataIt != dataCol->end(currBx) || emulIt != emulCol->end(currBx)) {
0757     while (true) {
0758       bool posGood = true;
0759       bool etGood = true;
0760       bool iso = dataIt->hwIso();
0761 
0762       // object Et mismatch
0763       if (dataIt->hwPt() != emulIt->hwPt()) {
0764         etGood = false;
0765         eventGood = false;
0766       }
0767 
0768       // object position mismatch (phi)
0769       if (dataIt->hwPhi() != emulIt->hwPhi()) {
0770         posGood = false;
0771         eventGood = false;
0772       }
0773 
0774       // object position mismatch (eta)
0775       if (dataIt->hwEta() != emulIt->hwEta()) {
0776         posGood = false;
0777         eventGood = false;
0778       }
0779 
0780       // if both position and energy agree, object is good
0781       if (posGood && etGood) {
0782         agreementSummary->Fill(TAUGOOD_S);
0783 
0784         if (iso) {
0785           tauSummary->Fill(ISOTAUGOOD);
0786         } else {
0787           tauSummary->Fill(TAUGOOD);
0788         }
0789       } else {
0790         if (iso) {
0791           isoTauEtData->Fill(dataIt->hwPt());
0792           isoTauEtaData->Fill(dataIt->hwEta());
0793           isoTauPhiData->Fill(dataIt->hwPhi());
0794           if (enable2DComp)
0795             isoTau2DEtaPhiData->Fill(dataIt->eta(), dataIt->phi());
0796 
0797           isoTauEtEmul->Fill(emulIt->hwPt());
0798           isoTauEtaEmul->Fill(emulIt->hwEta());
0799           isoTauPhiEmul->Fill(emulIt->hwPhi());
0800           if (enable2DComp)
0801             isoTau2DEtaPhiEmul->Fill(emulIt->eta(), emulIt->phi());
0802 
0803         } else {
0804           tauEtData->Fill(dataIt->hwPt());
0805           tauEtaData->Fill(dataIt->hwEta());
0806           tauPhiData->Fill(dataIt->hwPhi());
0807           if (enable2DComp)
0808             tau2DEtaPhiData->Fill(dataIt->eta(), dataIt->phi());
0809 
0810           tauEtEmul->Fill(emulIt->hwPt());
0811           tauEtaEmul->Fill(emulIt->hwEta());
0812           tauPhiEmul->Fill(emulIt->hwPhi());
0813           if (enable2DComp)
0814             tau2DEtaPhiEmul->Fill(emulIt->eta(), emulIt->phi());
0815         }
0816 
0817         if (verbose) {
0818           edm::LogInfo("L1TdeStage2CaloLayer2") << "--- tau ---" << std::endl;
0819           edm::LogInfo("L1TdeStage2CaloLayer2") << "data tau Et = " << dataIt->hwPt() << std::endl;
0820           edm::LogInfo("L1TdeStage2CaloLayer2") << "emul tau Et = " << emulIt->hwPt() << std::endl;
0821           edm::LogInfo("L1TdeStage2CaloLayer2") << "data tau phi = " << dataIt->hwPhi() << std::endl;
0822           edm::LogInfo("L1TdeStage2CaloLayer2") << "emul tau phi = " << emulIt->hwPhi() << std::endl;
0823           edm::LogInfo("L1TdeStage2CaloLayer2") << "data tau eta = " << dataIt->hwEta() << std::endl;
0824           edm::LogInfo("L1TdeStage2CaloLayer2") << "emul tau eta = " << emulIt->hwEta() << std::endl;
0825           edm::LogInfo("L1TdeStage2CaloLayer2") << "---" << std::endl;
0826         }
0827       }
0828 
0829       // if only position agrees
0830       if (posGood && !etGood) {
0831         if (iso) {
0832           tauSummary->Fill(ISOTAUETOFF);
0833         } else {
0834           tauSummary->Fill(TAUETOFF);
0835         }
0836       }
0837 
0838       // if only energy agrees
0839       if (!posGood && etGood) {
0840         if (iso) {
0841           tauSummary->Fill(ISOTAUPOSOFF);
0842         } else {
0843           tauSummary->Fill(TAUPOSOFF);
0844         }
0845       }
0846 
0847       // keep track of number of objects
0848       if (iso) {
0849         tauSummary->Fill(NISOTAUS);
0850       } else {
0851         tauSummary->Fill(NTAUS);
0852       }
0853 
0854       agreementSummary->Fill(NTAUS_S);
0855 
0856       // increment position of pointers
0857       ++dataIt;
0858       ++emulIt;
0859 
0860       if (dataIt == dataCol->end(currBx) || emulIt == emulCol->end(currBx))
0861         break;
0862     }
0863   } else {
0864     if (dataCol->size(currBx) != 0 || emulCol->size(currBx) != 0)
0865       return false;
0866   }
0867 
0868   // return a boolean that states whether the jet data in the event is in
0869   // agreement
0870   return eventGood;
0871 }
0872 
0873 // comparison method for sums
0874 bool L1TdeStage2CaloLayer2::compareSums(const edm::Handle<l1t::EtSumBxCollection>& dataCol,
0875                                         const edm::Handle<l1t::EtSumBxCollection>& emulCol) {
0876   bool eventGood = true;
0877 
0878   bool etGood = true;
0879   bool phiGood = true;
0880 
0881   double dataEt = 0;
0882   double emulEt = 0;
0883   double dataPhi = 0;
0884   double emulPhi = 0;
0885   int dataCentr = 0;
0886   int emulCentr = 0;
0887 
0888   l1t::EtSumBxCollection::const_iterator dataIt;
0889   l1t::EtSumBxCollection::const_iterator emulIt = emulCol->begin(currBx);
0890 
0891   // if either data or emulator collections are empty mark the event as bad (this should never occur in normal running)
0892   // matching data/emul collections by type before proceeding with the checks
0893   if (dataCol->isEmpty(currBx) || emulCol->isEmpty(currBx))
0894     return false;
0895 
0896   while (true) {
0897     dataIt = dataCol->begin(currBx);
0898     while (true) {
0899       if (dataIt->getType() == emulIt->getType()) {
0900         // It should be possible to implement this with a switch statement
0901         etGood = true;
0902         phiGood = true;
0903         // ETT
0904         if (l1t::EtSum::EtSumType::kTotalEt == dataIt->getType()) {
0905           dataEt = dataIt->hwPt();
0906           emulEt = emulIt->hwPt();
0907 
0908           if (dataEt != emulEt) {
0909             eventGood = false;
0910 
0911             ettData->Fill(dataEt);
0912             ettEmul->Fill(emulEt);
0913           } else {
0914             agreementSummary->Fill(SUMGOOD_S);
0915             sumSummary->Fill(SUMGOOD);
0916             sumSummary->Fill(ETTSUMGOOD);
0917           }
0918 
0919           if (verbose) {
0920             edm::LogInfo("L1TdeStage2CaloLayer2") << "ETT       | ";
0921             if (dataEt != emulEt)
0922               edm::LogInfo("L1TdeStage2CaloLayer2") << "x ";
0923             else
0924               edm::LogInfo("L1TdeStage2CaloLayer2") << "  ";
0925             edm::LogInfo("L1TdeStage2CaloLayer2") << dataEt << "\t" << emulEt;
0926             edm::LogInfo("L1TdeStage2CaloLayer2") << std::endl;
0927           }
0928 
0929           // update sum counters
0930           agreementSummary->Fill(NSUMS_S);
0931           sumSummary->Fill(NETTSUMS);
0932           sumSummary->Fill(NSUMS);
0933         }
0934 
0935         // ETTEM
0936         if (l1t::EtSum::EtSumType::kTotalEtEm == dataIt->getType()) {
0937           dataEt = dataIt->hwPt();
0938           emulEt = emulIt->hwPt();
0939 
0940           if (dataEt != emulEt) {
0941             eventGood = false;
0942             ettEmData->Fill(dataEt);
0943             ettEmEmul->Fill(emulEt);
0944 
0945           } else {
0946             agreementSummary->Fill(SUMGOOD_S);
0947             sumSummary->Fill(SUMGOOD);
0948             sumSummary->Fill(ETTSUMGOOD);
0949           }
0950 
0951           if (verbose) {
0952             edm::LogInfo("L1TdeStage2CaloLayer2") << "ETTEM     | ";
0953             if (dataEt != emulEt)
0954               edm::LogInfo("L1TdeStage2CaloLayer2") << "x ";
0955             else
0956               edm::LogInfo("L1TdeStage2CaloLayer2") << "  ";
0957             edm::LogInfo("L1TdeStage2CaloLayer2") << dataEt << "\t" << emulEt;
0958             edm::LogInfo("L1TdeStage2CaloLayer2") << std::endl;
0959           }
0960 
0961           // update sum counters
0962           agreementSummary->Fill(NSUMS_S);
0963           sumSummary->Fill(NETTSUMS);
0964           sumSummary->Fill(NSUMS);
0965         }
0966 
0967         // HTT
0968         if (l1t::EtSum::EtSumType::kTotalHt == dataIt->getType()) {
0969           dataEt = dataIt->hwPt();
0970           emulEt = emulIt->hwPt();
0971 
0972           if (dataEt != emulEt) {
0973             eventGood = false;
0974             httData->Fill(dataEt);
0975             httEmul->Fill(emulEt);
0976           } else {
0977             agreementSummary->Fill(SUMGOOD_S);
0978             sumSummary->Fill(SUMGOOD);
0979             sumSummary->Fill(HTTSUMGOOD);
0980           }
0981 
0982           if (verbose) {
0983             edm::LogInfo("L1TdeStage2CaloLayer2") << "HTT       | ";
0984             if (dataEt != emulEt)
0985               edm::LogInfo("L1TdeStage2CaloLayer2") << "x ";
0986             else
0987               edm::LogInfo("L1TdeStage2CaloLayer2") << "  ";
0988             edm::LogInfo("L1TdeStage2CaloLayer2") << dataEt << "\t" << emulEt;
0989             edm::LogInfo("L1TdeStage2CaloLayer2") << std::endl;
0990           }
0991 
0992           // update sum counters
0993           agreementSummary->Fill(NSUMS_S);
0994           sumSummary->Fill(NHTTSUMS);
0995           sumSummary->Fill(NSUMS);
0996         }
0997 
0998         // MET
0999         if (l1t::EtSum::EtSumType::kMissingEt == dataIt->getType() && dataIt->hwPt() != 0) {
1000           dataEt = dataIt->hwPt();
1001           emulEt = emulIt->hwPt();
1002 
1003           dataPhi = dataIt->hwPhi();
1004           emulPhi = emulIt->hwPhi();
1005 
1006           if (dataEt != emulEt) {
1007             etGood = false;
1008             eventGood = false;
1009           }
1010 
1011           if (dataPhi != emulPhi) {
1012             phiGood = false;
1013             eventGood = false;
1014           }
1015 
1016           if (etGood && phiGood) {
1017             agreementSummary->Fill(SUMGOOD_S);
1018             sumSummary->Fill(SUMGOOD);
1019             sumSummary->Fill(METSUMGOOD);
1020           } else {
1021             metEtData->Fill(dataEt);
1022             metPhiData->Fill(dataPhi);
1023             metEtEmul->Fill(emulEt);
1024             metPhiEmul->Fill(emulPhi);
1025           }
1026 
1027           if (verbose) {
1028             edm::LogInfo("L1TdeStage2CaloLayer2") << "MET       | ";
1029             if (dataEt != emulEt)
1030               edm::LogInfo("L1TdeStage2CaloLayer2") << "x ";
1031             else
1032               edm::LogInfo("L1TdeStage2CaloLayer2") << "  ";
1033             edm::LogInfo("L1TdeStage2CaloLayer2") << dataEt << "\t" << emulEt;
1034             edm::LogInfo("L1TdeStage2CaloLayer2") << std::endl;
1035 
1036             edm::LogInfo("L1TdeStage2CaloLayer2") << "MET phi   | ";
1037             if (dataPhi != emulPhi)
1038               edm::LogInfo("L1TdeStage2CaloLayer2") << "x ";
1039             else
1040               edm::LogInfo("L1TdeStage2CaloLayer2") << "  ";
1041             edm::LogInfo("L1TdeStage2CaloLayer2") << dataPhi << "\t" << emulPhi;
1042             edm::LogInfo("L1TdeStage2CaloLayer2") << std::endl;
1043           }
1044 
1045           // update sum counters
1046           agreementSummary->Fill(NSUMS_S);
1047           sumSummary->Fill(NMETSUMS);
1048           sumSummary->Fill(NSUMS);
1049         }
1050 
1051         // METHF
1052         if (l1t::EtSum::EtSumType::kMissingEtHF == dataIt->getType() && dataIt->hwPt() != 0) {
1053           dataEt = dataIt->hwPt();
1054           emulEt = emulIt->hwPt();
1055 
1056           dataPhi = dataIt->hwPhi();
1057           emulPhi = emulIt->hwPhi();
1058 
1059           if (dataEt != emulEt) {
1060             etGood = false;
1061             eventGood = false;
1062           }
1063 
1064           if (dataPhi != emulPhi) {
1065             phiGood = false;
1066             eventGood = false;
1067           }
1068 
1069           if (etGood && phiGood) {
1070             agreementSummary->Fill(SUMGOOD_S);
1071             sumSummary->Fill(SUMGOOD);
1072             sumSummary->Fill(METSUMGOOD);
1073           } else {
1074             metHFEtData->Fill(dataEt);
1075             metHFPhiData->Fill(dataPhi);
1076             metHFEtEmul->Fill(emulEt);
1077             metHFPhiEmul->Fill(emulPhi);
1078           }
1079 
1080           if (verbose) {
1081             edm::LogInfo("L1TdeStage2CaloLayer2") << "METHF     | ";
1082             if (dataEt != emulEt)
1083               edm::LogInfo("L1TdeStage2CaloLayer2") << "x ";
1084             else
1085               edm::LogInfo("L1TdeStage2CaloLayer2") << "  ";
1086             edm::LogInfo("L1TdeStage2CaloLayer2") << dataEt << "\t" << emulEt;
1087             edm::LogInfo("L1TdeStage2CaloLayer2") << std::endl;
1088 
1089             edm::LogInfo("L1TdeStage2CaloLayer2") << "METHF phi | ";
1090             if (dataPhi != emulPhi)
1091               edm::LogInfo("L1TdeStage2CaloLayer2") << "x ";
1092             else
1093               edm::LogInfo("L1TdeStage2CaloLayer2") << "  ";
1094             edm::LogInfo("L1TdeStage2CaloLayer2") << dataPhi << "\t" << emulPhi;
1095             edm::LogInfo("L1TdeStage2CaloLayer2") << std::endl;
1096           }
1097 
1098           // update sum counters
1099           agreementSummary->Fill(NSUMS_S);
1100           sumSummary->Fill(NMETSUMS);
1101           sumSummary->Fill(NSUMS);
1102         }
1103 
1104         // MHT
1105         if (l1t::EtSum::EtSumType::kMissingHt == dataIt->getType() && dataIt->hwPt() != 0) {
1106           dataEt = dataIt->hwPt();
1107           emulEt = emulIt->hwPt();
1108 
1109           dataPhi = dataIt->hwPhi();
1110           emulPhi = emulIt->hwPhi();
1111 
1112           if (dataEt != emulEt) {
1113             etGood = false;
1114             eventGood = false;
1115           }
1116 
1117           if (!(etGood && dataEt == 0)) {
1118             if (dataPhi != emulPhi) {
1119               phiGood = false;
1120               eventGood = false;
1121             }
1122           }
1123 
1124           if (etGood && phiGood) {
1125             agreementSummary->Fill(SUMGOOD_S);
1126             sumSummary->Fill(SUMGOOD);
1127             sumSummary->Fill(MHTSUMGOOD);
1128           } else {
1129             mhtEtData->Fill(dataEt);
1130             mhtPhiData->Fill(dataPhi);
1131             mhtEtEmul->Fill(emulEt);
1132             mhtPhiEmul->Fill(emulPhi);
1133           }
1134 
1135           if (verbose) {
1136             edm::LogInfo("L1TdeStage2CaloLayer2") << "MHT       | ";
1137             if (dataEt != emulEt)
1138               edm::LogInfo("L1TdeStage2CaloLayer2") << "x ";
1139             else
1140               edm::LogInfo("L1TdeStage2CaloLayer2") << "  ";
1141             edm::LogInfo("L1TdeStage2CaloLayer2") << dataEt << "\t" << emulEt;
1142             edm::LogInfo("L1TdeStage2CaloLayer2") << std::endl;
1143 
1144             edm::LogInfo("L1TdeStage2CaloLayer2") << "MHT phi   | ";
1145             if (dataPhi != emulPhi)
1146               edm::LogInfo("L1TdeStage2CaloLayer2") << "x ";
1147             else
1148               edm::LogInfo("L1TdeStage2CaloLayer2") << "  ";
1149             edm::LogInfo("L1TdeStage2CaloLayer2") << dataPhi << "\t" << emulPhi;
1150             edm::LogInfo("L1TdeStage2CaloLayer2") << std::endl;
1151           }
1152 
1153           // update sum counters
1154           agreementSummary->Fill(NSUMS_S);
1155           sumSummary->Fill(NMHTSUMS);
1156           sumSummary->Fill(NSUMS);
1157         }
1158 
1159         // MHTHF
1160         if (l1t::EtSum::EtSumType::kMissingHtHF == dataIt->getType() && dataIt->hwPt() != 0) {
1161           dataEt = dataIt->hwPt();
1162           emulEt = emulIt->hwPt();
1163 
1164           dataPhi = dataIt->hwPhi();
1165           emulPhi = emulIt->hwPhi();
1166 
1167           if (dataEt != emulEt) {
1168             phiGood = false;
1169             eventGood = false;
1170           }
1171 
1172           if (!(etGood && dataEt == 0)) {
1173             if (dataPhi != emulPhi) {
1174               phiGood = false;
1175               eventGood = false;
1176             }
1177           }
1178 
1179           if (etGood && phiGood) {
1180             agreementSummary->Fill(SUMGOOD_S);
1181             sumSummary->Fill(SUMGOOD);
1182             sumSummary->Fill(MHTSUMGOOD);
1183           } else {
1184             mhtHFEtData->Fill(dataEt);
1185             mhtHFPhiData->Fill(dataPhi);
1186             mhtHFEtEmul->Fill(emulEt);
1187             mhtHFPhiEmul->Fill(emulPhi);
1188           }
1189 
1190           if (verbose) {
1191             edm::LogInfo("L1TdeStage2CaloLayer2") << "MHTHF     | ";
1192             if (dataEt != emulEt)
1193               edm::LogInfo("L1TdeStage2CaloLayer2") << "x ";
1194             else
1195               edm::LogInfo("L1TdeStage2CaloLayer2") << "  ";
1196             edm::LogInfo("L1TdeStage2CaloLayer2") << dataEt << "\t" << emulEt;
1197             edm::LogInfo("L1TdeStage2CaloLayer2") << std::endl;
1198 
1199             edm::LogInfo("L1TdeStage2CaloLayer2") << "MHTHF phi | ";
1200             if (dataPhi != emulPhi)
1201               edm::LogInfo("L1TdeStage2CaloLayer2") << "x ";
1202             else
1203               edm::LogInfo("L1TdeStage2CaloLayer2") << "  ";
1204             edm::LogInfo("L1TdeStage2CaloLayer2") << dataPhi << "\t" << emulPhi;
1205             edm::LogInfo("L1TdeStage2CaloLayer2") << std::endl;
1206           }
1207 
1208           // update sum counters
1209           agreementSummary->Fill(NSUMS_S);
1210           sumSummary->Fill(NMHTSUMS);
1211           sumSummary->Fill(NSUMS);
1212         }
1213 
1214         // MBHFP0
1215         if (l1t::EtSum::EtSumType::kMinBiasHFP0 == dataIt->getType()) {
1216           dataEt = dataIt->hwPt();
1217           emulEt = emulIt->hwPt();
1218 
1219           if (dataEt != emulEt) {
1220             eventGood = false;
1221             mbhfp0Data->Fill(dataEt);
1222             mbhfp0Emul->Fill(emulEt);
1223           } else {
1224             agreementSummary->Fill(SUMGOOD_S);
1225             sumSummary->Fill(SUMGOOD);
1226             sumSummary->Fill(MBHFSUMGOOD);
1227           }
1228 
1229           if (verbose) {
1230             edm::LogInfo("L1TdeStage2CaloLayer2") << "MBHFP0    | ";
1231             if (dataEt != emulEt)
1232               edm::LogInfo("L1TdeStage2CaloLayer2") << "x ";
1233             else
1234               edm::LogInfo("L1TdeStage2CaloLayer2") << "  ";
1235             edm::LogInfo("L1TdeStage2CaloLayer2") << dataEt << "\t" << emulEt;
1236             edm::LogInfo("L1TdeStage2CaloLayer2") << std::endl;
1237           }
1238 
1239           // update sum counters
1240           agreementSummary->Fill(NSUMS_S);
1241           sumSummary->Fill(NMBHFSUMS);
1242           sumSummary->Fill(NSUMS);
1243         }
1244 
1245         // MBHFM0
1246         if (l1t::EtSum::EtSumType::kMinBiasHFM0 == dataIt->getType()) {
1247           dataEt = dataIt->hwPt();
1248           emulEt = emulIt->hwPt();
1249 
1250           if (dataEt != emulEt) {
1251             eventGood = false;
1252             mbhfm0Data->Fill(dataEt);
1253             mbhfm0Emul->Fill(emulEt);
1254           } else {
1255             agreementSummary->Fill(SUMGOOD_S);
1256             sumSummary->Fill(SUMGOOD);
1257             sumSummary->Fill(MBHFSUMGOOD);
1258           }
1259 
1260           // update sum counters
1261           agreementSummary->Fill(NSUMS_S);
1262           sumSummary->Fill(NMBHFSUMS);
1263           sumSummary->Fill(NSUMS);
1264         }
1265 
1266         // MBHFP1
1267         if (l1t::EtSum::EtSumType::kMinBiasHFP1 == dataIt->getType()) {
1268           dataEt = dataIt->hwPt();
1269           emulEt = emulIt->hwPt();
1270 
1271           if (dataEt != emulEt) {
1272             eventGood = false;
1273             mbhfp1Data->Fill(dataEt);
1274             mbhfp1Emul->Fill(emulEt);
1275           } else {
1276             agreementSummary->Fill(SUMGOOD_S);
1277             sumSummary->Fill(SUMGOOD);
1278             sumSummary->Fill(MBHFSUMGOOD);
1279           }
1280 
1281           if (verbose) {
1282             edm::LogInfo("L1TdeStage2CaloLayer2") << "MBHFP1    | ";
1283             if (dataEt != emulEt)
1284               edm::LogInfo("L1TdeStage2CaloLayer2") << "x ";
1285             else
1286               edm::LogInfo("L1TdeStage2CaloLayer2") << "  ";
1287             edm::LogInfo("L1TdeStage2CaloLayer2") << dataEt << "\t" << emulEt;
1288             edm::LogInfo("L1TdeStage2CaloLayer2") << std::endl;
1289           }
1290 
1291           // update sum counters
1292           agreementSummary->Fill(NSUMS_S);
1293           sumSummary->Fill(NMBHFSUMS);
1294           sumSummary->Fill(NSUMS);
1295         }
1296 
1297         // MBHFM1
1298         if (l1t::EtSum::EtSumType::kMinBiasHFM1 == dataIt->getType()) {
1299           dataEt = dataIt->hwPt();
1300           emulEt = emulIt->hwPt();
1301 
1302           sumSummary->Fill(NMBHFSUMS);
1303 
1304           if (dataEt != emulEt) {
1305             eventGood = false;
1306             mbhfm1Data->Fill(dataEt);
1307             mbhfm1Emul->Fill(emulEt);
1308           } else {
1309             agreementSummary->Fill(SUMGOOD_S);
1310             sumSummary->Fill(SUMGOOD);
1311             sumSummary->Fill(MBHFSUMGOOD);
1312           }
1313 
1314           if (verbose) {
1315             edm::LogInfo("L1TdeStage2CaloLayer2") << "MBHFM1    | ";
1316             if (dataEt != emulEt)
1317               edm::LogInfo("L1TdeStage2CaloLayer2") << "x ";
1318             else
1319               edm::LogInfo("L1TdeStage2CaloLayer2") << "  ";
1320             edm::LogInfo("L1TdeStage2CaloLayer2") << dataEt << "\t" << emulEt;
1321             edm::LogInfo("L1TdeStage2CaloLayer2") << std::endl;
1322           }
1323 
1324           agreementSummary->Fill(NSUMS_S);
1325           sumSummary->Fill(NSUMS);
1326         }
1327 
1328         // TowerCount
1329         if (l1t::EtSum::EtSumType::kTowerCount == dataIt->getType()) {
1330           dataEt = dataIt->hwPt();
1331           emulEt = emulIt->hwPt();
1332 
1333           if (dataEt != emulEt) {
1334             eventGood = false;
1335             towCountData->Fill(dataEt);
1336             towCountEmul->Fill(emulEt);
1337           } else {
1338             agreementSummary->Fill(SUMGOOD_S);
1339             sumSummary->Fill(SUMGOOD);
1340             sumSummary->Fill(TOWCOUNTGOOD);
1341           }
1342 
1343           if (verbose) {
1344             edm::LogInfo("L1TdeStage2CaloLayer2") << "TowCount  | ";
1345             if (dataEt != emulEt)
1346               edm::LogInfo("L1TdeStage2CaloLayer2") << "x ";
1347             else
1348               edm::LogInfo("L1TdeStage2CaloLayer2") << "  ";
1349             edm::LogInfo("L1TdeStage2CaloLayer2") << dataEt << "\t" << emulEt;
1350             edm::LogInfo("L1TdeStage2CaloLayer2") << std::endl;
1351           }
1352 
1353           // update sum counters
1354           agreementSummary->Fill(NSUMS_S);
1355           sumSummary->Fill(NTOWCOUNTS);
1356           sumSummary->Fill(NSUMS);
1357         }
1358 
1359         // AsymmetryCount
1360         if (l1t::EtSum::EtSumType::kAsymEt == dataIt->getType()) {
1361           dataEt = dataIt->hwPt();
1362           emulEt = emulIt->hwPt();
1363 
1364           if (dataEt != emulEt) {
1365             eventGood = false;
1366             asymCountData->Fill(dataEt);
1367             asymCountEmul->Fill(emulEt);
1368           } else {
1369             agreementSummary->Fill(SUMGOOD_S);
1370             sumSummary->Fill(SUMGOOD);
1371             sumSummary->Fill(ASYMCOUNTGOOD);
1372           }
1373 
1374           if (verbose) {
1375             edm::LogInfo("L1TdeStage2CaloLayer2") << "AsymCount  | ";
1376             if (dataEt != emulEt)
1377               edm::LogInfo("L1TdeStage2CaloLayer2") << "x ";
1378             else
1379               edm::LogInfo("L1TdeStage2CaloLayer2") << "  ";
1380 
1381             edm::LogInfo("L1TdeStage2CaloLayer2") << dataEt << "\t" << emulEt;
1382             edm::LogInfo("L1TdeStage2CaloLayer2") << std::endl;
1383           }
1384           // update sum counters
1385           agreementSummary->Fill(NSUMS_S);
1386           sumSummary->Fill(NASYMCOUNTS);
1387           sumSummary->Fill(NSUMS);
1388         }
1389 
1390         // CentralityCount
1391         if (l1t::EtSum::EtSumType::kCentrality == dataIt->getType()) {
1392           dataCentr = dataIt->hwPt();
1393           emulCentr = emulIt->hwPt();
1394 
1395           if (dataCentr != emulCentr) {
1396             eventGood = false;
1397             if (dataCentr == 0)
1398               centrCountData->Fill(-1);
1399             else {
1400               for (int i = 0; i < 8; i++)
1401                 if (((dataCentr >> i) & 1) == 1)
1402                   centrCountData->Fill(i);
1403             }
1404 
1405             if (emulCentr == 0)
1406               centrCountEmul->Fill(-1);
1407             else {
1408               for (int i = 0; i < 8; i++)
1409                 if (((emulCentr >> i) & 1) == 1)
1410                   centrCountEmul->Fill(i);
1411             }
1412 
1413           } else {
1414             agreementSummary->Fill(SUMGOOD_S);
1415             sumSummary->Fill(SUMGOOD);
1416             sumSummary->Fill(CENTRCOUNTGOOD);
1417           }
1418 
1419           if (verbose) {
1420             edm::LogInfo("L1TdeStage2CaloLayer2") << "CentrCount  | ";
1421             if (dataEt != emulEt)
1422               edm::LogInfo("L1TdeStage2CaloLayer2") << "x ";
1423             else
1424               edm::LogInfo("L1TdeStage2CaloLayer2") << "  ";
1425 
1426             edm::LogInfo("L1TdeStage2CaloLayer2") << dataEt << "\t" << emulEt;
1427             edm::LogInfo("L1TdeStage2CaloLayer2") << std::endl;
1428           }
1429           // update sum counters
1430           agreementSummary->Fill(NSUMS_S);
1431           sumSummary->Fill(NCENTRCOUNTS);
1432           sumSummary->Fill(NSUMS);
1433         }
1434 
1435         break;
1436       }
1437       ++dataIt;
1438       if (dataIt == dataCol->end(currBx))
1439         break;
1440     }
1441 
1442     ++emulIt;
1443     if (emulIt == emulCol->end(currBx))
1444       break;
1445   }
1446   // return a boolean that states whether the jet data in the event is in
1447   // agreement
1448   return eventGood;
1449 }