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 
14 
15 using namespace edm;
16 using namespace std;
17 using namespace trigger;
18 
19 //
20 // constants, enums and typedefs
21 //
22 
23 //
24 // static data member definitions
25 //
26 
27 //
28 // constructors and destructor
29 //
31 
32 {
33  //now do what ever initialization is needed
34  LogDebug("HLTSeedL1LogicScalers") << "constructor" ;
35 
36  // get untracked parameters
38  fL1BeforeMask = iConfig.getParameter<bool>("l1BeforeMask");
39  fProcessname = iConfig.getParameter<std::string>("processname");
40 
41  // input tag for GT DAQ product
42  fL1GtDaqReadoutRecordInputTag = iConfig.getParameter<edm::InputTag>("L1GtDaqReadoutRecordInputTag");
43 
44  // input tag for GT lite product
45  fL1GtRecordInputTag = iConfig.getParameter<edm::InputTag>("L1GtRecordInputTag");
46 
47  // get untracked parameters
49  fDQMFolder = iConfig.getUntrackedParameter("DQMFolder", string("HLT/HLTSeedL1LogicScalers/HLT_LogicL1"));
50  fMonitorPaths = iConfig.getUntrackedParameter<std::vector<std::string > >("monitorPaths");
51 
52  fDbe = Service < DQMStore > ().operator->();
53 
54  if ( ! fDbe ) {
55  LogInfo("HLTSeedL1LogicScalers") << "unable to get DQMStore service?";
56  }
57  else {
58  fDbe->setCurrentFolder(fDQMFolder);
59  }
60 
61 }
62 
63 
65 {
66 }
67 
68 void
70 {
71 
72  LogDebug("HLTSeedL1LogicScalers") << "HLTSeedL1LogicScalers::analyze event " ;
73 
74  // before accessing any result from L1GtUtils, one must retrieve and cache
75  // the L1 trigger event setup
76  // add this call in the analyze / produce / filter method of your
77  // analyzer / producer / filter
78 
79  m_l1GtUtils.retrieveL1EventSetup(iSetup);
80 
81  // loop over maps of ME-L1Algos
82  for (unsigned int i=0;i<fMapMEL1Algos.size();i++) {
83 
84  MonitorElement* me = fMapMEL1Algos[i].first;
85  LogTrace("HLTSeedL1LogicScalers") << "ME = " << me->getName() << endl;
86 
87  const vector<string>& l1Algos = fMapMEL1Algos[i].second;
88 
89  // word to bit-pack decisions of l1Algos
90  unsigned int myL1Word = 0;
91 
92  // loop over l1Algos
93  for (unsigned int j=0;j<l1Algos.size();j++) {
94 
95  // check if this l1Algo passed
96  bool l1Pass = analyzeL1GtUtils(iEvent, iSetup, l1Algos[j]);
97  LogTrace("HLTSeedL1LogicScalers") << "l1Algo = " << l1Algos[j] << " l1Pass = " << l1Pass << endl;
98  if(l1Pass) {
99 
100  // bit-wise pack
101  myL1Word |= (1<<j);
102 
103  }
104 /*
105 */
106 
107  }
108 
109  me->Fill(myL1Word);
110 
111  } // end for i maps
112 
113 }
114 
115 
116 
117 void
119 {
120 
121  // Get configuration of HLT menu used in this run
122  LogTrace("HLTSeedL1LogicScalers") << "beginRun, run " << run.id();
123  fDbe->setCurrentFolder(fDQMFolder);
124 
125  // HLT config does not change within runs!
126 
127  bool changed = false;
128 
129  if (!fHLTConfig.init(run, iSetup, fProcessname, changed)) {
130 
131  LogDebug("HLTSeedL1LogicScalers") << "HLTConfigProvider failed to initialize.";
132  return;
133 
134  // check if trigger name in (new) config
135  // cout << "Available TriggerNames are: " << endl;
136  // fHLTConfig.dump("Triggers");
137 
138  }
139 
140  const unsigned int n(fHLTConfig.size());
141 
142  for (unsigned int j=0; j!=n; ++j) {
143 
144  LogTrace("HLTSeedL1LogicScalers") << "HLTConfig path " << fHLTConfig.triggerName(j) << endl;
145 
146  }
147 
148  // book histos for L1 logic of specificified HLT paths
149  LogTrace("HLTSeedL1LogicScalers") << "size of vector of paths to monitor = " << fMonitorPaths.size() << endl;
150  for (unsigned int iPath=0;iPath<fMonitorPaths.size();iPath++) {
151 
152  string monPath = fMonitorPaths[iPath];
153  LogTrace("HLTSeedL1LogicScalers") << "monPath = " << monPath << endl;
154 
155  string folderName = fDQMFolder + "/" + monPath;
156  fDbe->setCurrentFolder(folderName);
157 
158  // do nothing if monPath is not in the HLT menu
159  if(fHLTConfig.triggerIndex(monPath) == fHLTConfig.size()) continue;
160  // get L1SeedLogicalExpression of this path
161  vector<pair<bool,string> > hltL1GTSeed = fHLTConfig.hltL1GTSeeds(monPath);
162  LogTrace("HLTSeedL1LogicScalers") << endl << "size of vector of GTSeedL1LogicalExpression = " << hltL1GTSeed.size() << endl;
163 
164  // each GT Seed of each path contains l1Algos
165  for (unsigned int iSeed=0;iSeed<hltL1GTSeed.size();iSeed++) {
166 
167  LogTrace("HLTSeedL1LogicScalers") << " TechBit_flag = " << hltL1GTSeed[iSeed].first << " GTSeedL1LogicalExpression = " << hltL1GTSeed[iSeed].second << endl;;
168 
169  istringstream totalSString( hltL1GTSeed[iSeed].second );
170  string temp_string;
171 
172  vector<string> l1Algos;
173 
174  // only if not TechBit flag
175  while(! hltL1GTSeed[iSeed].first) {
176 
177  totalSString >> temp_string;
178 
179  if(! l1Algos.empty()) {
180 
181  if(temp_string.compare(l1Algos.back()) == 0) break;
182 
183  }
184  if(temp_string != "OR" && temp_string != "AND" && temp_string != "NOT" && temp_string != "(" && temp_string != ")" && temp_string != ""){
185 
186  l1Algos.push_back(temp_string);
187 
188  }
189  }
190 
191  int nL1Algo = l1Algos.size();
192 
193  // put an upper limit on the size of l1Algos
194  if(nL1Algo > 32) {
195 
196  LogWarning("HLTSeedL1LogicScalers") << " number of l1 Algos grater than 32. Using only the first 32." << endl ;
197  l1Algos.resize(32);
198 
199  }
200  int nBins = 1 << nL1Algo;
201 
202  for (unsigned int k=0;k< l1Algos.size();k++) {
203 
204  LogTrace("HLTSeedL1LogicScalers") << " l1 Algo = " << l1Algos[k] << endl;
205 
206 
207  } // end for k
208 
209  //char title[100];
210  //char name[100];
211 
212  std::stringstream title;
213  std::stringstream name;
214 
215  name << monPath << "_Seed_" << iSeed << "_L1BitLogic";
216  title << monPath << " BitPacked L1Algos of GTSeed " << iSeed << ": '" << hltL1GTSeed[iSeed].second << "'";
217 
218  //sprintf(name,"%s_Seed_%d_L1BitLogic",monPath.c_str(),iSeed);
219  //sprintf(title,"%s BitPacked L1Algos of GTSeed %d: '%s'",monPath.c_str(), iSeed, hltL1GTSeed[iSeed].second.c_str());
220 
221  LogTrace("HLTSeedL1LogicScalers") << " MonitorElement name = " << name << endl;
222  LogTrace("HLTSeedL1LogicScalers") << " MonitorElement title = " << title << endl;
223  LogTrace("HLTSeedL1LogicScalers") << " MonitorElement nBins = " << nBins << endl << endl;
224 
225  MonitorElement* me = fDbe->book1D(name.str().c_str(), title.str().c_str(), nBins,0,nBins);
226  me->setAxisTitle("bit-packed word L1 Algorithms");
227  fMonitorPathsME.push_back(me);
228 
229  // pair of 1D hisotgram and vector of l1Algos
230  //pair<MonitorElement*, vector<string> > pairMEL1Algo;
231  //pairMEL1Algo.first = me;
232  //pairMEL1Algo.second = l1Algos;
233  //fMapMEL1Algos.push_back(pairMEL1Algo);
234  fMapMEL1Algos.push_back(make_pair(me, l1Algos));
235 
236  } // end for Seeds
237 
238 
239 
240  } // end for monitoring paths
241 
242 }
243 
244 void
246 {
247 }
248 
249 // ------------ method called once each job just after ending the event loop ------------
250 void
252 }
253 
254 bool HLTSeedL1LogicScalers::analyzeL1GtUtils(const edm::Event& iEvent, const edm::EventSetup& evSetup, const string & l1AlgoName)
255 {
256 
257  LogTrace("HLTSeedL1LogicScalers") << "analyzeL1GtUtils..." << endl;
258 
259  // access L1 trigger results using public methods from L1GtUtils
260  // always check on error code returned by that method
261 
262  int iErrorCode = -1;
263 
264 
265  LogTrace("HLTSeedL1LogicScalers") << "l1AlgoName = " << l1AlgoName << endl;
266 
267  bool decisionAlgTechTrig = false;
268 
269  // check flag L1BeforeMask
270  if (fL1BeforeMask) {
271 
272  decisionAlgTechTrig = m_l1GtUtils.decisionBeforeMask(iEvent, fL1GtRecordInputTag, fL1GtDaqReadoutRecordInputTag, l1AlgoName, iErrorCode);
273 
274  }
275  else {
276 
277  decisionAlgTechTrig = m_l1GtUtils.decisionAfterMask(iEvent, fL1GtRecordInputTag, fL1GtDaqReadoutRecordInputTag, l1AlgoName, iErrorCode);
278 
279  }
280 
281  LogTrace("HLTSeedL1LogicScalers") << "bool L1BeforeMask = " << fL1BeforeMask << " decisionAlgTechTrig = " << decisionAlgTechTrig << endl;
282 
283  if (iErrorCode == 0) {
284 
285  return decisionAlgTechTrig;
286 
287  } else if (iErrorCode == 1) {
288 
289  // algorithm / technical trigger does not exist in the L1 menu
290  LogWarning("HLTSeedL1LogicScalers") << "L1 algorithm " << l1AlgoName << " not in L1 menu, but HLTConfigProvider found it in L1SeedsLogicalExpression of at least one HLT path of the HLT menu." << endl;
291  return false;
292 
293  } else {
294 
295  // error - see error code
296  // do whatever needed
297  return false;
298 
299  }
300 
301  return false;
302 
303 }
304 
305 bool HLTSeedL1LogicScalers::analyzeL1GtRecord(const edm::Event& iEvent, const edm::EventSetup& evSetup, string l1AlgoName)
306 {
307  LogTrace("HLTSeedL1LogicScalers") << "analyzeL1GtRecord.. " << endl;
308 /*
309  edm::Handle<L1GtTriggerMenu> menuRcd;
310  evSetup.get<L1GtTriggerMenuRcd>().get(menuRcd) ;
311  const L1GtTriggerMenu* menu = menuRcd.product();
312 
313  edm::Handle< L1GlobalTriggerReadoutRecord > gtReadoutRecord;
314  iEvent.getByLabel( edm::InputTag("gtDigis"), gtReadoutRecord);
315  const DecisionWord& gtDecisionWordBeforeMask = = gtReadoutRecord->decisionWord();
316 
317  // test if the algorithm name is in the menu
318 
319  const AlgorithmMap& algorithmMap = menu->gtAlgorithmMap();
320  CItAlgo itAlgo = algorithmMap.find(l1AlgoName);
321  if (itAlgo != algorithmAliasMap.end()) {
322  bool l1Result = menu->gtAlgorithmResult( l1AlgoName, gtDecisionWordBeforeMask);
323  return l1Result;
324  } else {
325  // algorithm not in the L1 menu - do whatever needed
326  return false;
327  }
328 */
329  return false;
330 
331 }
#define LogDebug(id)
bool analyzeL1GtRecord(const edm::Event &, const edm::EventSetup &, std::string)
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
RunID const & id() const
Definition: RunBase.h:41
virtual void beginRun(const edm::Run &run, const edm::EventSetup &c)
bool analyzeL1GtUtils(const edm::Event &, const edm::EventSetup &, const std::string &)
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:243
int j
Definition: DBlmapReader.cc:9
#define LogTrace(id)
int k[5][pyjets_maxn]
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