ATLAS Offline Software
Functions
lhMM_runII_fromTxt_commonTool.cxx File Reference
#include <iostream>
#include <fstream>
#include <TH1F.h>
#include <TH2F.h>
#include <TMath.h>
#include <TFile.h>
#include <TRandom3.h>
#include "FakeBkgTools/LhoodMMEvent.h"
#include "FakeBkgTools/LhoodMM_tools.h"
Include dependency graph for lhMM_runII_fromTxt_commonTool.cxx:

Go to the source code of this file.

Functions

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

Function Documentation

◆ main()

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

Definition at line 15 of file lhMM_runII_fromTxt_commonTool.cxx.

15  {
16 
17  TRandom3 rand(349867);
18 
19  LhoodMM_tools* l = new LhoodMM_tools();
20  if (l ==0) {
21  std::cout << "null!" << std::endl;
22  return 1;
23  }
24 
25  TH1F* h_ht = new TH1F("ht", "ht", 10, 0, 1000);
26  float ht;
27  TH1F* h_phi = new TH1F("phi", "phi", 10, 0, 7);
28  float phi;
29  TH2F* h_2d = new TH2F("ht_vs_phi", "ht_vs_phi", 10, 0, 7, 10, 0, 1000);
30  l->register1DHistogram(h_ht, &ht);
31  l->register1DHistogram(h_phi, &phi);
32  l->register2DHistogram(h_2d, &phi, &ht);
33 
34  // loop over all the input txt files
35  for (int itxtfile = 1; itxtfile < argc-1; itxtfile++) {
36 
37  char* txtFilename = argv[itxtfile];
38  fstream txtFile(txtFilename);
39  while (!txtFile.eof()) {
40  std::cout << "reading..." << std::endl;
41  int nlep;
42  std::vector<bool> isTight_vals;
43  std::vector<double> realEff_vals;
44  std::vector<double> fakeEff_vals;
45  txtFile >> nlep;
46  std::vector<FakeBkgTools::Particle> particles;
47  for (int ilep = 0; ilep<nlep; ilep++) {
48  bool is_tight;
49  float real_eff;
50  float fake_eff;
52  txtFile >> is_tight >> real_eff >> fake_eff;
53  p.is_tight = is_tight;
54  p.real_eff = real_eff;
55  p.fake_eff = fake_eff;
56 
57  particles.push_back(p);
58  }
59 
60  ht = 1000.*rand.Uniform();
61  phi = 2*TMath::Pi()*rand.Uniform();
62 
63  if (!txtFile.eof()) {
64  l->BaseFakeBkgTool::addEvent(particles);
65  }
66  }
67 
68  l->fillHistograms();
69 
70  TFile f("test.root", "RECREATE");
71  f.cd();
72  h_ht->Write();
73  h_phi->Write();
74  h_2d->Write();
75  f.Close();
76  }
77 
78  double nfakes, poserr, negerr;
79  // l->setPrintLevel(1);
80  FakeBkgTools::Yield y = l->getTotalYield(); // need to update once
81  // syntax interpreter is available
82 
83  nfakes = y.value;
85  u.index = 0;
86  poserr = y.uncertainties[u].up;
87  negerr = y.uncertainties[u].down;
88 
89  std::cout << "nfakes = " << nfakes << " + " << poserr << " - " << -1.0*negerr << std::endl;
90 
91  TFile rootFile(argv[argc-1], "RECREATE");
92  TH1F* h_count = new TH1F("h_count", "h_count", 2, 0, 2);
93  h_count->SetBinContent(1, nfakes);
94  h_count->SetBinError(1, TMath::Max(TMath::Abs(poserr), TMath::Abs(negerr)));
95  rootFile.cd();
96  h_count->Write();
97  rootFile.Close();
98 
99 }
FakeBkgTools::Uncertainty
Definition: FakeBkgInternals.h:27
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
TH2F
Definition: rootspy.cxx:420
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
LArCellConditions.argv
argv
Definition: LArCellConditions.py:112
python.TrigEgammaMonitorHelper.TH2F
def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:45
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:83
xAOD::Particle
Particle_v1 Particle
Define the latest version of the particle class.
Definition: Event/xAOD/xAODParticleEvent/xAODParticleEvent/Particle.h:17
LArG4FSStartPointFilter.rand
rand
Definition: LArG4FSStartPointFilter.py:80
makeComparison.rootFile
rootFile
Definition: makeComparison.py:27
TH1F::SetBinContent
void SetBinContent(int, double)
Definition: rootspy.cxx:327
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
WriteCalibToCool.txtFile
txtFile
Definition: WriteCalibToCool.py:83
FakeBkgTools::Yield
a structure to hold an event yield together with a statistical uncertainty and a variable number of s...
Definition: FakeBkgInternals.h:70
y
#define y
TH1F
Definition: rootspy.cxx:320
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
top::ht
double ht(const top::Event &event)
HT calculation.
Definition: EventTools.cxx:33