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