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