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