1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 //_________________________________________________________________________
17 // This is a TTask for reconstruction V2 in TOF
18 // Description of the algorithm
19 //-- Author: F. Pierella | pierella@bo.infn.it
20 //////////////////////////////////////////////////////////////////////////////
22 #include "TBenchmark.h"
25 #include "TParticle.h"
28 #include "TClonesArray.h"
35 #include "TVirtualMC.h"
37 #include "AliDetector.h"
41 #include "AliTOFDigitMap.h"
42 #include "AliTOFHitMap.h"
43 #include "AliTOFhitT0.h"
44 #include "AliTOFdigit.h"
45 #include "AliTOFConstants.h"
46 #include "AliTOFReconstructionerV2.h"
47 #include "AliTOFTrackV2.h"
49 #include "AliKalmanTrack.h"
50 #include "../TPC/AliTPCtrack.h"
51 #include "../TRD/AliTRDtrack.h"
53 ClassImp(AliTOFReconstructionerV2)
55 //____________________________________________________________________________
56 AliTOFReconstructionerV2::AliTOFReconstructionerV2():TTask("AliTOFReconstructionerV2","")
60 // set all member vars to zero
70 fTOFDigitsFile ="digits.root";
71 fTPCBackTracksFile="AliTPCBackTracks.root";
73 fBranchWithTracks =0x0;
76 //____________________________________________________________________________
77 AliTOFReconstructionerV2::AliTOFReconstructionerV2(char* tpcBackTracks, char* tofDigits):TTask("AliTOFReconstructionerV2","")
81 // default arguments are specified only in
84 // tpcBackTracks -> file name with backpropagated tracks in TPC
85 // tofDigits -> file name with TOF digits
90 fField =0.2; // default value 0.2 [Tesla]
91 fNDummyTracks=20; // by default 20 test tracks used
96 fTOFDigitsFile =tofDigits;
97 fTPCBackTracksFile=tpcBackTracks;
99 fBranchWithTracks =0x0;
101 // initialize the G3 geometry
105 // add Task to //root/Tasks folder
106 TTask * roottasks = (TTask*)gROOT->GetRootFolder()->FindObject("Tasks") ;
107 roottasks->Add(this) ;
110 //____________________________________________________________________________
111 AliTOFReconstructionerV2::AliTOFReconstructionerV2(const AliTOFReconstructionerV2 & rec)
114 // Dummy copy constructor
115 // required by coding conventions
121 //____________________________________________________________________________
122 AliTOFReconstructionerV2::~AliTOFReconstructionerV2()
126 // some delete has to be moved
149 delete fTOFDigitsFile;
152 if (fTPCBackTracksFile)
154 delete fTPCBackTracksFile;
163 if (fBranchWithTracks)
165 delete fBranchWithTracks;
166 fBranchWithTracks = 0;
171 //____________________________________________________________________________
172 void AliTOFReconstructionerV2::Exec(Option_t* option)
175 // Description of the algorithm:
183 // load TOF digits and fill the digit map
184 Int_t tofDigitsLoading=LoadTOFDigits();
186 // load back-propagated tracks in TPC
187 Int_t tpcTracksLoading=LoadTPCTracks();
189 if(tofDigitsLoading || tpcTracksLoading) {
190 cout<<" Couldn't start reconstruction V2. Exit."<<endl;
193 // or load TRD reconstructed tracks
194 // Int_t trdTracksLoading=LoadTRDTracks();
196 // create a TObjArray to store reconstructed tracks
197 // and reject fake tracks
198 const Int_t maxRecTracks = 10000; // max number of reconstructed tracks
201 const Float_t stripRegionHeight = 15.3; // [cm] height in radial direction
202 // of the volume where strips are placed
203 TObjArray trackArray(maxRecTracks);
206 fTOFTracks= new TClonesArray("AliTOFTrackV2");
207 // create a reference to fill the TClonesArray
208 TClonesArray &aTOFTracks = *fTOFTracks;
210 const Int_t maxIndex = 100000; // max number of primary tracks to be analysed
211 // the index of the rtIndex array is the track label
212 // the content of the array is -1 for fake tracks
213 // and the track index for good tracks
214 Float_t dEdXarray[maxRecTracks];
215 Int_t rtIndex[maxIndex];
216 for(Int_t i = 0; i < maxIndex; i++) rtIndex[i] = -1;
218 AliKalmanTrack::SetConvConst(100/0.299792458/fField);
220 Int_t nRecTracks = (Int_t) fKalmanTree->GetEntries();
221 cout<<"Found "<<nRecTracks<<" entries in the track tree "<<endl;
223 // load the tracks into the array
224 for (Int_t i=0; i<nRecTracks; i++) {
225 AliTPCtrack *iotrack=new AliTPCtrack();
226 fBranchWithTracks->SetAddress(&iotrack);
227 fKalmanTree->GetEvent(i);
228 trackArray.AddLast(iotrack);
229 Int_t trackLabel = iotrack->GetLabel();
230 dEdXarray[i]=iotrack->GetdEdx(); // usefull for PID
232 // start filling the TClonesArray of AliTOFTrackV2
233 Float_t trdXYZ[3]={0.,0.,0.};
234 Float_t trdPxPyPz[3]={0.,0.,0.};
236 // tpc outer wall positions
237 Double_t xk=iotrack->GetX();
238 // get the running coordinates in the lrf
241 Double_t y=iotrack->GetY();
242 Double_t z=iotrack->GetZ();
243 Double_t alpha=iotrack->GetAlpha();
244 GetGlobalXYZ(alpha, x, y, z);
245 Float_t tpcXYZ[3]={x,y,z};
247 // momentum at the end of TPC
248 Float_t lambda=TMath::ATan(iotrack->GetTgl());
249 Float_t invpt=TMath::Abs(iotrack->Get1Pt());
251 if (invpt) pt= 1./invpt; // pt
252 Float_t tpcmom=1./(invpt*TMath::Cos(lambda));
253 Float_t pz=tpcmom*TMath::Sin(lambda);
254 Float_t tpcPtPz[2]={pt,pz};
256 Int_t matchingStatus=-1;
257 if(trackLabel < 0) matchingStatus=0;
258 new(aTOFTracks[i]) AliTOFTrackV2(trackLabel,matchingStatus,tpcmom,dEdXarray[i],tpcXYZ,tpcPtPz,trdXYZ,trdPxPyPz);
259 // printf("rt with %d clusters and label %d \n",
260 // iotrack->GetNumberOfClusters(), trackLabel);
262 if(trackLabel < 0) continue;
263 if(trackLabel >= maxIndex) continue;
264 rtIndex[trackLabel] = i;
268 if(strstr(option,"MC")) Comparison(rtIndex);
270 // start loop on tracks
271 // and backpropagate them from TPC to TOF
272 // backpropagation is performed only
273 // for good tracks (fake tracks rejected)
276 for (Int_t i=0; i<nRecTracks; i++) {
278 //******* tracking: extract track coordinates, momentum, etc.
279 rt = (AliTPCtrack*) trackArray.UncheckedAt(i);
280 // track length to be implemented
281 // Double_t tr_length = rt->GetLength();
283 Int_t tpcTrackLabel=rt->GetLabel();
284 // reject fake tracks
285 //if(tpcTrackLabel< 0) continue;
287 // starting backpropagation to TOF
288 // here we assume to have backpropagated tracks in TPC
289 // starting point xk=246.055
290 // starting back propagation
291 // outer wall of the TPC
292 Int_t iOuterTPCWall=rt->PropagateTo(261.53,40.,0.06124);
293 // frame with air just to the beginning of the TOF
294 Int_t iFrameWithAir=rt->PropagateTo(370.,36.66,1.2931e-3);
295 // trough the wall of the TOF plate
296 // thickness has changed according to the
298 Int_t iTOFWall=rt->PropagateTo(370.11,24.01,2.7);
301 // outer wall of the TPC
302 Int_t iOuterTPCWall=rt->PropagateTo(261.53,40.,0.06124);
303 // air in between TPC and TRD
304 Int_t iFrameWithAir=rt->PropagateTo(294.5,36.66,1.2931e-3);
306 // mean density for the TRD calculated from
307 // TRD Technical Design Report
308 // page 11 -> global thickness
309 // page 23 -> different main layers thickness (Radiator Air/ Drift Chamber Gas /G10)
310 // page 139 -> material budget and radiation lengths
311 Int_t iTRD=rt->PropagateTo(369.1,171.7,0.33);
312 // air in between TRD and TOF
313 Int_t iFrameWithAirbis=rt->PropagateTo(370.,36.66,1.2931e-3);
314 // trough the wall of the TOF plate
315 Int_t iTOFWall=rt->PropagateTo(370.11,24.01,2.7);
318 // select only cases when
319 // backpropagation succeded
320 // and particle is in the geometrical TOF acceptance along Z
322 AliTOFTrackV2* oTOFtracks=(AliTOFTrackV2*)fTOFTracks->UncheckedAt(i);
323 Bool_t outOfZacceptance=(rt->GetZ()<=380.);
324 if(outOfZacceptance) oTOFtracks->SetMatchingStatus(-2);
326 if(iOuterTPCWall==1 && iFrameWithAir==1 && iTOFWall==1 && (!outOfZacceptance)){
328 // get sigmaY and sigmaZ
329 rt->GetExternalCovariance(cc);
330 Double_t sigmaY =TMath::Sqrt(cc[0]); // [cm]
331 Double_t sigmaZ =TMath::Sqrt(cc[2]); // [cm]
333 // arrays used by the DigitFinder
335 TArrayI *secArray= new TArrayI(nSlot);
336 TArrayI *plaArray= new TArrayI(nSlot);
337 TArrayI *strArray= new TArrayI(nSlot);
338 TArrayI *pdzArray= new TArrayI(nSlot);
339 TArrayI *pdxArray= new TArrayI(nSlot);
341 // make fNDummyTracks clones of the current backpropagated track
342 // make a copy of the current track
343 // smear according to the backpropagated area
344 for (Int_t j=0; j<fNDummyTracks; i++) {
345 AliTPCtrack *dummyrt=new AliTPCtrack(*rt);
347 Double_t ylrf= dummyrt->GetY(); // P0
348 Double_t zlrf= dummyrt->GetZ(); // P1
350 // smear according to sigmaY and sigmaZ
351 Double_t ylrfNew=gRandom->Gaus(ylrf,fScaleSigmaFactor*sigmaY);
352 Double_t zlrfNew=gRandom->Gaus(zlrf,fScaleSigmaFactor*sigmaZ);
354 // set Y and Z accordingly
355 // setter to be added in the class AliTPCtrack
356 // here I have to modify the AliTPCtrack class
357 // adding the setters for Y and Z
358 //dummyrt->SetY(ylrfNew);
359 //dummyrt->SetZ(zlrfNew);
361 // start fine-backpropagation inside the TOF
362 Bool_t padNotFound =kTRUE;
363 Bool_t isInStripsRegion=kTRUE;
364 Double_t xk=dummyrt->GetX();
366 while (padNotFound && isInStripsRegion){
368 // here we assume a frame with air
369 dummyrt->PropagateTo(xk,36.66,1.2931e-3);
370 // get the running coordinates in the lrf
373 Double_t y=dummyrt->GetY();
374 Double_t z=dummyrt->GetZ();
375 Double_t alpha=dummyrt->GetAlpha();
376 GetGlobalXYZ(alpha, x, y, z);
378 // check if the point falls into a pad
379 // using the G3 geometry
380 Int_t* volumeID = new Int_t[AliTOFConstants::fgkmaxtoftree];
381 // volumeID[0] -> TOF Sector range [1-18]
382 // volumeID[1] -> TOF Plate range [1- 5]
383 // volumeID[2] -> TOF Strip max range [1-20]
384 // volumeID[3] -> TOF Pad along Z range [1- 2]
385 // volumeID[4] -> TOF Pad along X range [1-48]
387 Float_t zInPadFrame=0.;
388 Float_t xInPadFrame=0.;
389 IsInsideThePad((Float_t)x,(Float_t)y,(Float_t)z, volumeID, zInPadFrame, xInPadFrame);
390 // adding protection versus wrong volume numbering
391 // to be released in the next release after debugging
395 secArray->Set(nSlot-1);
396 plaArray->Set(nSlot-1);
397 strArray->Set(nSlot-1);
398 pdzArray->Set(nSlot-1);
399 pdxArray->Set(nSlot-1);
401 (*secArray)[nSlot-1]=volumeID[0];
402 (*plaArray)[nSlot-1]=volumeID[1];
403 (*strArray)[nSlot-1]=volumeID[2];
404 (*pdzArray)[nSlot-1]=volumeID[3];
405 (*pdxArray)[nSlot-1]=volumeID[4];
407 } // track falls into a pad volume
411 // check on xk to stop the fine-propagation
412 if(xk>=(370.+stripRegionHeight)) isInStripsRegion=kFALSE;
414 } // close the while for fine-propagation
417 } // end loop on test tracks
419 // start TOF digit finder
420 Int_t assignedVol[5]={0,0,0,0,0};
422 Int_t* digitTrackArray=0x0;
423 Bool_t assignedDigit=DigitFinder(secArray, plaArray, strArray, pdzArray, pdxArray, assignedVol, digitTrackArray, tdc);
427 // fill the tree for tracks with time of flight
428 // tof is given in tdc bin
429 // conversion to [ns]
430 Float_t binWidth=50.; // [ps]
431 Float_t timeOfFlight=tdc*binWidth/1000.;
433 // only the first track number contributing
434 // to the assigned digit
435 Int_t tofDigitTrackLabel=digitTrackArray[0];
437 // matching status for the current track
439 if(tpcTrackLabel==digitTrackArray[0] || tpcTrackLabel==digitTrackArray[1] || tpcTrackLabel==digitTrackArray[0]) matching=3;
440 oTOFtracks->UpdateTrack(tofDigitTrackLabel, matching, timeOfFlight);
442 // fill the TClonesArray for tracks with no time of flight
444 oTOFtracks->SetMatchingStatus(matching);
447 // delete used memory for tmp arrays used by DigitFinder
454 } // close the if for succeded backpropagation in TOF acceptance along z
456 } // end loop on reconstructed tracks
458 // free used memory for digitmap
461 // save array with TOF tracks
462 Int_t output=SaveTracks();
463 if(output) cout << "Error writing TOF tracks " << endl;
467 //__________________________________________________________________
468 void AliTOFReconstructionerV2::Init(Option_t* opt)
471 // Initialize the AliTOFReconstructionerV2
477 //__________________________________________________________________
478 Int_t AliTOFReconstructionerV2::LoadTPCTracks()
481 // Connect the tree and the branch
482 // with reconstructed tracks
483 // backpropagated in the TPC
485 gBenchmark->Start("LoadTPCTracks");
487 TFile *kalFile = TFile::Open(fTPCBackTracksFile.Data());
488 if (!kalFile->IsOpen()) {cerr<<"Can't open AliTPCBackTracks.root !\n"; return 3;}
490 // tracks from Kalman
492 char treename[100]; sprintf(treename,"TreeT_TPCb_%d",event);
493 fKalmanTree=(TTree*)kalFile->Get(treename);
494 if (!fKalmanTree) {cerr<<"Can't get a tree with TPC back tracks !\n"; return 4;}
496 // otherwise you get always 0 for 1/pt
497 AliKalmanTrack::SetConvConst(100/0.299792458/fField);
499 fBranchWithTracks=fKalmanTree->GetBranch("tracks");
500 Int_t kalEntries =(Int_t)fKalmanTree->GetEntries();
501 cout<<"Number of loaded Tracks :"<< kalEntries <<endl;
503 gBenchmark->Stop("LoadTPCTracks");
504 gBenchmark->Show("LoadTPCTracks");
508 //__________________________________________________________________
509 Int_t AliTOFReconstructionerV2::LoadTRDTracks()
512 // Connect the tree and the branch
513 // with reconstructed tracks in TRD
515 gBenchmark->Start("LoadTRDTracks");
518 const Int_t nPrimaries = 84210/16;
519 const Int_t maxIndex = nPrimaries;
520 Int_t rtIndex[maxIndex];
522 TFile *tf=TFile::Open("AliTRDtracks.root");
524 if (!tf->IsOpen()) {cerr<<"Can't open AliTRDtracks.root !\n"; return 3;}
525 TObjArray tarray(2000);
527 sprintf(tname,"TRDb_%d",nEvent);
528 TTree *tracktree=(TTree*)tf->Get(tname);
530 TBranch *tbranch=tracktree->GetBranch("tracks");
532 Int_t nRecTracks = (Int_t) tracktree->GetEntries();
533 cerr<<"Found "<<nRecTracks<<" entries in the track tree"<<endl;
535 for (Int_t i=0; i<nRecTracks; i++) {
536 AliTRDtrack *iotrack=new AliTRDtrack();
537 tbranch->SetAddress(&iotrack);
538 tracktree->GetEvent(i);
539 tarray.AddLast(iotrack);
540 Int_t trackLabel = iotrack->GetLabel();
542 // printf("rt with %d clusters and label %d \n",
543 // iotrack->GetNumberOfClusters(), trackLabel);
545 if(trackLabel < 0) continue;
546 if(trackLabel >= maxIndex) continue;
547 rtIndex[trackLabel] = i;
550 gBenchmark->Stop("LoadTRDTracks");
551 gBenchmark->Show("LoadTRDTracks");
556 //__________________________________________________________________
557 Int_t AliTOFReconstructionerV2::LoadTOFDigits()
560 // Connect the TClonesArray with TOF
561 // digits and fill the digit map
562 // used by the DigitFinder
566 gBenchmark->Start("LoadTOFDigits");
568 TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(fTOFDigitsFile.Data());
570 cout<<"headerFile already open \n";
573 if(!file)file=TFile::Open(fTOFDigitsFile.Data());
576 // Get AliRun object from file
578 gAlice = (AliRun*)file->Get("gAlice");
579 if (gAlice) printf("AliRun object found on file\n");
583 if (iEvNum == 0) iEvNum = (Int_t) gAlice->TreeE()->GetEntries();
586 AliTOFdigit *tofdigit;
588 AliTOF * tof = (AliTOF *) gAlice->GetDetector("TOF") ;
591 cout << "<LoadTOFDigits> No TOF detector found" << endl;
596 for (Int_t ievent = 0; ievent < iEvNum; ievent++) {
598 gAlice->GetEvent(ievent) ;
599 if(gAlice->TreeD()==0) {
600 cout << "<LoadTOFDigits> No TreeD found" << endl;
607 gAlice->ResetDigits();
608 gAlice->TreeD()->GetEvent(ievent);
609 fTOFDigits = tof->Digits();
611 ndig=fTOFDigits->GetEntries();
613 // create the digit map
614 fDigitsMap = new AliTOFDigitMap(fTOFDigits);
617 cout << "<LoadTOFDigits> found " << ndig
618 << " TOF digits for event " << ievent << endl;
620 for (Int_t k=0; k<ndig; k++) {
621 tofdigit= (AliTOFdigit*) fTOFDigits->UncheckedAt(k);
622 Float_t tdc=tofdigit->GetTdc();
623 // adc value can be used for weighting
624 //Float_t adc=tofdigit->GetAdc();
627 Int_t vol[5]; // location for a digit
628 Int_t sector = tofdigit->GetSector(); // range [1-18]
629 Int_t plate = tofdigit->GetPlate(); // range [1- 5]
630 Int_t strip = tofdigit->GetStrip(); // range [1-20]
631 Int_t padx = tofdigit->GetPadx(); // range [1-48]
632 Int_t padz = tofdigit->GetPadz(); // range [1- 2]
641 Bool_t isDigitBad = (sector<1 || sector>18 || plate<1 || plate >5 || padz<1 || padz>2 || padx<1 || padx>48);
644 cout << "<LoadTOFDigits> strange digit found" << endl;
649 // Fill the digit map checking if the location is already used
650 // in this case we take the earliest signal
651 if (fDigitsMap->TestHit(vol) != kEmpty) {
652 // start comparison in between the 2 digit
653 AliTOFdigit *dig = static_cast<AliTOFdigit*>(fDigitsMap->GetHit(vol));
654 if(tdc < (dig->GetTdc())) fDigitsMap->SetHit(vol,k);
655 // we can add also the check on adc value
656 // by selecting the largest adc value
658 fDigitsMap->SetHit(vol,k);
660 // to be added protection versus 2-digit on the same pad
661 // we have to have memory also of the second digit
663 } // for (k=0; k<ndig; k++)
665 } // end loop on events
667 gBenchmark->Stop("LoadTOFDigits");
668 gBenchmark->Show("LoadTOFDigits");
672 //__________________________________________________________________
673 void AliTOFReconstructionerV2::IsInsideThePad(Float_t x, Float_t y, Float_t z, Int_t *nGeom, Float_t& zPad, Float_t& xPad)
675 // input: x,y,z - coordinates of a point in the mrf [cm]
676 // output: array nGeom[]
677 // nGeom[0] - the TOF sector number, 1,2,...,18 along azimuthal direction starting from -90 deg.
678 // nGeom[1] - the TOF module number, 1,2,3,4,5=C,B,A,B,C along z-direction
679 // nGeom[2] - the TOF strip number, 1,2,... along z-direction
680 // nGeom[3] - the TOF padz number, 1,2=NPZ across a strip
681 // nGeom[4] - the TOF padx number, 1,2,...,48=NPX along a strip
682 // zPad, xPad - coordinates of the hit in the pad frame
683 // numbering is adopted for the version 3.08 of AliRoot
685 // from Hits: sec,pla,str,padz,padx=4,2,14,2,35
686 // Vol. n.0: ALIC, copy number 1
687 // Vol. n.1: B077, copy number 1
688 // Vol. n.2: B074, copy number 5
689 // Vol. n.3: BTO2, copy number 1
690 // Vol. n.4: FTOB, copy number 2
691 // Vol. n.5: FLTB, copy number 0
692 // Vol. n.6: FSTR, copy number 14
693 // Vol. n.7: FSEN, copy number 0
694 // Vol. n.8: FSEZ, copy number 2
695 // Vol. n.9: FSEX, copy number 35
696 // Vol. n.10: FPAD, copy number 0
700 Int_t sector=0,module=0,strip=0,padz=0,padx=0;
701 Int_t i,numed,nLevel,copyNumber;
706 for (i=0; i<AliTOFConstants::fgkmaxtoftree; i++) nGeom[i]=0;
714 TGeant3 * fG3Geom = (TGeant3*) gMC;
716 fG3Geom->Gmedia(xTOF, numed);
717 gcvolu=fG3Geom->Gcvolu();
718 nLevel=gcvolu->nlevel;
720 for (Int_t i=0; i<nLevel; i++) {
721 strncpy(name,(char*) (&gcvolu->names[i]),4);
722 cout<<"Vol. n."<<i<<": "<<name<<", copy number "<<gcvolu->number[i]<<endl;
726 // sector type name: B071(1,2,...,10),B074(1,2,3,4,5-PHOS),B075(1,2,3-RICH)
727 strncpy(name,(char*) (&gcvolu->names[2]),4);
728 // volume copy: 1,2,...,10 for B071, 1,2,3,4,5 for B074, 1,2,3 for B075
729 copyNumber=gcvolu->number[2];
730 if(!strcmp(name,"B071")) {
731 if (copyNumber>=6 && copyNumber<=8) {
732 sector=copyNumber+10;
733 } else if (copyNumber>=1 && copyNumber<=5){
738 } else if(!strcmp(name,"B075")) {
739 sector=copyNumber+12;
740 } else if(!strcmp(name,"B074")) {
741 if (copyNumber>=1 && copyNumber<=3){
751 // we'll use the module value in z-direction:
753 // the module order in z-direction: FTOC,FTOB,FTOA,FTOB,FTOC
754 // the module copy: 2 2 0 1 1
755 // module type name: FTOA, FTOB, FTOC
756 strncpy(name,(char*) (&gcvolu->names[4]),4);
758 copyNumber=gcvolu->number[4];
759 if(!strcmp(name,"FTOC")) {
765 } else if(!strcmp(name,"FTOB")) {
771 } else if(!strcmp(name,"FTOA")) {
780 // strip type name: FSTR
781 strncpy(name,(char*) (&gcvolu->names[6]),4);
783 copyNumber=gcvolu->number[6];
784 if(!strcmp(name,"FSTR")) strip=copyNumber;
791 // padz type name: FSEZ
792 strncpy(name,(char*) (&gcvolu->names[8]),4);
794 copyNumber=gcvolu->number[8];
795 if(!strcmp(name,"FSEZ")) padz=copyNumber;
801 // padx type name: FSEX
802 strncpy(name,(char*) (&gcvolu->names[9]),4);
804 copyNumber=gcvolu->number[9];
805 if(!strcmp(name,"FSEX")) padx=copyNumber;
817 //__________________________________________________________________
818 void AliTOFReconstructionerV2::GetGlobalXYZ(Double_t alpha, Double_t& x, Double_t& y, Double_t& z)
821 // return the current running coordinates of
822 // the track in the global reference frame
823 // x, y and z have to initialized to the
824 // local frame coordinates by the caller
825 // alpha is the alpha coordinate in the TPC Kalman
828 // it take into account differences in between
829 // TPC and TRD local coordinates frames
830 if (alpha < -TMath::Pi()) alpha += 2*TMath::Pi();
831 else if (alpha >= TMath::Pi()) alpha -= 2*TMath::Pi();
834 Double_t tmp=x*TMath::Cos(alpha) - y*TMath::Sin(alpha);
835 y=x*TMath::Sin(alpha) + y*TMath::Cos(alpha);
839 //__________________________________________________________________
840 Bool_t AliTOFReconstructionerV2::DigitFinder(TArrayI *secArray, TArrayI *plaArray, TArrayI *strArray, TArrayI *pdzArray, TArrayI *pdxArray, Int_t* assignedVol, Int_t* digitTrackArray, Float_t& tdc)
844 // input: arrays with sectors, plates, strips, padz, padx
845 // found during fine-propagation of probe tracks
847 // output kFALSE if signal is not found
848 // kTRUE if signal is found
849 // in this case the assignedVol array contains the digit volume numbers
850 // and digitTrackArray the track numbers (max 3) contributing to the
854 Int_t nFilledSlot=secArray->GetSize();
857 Float_t maxWeight=-1.;
858 Int_t indexOfMaxWeight=-1;
859 for (Int_t i = 0; i < nFilledSlot; i++) {
860 Int_t vol[5]; // location for a digit
861 vol[0] = (*secArray)[i];
862 vol[1] = (*plaArray)[i];
863 vol[2] = (*strArray)[i];
864 vol[3] = (*pdxArray)[i];
865 vol[4] = (*pdzArray)[i];
867 // check for digit in the current location
868 if (fDigitsMap->TestHit(vol) != kEmpty) {
870 AliTOFdigit *dig = static_cast<AliTOFdigit*>(fDigitsMap->GetHit(vol));
871 Float_t adcWeight=dig->GetAdc();
872 if(adcWeight > maxWeight){
876 digitTrackArray=dig->GetTracks();
878 } // if(adcWeight > maxWeight)
879 } // close if (fDigitsMap->TestHit(vol) != kEmpty)
883 if(indexOfMaxWeight!=-1){
884 assignedVol[0]=(*secArray)[indexOfMaxWeight];
885 assignedVol[1]=(*plaArray)[indexOfMaxWeight];
886 assignedVol[2]=(*strArray)[indexOfMaxWeight];
887 assignedVol[3]=(*pdxArray)[indexOfMaxWeight];
888 assignedVol[4]=(*pdzArray)[indexOfMaxWeight];
895 //__________________________________________________________________
896 Int_t AliTOFReconstructionerV2::SaveTracks(const Char_t *outname, const Int_t split)
899 // save reconstructed tracks into
902 TDirectory *savedir=gDirectory;
903 const Char_t *name="Writing Output";
904 cerr<<'\n'<<name<<"...\n";
905 gBenchmark->Start(name);
907 TFile *out=TFile::Open(outname,"RECREATE");
908 if (!out->IsOpen()) {
909 cerr<<"AliTOFReconstructionerV2::SaveTracks(): ";
910 cerr<<"file for TOF tracks is not open !\n";
915 TTree T("T","tree with TOF tracks");
916 T.Branch("tracks",&fTOFTracks,256000,split);
924 gBenchmark->Stop(name);
925 gBenchmark->Show(name);
928 //__________________________________________________________________
929 void AliTOFReconstructionerV2::Comparison(Int_t* rtIndex)
932 // perform MC comparison
933 // used also for track length
934 // for the time being
935 // Connect the AliRoot file containing Geometry, Kine, Hits, and Digits
939 Char_t *alifile = "galice.root";
941 TFile *gafl = (TFile*) gROOT->GetListOfFiles()->FindObject(alifile);
943 cout << "Open the ALIROOT-file " << alifile << endl;
944 gafl = new TFile(alifile);
947 cout << alifile << " is already open" << endl;
950 // Get AliRun object from file or create it if not on file
951 gAlice = (AliRun*) gafl->Get("gAlice");
953 cout << "AliRun object found on file" << endl;
955 gAlice = new AliRun("gAlice","Alice test program");
958 // Import the Trees for the event nEvent in the file
959 const Int_t nparticles = gAlice->GetEvent(nEvent);
960 if (nparticles <= 0) return;
962 // Get pointers to Alice detectors and Hits containers
963 AliDetector *TOF = gAlice->GetDetector("TOF");
964 Int_t ntracks = (Int_t) gAlice->TreeH()->GetEntries();
966 // Start loop on tracks in the hits containers
967 for (Int_t track=0; track < ntracks; track++) {
970 for(AliTOFhitT0* tofHit = (AliTOFhitT0*)TOF->FirstHit(track);
972 tofHit=(AliTOFhitT0*)TOF->NextHit()) {
974 Int_t ipart = tofHit->GetTrack();
975 if(ipart >= 80000) continue;
976 if(rtIndex[ipart] < 0) continue;
978 TParticle *part = gAlice->Particle(ipart);
980 // get first the pdg code
981 Int_t pdgCode=part->GetPdgCode();
984 Float_t trackLength=tofHit->GetLen(); // [cm]
986 // update the tof TClonesArray with TOF tracks
987 AliTOFTrackV2* oTOFtracks=(AliTOFTrackV2*)fTOFTracks->UncheckedAt(rtIndex[ipart]);
988 oTOFtracks->UpdateTrack(pdgCode,trackLength);
990 } // loop on hits connected to the current track
992 } // end loop on primary tracks
995 //__________________________________________________________________
996 Bool_t AliTOFReconstructionerV2::operator==(const AliTOFReconstructionerV2 & tofrecv2)const
999 // Reconstructioner are equal if their fField, fNDummyTracks, fScaleSigmaFactor and fStep are equal
1001 if( (fField==tofrecv2.fField)&&(fNDummyTracks==tofrecv2.fNDummyTracks)&&(fScaleSigmaFactor==tofrecv2.fScaleSigmaFactor)&&(fStep==tofrecv2.fStep))