DESY Hbb Analysis Framework
Functions
AnalysisTriggerExample.cc File Reference
#include <string>
#include <iostream>
#include <vector>
#include "TFile.h"
#include "TFileCollection.h"
#include "TChain.h"
#include "TH1.h"
#include "Analysis/Tools/interface/Analysis.h"
#include "Analysis/Tools/bin/macro_config.h"

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 19 of file AnalysisTriggerExample.cc.

References analysis::tools::Analysis::addTree(), analysis::tools::Analysis::collection(), analysis::tools::Candidate::eta(), analysis::tools::Analysis::event(), hltPath_, inputlist_, l1Seed_, macro_config(), nevtmax_, analysis::tools::Candidate::phi(), analysis::tools::Candidate::pt(), analysis::tools::Analysis::size(), triggerCol_, triggerObjDir_, triggerObjectsJets_, analysis::tools::Analysis::triggerPrescale(), analysis::tools::Analysis::triggerResult(), and analysis::tools::Analysis::triggerResults().

20 {
21  TH1::SetDefaultSumw2(); // proper treatment of errors when scaling histograms
22 
23  if ( macro_config(argc, argv) != 0 ) return -1;
24 
25  // Input files list
27 
28  // Trigger
29  analysis.triggerResults(triggerCol_);
30 
31  // Trigger objects
32  for ( auto & obj : triggerObjectsJets_ )
33  analysis.addTree<TriggerObject>(obj,triggerObjDir_+"/"+obj);
34 
35  // Analysis of events
36  std::cout << "This analysis has " << analysis.size() << " events" << std::endl;
37  int nevts = analysis.size();
38  if ( nevts > 0 ) nevts = nevtmax_;
39  for ( int i = 0 ; i < nevts ; ++i )
40  {
41  analysis.event(i);
42 
43  std::cout << "++++++ ENTRY " << i << std::endl;
44 
45  // Trigger results: fired and prescales
46  // hltPath
47  int trg_fired = analysis.triggerResult(hltPath_);
48  // prescales
49  int l1ps = analysis.triggerPrescale(l1Seed_);
50  int hltps = analysis.triggerPrescale(hltPath_);
51  std::string s_accept = " fired ";
52 
53  // printing info
54  if ( ! trg_fired )
55  {
56  std::cout << "The path " << hltPath_ << " did not fire " << std::endl;
57  continue;
58  }
59 
60  std::cout << "The path " << hltPath_ << " fired and has HLT PS = " << hltps << std::endl;
61  std::cout << "and its L1 seed " << l1Seed_ << " has the following prescale: " << l1ps << endl;
62 
63  // dealing with trigger objects
64  // *** WARNING! *** the order you enter the trigger object in the config file matter!
65  auto l1jets = analysis.collection<TriggerObject>(triggerObjectsJets_[0]);
66  for ( int j = 0 ; j < l1jets->size() ; ++j )
67  {
68  TriggerObject l1jet = l1jets->at(j);
69  std::cout << "L1 Jet: pT = " << l1jet.pt() << ", " << l1jet.eta() << ", " << l1jet.phi() << std::endl;
70  }
71 
72  }
73 
74 
75 }
float eta() const
returns the pseudorapidity
Definition: Candidate.cc:134
int macro_config(int argc, char *argv[])
Definition: macro_config.h:145
float phi() const
returns the azimuthal angle
Definition: Candidate.cc:135
std::string triggerObjDir_
Definition: macro_config.h:139
std::vector< std::string > triggerObjectsJets_
Definition: macro_config.h:127
std::string l1Seed_
Definition: macro_config.h:116
std::string inputlist_
Definition: macro_config.h:21
float pt() const
returns the transverse momentum
Definition: Candidate.cc:133
std::string hltPath_
Definition: macro_config.h:115
int nevtmax_
Definition: macro_config.h:15
std::string triggerCol_
Definition: macro_config.h:136