]>
Commit | Line | Data |
---|---|---|
3e87ef69 | 1 | // @(#) $Id$ |
e8541476 | 2 | |
b661165c | 3 | // Author: Anders Vestbo <mailto:vestbo@fi.uib.no> |
3e87ef69 | 4 | //*-- Copyright © ALICE HLT Group |
108615fc | 5 | |
118c26c3 | 6 | #include "AliL3StandardIncludes.h" |
b1ed0288 | 7 | #include <TObject.h> |
108615fc | 8 | #include <TFile.h> |
9 | #include <TH1.h> | |
10 | #include <TParticle.h> | |
11 | #include <TTree.h> | |
12 | #include <TClonesArray.h> | |
b1ed0288 | 13 | #include <TTree.h> |
14 | #include <TNtuple.h> | |
108615fc | 15 | |
4499ed26 | 16 | #include <AliRun.h> |
17 | #include <AliSimDigits.h> | |
18 | #include <AliTPC.h> | |
19 | #include <AliTPCcluster.h> | |
20 | #include <AliTPCClustersArray.h> | |
21 | #include <AliTPCClustersRow.h> | |
22 | #include <AliTPCParam.h> | |
23 | #include <AliComplexCluster.h> | |
b2a02bce | 24 | #include <AliStack.h> |
108615fc | 25 | |
0bd0c1ef | 26 | #if __GNUC__ == 3 |
118c26c3 | 27 | #include <fstream> |
28 | #include <iosfwd> | |
29 | #else | |
30 | #include <fstream.h> | |
31 | #endif | |
32 | ||
33 | #include "AliL3Logging.h" | |
108615fc | 34 | #include "AliL3Transform.h" |
35 | #include "AliL3SpacePointData.h" | |
36 | #include "AliL3Track.h" | |
37 | #include "AliL3FileHandler.h" | |
38 | #include "AliL3TrackArray.h" | |
39 | #include "AliL3Evaluate.h" | |
118c26c3 | 40 | |
0bd0c1ef | 41 | #if __GNUC__ == 3 |
118c26c3 | 42 | using namespace std; |
43 | #endif | |
108615fc | 44 | |
3e87ef69 | 45 | /** \class AliL3Evaluate |
46 | <pre> | |
b661165c | 47 | //_____________________________________________________________ |
48 | // AliL3Evaluate | |
49 | // | |
59260886 | 50 | // Evaluation class for tracking; plots, efficiencies etc.. |
84122e15 | 51 | // |
3e87ef69 | 52 | </pre> |
53 | */ | |
108615fc | 54 | |
55 | ClassImp(AliL3Evaluate) | |
56 | ||
57 | AliL3Evaluate::AliL3Evaluate() | |
b1ed0288 | 58 | { |
59 | //constructor | |
59260886 | 60 | Clear(); |
108615fc | 61 | } |
62 | ||
b2a02bce | 63 | AliL3Evaluate::AliL3Evaluate(Char_t *datapath,Int_t min_clusters,Int_t minhits,Double_t minpt,Double_t maxpt,Int_t *slice) |
b1ed0288 | 64 | { |
65 | //constructor | |
59260886 | 66 | Clear(); |
3e87ef69 | 67 | |
e0f4d6b2 | 68 | if(slice) |
69 | { | |
70 | fMinSlice=slice[0]; | |
71 | fMaxSlice=slice[1]; | |
72 | } | |
73 | else | |
74 | { | |
75 | fMinSlice=0; | |
76 | fMaxSlice=35; | |
77 | } | |
59260886 | 78 | |
3e87ef69 | 79 | sprintf(fPath,"%s",datapath); |
e0f4d6b2 | 80 | fMinPointsOnTrack = min_clusters; |
81 | fMinHitsFromParticle = minhits; | |
82 | fMinGoodPt = minpt; | |
b2a02bce | 83 | fMaxGoodPt = maxpt; |
59260886 | 84 | } |
85 | ||
86 | AliL3Evaluate::~AliL3Evaluate() | |
b1ed0288 | 87 | { |
88 | //destructor | |
59260886 | 89 | if(fGoodTracks) delete[] fGoodTracks; |
90 | if(fTracks) delete fTracks; | |
91 | if(fPtRes) delete fPtRes; | |
92 | if(fNGoodTracksPt) delete fNGoodTracksPt; | |
93 | if(fNFoundTracksPt) delete fNFoundTracksPt; | |
94 | if(fNFakeTracksPt) delete fNFakeTracksPt; | |
95 | if(fTrackEffPt) delete fTrackEffPt; | |
96 | if(fFakeTrackEffPt) delete fFakeTrackEffPt; | |
97 | if(fNGoodTracksEta) delete fNGoodTracksEta; | |
98 | if(fNFoundTracksEta) delete fNFoundTracksEta; | |
99 | if(fNFakeTracksEta) delete fNFakeTracksEta; | |
100 | if(fTrackEffEta) delete fTrackEffEta; | |
101 | if(fFakeTrackEffEta) delete fFakeTrackEffEta; | |
102 | if(fMcIndex) delete [] fMcIndex; | |
103 | if(fMcId) delete [] fMcId; | |
104 | if(fNtuppel) delete fNtuppel; | |
105 | if(fNtupleRes) delete fNtupleRes; | |
106 | ||
107 | for(Int_t s=0; s<=35; s++) | |
108 | for(Int_t p=0; p<6; p++) | |
109 | { | |
110 | //cout << s << " " << p <<endl; | |
111 | if(fClustersFile[s][p]) delete fClustersFile[s][p]; | |
112 | fClusters[s][p]=0; | |
113 | } | |
114 | } | |
115 | ||
116 | void AliL3Evaluate::Clear() | |
b1ed0288 | 117 | { |
118 | //clear | |
59260886 | 119 | fTracks = 0; |
120 | fMinSlice=0; | |
121 | fMaxSlice=0; | |
122 | fNFastPoints = 0; | |
123 | fMcIndex = 0; | |
124 | fMcId = 0; | |
125 | fGoodFound = 0; | |
126 | fGoodGen = 0; | |
127 | fMinGoodPt = 0; | |
128 | fMaxGoodPt = 0; | |
129 | fMinPointsOnTrack = 0; | |
130 | fMinHitsFromParticle = 0; | |
131 | fGoodTracks = 0; | |
132 | fMaxFalseClusters = 0.1; | |
133 | ||
b2a02bce | 134 | fNtuppel=0; |
59260886 | 135 | fPtRes=0; |
136 | fNGoodTracksPt = 0; | |
137 | fNFoundTracksPt = 0; | |
138 | fNFakeTracksPt = 0; | |
139 | fTrackEffPt = 0; | |
140 | fFakeTrackEffPt = 0; | |
141 | fNGoodTracksEta = 0; | |
142 | fNFoundTracksEta = 0; | |
143 | fNFakeTracksEta = 0; | |
144 | fTrackEffEta = 0; | |
145 | fFakeTrackEffEta = 0; | |
146 | fNtupleRes = 0; | |
147 | ||
b2a02bce | 148 | fStandardComparison=kTRUE; |
59260886 | 149 | for(Int_t s=0; s<=35; s++) |
150 | for(Int_t p=0; p<6; p++){ | |
151 | fClusters[s][p]=0; | |
152 | fClustersFile[s][p]=0; | |
153 | } | |
154 | sprintf(fPath,"./"); | |
3e87ef69 | 155 | } |
156 | ||
157 | void AliL3Evaluate::LoadData(Int_t event,Bool_t sp) | |
b1ed0288 | 158 | { |
159 | //load cluster points | |
e0f4d6b2 | 160 | Char_t fname[1024]; |
59260886 | 161 | |
108615fc | 162 | for(Int_t s=fMinSlice; s<=fMaxSlice; s++) |
163 | { | |
e0f4d6b2 | 164 | for(Int_t p=0; p<AliL3Transform::GetNPatches(); p++) |
108615fc | 165 | { |
3e87ef69 | 166 | Int_t patch; |
167 | if(sp==kTRUE) | |
168 | patch=-1; | |
169 | else | |
170 | patch=p; | |
171 | ||
59260886 | 172 | if(fClustersFile[s][p]) |
173 | delete fClustersFile[s][p]; | |
1f79afc0 | 174 | fClusters[s][p] = 0; |
59260886 | 175 | fClustersFile[s][p] = new AliL3FileHandler(); |
3e87ef69 | 176 | if(event<0) |
177 | sprintf(fname,"%s/points_%d_%d.raw",fPath,s,patch); | |
178 | else | |
179 | sprintf(fname,"%s/points_%d_%d_%d.raw",fPath,event,s,patch); | |
59260886 | 180 | if(!fClustersFile[s][p]->SetBinaryInput(fname)) |
108615fc | 181 | { |
182 | LOG(AliL3Log::kError,"AliL3Evaluation::Setup","File Open") | |
183 | <<"Inputfile "<<fname<<" does not exist"<<ENDLOG; | |
59260886 | 184 | delete fClustersFile[s][p]; |
185 | fClustersFile[s][p] = 0; | |
bc2f4f0e | 186 | continue; |
108615fc | 187 | } |
59260886 | 188 | fClusters[s][p] = (AliL3SpacePointData*)fClustersFile[s][p]->Allocate(); |
189 | fClustersFile[s][p]->Binary2Memory(fNcl[s][p],fClusters[s][p]); | |
190 | fClustersFile[s][p]->CloseBinaryInput(); | |
3e87ef69 | 191 | if(sp==kTRUE) |
192 | break; | |
108615fc | 193 | } |
194 | } | |
b2a02bce | 195 | |
3e87ef69 | 196 | sprintf(fname,"%s/tracks_%d.raw",fPath,event); |
108615fc | 197 | AliL3FileHandler *tfile = new AliL3FileHandler(); |
e0f4d6b2 | 198 | if(!tfile->SetBinaryInput(fname)){ |
bc2f4f0e | 199 | LOG(AliL3Log::kError,"AliL3Evaluation::Setup","File Open") |
e0f4d6b2 | 200 | <<"Inputfile "<<fname<<" does not exist"<<ENDLOG; |
bc2f4f0e | 201 | return; |
202 | } | |
3e87ef69 | 203 | if(fTracks) |
204 | delete fTracks; | |
108615fc | 205 | fTracks = new AliL3TrackArray(); |
206 | tfile->Binary2TrackArray(fTracks); | |
207 | tfile->CloseBinaryInput(); | |
b2a02bce | 208 | fTracks->QSort(); |
59260886 | 209 | delete tfile; |
108615fc | 210 | } |
211 | ||
de3c3890 | 212 | void AliL3Evaluate::AssignPIDs() |
b1ed0288 | 213 | { |
214 | //assign pid | |
59260886 | 215 | if(!fTracks) return; |
de3c3890 | 216 | fTracks->QSort(); |
217 | LOG(AliL3Log::kDebug,"AliL3Evaluate::AssignPIDs","Track Loop") | |
218 | <<"Assigning pid to the found tracks...."<<ENDLOG; | |
219 | for(Int_t i=0; i<fTracks->GetNTracks(); i++) | |
220 | { | |
221 | AliL3Track *track = (AliL3Track*)fTracks->GetCheckedTrack(i); | |
222 | if(!track) continue; | |
223 | if(track->GetNumberOfPoints() < fMinPointsOnTrack) | |
224 | track->SetPID(0); | |
225 | else { | |
226 | Float_t pid = GetTrackPID(track); | |
227 | track->SetPID(pid); | |
228 | } | |
229 | } | |
230 | } | |
8af8a456 | 231 | |
108615fc | 232 | void AliL3Evaluate::AssignIDs() |
b1ed0288 | 233 | { |
108615fc | 234 | //Assign MC id to the tracks. |
e0f4d6b2 | 235 | #ifndef do_mc |
236 | cerr<<"AliL3Evaluate::AssignIDs() : You need to compile with the do_mc flag!"<<endl; | |
237 | return; | |
238 | #endif | |
59260886 | 239 | if(!fTracks) return; |
3e87ef69 | 240 | fGoodFound=0; |
108615fc | 241 | fTracks->QSort(); |
242 | LOG(AliL3Log::kDebug,"AliL3Evaluate::AssignIDs","Track Loop") | |
243 | <<"Assigning MC id to the found tracks...."<<ENDLOG; | |
244 | for(Int_t i=0; i<fTracks->GetNTracks(); i++) | |
245 | { | |
246 | AliL3Track *track = (AliL3Track*)fTracks->GetCheckedTrack(i); | |
c0217812 | 247 | if(!track) continue; |
108615fc | 248 | if(track->GetNumberOfPoints() < fMinPointsOnTrack) break; |
23908b9b | 249 | |
23908b9b | 250 | fGoodFound++; |
c0217812 | 251 | Int_t tID = GetMCTrackLabel(track); |
108615fc | 252 | track->SetMCid(tID); |
108615fc | 253 | } |
3e87ef69 | 254 | //cout<<"Found "<<fGoodFound<<" good tracks "<<endl; |
108615fc | 255 | } |
256 | ||
de3c3890 | 257 | Float_t AliL3Evaluate::GetTrackPID(AliL3Track *track) |
b1ed0288 | 258 | { |
259 | //get track pid | |
de3c3890 | 260 | track->CalculateHelix(); |
261 | // Track dEdx | |
262 | Int_t nc=track->GetNHits(); | |
263 | UInt_t *hits = track->GetHitNumbers(); | |
264 | Float_t sampleDEdx[159]; | |
265 | for (Int_t iHit = 0; iHit < nc; iHit++) { | |
266 | UInt_t hitID = hits[iHit]; | |
267 | Int_t iSector = (hitID>>25) & 0x7f; | |
268 | Int_t patch = (hitID>>22) & 0x7; | |
269 | UInt_t position = hitID&0x3fffff; | |
270 | AliL3SpacePointData *points = fClusters[iSector][patch]; | |
271 | if(!points) continue; | |
272 | if(position>=fNcl[iSector][patch]) | |
273 | { | |
274 | LOG(AliL3Log::kError,"AliL3Evaluate::GetMCTrackLabel","Clusterarray") | |
275 | <<AliL3Log::kDec<<"ERROR"<<ENDLOG; | |
276 | continue; | |
277 | } | |
278 | UChar_t padrow = points[position].fPadRow; | |
279 | Float_t pWidth = AliL3Transform::GetPadPitchWidthLow(); | |
280 | if (padrow>63) | |
281 | pWidth = AliL3Transform::GetPadPitchWidthUp(); | |
282 | Float_t corr=1.; if (padrow>63) corr=0.67; | |
283 | sampleDEdx[iHit] = points[position].fCharge/pWidth*corr; | |
284 | Double_t crossingangle = track->GetCrossingAngle(padrow,iSector); | |
285 | Double_t s = sin(crossingangle); | |
286 | Double_t t = track->GetTgl(); | |
287 | sampleDEdx[iHit] *= sqrt((1-s*s)/(1+t*t)); | |
288 | } | |
289 | ||
290 | /* Cook dEdx */ | |
291 | Int_t i; | |
292 | Int_t swap;//stupid sorting | |
293 | do { | |
294 | swap=0; | |
295 | for (i=0; i<nc-1; i++) { | |
296 | if (sampleDEdx[i]<=sampleDEdx[i+1]) continue; | |
297 | Float_t tmp=sampleDEdx[i]; | |
298 | sampleDEdx[i]=sampleDEdx[i+1]; sampleDEdx[i+1]=tmp; | |
299 | swap++; | |
300 | } | |
301 | } while (swap); | |
302 | ||
303 | Double_t low=0.05; Double_t up=0.7; | |
304 | Int_t nl=Int_t(low*nc), nu=Int_t(up*nc); | |
305 | Float_t trackDEdx=0; | |
306 | for (i=nl; i<=nu; i++) trackDEdx += sampleDEdx[i]; | |
307 | trackDEdx /= (nu-nl+1); | |
308 | ||
37a5a5a9 | 309 | // cout<<" PID: "<<nc<<" "<<nl<<" "<<nu<<" "<<trackDEdx<<" "<<track->GetPt()<<endl; |
de3c3890 | 310 | return trackDEdx; |
311 | } | |
108615fc | 312 | |
313 | struct S {Int_t lab; Int_t max;}; | |
b1ed0288 | 314 | Int_t AliL3Evaluate::GetMCTrackLabel(AliL3Track *track) |
315 | { | |
108615fc | 316 | //Returns the MCtrackID of the belonging clusters. |
317 | //If MCLabel < 0, means that track is fake. | |
3e87ef69 | 318 | //Definitions are identical to offline. |
319 | //Fake track means: | |
320 | // - more than 10 percent of clusters are assigned incorrectly | |
321 | // - more than half of the innermost 10% of clusters were assigned incorrectly. | |
322 | ||
494fad94 | 323 | |
324 | #ifdef do_mc | |
108615fc | 325 | Int_t num_of_clusters = track->GetNumberOfPoints(); |
326 | S *s=new S[num_of_clusters]; | |
327 | Int_t i; | |
328 | for (i=0; i<num_of_clusters; i++) s[i].lab=s[i].max=0; | |
329 | UInt_t *hitnum = track->GetHitNumbers(); | |
330 | UInt_t id; | |
108615fc | 331 | |
108615fc | 332 | Int_t lab=123456789; |
333 | for (i=0; i<num_of_clusters; i++) | |
334 | { | |
335 | //Tricks to get the clusters belonging to this track: | |
336 | id = hitnum[i]; | |
337 | Int_t slice = (id>>25) & 0x7f; | |
338 | Int_t patch = (id>>22) & 0x7; | |
339 | UInt_t pos = id&0x3fffff; | |
340 | ||
341 | AliL3SpacePointData *points = fClusters[slice][patch]; | |
c0217812 | 342 | if(!points) continue; |
108615fc | 343 | if(pos>=fNcl[slice][patch]) |
344 | { | |
345 | LOG(AliL3Log::kError,"AliL3Evaluate::GetMCTrackLabel","Clusterarray") | |
346 | <<AliL3Log::kDec<<"ERROR"<<ENDLOG; | |
347 | continue; | |
348 | } | |
349 | ||
350 | //Get the label of the cluster: | |
3e87ef69 | 351 | lab=points[pos].fTrackID[0]; |
352 | ||
108615fc | 353 | Int_t j; |
354 | for (j=0; j<num_of_clusters; j++) | |
355 | if (s[j].lab==lab || s[j].max==0) break; | |
356 | s[j].lab=lab; | |
357 | s[j].max++; | |
358 | } | |
359 | ||
360 | Int_t max=0; | |
361 | for (i=0; i<num_of_clusters; i++) | |
362 | if (s[i].max>max) {max=s[i].max; lab=s[i].lab;} | |
363 | ||
3e87ef69 | 364 | if(lab == -1) |
365 | return -1; //If most clusters is -1, this is a noise track. | |
366 | if(lab < 0) | |
367 | cerr<<"AliL3Evaluate::GetMCTrackLabel : Track label negative :"<<lab<<endl; | |
368 | ||
108615fc | 369 | delete[] s; |
370 | ||
371 | for (i=0; i<num_of_clusters; i++) | |
372 | { | |
373 | id = hitnum[i]; | |
374 | Int_t slice = (id>>25) & 0x7f; | |
375 | Int_t patch = (id>>22) & 0x7; | |
376 | UInt_t pos = id&0x3fffff; | |
377 | ||
378 | AliL3SpacePointData *points = fClusters[slice][patch]; | |
c0217812 | 379 | if(!points) continue; |
108615fc | 380 | if(pos>=fNcl[slice][patch]) |
381 | { | |
382 | LOG(AliL3Log::kError,"AliL3Evaluate::GetMCTrackLabel","Clusterarray") | |
383 | <<AliL3Log::kDec<<"ERROR"<<ENDLOG; | |
384 | continue; | |
385 | } | |
386 | ||
355debe1 | 387 | if (abs(points[pos].fTrackID[1]) == lab || |
388 | abs(points[pos].fTrackID[2]) == lab ) max++; | |
108615fc | 389 | } |
390 | ||
3e87ef69 | 391 | |
392 | //Check if more than 10% of the clusters were assigned incorrectly: | |
e0f4d6b2 | 393 | if (1.-Float_t(max)/num_of_clusters > fMaxFalseClusters) |
108615fc | 394 | { |
395 | return -lab; | |
396 | } | |
3e87ef69 | 397 | else //Check if at least half of the 10% innermost clusters are assigned correctly. |
398 | { | |
399 | Int_t tail=Int_t(0.10*num_of_clusters); | |
400 | max=0; | |
401 | for (i=1; i<=tail; i++) | |
402 | { | |
403 | id = hitnum[num_of_clusters - i]; | |
404 | Int_t slice = (id>>25) & 0x7f; | |
405 | Int_t patch = (id>>22) & 0x7; | |
406 | UInt_t pos = id&0x3fffff; | |
407 | ||
408 | AliL3SpacePointData *points = fClusters[slice][patch]; | |
59260886 | 409 | if(!points) continue; |
3e87ef69 | 410 | if(lab == abs(points[pos].fTrackID[0]) || |
411 | lab == abs(points[pos].fTrackID[1]) || | |
412 | lab == abs(points[pos].fTrackID[2])) max++; | |
413 | } | |
414 | if (max < Int_t(0.5*tail)) return -lab; | |
415 | } | |
416 | ||
108615fc | 417 | return lab; |
494fad94 | 418 | #else //If we are running with mc_ids or not |
419 | return 0; | |
420 | #endif | |
421 | ||
108615fc | 422 | } |
423 | ||
c0217812 | 424 | void AliL3Evaluate::GetFastClusterIDs(Char_t *path) |
108615fc | 425 | { |
426 | //Get the MC id of space points in case of using the fast simulator. | |
59260886 | 427 | char name[256]; |
428 | sprintf(name,"%s/point_mc.dat",path); | |
429 | FILE *infile = fopen(name,"r"); | |
c0217812 | 430 | if(!infile) return; |
108615fc | 431 | Int_t hitid,hitmc,i; |
432 | ||
433 | for(i=0; ; i++) | |
434 | if(fscanf(infile,"%d %d",&hitid,&hitmc)==EOF) break; | |
108615fc | 435 | rewind(infile); |
c0217812 | 436 | fNFastPoints = i; |
437 | fMcId = new Int_t[fNFastPoints]; | |
438 | fMcIndex = new UInt_t[fNFastPoints]; | |
108615fc | 439 | |
c0217812 | 440 | for(i=0; i<fNFastPoints; i++) |
108615fc | 441 | { |
442 | if(fscanf(infile,"%d %d",&hitid,&hitmc)==EOF) break; | |
c0217812 | 443 | fMcId[i] = hitmc; |
444 | fMcIndex[i] = hitid; | |
108615fc | 445 | } |
446 | fclose(infile); | |
c0217812 | 447 | } |
448 | ||
e0f4d6b2 | 449 | void AliL3Evaluate::CreateHistos(Int_t nbin,Float_t xlow,Float_t xup) |
c0217812 | 450 | { |
451 | //Create the histograms | |
452 | ||
40896357 | 453 | LOG(AliL3Log::kInformational,"AliL3Evaluate::CreateHistos","Allocating") |
454 | <<"Creating histograms..."<<ENDLOG; | |
455 | ||
1f79afc0 | 456 | fNtuppel = new TNtuple("fNtuppel","Pt resolution","pt_gen:pt_found:nHits"); |
a8a3f5c2 | 457 | fNtuppel->SetDirectory(0); |
c0217812 | 458 | fPtRes = new TH1F("fPtRes","Relative Pt resolution",30,-10.,10.); |
459 | fNGoodTracksPt = new TH1F("fNGoodTracksPt","Good tracks vs pt",nbin,xlow,xup); | |
460 | fNFoundTracksPt = new TH1F("fNFoundTracksPt","Found tracks vs pt",nbin,xlow,xup); | |
461 | fNFakeTracksPt = new TH1F("fNFakeTracksPt","Fake tracks vs pt",nbin,xlow,xup); | |
462 | fTrackEffPt = new TH1F("fTrackEffPt","Tracking efficiency vs pt",nbin,xlow,xup); | |
463 | fFakeTrackEffPt = new TH1F("fFakeTrackEffPt","Efficiency for fake tracks vs pt",nbin,xlow,xup); | |
464 | ||
465 | fNGoodTracksEta = new TH1F("fNGoodTracksEta","Good tracks vs eta",20,-50,50); | |
466 | fNFoundTracksEta = new TH1F("fNFoundTracksEta","Found tracks vs eta",20,-50,50); | |
467 | fNFakeTracksEta = new TH1F("fNFakeTracksEta","Fake tracks vs eta",20,-50,50); | |
468 | fTrackEffEta = new TH1F("fTrackEffEta","Tracking efficienct vs eta",20,-50,50); | |
469 | fFakeTrackEffEta = new TH1F("fFakeTrackEffEta","Efficiency for fake tracks vs eta",20,-50,50); | |
e0f4d6b2 | 470 | |
471 | } | |
472 | ||
3e87ef69 | 473 | void AliL3Evaluate::GetGoodParticles(Char_t *path,Int_t event,Int_t *padrowrange) |
e0f4d6b2 | 474 | { |
475 | //Read the good particles from file. This file should already have been | |
476 | //generated by macro AliTPCComparison.C. | |
477 | ||
478 | Char_t filename[1024]; | |
3e87ef69 | 479 | if(event<0 && !padrowrange) |
a8a3f5c2 | 480 | sprintf(filename,"%s/good_tracks_tpc",path); |
3e87ef69 | 481 | else if(event>=0 && !padrowrange) |
482 | sprintf(filename,"%s/good_tracks_tpc_%d",path,event); | |
a8a3f5c2 | 483 | else |
3e87ef69 | 484 | sprintf(filename,"%s/good_tracks_tpc_%d_%d_%d",path,event,padrowrange[0],padrowrange[1]); |
e0f4d6b2 | 485 | ifstream in(filename); |
486 | if(!in) | |
487 | { | |
488 | cerr<<"AliL3Evaluate::GetGoodParticles : Problems opening file :"<<filename<<endl; | |
489 | return; | |
490 | } | |
491 | Int_t MaxTracks=20000; | |
3e87ef69 | 492 | if(fGoodTracks) |
493 | delete [] fGoodTracks; | |
494 | fGoodGen=0; | |
b1ed0288 | 495 | fGoodTracks = new AliGoodTrack[MaxTracks]; |
e0f4d6b2 | 496 | |
b2a02bce | 497 | if(fStandardComparison){ |
b1ed0288 | 498 | while (in>>fGoodTracks[fGoodGen].flabel>>fGoodTracks[fGoodGen].fcode>> |
499 | fGoodTracks[fGoodGen].fpx>>fGoodTracks[fGoodGen].fpy>>fGoodTracks[fGoodGen].fpz>> | |
500 | fGoodTracks[fGoodGen].fx>>fGoodTracks[fGoodGen].fy>>fGoodTracks[fGoodGen].fz) | |
b2a02bce | 501 | { |
b1ed0288 | 502 | fGoodTracks[fGoodGen].fnhits=-1; |
503 | fGoodTracks[fGoodGen].fsector=-1; | |
b2a02bce | 504 | fGoodGen++; |
505 | if (fGoodGen==MaxTracks) | |
506 | { | |
507 | cerr<<"AliL3Evaluate::GetGoodParticles : Too many good tracks !\n"; | |
508 | break; | |
509 | } | |
510 | } | |
511 | } else { | |
b1ed0288 | 512 | while (in>>fGoodTracks[fGoodGen].flabel>>fGoodTracks[fGoodGen].fcode>> |
513 | fGoodTracks[fGoodGen].fpx>>fGoodTracks[fGoodGen].fpy>>fGoodTracks[fGoodGen].fpz>> | |
514 | fGoodTracks[fGoodGen].fx>>fGoodTracks[fGoodGen].fy >>fGoodTracks[fGoodGen].fz>> | |
515 | fGoodTracks[fGoodGen].fnhits>>fGoodTracks[fGoodGen].fsector) | |
b2a02bce | 516 | { |
517 | fGoodGen++; | |
518 | if (fGoodGen==MaxTracks) | |
519 | { | |
520 | cerr<<"AliL3Evaluate::GetGoodParticles : Too many good tracks !\n"; | |
521 | break; | |
522 | } | |
523 | } | |
524 | } | |
c0217812 | 525 | } |
eeddc64d | 526 | |
e1a32fa5 | 527 | void AliL3Evaluate::FillEffHistos() |
b1ed0288 | 528 | { |
529 | //has to be modified for fakes. | |
530 | ||
e0f4d6b2 | 531 | if(!fGoodTracks) |
532 | { | |
533 | cerr<<"AliL3Evaluate::FillEffHistos : No good tracks"<<endl; | |
534 | return; | |
535 | } | |
59260886 | 536 | if(!fTracks) return; |
537 | ||
3e87ef69 | 538 | //cout<<"Comparing "<<fGoodGen<<" good tracks ..."<<endl; |
e1a32fa5 | 539 | for(Int_t i=0; i<fGoodGen; i++) |
c0217812 | 540 | { |
e0f4d6b2 | 541 | //cout<<"Checking particle "<<i<<endl; |
b2a02bce | 542 | if(!fStandardComparison) |
b1ed0288 | 543 | if(fGoodTracks[i].fnhits < fMinHitsFromParticle) continue; |
544 | Float_t ptg = TMath::Sqrt(fGoodTracks[i].fpx*fGoodTracks[i].fpx + fGoodTracks[i].fpy*fGoodTracks[i].fpy); | |
b2a02bce | 545 | if(ptg < fMinGoodPt || ptg > fMaxGoodPt) continue; |
b1ed0288 | 546 | Float_t pzg=fGoodTracks[i].fpz; |
c0217812 | 547 | Float_t dipangle=TMath::ATan2(pzg,ptg)*180./TMath::Pi(); |
b2a02bce | 548 | |
549 | //If we are only considering tracks on one side of the TPC: | |
550 | if(fMaxSlice <= 17) | |
551 | if(dipangle < 0) | |
552 | continue; | |
e0f4d6b2 | 553 | |
c0217812 | 554 | fNGoodTracksPt->Fill(ptg); |
555 | fNGoodTracksEta->Fill(dipangle); | |
556 | Int_t found = 0; | |
e0f4d6b2 | 557 | |
c0217812 | 558 | for(Int_t k=0; k<fTracks->GetNTracks(); k++) |
559 | { | |
560 | AliL3Track *track = fTracks->GetCheckedTrack(k); | |
561 | if(!track) continue; | |
562 | Int_t nHits = track->GetNumberOfPoints(); | |
563 | if(nHits < fMinPointsOnTrack) break; | |
c0217812 | 564 | Int_t tracklabel; |
565 | tracklabel = track->GetMCid(); | |
e0f4d6b2 | 566 | |
b1ed0288 | 567 | if(TMath::Abs(tracklabel) != fGoodTracks[i].flabel) continue; |
c0217812 | 568 | found=1; |
c0217812 | 569 | Float_t pt=track->GetPt(); |
b1ed0288 | 570 | if(tracklabel == fGoodTracks[i].flabel) |
3e87ef69 | 571 | { |
572 | fNFoundTracksPt->Fill(ptg); | |
573 | fNFoundTracksEta->Fill(dipangle); | |
574 | fNtuppel->Fill(ptg,pt,nHits); | |
575 | fPtRes->Fill((pt-ptg)/ptg*100.); | |
576 | } | |
577 | else | |
578 | { | |
579 | fNFakeTracksPt->Fill(ptg); | |
580 | fNFakeTracksEta->Fill(dipangle); | |
581 | } | |
582 | //fPtRes->Fill((pt-ptg)/ptg*100.); | |
583 | //fNtuppel->Fill(ptg,pt,nHits); | |
c0217812 | 584 | break; |
585 | ||
586 | } | |
3e87ef69 | 587 | //if(!found) |
b2a02bce | 588 | //cout<<"Track "<<fGoodTracks[i].label<<" was not found"<<endl; |
c0217812 | 589 | } |
590 | } | |
eeddc64d | 591 | |
e0f4d6b2 | 592 | void AliL3Evaluate::FillEffHistosNAIVE() |
355debe1 | 593 | { |
594 | //Fill the efficiency histograms. | |
595 | ||
596 | cout<<endl<<"Note: Doing NAIVE evaluation "<<endl; | |
597 | for(Int_t i=0; i<fGoodGen; i++) | |
598 | { | |
b2a02bce | 599 | if(!fStandardComparison) |
b1ed0288 | 600 | if(fGoodTracks[i].fnhits < fMinHitsFromParticle) continue; |
601 | Double_t ptg=TMath::Sqrt(fGoodTracks[i].fpx*fGoodTracks[i].fpx + fGoodTracks[i].fpy*fGoodTracks[i].fpy); | |
b2a02bce | 602 | if(ptg < fMinGoodPt || ptg > fMaxGoodPt) continue; |
b1ed0288 | 603 | Double_t pzg=fGoodTracks[i].fpz; |
355debe1 | 604 | Float_t dipangle=TMath::ATan2(pzg,ptg)*180./TMath::Pi(); |
605 | //printf("filling particle with pt %f and dipangle %f\n",ptg,dipangle); | |
606 | fNGoodTracksPt->Fill(ptg); | |
607 | fNGoodTracksEta->Fill(dipangle); | |
608 | ||
609 | } | |
610 | ||
611 | for(Int_t k=0; k<fTracks->GetNTracks(); k++) | |
612 | { | |
613 | AliL3Track *track = fTracks->GetCheckedTrack(k); | |
614 | if(!track) continue; | |
615 | Int_t nHits = track->GetNumberOfPoints(); | |
616 | if(nHits < fMinPointsOnTrack) break; | |
b2a02bce | 617 | if(track->GetPt()<fMinGoodPt || track->GetPt() > fMaxGoodPt) continue; |
355debe1 | 618 | if(fabs(track->GetPseudoRapidity())>0.9) continue; |
619 | ||
620 | fNFoundTracksPt->Fill(track->GetPt()); fNFoundTracksEta->Fill(track->GetPseudoRapidity()); | |
621 | //Float_t pt=track->GetPt(); | |
622 | //fPtRes->Fill((pt-ptg)/ptg*100.); | |
623 | //fNtuppel->Fill(ptg,pt,nHits); | |
355debe1 | 624 | } |
625 | } | |
c0217812 | 626 | |
3e87ef69 | 627 | void AliL3Evaluate::CalcEffHistos() |
b1ed0288 | 628 | { |
629 | //calc eff histos | |
3e87ef69 | 630 | |
c0217812 | 631 | Stat_t ngood=fNGoodTracksPt->GetEntries(); |
632 | Stat_t nfound=fNFoundTracksPt->GetEntries(); | |
633 | Stat_t nfake=fNFakeTracksPt->GetEntries(); | |
3e87ef69 | 634 | |
c0217812 | 635 | LOG(AliL3Log::kInformational,"AliL3Evaluate::FillEffHistos","Efficiency") |
636 | <<AliL3Log::kDec<<"There was "<<ngood<<" generated good tracks"<<ENDLOG; | |
637 | LOG(AliL3Log::kInformational,"AliL3Evaluate::FillEffHistos","Efficiency") | |
638 | <<AliL3Log::kDec<<"Found "<<nfound<<" tracks"<<ENDLOG; | |
639 | LOG(AliL3Log::kInformational,"AliL3Evaluate::FillEffHistos","Efficiency") | |
640 | <<AliL3Log::kDec<<"Integral efficiency is about "<<nfound/ngood*100<<ENDLOG; | |
641 | LOG(AliL3Log::kInformational,"AliL3Evaluate::FillEffHistos","Efficiency") | |
642 | <<AliL3Log::kDec<<"Fake tracks relative is about "<<nfake/ngood*100<<ENDLOG; | |
3e87ef69 | 643 | //LOG(AliL3Log::kInformational,"AliL3Evaluate::FillEffHistos","Efficiency") |
644 | //<<AliL3Log::kDec<<"Naive efficiency "<<(Double_t)fGoodFound/(Double_t)fGoodGen<<ENDLOG; | |
355debe1 | 645 | |
c0217812 | 646 | fNFoundTracksPt->Sumw2(); fNGoodTracksPt->Sumw2(); |
647 | fTrackEffPt->Divide(fNFoundTracksPt,fNGoodTracksPt,1,1.,"b"); | |
648 | fFakeTrackEffPt->Divide(fNFakeTracksPt,fNGoodTracksPt,1,1.,"b"); | |
649 | fTrackEffPt->SetMaximum(1.4); | |
650 | fTrackEffPt->SetXTitle("P_{T} [GeV]"); | |
651 | fTrackEffPt->SetLineWidth(2); | |
652 | fFakeTrackEffPt->SetFillStyle(3013); | |
653 | fTrackEffPt->SetLineColor(4); | |
654 | fFakeTrackEffPt->SetFillColor(2); | |
3e87ef69 | 655 | |
c0217812 | 656 | fNFoundTracksEta->Sumw2(); fNGoodTracksEta->Sumw2(); |
657 | fTrackEffEta->Divide(fNFoundTracksEta,fNGoodTracksEta,1,1.,"b"); | |
658 | fFakeTrackEffEta->Divide(fNFakeTracksEta,fNGoodTracksEta,1,1.,"b"); | |
659 | fTrackEffEta->SetMaximum(1.4); | |
660 | fTrackEffEta->SetXTitle("#lambda [degrees]"); | |
661 | fTrackEffEta->SetLineWidth(2); | |
662 | fFakeTrackEffEta->SetFillStyle(3013); | |
663 | fTrackEffEta->SetLineColor(4); | |
664 | fFakeTrackEffEta->SetFillColor(2); | |
108615fc | 665 | } |
666 | ||
667 | void AliL3Evaluate::Write2File(Char_t *outputfile) | |
668 | { | |
669 | //Write histograms to file: | |
670 | ||
e0f4d6b2 | 671 | TFile *of = TFile::Open(outputfile,"RECREATE"); |
108615fc | 672 | if(!of->IsOpen()) |
673 | { | |
674 | LOG(AliL3Log::kError,"AliL3Evaluate::Write2File","File Open") | |
675 | <<"Problems opening rootfile"<<ENDLOG; | |
676 | return; | |
677 | } | |
678 | ||
679 | of->cd(); | |
1f79afc0 | 680 | fNtuppel->Write(); |
108615fc | 681 | fPtRes->Write(); |
682 | fNGoodTracksPt->Write(); | |
683 | fNFoundTracksPt->Write(); | |
684 | fNFakeTracksPt->Write(); | |
685 | fTrackEffPt->Write(); | |
686 | fFakeTrackEffPt->Write(); | |
687 | fNGoodTracksEta->Write(); | |
688 | fNFoundTracksEta->Write(); | |
689 | fNFakeTracksEta->Write(); | |
690 | fTrackEffEta->Write(); | |
691 | fFakeTrackEffEta->Write(); | |
692 | ||
693 | of->Close(); | |
108615fc | 694 | } |
695 | ||
b2a02bce | 696 | TNtuple *AliL3Evaluate::GetNtuple() |
b1ed0288 | 697 | { |
698 | //get ntuple | |
b2a02bce | 699 | if(!fNtupleRes) |
700 | { | |
701 | fNtupleRes = new TNtuple("ntuppel","Residuals","residual_trans:residual_long:zHit:pt:dipangle:beta:padrow:nHits"); | |
702 | fNtupleRes->SetDirectory(0);//Bug in older version of root. | |
703 | } | |
704 | return fNtupleRes; | |
705 | } | |
1f79afc0 | 706 | |
b2a02bce | 707 | void AliL3Evaluate::CalculateResiduals() |
b1ed0288 | 708 | { |
709 | //calculate residuals | |
b2a02bce | 710 | TNtuple *ntuppel = GetNtuple(); |
3e87ef69 | 711 | |
712 | for(Int_t i=0; i<fTracks->GetNTracks(); i++) | |
1f79afc0 | 713 | { |
3e87ef69 | 714 | |
715 | AliL3Track *track = (AliL3Track*)fTracks->GetCheckedTrack(i); | |
716 | if(!track) continue; | |
b2a02bce | 717 | if(track->GetNHits() < fMinPointsOnTrack) break; |
3e87ef69 | 718 | |
719 | track->CalculateHelix(); | |
720 | UInt_t *hitnum = track->GetHitNumbers(); | |
721 | UInt_t id; | |
722 | ||
723 | Float_t xyz[3]; | |
724 | Int_t padrow; | |
725 | for(Int_t j=0; j<track->GetNumberOfPoints()-1; j++) | |
1f79afc0 | 726 | { |
3e87ef69 | 727 | id = hitnum[j]; |
728 | Int_t slice = (id>>25) & 0x7f; | |
729 | Int_t patch = (id>>22) & 0x7; | |
730 | UInt_t pos = id&0x3fffff; | |
b2a02bce | 731 | |
732 | //if(slice<18) continue; | |
1f79afc0 | 733 | |
3e87ef69 | 734 | AliL3SpacePointData *points = fClusters[slice][patch]; |
3e87ef69 | 735 | if(!points) |
1f79afc0 | 736 | { |
3e87ef69 | 737 | LOG(AliL3Log::kError,"AliL3Evaluate::CalculateResiduals","Clusterarray") |
738 | <<"No points at slice "<<slice<<" patch "<<patch<<" pos "<<pos<<ENDLOG; | |
739 | continue; | |
1f79afc0 | 740 | } |
3e87ef69 | 741 | if(pos>=fNcl[slice][patch]) |
742 | { | |
743 | LOG(AliL3Log::kError,"AliL3Evaluate::CalculateResiduals","Clusterarray") | |
744 | <<AliL3Log::kDec<<"ERROR"<<ENDLOG; | |
745 | continue; | |
746 | } | |
747 | ||
748 | xyz[0] = points[pos].fX; | |
749 | xyz[1] = points[pos].fY; | |
750 | xyz[2] = points[pos].fZ; | |
751 | padrow = points[pos].fPadRow; | |
5a31e9df | 752 | //AliL3Transform::Global2Local(xyz,slice,kTRUE); |
753 | AliL3Transform::Global2LocHLT(xyz,slice); | |
3e87ef69 | 754 | |
755 | Float_t angle = 0; | |
756 | AliL3Transform::Local2GlobalAngle(&angle,slice); | |
b2a02bce | 757 | if(!track->CalculateReferencePoint(angle,AliL3Transform::Row2X(padrow))) |
758 | { | |
759 | LOG(AliL3Log::kError,"AliL3Evaluate::CalculateResiduals","Crossing point") | |
760 | <<"Track does not crossing padrow "<<padrow<<" in slice "<<slice<<ENDLOG; | |
761 | continue; | |
762 | } | |
763 | ||
3e87ef69 | 764 | Float_t xyz_cross[3] = {track->GetPointX(),track->GetPointY(),track->GetPointZ()}; |
5a31e9df | 765 | //AliL3Transform::Global2Local(xyz_cross,slice,kTRUE); |
766 | AliL3Transform::Global2LocHLT(xyz_cross,slice); | |
3e87ef69 | 767 | |
768 | Double_t beta = track->GetCrossingAngle(padrow,slice); | |
769 | ||
770 | Double_t yres = xyz_cross[1] - xyz[1]; | |
771 | Double_t zres = xyz_cross[2] - xyz[2]; | |
3e87ef69 | 772 | Double_t dipangle = atan(track->GetTgl()); |
773 | ntuppel->Fill(yres,zres,xyz_cross[2],track->GetPt(),dipangle,beta,padrow,track->GetNumberOfPoints()); | |
774 | ||
1f79afc0 | 775 | } |
1f79afc0 | 776 | } |
1f79afc0 | 777 | } |
778 | ||
3e87ef69 | 779 | enum tagprimary {kPrimaryCharged = 0x4000}; |
780 | void AliL3Evaluate::EvaluatePoints(Char_t *rootfile,Char_t *exactfile,Char_t *tofile,Int_t nevent,Bool_t offline,Bool_t sp) | |
78127e35 | 781 | { |
e1a32fa5 | 782 | //Compare points to the exact crossing points of track and padrows. |
1b76fd18 | 783 | //The input file to this function, contains the exact clusters calculated |
784 | //in AliTPC::Hits2ExactClusters. | |
8af8a456 | 785 | |
5bfdc6ad | 786 | #ifndef do_mc |
787 | cerr<<"AliL3Evaluate::EvaluatePoints : Compile with do_mc flag!"<<endl; | |
3e87ef69 | 788 | return; |
5bfdc6ad | 789 | #else |
355debe1 | 790 | cout<<"Evaluating points"<<endl; |
3e87ef69 | 791 | TNtuple *ntuppel = new TNtuple("ntuppel_res","Cluster properties", |
792 | "slice:padrow:charge:resy:resz:zHit:pt:beta:sigmaY2:sigmaZ2:psigmaY2:psigmaZ2"); | |
8af8a456 | 793 | ntuppel->SetDirectory(0); |
78127e35 | 794 | |
3e87ef69 | 795 | TNtuple *ntuppel2 = new TNtuple("ntuppel_eff","Efficiency","slice:padrow:nfound:ngen"); |
796 | ntuppel2->SetDirectory(0); | |
797 | ||
798 | TFile *exfile = TFile::Open(rootfile); | |
355debe1 | 799 | if(!exfile) |
800 | { | |
3e87ef69 | 801 | cerr<<"Error opening rootfile "<<rootfile<<endl; |
802 | return; | |
355debe1 | 803 | } |
8af8a456 | 804 | gAlice = (AliRun*)exfile->Get("gAlice"); |
805 | if (!gAlice) | |
806 | { | |
807 | LOG(AliL3Log::kError,"AliL3Evaluate::InitMC","gAlice") | |
808 | <<"AliRun object non existing on file"<<ENDLOG; | |
3e87ef69 | 809 | return; |
8af8a456 | 810 | } |
3e87ef69 | 811 | |
5e0f9911 | 812 | AliTPCParam *param = (AliTPCParam*)exfile->Get(AliL3Transform::GetParamName()); |
e1a32fa5 | 813 | |
3e87ef69 | 814 | TFile *exact = TFile::Open(exactfile); |
815 | if(!exact) | |
78127e35 | 816 | { |
3e87ef69 | 817 | cerr<<"AliL3Evaluate::EvaluatePoints : Problems opening file :"<<exactfile<<endl; |
818 | return; | |
819 | } | |
820 | ||
b2a02bce | 821 | AliStack *astack=gAlice->Stack(); |
822 | ||
3e87ef69 | 823 | AliTPCClustersArray *arr=0; |
824 | for(Int_t event=0; event<nevent; event++) | |
825 | { | |
826 | LoadData(event,sp); | |
827 | exfile->cd(); | |
828 | if(arr) | |
829 | delete arr; | |
830 | Int_t nparticles = gAlice->GetEvent(event); | |
831 | Int_t nprimaries = 0;//FindPrimaries(nparticles); | |
832 | cout<<"Event "<<event<<" had "<<nparticles<<" particles and "<<nprimaries<<" primaries"<<endl; | |
833 | exact->cd(); | |
78127e35 | 834 | |
3e87ef69 | 835 | //Get the exact clusters from file: |
836 | AliTPCClustersArray *arr = new AliTPCClustersArray; | |
837 | arr->Setup(param); | |
838 | arr->SetClusterType("AliComplexCluster"); | |
839 | char treeName[500]; | |
840 | sprintf(treeName,"TreeCExact_%s_%d",param->GetTitle(),event); | |
841 | Bool_t clusterok = arr->ConnectTree(treeName);//Segment Tree (for offline clusters) | |
842 | if(!clusterok) {printf("AliL3Evaluate::EvaluatePoints : Error in clusterloading\n"); return;} | |
78127e35 | 843 | |
3e87ef69 | 844 | //cout<<"Entering loop with "<<(Int_t)arr->GetTree()->GetEntries()<<endl; |
845 | for(Int_t i=0; i<arr->GetTree()->GetEntries(); i++) | |
8af8a456 | 846 | { |
3e87ef69 | 847 | //Get the exact clusters for this row: |
848 | Int_t cursec,currow; | |
849 | AliSegmentID *s = arr->LoadEntry(i); | |
850 | param->AdjustSectorRow(s->GetID(),cursec,currow); | |
851 | ||
852 | AliTPCClustersRow *ro = (AliTPCClustersRow *)arr->GetRow(cursec,currow); | |
853 | TClonesArray *clusters = ro->GetArray(); | |
854 | int num_of_offline=clusters->GetEntriesFast(); | |
855 | ||
856 | //Get the found clusters: | |
857 | Int_t slice,padrow; | |
858 | AliL3Transform::Sector2Slice(slice,padrow,cursec,currow); | |
859 | if(slice < fMinSlice) continue; | |
860 | if(slice > fMaxSlice) break; | |
861 | ||
862 | Int_t patch = AliL3Transform::GetPatch(padrow); | |
863 | if(sp) | |
864 | patch=0; | |
865 | AliL3SpacePointData *points = fClusters[slice][patch]; | |
866 | if(!points) | |
867 | continue; | |
868 | ||
869 | //cout<<"Slice "<<slice<<" padrow "<<padrow<<" has "<<num_of_offline<<" clusters "<<endl; | |
870 | Int_t clustercount=0; | |
871 | Int_t crosscount=0; | |
e1a32fa5 | 872 | for(Int_t m=0; m<num_of_offline; m++) |
78127e35 | 873 | { |
e1a32fa5 | 874 | AliComplexCluster *cluster = (AliComplexCluster *)clusters->UncheckedAt(m); |
b2a02bce | 875 | #ifdef use_newio |
876 | Int_t mcId = cluster->GetTrack(0); | |
877 | #else | |
e1a32fa5 | 878 | Int_t mcId = cluster->fTracks[0]; |
b2a02bce | 879 | #endif |
294ee877 | 880 | if(mcId <0) continue; |
b2a02bce | 881 | |
882 | #ifdef use_newio | |
883 | if(cluster->GetY() < 1 || cluster->GetY() > AliL3Transform::GetNPads(padrow) - 2 || | |
884 | cluster->GetX() < 1 || cluster->GetX() > AliL3Transform::GetNTimeBins() - 2) | |
885 | continue; | |
886 | #else | |
3e87ef69 | 887 | if(cluster->fY < 1 || cluster->fY > AliL3Transform::GetNPads(padrow) - 2 || |
888 | cluster->fX < 1 || cluster->fX > AliL3Transform::GetNTimeBins() - 2) | |
e1a32fa5 | 889 | continue; |
b2a02bce | 890 | #endif |
3e87ef69 | 891 | Float_t xyz_ex[3]; |
892 | ||
b2a02bce | 893 | #ifdef use_newio |
894 | AliL3Transform::Raw2Local(xyz_ex,cursec,currow,cluster->GetY(),cluster->GetX()); | |
895 | #else | |
494fad94 | 896 | AliL3Transform::Raw2Local(xyz_ex,cursec,currow,cluster->fY,cluster->fX); |
b2a02bce | 897 | #endif |
8af8a456 | 898 | //In function AliTPC::Hits2ExactClusters the time offset is not included, |
899 | //so we have to substract it again here. | |
3e87ef69 | 900 | if(slice<18) |
901 | xyz_ex[2]-=AliL3Transform::GetZOffset(); | |
902 | else | |
903 | xyz_ex[2]+=AliL3Transform::GetZOffset(); | |
8af8a456 | 904 | |
3e87ef69 | 905 | //Outside our cone: |
906 | if(param->GetPadRowRadii(cursec,currow)<230./250.*fabs(xyz_ex[2])) | |
907 | continue; | |
908 | ||
b2a02bce | 909 | TParticle *part = astack->Particle(mcId); |
3e87ef69 | 910 | crosscount++; |
911 | ||
912 | if(part->Pt() < fMinGoodPt) continue; | |
913 | ||
914 | //Dont take secondaries, because in width calculation we assume primaries: | |
915 | //if(!(part->TestBit(kPrimaryCharged))) continue; | |
916 | if(part->GetFirstMother()>=0) continue; | |
917 | ||
918 | Int_t tempcount=0; | |
919 | for(UInt_t c=0; c<fNcl[slice][patch]; c++) | |
920 | { | |
921 | if((Int_t)points[c].fPadRow!=padrow) continue; | |
922 | Float_t xyz_cl[3] = {points[c].fX,points[c].fY,points[c].fZ}; | |
923 | ||
924 | if(!offline) | |
925 | AliL3Transform::Global2Local(xyz_cl,cursec); | |
926 | tempcount++; | |
927 | ||
928 | if(points[c].fTrackID[0] != mcId && | |
929 | points[c].fTrackID[1] != mcId && | |
930 | points[c].fTrackID[2] != mcId) | |
931 | continue; | |
932 | ||
933 | //Residuals: | |
934 | Float_t resy = xyz_cl[1] - xyz_ex[1]; | |
935 | Float_t resz = xyz_cl[2] - xyz_ex[2]; | |
936 | ||
937 | //Cluster shape | |
938 | Int_t charge = (Int_t)points[c].fCharge; | |
939 | Float_t beta = GetCrossingAngle(part,slice,padrow,xyz_ex); | |
940 | Double_t tanl = xyz_ex[2]/sqrt(xyz_ex[0]*xyz_ex[0]+xyz_ex[1]*xyz_ex[1]); | |
941 | Float_t psigmaY2 = AliL3Transform::GetParSigmaY2(padrow,xyz_ex[2],beta); | |
942 | Float_t psigmaZ2 = AliL3Transform::GetParSigmaZ2(padrow,xyz_ex[2],tanl); | |
943 | Float_t sigmaY2 = points[c].fSigmaY2; | |
944 | Float_t sigmaZ2 = points[c].fSigmaZ2; | |
945 | ntuppel->Fill(slice,padrow,charge,resy,resz,xyz_ex[2],part->Pt(),beta,sigmaY2,sigmaZ2,psigmaY2,psigmaZ2); | |
946 | } | |
947 | clustercount=tempcount; | |
78127e35 | 948 | } |
3e87ef69 | 949 | ntuppel2->Fill(slice,padrow,clustercount,crosscount); |
950 | arr->ClearRow(cursec,currow); | |
951 | } | |
78127e35 | 952 | } |
3e87ef69 | 953 | exfile->Close(); |
954 | exact->Close(); | |
e1a32fa5 | 955 | |
3e87ef69 | 956 | TFile *ofile = TFile::Open(tofile,"RECREATE"); |
957 | ntuppel->Write(); | |
958 | ntuppel2->Write(); | |
959 | ofile->Close(); | |
5bfdc6ad | 960 | #endif |
78127e35 | 961 | } |
355debe1 | 962 | |
3e87ef69 | 963 | void AliL3Evaluate::GetCFeff(Char_t *path,Char_t *outfile,Int_t nevent,Bool_t sp) |
78127e35 | 964 | { |
3e87ef69 | 965 | //Evaluate the cluster finder efficiency. |
78127e35 | 966 | |
3e87ef69 | 967 | #ifndef do_mc |
968 | cerr<<"AliL3Evaluate::GetCFeff : Compile with do_mc flag"<<endl; | |
969 | return; | |
970 | #else | |
971 | TNtuple *ntuppel = new TNtuple("ntuppel","Cluster finder efficiency","slice:row:ncrossings:nclusters"); | |
972 | ntuppel->SetDirectory(0); | |
355debe1 | 973 | |
3e87ef69 | 974 | Char_t filename[1024]; |
975 | sprintf(filename,"%s/alirunfile.root",path); | |
976 | TFile *rfile = TFile::Open(filename); | |
977 | gAlice = (AliRun*)rfile->Get("gAlice"); | |
b2a02bce | 978 | |
979 | AliStack *astack=gAlice->Stack(); | |
355debe1 | 980 | |
3e87ef69 | 981 | AliTPCParam *param = (AliTPCParam*)rfile->Get(AliL3Transform::GetParamName()); |
982 | ||
983 | Int_t zero=param->GetZeroSup(); | |
984 | ||
985 | sprintf(filename,"%s/digitfile.root",path); | |
986 | TFile *dfile = TFile::Open(filename); | |
355debe1 | 987 | |
3e87ef69 | 988 | for(Int_t event=0; event<nevent; event++) |
78127e35 | 989 | { |
3e87ef69 | 990 | LoadData(event,sp); |
991 | rfile->cd(); | |
992 | gAlice->GetEvent(event); | |
b2a02bce | 993 | Int_t np = astack->GetNtrack(); |
3e87ef69 | 994 | cout<<"Processing event "<<event<<" with "<<np<<" particles "<<endl; |
995 | dfile->cd(); | |
996 | sprintf(filename,"TreeD_75x40_100x60_150x60_%d",event); | |
997 | TTree *TD=(TTree*)gDirectory->Get(filename); | |
998 | AliSimDigits da, *digits=&da; | |
999 | TD->GetBranch("Segment")->SetAddress(&digits); | |
1000 | ||
1001 | Int_t crossed=0,recs=0; | |
1002 | Int_t *count = new Int_t[np]; //np number of particles. | |
1003 | Int_t i; | |
1004 | Float_t xyz[3]; | |
1005 | for (i=0; i<np; i++) count[i]=0; | |
1006 | ||
1007 | ||
1008 | Int_t sec,row,sl,sr; | |
1009 | for(Int_t i=0; i<(Int_t)TD->GetEntries(); i++) | |
78127e35 | 1010 | { |
3e87ef69 | 1011 | crossed=recs=0; |
1012 | if (!TD->GetEvent(i)) continue; | |
1013 | param->AdjustSectorRow(digits->GetID(),sec,row); | |
1014 | AliL3Transform::Sector2Slice(sl,sr,sec,row); | |
1015 | if(sl < fMinSlice) continue; | |
1016 | if(sl > fMaxSlice) break; | |
1017 | cout<<"Processing slice "<<sl<<" row "<<sr<<endl; | |
1018 | digits->First(); | |
355debe1 | 1019 | do { |
3e87ef69 | 1020 | Int_t it=digits->CurrentRow(), ip=digits->CurrentColumn(); |
1021 | Short_t dig = digits->GetDigit(it,ip); | |
355debe1 | 1022 | |
3e87ef69 | 1023 | if(dig<=param->GetZeroSup()) continue; |
494fad94 | 1024 | AliL3Transform::Raw2Local(xyz,sec,row,ip,it); |
3e87ef69 | 1025 | if(param->GetPadRowRadii(sec,row)<230./250.*fabs(xyz[2])) |
355debe1 | 1026 | continue; |
1027 | ||
3e87ef69 | 1028 | Int_t idx0=digits->GetTrackID(it,ip,0); |
1029 | Int_t idx1=digits->GetTrackID(it,ip,1); | |
1030 | Int_t idx2=digits->GetTrackID(it,ip,2); | |
355debe1 | 1031 | |
1032 | if (idx0>=0 && dig>=zero) count[idx0]+=1; | |
1033 | if (idx1>=0 && dig>=zero) count[idx1]+=1; | |
1034 | if (idx2>=0 && dig>=zero) count[idx2]+=1; | |
3e87ef69 | 1035 | } while (digits->Next()); |
355debe1 | 1036 | for (Int_t j=0; j<np; j++) |
78127e35 | 1037 | { |
b2a02bce | 1038 | TParticle *part = astack->Particle(j); |
3e87ef69 | 1039 | if(part->Pt() < fMinGoodPt) continue; |
1040 | if(part->GetFirstMother() >= 0) continue; | |
355debe1 | 1041 | if (count[j]>1) //at least two digits at this padrow |
494fad94 | 1042 | { |
1043 | crossed++; | |
1044 | count[j]=0; | |
1045 | } | |
355debe1 | 1046 | } |
3e87ef69 | 1047 | |
1048 | Int_t patch = AliL3Transform::GetPatch(sr); | |
1049 | if(sp==kTRUE) | |
1050 | patch=0; | |
1051 | AliL3SpacePointData *points = fClusters[sl][patch]; | |
1052 | if(!points) | |
1053 | continue; | |
1054 | for(UInt_t k=0; k<fNcl[sl][patch]; k++) | |
355debe1 | 1055 | { |
3e87ef69 | 1056 | if(points[k].fPadRow!=sr) continue; |
355debe1 | 1057 | recs++; |
78127e35 | 1058 | } |
3e87ef69 | 1059 | ntuppel->Fill(sl,sr,crossed,recs); |
78127e35 | 1060 | } |
494fad94 | 1061 | |
3e87ef69 | 1062 | TD->Delete(); |
1063 | delete[] count; | |
78127e35 | 1064 | } |
355debe1 | 1065 | TFile *file = TFile::Open(outfile,"RECREATE"); |
1066 | ntuppel->Write(); | |
1067 | file->Close(); | |
1068 | ||
3e87ef69 | 1069 | rfile->Close(); |
1070 | dfile->Close(); | |
1071 | #endif | |
1072 | } | |
1073 | ||
dd7d3870 | 1074 | Float_t AliL3Evaluate::GetCrossingAngle(TParticle *part,Int_t slice,Int_t /*padrow*/,Float_t *xyz) |
3e87ef69 | 1075 | { |
1076 | //Calculate the padrow crossing angle of the particle | |
1077 | ||
1078 | Double_t kappa = AliL3Transform::GetBField()*AliL3Transform::GetBFact()/part->Pt(); | |
1079 | ||
1080 | Double_t radius = 1/fabs(kappa); | |
1081 | if(part->GetPdgCode() > 0) kappa = -kappa; | |
1082 | ||
1083 | Float_t angl[1] = {part->Phi()}; | |
1084 | ||
1085 | AliL3Transform::Global2LocalAngle(angl,slice); | |
1086 | ||
1087 | Double_t charge = -1.*kappa; | |
1088 | ||
1089 | Double_t trackPhi0 = angl[0] + charge*0.5*AliL3Transform::Pi()/fabs(charge); | |
1090 | ||
1091 | Double_t x0=0; | |
1092 | Double_t y0=0; | |
1093 | Double_t xc = x0 - radius * cos(trackPhi0); | |
1094 | Double_t yc = y0 - radius * sin(trackPhi0); | |
1095 | ||
1096 | Double_t tangent[2]; | |
1097 | tangent[0] = -1.*(xyz[1] - yc)/radius; | |
1098 | tangent[1] = (xyz[0] - xc)/radius; | |
1099 | ||
1100 | Double_t perp_padrow[2] = {1,0}; //locally in slice | |
1101 | ||
1102 | Double_t cos_beta = fabs(tangent[0]*perp_padrow[0] + tangent[1]*perp_padrow[1]); | |
1103 | if(cos_beta > 1) cos_beta=1; | |
1104 | return acos(cos_beta); | |
78127e35 | 1105 | } |
355debe1 | 1106 | |
3e87ef69 | 1107 | Int_t AliL3Evaluate::FindPrimaries(Int_t nparticles) |
1108 | { | |
1109 | // cuts: | |
1110 | Double_t vertcut = 0.001; | |
1111 | Double_t decacut = 3.; | |
1112 | Double_t timecut = 0.; | |
1113 | Int_t nprch1=0; | |
b2a02bce | 1114 | AliStack *astack=gAlice->Stack(); |
1115 | TParticle * part = astack->Particle(0); | |
3e87ef69 | 1116 | Double_t xori = part->Vx(); |
1117 | Double_t yori = part->Vy(); | |
1118 | Double_t zori = part->Vz(); | |
1119 | for(Int_t iprim = 0; iprim<nparticles; iprim++){ //loop on tracks | |
1120 | ||
b2a02bce | 1121 | part = astack->Particle(iprim); |
62bb4b3d | 1122 | const char * xxx=strstr(part->GetName(),"XXX"); |
3e87ef69 | 1123 | if(xxx)continue; |
1124 | ||
1125 | TParticlePDG *ppdg = part->GetPDG(); | |
1126 | if(TMath::Abs(ppdg->Charge())!=3)continue; // only charged (no quarks) | |
1127 | ||
1128 | Double_t dist=TMath::Sqrt((part->Vx()-xori)*(part->Vx()-xori)+(part->Vy()-yori)*(part->Vy()-yori)+(part->Vz()-zori)*(part->Vz()-zori)); | |
1129 | if(dist>vertcut)continue; // cut on the vertex | |
1130 | ||
1131 | if(part->T()>timecut)continue; | |
1132 | ||
1133 | Double_t ptot=TMath::Sqrt(part->Px()*part->Px()+part->Py()*part->Py()+part->Pz()*part->Pz()); | |
1134 | if(ptot==(TMath::Abs(part->Pz())))continue; // no beam particles | |
1135 | ||
1136 | Bool_t prmch = kTRUE; // candidate primary track | |
1137 | Int_t fidau=part->GetFirstDaughter(); // cut on daughters | |
1138 | Int_t lasdau=0; | |
1139 | Int_t ndau=0; | |
1140 | if(fidau>=0){ | |
1141 | lasdau=part->GetLastDaughter(); | |
1142 | ndau=lasdau-fidau+1; | |
1143 | } | |
1144 | if(ndau>0){ | |
1145 | for(Int_t j=fidau;j<=lasdau;j++){ | |
b2a02bce | 1146 | TParticle *dau=astack->Particle(j); |
3e87ef69 | 1147 | Double_t distd=TMath::Sqrt((dau->Vx()-xori)*(dau->Vx()-xori)+(dau->Vy()-yori)*(dau->Vy()-yori)+(dau->Vz()-zori)*(dau->Vz()-zori)); |
1148 | if(distd<decacut)prmch=kFALSE; // eliminate if the decay is near the vertex | |
1149 | } | |
1150 | } | |
1151 | ||
1152 | if(prmch){ | |
1153 | nprch1++; | |
1154 | part->SetBit(kPrimaryCharged); | |
1155 | } | |
1156 | } | |
1157 | ||
1158 | return nprch1; | |
1159 | } |