Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-04 03:24:40

0001 /**
0002  * \class L1ExtraDQM
0003  *
0004  *
0005  * Description: online DQM module for L1Extra trigger objects.
0006  *
0007  * Implementation:
0008  *    <TODO: enter implementation details>
0009  *
0010  * \author: Vasile Mihai Ghete   - HEPHY Vienna
0011  *
0012  *
0013  */
0014 
0015 // this class header
0016 #include "DQM/L1TMonitor/interface/L1ExtraDQM.h"
0017 
0018 // system include files
0019 #include <iostream>
0020 #include <iomanip>
0021 #include <memory>
0022 #include <string>
0023 
0024 // constructor
0025 L1ExtraDQM::L1ExtraDQM(const edm::ParameterSet& paramSet)
0026     :  //
0027       m_retrieveL1Extra(paramSet.getParameter<edm::ParameterSet>("L1ExtraInputTags"), consumesCollector()),
0028       L1ExtraIsoTauJetSource(paramSet.getParameter<edm::InputTag>("L1ExtraIsoTauJetSource_")),
0029       m_dirName(paramSet.getParameter<std::string>("DirName")),
0030       m_stage1_layer2_(paramSet.getParameter<bool>("stage1_layer2_")),
0031       //
0032       m_nrBxInEventGmt(paramSet.getParameter<int>("NrBxInEventGmt")),
0033       m_nrBxInEventGct(paramSet.getParameter<int>("NrBxInEventGct")),
0034       //
0035       m_resetModule(true),
0036       m_currentRun(-99),
0037       //
0038       m_nrEvJob(0),
0039       m_nrEvRun(0),
0040       //
0041       m_histTokens(consumesCollector(), true) {
0042   //
0043   if ((m_nrBxInEventGmt > 0) && ((m_nrBxInEventGmt % 2) == 0)) {
0044     m_nrBxInEventGmt = m_nrBxInEventGmt - 1;
0045 
0046     edm::LogInfo("L1ExtraDQM") << "\nWARNING: Number of bunch crossing to be monitored for GMT rounded to: "
0047                                << m_nrBxInEventGmt << "\n         The number must be an odd number!\n"
0048                                << std::endl;
0049   }
0050 
0051   if ((m_nrBxInEventGct > 0) && ((m_nrBxInEventGct % 2) == 0)) {
0052     m_nrBxInEventGct = m_nrBxInEventGct - 1;
0053 
0054     edm::LogInfo("L1ExtraDQM") << "\nWARNING: Number of bunch crossing to be monitored for GCT rounded to: "
0055                                << m_nrBxInEventGct << "\n         The number must be an odd number!\n"
0056                                << std::endl;
0057   }
0058 
0059   if (m_stage1_layer2_ == true) {
0060     m_tagL1ExtraIsoTauJetTok =
0061         consumes<l1extra::L1JetParticleCollection>(paramSet.getParameter<edm::InputTag>("L1ExtraIsoTauJetSource_"));
0062   }
0063   //
0064   m_meAnalysisL1ExtraMuon.reserve(m_nrBxInEventGmt);
0065   m_meAnalysisL1ExtraIsoEG.reserve(m_nrBxInEventGct);
0066   m_meAnalysisL1ExtraNoIsoEG.reserve(m_nrBxInEventGct);
0067   m_meAnalysisL1ExtraCenJet.reserve(m_nrBxInEventGct);
0068   m_meAnalysisL1ExtraForJet.reserve(m_nrBxInEventGct);
0069   m_meAnalysisL1ExtraTauJet.reserve(m_nrBxInEventGct);
0070   if (m_stage1_layer2_ == true) {
0071     m_meAnalysisL1ExtraIsoTauJet.reserve(m_nrBxInEventGct);
0072   }
0073   m_meAnalysisL1ExtraETT.reserve(m_nrBxInEventGct);
0074   m_meAnalysisL1ExtraETM.reserve(m_nrBxInEventGct);
0075   m_meAnalysisL1ExtraHTT.reserve(m_nrBxInEventGct);
0076   m_meAnalysisL1ExtraHTM.reserve(m_nrBxInEventGct);
0077   m_meAnalysisL1ExtraHfBitCounts.reserve(m_nrBxInEventGct);
0078   m_meAnalysisL1ExtraHfRingEtSums.reserve(m_nrBxInEventGct);
0079 }
0080 
0081 // destructor
0082 L1ExtraDQM::~L1ExtraDQM() {
0083   // empty
0084 }
0085 
0086 void L1ExtraDQM::analyzeL1ExtraMuon(const edm::Event& iEvent, const edm::EventSetup& evSetup) {
0087   bool bookEta = true;
0088   bool bookPhi = true;
0089 
0090   bool isL1Coll = true;
0091 
0092   for (int iBxInEvent = 0; iBxInEvent < m_nrBxInEventGmt; ++iBxInEvent) {
0093     int bxInEvent = iBxInEvent + (m_nrBxInEventGmt + 1) / 2 - m_nrBxInEventGmt;
0094 
0095     (m_meAnalysisL1ExtraMuon.at(iBxInEvent))
0096         ->fillNrObjects(m_retrieveL1Extra.l1ExtraMuon(), m_retrieveL1Extra.validL1ExtraMuon(), isL1Coll, bxInEvent);
0097     (m_meAnalysisL1ExtraMuon.at(iBxInEvent))
0098         ->fillPtPhiEta(m_retrieveL1Extra.l1ExtraMuon(),
0099                        m_retrieveL1Extra.validL1ExtraMuon(),
0100                        bookPhi,
0101                        bookEta,
0102                        isL1Coll,
0103                        bxInEvent);
0104   }
0105 }
0106 
0107 void L1ExtraDQM::analyzeL1ExtraIsoEG(const edm::Event& iEvent, const edm::EventSetup& evSetup) {
0108   bool bookEta = true;
0109   bool bookPhi = true;
0110 
0111   bool isL1Coll = true;
0112 
0113   for (int iBxInEvent = 0; iBxInEvent < m_nrBxInEventGct; ++iBxInEvent) {
0114     int bxInEvent = iBxInEvent + (m_nrBxInEventGct + 1) / 2 - m_nrBxInEventGct;
0115 
0116     (m_meAnalysisL1ExtraIsoEG.at(iBxInEvent))
0117         ->fillNrObjects(m_retrieveL1Extra.l1ExtraIsoEG(), m_retrieveL1Extra.validL1ExtraIsoEG(), isL1Coll, bxInEvent);
0118     (m_meAnalysisL1ExtraIsoEG.at(iBxInEvent))
0119         ->fillPtPhiEta(m_retrieveL1Extra.l1ExtraIsoEG(),
0120                        m_retrieveL1Extra.validL1ExtraIsoEG(),
0121                        bookPhi,
0122                        bookEta,
0123                        isL1Coll,
0124                        bxInEvent);
0125   }
0126 }
0127 
0128 void L1ExtraDQM::analyzeL1ExtraNoIsoEG(const edm::Event& iEvent, const edm::EventSetup& evSetup) {
0129   bool bookEta = true;
0130   bool bookPhi = true;
0131 
0132   bool isL1Coll = true;
0133 
0134   for (int iBxInEvent = 0; iBxInEvent < m_nrBxInEventGct; ++iBxInEvent) {
0135     int bxInEvent = iBxInEvent + (m_nrBxInEventGct + 1) / 2 - m_nrBxInEventGct;
0136 
0137     (m_meAnalysisL1ExtraNoIsoEG.at(iBxInEvent))
0138         ->fillNrObjects(
0139             m_retrieveL1Extra.l1ExtraNoIsoEG(), m_retrieveL1Extra.validL1ExtraNoIsoEG(), isL1Coll, bxInEvent);
0140     (m_meAnalysisL1ExtraNoIsoEG.at(iBxInEvent))
0141         ->fillPtPhiEta(m_retrieveL1Extra.l1ExtraNoIsoEG(),
0142                        m_retrieveL1Extra.validL1ExtraNoIsoEG(),
0143                        bookPhi,
0144                        bookEta,
0145                        isL1Coll,
0146                        bxInEvent);
0147   }
0148 }
0149 
0150 void L1ExtraDQM::analyzeL1ExtraCenJet(const edm::Event& iEvent, const edm::EventSetup& evSetup) {
0151   bool bookEta = true;
0152   bool bookPhi = true;
0153 
0154   bool isL1Coll = true;
0155 
0156   for (int iBxInEvent = 0; iBxInEvent < m_nrBxInEventGct; ++iBxInEvent) {
0157     int bxInEvent = iBxInEvent + (m_nrBxInEventGct + 1) / 2 - m_nrBxInEventGct;
0158 
0159     (m_meAnalysisL1ExtraCenJet.at(iBxInEvent))
0160         ->fillNrObjects(m_retrieveL1Extra.l1ExtraCenJet(), m_retrieveL1Extra.validL1ExtraCenJet(), isL1Coll, bxInEvent);
0161     (m_meAnalysisL1ExtraCenJet.at(iBxInEvent))
0162         ->fillEtPhiEta(m_retrieveL1Extra.l1ExtraCenJet(),
0163                        m_retrieveL1Extra.validL1ExtraCenJet(),
0164                        bookPhi,
0165                        bookEta,
0166                        isL1Coll,
0167                        bxInEvent);
0168   }
0169 }
0170 
0171 void L1ExtraDQM::analyzeL1ExtraForJet(const edm::Event& iEvent, const edm::EventSetup& evSetup) {
0172   bool bookPhi = true;
0173   bool bookEta = true;
0174 
0175   bool isL1Coll = true;
0176 
0177   for (int iBxInEvent = 0; iBxInEvent < m_nrBxInEventGct; ++iBxInEvent) {
0178     int bxInEvent = iBxInEvent + (m_nrBxInEventGct + 1) / 2 - m_nrBxInEventGct;
0179 
0180     (m_meAnalysisL1ExtraForJet.at(iBxInEvent))
0181         ->fillNrObjects(m_retrieveL1Extra.l1ExtraForJet(), m_retrieveL1Extra.validL1ExtraForJet(), isL1Coll, bxInEvent);
0182     (m_meAnalysisL1ExtraForJet.at(iBxInEvent))
0183         ->fillEtPhiEta(m_retrieveL1Extra.l1ExtraForJet(),
0184                        m_retrieveL1Extra.validL1ExtraForJet(),
0185                        bookPhi,
0186                        bookEta,
0187                        isL1Coll,
0188                        bxInEvent);
0189   }
0190 }
0191 
0192 void L1ExtraDQM::analyzeL1ExtraTauJet(const edm::Event& iEvent, const edm::EventSetup& evSetup) {
0193   bool bookPhi = true;
0194   bool bookEta = true;
0195 
0196   bool isL1Coll = true;
0197 
0198   for (int iBxInEvent = 0; iBxInEvent < m_nrBxInEventGct; ++iBxInEvent) {
0199     int bxInEvent = iBxInEvent + (m_nrBxInEventGct + 1) / 2 - m_nrBxInEventGct;
0200 
0201     (m_meAnalysisL1ExtraTauJet.at(iBxInEvent))
0202         ->fillNrObjects(m_retrieveL1Extra.l1ExtraTauJet(), m_retrieveL1Extra.validL1ExtraTauJet(), isL1Coll, bxInEvent);
0203     (m_meAnalysisL1ExtraTauJet.at(iBxInEvent))
0204         ->fillEtPhiEta(m_retrieveL1Extra.l1ExtraTauJet(),
0205                        m_retrieveL1Extra.validL1ExtraTauJet(),
0206                        bookPhi,
0207                        bookEta,
0208                        isL1Coll,
0209                        bxInEvent);
0210   }
0211 }
0212 
0213 void L1ExtraDQM::analyzeL1ExtraIsoTauJet(const edm::Event& iEvent, const edm::EventSetup& evSetup) {
0214   bool bookPhi = true;
0215   bool bookEta = true;
0216 
0217   bool isL1Coll = true;
0218 
0219   bool m_validL1ExtraIsoTauJet;
0220 
0221   edm::Handle<l1extra::L1JetParticleCollection> collL1ExtraIsoTauJet;
0222   iEvent.getByToken(m_tagL1ExtraIsoTauJetTok, collL1ExtraIsoTauJet);
0223 
0224   const l1extra::L1JetParticleCollection* m_l1ExtraIsoTauJet;
0225 
0226   if (collL1ExtraIsoTauJet.isValid()) {
0227     m_validL1ExtraIsoTauJet = true;
0228     m_l1ExtraIsoTauJet = collL1ExtraIsoTauJet.product();
0229   } else {
0230     LogDebug("L1RetrieveL1Extra") << "\n l1extra::L1JetParticleCollection with input tag \n  "
0231                                   << "m_tagL1ExtraIsoTauJet"
0232                                   << "\n not found in the event.\n"
0233                                   << "\n Return pointer 0 and false validity tag." << std::endl;
0234 
0235     m_validL1ExtraIsoTauJet = false;
0236     m_l1ExtraIsoTauJet = nullptr;
0237   }
0238 
0239   for (int iBxInEvent = 0; iBxInEvent < m_nrBxInEventGct; ++iBxInEvent) {
0240     int bxInEvent = iBxInEvent + (m_nrBxInEventGct + 1) / 2 - m_nrBxInEventGct;
0241     (m_meAnalysisL1ExtraIsoTauJet.at(iBxInEvent))
0242         ->fillNrObjects(m_l1ExtraIsoTauJet, m_validL1ExtraIsoTauJet, isL1Coll, bxInEvent);
0243     (m_meAnalysisL1ExtraIsoTauJet.at(iBxInEvent))
0244         ->fillEtPhiEta(m_l1ExtraIsoTauJet, m_validL1ExtraIsoTauJet, bookPhi, bookEta, isL1Coll, bxInEvent);
0245   }
0246 }
0247 
0248 void L1ExtraDQM::analyzeL1ExtraETT(const edm::Event& iEvent, const edm::EventSetup& evSetup) {
0249   bool isL1Coll = true;
0250 
0251   for (int iBxInEvent = 0; iBxInEvent < m_nrBxInEventGct; ++iBxInEvent) {
0252     int bxInEvent = iBxInEvent + (m_nrBxInEventGct + 1) / 2 - m_nrBxInEventGct;
0253 
0254     (m_meAnalysisL1ExtraETT.at(iBxInEvent))
0255         ->fillEtTotal(m_retrieveL1Extra.l1ExtraETT(), m_retrieveL1Extra.validL1ExtraETT(), isL1Coll, bxInEvent);
0256   }
0257 }
0258 
0259 void L1ExtraDQM::analyzeL1ExtraETM(const edm::Event& iEvent, const edm::EventSetup& evSetup) {
0260   bool bookPhi = true;
0261   bool bookEta = false;
0262 
0263   bool isL1Coll = true;
0264 
0265   for (int iBxInEvent = 0; iBxInEvent < m_nrBxInEventGct; ++iBxInEvent) {
0266     int bxInEvent = iBxInEvent + (m_nrBxInEventGct + 1) / 2 - m_nrBxInEventGct;
0267 
0268     (m_meAnalysisL1ExtraETM.at(iBxInEvent))
0269         ->fillEtPhiEta(
0270             m_retrieveL1Extra.l1ExtraETM(), m_retrieveL1Extra.validL1ExtraETM(), bookPhi, bookEta, isL1Coll, bxInEvent);
0271   }
0272 }
0273 
0274 void L1ExtraDQM::analyzeL1ExtraHTT(const edm::Event& iEvent, const edm::EventSetup& evSetup) {
0275   bool isL1Coll = true;
0276 
0277   for (int iBxInEvent = 0; iBxInEvent < m_nrBxInEventGct; ++iBxInEvent) {
0278     int bxInEvent = iBxInEvent + (m_nrBxInEventGct + 1) / 2 - m_nrBxInEventGct;
0279 
0280     (m_meAnalysisL1ExtraHTT.at(iBxInEvent))
0281         ->fillEtTotal(m_retrieveL1Extra.l1ExtraHTT(), m_retrieveL1Extra.validL1ExtraHTT(), isL1Coll, bxInEvent);
0282   }
0283 }
0284 
0285 void L1ExtraDQM::analyzeL1ExtraHTM(const edm::Event& iEvent, const edm::EventSetup& evSetup) {
0286   bool bookPhi = true;
0287   bool bookEta = false;
0288 
0289   bool isL1Coll = true;
0290 
0291   for (int iBxInEvent = 0; iBxInEvent < m_nrBxInEventGct; ++iBxInEvent) {
0292     int bxInEvent = iBxInEvent + (m_nrBxInEventGct + 1) / 2 - m_nrBxInEventGct;
0293 
0294     (m_meAnalysisL1ExtraHTM.at(iBxInEvent))
0295         ->fillEtPhiEta(
0296             m_retrieveL1Extra.l1ExtraHTM(), m_retrieveL1Extra.validL1ExtraHTM(), bookPhi, bookEta, isL1Coll, bxInEvent);
0297   }
0298 }
0299 
0300 void L1ExtraDQM::analyzeL1ExtraHfBitCounts(const edm::Event& iEvent, const edm::EventSetup& evSetup) {
0301   bool isL1Coll = true;
0302 
0303   for (int iBxInEvent = 0; iBxInEvent < m_nrBxInEventGct; ++iBxInEvent) {
0304     int bxInEvent = iBxInEvent + (m_nrBxInEventGct + 1) / 2 - m_nrBxInEventGct;
0305 
0306     for (int iCount = 0; iCount < l1extra::L1HFRings::kNumRings; ++iCount) {
0307       (m_meAnalysisL1ExtraHfBitCounts.at(iBxInEvent))
0308           ->fillHfBitCounts(m_retrieveL1Extra.l1ExtraHfBitCounts(),
0309                             m_retrieveL1Extra.validL1ExtraHfBitCounts(),
0310                             iCount,
0311                             isL1Coll,
0312                             bxInEvent);
0313     }
0314   }
0315 }
0316 
0317 void L1ExtraDQM::analyzeL1ExtraHfRingEtSums(const edm::Event& iEvent, const edm::EventSetup& evSetup) {
0318   bool isL1Coll = true;
0319 
0320   for (int iBxInEvent = 0; iBxInEvent < m_nrBxInEventGct; ++iBxInEvent) {
0321     int bxInEvent = iBxInEvent + (m_nrBxInEventGct + 1) / 2 - m_nrBxInEventGct;
0322 
0323     for (int iCount = 0; iCount < l1extra::L1HFRings::kNumRings; ++iCount) {
0324       (m_meAnalysisL1ExtraHfRingEtSums.at(iBxInEvent))
0325           ->fillHfRingEtSums(m_retrieveL1Extra.l1ExtraHfRingEtSums(),
0326                              m_retrieveL1Extra.validL1ExtraHfRingEtSums(),
0327                              iCount,
0328                              isL1Coll,
0329                              bxInEvent);
0330     }
0331   }
0332 }
0333 
0334 void L1ExtraDQM::dqmBeginRun(edm::Run const& iRun, edm::EventSetup const& evSetup) {}
0335 
0336 void L1ExtraDQM::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const&, edm::EventSetup const& evSetup) {
0337   m_nrEvRun = 0;
0338 
0339   std::vector<L1GtObject> l1Obj;
0340   //const edm::EventSetup& evSetup;
0341 
0342   // define standard sets of histograms
0343 
0344   //
0345   l1Obj.clear();
0346   l1Obj.push_back(Mu);
0347   int nrMonElements = 5;
0348 
0349   for (int iBxInEvent = 0; iBxInEvent < m_nrBxInEventGmt; ++iBxInEvent) {
0350     m_meAnalysisL1ExtraMuon.push_back(
0351         new L1ExtraDQM::L1ExtraMonElement<l1extra::L1MuonParticleCollection>(m_histTokens, nrMonElements));
0352 
0353     int bxInEvent = iBxInEvent + (m_nrBxInEventGct + 1) / 2 - m_nrBxInEventGct;
0354     int bxInEventHex = (bxInEvent + 16) % 16;
0355 
0356     std::stringstream ss;
0357     std::string bxInEventHexString;
0358     ss << std::uppercase << std::hex << bxInEventHex;
0359     ss >> bxInEventHexString;
0360 
0361     ibooker.setCurrentFolder(m_dirName + "/BxInEvent_" + bxInEventHexString);
0362 
0363     (m_meAnalysisL1ExtraMuon.at(iBxInEvent))->bookhistograms(evSetup, ibooker, "L1_Mu", l1Obj);
0364   }
0365 
0366   //
0367   l1Obj.clear();
0368   l1Obj.push_back(IsoEG);
0369   nrMonElements = 4;
0370 
0371   for (int iBxInEvent = 0; iBxInEvent < m_nrBxInEventGct; ++iBxInEvent) {
0372     m_meAnalysisL1ExtraIsoEG.push_back(
0373         new L1ExtraDQM::L1ExtraMonElement<l1extra::L1EmParticleCollection>(m_histTokens, nrMonElements));
0374 
0375     int bxInEvent = iBxInEvent + (m_nrBxInEventGct + 1) / 2 - m_nrBxInEventGct;
0376     int bxInEventHex = (bxInEvent + 16) % 16;
0377 
0378     std::stringstream ss;
0379     std::string bxInEventHexString;
0380     ss << std::uppercase << std::hex << bxInEventHex;
0381     ss >> bxInEventHexString;
0382 
0383     ibooker.setCurrentFolder(m_dirName + "/BxInEvent_" + bxInEventHexString);
0384 
0385     (m_meAnalysisL1ExtraIsoEG.at(iBxInEvent))->bookhistograms(evSetup, ibooker, "L1_IsoEG", l1Obj);
0386   }
0387 
0388   //
0389   l1Obj.clear();
0390   l1Obj.push_back(NoIsoEG);
0391   nrMonElements = 4;
0392 
0393   for (int iBxInEvent = 0; iBxInEvent < m_nrBxInEventGct; ++iBxInEvent) {
0394     m_meAnalysisL1ExtraNoIsoEG.push_back(
0395         new L1ExtraDQM::L1ExtraMonElement<l1extra::L1EmParticleCollection>(m_histTokens, nrMonElements));
0396 
0397     int bxInEvent = iBxInEvent + (m_nrBxInEventGct + 1) / 2 - m_nrBxInEventGct;
0398     int bxInEventHex = (bxInEvent + 16) % 16;
0399 
0400     std::stringstream ss;
0401     std::string bxInEventHexString;
0402     ss << std::uppercase << std::hex << bxInEventHex;
0403     ss >> bxInEventHexString;
0404 
0405     //if (m_dbe) {
0406     ibooker.setCurrentFolder(m_dirName + "/BxInEvent_" + bxInEventHexString);
0407     //}
0408 
0409     (m_meAnalysisL1ExtraNoIsoEG.at(iBxInEvent))->bookhistograms(evSetup, ibooker, "L1_NoIsoEG", l1Obj);
0410   }
0411 
0412   //
0413   l1Obj.clear();
0414   l1Obj.push_back(CenJet);
0415   nrMonElements = 4;
0416 
0417   for (int iBxInEvent = 0; iBxInEvent < m_nrBxInEventGct; ++iBxInEvent) {
0418     m_meAnalysisL1ExtraCenJet.push_back(
0419         new L1ExtraDQM::L1ExtraMonElement<l1extra::L1JetParticleCollection>(m_histTokens, nrMonElements));
0420 
0421     int bxInEvent = iBxInEvent + (m_nrBxInEventGct + 1) / 2 - m_nrBxInEventGct;
0422     int bxInEventHex = (bxInEvent + 16) % 16;
0423 
0424     std::stringstream ss;
0425     std::string bxInEventHexString;
0426     ss << std::uppercase << std::hex << bxInEventHex;
0427     ss >> bxInEventHexString;
0428 
0429     ibooker.setCurrentFolder(m_dirName + "/BxInEvent_" + bxInEventHexString);
0430 
0431     (m_meAnalysisL1ExtraCenJet.at(iBxInEvent))->bookhistograms(evSetup, ibooker, "L1_CenJet", l1Obj);
0432   }
0433 
0434   //
0435   l1Obj.clear();
0436   l1Obj.push_back(ForJet);
0437 
0438   for (int iBxInEvent = 0; iBxInEvent < m_nrBxInEventGct; ++iBxInEvent) {
0439     m_meAnalysisL1ExtraForJet.push_back(
0440         new L1ExtraDQM::L1ExtraMonElement<l1extra::L1JetParticleCollection>(m_histTokens, nrMonElements));
0441 
0442     int bxInEvent = iBxInEvent + (m_nrBxInEventGct + 1) / 2 - m_nrBxInEventGct;
0443     int bxInEventHex = (bxInEvent + 16) % 16;
0444 
0445     std::stringstream ss;
0446     std::string bxInEventHexString;
0447     ss << std::uppercase << std::hex << bxInEventHex;
0448     ss >> bxInEventHexString;
0449 
0450     ibooker.setCurrentFolder(m_dirName + "/BxInEvent_" + bxInEventHexString);
0451 
0452     (m_meAnalysisL1ExtraForJet.at(iBxInEvent))->bookhistograms(evSetup, ibooker, "L1_ForJet", l1Obj);
0453   }
0454 
0455   //
0456   l1Obj.clear();
0457   l1Obj.push_back(TauJet);
0458 
0459   for (int iBxInEvent = 0; iBxInEvent < m_nrBxInEventGct; ++iBxInEvent) {
0460     m_meAnalysisL1ExtraTauJet.push_back(
0461         new L1ExtraDQM::L1ExtraMonElement<l1extra::L1JetParticleCollection>(m_histTokens, nrMonElements));
0462 
0463     int bxInEvent = iBxInEvent + (m_nrBxInEventGct + 1) / 2 - m_nrBxInEventGct;
0464     int bxInEventHex = (bxInEvent + 16) % 16;
0465 
0466     std::stringstream ss;
0467     std::string bxInEventHexString;
0468     ss << std::uppercase << std::hex << bxInEventHex;
0469     ss >> bxInEventHexString;
0470 
0471     ibooker.setCurrentFolder(m_dirName + "/BxInEvent_" + bxInEventHexString);
0472 
0473     (m_meAnalysisL1ExtraTauJet.at(iBxInEvent))->bookhistograms(evSetup, ibooker, "L1_TauJet", l1Obj);
0474   }
0475 
0476   if (m_stage1_layer2_ == true) {
0477     l1Obj.clear();
0478     l1Obj.push_back(TauJet);
0479     nrMonElements = 4;
0480 
0481     for (int iBxInEvent = 0; iBxInEvent < m_nrBxInEventGct; ++iBxInEvent) {
0482       m_meAnalysisL1ExtraIsoTauJet.push_back(
0483           new L1ExtraDQM::L1ExtraMonElement<l1extra::L1JetParticleCollection>(m_histTokens, nrMonElements));
0484 
0485       int bxInEvent = iBxInEvent + (m_nrBxInEventGct + 1) / 2 - m_nrBxInEventGct;
0486       int bxInEventHex = (bxInEvent + 16) % 16;
0487 
0488       std::stringstream ss;
0489       std::string bxInEventHexString;
0490       ss << std::uppercase << std::hex << bxInEventHex;
0491       ss >> bxInEventHexString;
0492 
0493       ibooker.setCurrentFolder(m_dirName + "/BxInEvent_" + bxInEventHexString);
0494 
0495       (m_meAnalysisL1ExtraIsoTauJet.at(iBxInEvent))->bookhistograms(evSetup, ibooker, "L1_IsoTauJet", l1Obj);
0496     }
0497   }
0498 
0499   //
0500   l1Obj.clear();
0501   l1Obj.push_back(ETT);
0502   nrMonElements = 1;
0503 
0504   bool bookPhi = false;
0505   bool bookEta = false;
0506 
0507   for (int iBxInEvent = 0; iBxInEvent < m_nrBxInEventGct; ++iBxInEvent) {
0508     m_meAnalysisL1ExtraETT.push_back(
0509         new L1ExtraDQM::L1ExtraMonElement<l1extra::L1EtMissParticleCollection>(m_histTokens, nrMonElements));
0510 
0511     int bxInEvent = iBxInEvent + (m_nrBxInEventGct + 1) / 2 - m_nrBxInEventGct;
0512     int bxInEventHex = (bxInEvent + 16) % 16;
0513 
0514     std::stringstream ss;
0515     std::string bxInEventHexString;
0516     ss << std::uppercase << std::hex << bxInEventHex;
0517     ss >> bxInEventHexString;
0518 
0519     ibooker.setCurrentFolder(m_dirName + "/BxInEvent_" + bxInEventHexString);
0520 
0521     (m_meAnalysisL1ExtraETT.at(iBxInEvent))->bookhistograms(evSetup, ibooker, "L1_ETT", l1Obj, bookPhi, bookEta);
0522   }
0523 
0524   //
0525   l1Obj.clear();
0526   l1Obj.push_back(ETM);
0527   nrMonElements = 2;
0528 
0529   bookPhi = true;
0530   bookEta = false;
0531 
0532   for (int iBxInEvent = 0; iBxInEvent < m_nrBxInEventGct; ++iBxInEvent) {
0533     m_meAnalysisL1ExtraETM.push_back(
0534         new L1ExtraDQM::L1ExtraMonElement<l1extra::L1EtMissParticleCollection>(m_histTokens, nrMonElements));
0535     int bxInEvent = iBxInEvent + (m_nrBxInEventGct + 1) / 2 - m_nrBxInEventGct;
0536     int bxInEventHex = (bxInEvent + 16) % 16;
0537 
0538     std::stringstream ss;
0539     std::string bxInEventHexString;
0540     ss << std::uppercase << std::hex << bxInEventHex;
0541     ss >> bxInEventHexString;
0542 
0543     ibooker.setCurrentFolder(m_dirName + "/BxInEvent_" + bxInEventHexString);
0544 
0545     (m_meAnalysisL1ExtraETM.at(iBxInEvent))->bookhistograms(evSetup, ibooker, "L1_ETM", l1Obj, bookPhi, bookEta);
0546   }
0547 
0548   //
0549   l1Obj.clear();
0550   l1Obj.push_back(HTT);
0551   nrMonElements = 1;
0552 
0553   bookPhi = false;
0554   bookEta = false;
0555 
0556   for (int iBxInEvent = 0; iBxInEvent < m_nrBxInEventGct; ++iBxInEvent) {
0557     m_meAnalysisL1ExtraHTT.push_back(
0558         new L1ExtraDQM::L1ExtraMonElement<l1extra::L1EtMissParticleCollection>(m_histTokens, nrMonElements));
0559     int bxInEvent = iBxInEvent + (m_nrBxInEventGct + 1) / 2 - m_nrBxInEventGct;
0560     int bxInEventHex = (bxInEvent + 16) % 16;
0561 
0562     std::stringstream ss;
0563     std::string bxInEventHexString;
0564     ss << std::uppercase << std::hex << bxInEventHex;
0565     ss >> bxInEventHexString;
0566 
0567     ibooker.setCurrentFolder(m_dirName + "/BxInEvent_" + bxInEventHexString);
0568 
0569     (m_meAnalysisL1ExtraHTT.at(iBxInEvent))->bookhistograms(evSetup, ibooker, "L1_HTT", l1Obj, bookPhi, bookEta);
0570   }
0571 
0572   //
0573   l1Obj.clear();
0574   l1Obj.push_back(HTM);
0575   nrMonElements = 2;
0576 
0577   bookPhi = true;
0578   bookEta = false;
0579 
0580   for (int iBxInEvent = 0; iBxInEvent < m_nrBxInEventGct; ++iBxInEvent) {
0581     m_meAnalysisL1ExtraHTM.push_back(
0582         new L1ExtraDQM::L1ExtraMonElement<l1extra::L1EtMissParticleCollection>(m_histTokens, nrMonElements));
0583     int bxInEvent = iBxInEvent + (m_nrBxInEventGct + 1) / 2 - m_nrBxInEventGct;
0584     int bxInEventHex = (bxInEvent + 16) % 16;
0585 
0586     std::stringstream ss;
0587     std::string bxInEventHexString;
0588     ss << std::uppercase << std::hex << bxInEventHex;
0589     ss >> bxInEventHexString;
0590 
0591     ibooker.setCurrentFolder(m_dirName + "/BxInEvent_" + bxInEventHexString);
0592 
0593     if (m_stage1_layer2_ == false) {
0594       (m_meAnalysisL1ExtraHTM.at(iBxInEvent))->bookhistograms(evSetup, ibooker, "L1_HTM", l1Obj, bookPhi, bookEta);
0595     } else {
0596       (m_meAnalysisL1ExtraHTM.at(iBxInEvent))->bookhistograms(evSetup, ibooker, "L1_HTMHTT", l1Obj, bookPhi, bookEta);
0597     }
0598   }
0599 
0600   //
0601   l1Obj.clear();
0602   l1Obj.push_back(HfBitCounts);
0603   nrMonElements = 1;
0604 
0605   bookPhi = false;
0606   bookEta = false;
0607 
0608   for (int iBxInEvent = 0; iBxInEvent < m_nrBxInEventGct; ++iBxInEvent) {
0609     m_meAnalysisL1ExtraHfBitCounts.push_back(
0610         new L1ExtraDQM::L1ExtraMonElement<l1extra::L1HFRingsCollection>(m_histTokens, nrMonElements));
0611     int bxInEvent = iBxInEvent + (m_nrBxInEventGct + 1) / 2 - m_nrBxInEventGct;
0612     int bxInEventHex = (bxInEvent + 16) % 16;
0613 
0614     std::stringstream ss;
0615     std::string bxInEventHexString;
0616     ss << std::uppercase << std::hex << bxInEventHex;
0617     ss >> bxInEventHexString;
0618 
0619     ibooker.setCurrentFolder(m_dirName + "/BxInEvent_" + bxInEventHexString);
0620 
0621     (m_meAnalysisL1ExtraHfBitCounts.at(iBxInEvent))
0622         ->bookhistograms(evSetup, ibooker, "L1_HfBitCounts", l1Obj, bookPhi, bookEta);
0623   }
0624 
0625   //
0626   l1Obj.clear();
0627   l1Obj.push_back(HfRingEtSums);
0628   nrMonElements = 1;
0629 
0630   bookPhi = false;
0631   bookEta = false;
0632 
0633   for (int iBxInEvent = 0; iBxInEvent < m_nrBxInEventGct; ++iBxInEvent) {
0634     m_meAnalysisL1ExtraHfRingEtSums.push_back(
0635         new L1ExtraDQM::L1ExtraMonElement<l1extra::L1HFRingsCollection>(m_histTokens, nrMonElements));
0636     int bxInEvent = iBxInEvent + (m_nrBxInEventGct + 1) / 2 - m_nrBxInEventGct;
0637     int bxInEventHex = (bxInEvent + 16) % 16;
0638 
0639     std::stringstream ss;
0640     std::string bxInEventHexString;
0641     ss << std::uppercase << std::hex << bxInEventHex;
0642     ss >> bxInEventHexString;
0643 
0644     ibooker.setCurrentFolder(m_dirName + "/BxInEvent_" + bxInEventHexString);
0645 
0646     if (m_stage1_layer2_ == false) {
0647       (m_meAnalysisL1ExtraHfRingEtSums.at(iBxInEvent))
0648           ->bookhistograms(evSetup, ibooker, "L1_HfRingEtSums", l1Obj, bookPhi, bookEta);
0649     }
0650     if (m_stage1_layer2_ == true) {
0651       (m_meAnalysisL1ExtraHfRingEtSums.at(iBxInEvent))
0652           ->bookhistograms(evSetup, ibooker, "L1_IsoTau_replace_Hf", l1Obj, bookPhi, bookEta);
0653     }
0654   }
0655 }
0656 
0657 //
0658 void L1ExtraDQM::analyze(const edm::Event& iEvent, const edm::EventSetup& evSetup) {
0659   ++m_nrEvJob;
0660   ++m_nrEvRun;
0661   //
0662   m_retrieveL1Extra.retrieveL1ExtraObjects(iEvent, evSetup);
0663   //
0664   analyzeL1ExtraMuon(iEvent, evSetup);
0665   analyzeL1ExtraIsoEG(iEvent, evSetup);
0666   analyzeL1ExtraNoIsoEG(iEvent, evSetup);
0667   analyzeL1ExtraCenJet(iEvent, evSetup);
0668   analyzeL1ExtraForJet(iEvent, evSetup);
0669   analyzeL1ExtraTauJet(iEvent, evSetup);
0670   analyzeL1ExtraETT(iEvent, evSetup);
0671   analyzeL1ExtraETM(iEvent, evSetup);
0672   analyzeL1ExtraHTT(iEvent, evSetup);
0673   analyzeL1ExtraHTM(iEvent, evSetup);
0674   analyzeL1ExtraHfBitCounts(iEvent, evSetup);
0675   analyzeL1ExtraHfRingEtSums(iEvent, evSetup);
0676 
0677   if (m_stage1_layer2_ == true) {
0678     analyzeL1ExtraIsoTauJet(iEvent, evSetup);
0679   }
0680 }
0681 
0682 void L1ExtraDQM::dqmEndRun(const edm::Run& run, const edm::EventSetup& evSetup) {
0683   // delete if event setup has changed only FIXME
0684 
0685   for (std::vector<L1ExtraMonElement<l1extra::L1MuonParticleCollection>*>::iterator iterME =
0686            m_meAnalysisL1ExtraMuon.begin();
0687        iterME != m_meAnalysisL1ExtraMuon.end();
0688        ++iterME) {
0689     delete *iterME;
0690   }
0691   m_meAnalysisL1ExtraMuon.clear();
0692 
0693   for (std::vector<L1ExtraMonElement<l1extra::L1EmParticleCollection>*>::iterator iterME =
0694            m_meAnalysisL1ExtraIsoEG.begin();
0695        iterME != m_meAnalysisL1ExtraIsoEG.end();
0696        ++iterME) {
0697     delete *iterME;
0698   }
0699   m_meAnalysisL1ExtraIsoEG.clear();
0700 
0701   for (std::vector<L1ExtraMonElement<l1extra::L1EmParticleCollection>*>::iterator iterME =
0702            m_meAnalysisL1ExtraNoIsoEG.begin();
0703        iterME != m_meAnalysisL1ExtraNoIsoEG.end();
0704        ++iterME) {
0705     delete *iterME;
0706   }
0707   m_meAnalysisL1ExtraNoIsoEG.clear();
0708 
0709   for (std::vector<L1ExtraMonElement<l1extra::L1JetParticleCollection>*>::iterator iterME =
0710            m_meAnalysisL1ExtraCenJet.begin();
0711        iterME != m_meAnalysisL1ExtraCenJet.end();
0712        ++iterME) {
0713     delete *iterME;
0714   }
0715   m_meAnalysisL1ExtraCenJet.clear();
0716 
0717   for (std::vector<L1ExtraMonElement<l1extra::L1JetParticleCollection>*>::iterator iterME =
0718            m_meAnalysisL1ExtraForJet.begin();
0719        iterME != m_meAnalysisL1ExtraForJet.end();
0720        ++iterME) {
0721     delete *iterME;
0722   }
0723   m_meAnalysisL1ExtraForJet.clear();
0724 
0725   for (std::vector<L1ExtraMonElement<l1extra::L1JetParticleCollection>*>::iterator iterME =
0726            m_meAnalysisL1ExtraTauJet.begin();
0727        iterME != m_meAnalysisL1ExtraTauJet.end();
0728        ++iterME) {
0729     delete *iterME;
0730   }
0731   m_meAnalysisL1ExtraTauJet.clear();
0732 
0733   for (std::vector<L1ExtraMonElement<l1extra::L1EtMissParticleCollection>*>::iterator iterME =
0734            m_meAnalysisL1ExtraETT.begin();
0735        iterME != m_meAnalysisL1ExtraETT.end();
0736        ++iterME) {
0737     delete *iterME;
0738   }
0739   m_meAnalysisL1ExtraETT.clear();
0740 
0741   for (std::vector<L1ExtraMonElement<l1extra::L1EtMissParticleCollection>*>::iterator iterME =
0742            m_meAnalysisL1ExtraETM.begin();
0743        iterME != m_meAnalysisL1ExtraETM.end();
0744        ++iterME) {
0745     delete *iterME;
0746   }
0747   m_meAnalysisL1ExtraETM.clear();
0748 
0749   for (std::vector<L1ExtraMonElement<l1extra::L1EtMissParticleCollection>*>::iterator iterME =
0750            m_meAnalysisL1ExtraHTT.begin();
0751        iterME != m_meAnalysisL1ExtraHTT.end();
0752        ++iterME) {
0753     delete *iterME;
0754   }
0755   m_meAnalysisL1ExtraHTT.clear();
0756 
0757   for (std::vector<L1ExtraMonElement<l1extra::L1EtMissParticleCollection>*>::iterator iterME =
0758            m_meAnalysisL1ExtraHTM.begin();
0759        iterME != m_meAnalysisL1ExtraHTM.end();
0760        ++iterME) {
0761     delete *iterME;
0762   }
0763   m_meAnalysisL1ExtraHTM.clear();
0764 
0765   for (std::vector<L1ExtraMonElement<l1extra::L1HFRingsCollection>*>::iterator iterME =
0766            m_meAnalysisL1ExtraHfBitCounts.begin();
0767        iterME != m_meAnalysisL1ExtraHfBitCounts.end();
0768        ++iterME) {
0769     delete *iterME;
0770   }
0771   m_meAnalysisL1ExtraHfBitCounts.clear();
0772 
0773   for (std::vector<L1ExtraMonElement<l1extra::L1HFRingsCollection>*>::iterator iterME =
0774            m_meAnalysisL1ExtraHfRingEtSums.begin();
0775        iterME != m_meAnalysisL1ExtraHfRingEtSums.end();
0776        ++iterME) {
0777     delete *iterME;
0778   }
0779   m_meAnalysisL1ExtraHfRingEtSums.clear();
0780 
0781   LogDebug("L1ExtraDQM") << "\n\n endRun: " << run.id()
0782                          << "\n  Number of events analyzed in this run:       " << m_nrEvRun
0783                          << "\n  Total number of events analyzed in this job: " << m_nrEvJob << "\n"
0784                          << std::endl;
0785 }
0786 
0787 // constructor L1ExtraMonElement
0788 template <class CollectionType>
0789 L1ExtraDQM::L1ExtraMonElement<CollectionType>::L1ExtraMonElement(const L1GetHistLimits::Tokens& tokens,
0790                                                                  const int nrElements)
0791     : m_tokens(tokens),
0792       m_indexNrObjects(-1),
0793       m_indexPt(-1),
0794       m_indexEt(-1),
0795       m_indexPhi(-1),
0796       m_indexEta(-1),
0797       m_indexEtTotal(-1),
0798       m_indexCharge(-1),
0799       m_indexHfBitCounts(-1),
0800       m_indexHfRingEtSums(-1) {
0801   m_monElement.reserve(nrElements);
0802 }
0803 
0804 // destructor L1ExtraMonElement
0805 template <class CollectionType>
0806 L1ExtraDQM::L1ExtraMonElement<CollectionType>::~L1ExtraMonElement() {
0807   //empty
0808 }
0809 
0810 template <class CollectionType>
0811 void L1ExtraDQM::L1ExtraMonElement<CollectionType>::bookhistograms(const edm::EventSetup& evSetup,
0812                                                                    DQMStore::IBooker& ibooker,
0813                                                                    const std::string& l1ExtraObject,
0814                                                                    const std::vector<L1GtObject>& l1GtObj,
0815                                                                    const bool bookPhi,
0816                                                                    const bool bookEta) {
0817   // FIXME
0818   L1GtObject gtObj = l1GtObj.at(0);
0819 
0820   //
0821   std::string histName;
0822   std::string histTitle;
0823   std::string xAxisTitle;
0824   std::string yAxisTitle;
0825 
0826   std::string quantity = "";
0827 
0828   int indexHistogram = -1;
0829 
0830   if (gtObj == HfBitCounts) {
0831     L1GetHistLimits l1GetHistLimits(m_tokens, evSetup);
0832     const L1GetHistLimits::L1HistLimits& histLimits = l1GetHistLimits.l1HistLimits(gtObj, quantity);
0833 
0834     const int histNrBins = histLimits.nrBins;
0835     const double histMinValue = histLimits.lowerBinValue;
0836     const double histMaxValue = histLimits.upperBinValue;
0837 
0838     indexHistogram++;
0839     m_indexHfBitCounts = indexHistogram;
0840 
0841     for (int iCount = 0; iCount < l1extra::L1HFRings::kNumRings; ++iCount) {
0842       histName = l1ExtraObject + "_Count_" + std::to_string(iCount);
0843       histTitle = l1ExtraObject + ": count " + std::to_string(iCount);
0844       xAxisTitle = l1ExtraObject;
0845       yAxisTitle = "Entries";
0846 
0847       m_monElement.push_back(ibooker.book1D(histName, histTitle, histNrBins, histMinValue, histMaxValue));
0848       m_monElement[m_indexHfBitCounts + iCount]->setAxisTitle(xAxisTitle, 1);
0849       m_monElement[m_indexHfBitCounts + iCount]->setAxisTitle(yAxisTitle, 2);
0850     }
0851 
0852     return;
0853   }
0854 
0855   // number of objects per event
0856   if ((gtObj == Mu) || (gtObj == IsoEG) || (gtObj == NoIsoEG) || (gtObj == CenJet) || (gtObj == ForJet) ||
0857       (gtObj == TauJet)) {
0858     quantity = "NrObjects";
0859 
0860     L1GetHistLimits l1GetHistLimits(m_tokens, evSetup);
0861     const L1GetHistLimits::L1HistLimits& histLimits = l1GetHistLimits.l1HistLimits(gtObj, quantity);
0862 
0863     const int histNrBins = histLimits.nrBins;
0864     const double histMinValue = histLimits.lowerBinValue;
0865     const double histMaxValue = histLimits.upperBinValue;
0866 
0867     histName = l1ExtraObject + "_NrObjectsPerEvent";
0868     histTitle = l1ExtraObject + ": number of objects per event";
0869     xAxisTitle = "Nr_" + l1ExtraObject;
0870     yAxisTitle = "Entries";
0871 
0872     m_monElement.push_back(ibooker.book1D(histName, histTitle, histNrBins, histMinValue, histMaxValue));
0873     indexHistogram++;
0874 
0875     m_monElement[indexHistogram]->setAxisTitle(xAxisTitle, 1);
0876     m_monElement[indexHistogram]->setAxisTitle(yAxisTitle, 2);
0877     m_indexNrObjects = indexHistogram;
0878   }
0879 
0880   // transverse momentum (energy)  PT (ET) [GeV]
0881 
0882   quantity = "ET";
0883   std::string quantityLongName = " transverse energy ";
0884 
0885   if (gtObj == Mu) {
0886     quantity = "PT";
0887     quantityLongName = " transverse momentum ";
0888   }
0889 
0890   L1GetHistLimits l1GetHistLimits(m_tokens, evSetup);
0891   const L1GetHistLimits::L1HistLimits& histLimits = l1GetHistLimits.l1HistLimits(gtObj, quantity);
0892 
0893   const int histNrBinsET = histLimits.nrBins;
0894   const double histMinValueET = histLimits.lowerBinValue;
0895   const double histMaxValueET = histLimits.upperBinValue;
0896   const std::vector<float>& binThresholdsET = histLimits.binThresholds;
0897 
0898   float* binThresholdsETf;
0899   size_t sizeBinThresholdsET = binThresholdsET.size();
0900   binThresholdsETf = new float[sizeBinThresholdsET];
0901   copy(binThresholdsET.begin(), binThresholdsET.end(), binThresholdsETf);
0902 
0903   LogDebug("L1ExtraDQM") << "\n PT/ET histogram for " << l1ExtraObject << "\n histNrBinsET = " << histNrBinsET
0904                          << "\n histMinValueET = " << histMinValueET << "\n histMaxValueET = " << histMaxValueET
0905                          << "\n Last bin value represents the upper limit of the histogram" << std::endl;
0906   for (size_t iBin = 0; iBin < sizeBinThresholdsET; ++iBin) {
0907     LogTrace("L1ExtraDQM") << "Bin " << iBin << ": " << quantity << " = " << binThresholdsETf[iBin] << " GeV"
0908                            << std::endl;
0909   }
0910 
0911   histName = l1ExtraObject + "_" + quantity;
0912   histTitle = l1ExtraObject + ":" + quantityLongName + quantity + " [GeV]";
0913   xAxisTitle = l1ExtraObject + "_" + quantity + " [GeV]";
0914   yAxisTitle = "Entries";
0915 
0916   if (gtObj == HfRingEtSums) {
0917     indexHistogram++;
0918     m_indexHfRingEtSums = indexHistogram;
0919 
0920     for (int iCount = 0; iCount < l1extra::L1HFRings::kNumRings; ++iCount) {
0921       histName = l1ExtraObject + "_Count_" + std::to_string(iCount);
0922       histTitle = l1ExtraObject + ": count " + std::to_string(iCount);
0923       xAxisTitle = l1ExtraObject;
0924       yAxisTitle = "Entries";
0925 
0926       m_monElement.push_back(ibooker.book1D(histName, histTitle, histNrBinsET, binThresholdsETf));
0927 
0928       m_monElement[m_indexHfRingEtSums + iCount]->setAxisTitle(xAxisTitle, 1);
0929       m_monElement[m_indexHfRingEtSums + iCount]->setAxisTitle(yAxisTitle, 2);
0930     }
0931 
0932   } else {
0933     m_monElement.push_back(ibooker.book1D(histName, histTitle, histNrBinsET, binThresholdsETf));
0934     indexHistogram++;
0935 
0936     m_monElement[indexHistogram]->setAxisTitle(xAxisTitle, 1);
0937     m_monElement[indexHistogram]->setAxisTitle(yAxisTitle, 2);
0938     m_indexPt = indexHistogram;
0939     m_indexEt = indexHistogram;
0940     m_indexEtTotal = indexHistogram;
0941   }
0942 
0943   delete[] binThresholdsETf;
0944 
0945   //
0946 
0947   if (bookPhi) {
0948     quantity = "phi";
0949 
0950     // get limits and binning from L1Extra
0951     L1GetHistLimits l1GetHistLimits(m_tokens, evSetup);
0952     const L1GetHistLimits::L1HistLimits& histLimits = l1GetHistLimits.l1HistLimits(gtObj, quantity);
0953 
0954     const int histNrBinsPhi = histLimits.nrBins;
0955     const double histMinValuePhi = histLimits.lowerBinValue;
0956     const double histMaxValuePhi = histLimits.upperBinValue;
0957     const std::vector<float>& binThresholdsPhi = histLimits.binThresholds;
0958 
0959     float* binThresholdsPhif;
0960     size_t sizeBinThresholdsPhi = binThresholdsPhi.size();
0961     binThresholdsPhif = new float[sizeBinThresholdsPhi];
0962     copy(binThresholdsPhi.begin(), binThresholdsPhi.end(), binThresholdsPhif);
0963 
0964     LogDebug("L1ExtraDQM") << "\n phi histogram for " << l1ExtraObject << "\n histNrBinsPhi = " << histNrBinsPhi
0965                            << "\n histMinValuePhi = " << histMinValuePhi << "\n histMaxValuePhi = " << histMaxValuePhi
0966                            << "\n Last bin value represents the upper limit of the histogram" << std::endl;
0967     for (size_t iBin = 0; iBin < sizeBinThresholdsPhi; ++iBin) {
0968       LogTrace("L1ExtraDQM") << "Bin " << iBin << ": phi = " << binThresholdsPhif[iBin] << " deg" << std::endl;
0969     }
0970 
0971     histName = l1ExtraObject + "_phi";
0972     histTitle = l1ExtraObject + ": phi distribution ";
0973     xAxisTitle = l1ExtraObject + "_phi [deg]";
0974     yAxisTitle = "Entries";
0975 
0976     m_monElement.push_back(ibooker.book1D(histName, histTitle, histNrBinsPhi, histMinValuePhi, histMaxValuePhi));
0977     indexHistogram++;
0978 
0979     m_monElement[indexHistogram]->setAxisTitle(xAxisTitle, 1);
0980     m_monElement[indexHistogram]->setAxisTitle(yAxisTitle, 2);
0981     m_indexPhi = indexHistogram;
0982 
0983     delete[] binThresholdsPhif;
0984   }
0985 
0986   //
0987 
0988   if (bookEta) {
0989     quantity = "eta";
0990 
0991     // get limits and binning from L1Extra
0992     L1GetHistLimits l1GetHistLimits(m_tokens, evSetup);
0993     const L1GetHistLimits::L1HistLimits& histLimits = l1GetHistLimits.l1HistLimits(gtObj, quantity);
0994 
0995     const int histNrBinsEta = histLimits.nrBins;
0996     const double histMinValueEta = histLimits.lowerBinValue;
0997     const double histMaxValueEta = histLimits.upperBinValue;
0998     const std::vector<float>& binThresholdsEta = histLimits.binThresholds;
0999 
1000     //
1001     float* binThresholdsEtaf;
1002     size_t sizeBinThresholdsEta = binThresholdsEta.size();
1003     binThresholdsEtaf = new float[sizeBinThresholdsEta];
1004     copy(binThresholdsEta.begin(), binThresholdsEta.end(), binThresholdsEtaf);
1005 
1006     LogDebug("L1ExtraDQM") << "\n eta histogram for " << l1ExtraObject << "\n histNrBinsEta = " << histNrBinsEta
1007                            << "\n histMinValueEta = " << histMinValueEta << "\n histMaxValueEta = " << histMaxValueEta
1008                            << "\n Last bin value represents the upper limit of the histogram" << std::endl;
1009     for (size_t iBin = 0; iBin < sizeBinThresholdsEta; ++iBin) {
1010       LogTrace("L1ExtraDQM") << "Bin " << iBin << ": eta = " << binThresholdsEtaf[iBin] << std::endl;
1011     }
1012 
1013     histName = l1ExtraObject + "_eta";
1014     histTitle = l1ExtraObject + ": eta distribution ";
1015     xAxisTitle = l1ExtraObject + "_eta";
1016     yAxisTitle = "Entries";
1017 
1018     m_monElement.push_back(ibooker.book1D(histName, histTitle, histNrBinsEta, binThresholdsEtaf));
1019     indexHistogram++;
1020 
1021     m_monElement[indexHistogram]->setAxisTitle(xAxisTitle, 1);
1022     m_monElement[indexHistogram]->setAxisTitle(yAxisTitle, 2);
1023     m_indexEta = indexHistogram;
1024 
1025     delete[] binThresholdsEtaf;
1026   }
1027 }
1028 
1029 template <class CollectionType>
1030 void L1ExtraDQM::L1ExtraMonElement<CollectionType>::fillNrObjects(const CollectionType* collType,
1031                                                                   const bool validColl,
1032                                                                   const bool isL1Coll,
1033                                                                   const int bxInEvent) {
1034   if (validColl && isL1Coll) {
1035     size_t collSize = 0;
1036     for (CIterColl iterColl = collType->begin(); iterColl != collType->end(); ++iterColl) {
1037       if (iterColl->bx() == bxInEvent) {
1038         collSize++;
1039       }
1040     }
1041     m_monElement[m_indexNrObjects]->Fill(collSize);
1042   } else {
1043     size_t collSize = collType->size();
1044     m_monElement[m_indexNrObjects]->Fill(collSize);
1045   }
1046 }
1047 
1048 template <class CollectionType>
1049 void L1ExtraDQM::L1ExtraMonElement<CollectionType>::fillPtPhiEta(const CollectionType* collType,
1050                                                                  const bool validColl,
1051                                                                  const bool bookPhi,
1052                                                                  const bool bookEta,
1053                                                                  const bool isL1Coll,
1054                                                                  const int bxInEvent) {
1055   if (validColl) {
1056     for (CIterColl iterColl = collType->begin(); iterColl != collType->end(); ++iterColl) {
1057       if (isL1Coll && (iterColl->bx() != bxInEvent)) {
1058         continue;
1059       }
1060 
1061       m_monElement[m_indexPt]->Fill(iterColl->pt());
1062 
1063       if (bookPhi) {
1064         // add a very small quantity to get off the bin edge
1065         m_monElement[m_indexPhi]->Fill(rad2deg(iterColl->phi()) + 1.e-6);
1066       }
1067 
1068       if (bookEta) {
1069         m_monElement[m_indexEta]->Fill(iterColl->eta());
1070       }
1071     }
1072   }
1073 }
1074 
1075 template <class CollectionType>
1076 void L1ExtraDQM::L1ExtraMonElement<CollectionType>::fillEtPhiEta(const CollectionType* collType,
1077                                                                  const bool validColl,
1078                                                                  const bool bookPhi,
1079                                                                  const bool bookEta,
1080                                                                  const bool isL1Coll,
1081                                                                  const int bxInEvent) {
1082   if (validColl) {
1083     for (CIterColl iterColl = collType->begin(); iterColl != collType->end(); ++iterColl) {
1084       if (isL1Coll && (iterColl->bx() != bxInEvent)) {
1085         continue;
1086       }
1087 
1088       m_monElement[m_indexEt]->Fill(iterColl->et());
1089 
1090       if (bookPhi) {
1091         // add a very small quantity to get off the bin edge
1092         m_monElement[m_indexPhi]->Fill(rad2deg(iterColl->phi()) + 1.e-6);
1093       }
1094 
1095       if (bookEta) {
1096         m_monElement[m_indexEta]->Fill(iterColl->eta());
1097       }
1098     }
1099   }
1100 }
1101 
1102 template <class CollectionType>
1103 void L1ExtraDQM::L1ExtraMonElement<CollectionType>::fillEtTotal(const CollectionType* collType,
1104                                                                 const bool validColl,
1105                                                                 const bool isL1Coll,
1106                                                                 const int bxInEvent) {
1107   if (validColl) {
1108     for (CIterColl iterColl = collType->begin(); iterColl != collType->end(); ++iterColl) {
1109       if (isL1Coll && (iterColl->bx() != bxInEvent)) {
1110         continue;
1111       }
1112 
1113       m_monElement[m_indexEtTotal]->Fill(iterColl->etTotal());
1114     }
1115   }
1116 }
1117 
1118 template <class CollectionType>
1119 void L1ExtraDQM::L1ExtraMonElement<CollectionType>::fillCharge(const CollectionType* collType,
1120                                                                const bool validColl,
1121                                                                const bool isL1Coll,
1122                                                                const int bxInEvent) {
1123   if (validColl) {
1124     for (CIterColl iterColl = collType->begin(); iterColl != collType->end(); ++iterColl) {
1125       if (isL1Coll && (iterColl->bx() != bxInEvent)) {
1126         continue;
1127       }
1128 
1129       m_monElement[m_indexCharge]->Fill(iterColl->charge());
1130     }
1131   }
1132 }
1133 
1134 template <class CollectionType>
1135 void L1ExtraDQM::L1ExtraMonElement<CollectionType>::fillHfBitCounts(const CollectionType* collType,
1136                                                                     const bool validColl,
1137                                                                     const int countIndex,
1138                                                                     const bool isL1Coll,
1139                                                                     const int bxInEvent) {
1140   if (validColl) {
1141     for (CIterColl iterColl = collType->begin(); iterColl != collType->end(); ++iterColl) {
1142       if (isL1Coll && (iterColl->bx() != bxInEvent)) {
1143         continue;
1144       }
1145 
1146       m_monElement[m_indexHfBitCounts + countIndex]->Fill(
1147           iterColl->hfBitCount((l1extra::L1HFRings::HFRingLabels)countIndex));
1148     }
1149   }
1150 }
1151 
1152 template <class CollectionType>
1153 void L1ExtraDQM::L1ExtraMonElement<CollectionType>::fillHfRingEtSums(const CollectionType* collType,
1154                                                                      const bool validColl,
1155                                                                      const int countIndex,
1156                                                                      const bool isL1Coll,
1157                                                                      const int bxInEvent) {
1158   if (validColl) {
1159     for (CIterColl iterColl = collType->begin(); iterColl != collType->end(); ++iterColl) {
1160       if (isL1Coll && (iterColl->bx() != bxInEvent)) {
1161         continue;
1162       }
1163 
1164       m_monElement[m_indexHfRingEtSums + countIndex]->Fill(
1165           iterColl->hfEtSum((l1extra::L1HFRings::HFRingLabels)countIndex));
1166     }
1167   }
1168 }