-
Notifications
You must be signed in to change notification settings - Fork 0
/
testFantr.C
279 lines (265 loc) · 8.16 KB
/
testFantr.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
#if !defined(__CINT__) || defined(__MAKECINT__)
#include <TH1F.h>
#include <TSystem.h>
#include <TMath.h>
#include <TParticle.h>
#include <TRandom.h>
#include <TROOT.h>
#include "AliESDVertex.h"
#include "AliExternalTrackParam.h"
#include "FT2.h"
#include <TTree.h>
#include <TFile.h>
#include <TParticlePDG.h>
FT2* det=0;
#endif
TH1F* hdca=0,*hdcaN=0;
TH1F* hdcaZ=0,*hdcaZN=0;
TH1F* hFdca=0,*hFdcaN=0;
TH1F* hFdcaZ=0,*hFdcaZN=0;
TH1F* hPatternITS=0;
TH1F* hFPatternITS=0;
typedef struct {
Int_t pdg;
Int_t qMC;
Float_t ptMC;
Float_t etaMC;
Float_t phiMC;
Float_t drMC;
Float_t dzMC;
//
Int_t nrec;
//
Int_t q;
Float_t zvSPD;
Float_t zvTrc;
Float_t pt;
Float_t eta;
Float_t phi;
Float_t dca[2];
Float_t dcaErr[2];
Float_t sigpti;
Float_t tpcChi2;
Float_t trdChi2;
//
UChar_t nclITS;
UChar_t nclITSF;
UChar_t nclTPC;
UChar_t nclTRD;
UChar_t clITS;
UChar_t clITSF;
UChar_t clTRD;
//
Int_t mlt05;
//
Int_t lbl;
Int_t lblTPC;
Int_t lblITS;
//
ULong64_t fFlags;
ULong64_t fMyBits;
//
} trSumm;
trSumm tSum;
void testFantr(const char* inpTreeName="trsf.root",int ntrials=-1, double dndy=2100., Bool_t useKalmanOut=kTRUE);
void testFantr(TTree* inpTree ,int ntrials=-1, double dndy=2100.*3, Bool_t useKalmanOut=kTRUE);
void SetInpTree(TTree* inpTree);
void BookTree(const char* treeFile, const char* treeName, const char* treeTitle="SummaryTree");
void CloseTree();
TFile* treeOutFile = 0;
TTree* treeOut = 0;
void testFantr(const char* inpTreeName ,int ntrials, double dndy, Bool_t useKalmanOut)
{
TFile* ff = TFile::Open(inpTreeName);
TTree *tin = (TTree*)ff->Get("sum");
testFantr(tin,ntrials,dndy,useKalmanOut);
}
void testFantr(TTree* inpTree ,int ntrials, double dndy, Bool_t useKalmanOut)
{
#if defined(__CINT__) && !defined(__MAKECINT__)
gSystem->Load("libITSUpgradeBase.so");
gSystem->Load("libITSUpgradeSim.so");
gSystem->Load("libITSUpgradeRec.so");
gROOT->ProcessLine(".L FT2.cxx+");
FT2* det=0;
#endif
//
det = new FT2();
det->InitEnvLocal();
det->InitDetector();
det->SetSimMat(kTRUE);
det->SetMaxStepTGeo(1.);
det->SetdNdY(dndy);
det->SetUseKalmanOut(useKalmanOut);
//
SetInpTree(inpTree);
BookTree("ft2anres.root","tsumft2");
int nent = inpTree->GetEntries();
//
AliESDVertex *vtx = new AliESDVertex();
double vcov[6] = {1e-4, 0, 1e-4, 0, 0, 1e-4};
vtx->SetCovarianceMatrix(vcov);
vtx->Print();
//
TParticle prt;
int ntrAcc = 0;
for (int ntr=0;ntr<nent;ntr++) {
inpTree->GetEntry(ntr);
if (tSum.qMC==0 || tSum.nrec==0) continue;
//
vtx->SetXv(gRandom->Gaus(-0.1, 50e-4));
vtx->SetYv(gRandom->Gaus(0.2, 50e-4));
vtx->SetZv(tSum.zvTrc);
//
double phi = tSum.phiMC;
double eta = tSum.etaMC;
double theta = 2*TMath::ATan(TMath::Exp(-eta));
double pt = tSum.ptMC;
double p = pt/TMath::Sin(theta);
double pz = p*TMath::Cos(theta);
// double pt = p*TMath::Sin(theta);
double pxyz[3]={pt*TMath::Cos(phi),pt*TMath::Sin(phi),pz};
prt.SetPdgCode(tSum.pdg);
TParticlePDG* ppdg = prt.GetPDG();
if (!ppdg) continue;
double m = ppdg->Mass();
double en = TMath::Sqrt(p*p+m*m);
//
prt.SetMomentum(pxyz[0],pxyz[1],pxyz[2],en);
prt.SetProductionVertex(vtx->GetX(),vtx->GetY(),vtx->GetZ(),0);
//
if (det->ProcessTrack(&prt,vtx)) {
//const AliExternalTrackParam& prob = det->GetProbe();
// printf("%d %d\n",det->GetNClITS(),det->GetNClTPC());
// prob.Print();
// /*
const double* dca = det->GetDCA();
const double* cov = det->GetDCACov();
tSum.dca[0] = dca[0];
tSum.dca[1] = dca[1];
tSum.dcaErr[0] = TMath::Sqrt(cov[0]);
tSum.dcaErr[1] = TMath::Sqrt(cov[2]);
//
tSum.nclITSF = det->GetNClITSFakes();
tSum.nclITS = det->GetNClITS();
//
tSum.clITS = (UChar_t) det->GetITSPattern();
tSum.clITSF = det->GetITSPatternFakes();
//
const FTProbe& probe = det->GetProbe();
tSum.pt = probe.Pt();
tSum.eta = probe.Eta();
tSum.phi = probe.Phi();
tSum.sigpti = TMath::Sqrt(probe.GetSigma1Pt2());
tSum.tpcChi2 = det->GetChi2TPC();
tSum.trdChi2 = det->GetChi2ITS();
tSum.nclTPC = det->GetNClTPC();
ntrAcc++;
treeOut->Fill();
if ( (ntrAcc%5000)==0 ) printf("%d tracks accepted from %d read, total %d\n",ntrAcc,ntr,nent);
}
else {
printf("Failed on track %d\n",ntr);
}
if (ntrials>0 && ntrAcc>ntrials) break;
}
//
CloseTree();
}
void SetInpTree(TTree* inpTree)
{
inpTree->SetBranchAddress("pdg", &tSum.pdg);
inpTree->SetBranchAddress("qMC", &tSum.qMC);
inpTree->SetBranchAddress("ptMC", &tSum.ptMC);
inpTree->SetBranchAddress("etaMC", &tSum.etaMC);
inpTree->SetBranchAddress("phiMC", &tSum.phiMC);
inpTree->SetBranchAddress("drMC", &tSum.drMC);
inpTree->SetBranchAddress("dzMC", &tSum.dzMC);
//
inpTree->SetBranchAddress("nrec", &tSum.nrec);
//
inpTree->SetBranchAddress("q", &tSum.q);
inpTree->SetBranchAddress("zvSPD", &tSum.zvSPD);
inpTree->SetBranchAddress("zvTrc", &tSum.zvTrc);
inpTree->SetBranchAddress("pt", &tSum.pt);
inpTree->SetBranchAddress("eta", &tSum.eta);
inpTree->SetBranchAddress("phi", &tSum.phi);
inpTree->SetBranchAddress("dca", &tSum.dca);
inpTree->SetBranchAddress("dcaErr", &tSum.dcaErr);
inpTree->SetBranchAddress("sigpti", &tSum.sigpti);
inpTree->SetBranchAddress("tpcChi2", &tSum.tpcChi2);
inpTree->SetBranchAddress("trdChi2", &tSum.trdChi2);
//
inpTree->SetBranchAddress("nclITS", &tSum.nclITS);
inpTree->SetBranchAddress("nclITSF", &tSum.nclITSF);
inpTree->SetBranchAddress("nclTPC", &tSum.nclTPC);
inpTree->SetBranchAddress("nclTRD", &tSum.nclTRD);
//
inpTree->SetBranchAddress("clITS", &tSum.clITS);
inpTree->SetBranchAddress("clITSF", &tSum.clITSF);
inpTree->SetBranchAddress("clTRD", &tSum.clTRD);
//
inpTree->SetBranchAddress("mlt05", &tSum.mlt05);
//
inpTree->SetBranchAddress("lbl", &tSum.lbl);
inpTree->SetBranchAddress("lblTPC", &tSum.lblTPC);
inpTree->SetBranchAddress("lblITS", &tSum.lblITS);
//
inpTree->SetBranchAddress("fFlags", &tSum.fFlags);
inpTree->SetBranchAddress("fMyBits",&tSum.fMyBits);
}
//_______________________________________________
void BookTree(const char* treeFile, const char* treeName, const char* treeTitle)
{
treeOutFile = TFile::Open(treeFile,"recreate");
treeOut = new TTree(treeName,treeTitle);
//
treeOut->Branch("pdg", &tSum.pdg ,"pdg/I");
treeOut->Branch("qMC", &tSum.qMC ,"qMC/I");
treeOut->Branch("ptMC", &tSum.ptMC ,"ptMC/F");
treeOut->Branch("etaMC", &tSum.etaMC ,"etaMC/F");
treeOut->Branch("phiMC", &tSum.phiMC ,"phiMC/F");
treeOut->Branch("drMC", &tSum.drMC ,"drMC/F");
treeOut->Branch("dzMC", &tSum.dzMC ,"dzMC/F");
//
treeOut->Branch("nrec", &tSum.nrec ,"nrec/I");
//
treeOut->Branch("q", &tSum.q ,"q/I");
treeOut->Branch("zvSPD", &tSum.zvSPD ,"zvSPD/F");
treeOut->Branch("zvTrc", &tSum.zvTrc ,"zvTrc/F");
treeOut->Branch("pt", &tSum.pt ,"pt/F");
treeOut->Branch("eta", &tSum.eta ,"eta/F");
treeOut->Branch("phi", &tSum.phi ,"phi/F");
treeOut->Branch("dca", &tSum.dca ,"dca[2]/F");
treeOut->Branch("dcaErr", &tSum.dcaErr ,"dcaErr[2]/F");
treeOut->Branch("sigpti", &tSum.sigpti ,"sigpti/F");
treeOut->Branch("tpcChi2", &tSum.tpcChi2 ,"tpcChi2/F");
treeOut->Branch("trdChi2", &tSum.trdChi2 ,"trdChi2/F");
//
treeOut->Branch("nclITS", &tSum.nclITS ,"nclITS/b");
treeOut->Branch("nclITSF", &tSum.nclITSF ,"nclITSF/b");
treeOut->Branch("nclTPC", &tSum.nclTPC ,"nclTPC/b");
treeOut->Branch("nclTRD", &tSum.nclTRD ,"nclTRD/b");
//
treeOut->Branch("clITS", &tSum.clITS ,"clITS/b");
treeOut->Branch("clITSF", &tSum.clITSF ,"clITSF/b");
treeOut->Branch("clTRD", &tSum.clTRD ,"clTRD/b");
//
treeOut->Branch("mlt05", &tSum.mlt05 ,"mlt05/I");
//
treeOut->Branch("lbl", &tSum.lbl ,"lbl/I");
treeOut->Branch("lblTPC", &tSum.lblTPC ,"lblTPC/I");
treeOut->Branch("lblITS", &tSum.lblITS ,"lblITS/I");
//
treeOut->Branch("fFlags", &tSum.fFlags ,"fFlags/l");
treeOut->Branch("fMyBits",&tSum.fMyBits ,"fMyBits/l");
}
//_______________________________________________
void CloseTree()
{
treeOutFile->cd();
treeOut->Write();
delete treeOut;
treeOutFile->Close();
delete treeOutFile;
}