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