00001
00012 #include "FWCore/Common/interface/TriggerNames.h"
00013 #include "FWCore/Common/interface/TriggerResultsByName.h"
00014 #include "HLTrigger/HLTcore/interface/HLTEventAnalyzerRAW.h"
00015
00016
00017 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
00018 #include "DataFormats/EgammaCandidates/interface/Electron.h"
00019 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
00020 #include "DataFormats/JetReco/interface/CaloJet.h"
00021 #include "DataFormats/Candidate/interface/CompositeCandidate.h"
00022 #include "DataFormats/METReco/interface/MET.h"
00023 #include "DataFormats/METReco/interface/CaloMET.h"
00024 #include "DataFormats/HcalIsolatedTrack/interface/IsolatedPixelTrackCandidate.h"
00025 #include "DataFormats/L1Trigger/interface/L1HFRings.h"
00026 #include "DataFormats/L1Trigger/interface/L1EmParticle.h"
00027 #include "DataFormats/L1Trigger/interface/L1JetParticle.h"
00028 #include "DataFormats/L1Trigger/interface/L1MuonParticle.h"
00029 #include "DataFormats/L1Trigger/interface/L1EtMissParticle.h"
00030 #include "DataFormats/JetReco/interface/PFJet.h"
00031 #include "DataFormats/TauReco/interface/PFTau.h"
00032
00033 #include <cassert>
00034
00035
00036
00037
00038 HLTEventAnalyzerRAW::HLTEventAnalyzerRAW(const edm::ParameterSet& ps) :
00039 processName_(ps.getParameter<std::string>("processName")),
00040 triggerName_(ps.getParameter<std::string>("triggerName")),
00041 triggerResultsTag_(ps.getParameter<edm::InputTag>("triggerResults")),
00042 triggerEventWithRefsTag_(ps.getParameter<edm::InputTag>("triggerEventWithRefs"))
00043 {
00044 using namespace std;
00045 using namespace edm;
00046
00047 cout << "HLTEventAnalyzerRAW configuration: " << endl
00048 << " ProcessName = " << processName_ << endl
00049 << " TriggerName = " << triggerName_ << endl
00050 << " TriggerResultsTag = " << triggerResultsTag_.encode() << endl
00051 << " TriggerEventWithRefsTag = " << triggerEventWithRefsTag_.encode() << endl;
00052
00053 }
00054
00055 HLTEventAnalyzerRAW::~HLTEventAnalyzerRAW()
00056 {
00057 }
00058
00059
00060
00061
00062 void
00063 HLTEventAnalyzerRAW::beginRun(edm::Run const & iRun, edm::EventSetup const& iSetup)
00064 {
00065 using namespace std;
00066 using namespace edm;
00067
00068 bool changed(true);
00069 if (hltConfig_.init(iRun,iSetup,processName_,changed)) {
00070 if (changed) {
00071
00072 if (triggerName_!="@") {
00073 const unsigned int n(hltConfig_.size());
00074 const unsigned int triggerIndex(hltConfig_.triggerIndex(triggerName_));
00075 if (triggerIndex>=n) {
00076 cout << "HLTEventAnalyzerRAW::analyze:"
00077 << " TriggerName " << triggerName_
00078 << " not available in (new) config!" << endl;
00079 cout << "Available TriggerNames are: " << endl;
00080 hltConfig_.dump("Triggers");
00081 }
00082 }
00083 }
00084 } else {
00085 cout << "HLTEventAnalyzerRAW::analyze:"
00086 << " config extraction failure with process name "
00087 << processName_ << endl;
00088 }
00089
00090 }
00091
00092
00093 void
00094 HLTEventAnalyzerRAW::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00095 {
00096 using namespace std;
00097 using namespace edm;
00098
00099 cout << endl;
00100
00101
00102 iEvent.getByLabel(triggerResultsTag_,triggerResultsHandle_);
00103 if (!triggerResultsHandle_.isValid()) {
00104 cout << "HLTEventAnalyzerRAW::analyze: Error in getting TriggerResults product from Event!" << endl;
00105 return;
00106 }
00107 iEvent.getByLabel(triggerEventWithRefsTag_,triggerEventWithRefsHandle_);
00108 if (!triggerEventWithRefsHandle_.isValid()) {
00109 cout << "HLTEventAnalyzerRAW::analyze: Error in getting TriggerEventWithRefs product from Event!" << endl;
00110 return;
00111 }
00112
00113 assert(triggerResultsHandle_->size()==hltConfig_.size());
00114
00115
00116 if (triggerName_=="@") {
00117 const unsigned int n(hltConfig_.size());
00118 for (unsigned int i=0; i!=n; ++i) {
00119 analyzeTrigger(iEvent,iSetup,hltConfig_.triggerName(i));
00120 }
00121 } else {
00122 analyzeTrigger(iEvent,iSetup,triggerName_);
00123 }
00124
00125 return;
00126
00127 }
00128
00129 void HLTEventAnalyzerRAW::analyzeTrigger(const edm::Event& iEvent, const edm::EventSetup& iSetup, const std::string& triggerName) {
00130
00131 using namespace std;
00132 using namespace edm;
00133 using namespace reco;
00134 using namespace trigger;
00135
00136 cout << endl;
00137
00138 const unsigned int n(hltConfig_.size());
00139 const unsigned int triggerIndex(hltConfig_.triggerIndex(triggerName));
00140 assert(triggerIndex==iEvent.triggerNames(*triggerResultsHandle_).triggerIndex(triggerName));
00141
00142
00143 if (triggerIndex>=n) {
00144 cout << "HLTEventAnalyzerRAW::analyzeTrigger: path "
00145 << triggerName << " - not found!" << endl;
00146 return;
00147 }
00148
00149 cout << "HLTEventAnalyzerRAW::analyzeTrigger: path "
00150 << triggerName << " [" << triggerIndex << "]" << endl;
00151
00152 const unsigned int m(hltConfig_.size(triggerIndex));
00153 const vector<string>& moduleLabels(hltConfig_.moduleLabels(triggerIndex));
00154
00155
00156 cout << " Trigger path status:"
00157 << " WasRun=" << triggerResultsHandle_->wasrun(triggerIndex)
00158 << " Accept=" << triggerResultsHandle_->accept(triggerIndex)
00159 << " Error =" << triggerResultsHandle_->error(triggerIndex)
00160 << endl;
00161 const unsigned int moduleIndex(triggerResultsHandle_->index(triggerIndex));
00162 cout << " Last active module - label/type: "
00163 << moduleLabels[moduleIndex] << "/" << hltConfig_.moduleType(moduleLabels[moduleIndex])
00164 << " [" << moduleIndex << " out of 0-" << (m-1) << " on this path]"
00165 << endl;
00166 assert (moduleIndex<m);
00167
00168
00169 photonIds_.clear();
00170 photonRefs_.clear();
00171 electronIds_.clear();
00172 electronRefs_.clear();
00173 muonIds_.clear();
00174 muonRefs_.clear();
00175 jetIds_.clear();
00176 jetRefs_.clear();
00177 compositeIds_.clear();
00178 compositeRefs_.clear();
00179 basemetIds_.clear();
00180 basemetRefs_.clear();
00181 calometIds_.clear();
00182 calometRefs_.clear();
00183 pixtrackIds_.clear();
00184 pixtrackRefs_.clear();
00185 l1emIds_.clear();
00186 l1emRefs_.clear();
00187 l1muonIds_.clear();
00188 l1muonRefs_.clear();
00189 l1jetIds_.clear();
00190 l1jetRefs_.clear();
00191 l1etmissIds_.clear();
00192 l1etmissRefs_.clear();
00193 l1hfringsIds_.clear();
00194 l1hfringsRefs_.clear();
00195 pfjetIds_.clear();
00196 pfjetRefs_.clear();
00197 pftauIds_.clear();
00198 pftauRefs_.clear();
00199
00200
00201
00202 for (unsigned int j=0; j<=moduleIndex; ++j) {
00203 const string& moduleLabel(moduleLabels[j]);
00204 const string moduleType(hltConfig_.moduleType(moduleLabel));
00205
00206 const unsigned int filterIndex(triggerEventWithRefsHandle_->filterIndex(InputTag(moduleLabel,"",processName_)));
00207 if (filterIndex<triggerEventWithRefsHandle_->size()) {
00208 cout << " Filter in slot " << j << " - label/type " << moduleLabel << "/" << moduleType << endl;
00209 cout << " Filter packed up at: " << filterIndex << endl;
00210 cout << " Accepted objects:" << endl;
00211
00212 triggerEventWithRefsHandle_->getObjects(filterIndex,photonIds_,photonRefs_);
00213 const unsigned int nPhotons(photonIds_.size());
00214 if (nPhotons>0) {
00215 cout << " Photons: " << nPhotons << " - the objects: # id pt" << endl;
00216 for (unsigned int i=0; i!=nPhotons; ++i) {
00217 cout << " " << i << " " << photonIds_[i]
00218 << " " << photonRefs_[i]->pt()
00219 << endl;
00220 }
00221 }
00222
00223 triggerEventWithRefsHandle_->getObjects(filterIndex,electronIds_,electronRefs_);
00224 const unsigned int nElectrons(electronIds_.size());
00225 if (nElectrons>0) {
00226 cout << " Electrons: " << nElectrons << " - the objects: # id pt" << endl;
00227 for (unsigned int i=0; i!=nElectrons; ++i) {
00228 cout << " " << i << " " << electronIds_[i]
00229 << " " << electronRefs_[i]->pt()
00230 << endl;
00231 }
00232 }
00233
00234 triggerEventWithRefsHandle_->getObjects(filterIndex,muonIds_,muonRefs_);
00235 const unsigned int nMuons(muonIds_.size());
00236 if (nMuons>0) {
00237 cout << " Muons: " << nMuons << " - the objects: # id pt" << endl;
00238 for (unsigned int i=0; i!=nMuons; ++i) {
00239 cout << " " << i << " " << muonIds_[i]
00240 << " " << muonRefs_[i]->pt()
00241 << endl;
00242 }
00243 }
00244
00245 triggerEventWithRefsHandle_->getObjects(filterIndex,jetIds_,jetRefs_);
00246 const unsigned int nJets(jetIds_.size());
00247 if (nJets>0) {
00248 cout << " Jets: " << nJets << " - the objects: # id pt" << endl;
00249 for (unsigned int i=0; i!=nJets; ++i) {
00250 cout << " " << i << " " << jetIds_[i]
00251 << " " << jetRefs_[i]->pt()
00252 << endl;
00253 }
00254 }
00255
00256 triggerEventWithRefsHandle_->getObjects(filterIndex,compositeIds_,compositeRefs_);
00257 const unsigned int nComposites(compositeIds_.size());
00258 if (nComposites>0) {
00259 cout << " Composites: " << nComposites << " - the objects: # id pt" << endl;
00260 for (unsigned int i=0; i!=nComposites; ++i) {
00261 cout << " " << i << " " << compositeIds_[i]
00262 << " " << compositeRefs_[i]->pt()
00263 << endl;
00264 }
00265 }
00266
00267 triggerEventWithRefsHandle_->getObjects(filterIndex,basemetIds_,basemetRefs_);
00268 const unsigned int nBaseMETs(basemetIds_.size());
00269 if (nBaseMETs>0) {
00270 cout << " BaseMETs: " << nBaseMETs << " - the objects: # id pt" << endl;
00271 for (unsigned int i=0; i!=nBaseMETs; ++i) {
00272 cout << " " << i << " " << basemetIds_[i]
00273 << " " << basemetRefs_[i]->pt()
00274 << endl;
00275 }
00276 }
00277
00278 triggerEventWithRefsHandle_->getObjects(filterIndex,calometIds_,calometRefs_);
00279 const unsigned int nCaloMETs(calometIds_.size());
00280 if (nCaloMETs>0) {
00281 cout << " CaloMETs: " << nCaloMETs << " - the objects: # id pt" << endl;
00282 for (unsigned int i=0; i!=nCaloMETs; ++i) {
00283 cout << " " << i << " " << calometIds_[i]
00284 << " " << calometRefs_[i]->pt()
00285 << endl;
00286 }
00287 }
00288
00289 triggerEventWithRefsHandle_->getObjects(filterIndex,pixtrackIds_,pixtrackRefs_);
00290 const unsigned int nPixTracks(pixtrackIds_.size());
00291 if (nPixTracks>0) {
00292 cout << " PixTracks: " << nPixTracks << " - the objects: # id pt" << endl;
00293 for (unsigned int i=0; i!=nPixTracks; ++i) {
00294 cout << " " << i << " " << pixtrackIds_[i]
00295 << " " << pixtrackRefs_[i]->pt()
00296 << endl;
00297 }
00298 }
00299
00300 triggerEventWithRefsHandle_->getObjects(filterIndex,l1emIds_,l1emRefs_);
00301 const unsigned int nL1EM(l1emIds_.size());
00302 if (nL1EM>0) {
00303 cout << " L1EM: " << nL1EM << " - the objects: # id pt" << endl;
00304 for (unsigned int i=0; i!=nL1EM; ++i) {
00305 cout << " " << i << " " << l1emIds_[i]
00306 << " " << l1emRefs_[i]->pt()
00307 << endl;
00308 }
00309 }
00310
00311 triggerEventWithRefsHandle_->getObjects(filterIndex,l1muonIds_,l1muonRefs_);
00312 const unsigned int nL1Muon(l1muonIds_.size());
00313 if (nL1Muon>0) {
00314 cout << " L1Muon: " << nL1Muon << " - the objects: # id pt" << endl;
00315 for (unsigned int i=0; i!=nL1Muon; ++i) {
00316 cout << " " << i << " " << l1muonIds_[i]
00317 << " " << l1muonRefs_[i]->pt()
00318 << endl;
00319 }
00320 }
00321
00322 triggerEventWithRefsHandle_->getObjects(filterIndex,l1jetIds_,l1jetRefs_);
00323 const unsigned int nL1Jet(l1jetIds_.size());
00324 if (nL1Jet>0) {
00325 cout << " L1Jet: " << nL1Jet << " - the objects: # id pt" << endl;
00326 for (unsigned int i=0; i!=nL1Jet; ++i) {
00327 cout << " " << i << " " << l1jetIds_[i]
00328 << " " << l1jetRefs_[i]->pt()
00329 << endl;
00330 }
00331 }
00332
00333 triggerEventWithRefsHandle_->getObjects(filterIndex,l1etmissIds_,l1etmissRefs_);
00334 const unsigned int nL1EtMiss(l1etmissIds_.size());
00335 if (nL1EtMiss>0) {
00336 cout << " L1EtMiss: " << nL1EtMiss << " - the objects: # id pt" << endl;
00337 for (unsigned int i=0; i!=nL1EtMiss; ++i) {
00338 cout << " " << i << " " << l1etmissIds_[i]
00339 << " " << l1etmissRefs_[i]->pt()
00340 << endl;
00341 }
00342 }
00343
00344 triggerEventWithRefsHandle_->getObjects(filterIndex,l1hfringsIds_,l1hfringsRefs_);
00345 const unsigned int nL1HfRings(l1hfringsIds_.size());
00346 if (nL1HfRings>0) {
00347 cout << " L1HfRings: " << nL1HfRings << " - the objects: # id 4 4" << endl;
00348 for (unsigned int i=0; i!=nL1HfRings; ++i) {
00349 cout << " " << i << " " << l1hfringsIds_[i]
00350 << " " << l1hfringsRefs_[i]->hfEtSum(l1extra::L1HFRings::kRing1PosEta)
00351 << " " << l1hfringsRefs_[i]->hfEtSum(l1extra::L1HFRings::kRing1NegEta)
00352 << " " << l1hfringsRefs_[i]->hfEtSum(l1extra::L1HFRings::kRing2PosEta)
00353 << " " << l1hfringsRefs_[i]->hfEtSum(l1extra::L1HFRings::kRing2NegEta)
00354 << " " << l1hfringsRefs_[i]->hfBitCount(l1extra::L1HFRings::kRing1PosEta)
00355 << " " << l1hfringsRefs_[i]->hfBitCount(l1extra::L1HFRings::kRing1NegEta)
00356 << " " << l1hfringsRefs_[i]->hfBitCount(l1extra::L1HFRings::kRing2PosEta)
00357 << " " << l1hfringsRefs_[i]->hfBitCount(l1extra::L1HFRings::kRing2NegEta)
00358 << endl;
00359 }
00360 }
00361
00362 triggerEventWithRefsHandle_->getObjects(filterIndex,pfjetIds_,pfjetRefs_);
00363 const unsigned int nPFJets(pfjetIds_.size());
00364 if (nPFJets>0) {
00365 cout << " PFJets: " << nPFJets << " - the objects: # id pt" << endl;
00366 for (unsigned int i=0; i!=nPFJets; ++i) {
00367 cout << " " << i << " " << pfjetIds_[i]
00368 << " " << pfjetRefs_[i]->pt()
00369 << endl;
00370 }
00371 }
00372
00373 triggerEventWithRefsHandle_->getObjects(filterIndex,pftauIds_,pftauRefs_);
00374 const unsigned int nPFTaus(pftauIds_.size());
00375 if (nPFTaus>0) {
00376 cout << " PFTaus: " << nPFTaus << " - the objects: # id pt" << endl;
00377 for (unsigned int i=0; i!=nPFTaus; ++i) {
00378 cout << " " << i << " " << pftauIds_[i]
00379 << " " << pftauRefs_[i]->pt()
00380 << endl;
00381 }
00382 }
00383
00384 }
00385 }
00386
00387 return;
00388 }