CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTInfo.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <sstream>
3 #include <istream>
4 #include <fstream>
5 #include <iomanip>
6 #include <string>
7 #include <cmath>
8 #include <functional>
9 #include <stdlib.h>
10 #include <string.h>
11 
14 
15 // L1 related
22 
23 static const bool useL1EventSetup(true);
24 static const bool useL1GtTriggerMenuLite(false);
25 
27 
28  //set parameter defaults
29  _Debug=false;
30  _OR_BXes=false;
32 }
33 
35 
36 
37  bool changed(true);
38  if (hltConfig_.init(run,c,processName_,changed)) {
39  // if init returns TRUE, initialisation has succeeded!
40  if (changed) {
41  // The HLT config has actually changed wrt the previous Run, hence rebook your
42  // histograms or do anything else dependent on the revised HLT config
43  std::cout << "Initalizing HLTConfigProvider" << std::endl;
44  }
45  } else {
46  // if init returns FALSE, initialisation has NOT succeeded, which indicates a problem
47  // with the file and/or code and needs to be investigated!
48  std::cout << " HLT config extraction failure with process name " << processName_ << std::endl;
49  // In this case, all access methods will return empty values!
50  }
51 
52 }
53 
54 /* Setup the analysis to put the branch-variables into the tree. */
55 void HLTInfo::setup(const edm::ParameterSet& pSet, TTree* HltTree) {
56 
57  processName_ = pSet.getParameter<std::string>("HLTProcessName") ;
58 
59  edm::ParameterSet myHltParams = pSet.getParameter<edm::ParameterSet>("RunParameters") ;
60  std::vector<std::string> parameterNames = myHltParams.getParameterNames() ;
61 
62  for ( std::vector<std::string>::iterator iParam = parameterNames.begin();
63  iParam != parameterNames.end(); iParam++ ){
64  if ( (*iParam) == "Debug" ) _Debug = myHltParams.getParameter<bool>( *iParam );
65  }
66 
67  dummyBranches_ = pSet.getUntrackedParameter<std::vector<std::string> >("dummyBranches",std::vector<std::string>(0));
68 
69  HltEvtCnt = 0;
70  const int kMaxTrigFlag = 10000;
71  trigflag = new int[kMaxTrigFlag];
72  trigPrescl = new int[kMaxTrigFlag];
73  L1EvtCnt = 0;
74  const int kMaxL1Flag = 10000;
75  l1flag = new int[kMaxL1Flag];
76  l1flag5Bx = new int[kMaxTrigFlag];
77  l1Prescl = new int[kMaxL1Flag];
78  l1techflag = new int[kMaxL1Flag];
79  l1techflag5Bx = new int[kMaxTrigFlag];
80  l1techPrescl = new int[kMaxTrigFlag];
81  const int kMaxHLTPart = 10000;
82  hltppt = new float[kMaxHLTPart];
83  hltpeta = new float[kMaxHLTPart];
84  const int kMaxL1ExtEmI = 10000;
85  l1extiemet = new float[kMaxL1ExtEmI];
86  l1extieme = new float[kMaxL1ExtEmI];
87  l1extiemeta = new float[kMaxL1ExtEmI];
88  l1extiemphi = new float[kMaxL1ExtEmI];
89  const int kMaxL1ExtEmN = 10000;
90  l1extnemet = new float[kMaxL1ExtEmN];
91  l1extneme = new float[kMaxL1ExtEmN];
92  l1extnemeta = new float[kMaxL1ExtEmN];
93  l1extnemphi = new float[kMaxL1ExtEmN];
94  const int kMaxL1ExtMu = 10000;
95  l1extmupt = new float[kMaxL1ExtMu];
96  l1extmue = new float[kMaxL1ExtMu];
97  l1extmueta = new float[kMaxL1ExtMu];
98  l1extmuphi = new float[kMaxL1ExtMu];
99  l1extmuiso = new int[kMaxL1ExtMu];
100  l1extmumip = new int[kMaxL1ExtMu];
101  l1extmufor = new int[kMaxL1ExtMu];
102  l1extmurpc = new int[kMaxL1ExtMu];
103  l1extmuqul = new int[kMaxL1ExtMu];
104  l1extmuchg = new int[kMaxL1ExtMu];
105  const int kMaxL1ExtJtC = 10000;
106  l1extjtcet = new float[kMaxL1ExtJtC];
107  l1extjtce = new float[kMaxL1ExtJtC];
108  l1extjtceta = new float[kMaxL1ExtJtC];
109  l1extjtcphi = new float[kMaxL1ExtJtC];
110  const int kMaxL1ExtJtF = 10000;
111  l1extjtfet = new float[kMaxL1ExtJtF];
112  l1extjtfe = new float[kMaxL1ExtJtF];
113  l1extjtfeta = new float[kMaxL1ExtJtF];
114  l1extjtfphi = new float[kMaxL1ExtJtF];
115  const int kMaxL1ExtJt = 10000;
116  l1extjtet = new float[kMaxL1ExtJt];
117  l1extjte = new float[kMaxL1ExtJt];
118  l1extjteta = new float[kMaxL1ExtJt];
119  l1extjtphi = new float[kMaxL1ExtJt];
120  const int kMaxL1ExtTau = 10000;
121  l1exttauet = new float[kMaxL1ExtTau];
122  l1exttaue = new float[kMaxL1ExtTau];
123  l1exttaueta = new float[kMaxL1ExtTau];
124  l1exttauphi = new float[kMaxL1ExtTau];
125 
126  algoBitToName = new TString[128];
127  techBitToName = new TString[128];
128 
129  HltTree->Branch("NL1IsolEm",&nl1extiem,"NL1IsolEm/I");
130  HltTree->Branch("L1IsolEmEt",l1extiemet,"L1IsolEmEt[NL1IsolEm]/F");
131  HltTree->Branch("L1IsolEmE",l1extieme,"L1IsolEmE[NL1IsolEm]/F");
132  HltTree->Branch("L1IsolEmEta",l1extiemeta,"L1IsolEmEta[NL1IsolEm]/F");
133  HltTree->Branch("L1IsolEmPhi",l1extiemphi,"L1IsolEmPhi[NL1IsolEm]/F");
134  HltTree->Branch("NL1NIsolEm",&nl1extnem,"NL1NIsolEm/I");
135  HltTree->Branch("L1NIsolEmEt",l1extnemet,"L1NIsolEmEt[NL1NIsolEm]/F");
136  HltTree->Branch("L1NIsolEmE",l1extneme,"L1NIsolEmE[NL1NIsolEm]/F");
137  HltTree->Branch("L1NIsolEmEta",l1extnemeta,"L1NIsolEmEta[NL1NIsolEm]/F");
138  HltTree->Branch("L1NIsolEmPhi",l1extnemphi,"L1NIsolEmPhi[NL1NIsolEm]/F");
139  HltTree->Branch("NL1Mu",&nl1extmu,"NL1Mu/I");
140  HltTree->Branch("L1MuPt",l1extmupt,"L1MuPt[NL1Mu]/F");
141  HltTree->Branch("L1MuE",l1extmue,"L1MuE[NL1Mu]/F");
142  HltTree->Branch("L1MuEta",l1extmueta,"L1MuEta[NL1Mu]/F");
143  HltTree->Branch("L1MuPhi",l1extmuphi,"L1MuPhi[NL1Mu]/F");
144  HltTree->Branch("L1MuIsol",l1extmuiso,"L1MuIsol[NL1Mu]/I");
145  HltTree->Branch("L1MuMip",l1extmumip,"L1MuMip[NL1Mu]/I");
146  HltTree->Branch("L1MuFor",l1extmufor,"L1MuFor[NL1Mu]/I");
147  HltTree->Branch("L1MuRPC",l1extmurpc,"L1MuRPC[NL1Mu]/I");
148  HltTree->Branch("L1MuQal",l1extmuqul,"L1MuQal[NL1Mu]/I");
149  HltTree->Branch("L1MuChg",l1extmuchg,"L1MuChg[NL1Mu]/I");
150  HltTree->Branch("NL1CenJet",&nl1extjetc,"NL1CenJet/I");
151  HltTree->Branch("L1CenJetEt",l1extjtcet,"L1CenJetEt[NL1CenJet]/F");
152  HltTree->Branch("L1CenJetE",l1extjtce,"L1CenJetE[NL1CenJet]/F");
153  HltTree->Branch("L1CenJetEta",l1extjtceta,"L1CenJetEta[NL1CenJet]/F");
154  HltTree->Branch("L1CenJetPhi",l1extjtcphi,"L1CenJetPhi[NL1CenJet]/F");
155  HltTree->Branch("NL1ForJet",&nl1extjetf,"NL1ForJet/I");
156  HltTree->Branch("L1ForJetEt",l1extjtfet,"L1ForJetEt[NL1ForJet]/F");
157  HltTree->Branch("L1ForJetE",l1extjtfe,"L1ForJetE[NL1ForJet]/F");
158  HltTree->Branch("L1ForJetEta",l1extjtfeta,"L1ForJetEta[NL1ForJet]/F");
159  HltTree->Branch("L1ForJetPhi",l1extjtfphi,"L1ForJetPhi[NL1ForJet]/F");
160  /*
161  HltTree->Branch("NL1Jet",&nl1extjet,"NL1Jet/I");
162  HltTree->Branch("L1JetEt",l1extjtet,"L1JetEt[NL1Jet]/F");
163  HltTree->Branch("L1JetE",l1extjte,"L1JetE[NL1Jet]/F");
164  HltTree->Branch("L1JetEta",l1extjteta,"L1JetEta[NL1Jet]/F");
165  HltTree->Branch("L1JetPhi",l1extjtphi,"L1JetPhi[NL1Jet]/F");
166  */
167  HltTree->Branch("NL1Tau",&nl1exttau,"NL1Tau/I");
168  HltTree->Branch("L1TauEt",l1exttauet,"L1TauEt[NL1Tau]/F");
169  HltTree->Branch("L1TauE",l1exttaue,"L1TauE[NL1Tau]/F");
170  HltTree->Branch("L1TauEta",l1exttaueta,"L1TauEta[NL1Tau]/F");
171  HltTree->Branch("L1TauPhi",l1exttauphi,"L1TauPhi[NL1Tau]/F");
172  HltTree->Branch("L1Met",&met,"L1Met/F");
173  HltTree->Branch("L1MetPhi",&metphi,"L1MetPhi/F");
174  HltTree->Branch("L1EtTot",&ettot,"L1EtTot/F");
175  HltTree->Branch("L1Mht",&mht,"L1Mht/F");
176  HltTree->Branch("L1MhtPhi",&mhtphi,"L1MhtPhi/F");
177  HltTree->Branch("L1EtHad",&ethad,"L1EtHad/F");
178 
179  // L1GctJetCounts
180  HltTree->Branch("L1HfRing1EtSumPositiveEta",&l1hfRing1EtSumPositiveEta,"L1HfRing1EtSumPositiveEta/I");
181  HltTree->Branch("L1HfRing2EtSumPositiveEta",&l1hfRing2EtSumPositiveEta,"L1HfRing2EtSumPositiveEta/I");
182  HltTree->Branch("L1HfRing1EtSumNegativeEta",&l1hfRing1EtSumNegativeEta,"L1HfRing1EtSumNegativeEta/I");
183  HltTree->Branch("L1HfRing2EtSumNegativeEta",&l1hfRing2EtSumNegativeEta,"L1HfRing2EtSumNegativeEta/I");
184  HltTree->Branch("L1HfTowerCountPositiveEtaRing1",&l1hfTowerCountPositiveEtaRing1,"L1HfTowerCountPositiveEtaRing1/I");
185  HltTree->Branch("L1HfTowerCountNegativeEtaRing1",&l1hfTowerCountNegativeEtaRing1,"L1HfTowerCountNegativeEtaRing1/I");
186  HltTree->Branch("L1HfTowerCountPositiveEtaRing2",&l1hfTowerCountPositiveEtaRing2,"L1HfTowerCountPositiveEtaRing2/I");
187  HltTree->Branch("L1HfTowerCountNegativeEtaRing2",&l1hfTowerCountNegativeEtaRing2,"L1HfTowerCountNegativeEtaRing2/I");
188 }
189 
190 /* **Analyze the event** */
202  const edm::Handle<L1GctHFBitCountsCollection> & gctBitCounts,
203  const edm::Handle<L1GctHFRingEtSumsCollection> & gctRingSums,
204  edm::EventSetup const& eventSetup,
205  edm::Event const& iEvent,
206  TTree* HltTree) {
207 
208 // std::cout << " Beginning HLTInfo " << std::endl;
209 
210 
212  if (hltresults.isValid()) {
213  int ntrigs = hltresults->size();
214  if (ntrigs==0){std::cout << "%HLTInfo -- No trigger name given in TriggerResults of the input " << std::endl;}
215 
216  edm::TriggerNames const& triggerNames = iEvent.triggerNames(*hltresults);
217 
218  // 1st event : Book as many branches as trigger paths provided in the input...
219  if (HltEvtCnt==0){
220  for (int itrig = 0; itrig != ntrigs; ++itrig) {
221  TString trigName = triggerNames.triggerName(itrig);
222  HltTree->Branch(trigName,trigflag+itrig,trigName+"/I");
223  HltTree->Branch(trigName+"_Prescl",trigPrescl+itrig,trigName+"_Prescl/I");
224  }
225 
226  int itdum = ntrigs;
227  for (unsigned int idum = 0; idum < dummyBranches_.size(); ++idum) {
228  TString trigName(dummyBranches_[idum].data());
229  bool addThisBranch = 1;
230  for (int itrig = 0; itrig != ntrigs; ++itrig) {
231  TString realTrigName = triggerNames.triggerName(itrig);
232  if(trigName == realTrigName) addThisBranch = 0;
233  }
234  if(addThisBranch){
235  HltTree->Branch(trigName,trigflag+itdum,trigName+"/I");
236  HltTree->Branch(trigName+"_Prescl",trigPrescl+itdum,trigName+"_Prescl/I");
237  trigflag[itdum] = 0;
238  trigPrescl[itdum] = 0;
239  ++itdum;
240  }
241  }
242 
243  HltEvtCnt++;
244  }
245  // ...Fill the corresponding accepts in branch-variables
246 
247  //std::cout << "Number of prescale sets: " << hltConfig_.prescaleSize() << std::endl;
248  //std::cout << "Number of HLT paths: " << hltConfig_.size() << std::endl;
249  //int presclSet = hltConfig_.prescaleSet(iEvent, eventSetup);
250  //std::cout<<"\tPrescale set number: "<< presclSet <<std::endl;
251 
252  for (int itrig = 0; itrig != ntrigs; ++itrig){
253 
254  std::string trigName=triggerNames.triggerName(itrig);
255  bool accept = hltresults->accept(itrig);
256 
257  trigPrescl[itrig] = hltConfig_.prescaleValue(iEvent, eventSetup, trigName);
258 
259 
260  if (accept){trigflag[itrig] = 1;}
261  else {trigflag[itrig] = 0;}
262 
263  if (_Debug){
264  if (_Debug) std::cout << "%HLTInfo -- Number of HLT Triggers: " << ntrigs << std::endl;
265  std::cout << "%HLTInfo -- HLTTrigger(" << itrig << "): " << trigName << " = " << accept << std::endl;
266  }
267  }
268  }
269  else { if (_Debug) std::cout << "%HLTInfo -- No Trigger Result" << std::endl;}
270 
272 
273  const int maxL1EmIsol = 4;
274  for (int i=0; i!=maxL1EmIsol; ++i){
275  l1extiemet[i] = -999.;
276  l1extieme[i] = -999.;
277  l1extiemeta[i] = -999.;
278  l1extiemphi[i] = -999.;
279  }
280  if (L1ExtEmIsol.isValid()) {
281  nl1extiem = maxL1EmIsol;
283  myl1iems = * L1ExtEmIsol;
284  std::sort(myl1iems.begin(),myl1iems.end(),EtGreater());
285  int il1exem = 0;
286  for (l1extra::L1EmParticleCollection::const_iterator emItr = myl1iems.begin(); emItr != myl1iems.end(); ++emItr) {
287  l1extiemet[il1exem] = emItr->et();
288  l1extieme[il1exem] = emItr->energy();
289  l1extiemeta[il1exem] = emItr->eta();
290  l1extiemphi[il1exem] = emItr->phi();
291  il1exem++;
292  }
293  }
294  else {
295  nl1extiem = 0;
296  if (_Debug) std::cout << "%HLTInfo -- No Isolated L1 EM object" << std::endl;
297  }
298 
299  const int maxL1EmNIsol = 4;
300  for (int i=0; i!=maxL1EmNIsol; ++i){
301  l1extnemet[i] = -999.;
302  l1extneme[i] = -999.;
303  l1extnemeta[i] = -999.;
304  l1extnemphi[i] = -999.;
305  }
306  if (L1ExtEmNIsol.isValid()) {
307  nl1extnem = maxL1EmNIsol;
309  myl1nems = * L1ExtEmNIsol;
310  std::sort(myl1nems.begin(),myl1nems.end(),EtGreater());
311  int il1exem = 0;
312  for (l1extra::L1EmParticleCollection::const_iterator emItr = myl1nems.begin(); emItr != myl1nems.end(); ++emItr) {
313  l1extnemet[il1exem] = emItr->et();
314  l1extneme[il1exem] = emItr->energy();
315  l1extnemeta[il1exem] = emItr->eta();
316  l1extnemphi[il1exem] = emItr->phi();
317  il1exem++;
318  }
319  }
320  else {
321  nl1extnem = 0;
322  if (_Debug) std::cout << "%HLTInfo -- No Non-Isolated L1 EM object" << std::endl;
323  }
324 
325  const int maxL1Mu = 4;
326  for (int i=0; i!=maxL1Mu; ++i){
327  l1extmupt[i] = -999.;
328  l1extmue[i] = -999.;
329  l1extmueta[i] = -999.;
330  l1extmuphi[i] = -999.;
331  l1extmuiso[i] = -999;
332  l1extmumip[i] = -999;
333  l1extmufor[i] = -999;
334  l1extmurpc[i] = -999;
335  l1extmuqul[i] = -999;
336  l1extmuchg[i] = -999;
337  }
338  if (L1ExtMu.isValid()) {
339  nl1extmu = maxL1Mu;
341  myl1mus = * L1ExtMu;
342  std::sort(myl1mus.begin(),myl1mus.end(),PtGreater());
343  int il1exmu = 0;
344  for (l1extra::L1MuonParticleCollection::const_iterator muItr = myl1mus.begin(); muItr != myl1mus.end(); ++muItr) {
345  l1extmupt[il1exmu] = muItr->pt();
346  l1extmue[il1exmu] = muItr->energy();
347  l1extmueta[il1exmu] = muItr->eta();
348  l1extmuphi[il1exmu] = muItr->phi();
349  l1extmuiso[il1exmu] = muItr->isIsolated(); // = 1 for Isolated ?
350  l1extmumip[il1exmu] = muItr->isMip(); // = 1 for Mip ?
351  l1extmufor[il1exmu] = muItr->isForward();
352  l1extmurpc[il1exmu] = muItr->isRPC();
353  l1extmuchg[il1exmu] = muItr->charge();
354  L1MuGMTExtendedCand gmtCand = muItr->gmtMuonCand();
355  l1extmuqul[il1exmu] = gmtCand.quality(); // Muon quality as defined in the GT
356  il1exmu++;
357  }
358  }
359  else {
360  nl1extmu = 0;
361  if (_Debug) std::cout << "%HLTInfo -- No L1 MU object" << std::endl;
362  }
363 
364  const int maxL1CenJet = 4;
365  for (int i=0; i!=maxL1CenJet; ++i){
366  l1extjtcet[i] = -999.;
367  l1extjtce[i] = -999.;
368  l1extjtceta[i] = -999.;
369  l1extjtcphi[i] = -999.;
370  }
371  if (L1ExtJetC.isValid()) {
372  nl1extjetc = maxL1CenJet;
374  myl1jetsc = * L1ExtJetC;
375  std::sort(myl1jetsc.begin(),myl1jetsc.end(),EtGreater());
376  int il1exjt = 0;
377  for (l1extra::L1JetParticleCollection::const_iterator jtItr = myl1jetsc.begin(); jtItr != myl1jetsc.end(); ++jtItr) {
378  l1extjtcet[il1exjt] = jtItr->et();
379  l1extjtce[il1exjt] = jtItr->energy();
380  l1extjtceta[il1exjt] = jtItr->eta();
381  l1extjtcphi[il1exjt] = jtItr->phi();
382  il1exjt++;
383  }
384  }
385  else {
386  nl1extjetc = 0;
387  if (_Debug) std::cout << "%HLTInfo -- No L1 Central JET object" << std::endl;
388  }
389 
390  const int maxL1ForJet = 4;
391  for (int i=0; i!=maxL1ForJet; ++i){
392  l1extjtfet[i] = -999.;
393  l1extjtfe[i] = -999.;
394  l1extjtfeta[i] = -999.;
395  l1extjtfphi[i] = -999.;
396  }
397  if (L1ExtJetF.isValid()) {
398  nl1extjetf = maxL1ForJet;
400  myl1jetsf = * L1ExtJetF;
401  std::sort(myl1jetsf.begin(),myl1jetsf.end(),EtGreater());
402  int il1exjt = 0;
403  for (l1extra::L1JetParticleCollection::const_iterator jtItr = myl1jetsf.begin(); jtItr != myl1jetsf.end(); ++jtItr) {
404  l1extjtfet[il1exjt] = jtItr->et();
405  l1extjtfe[il1exjt] = jtItr->energy();
406  l1extjtfeta[il1exjt] = jtItr->eta();
407  l1extjtfphi[il1exjt] = jtItr->phi();
408  il1exjt++;
409  }
410  }
411  else {
412  nl1extjetf = 0;
413  if (_Debug) std::cout << "%HLTInfo -- No L1 Forward JET object" << std::endl;
414  }
415 
416  const int maxL1Jet = 324;
417  for (int i=0; i!=maxL1Jet; ++i){
418  l1extjtet[i] = -999.;
419  l1extjte[i] = -999.;
420  l1extjteta[i] = -999.;
421  l1extjtphi[i] = -999.;
422  }
423  if (L1ExtJet.isValid()) {
424  if (_Debug) std::cout << "%HLTInfo -- Found L1 JET object" << std::endl;
425  nl1extjet = maxL1Jet;
427  myl1jets = * L1ExtJet;
428  std::sort(myl1jets.begin(),myl1jets.end(),EtGreater());
429  int il1exjt = 0;
430  for (l1extra::L1JetParticleCollection::const_iterator jtItr = myl1jets.begin(); jtItr != myl1jets.end(); ++jtItr) {
431  l1extjtet[il1exjt] = jtItr->et();
432  l1extjte[il1exjt] = jtItr->energy();
433  l1extjteta[il1exjt] = jtItr->eta();
434  l1extjtphi[il1exjt] = jtItr->phi();
435  il1exjt++;
436  }
437  }
438  else {
439  // nl1extjetf = 0;
440  if (_Debug) std::cout << "%HLTInfo -- No L1 JET object" << std::endl;
441  }
442 
443 
444  const int maxL1TauJet = 4;
445  for (int i=0; i!=maxL1TauJet; ++i){
446  l1exttauet[i] = -999.;
447  l1exttaue[i] = -999.;
448  l1exttaueta[i] = -999.;
449  l1exttauphi[i] = -999.;
450  }
451  if (L1ExtTau.isValid()) {
452  nl1exttau = maxL1TauJet;
454  myl1taus = * L1ExtTau;
455  std::sort(myl1taus.begin(),myl1taus.end(),EtGreater());
456  int il1extau = 0;
457  for (l1extra::L1JetParticleCollection::const_iterator tauItr = myl1taus.begin(); tauItr != myl1taus.end(); ++tauItr) {
458  l1exttauet[il1extau] = tauItr->et();
459  l1exttaue[il1extau] = tauItr->energy();
460  l1exttaueta[il1extau] = tauItr->eta();
461  l1exttauphi[il1extau] = tauItr->phi();
462  il1extau++;
463  }
464  }
465  else {
466  nl1exttau = 0;
467  if (_Debug) std::cout << "%HLTInfo -- No L1 TAU object" << std::endl;
468  }
469 
470  if (L1ExtMet.isValid()) {
471  met = L1ExtMet->begin()->etMiss();
472  metphi = L1ExtMet->begin()->phi();
473  ettot = L1ExtMet->begin()->etTotal();
474  }
475  else {
476  if (_Debug) std::cout << "%HLTInfo -- No L1 MET object" << std::endl;
477  }
478 
479  if (L1ExtMht.isValid()) {
480  mht = L1ExtMht->begin()->etMiss();
481  mhtphi = L1ExtMht->begin()->phi();
482  ethad = L1ExtMht->begin()->etTotal();
483  }
484  else {
485  if (_Debug) std::cout << "%HLTInfo -- No L1 MHT object" << std::endl;
486  }
487 
488  //==============L1 information=======================================
489 
490  // L1 Triggers from Menu
491 
492  // m_l1GtUtils.retrieveL1EventSetup(eventSetup);
495  eventSetup.get<L1GtTriggerMenuRcd>().get(menuRcd) ;
496  const L1GtTriggerMenu* menu = menuRcd.product();
497 
498  int iErrorCode = -1;
500  const int pfSetIndexAlgorithmTrigger = m_l1GtUtils.prescaleFactorSetIndex(
501  iEvent, trigCategory, iErrorCode);
502  if (iErrorCode == 0) {
503  if (_Debug) std::cout << "%Prescale set index: " << pfSetIndexAlgorithmTrigger << std::endl;
504  }else{
505  std::cout << "%Could not extract Prescale set index from event record. Error code: " << iErrorCode << std::endl;
506  }
507 
508  // 1st event : Book as many branches as trigger paths provided in the input...
509  if (L1GTRR.isValid()) {
510 
511  DecisionWord gtDecisionWord = L1GTRR->decisionWord();
512  const unsigned int numberTriggerBits(gtDecisionWord.size());
513  const TechnicalTriggerWord& technicalTriggerWordBeforeMask = L1GTRR->technicalTriggerWord();
514  const unsigned int numberTechnicalTriggerBits(technicalTriggerWordBeforeMask.size());
515 
516  // 1st event : Book as many branches as trigger paths provided in the input...
517  if (L1EvtCnt==0){
518 
519 
520  //ccla determine if more than 1 bx was unpacked in event; add OR all bx's if so
521  const edm::Provenance& prov = iEvent.getProvenance(L1GTRR.id());
522  //const string& procName = prov.processName();
523  //std::cout << "procName:" << procName << std::endl;
524  //std::cout << "provinfo:" << prov << std::endl;
525  //std::cout << "setid:" << setId << std::endl;
526  edm::ParameterSet pSet=parameterSet(prov);
527  //std::cout << "pset:" << pSet << std::endl;
528  if (pSet.exists("UnpackBxInEvent")){
529  UnpackBxInEvent = pSet.getParameter<int>("UnpackBxInEvent");
530  }
531  if (_Debug) std::cout << "Number of beam crossings unpacked by GT: " << UnpackBxInEvent << std::endl;
532  if (UnpackBxInEvent == 5) _OR_BXes = true;
533 
534  // get L1 menu from event setup
535  for (CItAlgo algo = menu->gtAlgorithmMap().begin(); algo!=menu->gtAlgorithmMap().end(); ++algo) {
536  if (_Debug) std::cout << "Name: " << (algo->second).algoName() << " Alias: " << (algo->second).algoAlias() << std::endl;
537  int itrig = (algo->second).algoBitNumber();
538  // algoBitToName[itrig] = TString( (algo->second).algoName() );
539  algoBitToName[itrig] = TString( (algo->second).algoAlias() );
540  HltTree->Branch(algoBitToName[itrig],l1flag+itrig,algoBitToName[itrig]+"/I");
541  HltTree->Branch(algoBitToName[itrig]+"_Prescl",l1Prescl+itrig,algoBitToName[itrig]+"_Prescl/I");
542  if (_OR_BXes)
543  HltTree->Branch(algoBitToName[itrig]+"_5bx",l1flag5Bx+itrig,algoBitToName[itrig]+"_5bx/I");
544  }
545 
546  // Book branches for tech bits
547  for (CItAlgo techTrig = menu->gtTechnicalTriggerMap().begin(); techTrig != menu->gtTechnicalTriggerMap().end(); ++techTrig) {
548  int itrig = (techTrig->second).algoBitNumber();
549  techBitToName[itrig] = TString( (techTrig->second).algoName() );
550  if (_Debug) std::cout << "tech bit " << itrig << ": " << techBitToName[itrig] << " " << std::endl;
551  HltTree->Branch(techBitToName[itrig],l1techflag+itrig,techBitToName[itrig]+"/I");
552  HltTree->Branch(techBitToName[itrig]+"_Prescl",l1techPrescl+itrig,techBitToName[itrig]+"_Prescl/I");
553  if (_OR_BXes)
554  HltTree->Branch(techBitToName[itrig]+"_5bx",l1techflag5Bx+itrig,techBitToName[itrig]+"_5bx/I");
555  }
556  }
557 
558  std::string triggerAlgTechTrig = "PhysicsAlgorithms";
559  for (unsigned int iBit = 0; iBit < numberTriggerBits; ++iBit) {
560  // ...Fill the corresponding accepts in branch-variables
561  l1flag[iBit] = gtDecisionWord[iBit];
562 
563  std::string l1triggername= std::string (algoBitToName[iBit]);
564  l1Prescl[iBit] = m_l1GtUtils.prescaleFactor(iEvent,
565  l1triggername,
566  iErrorCode);
567 
568  if (_Debug) std::cout << "L1 TD: "<<iBit<<" "<<algoBitToName[iBit]<<" "
569  << gtDecisionWord[iBit]<<" "
570  << l1Prescl[iBit] << std::endl;
571 
572  }
573 
574  triggerAlgTechTrig = "TechnicalTriggers";
575  for (unsigned int iBit = 0; iBit < numberTechnicalTriggerBits; ++iBit) {
576  l1techflag[iBit] = (int) technicalTriggerWordBeforeMask.at(iBit);
577 
578  std::string l1triggername= std::string (techBitToName[iBit]);
579  l1techPrescl[iBit] = m_l1GtUtils.prescaleFactor(iEvent,
580  l1triggername,
581  iErrorCode);
582 
583  if (_Debug) std::cout << "L1 TD: "<<iBit<<" "<<techBitToName[iBit]<<" "
584  << l1techflag[iBit]<<" "
585  << l1Prescl[iBit] << std::endl;
586 
587  }
588 
589  if (_OR_BXes){
590  // look at all 5 bx window in case gt timing is off
591  // get Field Decision Logic
592  std::vector<DecisionWord> m_gtDecisionWord5Bx;
593  std::vector<TechnicalTriggerWord> m_gtTechDecisionWord5Bx;
594  std::vector<int> m_ibxn;
595 
596  const std::vector<L1GtFdlWord> &m_gtFdlWord(L1GTRR->gtFdlVector());
597  for (std::vector<L1GtFdlWord>::const_iterator itBx = m_gtFdlWord.begin();
598  itBx != m_gtFdlWord.end(); ++itBx) {
599  if (_Debug && L1EvtCnt==0) std::cout << "bx: " << (*itBx).bxInEvent() << " ";
600  m_gtDecisionWord5Bx.push_back((*itBx).gtDecisionWord());
601  m_gtTechDecisionWord5Bx.push_back((*itBx).gtTechnicalTriggerWord());
602  }
603  // --- Fill algo bits ---
604  for (unsigned int iBit = 0; iBit < numberTriggerBits; ++iBit) {
605  // ...Fill the corresponding accepts in branch-variables
606  if (_Debug) std::cout << std::endl << " L1 TD: "<<iBit<<" "<<algoBitToName[iBit]<<" ";
607  int result=0;
608  int bitword=0;
609  for (unsigned int jbx=0; jbx<m_gtDecisionWord5Bx.size(); ++jbx) {
610  if (_Debug) std::cout << m_gtDecisionWord5Bx[jbx][iBit]<< " ";
611  result += m_gtDecisionWord5Bx[jbx][iBit];
612  if (m_gtDecisionWord5Bx[jbx][iBit]>0) bitword |= 1 << jbx;
613  }
614  if (_Debug && result>1) {std::cout << "5BxOr=" << result << " Bitword= "<< bitword <<std::endl;
615  std::cout << "Unpacking: " ;
616  for (int i = 0; i<UnpackBxInEvent ; ++i){
617  bool bitOn=bitword & (1 << i);
618  std::cout << bitOn << " ";
619  }
620  std::cout << "\n";
621  }
622  l1flag5Bx[iBit] = bitword;
623  }
624  // --- Fill tech bits ---
625  for (unsigned int iBit = 0; iBit < m_gtTechDecisionWord5Bx[2].size(); ++iBit) {
626  // ...Fill the corresponding accepts in branch-variables
627  if (_Debug) std::cout << std::endl << " L1 TD: "<<iBit<<" "<<techBitToName[iBit]<<" ";
628  int result=0;
629  int bitword=0;
630  for (unsigned int jbx=0; jbx<m_gtTechDecisionWord5Bx.size(); ++jbx) {
631  if (_Debug) std::cout << m_gtTechDecisionWord5Bx[jbx][iBit]<< " ";
632  result += m_gtTechDecisionWord5Bx[jbx][iBit];
633  if (m_gtTechDecisionWord5Bx[jbx][iBit]>0) bitword |= 1 << jbx;
634  }
635  if (_Debug && result>1) {std::cout << "5BxOr=" << result << " Bitword= "<< bitword << std::endl;
636  std::cout << "Unpacking: " ;
637  for (int i = 0; i<UnpackBxInEvent ; ++i){
638  bool bitOn=bitword & (1 << i);
639  std::cout << bitOn << " ";
640  }
641  std::cout << "\n";
642  }
643  l1techflag5Bx[iBit] = bitword;
644  }
645  } // end of OR_BX
646 
647  L1EvtCnt++;
648  }
649  else {
650  if (_Debug) std::cout << "%HLTInfo -- No L1 GT ReadoutRecord " << std::endl;
651  }
652 
653  //
654  // LSB for feature bits = 0.125 GeV.
655  // The default LSB for the ring sums is 0.5 GeV.
656 
657  if (gctBitCounts.isValid()) {
658  L1GctHFBitCountsCollection::const_iterator bitCountItr;
659  for (bitCountItr=gctBitCounts->begin(); bitCountItr!=gctBitCounts->end(); ++bitCountItr) {
660  if (bitCountItr->bx()==0){ // select in-time beam crossing
661  l1hfTowerCountPositiveEtaRing1=bitCountItr->bitCount(0);
662  l1hfTowerCountNegativeEtaRing1=bitCountItr->bitCount(1);
663  l1hfTowerCountPositiveEtaRing2=bitCountItr->bitCount(2);
664  l1hfTowerCountNegativeEtaRing2=bitCountItr->bitCount(3);
665  }
666  }
667  } else {
668  if (_Debug) std::cout << "%HLTInfo -- No L1 Gct HF BitCounts" << std::endl;
669  }
670 
671  if (gctRingSums.isValid()) {
672  L1GctHFRingEtSumsCollection::const_iterator ringSumsItr;
673  for (ringSumsItr=gctRingSums->begin(); ringSumsItr!=gctRingSums->end(); ++ringSumsItr) {
674  if (ringSumsItr->bx()==0){ // select in-time beam crossing
675  l1hfRing1EtSumPositiveEta=ringSumsItr->etSum(0);
676  l1hfRing1EtSumNegativeEta=ringSumsItr->etSum(1);
677  l1hfRing2EtSumPositiveEta=ringSumsItr->etSum(2);
678  l1hfRing2EtSumNegativeEta=ringSumsItr->etSum(3);
679  }
680  }
681  } else {
682  if (_Debug) std::cout << "%HLTInfo -- No L1 Gct HF RingSums" << std::endl;
683  }
684 
685  if (_Debug) std::cout << "%HLTInfo -- Done with routine" << std::endl;
686 }
bool _Debug
Definition: HLTInfo.h:130
int L1EvtCnt
Definition: HLTInfo.h:109
float * l1extjte
Definition: HLTInfo.h:105
T getParameter(std::string const &) const
static const bool useL1EventSetup(true)
std::vector< std::string > dummyBranches_
Definition: HLTInfo.h:120
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
int l1hfTowerCountNegativeEtaRing2
Definition: HLTInfo.h:116
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: Event.cc:204
int * l1extmuchg
Definition: HLTInfo.h:102
HLTInfo()
Definition: HLTInfo.cc:26
int nl1extmu
Definition: HLTInfo.h:109
L1GtUtils m_l1GtUtils
Definition: HLTInfo.h:123
void setup(const edm::ParameterSet &pSet, TTree *tree)
Definition: HLTInfo.cc:55
ProductID id() const
Definition: HandleBase.cc:15
int * l1Prescl
Definition: HLTInfo.h:112
float * l1extiemeta
Definition: HLTInfo.h:99
int * l1techPrescl
Definition: HLTInfo.h:112
float * l1extmupt
Definition: HLTInfo.h:101
void analyze(const edm::Handle< edm::TriggerResults > &hltresults, const edm::Handle< l1extra::L1EmParticleCollection > &l1extemi, const edm::Handle< l1extra::L1EmParticleCollection > &l1extemn, const edm::Handle< l1extra::L1MuonParticleCollection > &l1extmu, const edm::Handle< l1extra::L1JetParticleCollection > &l1extjetc, const edm::Handle< l1extra::L1JetParticleCollection > &l1extjetf, const edm::Handle< l1extra::L1JetParticleCollection > &l1extjet, const edm::Handle< l1extra::L1JetParticleCollection > &l1exttaujet, const edm::Handle< l1extra::L1EtMissParticleCollection > &l1extmet, const edm::Handle< l1extra::L1EtMissParticleCollection > &l1extmht, const edm::Handle< L1GlobalTriggerReadoutRecord > &l1GTRR, const edm::Handle< L1GctHFBitCountsCollection > &gctBitCounts, const edm::Handle< L1GctHFRingEtSumsCollection > &gctRingSums, edm::EventSetup const &eventSetup, edm::Event const &iEvent, TTree *tree)
Definition: HLTInfo.cc:191
TriggerCategory
Definition: L1GtUtils.h:58
float * l1extjtphi
Definition: HLTInfo.h:105
std::vector< L1JetParticle > L1JetParticleCollection
int l1hfRing1EtSumNegativeEta
Definition: HLTInfo.h:113
float metphi
Definition: HLTInfo.h:107
bool exists(std::string const &parameterName) const
checks if a parameter exists
float * l1exttauet
Definition: HLTInfo.h:106
float * hltpeta
Definition: HLTInfo.h:98
float * l1extnemphi
Definition: HLTInfo.h:100
int nl1extiem
Definition: HLTInfo.h:109
float * l1extieme
Definition: HLTInfo.h:99
int * l1extmufor
Definition: HLTInfo.h:111
float ethad
Definition: HLTInfo.h:108
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:26
int l1hfRing2EtSumNegativeEta
Definition: HLTInfo.h:113
float * l1extjtfet
Definition: HLTInfo.h:104
AlgorithmMap::const_iterator CItAlgo
iterators through map containing the algorithms
float * l1extjtcphi
Definition: HLTInfo.h:103
float * l1exttaue
Definition: HLTInfo.h:106
int l1hfTowerCountPositiveEtaRing2
Definition: HLTInfo.h:116
std::string processName_
Definition: HLTInfo.h:124
int l1hfTowerCountPositiveEtaRing1
Definition: HLTInfo.h:115
float * l1extmueta
Definition: HLTInfo.h:101
unsigned int prescaleValue(unsigned int set, const std::string &trigger) const
HLT prescale value in specific prescale set for a specific trigger path.
int iEvent
Definition: GenABIO.cc:243
int * l1techflag5Bx
Definition: HLTInfo.h:111
int UnpackBxInEvent
Definition: HLTInfo.h:127
TString * algoBitToName
Definition: HLTInfo.h:118
int * l1extmuqul
Definition: HLTInfo.h:111
std::vector< bool > DecisionWord
typedefs
float mht
Definition: HLTInfo.h:108
float * l1extjtceta
Definition: HLTInfo.h:103
int l1hfTowerCountNegativeEtaRing1
Definition: HLTInfo.h:115
tuple result
Definition: query.py:137
float * l1extjtet
Definition: HLTInfo.h:105
float * l1exttaueta
Definition: HLTInfo.h:106
int HltEvtCnt
Definition: HLTInfo.h:109
std::vector< bool > TechnicalTriggerWord
technical trigger bits (64 bits)
float met
Definition: HLTInfo.h:107
void beginRun(const edm::Run &, const edm::EventSetup &)
Definition: HLTInfo.cc:34
std::vector< std::string > getParameterNames() const
bool isValid() const
Definition: HandleBase.h:76
float * l1extnemet
Definition: HLTInfo.h:100
int nl1exttau
Definition: HLTInfo.h:109
float * l1extjtce
Definition: HLTInfo.h:103
int l1hfRing2EtSumPositiveEta
Definition: HLTInfo.h:114
int * l1flag
Definition: HLTInfo.h:111
float * l1extjteta
Definition: HLTInfo.h:105
TString * techBitToName
Definition: HLTInfo.h:119
int * l1extmumip
Definition: HLTInfo.h:111
int nl1extjet
Definition: HLTInfo.h:109
float * l1extneme
Definition: HLTInfo.h:100
float * l1extnemeta
Definition: HLTInfo.h:100
bool _OR_BXes
Definition: HLTInfo.h:126
int * trigPrescl
Definition: HLTInfo.h:112
int nl1extjetf
Definition: HLTInfo.h:109
void getL1GtRunCache(const edm::Run &, const edm::EventSetup &, const bool, const bool, const edm::InputTag &)
get all the run-constant quantities for L1 trigger and cache them
Definition: L1GtUtils.cc:311
unsigned int quality() const
get quality
Definition: L1MuGMTCand.h:93
float * l1extmue
Definition: HLTInfo.h:101
int * l1techflag
Definition: HLTInfo.h:111
float * l1extmuphi
Definition: HLTInfo.h:101
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:27
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
const T & get() const
Definition: EventSetup.h:55
int nl1extnem
Definition: HLTInfo.h:109
T const * product() const
Definition: ESHandle.h:62
HLTConfigProvider hltConfig_
Definition: HLTInfo.h:122
int * l1extmurpc
Definition: HLTInfo.h:111
static const bool useL1GtTriggerMenuLite(false)
float * l1extjtfphi
Definition: HLTInfo.h:104
float ettot
Definition: HLTInfo.h:107
float * l1extiemet
Definition: HLTInfo.h:99
const int prescaleFactorSetIndex(const edm::Event &iEvent, const edm::InputTag &l1GtRecordInputTag, const edm::InputTag &l1GtReadoutRecordInputTag, const TriggerCategory &trigCategory, int &errorCode) const
Definition: L1GtUtils.cc:1760
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
float * l1extjtfe
Definition: HLTInfo.h:104
const AlgorithmMap & gtAlgorithmMap() const
get / set the algorithm map (by name)
float * l1extjtfeta
Definition: HLTInfo.h:104
float mhtphi
Definition: HLTInfo.h:108
int * trigflag
Definition: HLTInfo.h:111
int * l1flag5Bx
Definition: HLTInfo.h:111
tuple cout
Definition: gather_cfg.py:121
const AlgorithmMap & gtTechnicalTriggerMap() const
get / set the technical trigger map
float * l1extjtcet
Definition: HLTInfo.h:103
std::vector< L1EmParticle > L1EmParticleCollection
int l1hfRing1EtSumPositiveEta
Definition: HLTInfo.h:114
float * hltppt
Definition: HLTInfo.h:98
const int prescaleFactor(const edm::Event &iEvent, const edm::InputTag &l1GtRecordInputTag, const edm::InputTag &l1GtReadoutRecordInputTag, const std::string &nameAlgoTechTrig, int &errorCode) const
return prescale factor for a given algorithm or technical trigger
Definition: L1GtUtils.cc:1485
Provenance getProvenance(BranchID const &theID) const
Definition: Event.cc:76
int * l1extmuiso
Definition: HLTInfo.h:111
std::vector< L1MuonParticle > L1MuonParticleCollection
int nl1extjetc
Definition: HLTInfo.h:109
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11
float * l1extiemphi
Definition: HLTInfo.h:99
Definition: Run.h:41
float * l1exttauphi
Definition: HLTInfo.h:106