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