CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTConfigData.cc
Go to the documentation of this file.
1 
14 
15 #include <iostream>
16 
18 {
19  static edm::ParameterSet dummyPSet;
20  dummyPSet.registerIt();
21  return &dummyPSet;
22 }
23 
25  processPSet_(s_dummyPSet()),
26  processName_(""),
27  tableName_(), triggerNames_(), moduleLabels_(), saveTagsModules_(),
28  triggerIndex_(), moduleIndex_(),
29  hltL1GTSeeds_(),
30  streamNames_(), streamIndex_(), streamContents_(),
31  datasetNames_(), datasetIndex_(), datasetContents_(),
32  hltPrescaleTable_()
33 {
34  if (processPSet_->id().isValid()) {
35  extract();
36  }
37 }
38 
40  processPSet_(iPSet),
41  processName_(""),
42  tableName_(), triggerNames_(), moduleLabels_(), saveTagsModules_(),
43  triggerIndex_(), moduleIndex_(),
44  hltL1GTSeeds_(),
45  streamNames_(), streamIndex_(), streamContents_(),
46  datasetNames_(), datasetIndex_(), datasetContents_(),
47  hltPrescaleTable_()
48 {
49  if (processPSet_->id().isValid()) {
50  extract();
51  }
52 }
53 
55 {
56  using namespace std;
57  using namespace edm;
58  using namespace trigger;
59 
60  // Extract process name
61  if (processPSet_->existsAs<string>("@process_name",true)) {
62  processName_= processPSet_->getParameter<string>("@process_name");
63  }
64 
65  // Obtain PSet containing table name (available only in 2_1_10++ files)
66  if (processPSet_->existsAs<ParameterSet>("HLTConfigVersion",true)) {
67  const ParameterSet& HLTPSet(processPSet_->getParameterSet("HLTConfigVersion"));
68  if (HLTPSet.existsAs<string>("tableName",true)) {
69  tableName_=HLTPSet.getParameter<string>("tableName");
70  }
71  }
72  LogVerbatim("HLTConfigData") << "ProcessPSet with: "
73  << processName_ << " "
74  << tableName();
75 
76  // Extract trigger paths (= paths - end_paths)
77  if (processPSet_->existsAs<ParameterSet>("@trigger_paths",true)) {
78  const ParameterSet& HLTPSet(processPSet_->getParameterSet("@trigger_paths"));
79  if (HLTPSet.existsAs<vector<string> >("@trigger_paths",true)) {
80  triggerNames_= HLTPSet.getParameter<vector<string> >("@trigger_paths");
81  }
82  }
83 
84  // Obtain module labels of all modules on all trigger paths
85  const unsigned int n(size());
86  moduleLabels_.reserve(n);
87  for (unsigned int i=0;i!=n; ++i) {
88  if (processPSet_->existsAs<vector<string> >(triggerNames_[i],true)) {
89  moduleLabels_.push_back(processPSet_->getParameter<vector<string> >(triggerNames_[i]));
90  }
91  }
92  saveTagsModules_.reserve(n);
93  vector<string> labels;
94  for (unsigned int i=0;i!=n; ++i) {
95  labels.clear();
96  const vector<string>& modules(moduleLabels(i));
97  const unsigned int m(modules.size());
98  labels.reserve(m);
99  for (unsigned int j=0;j!=m; ++j) {
100  const string& label(modules[j]);
101  if (saveTags(label)) labels.push_back(label);
102  }
103  saveTagsModules_.push_back(labels);
104  }
105 
106  // Fill index maps for fast lookup
107  moduleIndex_.resize(n);
108  for (unsigned int i=0; i!=n; ++i) {
110  moduleIndex_[i].clear();
111  const unsigned int m(size(i));
112  for (unsigned int j=0; j!=m; ++j) {
114  }
115  }
116 
117  // Extract and fill HLTLevel1GTSeed information for each trigger path
118  hltL1GTSeeds_.resize(n);
119  for (unsigned int i=0; i!=n; ++i) {
120  hltL1GTSeeds_[i].clear();
121  const unsigned int m(size(i));
122  for (unsigned int j=0; j!=m; ++j) {
123  const string& label(moduleLabels_[i][j]);
124  if (moduleType(label) == "HLTLevel1GTSeed") {
125  const ParameterSet& pset(modulePSet(label));
126  if (pset!=ParameterSet()) {
127  const bool l1Tech(pset.getParameter<bool>("L1TechTriggerSeeding"));
128  const string l1Seed(pset.getParameter<string>("L1SeedsLogicalExpression"));
129  hltL1GTSeeds_[i].push_back(pair<bool,string>(l1Tech,l1Seed));
130  }
131  }
132  }
133  }
134 
135  // Extract and fill streams information
136  if (processPSet_->existsAs<ParameterSet>("streams",true)) {
137  const ParameterSet& streams(processPSet_->getParameterSet("streams"));
138  streamNames_=streams.getParameterNamesForType<vector<string> >();
139  sort(streamNames_.begin(),streamNames_.end());
140  const unsigned int n(streamNames_.size());
141  streamContents_.resize(n);
142  for (unsigned int i=0; i!=n; ++i) {
143  streamIndex_[streamNames_[i]]=i;
144  streamContents_[i]=streams.getParameter<vector<string> >(streamNames_[i]);
146  }
147 
148  }
149 
150  // Extract and fill datasets information
151  if (processPSet_->existsAs<ParameterSet>("datasets",true)) {
152  const ParameterSet& datasets(processPSet_->getParameterSet("datasets"));
153  datasetNames_=datasets.getParameterNamesForType<vector<string> >();
154  sort(datasetNames_.begin(),datasetNames_.end());
155  const unsigned int n(datasetNames_.size());
156  datasetContents_.resize(n);
157  for (unsigned int i=0; i!=n; ++i) {
158  datasetIndex_[datasetNames_[i]]=i;
159  datasetContents_[i]=datasets.getParameter< vector<string> >(datasetNames_[i]);
161  }
162  }
163 
164  // Extract and fill Prescale information
165 
166  // Check various possibilities to get the HLT prescale sets:
167  string prescaleName("");
168  const string preS("PrescaleService");
169  const string preT("PrescaleTable");
170  if (processPSet_->existsAs<ParameterSet>(preS,true)) {
171  prescaleName=preS;
172  } else if ( processPSet_->existsAs<ParameterSet>(preT,true)) {
173  prescaleName=preT;
174  }
175  if (prescaleName=="") {
177  } else {
178  const ParameterSet& iPS(processPSet_->getParameterSet(prescaleName));
179  string defaultLabel(iPS.getUntrackedParameter<string>("lvl1DefaultLabel",""));
180  vector<string> labels;
181  if (iPS.existsAs<vector<string> >("lvl1Labels",true)) {
182  labels = iPS.getParameter<vector<string> >("lvl1Labels");
183  }
184  unsigned int set(0);
185  const unsigned int n(labels.size());
186  for (unsigned int i=0; i!=n; ++i) {
187  if (labels[i]==defaultLabel) set=i;
188  }
189  map<string,vector<unsigned int> > table;
190  if (iPS.existsAs< vector<ParameterSet> >("prescaleTable",true)) {
191  const vector<ParameterSet>& vpTable(iPS.getParameterSetVector("prescaleTable"));
192  const unsigned int m (vpTable.size());
193  for (unsigned int i=0; i!=m; ++i) {
194  table[vpTable[i].getParameter<std::string>("pathName")] =
195  vpTable[i].getParameter<std::vector<unsigned int> >("prescales");
196  }
197  }
198  if (n>0) {
199  hltPrescaleTable_=HLTPrescaleTable(set,labels,table);
200  } else {
202  }
203 
204  }
205 
206  return;
207 }
208 
209 void HLTConfigData::dump(const std::string& what) const {
210  using namespace std;
211  using namespace edm;
212 
213  if (what=="ProcessPSet") {
214  cout << "HLTConfigData::dump: ProcessPSet = " << endl << *processPSet_ << endl;
215  } else if (what=="ProcessName") {
216  cout << "HLTConfigData::dump: ProcessName = " << processName_ << endl;
217 
218  } else if (what=="TableName") {
219  cout << "HLTConfigData::dump: TableName = " << tableName_ << endl;
220  } else if (what=="Triggers") {
221  const unsigned int n(size());
222  cout << "HLTConfigData::dump: Triggers: " << n << endl;
223  for (unsigned int i=0; i!=n; ++i) {
224  cout << " " << i << " " << triggerNames_[i] << endl;
225  }
226  } else if (what=="TriggerSeeds") {
227  const unsigned int n(size());
228  cout << "HLTConfigData::dump: TriggerSeeds: " << n << endl;
229  for (unsigned int i=0; i!=n; ++i) {
230  const unsigned int m(hltL1GTSeeds_[i].size());
231  cout << " " << i << " " << triggerNames_[i] << " " << m << endl;
232  for (unsigned int j=0; j!=m; ++j) {
233  cout << " " << j
234  << " " << hltL1GTSeeds_[i][j].first
235  << "/" << hltL1GTSeeds_[i][j].second << endl;
236  }
237  }
238  } else if (what=="Modules") {
239  const unsigned int n(size());
240  cout << "HLTConfigData::dump Triggers and Modules: " << n << endl;
241  for (unsigned int i=0; i!=n; ++i) {
242  const unsigned int m(size(i));
243  cout << i << " " << triggerNames_[i] << " " << m << endl;
244  cout << " - Modules: ";
245  unsigned int nHLTPrescalers(0);
246  unsigned int nHLTLevel1GTSeed(0);
247  for (unsigned int j=0; j!=m; ++j) {
248  const string& label(moduleLabels_[i][j]);
249  const string type(moduleType(label));
250  const string edmtype(moduleEDMType(label));
251  const bool tags(saveTags(label));
252  cout << " " << j << ":" << label << "/" << type << "/" << edmtype << "/" << tags;
253  if (type=="HLTPrescaler") nHLTPrescalers++;
254  if (type=="HLTLevel1GTSeed") nHLTLevel1GTSeed++;
255  }
256  cout << endl;
257  cout << " - Number of HLTPrescaler/HLTLevel1GTSeed modules: "
258  << nHLTPrescalers << "/" << nHLTLevel1GTSeed << endl;
259  }
260  } else if (what=="StreamNames") {
261  const unsigned int n(streamNames_.size());
262  cout << "HLTConfigData::dump: StreamNames: " << n << endl;
263  for (unsigned int i=0; i!=n; ++i) {
264  cout << " " << i << " " << streamNames_[i] << endl;
265  }
266  } else if (what=="Streams") {
267  const unsigned int n(streamNames_.size());
268  cout << "HLTConfigData::dump: Streams: " << n << endl;
269  for (unsigned int i=0; i!=n; ++i) {
270  const unsigned int m(streamContents_[i].size());
271  cout << " " << i << " " << streamNames_[i] << " " << m << endl;
272  for (unsigned int j=0; j!=m; ++j) {
273  cout << " " << j << " " << streamContents_[i][j] << endl;
274  }
275  }
276  } else if (what=="DatasetNames") {
277  const unsigned int n(datasetNames_.size());
278  cout << "HLTConfigData::dump: DatasetNames: " << n << endl;
279  for (unsigned int i=0; i!=n; ++i) {
280  cout << " " << i << " " << datasetNames_[i] << endl;
281  }
282  } else if (what=="Datasets") {
283  const unsigned int n(datasetNames_.size());
284  cout << "HLTConfigData::dump: Datasets: " << n << endl;
285  for (unsigned int i=0; i!=n; ++i) {
286  const unsigned int m(datasetContents_[i].size());
287  cout << " " << i << " " << datasetNames_[i] << " " << m << endl;
288  for (unsigned int j=0; j!=m; ++j) {
289  cout << " " << j << " " << datasetContents_[i][j] << endl;
290  }
291  }
292  } else if (what=="PrescaleTable") {
293  const unsigned int n (hltPrescaleTable_.size());
294  cout << "HLTConfigData::dump: PrescaleTable: # of sets : " << n << endl;
295  const vector<string>& labels(hltPrescaleTable_.labels());
296  for (unsigned int i=0; i!=n; ++i) {
297  cout << " " << i << "/'" << labels.at(i) << "'";
298  }
299  if (n>0) cout << endl;
300  const map<string,vector<unsigned int> >& table(hltPrescaleTable_.table());
301  cout << "HLTConfigData::dump: PrescaleTable: # of paths: " << table.size() << endl;
302  const map<string,vector<unsigned int> >::const_iterator tb(table.begin());
303  const map<string,vector<unsigned int> >::const_iterator te(table.end());
304  for (map<string,vector<unsigned int> >::const_iterator ti=tb; ti!=te; ++ti) {
305  for (unsigned int i=0; i!=n; ++i) {
306  cout << " " << ti->second.at(i);
307  }
308  cout << " " << ti->first << endl;
309  }
310  } else {
311  cout << "HLTConfigData::dump: Unkown dump request: " << what << endl;
312  }
313  return;
314 }
315 
316 const std::string& HLTConfigData::processName() const {
317  return processName_;
318 }
319 
320 unsigned int HLTConfigData::size() const {
321  return triggerNames_.size();
322 }
323 unsigned int HLTConfigData::size(unsigned int trigger) const {
324  return moduleLabels_.at(trigger).size();
325 }
326 unsigned int HLTConfigData::size(const std::string& trigger) const {
327  return size(triggerIndex(trigger));
328 }
329 
330 const std::string& HLTConfigData::tableName() const {
331  return tableName_;
332 }
333 const std::vector<std::string>& HLTConfigData::triggerNames() const {
334  return triggerNames_;
335 }
336 const std::string& HLTConfigData::triggerName(unsigned int trigger) const {
337  return triggerNames_.at(trigger);
338 }
339 unsigned int HLTConfigData::triggerIndex(const std::string& trigger) const {
340  const std::map<std::string,unsigned int>::const_iterator index(triggerIndex_.find(trigger));
341  if (index==triggerIndex_.end()) {
342  return size();
343  } else {
344  return index->second;
345  }
346 }
347 
348 const std::vector<std::string>& HLTConfigData::moduleLabels(unsigned int trigger) const {
349  return moduleLabels_.at(trigger);
350 }
351 const std::vector<std::string>& HLTConfigData::moduleLabels(const std::string& trigger) const {
352  return moduleLabels_.at(triggerIndex(trigger));
353 }
354 
355 const std::vector<std::string>& HLTConfigData::saveTagsModules(unsigned int trigger) const {
356  return saveTagsModules_.at(trigger);
357 }
358 const std::vector<std::string>& HLTConfigData::saveTagsModules(const std::string& trigger) const {
359  return saveTagsModules_.at(triggerIndex(trigger));
360 }
361 
362 const std::string& HLTConfigData::moduleLabel(unsigned int trigger, unsigned int module) const {
363  return moduleLabels_.at(trigger).at(module);
364 }
365 const std::string& HLTConfigData::moduleLabel(const std::string& trigger, unsigned int module) const {
366  return moduleLabels_.at(triggerIndex(trigger)).at(module);
367 }
368 
369 unsigned int HLTConfigData::moduleIndex(unsigned int trigger, const std::string& module) const {
370  const std::map<std::string,unsigned int>::const_iterator index(moduleIndex_.at(trigger).find(module));
371  if (index==moduleIndex_.at(trigger).end()) {
372  return size(trigger);
373  } else {
374  return index->second;
375  }
376 }
377 unsigned int HLTConfigData::moduleIndex(const std::string& trigger, const std::string& module) const {
378  return moduleIndex(triggerIndex(trigger),module);
379 }
380 
381 const std::string HLTConfigData::moduleType(const std::string& module) const {
382  const edm::ParameterSet& pset(modulePSet(module));
383  if (pset.existsAs<std::string>("@module_type",true)) {
384  return pset.getParameter<std::string>("@module_type");
385  } else {
386  return "";
387  }
388 }
389 
390 const std::string HLTConfigData::moduleEDMType(const std::string& module) const {
391  const edm::ParameterSet& pset(modulePSet(module));
392  if (pset.existsAs<std::string>("@module_edm_type",true)) {
393  return pset.getParameter<std::string>("@module_edm_type");
394  } else {
395  return "";
396  }
397 }
398 
400  return *processPSet_;
401 }
402 
403 const edm::ParameterSet& HLTConfigData::modulePSet(const std::string& module) const {
404  if (processPSet_->exists(module)) {
405  return processPSet_->getParameterSet(module);
406  } else {
407  return *s_dummyPSet();
408  }
409 }
410 
411 const bool HLTConfigData::saveTags(const std::string& module) const {
412  const edm::ParameterSet& pset(modulePSet(module));
413  if (pset.existsAs<bool>("saveTags",true)) {
414  return pset.getParameter<bool>("saveTags");
415  } else {
416  return false;
417  }
418 }
419 
420 const std::vector<std::vector<std::pair<bool,std::string> > >& HLTConfigData::hltL1GTSeeds() const {
421  return hltL1GTSeeds_;
422 }
423 
424 const std::vector<std::pair<bool,std::string> >& HLTConfigData::hltL1GTSeeds(const std::string& trigger) const {
425  return hltL1GTSeeds(triggerIndex(trigger));
426 }
427 
428 const std::vector<std::pair<bool,std::string> >& HLTConfigData::hltL1GTSeeds(unsigned int trigger) const {
429  return hltL1GTSeeds_.at(trigger);
430 }
431 
433 const std::vector<std::string>& HLTConfigData::streamNames() const {
434  return streamNames_;
435 }
436 
437 const std::string& HLTConfigData::streamName(unsigned int stream) const {
438  return streamNames_.at(stream);
439 }
440 
441 unsigned int HLTConfigData::streamIndex(const std::string& stream) const {
442  const std::map<std::string,unsigned int>::const_iterator index(streamIndex_.find(stream));
443  if (index==streamIndex_.end()) {
444  return streamNames_.size();
445  } else {
446  return index->second;
447  }
448 }
449 
450 const std::vector<std::vector<std::string> >& HLTConfigData::streamContents() const {
451  return streamContents_;
452 }
453 
454 const std::vector<std::string>& HLTConfigData::streamContent(unsigned int stream) const {
455  return streamContents_.at(stream);
456 }
457 
458 const std::vector<std::string>& HLTConfigData::streamContent(const std::string& stream) const {
459  return streamContent(streamIndex(stream));
460 }
461 
463 const std::vector<std::string>& HLTConfigData::datasetNames() const {
464  return datasetNames_;
465 }
466 
467 const std::string& HLTConfigData::datasetName(unsigned int dataset) const {
468  return datasetNames_.at(dataset);
469 }
470 
471 unsigned int HLTConfigData::datasetIndex(const std::string& dataset) const {
472  const std::map<std::string,unsigned int>::const_iterator index(datasetIndex_.find(dataset));
473  if (index==datasetIndex_.end()) {
474  return datasetNames_.size();
475  } else {
476  return index->second;
477  }
478 }
479 
480 const std::vector<std::vector<std::string> >& HLTConfigData::datasetContents() const {
481  return datasetContents_;
482 }
483 
484 const std::vector<std::string>& HLTConfigData::datasetContent(unsigned int dataset) const {
485  return datasetContents_.at(dataset);
486 }
487 
488 const std::vector<std::string>& HLTConfigData::datasetContent(const std::string& dataset) const {
489  return datasetContent(datasetIndex(dataset));
490 }
491 
492 
493 unsigned int HLTConfigData::prescaleSize() const {
494  return hltPrescaleTable_.size();
495 }
496 unsigned int HLTConfigData::prescaleValue(unsigned int set, const std::string& trigger) const {
497  return hltPrescaleTable_.prescale(set,trigger);
498 }
499 
500 const std::vector<std::string>& HLTConfigData::prescaleLabels() const {
501  return hltPrescaleTable_.labels();
502 }
503 const std::map<std::string,std::vector<unsigned int> >& HLTConfigData::prescaleTable() const {
504  return hltPrescaleTable_.table();
505 }
506 
508  return processPSet_->id();
509 }
list table
Definition: asciidump.py:386
type
Definition: HCALResponse.h:22
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:181
const std::string & datasetName(unsigned int dataset) const
name of dataset with index i
const std::string & label
Definition: MVAComputer.cc:186
std::vector< std::vector< std::pair< bool, std::string > > > hltL1GTSeeds_
std::vector< std::map< std::string, unsigned int > > moduleIndex_
const std::string & streamName(unsigned int stream) const
name of stream with index i
ParameterSetID id() const
std::map< std::string, unsigned int > datasetIndex_
The single EDProduct containing the HLT Prescale Table.
const std::vector< std::string > & triggerNames() const
names of trigger paths
const std::vector< std::vector< std::pair< bool, std::string > > > & hltL1GTSeeds() const
bool exists(std::string const &parameterName) const
checks if a parameter exists
const edm::ParameterSet & modulePSet(const std::string &module) const
ParameterSet of module.
std::vector< std::string > datasetNames_
unsigned int size() const
number of trigger paths in trigger table
unsigned int prescaleValue(unsigned int set, const std::string &trigger) const
HLT prescale value in specific prescale set for a specific trigger path.
const std::vector< std::string > & datasetNames() const
Datasets.
const std::map< std::string, std::vector< unsigned int > > & table() const
std::vector< std::vector< std::string > > saveTagsModules_
const std::vector< std::string > & streamNames() const
Streams.
const bool saveTags(const std::string &module) const
Is module an L3 filter (ie, tracked saveTags=true)
const std::vector< std::string > & datasetContent(unsigned int dataset) const
names of trigger paths in dataset with index i
std::vector< std::vector< std::string > > streamContents_
std::vector< std::string > triggerNames_
const std::vector< std::string > & labels() const
std::vector< std::vector< std::string > > datasetContents_
const std::vector< std::string > & saveTagsModules(unsigned int trigger) const
const std::vector< std::vector< std::string > > & datasetContents() const
names of trigger paths for all datasets
std::map< std::string, unsigned int > triggerIndex_
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
std::string tableName_
trigger::HLTPrescaleTable hltPrescaleTable_
std::vector< std::vector< std::string > > moduleLabels_
int j
Definition: DBlmapReader.cc:9
const std::string moduleType(const std::string &module) const
C++ class name of module.
#define end
Definition: vmac.h:38
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 - size-1)
void extract()
extract information into data members - called by init() methods
unsigned int moduleIndex(unsigned int trigger, const std::string &module) const
slot position of module on trigger path (0 - size-1)
const std::string & processName() const
Accessors (const methods)
unsigned int prescale(const std::string &trigger) const
high-level user access method: prescale for given trigger path
tuple tags
Definition: o2o.py:248
unsigned int streamIndex(const std::string &stream) const
index of stream with name
const std::string & tableName() const
HLT ConfDB table name.
tuple labels
Definition: L1TDQM_cfg.py:62
const std::map< std::string, std::vector< unsigned int > > & prescaleTable() const
const edm::ParameterSet * processPSet_
const edm::ParameterSet & processPSet() const
ParameterSet of process.
ParameterSet const & getParameterSet(std::string const &) const
unsigned int prescaleSize() const
const std::string moduleEDMType(const std::string &module) const
C++ base class name of module.
#define begin
Definition: vmac.h:31
bool isValid() const
Definition: Hash.h:136
unsigned int datasetIndex(const std::string &dataset) const
index of dataset with name
const std::vector< std::string > & prescaleLabels() const
low-level data member access
std::vector< std::string > streamNames_
const std::vector< std::vector< std::string > > & streamContents() const
names of datasets for all streams
const std::string & moduleLabel(unsigned int trigger, unsigned int module) const
tuple cout
Definition: gather_cfg.py:41
std::map< std::string, unsigned int > streamIndex_
unsigned int size() const
consistency condition: all vectors must have the same length
const std::string & triggerName(unsigned int triggerIndex) const
const std::vector< std::string > & streamContent(unsigned int stream) const
names of datasets in stream with index i
edm::ParameterSetID id() const
technical: id() function needed for use with ThreadSafeRegistry
ParameterSet const & registerIt()
Definition: vlib.h:209
static const edm::ParameterSet * s_dummyPSet()
std::string processName_
void dump(const std::string &what) const
Dumping config info to cout.