CMS 3D CMS Logo

HLTSeedL1LogicScalers.cc
Go to the documentation of this file.
1 
2 
4 
6 
12 
13 using namespace edm;
14 using namespace std;
15 using namespace trigger;
16 
18  : fL1GtDaqReadoutRecordInputTag(iConfig.getParameter<edm::InputTag>("L1GtDaqReadoutRecordInputTag")),
19  fL1GtRecordInputTag(iConfig.getParameter<edm::InputTag>("L1GtRecordInputTag")),
20  m_l1GtUtils(iConfig,
21  consumesCollector(),
22  false,
23  *this,
24  fL1GtRecordInputTag,
25  fL1GtDaqReadoutRecordInputTag,
26  edm::InputTag()) {
27  // now do what ever initialization is needed
28  LogDebug("HLTSeedL1LogicScalers") << "constructor";
29 
30  // get untracked parameters
32  fL1BeforeMask = iConfig.getParameter<bool>("l1BeforeMask");
33  fProcessname = iConfig.getParameter<std::string>("processname");
34 
35  // get untracked parameters
36  fDQMFolder = iConfig.getUntrackedParameter("DQMFolder", string("HLT/HLTSeedL1LogicScalers/HLT_LogicL1"));
37  fMonitorPaths = iConfig.getUntrackedParameter<std::vector<std::string> >("monitorPaths");
38 }
39 
41 
43  // HLT config does not change within runs!
44  bool changed = false;
45  if (!fHLTConfig.init(run, iSetup, fProcessname, changed)) {
46  LogDebug("HLTSeedL1LogicScalers") << "HLTConfigProvider failed to initialize.";
47  return;
48  }
49 
50  const unsigned int n(fHLTConfig.size());
51  for (unsigned int j = 0; j != n; ++j) {
52  LogTrace("HLTSeedL1LogicScalers") << "HLTConfig path " << fHLTConfig.triggerName(j) << endl;
53  }
54 }
55 
57  // book histos for L1 logic of specificified HLT paths
58  LogTrace("HLTSeedL1LogicScalers") << "size of vector of paths to monitor = " << fMonitorPaths.size() << endl;
59  for (unsigned int iPath = 0; iPath < fMonitorPaths.size(); iPath++) {
60  string monPath = fMonitorPaths[iPath];
61  LogTrace("HLTSeedL1LogicScalers") << "monPath = " << monPath << endl;
62 
63  string folderName = fDQMFolder + "/" + monPath;
64  iBooker.setCurrentFolder(folderName);
65 
66  // do nothing if monPath is not in the HLT menu
67  if (fHLTConfig.triggerIndex(monPath) == fHLTConfig.size())
68  continue;
69  // get L1SeedLogicalExpression of this path
70  vector<pair<bool, string> > hltL1GTSeed = fHLTConfig.hltL1GTSeeds(monPath);
71  LogTrace("HLTSeedL1LogicScalers") << endl
72  << "size of vector of GTSeedL1LogicalExpression = " << hltL1GTSeed.size() << endl;
73 
74  // each GT Seed of each path contains l1Algos
75  for (unsigned int iSeed = 0; iSeed < hltL1GTSeed.size(); iSeed++) {
76  LogTrace("HLTSeedL1LogicScalers") << " TechBit_flag = " << hltL1GTSeed[iSeed].first
77  << " GTSeedL1LogicalExpression = " << hltL1GTSeed[iSeed].second << endl;
78 
79  istringstream totalSString(hltL1GTSeed[iSeed].second);
80  string temp_string;
81 
82  vector<string> l1Algos;
83 
84  // only if not TechBit flag
85  while (!hltL1GTSeed[iSeed].first) {
86  totalSString >> temp_string;
87 
88  if (!l1Algos.empty()) {
89  if (temp_string == l1Algos.back())
90  break;
91  }
92  if (temp_string != "OR" && temp_string != "AND" && temp_string != "NOT" && temp_string != "(" &&
93  temp_string != ")" && !temp_string.empty()) {
94  l1Algos.push_back(temp_string);
95  }
96  }
97 
98  int nL1Algo = l1Algos.size();
99 
100  // put an upper limit on the size of l1Algos
101  if (nL1Algo > 32) {
102  LogWarning("HLTSeedL1LogicScalers") << " number of l1 Algos grater than 32. Using only the first 32." << endl;
103  l1Algos.resize(32);
104  }
105  int nBins = 1 << nL1Algo;
106 
107  for (unsigned int k = 0; k < l1Algos.size(); k++) {
108  LogTrace("HLTSeedL1LogicScalers") << " l1 Algo = " << l1Algos[k] << endl;
109  } // end for k
110 
111  std::stringstream title;
112  std::stringstream name;
113 
114  name << monPath << "_Seed_" << iSeed << "_L1BitLogic";
115  title << monPath << " BitPacked L1Algos of GTSeed " << iSeed << ": '" << hltL1GTSeed[iSeed].second << "'";
116 
117  LogTrace("HLTSeedL1LogicScalers") << " MonitorElement name = " << name.str() << endl;
118  LogTrace("HLTSeedL1LogicScalers") << " MonitorElement title = " << title.str() << endl;
119  LogTrace("HLTSeedL1LogicScalers") << " MonitorElement nBins = " << nBins << endl << endl;
120 
121  MonitorElement* me = iBooker.book1D(name.str().c_str(), title.str().c_str(), nBins, 0, nBins);
122  me->setAxisTitle("bit-packed word L1 Algorithms");
123  fMonitorPathsME.push_back(me);
124 
125  fMapMEL1Algos.push_back(make_pair(me, l1Algos));
126  } // end for Seeds
127  } // end for monitoring paths
128 }
129 
131  LogDebug("HLTSeedL1LogicScalers") << "HLTSeedL1LogicScalers::analyze event ";
132 
133  // before accessing any result from L1GtUtils, one must retrieve and cache
134  // the L1 trigger event setup
135  // add this call in the analyze / produce / filter method of your
136  // analyzer / producer / filter
137 
139 
140  // loop over maps of ME-L1Algos
141  for (unsigned int i = 0; i < fMapMEL1Algos.size(); i++) {
142  MonitorElement* me = fMapMEL1Algos[i].first;
143  LogTrace("HLTSeedL1LogicScalers") << "ME = " << me->getName() << endl;
144 
145  const vector<string>& l1Algos = fMapMEL1Algos[i].second;
146 
147  // word to bit-pack decisions of l1Algos
148  unsigned int myL1Word = 0;
149 
150  // loop over l1Algos
151  for (unsigned int j = 0; j < l1Algos.size(); j++) {
152  // check if this l1Algo passed
153  bool l1Pass = analyzeL1GtUtils(iEvent, iSetup, l1Algos[j]);
154  LogTrace("HLTSeedL1LogicScalers") << "l1Algo = " << l1Algos[j] << " l1Pass = " << l1Pass << endl;
155  if (l1Pass) {
156  // bit-wise pack
157  myL1Word |= (1 << j);
158  }
159  }
160  me->Fill(myL1Word);
161  } // end for i maps
162 }
163 
165  const edm::EventSetup& evSetup,
166  const string& l1AlgoName) {
167  LogTrace("HLTSeedL1LogicScalers") << "analyzeL1GtUtils..." << endl;
168 
169  // access L1 trigger results using public methods from L1GtUtils
170  // always check on error code returned by that method
171 
172  int iErrorCode = -1;
173 
174  LogTrace("HLTSeedL1LogicScalers") << "l1AlgoName = " << l1AlgoName << endl;
175 
176  bool decisionAlgTechTrig = false;
177 
178  // check flag L1BeforeMask
179  if (fL1BeforeMask) {
180  decisionAlgTechTrig = m_l1GtUtils.decisionBeforeMask(iEvent, l1AlgoName, iErrorCode);
181  } else {
182  decisionAlgTechTrig = m_l1GtUtils.decisionAfterMask(iEvent, l1AlgoName, iErrorCode);
183  }
184 
185  LogTrace("HLTSeedL1LogicScalers") << "bool L1BeforeMask = " << fL1BeforeMask
186  << " decisionAlgTechTrig = " << decisionAlgTechTrig << endl;
187 
188  if (iErrorCode == 0) {
189  return decisionAlgTechTrig;
190  } else if (iErrorCode == 1) {
191  // algorithm / technical trigger does not exist in the L1 menu
192  LogWarning("HLTSeedL1LogicScalers") << "L1 algorithm " << l1AlgoName
193  << " not in L1 menu, but HLTConfigProvider found it in "
194  "L1SeedsLogicalExpression of at least one HLT path of the HLT menu."
195  << endl;
196  return false;
197  } else {
198  // error - see error code
199  // do whatever needed
200  return false;
201  }
202  return false;
203 }
#define LogDebug(id)
unsigned int size() const
number of trigger paths in trigger table
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX)
Definition: DQMStore.cc:239
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const std::string & triggerName(unsigned int triggerIndex) const
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:418
bool analyzeL1GtUtils(const edm::Event &, const edm::EventSetup &, const std::string &)
const std::string & getName() const
get name of ME
HLTSeedL1LogicScalers(const edm::ParameterSet &)
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
void Fill(long long x)
U second(std::pair< T, U > const &p)
int iEvent
Definition: GenABIO.cc:224
void retrieveL1EventSetup(const edm::EventSetup &)
retrieve all the relevant L1 trigger event setup records and cache them to improve the speed ...
Definition: L1GtUtils.cc:112
#define LogTrace(id)
HLTConfigProvider fHLTConfig
const std::vector< std::vector< std::pair< bool, std::string > > > & hltL1GTSeeds() const
std::vector< std::string > fMonitorPaths
const bool decisionBeforeMask(const edm::Event &iEvent, const std::string &nameAlgoTechTrig, int &errorCode) const
return decision before trigger mask for a given algorithm or technical trigger
Definition: L1GtUtils.cc:996
std::vector< MonitorElement * > fMonitorPathsME
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
std::vector< std::pair< MonitorElement *, std::vector< std::string > > > fMapMEL1Algos
HLT enums.
void dqmBeginRun(const edm::Run &run, const edm::EventSetup &c) override
const bool decisionAfterMask(const edm::Event &iEvent, const std::string &nameAlgoTechTrig, int &errorCode) const
return decision after trigger mask for a given algorithm or technical trigger
Definition: L1GtUtils.cc:1010
Definition: Run.h:45
void analyze(const edm::Event &, const edm::EventSetup &) override
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)