CMS 3D CMS Logo

HLTEventAnalyzerAOD.cc
Go to the documentation of this file.
1 
16 
17 #include <cassert>
18 
19 //
20 // constructors and destructor
21 //
23  : processName_(ps.getParameter<std::string>("processName")),
24  triggerName_(ps.getParameter<std::string>("triggerName")),
25  triggerResultsTag_(ps.getParameter<edm::InputTag>("triggerResults")),
26  triggerResultsToken_(consumes<edm::TriggerResults>(triggerResultsTag_)),
27  triggerEventTag_(ps.getParameter<edm::InputTag>("triggerEvent")),
28  triggerEventToken_(consumes<trigger::TriggerEvent>(triggerEventTag_)),
29  hltPrescaleProvider_(ps, consumesCollector(), *this) {
30  using namespace std;
31  using namespace edm;
32 
33  LogVerbatim("HLTEventAnalyzerAOD") << "HLTEventAnalyzerAOD configuration: " << endl
34  << " ProcessName = " << processName_ << endl
35  << " TriggerName = " << triggerName_ << endl
36  << " TriggerResultsTag = " << triggerResultsTag_.encode() << endl
37  << " TriggerEventTag = " << triggerEventTag_.encode() << endl;
38 }
39 
41 
42 //
43 // member functions
44 //
47  desc.add<std::string>("processName", "HLT");
48  desc.add<std::string>("triggerName", "@");
49  desc.add<edm::InputTag>("triggerResults", edm::InputTag("TriggerResults", "", "HLT"));
50  desc.add<edm::InputTag>("triggerEvent", edm::InputTag("hltTriggerSummaryAOD", "", "HLT"));
51  desc.add<unsigned int>("stageL1Trigger", 1);
52  descriptions.add("hltEventAnalyzerAODDefault", desc);
53 }
54 
55 void HLTEventAnalyzerAOD::endRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {}
56 
57 void HLTEventAnalyzerAOD::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
58  using namespace std;
59  using namespace edm;
60 
61  bool changed(true);
62  if (hltPrescaleProvider_.init(iRun, iSetup, processName_, changed)) {
64 
65  if (changed) {
66  // check if trigger name in (new) config
67  if (triggerName_ != "@") { // "@" means: analyze all triggers in config
68  const unsigned int n(hltConfig.size());
69  const unsigned int triggerIndex(hltConfig.triggerIndex(triggerName_));
70  if (triggerIndex >= n) {
71  LogVerbatim("HLTEventAnalyzerAOD")
72  << "HLTEventAnalyzerAOD::analyze:"
73  << " TriggerName " << triggerName_ << " not available in (new) config!" << endl;
74  LogVerbatim("HLTEventAnalyzerAOD") << "Available TriggerNames are: " << endl;
75  hltConfig.dump("Triggers");
76  }
77  }
78  hltConfig.dump("ProcessName");
79  hltConfig.dump("GlobalTag");
80  hltConfig.dump("TableName");
81  hltConfig.dump("Streams");
82  hltConfig.dump("Datasets");
83  hltConfig.dump("PrescaleTable");
84  hltConfig.dump("ProcessPSet");
85  }
86  } else {
87  LogVerbatim("HLTEventAnalyzerAOD") << "HLTEventAnalyzerAOD::analyze:"
88  << " config extraction failure with process name " << processName_ << endl;
89  }
90 }
91 
92 // ------------ method called to produce the data ------------
94  using namespace std;
95  using namespace edm;
96 
97  LogVerbatim("HLTEventAnalyzerAOD") << endl;
98 
99  // get event products
102  LogVerbatim("HLTEventAnalyzerAOD")
103  << "HLTEventAnalyzerAOD::analyze: Error in getting TriggerResults product from Event!" << endl;
104  return;
105  }
107  if (!triggerEventHandle_.isValid()) {
108  LogVerbatim("HLTEventAnalyzerAOD")
109  << "HLTEventAnalyzerAOD::analyze: Error in getting TriggerEvent product from Event!" << endl;
110  return;
111  }
112 
114 
115  // sanity check
117 
118  // analyze this event for the triggers requested
119  if (triggerName_ == "@") {
120  const unsigned int n(hltConfig.size());
121  for (unsigned int i = 0; i != n; ++i) {
122  analyzeTrigger(iEvent, iSetup, hltConfig.triggerName(i));
123  }
124  } else {
126  }
127 
128  return;
129 }
130 
132  const edm::EventSetup& iSetup,
133  const std::string& triggerName) {
134  using namespace std;
135  using namespace edm;
136  using namespace reco;
137  using namespace trigger;
138 
139  LogVerbatim("HLTEventAnalyzerAOD") << endl;
140 
142 
143  const unsigned int n(hltConfig.size());
144  const unsigned int triggerIndex(hltConfig.triggerIndex(triggerName));
145  assert(triggerIndex == iEvent.triggerNames(*triggerResultsHandle_).triggerIndex(triggerName));
146 
147  // abort on invalid trigger name
148  if (triggerIndex >= n) {
149  LogVerbatim("HLTEventAnalyzerAOD") << "HLTEventAnalyzerAOD::analyzeTrigger: path " << triggerName << " - not found!"
150  << endl;
151  return;
152  }
153 
154  const std::pair<int, int> prescales(hltPrescaleProvider_.prescaleValues(iEvent, iSetup, triggerName));
155  LogVerbatim("HLTEventAnalyzerAOD") << "HLTEventAnalyzerAOD::analyzeTrigger: path " << triggerName << " ["
156  << triggerIndex << "] "
157  << "prescales L1T,HLT: " << prescales.first << "," << prescales.second << endl;
158  const std::pair<std::vector<std::pair<std::string, int> >, int> prescalesInDetail(
160  std::ostringstream message;
161  for (unsigned int i = 0; i < prescalesInDetail.first.size(); ++i) {
162  message << " " << i << ":" << prescalesInDetail.first[i].first << "/" << prescalesInDetail.first[i].second;
163  }
164  LogVerbatim("HLTEventAnalyzerAOD") << "HLTEventAnalyzerAOD::analyzeTrigger: path " << triggerName << " ["
165  << triggerIndex << "] " << endl
166  << "prescales L1T: " << prescalesInDetail.first.size() << message.str() << endl
167  << " prescale HLT: " << prescalesInDetail.second << endl;
168 
169  // modules on this trigger path
170  const unsigned int m(hltConfig.size(triggerIndex));
171  const vector<string>& moduleLabels(hltConfig.moduleLabels(triggerIndex));
172 
173  // Results from TriggerResults product
174  LogVerbatim("HLTEventAnalyzerAOD") << " Trigger path status:"
175  << " WasRun=" << triggerResultsHandle_->wasrun(triggerIndex)
176  << " Accept=" << triggerResultsHandle_->accept(triggerIndex)
177  << " Error =" << triggerResultsHandle_->error(triggerIndex) << endl;
178  const unsigned int moduleIndex(triggerResultsHandle_->index(triggerIndex));
179  LogVerbatim("HLTEventAnalyzerAOD") << " Last active module - label/type: " << moduleLabels[moduleIndex] << "/"
180  << hltConfig.moduleType(moduleLabels[moduleIndex]) << " [" << moduleIndex
181  << " out of 0-" << (m - 1) << " on this path]" << endl;
182  assert(moduleIndex < m);
183 
184  // Results from TriggerEvent product - Attention: must look only for
185  // modules actually run in this path for this event!
186  for (unsigned int j = 0; j <= moduleIndex; ++j) {
187  const string& moduleLabel(moduleLabels[j]);
188  const string moduleType(hltConfig.moduleType(moduleLabel));
189  // check whether the module is packed up in TriggerEvent product
190  const unsigned int filterIndex(triggerEventHandle_->filterIndex(InputTag(moduleLabel, "", processName_)));
191  if (filterIndex < triggerEventHandle_->sizeFilters()) {
192  LogVerbatim("HLTEventAnalyzerAOD") << " 'L3' filter in slot " << j << " - label/type " << moduleLabel << "/"
193  << moduleType << endl;
194  const Vids& VIDS(triggerEventHandle_->filterIds(filterIndex));
195  const Keys& KEYS(triggerEventHandle_->filterKeys(filterIndex));
196  const size_type nI(VIDS.size());
197  const size_type nK(KEYS.size());
198  assert(nI == nK);
199  const size_type n(max(nI, nK));
200  LogVerbatim("HLTEventAnalyzerAOD") << " " << n << " accepted 'L3' objects found: " << endl;
202  for (size_type i = 0; i != n; ++i) {
203  const TriggerObject& TO(TOC[KEYS[i]]);
204  LogVerbatim("HLTEventAnalyzerAOD") << " " << i << " " << VIDS[i] << "/" << KEYS[i] << ": " << TO.id() << " "
205  << TO.pt() << " " << TO.eta() << " " << TO.phi() << " " << TO.mass() << endl;
206  }
207  }
208  }
209 
210  return;
211 }
ConfigurationDescriptions.h
trigger::TriggerObject::phi
float phi() const
Definition: TriggerObject.h:54
TriggerObject
Definition: TriggerObject.py:1
HLTEventAnalyzerAOD::HLTEventAnalyzerAOD
HLTEventAnalyzerAOD(const edm::ParameterSet &)
Definition: HLTEventAnalyzerAOD.cc:22
mps_fire.i
i
Definition: mps_fire.py:355
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
trigger::TriggerEvent::filterKeys
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:118
MessageLogger.h
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
HLTEventAnalyzerAOD::triggerName_
const std::string triggerName_
Definition: HLTEventAnalyzerAOD.h:41
trigger::Vids
std::vector< int > Vids
Definition: TriggerTypeDefs.h:21
HLTEventAnalyzerAOD::triggerEventTag_
const edm::InputTag triggerEventTag_
Definition: HLTEventAnalyzerAOD.h:44
edm::Run
Definition: Run.h:45
HLTPrescaleProvider::hltConfigProvider
HLTConfigProvider const & hltConfigProvider() const
Definition: HLTPrescaleProvider.h:51
HLTEventAnalyzerAOD::~HLTEventAnalyzerAOD
~HLTEventAnalyzerAOD() override
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::HLTGlobalStatus::wasrun
bool wasrun() const
Was at least one path run?
Definition: HLTGlobalStatus.h:47
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
cms::cuda::assert
assert(be >=bs)
edm::HLTGlobalStatus::error
bool error() const
Has any path encountered an error (exception)
Definition: HLTGlobalStatus.h:51
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
HLTEventAnalyzerAOD::triggerEventToken_
const edm::EDGetTokenT< trigger::TriggerEvent > triggerEventToken_
Definition: HLTEventAnalyzerAOD.h:45
edm::HLTGlobalStatus::index
unsigned int index(const unsigned int i) const
Get index (slot position) of module giving the decision of the ith path.
Definition: HLTGlobalStatus.h:70
trigger::TriggerObject::pt
float pt() const
Definition: TriggerObject.h:52
HLTEventAnalyzerAOD::endRun
void endRun(edm::Run const &, edm::EventSetup const &) override
Definition: HLTEventAnalyzerAOD.cc:55
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
edm::HLTGlobalStatus::size
unsigned int size() const
Get number of paths stored.
Definition: HLTGlobalStatus.h:35
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
HLTEventAnalyzerAOD::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: HLTEventAnalyzerAOD.cc:93
HLTEventAnalyzerAOD::hltPrescaleProvider_
HLTPrescaleProvider hltPrescaleProvider_
Definition: HLTEventAnalyzerAOD.h:50
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HLTEventAnalyzerAOD::analyzeTrigger
virtual void analyzeTrigger(const edm::Event &, const edm::EventSetup &, const std::string &triggerName)
Definition: HLTEventAnalyzerAOD.cc:131
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
hltrates_dqm_sourceclient-live_cfg.prescales
prescales
Definition: hltrates_dqm_sourceclient-live_cfg.py:90
trigger::TriggerObjectCollection
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:75
HLTPrescaleProvider::prescaleValuesInDetail
std::pair< std::vector< std::pair< std::string, int > >, int > prescaleValuesInDetail(const edm::Event &iEvent, const edm::EventSetup &iSetup, const std::string &trigger)
Definition: HLTPrescaleProvider.cc:224
trigger::TriggerObject::id
int id() const
getters
Definition: TriggerObject.h:51
TriggerNames.h
iEvent
int iEvent
Definition: GenABIO.cc:224
trigger::TriggerEvent::filterIndex
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Definition: TriggerEvent.h:132
HLTEventAnalyzerAOD::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: HLTEventAnalyzerAOD.cc:57
trigger::Keys
std::vector< size_type > Keys
Definition: TriggerTypeDefs.h:19
edm::LogVerbatim
Definition: MessageLogger.h:297
trigger::TriggerObject::eta
float eta() const
Definition: TriggerObject.h:53
edm::InputTag::encode
std::string encode() const
Definition: InputTag.cc:159
edm::EventSetup
Definition: EventSetup.h:57
HLTEventAnalyzerAOD::triggerResultsTag_
const edm::InputTag triggerResultsTag_
Definition: HLTEventAnalyzerAOD.h:42
HLTConfigProvider.h
HLTEventAnalyzerAOD::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTEventAnalyzerAOD.cc:45
trigger::TriggerEvent::getObjects
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:101
HLTEventAnalyzerAOD::triggerResultsToken_
const edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
Definition: HLTEventAnalyzerAOD.h:43
HLTPrescaleProvider::init
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
Definition: HLTPrescaleProvider.cc:21
trigger::TriggerEvent::filterIds
const Vids & filterIds(trigger::size_type index) const
Definition: TriggerEvent.h:117
HLTEventAnalyzerAOD::triggerEventHandle_
edm::Handle< trigger::TriggerEvent > triggerEventHandle_
Definition: HLTEventAnalyzerAOD.h:49
HLTConfigProvider
Definition: HLTConfigProvider.h:28
std
Definition: JetResolutionObject.h:76
HLTEventAnalyzerAOD::processName_
const std::string processName_
module config parameters
Definition: HLTEventAnalyzerAOD.h:40
HltComparatorCreateWorkflow.hltConfig
hltConfig
Definition: HltComparatorCreateWorkflow.py:161
edm::HLTGlobalStatus::accept
bool accept() const
Has at least one path accepted the event?
Definition: HLTGlobalStatus.h:49
trigger
Definition: HLTPrescaleTableCond.h:8
HLTPrescaleProvider::prescaleValues
std::pair< int, int > prescaleValues(const edm::Event &iEvent, const edm::EventSetup &iSetup, const std::string &trigger)
Combined L1T (pair.first) and HLT (pair.second) prescales per HLT path.
Definition: HLTPrescaleProvider.cc:116
HerwigMaxPtPartonFilter_cfi.moduleLabel
moduleLabel
Definition: HerwigMaxPtPartonFilter_cfi.py:4
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
HLTEventAnalyzerAOD.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
HLTObjectsMonitor_cfi.TriggerResults
TriggerResults
Definition: HLTObjectsMonitor_cfi.py:9
edm::Event
Definition: Event.h:73
TriggerResultsByName.h
HLTEventAnalyzerAOD::triggerResultsHandle_
edm::Handle< edm::TriggerResults > triggerResultsHandle_
additional class data memebers
Definition: HLTEventAnalyzerAOD.h:48
trigger::TriggerObject::mass
float mass() const
Definition: TriggerObject.h:55
edm::InputTag
Definition: InputTag.h:15
PDWG_DiPhoton_SD_cff.triggerName
triggerName
Definition: PDWG_DiPhoton_SD_cff.py:37
ZCounting_cff.TriggerEvent
TriggerEvent
Definition: ZCounting_cff.py:5