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