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/HLTEventAnalyzerAOD.h"
00015 #include <cassert>
00016
00017
00018
00019
00020 HLTEventAnalyzerAOD::HLTEventAnalyzerAOD(const edm::ParameterSet& ps) :
00021 processName_(ps.getParameter<std::string>("processName")),
00022 triggerName_(ps.getParameter<std::string>("triggerName")),
00023 triggerResultsTag_(ps.getParameter<edm::InputTag>("triggerResults")),
00024 triggerEventTag_(ps.getParameter<edm::InputTag>("triggerEvent"))
00025 {
00026 using namespace std;
00027 using namespace edm;
00028
00029 cout << "HLTEventAnalyzerAOD configuration: " << endl
00030 << " ProcessName = " << processName_ << endl
00031 << " TriggerName = " << triggerName_ << endl
00032 << " TriggerResultsTag = " << triggerResultsTag_.encode() << endl
00033 << " TriggerEventTag = " << triggerEventTag_.encode() << endl;
00034
00035 }
00036
00037 HLTEventAnalyzerAOD::~HLTEventAnalyzerAOD()
00038 {
00039 }
00040
00041
00042
00043
00044 void
00045 HLTEventAnalyzerAOD::beginRun(edm::Run const & iRun, edm::EventSetup const& iSetup)
00046 {
00047 using namespace std;
00048 using namespace edm;
00049
00050 bool changed(true);
00051 if (hltConfig_.init(iRun,iSetup,processName_,changed)) {
00052 if (changed) {
00053
00054 if (triggerName_!="@") {
00055 const unsigned int n(hltConfig_.size());
00056 const unsigned int triggerIndex(hltConfig_.triggerIndex(triggerName_));
00057 if (triggerIndex>=n) {
00058 cout << "HLTEventAnalyzerAOD::analyze:"
00059 << " TriggerName " << triggerName_
00060 << " not available in (new) config!" << endl;
00061 cout << "Available TriggerNames are: " << endl;
00062 hltConfig_.dump("Triggers");
00063 }
00064 }
00065 hltConfig_.dump("ProcessName");
00066 hltConfig_.dump("GlobalTag");
00067 hltConfig_.dump("TableName");
00068 hltConfig_.dump("Streams");
00069 hltConfig_.dump("Datasets");
00070 hltConfig_.dump("PrescaleTable");
00071 hltConfig_.dump("ProcessPSet");
00072 }
00073 } else {
00074 cout << "HLTEventAnalyzerAOD::analyze:"
00075 << " config extraction failure with process name "
00076 << processName_ << endl;
00077 }
00078 }
00079
00080
00081 void
00082 HLTEventAnalyzerAOD::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00083 {
00084 using namespace std;
00085 using namespace edm;
00086
00087 cout << endl;
00088
00089
00090 iEvent.getByLabel(triggerResultsTag_,triggerResultsHandle_);
00091 if (!triggerResultsHandle_.isValid()) {
00092 cout << "HLTEventAnalyzerAOD::analyze: Error in getting TriggerResults product from Event!" << endl;
00093 return;
00094 }
00095 iEvent.getByLabel(triggerEventTag_,triggerEventHandle_);
00096 if (!triggerEventHandle_.isValid()) {
00097 cout << "HLTEventAnalyzerAOD::analyze: Error in getting TriggerEvent product from Event!" << endl;
00098 return;
00099 }
00100
00101 assert(triggerResultsHandle_->size()==hltConfig_.size());
00102
00103
00104 if (triggerName_=="@") {
00105 const unsigned int n(hltConfig_.size());
00106 for (unsigned int i=0; i!=n; ++i) {
00107 analyzeTrigger(iEvent,iSetup,hltConfig_.triggerName(i));
00108 }
00109 } else {
00110 analyzeTrigger(iEvent,iSetup,triggerName_);
00111 }
00112
00113 return;
00114
00115 }
00116
00117 void HLTEventAnalyzerAOD::analyzeTrigger(const edm::Event& iEvent, const edm::EventSetup& iSetup, const std::string& triggerName) {
00118
00119 using namespace std;
00120 using namespace edm;
00121 using namespace reco;
00122 using namespace trigger;
00123
00124 cout << endl;
00125
00126 const unsigned int n(hltConfig_.size());
00127 const unsigned int triggerIndex(hltConfig_.triggerIndex(triggerName));
00128 assert(triggerIndex==iEvent.triggerNames(*triggerResultsHandle_).triggerIndex(triggerName));
00129
00130
00131 if (triggerIndex>=n) {
00132 cout << "HLTEventAnalyzerAOD::analyzeTrigger: path "
00133 << triggerName << " - not found!" << endl;
00134 return;
00135 }
00136
00137 const std::pair<int,int> prescales(hltConfig_.prescaleValues(iEvent,iSetup,triggerName));
00138 cout << "HLTEventAnalyzerAOD::analyzeTrigger: path "
00139 << triggerName << " [" << triggerIndex << "] "
00140 << "prescales L1T,HLT: " << prescales.first << "," << prescales.second
00141 << endl;
00142
00143
00144 const unsigned int m(hltConfig_.size(triggerIndex));
00145 const vector<string>& moduleLabels(hltConfig_.moduleLabels(triggerIndex));
00146
00147
00148 cout << " Trigger path status:"
00149 << " WasRun=" << triggerResultsHandle_->wasrun(triggerIndex)
00150 << " Accept=" << triggerResultsHandle_->accept(triggerIndex)
00151 << " Error =" << triggerResultsHandle_->error(triggerIndex)
00152 << endl;
00153 const unsigned int moduleIndex(triggerResultsHandle_->index(triggerIndex));
00154 cout << " Last active module - label/type: "
00155 << moduleLabels[moduleIndex] << "/" << hltConfig_.moduleType(moduleLabels[moduleIndex])
00156 << " [" << moduleIndex << " out of 0-" << (m-1) << " on this path]"
00157 << endl;
00158 assert (moduleIndex<m);
00159
00160
00161
00162 for (unsigned int j=0; j<=moduleIndex; ++j) {
00163 const string& moduleLabel(moduleLabels[j]);
00164 const string moduleType(hltConfig_.moduleType(moduleLabel));
00165
00166 const unsigned int filterIndex(triggerEventHandle_->filterIndex(InputTag(moduleLabel,"",processName_)));
00167 if (filterIndex<triggerEventHandle_->sizeFilters()) {
00168 cout << " 'L3' filter in slot " << j << " - label/type " << moduleLabel << "/" << moduleType << endl;
00169 const Vids& VIDS (triggerEventHandle_->filterIds(filterIndex));
00170 const Keys& KEYS(triggerEventHandle_->filterKeys(filterIndex));
00171 const size_type nI(VIDS.size());
00172 const size_type nK(KEYS.size());
00173 assert(nI==nK);
00174 const size_type n(max(nI,nK));
00175 cout << " " << n << " accepted 'L3' objects found: " << endl;
00176 const TriggerObjectCollection& TOC(triggerEventHandle_->getObjects());
00177 for (size_type i=0; i!=n; ++i) {
00178 const TriggerObject& TO(TOC[KEYS[i]]);
00179 cout << " " << i << " " << VIDS[i] << "/" << KEYS[i] << ": "
00180 << TO.id() << " " << TO.pt() << " " << TO.eta() << " " << TO.phi() << " " << TO.mass()
00181 << endl;
00182 }
00183 }
00184 }
00185
00186 return;
00187 }