Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:55

0001 #include "L1Trigger/GlobalCaloTrigger/test/L1GctTestAnalyzer.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 
0010 #include "FWCore/Framework/interface/Event.h"
0011 #include "FWCore/Framework/interface/MakerMacros.h"
0012 
0013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0014 #include "FWCore/Utilities/interface/InputTag.h"
0015 
0016 #include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h"
0017 
0018 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctCollections.h"
0019 
0020 using std::endl;
0021 using std::ios;
0022 using std::string;
0023 
0024 //
0025 // constructors and destructor
0026 //
0027 L1GctTestAnalyzer::L1GctTestAnalyzer(const edm::ParameterSet& iConfig)
0028     : rawLabel_(iConfig.getUntrackedParameter<edm::InputTag>("rawInput", edm::InputTag("L1GctRawDigis"))),
0029       emuLabel_(iConfig.getUntrackedParameter<edm::InputTag>("emuInput", edm::InputTag("L1GctEmuDigis"))),
0030       outFilename_(iConfig.getUntrackedParameter<string>("outFile", "gctAnalyzer.txt")),
0031       doHW_(iConfig.getUntrackedParameter<bool>("doHardware", true)),
0032       doEmu_(iConfig.getUntrackedParameter<bool>("doEmulated", true)),
0033       doRctEM_(iConfig.getUntrackedParameter<bool>("doRctEm", true)),
0034       doInternEM_(iConfig.getUntrackedParameter<bool>("doInternEm", true)),
0035       doEM_(iConfig.getUntrackedParameter<bool>("doEm", true)),
0036       doJets_(iConfig.getUntrackedParameter<bool>("doJets", 0)),
0037       doEnergySums_(iConfig.getUntrackedParameter<bool>("doEnergySums", 0)),
0038       rctEmMinRank_(iConfig.getUntrackedParameter<unsigned>("rctEmMinRank", 0)) {
0039   //now do what ever initialization is needed
0040 
0041   outFile_.open(outFilename_.c_str(), ios::out);
0042 }
0043 
0044 L1GctTestAnalyzer::~L1GctTestAnalyzer() {
0045   // do anything here that needs to be done at desctruction time
0046   // (e.g. close files, deallocate resources etc.)
0047 
0048   outFile_.close();
0049 }
0050 
0051 //
0052 // member functions
0053 //
0054 
0055 // ------------ method called to produce the data  ------------
0056 void L1GctTestAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0057   using namespace edm;
0058 
0059   outFile_ << "Run :" << iEvent.id().run() << "  Event :" << iEvent.id().event() << endl;
0060 
0061   if (doRctEM_ && doHW_) {
0062     doRctEM(iEvent, rawLabel_);
0063   }
0064   if (doRctEM_ && doEmu_) {
0065     doRctEM(iEvent, emuLabel_);
0066   }
0067   if (doInternEM_ && doHW_) {
0068     doInternEM(iEvent, rawLabel_);
0069   }
0070   if (doInternEM_ && doEmu_) {
0071   }  //doInternEM(iEvent, emuLabel_); }
0072   if (doEM_ && doHW_) {
0073     doEM(iEvent, rawLabel_);
0074   }
0075   if (doEM_ && doEmu_) {
0076     doEM(iEvent, emuLabel_);
0077   }
0078   if (doJets_ && doHW_) {
0079     doJets(iEvent, rawLabel_);
0080   }
0081   if (doJets_ && doEmu_) {
0082     doJets(iEvent, emuLabel_);
0083   }
0084   if (doEnergySums_ && doHW_) {
0085     doEnergySums(iEvent, rawLabel_);
0086   }
0087   if (doEnergySums_ && doEmu_) {
0088     doEnergySums(iEvent, emuLabel_);
0089   }
0090 }
0091 
0092 void L1GctTestAnalyzer::doEM(const edm::Event& iEvent, edm::InputTag label) {
0093   using namespace edm;
0094 
0095   Handle<L1GctEmCandCollection> isoEm;
0096   Handle<L1GctEmCandCollection> nonIsoEm;
0097 
0098   L1GctEmCandCollection::const_iterator ie;
0099   L1GctEmCandCollection::const_iterator ne;
0100 
0101   iEvent.getByLabel(label.label(), "isoEm", isoEm);
0102   iEvent.getByLabel(label.label(), "nonIsoEm", nonIsoEm);
0103 
0104   outFile_ << "Iso EM :"
0105            << " from : " << label.label() << endl;
0106   for (ie = isoEm->begin(); ie != isoEm->end(); ie++) {
0107     outFile_ << (*ie) << endl;
0108   }
0109   outFile_ << endl;
0110 
0111   outFile_ << "Non-iso EM :"
0112            << " from : " << label.label() << endl;
0113   for (ne = nonIsoEm->begin(); ne != nonIsoEm->end(); ne++) {
0114     outFile_ << (*ne) << endl;
0115   }
0116   outFile_ << endl;
0117 }
0118 
0119 void L1GctTestAnalyzer::doRctEM(const edm::Event& iEvent, edm::InputTag label) {
0120   using namespace edm;
0121 
0122   Handle<L1CaloEmCollection> em;
0123 
0124   L1CaloEmCollection::const_iterator e;
0125 
0126   iEvent.getByLabel(label.label(), "", em);
0127 
0128   outFile_ << "RCT EM :"
0129            << " from : " << label.label() << endl;
0130   for (e = em->begin(); e != em->end(); e++) {
0131     if (e->rank() >= rctEmMinRank_) {
0132       outFile_ << (*e) << endl;
0133     }
0134   }
0135   outFile_ << endl;
0136 }
0137 
0138 void L1GctTestAnalyzer::doInternEM(const edm::Event& iEvent, edm::InputTag label) {
0139   using namespace edm;
0140 
0141   Handle<L1GctInternEmCandCollection> em;
0142 
0143   L1GctInternEmCandCollection::const_iterator e;
0144 
0145   iEvent.getByLabel(label.label(), "", em);
0146 
0147   outFile_ << "Internal EM :"
0148            << " from : " << label.label() << endl;
0149   for (e = em->begin(); e != em->end(); e++) {
0150     outFile_ << (*e) << endl;
0151   }
0152   outFile_ << endl;
0153 }
0154 
0155 void L1GctTestAnalyzer::doJets(const edm::Event& iEvent, edm::InputTag label) {
0156   using namespace edm;
0157 
0158   Handle<L1GctJetCandCollection> cenJets;
0159   Handle<L1GctJetCandCollection> forJets;
0160   Handle<L1GctJetCandCollection> tauJets;
0161 
0162   L1GctJetCandCollection::const_iterator cj;
0163   L1GctJetCandCollection::const_iterator fj;
0164   L1GctJetCandCollection::const_iterator tj;
0165 
0166   iEvent.getByLabel(label.label(), "cenJets", cenJets);
0167   iEvent.getByLabel(label.label(), "forJets", forJets);
0168   iEvent.getByLabel(label.label(), "tauJets", tauJets);
0169 
0170   outFile_ << "Central jets :"
0171            << " from : " << label.label() << endl;
0172   for (cj = cenJets->begin(); cj != cenJets->end(); cj++) {
0173     outFile_ << (*cj) << endl;
0174   }
0175   outFile_ << endl;
0176 
0177   outFile_ << "Forward jets : "
0178            << " from : " << label.label() << endl;
0179   for (fj = forJets->begin(); fj != forJets->end(); fj++) {
0180     outFile_ << (*fj) << endl;
0181   }
0182   outFile_ << endl;
0183 
0184   outFile_ << "Tau jets :"
0185            << " from : " << label.label() << endl;
0186   for (tj = tauJets->begin(); tj != tauJets->end(); tj++) {
0187     outFile_ << (*tj) << endl;
0188   }
0189   outFile_ << endl;
0190 }
0191 
0192 void L1GctTestAnalyzer::doEnergySums(const edm::Event& iEvent, edm::InputTag label) {
0193   using namespace edm;
0194 
0195   Handle<L1GctEtTotal> etTotResult;
0196   Handle<L1GctEtHad> etHadResult;
0197   Handle<L1GctEtMiss> etMissResult;
0198 
0199   iEvent.getByLabel(label, etTotResult);
0200   iEvent.getByLabel(label, etHadResult);
0201   iEvent.getByLabel(label, etMissResult);
0202 
0203   outFile_ << "Total Et from : " << label.label() << endl;
0204   outFile_ << (*etTotResult) << endl;
0205   outFile_ << "Total Ht from : " << label.label() << endl;
0206   outFile_ << (*etHadResult) << endl;
0207   outFile_ << "Missing Et from : " << label.label() << endl;
0208   outFile_ << (*etMissResult) << endl;
0209 
0210   outFile_ << endl;
0211 }