Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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