CMS 3D CMS Logo

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