CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/L1Trigger/L1GctAnalyzer/src/GctTimingAnalyzer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    GctTimingAnalyzer
00004 // Class:      GctTimingAnalyzer
00005 // 
00011 //
00012 // Original Author:  Alex Tapper
00013 //         Created:  Mon Apr 21 14:21:06 CEST 2008
00014 // $Id: GctTimingAnalyzer.cc,v 1.9 2008/11/05 20:34:17 tapper Exp $
00015 //
00016 //
00017 
00018 // Include file
00019 #include "L1Trigger/L1GctAnalyzer/interface/GctTimingAnalyzer.h"
00020 
00021 GctTimingAnalyzer::GctTimingAnalyzer(const edm::ParameterSet& iConfig):
00022   m_outputFileName(iConfig.getUntrackedParameter<std::string>("outFile", "gctTiming.txt")),
00023   m_gctSource(iConfig.getUntrackedParameter<edm::InputTag>("gctSource")),
00024   m_isoEmSource(iConfig.getUntrackedParameter<edm::InputTag>("isoEmSource")),
00025   m_nonIsoEmSource(iConfig.getUntrackedParameter<edm::InputTag>("nonIsoEmSource")),
00026   m_cenJetsSource(iConfig.getUntrackedParameter<edm::InputTag>("cenJetsSource")),
00027   m_forJetsSource(iConfig.getUntrackedParameter<edm::InputTag>("forJetsSource")),
00028   m_tauJetsSource(iConfig.getUntrackedParameter<edm::InputTag>("tauJetsSource")),
00029   m_doInternal(iConfig.getUntrackedParameter<bool>("doInternal")),
00030   m_doElectrons(iConfig.getUntrackedParameter<bool>("doElectrons")),
00031   m_doJets(iConfig.getUntrackedParameter<bool>("doJets")),
00032   m_doHFRings(iConfig.getUntrackedParameter<bool>("doHFRings")),
00033   m_doESums(iConfig.getUntrackedParameter<bool>("doESums")),
00034   m_evtNum(0)
00035 {
00036   m_outputFile.open(m_outputFileName.c_str());
00037 }
00038 
00039 GctTimingAnalyzer::~GctTimingAnalyzer()
00040 {
00041   m_outputFile.close();
00042 }
00043 
00044 void GctTimingAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00045 {
00046   using namespace edm;
00047   using namespace std;
00048   
00049   // Electrons
00050   if(m_doElectrons){
00051 
00052     // Isolated EM cands in GCT output
00053     Handle<L1GctEmCandCollection> isoEm; 
00054     iEvent.getByLabel(m_isoEmSource,isoEm);    
00055 
00056     for (L1GctEmCandCollection::const_iterator em=isoEm->begin(); em!=isoEm->end(); em++){
00057       if (em->rank()>0) {
00058         m_outputFile << "BX = " << dec << m_evtNum << " " << (*em) << std::endl; 
00059       }
00060     }
00061   
00062     // Non-Isolated EM cands in GCT output
00063     Handle<L1GctEmCandCollection> nonIsoEm; 
00064     iEvent.getByLabel(m_nonIsoEmSource,nonIsoEm);    
00065     
00066     for (L1GctEmCandCollection::const_iterator em=nonIsoEm->begin(); em!=nonIsoEm->end(); em++){
00067       if (em->rank()>0) {
00068         m_outputFile << "BX = " << dec << m_evtNum << " " << (*em) << std::endl; 
00069       }
00070     }
00071 
00072     if (m_doInternal){
00073       // Internal GCT EM cands
00074       Handle<L1GctInternEmCandCollection> internEm; 
00075       iEvent.getByLabel(m_gctSource,internEm);    
00076 
00077       if (internEm.isValid()) {
00078         for (L1GctInternEmCandCollection::const_iterator em=internEm->begin(); em!=internEm->end(); em++){
00079           if (em->rank()>0) {
00080             m_outputFile << "BX = " << dec << m_evtNum << " " << (*em) << std::endl; 
00081           }
00082         }
00083       }
00084     }
00085 
00086     // RCT EM cands
00087     Handle<L1CaloEmCollection> rctEm; 
00088     iEvent.getByLabel(m_gctSource,rctEm);    
00089     
00090     for (L1CaloEmCollection::const_iterator em=rctEm->begin(); em!=rctEm->end(); em++){
00091       if (em->rank()>0) {
00092         m_outputFile << "BX = " << dec << m_evtNum << " " << (*em) << std::endl; 
00093       }
00094     }
00095   }     
00096   
00097   // Jets
00098   if (m_doJets){
00099 
00100     // Central jet cands in GCT output
00101     Handle<L1GctJetCandCollection> cenJets; 
00102     iEvent.getByLabel(m_cenJetsSource,cenJets);    
00103 
00104     for (L1GctJetCandCollection::const_iterator cj=cenJets->begin(); cj!=cenJets->end(); cj++){
00105       if (cj->rank()>0) {
00106         m_outputFile << "BX = " << dec << m_evtNum << " " << (*cj) << std::endl; 
00107       }
00108     }
00109     
00110     // Forward jet cands in GCT output
00111     Handle<L1GctJetCandCollection> forJets; 
00112     iEvent.getByLabel(m_forJetsSource,forJets);    
00113     
00114     for (L1GctJetCandCollection::const_iterator fj=forJets->begin(); fj!=forJets->end(); fj++){
00115       if (fj->rank()>0) {
00116         m_outputFile << "BX = " << dec << m_evtNum << " " << (*fj) << std::endl; 
00117       }
00118     }
00119     
00120     // Tau jet cands in GCT output
00121     Handle<L1GctJetCandCollection> tauJets; 
00122     iEvent.getByLabel(m_tauJetsSource,tauJets);    
00123     
00124     for (L1GctJetCandCollection::const_iterator tj=tauJets->begin(); tj!=tauJets->end(); tj++){
00125       if (tj->rank()>0) {
00126         m_outputFile << "BX = " << dec << m_evtNum << " " << (*tj) << std::endl; 
00127       }
00128     }
00129   
00130     if (m_doInternal){
00131 
00132       // Internal GCT jet cands
00133       Handle<L1GctInternJetDataCollection> internJets; 
00134       iEvent.getByLabel(m_gctSource,internJets);    
00135     
00136       if (internJets.isValid()){
00137         for (L1GctInternJetDataCollection::const_iterator j=internJets->begin(); j!=internJets->end(); j++){
00138           if ((j->et()>0) || (j->rank()>0)) {
00139             m_outputFile << "BX = " << dec << m_evtNum << " " << (*j) << std::endl; 
00140           }
00141         }
00142       }
00143     }
00144   }
00145   
00146   // RCT regions
00147   Handle<L1CaloRegionCollection> rctRn; 
00148   iEvent.getByLabel(m_gctSource,rctRn);    
00149     
00150   for (L1CaloRegionCollection::const_iterator rn=rctRn->begin(); rn!=rctRn->end(); rn++){
00151     if (rn->et()>0) {
00152       m_outputFile << "BX = " << dec << m_evtNum << " " << (*rn) << std::endl; 
00153     }
00154   }
00155 
00156   // HF Rings
00157   if (m_doHFRings){
00158 
00159     // HFRing counts
00160     Handle<L1GctHFBitCountsCollection> hfBitCnt;
00161     iEvent.getByLabel(m_gctSource,hfBitCnt);
00162 
00163     for (L1GctHFBitCountsCollection::const_iterator jc=hfBitCnt->begin(); jc!=hfBitCnt->end(); jc++){
00164       if (jc->bitCount(0) || jc->bitCount(1) || jc->bitCount(2) || jc->bitCount(3)){
00165         m_outputFile << "BX = " << dec << m_evtNum << " " << (*jc) << std::endl; 
00166       }
00167     }
00168 
00169     // HFRing Et sums
00170     Handle<L1GctHFRingEtSumsCollection> hfEtSums;
00171     iEvent.getByLabel(m_gctSource,hfEtSums);
00172 
00173     for (L1GctHFRingEtSumsCollection::const_iterator js=hfEtSums->begin(); js!=hfEtSums->end(); js++){
00174       if (js->etSum(0) || js->etSum(1) || js->etSum(2) || js->etSum(3)){
00175         m_outputFile << "BX = " << dec << m_evtNum << " " << (*js) << std::endl; 
00176       }
00177     }
00178 
00179     if (m_doInternal){
00180       // Internal HF data
00181       Handle<L1GctInternHFDataCollection> internHF;
00182       iEvent.getByLabel(m_gctSource,internHF);
00183       
00184       if (internHF.isValid()){
00185         for (L1GctInternHFDataCollection::const_iterator hf=internHF->begin(); hf!=internHF->end(); hf++){
00186           if (hf->value(0) || hf->value(1) || hf->value(2) || hf->value(3)){
00187             m_outputFile << "BX = " << dec << m_evtNum << " " << (*hf) << std::endl; 
00188           }
00189         }
00190       }
00191     }    
00192   }
00193 
00194   // HT, MET and ET
00195   if (m_doESums){
00196 
00197     // MET
00198     Handle<L1GctEtMissCollection> missEt;
00199     iEvent.getByLabel(m_gctSource,missEt);
00200 
00201     for (L1GctEtMissCollection::const_iterator met=missEt->begin(); met!=missEt->end(); met++){
00202       if (met->et()>0){
00203         m_outputFile << "BX = " << dec << m_evtNum << " " << (*met) << std::endl; 
00204       }
00205     }
00206 
00207     // Total Et
00208     Handle<L1GctEtTotalCollection> totEt;
00209     iEvent.getByLabel(m_gctSource,totEt);
00210     
00211     for (L1GctEtTotalCollection::const_iterator tet=totEt->begin(); tet!=totEt->end(); tet++){
00212       if (tet->et()>0){
00213         m_outputFile << "BX = " << dec << m_evtNum << " " << (*tet) << std::endl; 
00214       }
00215     }
00216     
00217     // Ht
00218     Handle<L1GctEtHadCollection> hadEt;
00219     iEvent.getByLabel(m_gctSource,hadEt);
00220 
00221     for (L1GctEtHadCollection::const_iterator ht=hadEt->begin(); ht!=hadEt->end(); ht++){
00222       if (ht->et()>0){
00223         m_outputFile << "BX = " << dec << m_evtNum << " " << (*ht) << std::endl; 
00224       }
00225     }
00226 
00227     if (m_doInternal){
00228       // Internal GCT Et sums
00229       Handle<L1GctInternEtSumCollection> Et;
00230       iEvent.getByLabel(m_gctSource,Et);
00231       
00232       if (Et.isValid()){
00233         for (L1GctInternEtSumCollection::const_iterator e=Et->begin(); e!=Et->end(); e++){
00234           if (e->et()>0){
00235             m_outputFile << "BX = " << dec << m_evtNum << " " << (*e) << std::endl;
00236           }
00237         }
00238       }
00239     }    
00240   }
00241 
00242   m_evtNum++;
00243 
00244 }