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