CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/L1Trigger/L1GctAnalyzer/src/DumpGctDigis.cc

Go to the documentation of this file.
00001 #include "L1Trigger/L1GctAnalyzer/interface/DumpGctDigis.h"
00002 
00003 // system include files
00004 #include <memory>
00005 #include <iostream>
00006 
00007 // user include files
00008 #include "FWCore/Framework/interface/Frameworkfwd.h"
00009 #include "FWCore/Framework/interface/EDAnalyzer.h"
00010 
00011 #include "FWCore/Framework/interface/Event.h"
00012 #include "FWCore/Framework/interface/MakerMacros.h"
00013 
00014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00015 #include "FWCore/Utilities/interface/InputTag.h"
00016 
00017 #include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h"
00018 
00019 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctCollections.h"
00020 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctEtSums.h"
00021 
00022 using std::string;
00023 using std::ios;
00024 using std::endl;
00025 
00026 //
00027 // constructors and destructor
00028 //
00029 DumpGctDigis::DumpGctDigis(const edm::ParameterSet& iConfig) :
00030   rawLabel_( iConfig.getUntrackedParameter<edm::InputTag>("rawInput", edm::InputTag("L1GctRawDigis") ) ),
00031   emuRctLabel_( iConfig.getUntrackedParameter<edm::InputTag>("emuRctInput", edm::InputTag("L1RctEmuDigis") ) ),
00032   emuGctLabel_( iConfig.getUntrackedParameter<edm::InputTag>("emuGctInput", edm::InputTag("L1GctEmuDigis") ) ),
00033   outFilename_( iConfig.getUntrackedParameter<string>("outFile", "gctAnalyzer.txt") ),
00034   doHW_( iConfig.getUntrackedParameter<bool>("doHardware", true) ),
00035   doEmu_( iConfig.getUntrackedParameter<bool>("doEmulated", true) ),
00036   doRctEM_( iConfig.getUntrackedParameter<bool>("doRctEm", true) ),
00037   doEM_( iConfig.getUntrackedParameter<bool>("doEm", true) ),
00038   doRegions_( iConfig.getUntrackedParameter<bool>("doRegions", false) ),
00039   doJets_( iConfig.getUntrackedParameter<bool>("doJets", false) ),
00040   doInternEM_( iConfig.getUntrackedParameter<bool>("doInternEm", true) ),
00041   doFibres_( iConfig.getUntrackedParameter<bool>("doFibres", false) ),
00042   doEnergySums_( iConfig.getUntrackedParameter<bool>("doEnergySums", false) ),
00043   rctEmMinRank_( iConfig.getUntrackedParameter<unsigned>("rctEmMinRank", 0) )
00044 {
00045   //now do what ever initialization is needed
00046 
00047   outFile_.open(outFilename_.c_str(), ios::out);
00048 
00049 }
00050 
00051 
00052 DumpGctDigis::~DumpGctDigis()
00053 {
00054  
00055    // do anything here that needs to be done at desctruction time
00056    // (e.g. close files, deallocate resources etc.)
00057 
00058   outFile_.close();
00059 
00060 }
00061 
00062 
00063 //
00064 // member functions
00065 //
00066 
00067 // ------------ method called to produce the data  ------------
00068 void
00069 DumpGctDigis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00070 {
00071   using namespace edm;
00072   
00073   outFile_ << "Run :" << iEvent.id().run() << "  Event :" << iEvent.id().event() << endl;
00074   
00075   // EM
00076   if (doRctEM_ && doHW_) { doRctEM(iEvent, rawLabel_); }
00077   if (doRctEM_ && doEmu_) { doRctEM(iEvent, emuRctLabel_); }
00078   if (doEM_ && doHW_) { doEM(iEvent, rawLabel_); }
00079   if (doEM_ && doEmu_){ doEM(iEvent, emuGctLabel_); }
00080 
00081   // Jets
00082   if (doRegions_ && doHW_) { doRegions(iEvent, rawLabel_); }
00083   if (doRegions_ && doEmu_) { doRegions(iEvent, emuRctLabel_); }
00084   if (doJets_ && doHW_) { doJets(iEvent, rawLabel_); }
00085   if (doJets_ && doEmu_) { doJets(iEvent, emuGctLabel_); }
00086 
00087   // Energy Sums
00088   if (doEnergySums_ && doHW_) { doEnergySums(iEvent, rawLabel_); }
00089   if (doEnergySums_ && doEmu_) { doEnergySums(iEvent, emuGctLabel_); }
00090 
00091   // debugging
00092   if (doInternEM_ && doHW_) { doInternEM(iEvent, rawLabel_); }
00093   if (doFibres_ && doHW_) { doFibres(iEvent, rawLabel_); }
00094 
00095 }
00096 
00097 void DumpGctDigis::doEM(const edm::Event& iEvent, const edm::InputTag& label) {
00098 
00099   using namespace edm;
00100 
00101   Handle<L1GctEmCandCollection> isoEm;
00102   Handle<L1GctEmCandCollection> nonIsoEm;
00103 
00104   L1GctEmCandCollection::const_iterator ie;
00105   L1GctEmCandCollection::const_iterator ne;
00106   
00107   iEvent.getByLabel(label.label(),"isoEm",isoEm);
00108   iEvent.getByLabel(label.label(),"nonIsoEm",nonIsoEm);
00109 
00110   outFile_ << "Iso EM from : " << label.label() << endl;
00111   for (ie=isoEm->begin(); ie!=isoEm->end(); ie++) {
00112     outFile_ << (*ie) 
00113              << " ieta(detID)=" << ie->regionId().ieta()
00114              << " iphi(detID)=" << ie->regionId().iphi()
00115              << endl;
00116   } 
00117   outFile_ << endl;
00118   
00119   outFile_ << "Non-iso EM from : " << label.label() << endl;
00120   for (ne=nonIsoEm->begin(); ne!=nonIsoEm->end(); ne++) {
00121     outFile_ << (*ne) 
00122              << " ieta(detID)=" << ne->regionId().ieta()
00123              << " iphi(detID)=" << ne->regionId().iphi()
00124              << endl;
00125   } 
00126   outFile_ << endl;
00127 
00128 }
00129 
00130 void DumpGctDigis::doRctEM(const edm::Event& iEvent, const edm::InputTag& label) {
00131 
00132   using namespace edm;
00133 
00134   Handle<L1CaloEmCollection> em;
00135 
00136   L1CaloEmCollection::const_iterator e;
00137  
00138   iEvent.getByLabel(label, em);
00139 
00140   outFile_ << "RCT EM from : " << label.label() << endl;
00141   for (e=em->begin(); e!=em->end(); e++) {
00142     if (e->rank() >= rctEmMinRank_) {
00143       outFile_ << (*e) 
00144                << " ieta(detID)=" << e->regionId().ieta()
00145                << " iphi(detID)=" << e->regionId().iphi()
00146                << endl;
00147     }
00148   } 
00149   outFile_ << endl;
00150   
00151 }
00152 
00153 
00154 void DumpGctDigis::doRegions(const edm::Event& iEvent, const edm::InputTag& label) {
00155 
00156   using namespace edm;
00157 
00158   Handle<L1CaloRegionCollection> rgns;
00159 
00160   L1CaloRegionCollection::const_iterator r;
00161   
00162   iEvent.getByLabel(label, rgns);
00163 
00164   outFile_ << "Regions from : " << label.label() << endl;
00165   for (r=rgns->begin(); r!=rgns->end(); r++) {
00166     outFile_ << (*r) << endl;
00167   } 
00168   outFile_ << endl;
00169 
00170 }
00171 
00172 
00173 void DumpGctDigis::doJets(const edm::Event& iEvent, const edm::InputTag& label) {
00174 
00175   using namespace edm;
00176 
00177   Handle<L1GctJetCandCollection> cenJets;
00178   Handle<L1GctJetCandCollection> forJets;
00179   Handle<L1GctJetCandCollection> tauJets;
00180   
00181   L1GctJetCandCollection::const_iterator cj;
00182   L1GctJetCandCollection::const_iterator fj;
00183   L1GctJetCandCollection::const_iterator tj;
00184   
00185   const std::string labelStr = label.label();
00186   
00187   iEvent.getByLabel(labelStr,"cenJets",cenJets);
00188   iEvent.getByLabel(labelStr,"forJets",forJets);
00189   iEvent.getByLabel(labelStr,"tauJets",tauJets);
00190   
00191   outFile_ << "Central jets from : " << labelStr << endl;
00192   for (cj=cenJets->begin(); cj!=cenJets->end(); cj++) {
00193     outFile_ << (*cj) << endl;
00194   } 
00195   outFile_ << endl;
00196   
00197   outFile_ << "Forward jets from : " << labelStr << endl;
00198   for (fj=forJets->begin(); fj!=forJets->end(); fj++) {
00199     outFile_ << (*fj) << endl;
00200   } 
00201   outFile_ << endl;
00202   
00203   outFile_ << "Tau jets from : " << labelStr << endl;
00204   for (tj=tauJets->begin(); tj!=tauJets->end(); tj++) {
00205     outFile_ << (*tj) << endl;
00206   }
00207 }
00208 
00209 
00210 void DumpGctDigis::doInternEM(const edm::Event& iEvent, const edm::InputTag& label) {
00211 
00212   using namespace edm;
00213 
00214   Handle<L1GctInternEmCandCollection> em;
00215 
00216   L1GctInternEmCandCollection::const_iterator e;
00217   
00218   iEvent.getByLabel(label, em);
00219 
00220   outFile_ << "Internal EM from : " << label.label() << endl;
00221   for (e=em->begin(); e!=em->end(); e++) {
00222     outFile_ << (*e) 
00223              << " ieta(detID)=" << e->regionId().ieta()
00224              << " iphi(detID)=" << e->regionId().iphi()
00225              << endl;
00226   } 
00227   outFile_ << endl;
00228   
00229 }
00230 
00231 
00232 void DumpGctDigis::doFibres(const edm::Event& iEvent, const edm::InputTag& label) {
00233 
00234   using namespace edm;
00235 
00236   Handle<L1GctFibreCollection> fibres;
00237 
00238   L1GctFibreCollection::const_iterator f;
00239   
00240   iEvent.getByLabel(label, fibres);
00241 
00242   outFile_ << "Fibres from : " << label.label() << endl;
00243   for (f=fibres->begin(); f!=fibres->end(); f++) {
00244     outFile_ << (*f) << endl;
00245   } 
00246   outFile_ << endl;
00247   
00248 }
00249 
00250 void DumpGctDigis::doEnergySums(const edm::Event& iEvent, const edm::InputTag& label)
00251 {
00252   using namespace edm;
00253   
00254   Handle<L1GctEtTotalCollection> etTotal;
00255   Handle<L1GctEtHadCollection> etHad;
00256   Handle<L1GctEtMissCollection> etMiss;
00257   Handle<L1GctHtMissCollection> htMiss;
00258   
00259   iEvent.getByLabel(label, etTotal);
00260   iEvent.getByLabel(label, etHad);
00261   iEvent.getByLabel(label, etMiss);
00262   iEvent.getByLabel(label, htMiss);
00263   
00264   outFile_ << "Energy sums from: " << label.label() << endl;
00265   
00266   L1GctEtTotalCollection::const_iterator et;
00267   for (et=etTotal->begin(); et!=etTotal->end(); et++){
00268     outFile_ << *(et) << endl;
00269   }
00270 
00271   L1GctEtHadCollection::const_iterator ht;
00272   for (ht=etHad->begin(); ht!=etHad->end(); ht++){
00273     outFile_ << *(ht) << endl;
00274   }
00275 
00276   L1GctEtMissCollection::const_iterator met;
00277   for (met=etMiss->begin(); met!=etMiss->end(); met++){
00278     outFile_ << *(met) << endl;
00279   }
00280 
00281   L1GctHtMissCollection::const_iterator mht;
00282   for (mht=htMiss->begin(); mht!=htMiss->end(); mht++){
00283     outFile_ << *(mht) << endl;
00284   }
00285 
00286 }