Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "L1Trigger/L1GctAnalyzer/interface/DumpGctDigis.h"
0002 
0003 // system include files
0004 #include <memory>
0005 #include <iostream>
0006 
0007 // user include files
0008 #include "FWCore/Framework/interface/Frameworkfwd.h"
0009 #include "FWCore/Framework/interface/EDAnalyzer.h"
0010 
0011 #include "FWCore/Framework/interface/Event.h"
0012 #include "FWCore/Framework/interface/MakerMacros.h"
0013 
0014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0015 #include "FWCore/Utilities/interface/InputTag.h"
0016 
0017 #include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h"
0018 
0019 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctCollections.h"
0020 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctEtSums.h"
0021 
0022 using std::endl;
0023 using std::ios;
0024 using std::string;
0025 
0026 //
0027 // constructors and destructor
0028 //
0029 DumpGctDigis::DumpGctDigis(const edm::ParameterSet& iConfig)
0030     : rawLabel_(iConfig.getUntrackedParameter<edm::InputTag>("rawInput", edm::InputTag("L1GctRawDigis"))),
0031       emuRctLabel_(iConfig.getUntrackedParameter<edm::InputTag>("emuRctInput", edm::InputTag("L1RctEmuDigis"))),
0032       emuGctLabel_(iConfig.getUntrackedParameter<edm::InputTag>("emuGctInput", edm::InputTag("L1GctEmuDigis"))),
0033       outFilename_(iConfig.getUntrackedParameter<string>("outFile", "gctAnalyzer.txt")),
0034       doHW_(iConfig.getUntrackedParameter<bool>("doHardware", true)),
0035       doEmu_(iConfig.getUntrackedParameter<bool>("doEmulated", true)),
0036       doRctEM_(iConfig.getUntrackedParameter<bool>("doRctEm", true)),
0037       doEM_(iConfig.getUntrackedParameter<bool>("doEm", true)),
0038       doRegions_(iConfig.getUntrackedParameter<bool>("doRegions", false)),
0039       doJets_(iConfig.getUntrackedParameter<bool>("doJets", false)),
0040       doInternEM_(iConfig.getUntrackedParameter<bool>("doInternEm", true)),
0041       doFibres_(iConfig.getUntrackedParameter<bool>("doFibres", false)),
0042       doEnergySums_(iConfig.getUntrackedParameter<bool>("doEnergySums", false)),
0043       rctEmMinRank_(iConfig.getUntrackedParameter<unsigned>("rctEmMinRank", 0)) {
0044   //now do what ever initialization is needed
0045 
0046   outFile_.open(outFilename_.c_str(), ios::out);
0047 }
0048 
0049 DumpGctDigis::~DumpGctDigis() {
0050   // do anything here that needs to be done at desctruction time
0051   // (e.g. close files, deallocate resources etc.)
0052 
0053   outFile_.close();
0054 }
0055 
0056 //
0057 // member functions
0058 //
0059 
0060 // ------------ method called to produce the data  ------------
0061 void DumpGctDigis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0062   using namespace edm;
0063 
0064   outFile_ << "Run :" << iEvent.id().run() << "  Event :" << iEvent.id().event() << endl;
0065 
0066   // EM
0067   if (doRctEM_ && doHW_) {
0068     doRctEM(iEvent, rawLabel_);
0069   }
0070   if (doRctEM_ && doEmu_) {
0071     doRctEM(iEvent, emuRctLabel_);
0072   }
0073   if (doEM_ && doHW_) {
0074     doEM(iEvent, rawLabel_);
0075   }
0076   if (doEM_ && doEmu_) {
0077     doEM(iEvent, emuGctLabel_);
0078   }
0079 
0080   // Jets
0081   if (doRegions_ && doHW_) {
0082     doRegions(iEvent, rawLabel_);
0083   }
0084   if (doRegions_ && doEmu_) {
0085     doRegions(iEvent, emuRctLabel_);
0086   }
0087   if (doJets_ && doHW_) {
0088     doJets(iEvent, rawLabel_);
0089   }
0090   if (doJets_ && doEmu_) {
0091     doJets(iEvent, emuGctLabel_);
0092   }
0093 
0094   // Energy Sums
0095   if (doEnergySums_ && doHW_) {
0096     doEnergySums(iEvent, rawLabel_);
0097   }
0098   if (doEnergySums_ && doEmu_) {
0099     doEnergySums(iEvent, emuGctLabel_);
0100   }
0101 
0102   // debugging
0103   if (doInternEM_ && doHW_) {
0104     doInternEM(iEvent, rawLabel_);
0105   }
0106   if (doFibres_ && doHW_) {
0107     doFibres(iEvent, rawLabel_);
0108   }
0109 }
0110 
0111 void DumpGctDigis::doEM(const edm::Event& iEvent, const edm::InputTag& label) {
0112   using namespace edm;
0113 
0114   Handle<L1GctEmCandCollection> isoEm;
0115   Handle<L1GctEmCandCollection> nonIsoEm;
0116 
0117   L1GctEmCandCollection::const_iterator ie;
0118   L1GctEmCandCollection::const_iterator ne;
0119 
0120   iEvent.getByLabel(label.label(), "isoEm", isoEm);
0121   iEvent.getByLabel(label.label(), "nonIsoEm", nonIsoEm);
0122 
0123   outFile_ << "Iso EM from : " << label.label() << endl;
0124   for (ie = isoEm->begin(); ie != isoEm->end(); ie++) {
0125     outFile_ << (*ie) << " ieta(detID)=" << ie->regionId().ieta() << " iphi(detID)=" << ie->regionId().iphi() << endl;
0126   }
0127   outFile_ << endl;
0128 
0129   outFile_ << "Non-iso EM from : " << label.label() << endl;
0130   for (ne = nonIsoEm->begin(); ne != nonIsoEm->end(); ne++) {
0131     outFile_ << (*ne) << " ieta(detID)=" << ne->regionId().ieta() << " iphi(detID)=" << ne->regionId().iphi() << endl;
0132   }
0133   outFile_ << endl;
0134 }
0135 
0136 void DumpGctDigis::doRctEM(const edm::Event& iEvent, const edm::InputTag& label) {
0137   using namespace edm;
0138 
0139   Handle<L1CaloEmCollection> em;
0140 
0141   L1CaloEmCollection::const_iterator e;
0142 
0143   iEvent.getByLabel(label, em);
0144 
0145   outFile_ << "RCT EM from : " << label.label() << endl;
0146   for (e = em->begin(); e != em->end(); e++) {
0147     if (e->rank() >= rctEmMinRank_) {
0148       outFile_ << (*e) << " ieta(detID)=" << e->regionId().ieta() << " iphi(detID)=" << e->regionId().iphi() << endl;
0149     }
0150   }
0151   outFile_ << endl;
0152 }
0153 
0154 void DumpGctDigis::doRegions(const edm::Event& iEvent, const edm::InputTag& label) {
0155   using namespace edm;
0156 
0157   Handle<L1CaloRegionCollection> rgns;
0158 
0159   L1CaloRegionCollection::const_iterator r;
0160 
0161   iEvent.getByLabel(label, rgns);
0162 
0163   outFile_ << "Regions from : " << label.label() << endl;
0164   for (r = rgns->begin(); r != rgns->end(); r++) {
0165     outFile_ << (*r) << endl;
0166   }
0167   outFile_ << endl;
0168 }
0169 
0170 void DumpGctDigis::doJets(const edm::Event& iEvent, const edm::InputTag& label) {
0171   using namespace edm;
0172 
0173   Handle<L1GctJetCandCollection> cenJets;
0174   Handle<L1GctJetCandCollection> forJets;
0175   Handle<L1GctJetCandCollection> tauJets;
0176 
0177   L1GctJetCandCollection::const_iterator cj;
0178   L1GctJetCandCollection::const_iterator fj;
0179   L1GctJetCandCollection::const_iterator tj;
0180 
0181   const std::string& labelStr = label.label();
0182 
0183   iEvent.getByLabel(labelStr, "cenJets", cenJets);
0184   iEvent.getByLabel(labelStr, "forJets", forJets);
0185   iEvent.getByLabel(labelStr, "tauJets", tauJets);
0186 
0187   outFile_ << "Central jets from : " << labelStr << endl;
0188   for (cj = cenJets->begin(); cj != cenJets->end(); cj++) {
0189     outFile_ << (*cj) << endl;
0190   }
0191   outFile_ << endl;
0192 
0193   outFile_ << "Forward jets from : " << labelStr << endl;
0194   for (fj = forJets->begin(); fj != forJets->end(); fj++) {
0195     outFile_ << (*fj) << endl;
0196   }
0197   outFile_ << endl;
0198 
0199   outFile_ << "Tau jets from : " << labelStr << endl;
0200   for (tj = tauJets->begin(); tj != tauJets->end(); tj++) {
0201     outFile_ << (*tj) << endl;
0202   }
0203 }
0204 
0205 void DumpGctDigis::doInternEM(const edm::Event& iEvent, const edm::InputTag& label) {
0206   using namespace edm;
0207 
0208   Handle<L1GctInternEmCandCollection> em;
0209 
0210   L1GctInternEmCandCollection::const_iterator e;
0211 
0212   iEvent.getByLabel(label, em);
0213 
0214   outFile_ << "Internal EM from : " << label.label() << endl;
0215   for (e = em->begin(); e != em->end(); e++) {
0216     outFile_ << (*e) << " ieta(detID)=" << e->regionId().ieta() << " iphi(detID)=" << e->regionId().iphi() << endl;
0217   }
0218   outFile_ << endl;
0219 }
0220 
0221 void DumpGctDigis::doFibres(const edm::Event& iEvent, const edm::InputTag& label) {
0222   using namespace edm;
0223 
0224   Handle<L1GctFibreCollection> fibres;
0225 
0226   L1GctFibreCollection::const_iterator f;
0227 
0228   iEvent.getByLabel(label, fibres);
0229 
0230   outFile_ << "Fibres from : " << label.label() << endl;
0231   for (f = fibres->begin(); f != fibres->end(); f++) {
0232     outFile_ << (*f) << endl;
0233   }
0234   outFile_ << endl;
0235 }
0236 
0237 void DumpGctDigis::doEnergySums(const edm::Event& iEvent, const edm::InputTag& label) {
0238   using namespace edm;
0239 
0240   Handle<L1GctEtTotalCollection> etTotal;
0241   Handle<L1GctEtHadCollection> etHad;
0242   Handle<L1GctEtMissCollection> etMiss;
0243   Handle<L1GctHtMissCollection> htMiss;
0244 
0245   iEvent.getByLabel(label, etTotal);
0246   iEvent.getByLabel(label, etHad);
0247   iEvent.getByLabel(label, etMiss);
0248   iEvent.getByLabel(label, htMiss);
0249 
0250   outFile_ << "Energy sums from: " << label.label() << endl;
0251 
0252   L1GctEtTotalCollection::const_iterator et;
0253   for (et = etTotal->begin(); et != etTotal->end(); et++) {
0254     outFile_ << *(et) << endl;
0255   }
0256 
0257   L1GctEtHadCollection::const_iterator ht;
0258   for (ht = etHad->begin(); ht != etHad->end(); ht++) {
0259     outFile_ << *(ht) << endl;
0260   }
0261 
0262   L1GctEtMissCollection::const_iterator met;
0263   for (met = etMiss->begin(); met != etMiss->end(); met++) {
0264     outFile_ << *(met) << endl;
0265   }
0266 
0267   L1GctHtMissCollection::const_iterator mht;
0268   for (mht = htMiss->begin(); mht != htMiss->end(); mht++) {
0269     outFile_ << *(mht) << endl;
0270   }
0271 }