-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanESD.C
156 lines (148 loc) · 3.96 KB
/
anESD.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#if !defined(__CINT__) || defined(__MAKECINT__)
#include <TH1F.h>
#include <TH1I.h>
#include <TH2D.h>
#include <TFile.h>
#include <Riostream.h>
#include <TParticle.h>
#include <TCanvas.h>
#include <TLegend.h>
#include <TSystem.h>
#include <TROOT.h>
#include <TClonesArray.h>
#include <TTree.h>
#include <TArrayF.h>
#include <TStyle.h>
#include <TString.h>
#include <TParticlePDG.h>
#include "AliRun.h"
#include "AliRunLoader.h"
#include "AliMultiplicity.h"
#include "AliESDtrackCuts.h"
#include "AliStack.h"
#include "AliESDEvent.h"
#include "AliESDtrack.h"
#include "AliTrackReference.h"
//
#include "HistoManager.h"
#endif
TTree* treeInp = 0;
AliRunLoader* runLoader = 0;
AliESDEvent * esd=0;
void ProcessEvent(int iev);
void Process(const char* path);
void ProcChunk(const char* path);
void TestTracker(TTree* tRP, AliESDVertex* vtx);
void Process(const char* inpData)
{
//
TString inpDtStr = inpData;
if (inpDtStr.EndsWith(".root") || inpDtStr.EndsWith(".zip#")) {
ProcChunk(inpDtStr.Data());
}
else {
ifstream inpf(inpData);
if (!inpf.good()) {
printf("Failed on input filename %s\n",inpData);
return;
}
//
inpDtStr.ReadLine(inpf);
while ( !inpDtStr.IsNull() ) {
inpDtStr = inpDtStr.Strip(TString::kBoth,' ');
if (inpDtStr.BeginsWith("//") || inpDtStr.BeginsWith("#")) {inpDtStr.ReadLine(inpf); continue;}
inpDtStr = inpDtStr.Strip(TString::kBoth,',');
inpDtStr = inpDtStr.Strip(TString::kBoth,'"');
ProcChunk(inpDtStr.Data());
inpDtStr.ReadLine(inpf);
}
}
}
void ProcChunk(const char* path)
{
//
TString dir=path;
//
printf("Processing %s\n",dir.Data());
//
if (dir.EndsWith("AliESDs.root")) {
dir.ReplaceAll("AliESDs.root","");
}
//
TTree *trackRefTree = 0x0;
TClonesArray *trackRef = new TClonesArray("AliTrackReference",1000);
esd = new AliESDEvent();
//
runLoader = AliRunLoader::Open(Form("%sgalice.root",dir.Data()));
if (!runLoader) {
printf("galice not found\n");
return;
}
runLoader->LoadgAlice();
gAlice = runLoader->GetAliRun();
runLoader->LoadHeader();
runLoader->LoadKinematics();
// runLoader->LoadTrackRefs();
// ESD
TFile* esdFile = TFile::Open(Form("%sAliESDs.root",dir.Data()));
if (!esdFile || !esdFile->IsOpen()) {
printf("Error in opening ESD file\n");
// runLoader->UnloadTrackRefs();
runLoader->UnloadKinematics();
runLoader->UnloadHeader();
runLoader->UnloadgAlice();
delete runLoader;
return;
}
treeInp = (TTree*) esdFile->Get("esdTree");
if (!treeInp) {
printf("Error: no ESD tree found\n");
// runLoader->UnloadTrackRefs();
runLoader->UnloadKinematics();
runLoader->UnloadHeader();
runLoader->UnloadgAlice();
delete runLoader;
return;
}
esd->ReadFromTree(treeInp);
//
const int kDummy = -99999999;
for(Int_t iEv=0; iEv<runLoader->GetNumberOfEvents(); iEv++){
printf("ev %d\n",iEv);
ProcessEvent(iEv);
}
runLoader->UnloadTrackRefs();
runLoader->UnloadKinematics();
runLoader->UnloadHeader();
runLoader->UnloadgAlice();
delete runLoader;
runLoader = 0;
esdFile->Close();
delete esdFile;
}
//_______________________________________________
void ProcessEvent(int iEv)
{
runLoader->GetEvent(iEv);
treeInp->GetEvent(iEv);
AliStack *stack = runLoader->Stack();
Int_t nParticles = stack->GetNtrack();
Int_t nTracks= esd->GetNumberOfTracks();
printf("Ntr: %d NPart: %d\n",nTracks,nParticles);
const AliESDVertex* vtx = esd->GetPrimaryVertex();
if (!vtx || !vtx->GetStatus()) return;
//
TTree* treeITSRP = runLoader->GetTreeR("ITS",kFALSE);
if (!treeITSRP) {
printf("Failed to fetch ITS recpoints\n");
exit(1);
}
//
TestTracker(treeITSRP, vtx);
esd->Reset();
//
}
//_________________________________________________
void TestTracker(TTree* tRP, AliESDVertex* vtx)
{
}