]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/src/AliL3Evaluate.cxx
Set bits for kinematics selection.
[u/mrichter/AliRoot.git] / HLT / src / AliL3Evaluate.cxx
CommitLineData
108615fc 1//Author: Anders Strand Vestbo
2//Last Modified: 5.01.2001
3
4#include <stdio.h>
e170e0f9 5#include <math.h>
40896357 6#include <fstream.h>
108615fc 7#include <TFile.h>
8#include <TH1.h>
9#include <TParticle.h>
10#include <TTree.h>
11#include <TClonesArray.h>
12
13#include "AliRun.h"
14#include "AliSimDigits.h"
15#include "AliTPC.h"
16#include "AliTPCClustersArray.h"
17#include "AliTPCClustersRow.h"
18#include "AliTPCcluster.h"
19#include "AliTPCParam.h"
e1a32fa5 20#include "AliComplexCluster.h"
108615fc 21
1f79afc0 22#include "AliL3Defs.h"
108615fc 23#include "AliL3Transform.h"
24#include "AliL3SpacePointData.h"
25#include "AliL3Track.h"
26#include "AliL3FileHandler.h"
27#include "AliL3TrackArray.h"
28#include "AliL3Evaluate.h"
29#include "AliL3Logging.h"
30
31//AliL3Evaluate
32//Class for tracking evaluation.
33
34ClassImp(AliL3Evaluate)
35
36AliL3Evaluate::AliL3Evaluate()
37{
e1a32fa5 38 fDigitsFile = NULL;
108615fc 39 fTracks = NULL;
40 fMCclusterfile = NULL;
c0217812 41 fNFastPoints = 0;
42 fMcIndex = 0;
43 fMcId = 0;
1f79afc0 44 fMinSlice=0;
45 fMaxSlice=0;
23908b9b 46 fTransform = new AliL3Transform();
108615fc 47}
48
40896357 49AliL3Evaluate::AliL3Evaluate(Char_t *mcfile,Int_t *slice)
108615fc 50{
51 //Normal constructor. Input are the rootfile containing the
52 //original MC information of the simulated event.
53
e1a32fa5 54 fEventFile = new TFile(mcfile,"READ");
40896357 55
e1a32fa5 56 fParam = (AliTPCParam*)fEventFile->Get("75x40_100x60");
108615fc 57 fTransform = new AliL3Transform();
58
59 fMinSlice = slice[0];
60 fMaxSlice = slice[1];
e170e0f9 61 fMinGoodPt = 0.1;
23908b9b 62 fNoOverlap = kFALSE;
108615fc 63}
64
1f79afc0 65AliL3Evaluate::AliL3Evaluate(Int_t *slice)
66{
78127e35 67 //ctor to use if you do not need any rootfile.
68
1f79afc0 69
70 fMinSlice = slice[0];
71 fMaxSlice = slice[1];
72 fTransform = new AliL3Transform();
73
74}
75
108615fc 76AliL3Evaluate::~AliL3Evaluate()
77{
c0217812 78 if(fDigitsTree) fDigitsTree->Delete();
e1a32fa5 79 if(fDigitsFile) {
80 fDigitsFile->Close();
81 delete fDigitsFile;
c0217812 82 }
83 if(fTransform) delete fTransform;
84 if(fTracks) delete fTracks;
85 if(fPtRes) delete fPtRes;
86 if(fNGoodTracksPt) delete fNGoodTracksPt;
87 if(fNFoundTracksPt) delete fNFoundTracksPt;
88 if(fNFakeTracksPt) delete fNFakeTracksPt;
89 if(fTrackEffPt) delete fTrackEffPt;
90 if(fFakeTrackEffPt) delete fFakeTrackEffPt;
91 if(fNGoodTracksEta) delete fNGoodTracksEta;
92 if(fNFoundTracksEta) delete fNFoundTracksEta;
93 if(fNFakeTracksEta) delete fNFakeTracksEta;
94 if(fTrackEffEta) delete fTrackEffEta;
95 if(fFakeTrackEffEta) delete fFakeTrackEffEta;
96 if(fMcIndex) delete [] fMcIndex;
97 if(fMcId) delete [] fMcId;
1f79afc0 98 if(fNtuppel) delete fNtuppel;
108615fc 99}
100
bc2f4f0e 101void AliL3Evaluate::Setup(Char_t *trackfile,Char_t *path)
108615fc 102{
108615fc 103 //Read in the hit and track information from produced files.
104
23908b9b 105 fGoodFound = 0;
106 fGoodGen = 0;
108615fc 107 Char_t fname[256];
40896357 108 AliL3FileHandler *clusterfile[36][6];
108615fc 109 for(Int_t s=fMinSlice; s<=fMaxSlice; s++)
110 {
40896357 111 for(Int_t p=0; p<6; p++)
108615fc 112 {
1f79afc0 113 fClusters[s][p] = 0;
108615fc 114 clusterfile[s][p] = new AliL3FileHandler();
bc2f4f0e 115 sprintf(fname,"%s/points_%d_%d.raw",path,s,p);
108615fc 116 if(!clusterfile[s][p]->SetBinaryInput(fname))
117 {
118 LOG(AliL3Log::kError,"AliL3Evaluation::Setup","File Open")
119 <<"Inputfile "<<fname<<" does not exist"<<ENDLOG;
bc2f4f0e 120 delete clusterfile[s][p];
121 clusterfile[s][p] = 0;
122 continue;
108615fc 123 }
124 fClusters[s][p] = (AliL3SpacePointData*)clusterfile[s][p]->Allocate();
125 clusterfile[s][p]->Binary2Memory(fNcl[s][p],fClusters[s][p]);
126 clusterfile[s][p]->CloseBinaryInput();
127 }
128 }
78127e35 129
23908b9b 130
108615fc 131 AliL3FileHandler *tfile = new AliL3FileHandler();
bc2f4f0e 132 if(!tfile->SetBinaryInput(trackfile)){
133 LOG(AliL3Log::kError,"AliL3Evaluation::Setup","File Open")
134 <<"Inputfile "<<trackfile<<" does not exist"<<ENDLOG;
135 return;
136 }
108615fc 137 fTracks = new AliL3TrackArray();
138 tfile->Binary2TrackArray(fTracks);
139 tfile->CloseBinaryInput();
140 delete tfile;
bc2f4f0e 141}
142
40896357 143void AliL3Evaluate::SetupSlow(Char_t *trackfile,Char_t *digitsfile,Char_t *path)
bc2f4f0e 144{
145 //Setup for using the slow simulator.
146
40896357 147 fDigitsFile = new TFile(digitsfile,"READ");
148 if(!fDigitsFile->IsOpen())
149 {
150 LOG(AliL3Log::kError,"AliL3Evaluate::SetupSlow","File Open")
151 <<"Inputfile "<<digitsfile<<" does not exist"<<ENDLOG;
152 return;
153 }
bc2f4f0e 154 fIsSlow = true;
155 Setup(trackfile,path);
108615fc 156
e1a32fa5 157 if(!InitMC())
bc2f4f0e 158 LOG(AliL3Log::kError,"AliL3Evaluation::SetupSlow","Digits Tree")
159 <<"Error setting up digits tree"<<ENDLOG;
e1a32fa5 160
108615fc 161}
162
bc2f4f0e 163void AliL3Evaluate::SetupFast(Char_t *trackfile,Char_t *mcClusterfile,Char_t *path)
108615fc 164{
165 //Setup for using the fast simulator.
166
167 fIsSlow = false;
c0217812 168 GetFastClusterIDs(path);
108615fc 169
170 fMCclusterfile = new TFile(mcClusterfile);
171 if(!fMCclusterfile->IsOpen())
172 LOG(AliL3Log::kError,"AliL3Evaluation::SetupFast","File Open")
173 <<"Inputfile "<<mcClusterfile<<" does not exist"<<ENDLOG;
174
bc2f4f0e 175 Setup(trackfile,path);
e1a32fa5 176 InitMC();
108615fc 177}
178
e1a32fa5 179Bool_t AliL3Evaluate::InitMC()
108615fc 180{
e1a32fa5 181 if(fIsSlow)
108615fc 182 {
e1a32fa5 183 fDigitsFile->cd();
40896357 184 fDigitsTree = (TTree*)fDigitsFile->Get("TreeD_75x40_100x60_0");
185 if(!fDigitsTree)
186 {
187 LOG(AliL3Log::kError,"AliL3Evaluate::InitMC","Digits Tree")
188 <<AliL3Log::kHex<<"Error getting digitstree "<<(Int_t)fDigitsTree<<ENDLOG;
189 return false;
190 }
e1a32fa5 191 fDigitsTree->GetBranch("Segment")->SetAddress(&fDigits);
192 for(Int_t i=0; i<fDigitsTree->GetEntries(); i++)
193 {
194 if(!fDigitsTree->GetEvent(i)) continue;
195 Int_t se,ro,slice,slicerow;
196 fParam->AdjustSectorRow(fDigits->GetID(),se,ro);
197 fTransform->Sector2Slice(slice,slicerow,se,ro);
198 fRowid[slice][slicerow] = i;
199 }
108615fc 200 }
201
e1a32fa5 202 fEventFile->cd();
40896357 203 gAlice = (AliRun*)fEventFile->Get("gAlice");
108615fc 204 if (!gAlice)
205 {
40896357 206 LOG(AliL3Log::kError,"AliL3Evaluate::InitMC","gAlice")
108615fc 207 <<"AliRun object non existing on file"<<ENDLOG;
208 return false;
209 }
210
211 gAlice->GetEvent(0);
e1a32fa5 212
108615fc 213 return true;
e1a32fa5 214
108615fc 215}
216
217
e1a32fa5 218
40896357 219void AliL3Evaluate::DefineGoodTracks(Int_t *slice,Int_t *padrow,Int_t good_number,Char_t *fname)
108615fc 220{
221 //Loop over MC particles, and mark the good ones
222 //(which the tracker should find...)
e1a32fa5 223
40896357 224
225 ifstream in(fname);
226 if(in)
227 {
228 LOG(AliL3Log::kInformational,"AliL3Evaluate::DefineGoodTracks","infile")
229 <<"Reading good particles from file "<<fname<<ENDLOG;
230 while (in>>fGoodTracks[fGoodGen].label>>fGoodTracks[fGoodGen].code>>
231 fGoodTracks[fGoodGen].px>>fGoodTracks[fGoodGen].py>>fGoodTracks[fGoodGen].pz>>
232 fGoodTracks[fGoodGen].pt)
233 {
234 fGoodGen++;
235 if (fGoodGen==15000)
236 {
237 LOG(AliL3Log::kWarning,"AliL3Evaluate::DefineGoodTracks","fGoodGen")
238 <<"Too many good tracks"<<ENDLOG;
239 break;
240 }
241 }
242 if (!in.eof()) cerr<<"Read error (good_tracks_tpc) !\n";
243 return;
244 }
245
246
108615fc 247 AliTPC *TPC = (AliTPC*)gAlice->GetDetector("TPC");
e1a32fa5 248
108615fc 249 TPC->SetParam(fParam);
e1a32fa5 250
108615fc 251 Int_t ver = TPC->IsVersion();
252 LOG(AliL3Log::kInformational,"AliL3Evaluate::DefineGoodTracks","TPC version")
253 <<"TPC version "<<ver<<" found on file"<<ENDLOG;
254
108615fc 255 Int_t zero=TPC->GetParam()->GetZeroSup();
256
e1a32fa5 257 Int_t np = gAlice->GetNtrack();
108615fc 258 Int_t *good = new Int_t[np];
259 for(Int_t ii=0; ii<np; ii++)
260 good[ii] = 0;
261
262 if(ver==1)
263 {
264 if(fIsSlow)
265 LOG(AliL3Log::kError,"AliL3Evaluate::DefineGoodTracks","TPC version")
266 <<"TPC version "<<ver<<" does not match."<<ENDLOG;
267 fMCclusterfile->cd();
268 AliTPCClustersArray carray;
269 carray.Setup(fParam);
270 carray.SetClusterType("AliTPCcluster");
40896357 271 Char_t cname[100];
272 Int_t eventn = 0;
273 sprintf(cname,"TreeC_TPC_%d",eventn);
274 Bool_t clusterok = carray.ConnectTree(cname);
108615fc 275 if(!clusterok)
276 LOG(AliL3Log::kError,"AliL3Evaluate::DefineGoodTracks","Cluster Array")
277 <<"Error loading clusters from rootfile"<<ENDLOG;
78127e35 278
bc2f4f0e 279 for(Int_t i=0; i<carray.GetTree()->GetEntries(); i++)
108615fc 280 {
281 Int_t sec,row,sl,lr;
282 AliSegmentID *s = carray.LoadEntry(i);
283 fParam->AdjustSectorRow(s->GetID(),sec,row);
284 fTransform->Sector2Slice(sl,lr,sec,row);
285
e1a32fa5 286 if(sl != slice[0]) {carray.ClearRow(sec,row); continue;}
bc2f4f0e 287 if(lr < padrow[0]) {carray.ClearRow(sec,row); continue;}
288 if(lr > padrow[1]) {carray.ClearRow(sec,row); continue;}
108615fc 289 AliTPCClustersRow *cRow = carray.GetRow(sec,row);
290 for(Int_t j=0; j<cRow->GetArray()->GetEntriesFast(); j++)
291 {
292 AliTPCcluster *cluster=(AliTPCcluster*)(*cRow)[j];
293 Int_t lab=cluster->GetLabel(0);
294 if(lab<0) continue;
295 lab=TMath::Abs(lab);
296 good[lab]++;
297 }
298 if(carray.GetRow(sec,row))
299 carray.ClearRow(sec,row);
300 }
301 }
302 else if(ver==2)
303 {
304 if(!fIsSlow)
305 LOG(AliL3Log::kError,"AliL3Evaluate::DefineGoodTracks","TPC version")
306 <<"TPC version "<<ver<<" does not match."<<ENDLOG;
307 Int_t *count = new Int_t[np]; //np number of particles.
308 Int_t i;
309 for (i=0; i<np; i++) count[i]=0;
e1a32fa5 310 for(Int_t sl=slice[0]; sl<=slice[1]; sl++)
311 {
312 for (i=padrow[0]; i<=padrow[1]; i++) {
313 Int_t index = fRowid[sl][i];
314 if (!fDigitsTree->GetEvent(index)) continue;
315 Int_t sec,row;
316 fParam->AdjustSectorRow(fDigits->GetID(),sec,row);
317 fDigits->First();
318 do {
319 Int_t it=fDigits->CurrentRow(), ip=fDigits->CurrentColumn();
320 Short_t dig = fDigits->GetDigit(it,ip);
321 Int_t idx0=fDigits->GetTrackID(it,ip,0);
322 Int_t idx1=fDigits->GetTrackID(it,ip,1);
323 Int_t idx2=fDigits->GetTrackID(it,ip,2);
e170e0f9 324
e1a32fa5 325 if (idx0>=0 && dig>=zero) count[idx0]+=1;
326 if (idx1>=0 && dig>=zero) count[idx1]+=1;
327 if (idx2>=0 && dig>=zero) count[idx2]+=1;
328 } while (fDigits->Next());
329
330 for (Int_t j=0; j<np; j++)
331 {
332 if (count[j]>1) //at least two digits at this padrow
333 good[j]++;
334
335 count[j]=0;
336 }
108615fc 337 }
108615fc 338 }
108615fc 339 delete[] count;
340 }
e1a32fa5 341
108615fc 342 else
343 {
344 LOG(AliL3Log::kError,"AliL3Evaluation::FillEffHistos","TPC version")
345 <<"No valid TPC version found"<<ENDLOG;
e1a32fa5 346 return;
108615fc 347 }
348
e1a32fa5 349
350 //The following code has been taken from offlinemacro->AliTPCComparison.C
351
352 TTree *TH=gAlice->TreeH();
353 Int_t npart=(Int_t)TH->GetEntries();
e1a32fa5 354 Int_t max = 15000;
355 while (npart--) {
356 AliTPChit *hit0=0;
357
40896357 358 TPC->ResetHits();
359 TH->GetEvent(npart);
360 AliTPChit * hit = (AliTPChit*) TPC->FirstHit(-1);
361 while (hit){
362 if (hit->fQ==0.) break;
363 hit = (AliTPChit*) TPC->NextHit();
364 }
365 if (hit) {
366 hit0 = new AliTPChit(*hit); //Make copy of hit
367 hit = hit0;
368 }
369 else continue;
370 AliTPChit *hit1=(AliTPChit*)TPC->NextHit();
371 if (hit1==0) continue;
372 if (hit1->fQ != 0.) continue;
373 Int_t i=hit->Track();
374 TParticle *p = (TParticle*)gAlice->Particle(i);
375
376 //printf("Checking particle %d with code %d\n",i,p->GetPdgCode());
377 if (p->GetFirstMother()>=0) continue; //secondary particle
378 if (good[i] < good_number) continue;
379 if (p->Pt()<fMinGoodPt) continue;
380 if (TMath::Abs(p->Pz()/p->Pt())>0.999) continue;
381 printf("Found good particle %d, nHits %d\n",i,good[i]);
382
383 fGoodTracks[fGoodGen].label=i;
384 fGoodTracks[fGoodGen].code=p->GetPdgCode();
385 //**** px py pz - in global coordinate system, x y z - in local !
386 fGoodTracks[fGoodGen].px=hit->X(); fGoodTracks[fGoodGen].py=hit->Y(); fGoodTracks[fGoodGen].pz=hit->Z();
387 fGoodTracks[fGoodGen].pt = p->Pt();
388 fGoodGen++;
389 //nt++;
390 if (hit0) delete hit0;
391 if (fGoodGen==max) {cerr<<"Too many good tracks !n"; break;}
392 }
e170e0f9 393
108615fc 394 delete [] good;
40896357 395
396 LOG(AliL3Log::kInformational,"AliL3Evaluate::DefineGoodParticles","Eval")
397 <<AliL3Log::kDec<<"Found "<<fGoodGen<<"good tracks"<<ENDLOG;
398
399 ofstream out(fname);
400 if(out)
401 {
402 for (Int_t ngd=0; ngd<fGoodGen; ngd++)
403 out<<fGoodTracks[ngd].label<<' '<<fGoodTracks[ngd].code<<' '<<
404 fGoodTracks[ngd].px<<' '<<fGoodTracks[ngd].py<<' '<<fGoodTracks[ngd].pz<<' '<<
405 fGoodTracks[ngd].pt<<endl;
406
407 }
408 else
409 LOG(AliL3Log::kError,"AliL3Evaluate::DefineGoodParticles","file")
410 <<"Can not open file containing good tracks"<<ENDLOG;
411
412 out.close();
413
108615fc 414}
415
416void AliL3Evaluate::EvaluatePatch(Int_t slice,Int_t patch,Int_t min_points,Int_t good_number)
417{
418 //Make efficiency plots for tracking on patch level (before any merging).
419
40896357 420 Int_t row[6][2] = {{ 0, 45},{46,77},{78,109},{110,141},{142,175}};
e1a32fa5 421 Int_t sl[2] ={slice,slice};
422 DefineGoodTracks(sl,row[patch],good_number);
108615fc 423 SetMinPoints(min_points);
424 AssignIDs();
bc2f4f0e 425 CreateHistos();
e1a32fa5 426 FillEffHistos();
bc2f4f0e 427 CalcEffHistos();
108615fc 428}
429
430void AliL3Evaluate::EvaluateSlice(Int_t slice,Int_t min_points,Int_t good_number)
431{
432 //Make efficiency plots for tracking on a slice (after merging).
433 //min_points = minimum points on track to be considered for evaluation
434 //good_number = minimum hits (padrows) produced by simulated track for consideration.
435
ae97a0b9 436 Int_t row[2] = {0,175};
e1a32fa5 437 Int_t sl[2] ={slice,slice};
438 DefineGoodTracks(sl,row,good_number);
23908b9b 439
108615fc 440 SetMinPoints(min_points);
23908b9b 441
108615fc 442 AssignIDs();
bc2f4f0e 443 CreateHistos();
e1a32fa5 444 FillEffHistos();
bc2f4f0e 445 CalcEffHistos();
108615fc 446}
447
40896357 448void AliL3Evaluate::EvaluateGlobal(Int_t min_points,Int_t good_number,Char_t *fname)
108615fc 449{
450 //Make efficiency plots for tracking on several slices.
bc2f4f0e 451
ae97a0b9 452 Int_t row[2] = {0,175};
bc2f4f0e 453 SetMinPoints(min_points);
e1a32fa5 454 Int_t slice[2] = {fMinSlice,fMaxSlice};
40896357 455 DefineGoodTracks(slice,row,good_number,fname);
bc2f4f0e 456 AssignIDs();
23908b9b 457 CreateHistos(20,0,5);
40896357 458 printf("filling histos\n");
e1a32fa5 459 FillEffHistos();
40896357 460 printf("done fillling\n");
bc2f4f0e 461 CalcEffHistos();
108615fc 462}
463
108615fc 464void AliL3Evaluate::AssignIDs()
465{
466 //Assign MC id to the tracks.
467
108615fc 468 fTracks->QSort();
469 LOG(AliL3Log::kDebug,"AliL3Evaluate::AssignIDs","Track Loop")
470 <<"Assigning MC id to the found tracks...."<<ENDLOG;
471 for(Int_t i=0; i<fTracks->GetNTracks(); i++)
472 {
473 AliL3Track *track = (AliL3Track*)fTracks->GetCheckedTrack(i);
c0217812 474 if(!track) continue;
108615fc 475 if(track->GetNumberOfPoints() < fMinPointsOnTrack) break;
23908b9b 476
23908b9b 477 fGoodFound++;
c0217812 478 Int_t tID = GetMCTrackLabel(track);
108615fc 479 track->SetMCid(tID);
e170e0f9 480 printf("track %i id %d nHits %d\n",i,tID,track->GetNumberOfPoints());
108615fc 481 }
108615fc 482}
483
484
485struct S {Int_t lab; Int_t max;};
c0217812 486Int_t AliL3Evaluate::GetMCTrackLabel(AliL3Track *track){
108615fc 487 //Returns the MCtrackID of the belonging clusters.
488 //If MCLabel < 0, means that track is fake.
489 //Fake track means that more than 10 percent of clusters are assigned incorrectly.
c0217812 490
108615fc 491 Int_t num_of_clusters = track->GetNumberOfPoints();
492 S *s=new S[num_of_clusters];
493 Int_t i;
494 for (i=0; i<num_of_clusters; i++) s[i].lab=s[i].max=0;
495 UInt_t *hitnum = track->GetHitNumbers();
496 UInt_t id;
108615fc 497
23908b9b 498 Int_t **trackID = GetClusterIDs(track);
108615fc 499
500 Int_t lab=123456789;
501 for (i=0; i<num_of_clusters; i++)
502 {
503 //Tricks to get the clusters belonging to this track:
504 id = hitnum[i];
505 Int_t slice = (id>>25) & 0x7f;
506 Int_t patch = (id>>22) & 0x7;
507 UInt_t pos = id&0x3fffff;
508
509 AliL3SpacePointData *points = fClusters[slice][patch];
c0217812 510 if(!points) continue;
108615fc 511 if(pos>=fNcl[slice][patch])
512 {
513 LOG(AliL3Log::kError,"AliL3Evaluate::GetMCTrackLabel","Clusterarray")
514 <<AliL3Log::kDec<<"ERROR"<<ENDLOG;
515 continue;
516 }
517
518 //Get the label of the cluster:
519 //printf("label %d %d %d\n",trackID[i][0],trackID[i][1],trackID[i][2]);
520 lab=abs(trackID[i][0]);
521 Int_t j;
522 for (j=0; j<num_of_clusters; j++)
523 if (s[j].lab==lab || s[j].max==0) break;
524 s[j].lab=lab;
525 s[j].max++;
526 }
527
528 Int_t max=0;
529 for (i=0; i<num_of_clusters; i++)
530 if (s[i].max>max) {max=s[i].max; lab=s[i].lab;}
531
532 delete[] s;
533
534 for (i=0; i<num_of_clusters; i++)
535 {
536 id = hitnum[i];
537 Int_t slice = (id>>25) & 0x7f;
538 Int_t patch = (id>>22) & 0x7;
539 UInt_t pos = id&0x3fffff;
540
541 AliL3SpacePointData *points = fClusters[slice][patch];
c0217812 542 if(!points) continue;
108615fc 543 if(pos>=fNcl[slice][patch])
544 {
545 LOG(AliL3Log::kError,"AliL3Evaluate::GetMCTrackLabel","Clusterarray")
546 <<AliL3Log::kDec<<"ERROR"<<ENDLOG;
547 continue;
548 }
549
550 if (abs(trackID[i][1]) == lab ||
551 abs(trackID[i][2]) == lab ) max++;
552 }
553
554 //check if more than 10% of the clusters are incorrectly assigned (fake track):
555 if (1.-Float_t(max)/num_of_clusters > 0.10)
556 {
557 return -lab;
558 }
559
e170e0f9 560 for(Int_t j=0; j<track->GetNumberOfPoints(); j++)
561 delete [] trackID[j];
108615fc 562 delete [] trackID;
563 return lab;
564}
565
566
c0217812 567Int_t **AliL3Evaluate::GetClusterIDs(AliL3Track *track)
108615fc 568{
569 //Return the MC information of all clusters belonging to track.
c0217812 570
108615fc 571 Int_t num_of_clusters = track->GetNumberOfPoints();
572 Int_t **trackID = new Int_t*[num_of_clusters];
573
574 UInt_t *hitnum = track->GetHitNumbers();
575 UInt_t id;
108615fc 576
577 Float_t xyz[3];
c0217812 578 Int_t padrow;
108615fc 579 for(Int_t i=0; i<num_of_clusters; i++)
580 {
581 id = hitnum[i];
582 Int_t slice = (id>>25) & 0x7f;
583 Int_t patch = (id>>22) & 0x7;
584 UInt_t pos = id&0x3fffff;
585
586 AliL3SpacePointData *points = fClusters[slice][patch];
587
588 if(!points)
589 {
590 LOG(AliL3Log::kError,"AliL3Evaluate::GetClusterIDs","Clusterarray")
591 <<"No points at slice "<<slice<<" patch "<<patch<<" pos "<<pos<<ENDLOG;
592 continue;
593 }
594 if(pos>=fNcl[slice][patch])
595 {
596 LOG(AliL3Log::kError,"AliL3Evaluate::GetClusterIDs","Clusterarray")
597 <<AliL3Log::kDec<<"ERROR"<<ENDLOG;
598 continue;
599 }
600
601 xyz[0] = points[pos].fX;
602 xyz[1] = points[pos].fY;
603 xyz[2] = points[pos].fZ;
604 //sector = points[pos].fSector;
605 padrow = points[pos].fPadRow;
606 Int_t se,ro;
607 fTransform->Slice2Sector(slice,padrow,se,ro);
608 fTransform->Global2Raw(xyz,se,ro);
609
610 if(fIsSlow)
611 {
612 Int_t p = fRowid[slice][padrow];
108615fc 613 if(!fDigitsTree->GetEvent(p))
614 LOG(AliL3Log::kError,"AliL3Evaluate::GetClusterIDs","Digits Tree")
615 <<"Error reading digits tree"<<ENDLOG;
616
617 trackID[i] = new Int_t[3];
e170e0f9 618 trackID[i][0] = fDigits->GetTrackID((Int_t)rint(xyz[2]),(Int_t)rint(xyz[1]),0);
619 trackID[i][1] = fDigits->GetTrackID((Int_t)rint(xyz[2]),(Int_t)rint(xyz[1]),1);
620 trackID[i][2] = fDigits->GetTrackID((Int_t)rint(xyz[2]),(Int_t)rint(xyz[1]),2);
621 //if(trackID[i][0]==6 || trackID[i][0]==32)
622 //printf("trackID %d, padrow %d pad %d time %d\n",fDigits->GetTrackID((Int_t)rint(xyz[2]),(Int_t)rint(xyz[1]),0),padrow,(int)rint(xyz[1]),(int)rint(xyz[2]));
623 /*if(trackID[i][0]<0)
624 {
625
626 printf("trackID %d, padrow %d pad %d time %d\n",trackID[i][0],padrow,(int)rint(xyz[1]),(int)rint(xyz[2]));
627 printf("on the side %d %d %d %d\n",fDigits->GetTrackID(((int)rint(xyz[2])-1),((int)rint(xyz[1])),0),fDigits->GetTrackID(((int)rint(xyz[2])+1),((int)rint(xyz[1])),0),fDigits->GetTrackID(((int)rint(xyz[2])),((int)rint(xyz[1])-1),0),fDigits->GetTrackID(((int)rint(xyz[2])),((int)rint(xyz[1])+1),0));
628 }*/
108615fc 629 }
630 else
631 {
632 Int_t tmp_pid=0;
c0217812 633 for(Int_t ii=0; ii<fNFastPoints; ii++)
108615fc 634 {
c0217812 635 tmp_pid = fMcId[ii];
636 if(fMcIndex[ii] == id) break;
108615fc 637 }
638 trackID[i] = new Int_t[3];
639 trackID[i][0] = tmp_pid;
640 trackID[i][1] = -1;
641 trackID[i][2] = -1;
642 }
643 }
e170e0f9 644
108615fc 645 return trackID;
646}
647
c0217812 648void AliL3Evaluate::GetFastClusterIDs(Char_t *path)
108615fc 649{
650 //Get the MC id of space points in case of using the fast simulator.
c0217812 651 char fname[256];
652 sprintf(fname,"%s/point_mc.dat",path);
653 FILE *infile = fopen(fname,"r");
654 if(!infile) return;
108615fc 655 Int_t hitid,hitmc,i;
656
657 for(i=0; ; i++)
658 if(fscanf(infile,"%d %d",&hitid,&hitmc)==EOF) break;
108615fc 659 rewind(infile);
c0217812 660 fNFastPoints = i;
661 fMcId = new Int_t[fNFastPoints];
662 fMcIndex = new UInt_t[fNFastPoints];
108615fc 663
c0217812 664 for(i=0; i<fNFastPoints; i++)
108615fc 665 {
666 if(fscanf(infile,"%d %d",&hitid,&hitmc)==EOF) break;
c0217812 667 fMcId[i] = hitmc;
668 fMcIndex[i] = hitid;
108615fc 669 }
670 fclose(infile);
c0217812 671}
672
673void AliL3Evaluate::CreateHistos(Int_t nbin,Int_t xlow,Int_t xup)
674{
675 //Create the histograms
676
40896357 677 LOG(AliL3Log::kInformational,"AliL3Evaluate::CreateHistos","Allocating")
678 <<"Creating histograms..."<<ENDLOG;
679
1f79afc0 680 fNtuppel = new TNtuple("fNtuppel","Pt resolution","pt_gen:pt_found:nHits");
681
c0217812 682 fPtRes = new TH1F("fPtRes","Relative Pt resolution",30,-10.,10.);
683 fNGoodTracksPt = new TH1F("fNGoodTracksPt","Good tracks vs pt",nbin,xlow,xup);
684 fNFoundTracksPt = new TH1F("fNFoundTracksPt","Found tracks vs pt",nbin,xlow,xup);
685 fNFakeTracksPt = new TH1F("fNFakeTracksPt","Fake tracks vs pt",nbin,xlow,xup);
686 fTrackEffPt = new TH1F("fTrackEffPt","Tracking efficiency vs pt",nbin,xlow,xup);
687 fFakeTrackEffPt = new TH1F("fFakeTrackEffPt","Efficiency for fake tracks vs pt",nbin,xlow,xup);
688
689 fNGoodTracksEta = new TH1F("fNGoodTracksEta","Good tracks vs eta",20,-50,50);
690 fNFoundTracksEta = new TH1F("fNFoundTracksEta","Found tracks vs eta",20,-50,50);
691 fNFakeTracksEta = new TH1F("fNFakeTracksEta","Fake tracks vs eta",20,-50,50);
692 fTrackEffEta = new TH1F("fTrackEffEta","Tracking efficienct vs eta",20,-50,50);
693 fFakeTrackEffEta = new TH1F("fFakeTrackEffEta","Efficiency for fake tracks vs eta",20,-50,50);
40896357 694 printf("finished creating histos\n");
c0217812 695}
108615fc 696
e1a32fa5 697void AliL3Evaluate::FillEffHistos()
c0217812 698{
699 //Fill the efficiency histograms.
108615fc 700
e1a32fa5 701 for(Int_t i=0; i<fGoodGen; i++)
c0217812 702 {
e1a32fa5 703 Double_t ptg=fGoodTracks[i].pt,pzg=fGoodTracks[i].pz;
c0217812 704 Float_t dipangle=TMath::ATan2(pzg,ptg)*180./TMath::Pi();
40896357 705 printf("filling particle with pt %f and dipangle %f\n",ptg,dipangle);
c0217812 706 fNGoodTracksPt->Fill(ptg);
707 fNGoodTracksEta->Fill(dipangle);
708 Int_t found = 0;
709 for(Int_t k=0; k<fTracks->GetNTracks(); k++)
710 {
711 AliL3Track *track = fTracks->GetCheckedTrack(k);
712 if(!track) continue;
713 Int_t nHits = track->GetNumberOfPoints();
714 if(nHits < fMinPointsOnTrack) break;
715
716 Int_t tracklabel;
717 tracklabel = track->GetMCid();
40896357 718 printf("evaluating track id %d\n",tracklabel);
e1a32fa5 719 if(TMath::Abs(tracklabel) != fGoodTracks[i].label) continue;
c0217812 720 found=1;
e1a32fa5 721 if(tracklabel == fGoodTracks[i].label) {fNFoundTracksPt->Fill(ptg); fNFoundTracksEta->Fill(dipangle);}
c0217812 722 else {fNFakeTracksPt->Fill(ptg); fNFakeTracksEta->Fill(dipangle);}
723 Float_t pt=track->GetPt();
724 fPtRes->Fill((pt-ptg)/ptg*100.);
1f79afc0 725 fNtuppel->Fill(ptg,pt,nHits);
c0217812 726 break;
727
728 }
729 }
730}
731
732void AliL3Evaluate::CalcEffHistos(){
733
734 Stat_t ngood=fNGoodTracksPt->GetEntries();
735 Stat_t nfound=fNFoundTracksPt->GetEntries();
736 Stat_t nfake=fNFakeTracksPt->GetEntries();
737
738 LOG(AliL3Log::kInformational,"AliL3Evaluate::FillEffHistos","Efficiency")
739 <<AliL3Log::kDec<<"There was "<<ngood<<" generated good tracks"<<ENDLOG;
740 LOG(AliL3Log::kInformational,"AliL3Evaluate::FillEffHistos","Efficiency")
741 <<AliL3Log::kDec<<"Found "<<nfound<<" tracks"<<ENDLOG;
742 LOG(AliL3Log::kInformational,"AliL3Evaluate::FillEffHistos","Efficiency")
743 <<AliL3Log::kDec<<"Integral efficiency is about "<<nfound/ngood*100<<ENDLOG;
744 LOG(AliL3Log::kInformational,"AliL3Evaluate::FillEffHistos","Efficiency")
745 <<AliL3Log::kDec<<"Fake tracks relative is about "<<nfake/ngood*100<<ENDLOG;
746
747 fNFoundTracksPt->Sumw2(); fNGoodTracksPt->Sumw2();
748 fTrackEffPt->Divide(fNFoundTracksPt,fNGoodTracksPt,1,1.,"b");
749 fFakeTrackEffPt->Divide(fNFakeTracksPt,fNGoodTracksPt,1,1.,"b");
750 fTrackEffPt->SetMaximum(1.4);
751 fTrackEffPt->SetXTitle("P_{T} [GeV]");
752 fTrackEffPt->SetLineWidth(2);
753 fFakeTrackEffPt->SetFillStyle(3013);
754 fTrackEffPt->SetLineColor(4);
755 fFakeTrackEffPt->SetFillColor(2);
756
757 fNFoundTracksEta->Sumw2(); fNGoodTracksEta->Sumw2();
758 fTrackEffEta->Divide(fNFoundTracksEta,fNGoodTracksEta,1,1.,"b");
759 fFakeTrackEffEta->Divide(fNFakeTracksEta,fNGoodTracksEta,1,1.,"b");
760 fTrackEffEta->SetMaximum(1.4);
761 fTrackEffEta->SetXTitle("#lambda [degrees]");
762 fTrackEffEta->SetLineWidth(2);
763 fFakeTrackEffEta->SetFillStyle(3013);
764 fTrackEffEta->SetLineColor(4);
765 fFakeTrackEffEta->SetFillColor(2);
766
108615fc 767}
768
769void AliL3Evaluate::Write2File(Char_t *outputfile)
770{
771 //Write histograms to file:
772
773 TFile *of = new TFile(outputfile,"RECREATE");
774 if(!of->IsOpen())
775 {
776 LOG(AliL3Log::kError,"AliL3Evaluate::Write2File","File Open")
777 <<"Problems opening rootfile"<<ENDLOG;
778 return;
779 }
780
781 of->cd();
1f79afc0 782 fNtuppel->Write();
108615fc 783 fPtRes->Write();
784 fNGoodTracksPt->Write();
785 fNFoundTracksPt->Write();
786 fNFakeTracksPt->Write();
787 fTrackEffPt->Write();
788 fFakeTrackEffPt->Write();
789 fNGoodTracksEta->Write();
790 fNFoundTracksEta->Write();
791 fNFakeTracksEta->Write();
792 fTrackEffEta->Write();
793 fFakeTrackEffEta->Write();
794
795 of->Close();
796 delete of;
797
798}
799
1f79afc0 800TNtuple *AliL3Evaluate::CalculateResiduals()
801{
802
803 TNtuple *ntuppel=new TNtuple("ntuppel","Residuals","residual_trans:residual_long:zHit:pt:dipangle:beta:padrow:nHits");
78127e35 804
1f79afc0 805 for(int f=fMinSlice; f<=fMaxSlice; f++)
806 {
807 AliL3FileHandler *tfile = new AliL3FileHandler();
808 char fname[256];
809 sprintf(fname,"tracks_tr_%d_0.raw",f);
810 if(!tfile->SetBinaryInput(fname)){
811 LOG(AliL3Log::kError,"AliL3Evaluation::Setup","File Open")
812 <<"Inputfile "<<fname<<" does not exist"<<ENDLOG;
813 return 0;
814 }
815 fTracks = new AliL3TrackArray();
816 tfile->Binary2TrackArray(fTracks);
817 tfile->CloseBinaryInput();
818 delete tfile;
78127e35 819 printf("Looking in slice %d\n",f);
1f79afc0 820 for(Int_t i=0; i<fTracks->GetNTracks(); i++)
821 {
822
823 AliL3Track *track = (AliL3Track*)fTracks->GetCheckedTrack(i);
824 if(!track) continue;
825
826 track->CalculateHelix();
827 UInt_t *hitnum = track->GetHitNumbers();
828 UInt_t id;
829
830 Float_t xyz[3];
831 Int_t padrow;
78127e35 832 for(Int_t j=0; j<track->GetNumberOfPoints()-1; j++)
1f79afc0 833 {
834 id = hitnum[j];
835 Int_t slice = (id>>25) & 0x7f;
836 Int_t patch = (id>>22) & 0x7;
837 UInt_t pos = id&0x3fffff;
838
78127e35 839 //if(slice!=1) continue;
840
1f79afc0 841 AliL3SpacePointData *points = fClusters[slice][patch];
842
843 if(!points)
844 {
845 LOG(AliL3Log::kError,"AliL3Evaluate::CalculateResiduals","Clusterarray")
846 <<"No points at slice "<<slice<<" patch "<<patch<<" pos "<<pos<<ENDLOG;
847 continue;
848 }
849 if(pos>=fNcl[slice][patch])
850 {
851 LOG(AliL3Log::kError,"AliL3Evaluate::CalculateResiduals","Clusterarray")
852 <<AliL3Log::kDec<<"ERROR"<<ENDLOG;
853 continue;
854 }
855
856 xyz[0] = points[pos].fX;
857 xyz[1] = points[pos].fY;
858 xyz[2] = points[pos].fZ;
859 padrow = points[pos].fPadRow;
78127e35 860 //fTransform->Global2Local(xyz,slice);
1f79afc0 861
862 Float_t xyz_cross[3];
863 track->GetCrossingPoint(padrow,xyz_cross);
e1a32fa5 864 Double_t beta = track->GetCrossingAngle(padrow);
1f79afc0 865
866 Double_t yres = xyz_cross[1] - xyz[1];
867 Double_t zres = xyz_cross[2] - xyz[2];
868
869 Double_t dipangle = atan(track->GetTgl());
870 ntuppel->Fill(yres,zres,xyz_cross[2],track->GetPt(),dipangle,beta,padrow,track->GetNumberOfPoints());
871
872 }
873 }
874 if(fTracks)
875 delete fTracks;
876 }
877 return ntuppel;
878}
879
e1a32fa5 880TNtuple *AliL3Evaluate::EvaluatePoints(Char_t *rootfile)
78127e35 881{
e1a32fa5 882 //Compare points to the exact crossing points of track and padrows.
1b76fd18 883 //The input file to this function, contains the exact clusters calculated
884 //in AliTPC::Hits2ExactClusters.
e1a32fa5 885
78127e35 886
e1a32fa5 887 TNtuple *ntuppel = new TNtuple("ntuppel","residuals","slice:padrow:resy:resz:zHit:pt");
78127e35 888
e1a32fa5 889 TFile *exfile = new TFile(rootfile);
890
891 AliTPCParam *param = (AliTPCParam*)exfile->Get("75x40_100x60");
892
893 //Get the exact clusters from file:
894 AliTPCClustersArray *arr = new AliTPCClustersArray;
895 arr->Setup(param);
896 arr->SetClusterType("AliComplexCluster");
897 char treeName[500];
898 sprintf(treeName,"TreeCExact_%s",param->GetTitle());
294ee877 899 Bool_t clusterok = arr->ConnectTree(treeName);//Segment Tree (for offline clusters)
e1a32fa5 900 if(!clusterok) {printf("AliL3Evaluate::EvaluatePoints : Error in clusterloading\n"); return 0;}
901
902 for(Int_t i=0; i<arr->GetTree()->GetEntries(); i++)
78127e35 903 {
e1a32fa5 904 //Get the exact clusters for this row:
905 Int_t cursec,currow;
906 AliSegmentID *s = arr->LoadEntry(i);
907 param->AdjustSectorRow(s->GetID(),cursec,currow);
78127e35 908
e1a32fa5 909 AliTPCClustersRow *ro = (AliTPCClustersRow *)arr->GetRow(cursec,currow);
910 TClonesArray *clusters = ro->GetArray();
911 int num_of_offline=clusters->GetEntriesFast();
78127e35 912
e1a32fa5 913 //Get the found clusters:
914 Int_t slice,padrow;
915 fTransform->Sector2Slice(slice,padrow,cursec,currow);
916 if(slice<fMinSlice || slice>fMaxSlice) continue;
917 AliL3SpacePointData *points = fClusters[slice][0];
1b76fd18 918
919 Int_t index = fRowid[slice][padrow];
920 if(!fDigitsTree->GetEvent(index))
921 printf("AliL3Evaluate::EvaluatePoints : ERROR IN DIGITSTREE\n");
294ee877 922 printf("Checking slice %d padrow %d with %d clusters\n",slice,padrow,num_of_offline);
1b76fd18 923
e1a32fa5 924 for(UInt_t c=0; c<fNcl[slice][0]; c++)
78127e35 925 {
e1a32fa5 926 if(points[c].fPadRow!=padrow) continue;
e1a32fa5 927 for(Int_t m=0; m<num_of_offline; m++)
78127e35 928 {
e1a32fa5 929 AliComplexCluster *cluster = (AliComplexCluster *)clusters->UncheckedAt(m);
930 Int_t mcId = cluster->fTracks[0];
294ee877 931 //Int_t mcId = cluster->GetLabel(0);
932 if(mcId <0) continue;
e1a32fa5 933 TParticle *part = gAlice->Particle(mcId);
294ee877 934
e1a32fa5 935 Float_t xyz_cl[3] = {points[c].fX,points[c].fY,points[c].fZ};
294ee877 936 Float_t xyz_ex[3];
e1a32fa5 937 fTransform->Global2Raw(xyz_cl,cursec,currow);
e170e0f9 938 if(fDigits->GetTrackID((Int_t)rint(xyz_cl[2]),(Int_t)rint(xyz_cl[1]),0)!=mcId &&
939 fDigits->GetTrackID((Int_t)rint(xyz_cl[2]),(Int_t)rint(xyz_cl[1]),1)!=mcId &&
940 fDigits->GetTrackID((Int_t)rint(xyz_cl[2]),(Int_t)rint(xyz_cl[1]),2)!=mcId)
e1a32fa5 941 continue;
294ee877 942 fTransform->Raw2Local(xyz_ex,cursec,currow,cluster->fY,cluster->fX);
943 fTransform->Raw2Local(xyz_cl,cursec,currow,xyz_cl[1],xyz_cl[2]);
944 Float_t resy = xyz_cl[1] - xyz_ex[1];//cluster->GetY()
945 Float_t resz = xyz_cl[2] - xyz_ex[2];//cluster->GetZ()
e1a32fa5 946
294ee877 947 ntuppel->Fill(slice,padrow,resy,resz,xyz_ex[2],part->Pt());
78127e35 948 }
e1a32fa5 949 }
294ee877 950 arr->ClearRow(cursec,currow);
78127e35 951 }
e1a32fa5 952
78127e35 953 return ntuppel;
954}
e1a32fa5 955/*
78127e35 956TNtuple *AliL3Evaluate::EvaluateGEANT()
957{
958 TNtuple *ntuppel = new TNtuple("ntuppel","residuals","resy:ptgen:padrow:zHit:slice");
959
ae97a0b9 960 Int_t good_number=175;
961 Int_t row[2] = {0,175};
78127e35 962
963 Float_t xyz_cross[3];
964 Float_t xyz_cl[3];
965
966 for(Int_t slice=fMinSlice; slice<=fMaxSlice; slice++)
967 {
968 Int_t *particle_id = new Int_t[fParticles->GetEntriesFast()];
969 TObjArray *good_particles = DefineGoodTracks(slice,row,good_number,particle_id);
970
971 if(fMCclusterfile)
972 {
973 fMCclusterfile->Close();
974 delete fMCclusterfile;
975 fMCclusterfile = new TFile("/nfs/david/subatom/alice/data/V3.04/fast/clusters/hg_8k_v0_s1-3_e0_cl.root");
976 fMCclusterfile->cd();
977 }
978 AliTPCClustersArray arr;
979 arr.Setup(fParam);
980 arr.SetClusterType("AliTPCcluster");
981 Bool_t clusterok = arr.ConnectTree("Segment Tree");
982 if(!clusterok)
983 LOG(AliL3Log::kError,"AliL3Evaluate::DefineGoodTracks","Cluster Array")
984 <<"Error loading clusters from rootfile"<<ENDLOG;
985
986 for(Int_t ci=0; ci<arr.GetTree()->GetEntries(); ci++)
987 {
988 Int_t sec,row,sl,lr;
989 AliSegmentID *s = arr.LoadEntry(ci);
990 fParam->AdjustSectorRow(s->GetID(),sec,row);
991 fTransform->Sector2Slice(sl,lr,sec,row);
992 if(sl != slice) {arr.ClearRow(sec,row); continue;}
993 //if(lr!=pr) {carray.ClearRow(sec,row); continue;}
994 AliTPCClustersRow *cRow = arr.GetRow(sec,row);
995 printf("evaluating slice %d row %d\n",slice,lr);
996 for(Int_t j=0; j<cRow->GetArray()->GetEntriesFast(); j++)
997 {
998
999 AliTPCcluster *cluster=(AliTPCcluster*)(*cRow)[j];
1000 xyz_cl[1] = cluster->GetY();
1001 xyz_cl[2] = cluster->GetZ();
1002 Int_t lab=cluster->GetLabel(0);
1003 if(lab<0) continue;
1004
1005 for(Int_t pa=0; pa<good_particles->GetEntriesFast(); pa++)
1006 {
1007 if(particle_id[pa]!=lab) continue;
1008 TParticle *part = (TParticle*)good_particles->UncheckedAt(pa);
1009 GetParticleCrossingPoint(part,slice,lr,xyz_cross);
1010 Double_t yres = xyz_cl[1] - xyz_cross[1];
1011 ntuppel->Fill(yres,part->Pt(),lr,xyz_cl[2],slice);
1012 }
1013 }
1014 if(arr.GetRow(sec,row))
1015 arr.ClearRow(sec,row);
1016 }
1017 delete [] particle_id;
1018 delete good_particles;
1019 }
1020 return ntuppel;
1021}
e1a32fa5 1022*/
78127e35 1023Bool_t AliL3Evaluate::GetParticleCrossingPoint(TParticle *part,Int_t slice,Int_t padrow,Float_t *xyz)
1024{
1025 //Calcluate the crossing point between a generated particle and given padrow.
1026
1027
1028 Double_t kappa = 0.2*0.0029980/part->Pt();
1029
1030 Double_t radius = 1/fabs(kappa);
1031 if(part->GetPdgCode() > 0) kappa = -kappa;
1032
23908b9b 1033 Int_t charg;
1034 if(kappa>0)
1035 charg=-1;
1036 else
1037 charg=1;
1038
78127e35 1039 Float_t angl[1] = {part->Phi()};
1040
1041 fTransform->Global2LocalAngle(angl,slice);
1042
1043 Double_t charge = -1.*kappa;
1044 Double_t trackPhi0 = angl[0] + charge*0.5*Pi/fabs(charge);
1045
1046 Double_t x0=0;
1047 Double_t y0=0;
1048 Double_t xc = x0 - radius * cos(trackPhi0);
1049 Double_t yc = y0 - radius * sin(trackPhi0);
1050
1051 //printf("radius %f xc %f yc %f\n",radius,xc,yc);
1052
1053 Double_t xHit = fTransform->Row2X(padrow);
1054 xyz[0] = xHit;
1055 Double_t aa = (xHit - xc)*(xHit - xc);
1056 Double_t r2 = radius*radius;
1057 if(aa > r2)
1058 return false;
1059
1060 Double_t aa2 = sqrt(r2 - aa);
1061 Double_t y1 = yc + aa2;
1062 Double_t y2 = yc - aa2;
1063 xyz[1] = y1;
1064 if(fabs(y2) < fabs(y1)) xyz[1] = y2;
1065
23908b9b 1066 Double_t tgl = part->Pz()/part->Pt();
1067
1068 Double_t yHit = xyz[1];
1069 Double_t angle1 = atan2((yHit - yc),(xHit - xc));
1070 if(angle1 < 0) angle1 += 2.*Pi;
1071 Double_t angle2 = atan2((0 - yc),(0 - xc));
1072 if(angle2 < 0) angle2 += 2.*Pi;
1073 Double_t diff_angle = angle1 - angle2;
1074 diff_angle = fmod(diff_angle,2*Pi);
1075 if((charg*diff_angle) > 0) diff_angle = diff_angle - charg*2.*Pi;
1076 Double_t s_tot = fabs(diff_angle)*radius;
1077 Double_t zHit = 0 + s_tot*tgl;
1078 xyz[2] = zHit;
1079
78127e35 1080 return true;
1081}
1082