DESY Hbb Analysis Framework
TruePileup.cc
Go to the documentation of this file.
1 #include "TRandom3.h"
3 
4 // this produces histogram with the true pileup
5 
6 using namespace std;
7 using namespace analysis;
8 using namespace analysis::tools;
9 
10 int main(int argc, char ** argv)
11 {
12  TH1::SetDefaultSumw2(); // proper treatment of errors when scaling histograms
13 
14  Analyser analyser(argc,argv);
15 
16 // analyser.pileupHistogram();
17 
18  TRandom3 * rnd = new TRandom3();
19 
20 // float ps = 1./analyser.config()->prescale();
21 
22  int n = analyser.config()->n();
23  int evts_max = analyser.nEvents();
24  int evts = evts_max;
25 // float ps = float(n)/evts;
26 
27  if ( n < evts ) evts = n;
28 
29  // events loop
30 // for ( int i = 0 ; i < analyser.nEvents() ; ++i )
31  std::vector<int> v_evts;
32  for ( int i = 0 ; i < evts ; ++i )
33  {
34  // avoiding bias for some samples
35  double x;
36  if ( n < evts )
37  x = rnd->Rndm()*(evts_max-1);
38  else
39  x = double(i);
40 // if ( x > ps ) continue;
41  int ii = int(x);
42  if ( v_evts.size() > 0 )
43  {
44  if (std::find(v_evts.begin(), v_evts.end(),ii)!=v_evts.end())
45  {
46  std::cout << "repeated event" << std::endl;
47  continue;
48  }
49  }
50  v_evts.push_back(ii);
51 
52  analyser.event(ii);
53  analyser.fillPileupHistogram();
54 
55  } //end events loop
56 
57 } // end main
58 
std::shared_ptr< Config > config()
returns pointer to Config object
void fillPileupHistogram()
fills pileup histogram
int main(int argc, char **argv)
Definition: TruePileup.cc:10
virtual bool event(const int &)
Read event and perform basic selections and actions.
Definition: Analyser.cc:42
int nEvents()
number of events to be processed