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"
32 #include <Riostream.h>
33 #include <Riostream.h>
35 #include "TVirtualMC.h"
37 #include "AliDetector.h"
40 #include "AliTOFDigitMap.h"
41 #include "AliTOFHitMap.h"
42 #include "AliTOFhitT0.h"
43 #include "AliTOFdigit.h"
44 #include "AliTOFConstants.h"
45 #include "AliTOFReconstructionerV2.h"
46 #include "AliTOFTrackV2.h"
48 #include "AliKalmanTrack.h"
49 #include "../TPC/AliTPCtrack.h"
50 #include "../TRD/AliTRDtrack.h"
52 ClassImp(AliTOFReconstructionerV2)
54 //____________________________________________________________________________
55 AliTOFReconstructionerV2::AliTOFReconstructionerV2():TTask("AliTOFReconstructionerV2","")
59 // set all member vars to zero
69 fTOFDigitsFile ="digits.root";
70 fTPCBackTracksFile="AliTPCBackTracks.root";
72 fBranchWithTracks =0x0;
75 //____________________________________________________________________________
76 AliTOFReconstructionerV2::AliTOFReconstructionerV2(char* tpcBackTracks, char* tofDigits):TTask("AliTOFReconstructionerV2","")
80 // default arguments are specified only in
83 // tpcBackTracks -> file name with backpropagated tracks in TPC
84 // tofDigits -> file name with TOF digits
89 fField =0.2; // default value 0.2 [Tesla]
90 fNDummyTracks=20; // by default 20 test tracks used
95 fTOFDigitsFile =tofDigits;
96 fTPCBackTracksFile=tpcBackTracks;
98 fBranchWithTracks =0x0;
100 // initialize the G3 geometry
104 // add Task to //root/Tasks folder
105 TTask * roottasks = (TTask*)gROOT->GetRootFolder()->FindObject("Tasks") ;
106 roottasks->Add(this) ;
109 //____________________________________________________________________________
110 AliTOFReconstructionerV2::AliTOFReconstructionerV2(const AliTOFReconstructionerV2 & rec)
113 // Dummy copy constructor
114 // required by coding conventions
120 //____________________________________________________________________________
121 AliTOFReconstructionerV2::~AliTOFReconstructionerV2()
125 // some delete has to be moved
148 delete fTOFDigitsFile;
151 if (fTPCBackTracksFile)
153 delete fTPCBackTracksFile;
162 if (fBranchWithTracks)
164 delete fBranchWithTracks;
165 fBranchWithTracks = 0;
170 //____________________________________________________________________________
171 void AliTOFReconstructionerV2::Exec(Option_t* option)
174 // Description of the algorithm:
182 // load TOF digits and fill the digit map
183 Int_t tofDigitsLoading=LoadTOFDigits();
185 // load back-propagated tracks in TPC
186 Int_t tpcTracksLoading=LoadTPCTracks();
188 if(tofDigitsLoading || tpcTracksLoading) {
189 cout<<" Couldn't start reconstruction V2. Exit."<<endl;
192 // or load TRD reconstructed tracks
193 // Int_t trdTracksLoading=LoadTRDTracks();
195 // create a TObjArray to store reconstructed tracks
196 // and reject fake tracks
197 const Int_t maxRecTracks = 10000; // max number of reconstructed tracks
200 const Float_t stripRegionHeight = 15.3; // [cm] height in radial direction
201 // of the volume where strips are placed
202 TObjArray trackArray(maxRecTracks);
205 fTOFTracks= new TClonesArray("AliTOFTrackV2");
206 // create a reference to fill the TClonesArray
207 TClonesArray &aTOFTracks = *fTOFTracks;
209 const Int_t maxIndex = 100000; // max number of primary tracks to be analysed
210 // the index of the rtIndex array is the track label
211 // the content of the array is -1 for fake tracks
212 // and the track index for good tracks
213 Float_t dEdXarray[maxRecTracks];
214 Int_t rtIndex[maxIndex];
215 for(Int_t i = 0; i < maxIndex; i++) rtIndex[i] = -1;
217 AliKalmanTrack::SetConvConst(100/0.299792458/fField);
219 Int_t nRecTracks = (Int_t) fKalmanTree->GetEntries();
220 cout<<"Found "<<nRecTracks<<" entries in the track tree "<<endl;
222 // load the tracks into the array
223 for (Int_t i=0; i<nRecTracks; i++) {
224 AliTPCtrack *iotrack=new AliTPCtrack();
225 fBranchWithTracks->SetAddress(&iotrack);
226 fKalmanTree->GetEvent(i);
227 trackArray.AddLast(iotrack);
228 Int_t trackLabel = iotrack->GetLabel();
229 dEdXarray[i]=iotrack->GetdEdx(); // usefull for PID
231 // start filling the TClonesArray of AliTOFTrackV2
232 Float_t trdXYZ[3]={0.,0.,0.};
233 Float_t trdPxPyPz[3]={0.,0.,0.};
235 // tpc outer wall positions
236 Double_t xk=iotrack->GetX();
237 // get the running coordinates in the lrf
240 Double_t y=iotrack->GetY();
241 Double_t z=iotrack->GetZ();
242 Double_t alpha=iotrack->GetAlpha();
243 GetGlobalXYZ(alpha, x, y, z);
244 Float_t tpcXYZ[3]={x,y,z};
246 // momentum at the end of TPC
247 Float_t lambda=TMath::ATan(iotrack->GetTgl());
248 Float_t invpt=TMath::Abs(iotrack->Get1Pt());
250 if (invpt) pt= 1./invpt; // pt
251 Float_t tpcmom=1./(invpt*TMath::Cos(lambda));
252 Float_t pz=tpcmom*TMath::Sin(lambda);
253 Float_t tpcPtPz[2]={pt,pz};
255 Int_t matchingStatus=-1;
256 if(trackLabel < 0) matchingStatus=0;
257 new(aTOFTracks[i]) AliTOFTrackV2(trackLabel,matchingStatus,tpcmom,dEdXarray[i],tpcXYZ,tpcPtPz,trdXYZ,trdPxPyPz);
258 // printf("rt with %d clusters and label %d \n",
259 // iotrack->GetNumberOfClusters(), trackLabel);
261 if(trackLabel < 0) continue;
262 if(trackLabel >= maxIndex) continue;
263 rtIndex[trackLabel] = i;
267 if(strstr(option,"MC")) Comparison(rtIndex);
269 // start loop on tracks
270 // and backpropagate them from TPC to TOF
271 // backpropagation is performed only
272 // for good tracks (fake tracks rejected)
275 for (Int_t i=0; i<nRecTracks; i++) {
277 //******* tracking: extract track coordinates, momentum, etc.
278 rt = (AliTPCtrack*) trackArray.UncheckedAt(i);
279 // track length to be implemented
280 // Double_t tr_length = rt->GetLength();
282 Int_t tpcTrackLabel=rt->GetLabel();
283 // reject fake tracks
284 //if(tpcTrackLabel< 0) continue;
286 // starting backpropagation to TOF
287 // here we assume to have backpropagated tracks in TPC
288 // starting point xk=246.055
289 // starting back propagation
290 // outer wall of the TPC
291 Int_t iOuterTPCWall=rt->PropagateTo(261.53,40.,0.06124);
292 // frame with air just to the beginning of the TOF
293 Int_t iFrameWithAir=rt->PropagateTo(370.,36.66,1.2931e-3);
294 // trough the wall of the TOF plate
295 // thickness has changed according to the
297 Int_t iTOFWall=rt->PropagateTo(370.11,24.01,2.7);
300 // outer wall of the TPC
301 Int_t iOuterTPCWall=rt->PropagateTo(261.53,40.,0.06124);
302 // air in between TPC and TRD
303 Int_t iFrameWithAir=rt->PropagateTo(294.5,36.66,1.2931e-3);
305 // mean density for the TRD calculated from
306 // TRD Technical Design Report
307 // page 11 -> global thickness
308 // page 23 -> different main layers thickness (Radiator Air/ Drift Chamber Gas /G10)
309 // page 139 -> material budget and radiation lengths
310 Int_t iTRD=rt->PropagateTo(369.1,171.7,0.33);
311 // air in between TRD and TOF
312 Int_t iFrameWithAirbis=rt->PropagateTo(370.,36.66,1.2931e-3);
313 // trough the wall of the TOF plate
314 Int_t iTOFWall=rt->PropagateTo(370.11,24.01,2.7);
317 // select only cases when
318 // backpropagation succeded
319 // and particle is in the geometrical TOF acceptance along Z
321 AliTOFTrackV2* oTOFtracks=(AliTOFTrackV2*)fTOFTracks->UncheckedAt(i);
322 Bool_t outOfZacceptance=(rt->GetZ()<=380.);
323 if(outOfZacceptance) oTOFtracks->SetMatchingStatus(-2);
325 if(iOuterTPCWall==1 && iFrameWithAir==1 && iTOFWall==1 && (!outOfZacceptance)){
327 // get sigmaY and sigmaZ
328 rt->GetExternalCovariance(cc);
329 //Double_t sigmaY =TMath::Sqrt(cc[0]); // [cm]
330 //Double_t sigmaZ =TMath::Sqrt(cc[2]); // [cm]
332 // arrays used by the DigitFinder
334 TArrayI *secArray= new TArrayI(nSlot);
335 TArrayI *plaArray= new TArrayI(nSlot);
336 TArrayI *strArray= new TArrayI(nSlot);
337 TArrayI *pdzArray= new TArrayI(nSlot);
338 TArrayI *pdxArray= new TArrayI(nSlot);
340 // make fNDummyTracks clones of the current backpropagated track
341 // make a copy of the current track
342 // smear according to the backpropagated area
343 for (Int_t j=0; j<fNDummyTracks; i++) {
344 AliTPCtrack *dummyrt=new AliTPCtrack(*rt);
346 //Double_t ylrf= dummyrt->GetY(); // P0
347 //Double_t zlrf= dummyrt->GetZ(); // P1
349 // smear according to sigmaY and sigmaZ
350 //Double_t ylrfNew=gRandom->Gaus(ylrf,fScaleSigmaFactor*sigmaY);
351 //Double_t zlrfNew=gRandom->Gaus(zlrf,fScaleSigmaFactor*sigmaZ);
353 // set Y and Z accordingly
354 // setter to be added in the class AliTPCtrack
355 // here I have to modify the AliTPCtrack class
356 // adding the setters for Y and Z
357 //dummyrt->SetY(ylrfNew);
358 //dummyrt->SetZ(zlrfNew);
360 // start fine-backpropagation inside the TOF
361 Bool_t padNotFound =kTRUE;
362 Bool_t isInStripsRegion=kTRUE;
363 Double_t xk=dummyrt->GetX();
365 while (padNotFound && isInStripsRegion){
367 // here we assume a frame with air
368 dummyrt->PropagateTo(xk,36.66,1.2931e-3);
369 // get the running coordinates in the lrf
372 Double_t y=dummyrt->GetY();
373 Double_t z=dummyrt->GetZ();
374 Double_t alpha=dummyrt->GetAlpha();
375 GetGlobalXYZ(alpha, x, y, z);
377 // check if the point falls into a pad
378 // using the G3 geometry
379 Int_t* volumeID = new Int_t[AliTOFConstants::fgkmaxtoftree];
380 // volumeID[0] -> TOF Sector range [1-18]
381 // volumeID[1] -> TOF Plate range [1- 5]
382 // volumeID[2] -> TOF Strip max range [1-20]
383 // volumeID[3] -> TOF Pad along Z range [1- 2]
384 // volumeID[4] -> TOF Pad along X range [1-48]
386 Float_t zInPadFrame=0.;
387 Float_t xInPadFrame=0.;
388 IsInsideThePad((Float_t)x,(Float_t)y,(Float_t)z, volumeID, zInPadFrame, xInPadFrame);
389 // adding protection versus wrong volume numbering
390 // to be released in the next release after debugging
394 secArray->Set(nSlot-1);
395 plaArray->Set(nSlot-1);
396 strArray->Set(nSlot-1);
397 pdzArray->Set(nSlot-1);
398 pdxArray->Set(nSlot-1);
400 (*secArray)[nSlot-1]=volumeID[0];
401 (*plaArray)[nSlot-1]=volumeID[1];
402 (*strArray)[nSlot-1]=volumeID[2];
403 (*pdzArray)[nSlot-1]=volumeID[3];
404 (*pdxArray)[nSlot-1]=volumeID[4];
406 } // track falls into a pad volume
410 // check on xk to stop the fine-propagation
411 if(xk>=(370.+stripRegionHeight)) isInStripsRegion=kFALSE;
413 } // close the while for fine-propagation
416 } // end loop on test tracks
418 // start TOF digit finder
419 Int_t assignedVol[5]={0,0,0,0,0};
421 Int_t* digitTrackArray=0x0;
422 Bool_t assignedDigit=DigitFinder(secArray, plaArray, strArray, pdzArray, pdxArray, assignedVol, digitTrackArray, tdc);
426 // fill the tree for tracks with time of flight
427 // tof is given in tdc bin
428 // conversion to [ns]
429 Float_t binWidth=50.; // [ps]
430 Float_t timeOfFlight=tdc*binWidth/1000.;
432 // only the first track number contributing
433 // to the assigned digit
434 Int_t tofDigitTrackLabel=digitTrackArray[0];
436 // matching status for the current track
438 if(tpcTrackLabel==digitTrackArray[0] || tpcTrackLabel==digitTrackArray[1] || tpcTrackLabel==digitTrackArray[0]) matching=3;
439 oTOFtracks->UpdateTrack(tofDigitTrackLabel, matching, timeOfFlight);
441 // fill the TClonesArray for tracks with no time of flight
443 oTOFtracks->SetMatchingStatus(matching);
446 // delete used memory for tmp arrays used by DigitFinder
453 } // close the if for succeded backpropagation in TOF acceptance along z
455 } // end loop on reconstructed tracks
457 // free used memory for digitmap
460 // save array with TOF tracks
461 Int_t output=SaveTracks();
462 if(output) cout << "Error writing TOF tracks " << endl;
466 //__________________________________________________________________
467 void AliTOFReconstructionerV2::Init(Option_t* opt)
470 // Initialize the AliTOFReconstructionerV2
476 //__________________________________________________________________
477 Int_t AliTOFReconstructionerV2::LoadTPCTracks()
480 // Connect the tree and the branch
481 // with reconstructed tracks
482 // backpropagated in the TPC
484 gBenchmark->Start("LoadTPCTracks");
486 TFile *kalFile = TFile::Open(fTPCBackTracksFile.Data());
487 if (!kalFile->IsOpen()) {cerr<<"Can't open AliTPCBackTracks.root !\n"; return 3;}
489 // tracks from Kalman
491 char treename[100]; sprintf(treename,"TreeT_TPCb_%d",event);
492 fKalmanTree=(TTree*)kalFile->Get(treename);
493 if (!fKalmanTree) {cerr<<"Can't get a tree with TPC back tracks !\n"; return 4;}
495 // otherwise you get always 0 for 1/pt
496 AliKalmanTrack::SetConvConst(100/0.299792458/fField);
498 fBranchWithTracks=fKalmanTree->GetBranch("tracks");
499 Int_t kalEntries =(Int_t)fKalmanTree->GetEntries();
500 cout<<"Number of loaded Tracks :"<< kalEntries <<endl;
502 gBenchmark->Stop("LoadTPCTracks");
503 gBenchmark->Show("LoadTPCTracks");
507 //__________________________________________________________________
508 Int_t AliTOFReconstructionerV2::LoadTRDTracks()
511 // Connect the tree and the branch
512 // with reconstructed tracks in TRD
514 gBenchmark->Start("LoadTRDTracks");
517 const Int_t nPrimaries = 84210/16;
518 const Int_t maxIndex = nPrimaries;
519 Int_t rtIndex[maxIndex];
521 TFile *tf=TFile::Open("AliTRDtracks.root");
523 if (!tf->IsOpen()) {cerr<<"Can't open AliTRDtracks.root !\n"; return 3;}
524 TObjArray tarray(2000);
526 sprintf(tname,"TRDb_%d",nEvent);
527 TTree *tracktree=(TTree*)tf->Get(tname);
529 TBranch *tbranch=tracktree->GetBranch("tracks");
531 Int_t nRecTracks = (Int_t) tracktree->GetEntries();
532 cerr<<"Found "<<nRecTracks<<" entries in the track tree"<<endl;
534 for (Int_t i=0; i<nRecTracks; i++) {
535 AliTRDtrack *iotrack=new AliTRDtrack();
536 tbranch->SetAddress(&iotrack);
537 tracktree->GetEvent(i);
538 tarray.AddLast(iotrack);
539 Int_t trackLabel = iotrack->GetLabel();
541 // printf("rt with %d clusters and label %d \n",
542 // iotrack->GetNumberOfClusters(), trackLabel);
544 if(trackLabel < 0) continue;
545 if(trackLabel >= maxIndex) continue;
546 rtIndex[trackLabel] = i;
549 gBenchmark->Stop("LoadTRDTracks");
550 gBenchmark->Show("LoadTRDTracks");
555 //__________________________________________________________________
556 Int_t AliTOFReconstructionerV2::LoadTOFDigits()
559 // Connect the TClonesArray with TOF
560 // digits and fill the digit map
561 // used by the DigitFinder
565 gBenchmark->Start("LoadTOFDigits");
567 TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(fTOFDigitsFile.Data());
569 cout<<"headerFile already open \n";
572 if(!file)file=TFile::Open(fTOFDigitsFile.Data());
575 // Get AliRun object from file
577 gAlice = (AliRun*)file->Get("gAlice");
578 if (gAlice) printf("AliRun object found on file\n");
582 if (iEvNum == 0) iEvNum = (Int_t) gAlice->TreeE()->GetEntries();
585 AliTOFdigit *tofdigit;
587 AliTOF * tof = (AliTOF *) gAlice->GetDetector("TOF") ;
590 cout << "<LoadTOFDigits> No TOF detector found" << endl;
595 for (Int_t ievent = 0; ievent < iEvNum; ievent++) {
597 gAlice->GetEvent(ievent) ;
598 if(gAlice->TreeD()==0) {
599 cout << "<LoadTOFDigits> No TreeD found" << endl;
606 gAlice->ResetDigits();
607 gAlice->TreeD()->GetEvent(ievent);
608 fTOFDigits = tof->Digits();
610 ndig=fTOFDigits->GetEntries();
612 // create the digit map
613 fDigitsMap = new AliTOFDigitMap(fTOFDigits);
616 cout << "<LoadTOFDigits> found " << ndig
617 << " TOF digits for event " << ievent << endl;
619 for (Int_t k=0; k<ndig; k++) {
620 tofdigit= (AliTOFdigit*) fTOFDigits->UncheckedAt(k);
621 Float_t tdc=tofdigit->GetTdc();
622 // adc value can be used for weighting
623 //Float_t adc=tofdigit->GetAdc();
626 Int_t vol[5]; // location for a digit
627 Int_t sector = tofdigit->GetSector(); // range [1-18]
628 Int_t plate = tofdigit->GetPlate(); // range [1- 5]
629 Int_t strip = tofdigit->GetStrip(); // range [1-20]
630 Int_t padx = tofdigit->GetPadx(); // range [1-48]
631 Int_t padz = tofdigit->GetPadz(); // range [1- 2]
640 Bool_t isDigitBad = (sector<1 || sector>18 || plate<1 || plate >5 || padz<1 || padz>2 || padx<1 || padx>48);
643 cout << "<LoadTOFDigits> strange digit found" << endl;
648 // Fill the digit map checking if the location is already used
649 // in this case we take the earliest signal
650 if (fDigitsMap->TestHit(vol) != kEmpty) {
651 // start comparison in between the 2 digit
652 AliTOFdigit *dig = static_cast<AliTOFdigit*>(fDigitsMap->GetHit(vol));
653 if(tdc < (dig->GetTdc())) fDigitsMap->SetHit(vol,k);
654 // we can add also the check on adc value
655 // by selecting the largest adc value
657 fDigitsMap->SetHit(vol,k);
659 // to be added protection versus 2-digit on the same pad
660 // we have to have memory also of the second digit
662 } // for (k=0; k<ndig; k++)
664 } // end loop on events
666 gBenchmark->Stop("LoadTOFDigits");
667 gBenchmark->Show("LoadTOFDigits");
671 //__________________________________________________________________
672 void AliTOFReconstructionerV2::IsInsideThePad(Float_t x, Float_t y, Float_t z, Int_t *nGeom, Float_t& zPad, Float_t& xPad)
674 // input: x,y,z - coordinates of a point in the mrf [cm]
675 // output: array nGeom[]
676 // nGeom[0] - the TOF sector number, 1,2,...,18 along azimuthal direction starting from -90 deg.
677 // nGeom[1] - the TOF module number, 1,2,3,4,5=C,B,A,B,C along z-direction
678 // nGeom[2] - the TOF strip number, 1,2,... along z-direction
679 // nGeom[3] - the TOF padz number, 1,2=NPZ across a strip
680 // nGeom[4] - the TOF padx number, 1,2,...,48=NPX along a strip
681 // zPad, xPad - coordinates of the hit in the pad frame
682 // numbering is adopted for the version 3.08 of AliRoot
684 // from Hits: sec,pla,str,padz,padx=4,2,14,2,35
685 // Vol. n.0: ALIC, copy number 1
686 // Vol. n.1: B077, copy number 1
687 // Vol. n.2: B074, copy number 5
688 // Vol. n.3: BTO2, copy number 1
689 // Vol. n.4: FTOB, copy number 2
690 // Vol. n.5: FLTB, copy number 0
691 // Vol. n.6: FSTR, copy number 14
692 // Vol. n.7: FSEN, copy number 0
693 // Vol. n.8: FSEZ, copy number 2
694 // Vol. n.9: FSEX, copy number 35
695 // Vol. n.10: FPAD, copy number 0
699 Int_t sector=0,module=0,strip=0,padz=0,padx=0;
700 Int_t i,numed,nLevel,copyNumber;
705 for (i=0; i<AliTOFConstants::fgkmaxtoftree; i++) nGeom[i]=0;
713 TGeant3 * fG3Geom = (TGeant3*) gMC;
715 fG3Geom->Gmedia(xTOF, numed);
716 gcvolu=fG3Geom->Gcvolu();
717 nLevel=gcvolu->nlevel;
719 for (Int_t i=0; i<nLevel; i++) {
720 strncpy(name,(char*) (&gcvolu->names[i]),4);
721 cout<<"Vol. n."<<i<<": "<<name<<", copy number "<<gcvolu->number[i]<<endl;
725 // sector type name: B071(1,2,...,10),B074(1,2,3,4,5-PHOS),B075(1,2,3-RICH)
726 strncpy(name,(char*) (&gcvolu->names[2]),4);
727 // volume copy: 1,2,...,10 for B071, 1,2,3,4,5 for B074, 1,2,3 for B075
728 copyNumber=gcvolu->number[2];
729 if(!strcmp(name,"B071")) {
730 if (copyNumber>=6 && copyNumber<=8) {
731 sector=copyNumber+10;
732 } else if (copyNumber>=1 && copyNumber<=5){
737 } else if(!strcmp(name,"B075")) {
738 sector=copyNumber+12;
739 } else if(!strcmp(name,"B074")) {
740 if (copyNumber>=1 && copyNumber<=3){
750 // we'll use the module value in z-direction:
752 // the module order in z-direction: FTOC,FTOB,FTOA,FTOB,FTOC
753 // the module copy: 2 2 0 1 1
754 // module type name: FTOA, FTOB, FTOC
755 strncpy(name,(char*) (&gcvolu->names[4]),4);
757 copyNumber=gcvolu->number[4];
758 if(!strcmp(name,"FTOC")) {
764 } else if(!strcmp(name,"FTOB")) {
770 } else if(!strcmp(name,"FTOA")) {
779 // strip type name: FSTR
780 strncpy(name,(char*) (&gcvolu->names[6]),4);
782 copyNumber=gcvolu->number[6];
783 if(!strcmp(name,"FSTR")) strip=copyNumber;
790 // padz type name: FSEZ
791 strncpy(name,(char*) (&gcvolu->names[8]),4);
793 copyNumber=gcvolu->number[8];
794 if(!strcmp(name,"FSEZ")) padz=copyNumber;
800 // padx type name: FSEX
801 strncpy(name,(char*) (&gcvolu->names[9]),4);
803 copyNumber=gcvolu->number[9];
804 if(!strcmp(name,"FSEX")) padx=copyNumber;
816 //__________________________________________________________________
817 void AliTOFReconstructionerV2::GetGlobalXYZ(Double_t alpha, Double_t& x, Double_t& y, Double_t& z)
820 // return the current running coordinates of
821 // the track in the global reference frame
822 // x, y and z have to initialized to the
823 // local frame coordinates by the caller
824 // alpha is the alpha coordinate in the TPC Kalman
827 // it take into account differences in between
828 // TPC and TRD local coordinates frames
829 if (alpha < -TMath::Pi()) alpha += 2*TMath::Pi();
830 else if (alpha >= TMath::Pi()) alpha -= 2*TMath::Pi();
833 Double_t tmp=x*TMath::Cos(alpha) - y*TMath::Sin(alpha);
834 y=x*TMath::Sin(alpha) + y*TMath::Cos(alpha);
838 //__________________________________________________________________
839 Bool_t AliTOFReconstructionerV2::DigitFinder(TArrayI *secArray, TArrayI *plaArray, TArrayI *strArray, TArrayI *pdzArray, TArrayI *pdxArray, Int_t* assignedVol, Int_t* digitTrackArray, Float_t& tdc)
843 // input: arrays with sectors, plates, strips, padz, padx
844 // found during fine-propagation of probe tracks
846 // output kFALSE if signal is not found
847 // kTRUE if signal is found
848 // in this case the assignedVol array contains the digit volume numbers
849 // and digitTrackArray the track numbers (max 3) contributing to the
853 Int_t nFilledSlot=secArray->GetSize();
856 Float_t maxWeight=-1.;
857 Int_t indexOfMaxWeight=-1;
858 for (Int_t i = 0; i < nFilledSlot; i++) {
859 Int_t vol[5]; // location for a digit
860 vol[0] = (*secArray)[i];
861 vol[1] = (*plaArray)[i];
862 vol[2] = (*strArray)[i];
863 vol[3] = (*pdxArray)[i];
864 vol[4] = (*pdzArray)[i];
866 // check for digit in the current location
867 if (fDigitsMap->TestHit(vol) != kEmpty) {
869 AliTOFdigit *dig = static_cast<AliTOFdigit*>(fDigitsMap->GetHit(vol));
870 Float_t adcWeight=dig->GetAdc();
871 if(adcWeight > maxWeight){
875 digitTrackArray=dig->GetTracks();
877 } // if(adcWeight > maxWeight)
878 } // close if (fDigitsMap->TestHit(vol) != kEmpty)
882 if(indexOfMaxWeight!=-1){
883 assignedVol[0]=(*secArray)[indexOfMaxWeight];
884 assignedVol[1]=(*plaArray)[indexOfMaxWeight];
885 assignedVol[2]=(*strArray)[indexOfMaxWeight];
886 assignedVol[3]=(*pdxArray)[indexOfMaxWeight];
887 assignedVol[4]=(*pdzArray)[indexOfMaxWeight];
894 //__________________________________________________________________
895 Int_t AliTOFReconstructionerV2::SaveTracks(const Char_t *outname, const Int_t split)
898 // save reconstructed tracks into
901 TDirectory *savedir=gDirectory;
902 const Char_t *name="Writing Output";
903 cerr<<'\n'<<name<<"...\n";
904 gBenchmark->Start(name);
906 TFile *out=TFile::Open(outname,"RECREATE");
907 if (!out->IsOpen()) {
908 cerr<<"AliTOFReconstructionerV2::SaveTracks(): ";
909 cerr<<"file for TOF tracks is not open !\n";
914 TTree T("T","tree with TOF tracks");
915 T.Branch("tracks",&fTOFTracks,256000,split);
923 gBenchmark->Stop(name);
924 gBenchmark->Show(name);
927 //__________________________________________________________________
928 void AliTOFReconstructionerV2::Comparison(Int_t* rtIndex)
931 // perform MC comparison
932 // used also for track length
933 // for the time being
934 // Connect the AliRoot file containing Geometry, Kine, Hits, and Digits
938 Char_t *alifile = "galice.root";
940 TFile *gafl = (TFile*) gROOT->GetListOfFiles()->FindObject(alifile);
942 cout << "Open the ALIROOT-file " << alifile << endl;
943 gafl = new TFile(alifile);
946 cout << alifile << " is already open" << endl;
949 // Get AliRun object from file or create it if not on file
950 gAlice = (AliRun*) gafl->Get("gAlice");
952 cout << "AliRun object found on file" << endl;
954 gAlice = new AliRun("gAlice","Alice test program");
957 // Import the Trees for the event nEvent in the file
958 const Int_t nparticles = gAlice->GetEvent(nEvent);
959 if (nparticles <= 0) return;
961 // Get pointers to Alice detectors and Hits containers
962 AliDetector *TOF = gAlice->GetDetector("TOF");
963 Int_t ntracks = (Int_t) gAlice->TreeH()->GetEntries();
965 // Start loop on tracks in the hits containers
966 for (Int_t track=0; track < ntracks; track++) {
969 for(AliTOFhitT0* tofHit = (AliTOFhitT0*)TOF->FirstHit(track);
971 tofHit=(AliTOFhitT0*)TOF->NextHit()) {
973 Int_t ipart = tofHit->GetTrack();
974 if(ipart >= 80000) continue;
975 if(rtIndex[ipart] < 0) continue;
977 TParticle *part = gAlice->Particle(ipart);
979 // get first the pdg code
980 Int_t pdgCode=part->GetPdgCode();
983 Float_t trackLength=tofHit->GetLen(); // [cm]
985 // update the tof TClonesArray with TOF tracks
986 AliTOFTrackV2* oTOFtracks=(AliTOFTrackV2*)fTOFTracks->UncheckedAt(rtIndex[ipart]);
987 oTOFtracks->UpdateTrack(pdgCode,trackLength);
989 } // loop on hits connected to the current track
991 } // end loop on primary tracks
994 //__________________________________________________________________
995 Bool_t AliTOFReconstructionerV2::operator==(const AliTOFReconstructionerV2 & tofrecv2)const
998 // Reconstructioner are equal if their fField, fNDummyTracks, fScaleSigmaFactor and fStep are equal
1000 if( (fField==tofrecv2.fField)&&(fNDummyTracks==tofrecv2.fNDummyTracks)&&(fScaleSigmaFactor==tofrecv2.fScaleSigmaFactor)&&(fStep==tofrecv2.fStep))