ATLAS Offline Software
Loading...
Searching...
No Matches
AverageMinBias.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Macro to average MinBias hits energies in the EMB strips
6
7
8#ifndef AverageMinBias_h
9#define AverageMinBias_h
10
11#include <TROOT.h>
12#include <TChain.h>
13#include <TFile.h>
14
16public :
17 TTree *fChain;
18 Int_t fCurrent;
19
20 static const unsigned nindex=1833;
21 // Declaration of leaf types
22 Int_t ncell;
24 Int_t identifier[nindex]; //[ncell]
25 Int_t layer[nindex]; //[ncell]
26 Int_t region[nindex]; //[ncell]
27 Int_t ieta[nindex]; //[ncell]
28 Float_t eta[nindex]; //[ncell]
29 Float_t phi[nindex]; //[ncell]
30 Double_t nevt[nindex]; //[ncell]
31 Double_t average[nindex]; //[ncell]
32 Double_t rms[nindex]; //[ncell]
33 Double_t reference[nindex]; //[ncell]
34
35 // List of branches
36 TBranch *b_ncell;
37 TBranch *b_nevt_total;
38 TBranch *b_identifier;
39 TBranch *b_layer;
40 TBranch *b_region;
41 TBranch *b_ieta;
42 TBranch *b_eta;
43 TBranch *b_phi;
44 TBranch *b_nevt;
45 TBranch *b_average;
46 TBranch *b_rms;
47 TBranch *b_reference;
48
50 virtual ~AverageMinBias();
51 virtual Int_t Cut(Long64_t entry);
52 virtual Int_t GetEntry(Long64_t entry);
53 virtual Long64_t LoadTree(Long64_t entry);
54 virtual void Init(TTree *tree);
55 virtual void Loop();
56 virtual Bool_t Notify();
57 virtual void Show(Long64_t entry = -1);
58};
59
60#endif
61
62#ifdef AverageMinBias_cxx
63AverageMinBias::AverageMinBias(TTree *tree) : fChain(0)
64{
65// if parameter tree is not specified (or zero), connect the file
66// used to generate this class and read the Tree.
67 if (tree == 0) {
68 TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("ntuple.root");
69 if (!f || !f->IsOpen()) {
70 f = new TFile("ntuple.root");
71 }
72 f->GetObject("m_tree",tree);
73
74 }
75 Init(tree);
76}
77
79{
80 if (!fChain) return;
81 delete fChain->GetCurrentFile();
82}
83
84Int_t AverageMinBias::GetEntry(Long64_t entry)
85{
86// Read contents of entry.
87 if (!fChain) return 0;
88 return fChain->GetEntry(entry);
89}
90Long64_t AverageMinBias::LoadTree(Long64_t entry)
91{
92// Set the environment to read one entry
93 if (!fChain) return -5;
94 Long64_t centry = fChain->LoadTree(entry);
95 if (centry < 0) return centry;
96 if (fChain->GetTreeNumber() != fCurrent) {
97 fCurrent = fChain->GetTreeNumber();
98 Notify();
99 }
100 return centry;
101}
102
103void AverageMinBias::Init(TTree *tree)
104{
105 // Set branch addresses and branch pointers
106 if (!tree) return;
107 fChain = tree;
108 fCurrent = -1;
109 fChain->SetMakeClass(1);
110
111 fChain->SetBranchAddress("ncell", &ncell, &b_ncell);
112 fChain->SetBranchAddress("nevt_total", &nevt_total, &b_nevt_total);
113 fChain->SetBranchAddress("identifier", identifier, &b_identifier);
114 fChain->SetBranchAddress("layer", layer, &b_layer);
115 fChain->SetBranchAddress("region", region, &b_region);
116 fChain->SetBranchAddress("ieta", ieta, &b_ieta);
117 fChain->SetBranchAddress("eta", eta, &b_eta);
118 fChain->SetBranchAddress("phi", phi, &b_phi);
119 fChain->SetBranchAddress("nevt", nevt, &b_nevt);
120 fChain->SetBranchAddress("average", average, &b_average);
121 fChain->SetBranchAddress("rms", rms, &b_rms);
122 fChain->SetBranchAddress("reference", reference, &b_reference);
123 Notify();
124}
125
127{
128 return kTRUE;
129}
130
131void AverageMinBias::Show(Long64_t entry)
132{
133 if (!fChain) return;
134 fChain->Show(entry);
135}
136Int_t AverageMinBias::Cut(Long64_t entry)
137{
138 return 1;
139}
140#endif // #ifdef AverageMinBias_cxx
virtual void Loop()
AverageMinBias(TTree *tree=0)
virtual Bool_t Notify()
TBranch * b_nevt_total
TBranch * b_region
Double_t nevt[nindex]
Int_t region[nindex]
virtual ~AverageMinBias()
Int_t layer[nindex]
virtual Int_t Cut(Long64_t entry)
virtual void Init(TTree *tree)
Int_t ieta[nindex]
Int_t identifier[nindex]
Double_t rms[nindex]
virtual void Show(Long64_t entry=-1)
Double_t reference[nindex]
TBranch * b_reference
static const unsigned nindex
current Tree number in a TChain
TBranch * b_ncell
virtual Long64_t LoadTree(Long64_t entry)
virtual Int_t GetEntry(Long64_t entry)
Float_t phi[nindex]
TBranch * b_average
Float_t eta[nindex]
Int_t fCurrent
pointer to the analyzed TTree or TChain
TBranch * b_identifier
Double_t average[nindex]
TBranch * b_layer
TChain * tree