Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:22:33

0001 // -*- C++ -*-
0002 //
0003 // Package:    GctTimingAnalyzer
0004 // Class:      GctTimingAnalyzer
0005 //
0006 /**\class GctTimingAnalyzer GctTimingAnalyzer.cc L1Trigger/L1GctAnalzyer/src/GctTimingAnalyzer.cc
0007 
0008 Description: Analyse the timing of all of the GCT pipelines
0009 
0010 */
0011 //
0012 // Original Author:  Alex Tapper
0013 //         Created:  Mon Apr 21 14:21:06 CEST 2008
0014 //
0015 //
0016 
0017 // Include file
0018 #include "L1Trigger/L1GctAnalyzer/interface/GctTimingAnalyzer.h"
0019 
0020 GctTimingAnalyzer::GctTimingAnalyzer(const edm::ParameterSet& iConfig)
0021     : m_outputFileName(iConfig.getUntrackedParameter<std::string>("outFile", "gctTiming.txt")),
0022       m_gctSource(iConfig.getUntrackedParameter<edm::InputTag>("gctSource")),
0023       m_isoEmSource(iConfig.getUntrackedParameter<edm::InputTag>("isoEmSource")),
0024       m_nonIsoEmSource(iConfig.getUntrackedParameter<edm::InputTag>("nonIsoEmSource")),
0025       m_cenJetsSource(iConfig.getUntrackedParameter<edm::InputTag>("cenJetsSource")),
0026       m_forJetsSource(iConfig.getUntrackedParameter<edm::InputTag>("forJetsSource")),
0027       m_tauJetsSource(iConfig.getUntrackedParameter<edm::InputTag>("tauJetsSource")),
0028       m_doInternal(iConfig.getUntrackedParameter<bool>("doInternal")),
0029       m_doElectrons(iConfig.getUntrackedParameter<bool>("doElectrons")),
0030       m_doJets(iConfig.getUntrackedParameter<bool>("doJets")),
0031       m_doHFRings(iConfig.getUntrackedParameter<bool>("doHFRings")),
0032       m_doESums(iConfig.getUntrackedParameter<bool>("doESums")),
0033       m_evtNum(0) {
0034   m_outputFile.open(m_outputFileName.c_str());
0035 }
0036 
0037 GctTimingAnalyzer::~GctTimingAnalyzer() { m_outputFile.close(); }
0038 
0039 void GctTimingAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0040   using namespace edm;
0041   using namespace std;
0042 
0043   // Electrons
0044   if (m_doElectrons) {
0045     // Isolated EM cands in GCT output
0046     Handle<L1GctEmCandCollection> isoEm;
0047     iEvent.getByLabel(m_isoEmSource, isoEm);
0048 
0049     for (L1GctEmCandCollection::const_iterator em = isoEm->begin(); em != isoEm->end(); em++) {
0050       if (em->rank() > 0) {
0051         m_outputFile << "BX = " << dec << m_evtNum << " " << (*em) << std::endl;
0052       }
0053     }
0054 
0055     // Non-Isolated EM cands in GCT output
0056     Handle<L1GctEmCandCollection> nonIsoEm;
0057     iEvent.getByLabel(m_nonIsoEmSource, nonIsoEm);
0058 
0059     for (L1GctEmCandCollection::const_iterator em = nonIsoEm->begin(); em != nonIsoEm->end(); em++) {
0060       if (em->rank() > 0) {
0061         m_outputFile << "BX = " << dec << m_evtNum << " " << (*em) << std::endl;
0062       }
0063     }
0064 
0065     if (m_doInternal) {
0066       // Internal GCT EM cands
0067       Handle<L1GctInternEmCandCollection> internEm;
0068       iEvent.getByLabel(m_gctSource, internEm);
0069 
0070       if (internEm.isValid()) {
0071         for (L1GctInternEmCandCollection::const_iterator em = internEm->begin(); em != internEm->end(); em++) {
0072           if (em->rank() > 0) {
0073             m_outputFile << "BX = " << dec << m_evtNum << " " << (*em) << std::endl;
0074           }
0075         }
0076       }
0077     }
0078 
0079     // RCT EM cands
0080     Handle<L1CaloEmCollection> rctEm;
0081     iEvent.getByLabel(m_gctSource, rctEm);
0082 
0083     for (L1CaloEmCollection::const_iterator em = rctEm->begin(); em != rctEm->end(); em++) {
0084       if (em->rank() > 0) {
0085         m_outputFile << "BX = " << dec << m_evtNum << " " << (*em) << std::endl;
0086       }
0087     }
0088   }
0089 
0090   // Jets
0091   if (m_doJets) {
0092     // Central jet cands in GCT output
0093     Handle<L1GctJetCandCollection> cenJets;
0094     iEvent.getByLabel(m_cenJetsSource, cenJets);
0095 
0096     for (L1GctJetCandCollection::const_iterator cj = cenJets->begin(); cj != cenJets->end(); cj++) {
0097       if (cj->rank() > 0) {
0098         m_outputFile << "BX = " << dec << m_evtNum << " " << (*cj) << std::endl;
0099       }
0100     }
0101 
0102     // Forward jet cands in GCT output
0103     Handle<L1GctJetCandCollection> forJets;
0104     iEvent.getByLabel(m_forJetsSource, forJets);
0105 
0106     for (L1GctJetCandCollection::const_iterator fj = forJets->begin(); fj != forJets->end(); fj++) {
0107       if (fj->rank() > 0) {
0108         m_outputFile << "BX = " << dec << m_evtNum << " " << (*fj) << std::endl;
0109       }
0110     }
0111 
0112     // Tau jet cands in GCT output
0113     Handle<L1GctJetCandCollection> tauJets;
0114     iEvent.getByLabel(m_tauJetsSource, tauJets);
0115 
0116     for (L1GctJetCandCollection::const_iterator tj = tauJets->begin(); tj != tauJets->end(); tj++) {
0117       if (tj->rank() > 0) {
0118         m_outputFile << "BX = " << dec << m_evtNum << " " << (*tj) << std::endl;
0119       }
0120     }
0121 
0122     if (m_doInternal) {
0123       // Internal GCT jet cands
0124       Handle<L1GctInternJetDataCollection> internJets;
0125       iEvent.getByLabel(m_gctSource, internJets);
0126 
0127       if (internJets.isValid()) {
0128         for (L1GctInternJetDataCollection::const_iterator j = internJets->begin(); j != internJets->end(); j++) {
0129           if ((j->et() > 0) || (j->rank() > 0)) {
0130             m_outputFile << "BX = " << dec << m_evtNum << " " << (*j) << std::endl;
0131           }
0132         }
0133       }
0134     }
0135   }
0136 
0137   // RCT regions
0138   Handle<L1CaloRegionCollection> rctRn;
0139   iEvent.getByLabel(m_gctSource, rctRn);
0140 
0141   for (L1CaloRegionCollection::const_iterator rn = rctRn->begin(); rn != rctRn->end(); rn++) {
0142     if (rn->et() > 0) {
0143       m_outputFile << "BX = " << dec << m_evtNum << " " << (*rn) << std::endl;
0144     }
0145   }
0146 
0147   // HF Rings
0148   if (m_doHFRings) {
0149     // HFRing counts
0150     Handle<L1GctHFBitCountsCollection> hfBitCnt;
0151     iEvent.getByLabel(m_gctSource, hfBitCnt);
0152 
0153     for (L1GctHFBitCountsCollection::const_iterator jc = hfBitCnt->begin(); jc != hfBitCnt->end(); jc++) {
0154       if (jc->bitCount(0) || jc->bitCount(1) || jc->bitCount(2) || jc->bitCount(3)) {
0155         m_outputFile << "BX = " << dec << m_evtNum << " " << (*jc) << std::endl;
0156       }
0157     }
0158 
0159     // HFRing Et sums
0160     Handle<L1GctHFRingEtSumsCollection> hfEtSums;
0161     iEvent.getByLabel(m_gctSource, hfEtSums);
0162 
0163     for (L1GctHFRingEtSumsCollection::const_iterator js = hfEtSums->begin(); js != hfEtSums->end(); js++) {
0164       if (js->etSum(0) || js->etSum(1) || js->etSum(2) || js->etSum(3)) {
0165         m_outputFile << "BX = " << dec << m_evtNum << " " << (*js) << std::endl;
0166       }
0167     }
0168 
0169     if (m_doInternal) {
0170       // Internal HF data
0171       Handle<L1GctInternHFDataCollection> internHF;
0172       iEvent.getByLabel(m_gctSource, internHF);
0173 
0174       if (internHF.isValid()) {
0175         for (L1GctInternHFDataCollection::const_iterator hf = internHF->begin(); hf != internHF->end(); hf++) {
0176           if (hf->value(0) || hf->value(1) || hf->value(2) || hf->value(3)) {
0177             m_outputFile << "BX = " << dec << m_evtNum << " " << (*hf) << std::endl;
0178           }
0179         }
0180       }
0181     }
0182   }
0183 
0184   // HT, MET and ET
0185   if (m_doESums) {
0186     // MET
0187     Handle<L1GctEtMissCollection> missEt;
0188     iEvent.getByLabel(m_gctSource, missEt);
0189 
0190     for (L1GctEtMissCollection::const_iterator met = missEt->begin(); met != missEt->end(); met++) {
0191       if (met->et() > 0) {
0192         m_outputFile << "BX = " << dec << m_evtNum << " " << (*met) << std::endl;
0193       }
0194     }
0195 
0196     // Total Et
0197     Handle<L1GctEtTotalCollection> totEt;
0198     iEvent.getByLabel(m_gctSource, totEt);
0199 
0200     for (L1GctEtTotalCollection::const_iterator tet = totEt->begin(); tet != totEt->end(); tet++) {
0201       if (tet->et() > 0) {
0202         m_outputFile << "BX = " << dec << m_evtNum << " " << (*tet) << std::endl;
0203       }
0204     }
0205 
0206     // Ht
0207     Handle<L1GctEtHadCollection> hadEt;
0208     iEvent.getByLabel(m_gctSource, hadEt);
0209 
0210     for (L1GctEtHadCollection::const_iterator ht = hadEt->begin(); ht != hadEt->end(); ht++) {
0211       if (ht->et() > 0) {
0212         m_outputFile << "BX = " << dec << m_evtNum << " " << (*ht) << std::endl;
0213       }
0214     }
0215 
0216     if (m_doInternal) {
0217       // Internal GCT Et sums
0218       Handle<L1GctInternEtSumCollection> Et;
0219       iEvent.getByLabel(m_gctSource, Et);
0220 
0221       if (Et.isValid()) {
0222         for (L1GctInternEtSumCollection::const_iterator e = Et->begin(); e != Et->end(); e++) {
0223           if (e->et() > 0) {
0224             m_outputFile << "BX = " << dec << m_evtNum << " " << (*e) << std::endl;
0225           }
0226         }
0227       }
0228     }
0229   }
0230 
0231   m_evtNum++;
0232 }