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 **************************************************************************/
18 //_________________________________________________________________________
19 // This is a TTask for reconstruction V2 in TOF
20 // Description of the algorithm
21 //-- Author: F. Pierella | pierella@bo.infn.it
22 //////////////////////////////////////////////////////////////////////////////
25 #include <Riostream.h>
28 #include <TBenchmark.h>
29 #include <TClonesArray.h>
33 #include <TParticle.h>
38 #include <TVirtualMC.h>
40 #include "../TPC/AliTPCtrack.h"
41 #include "../TRD/AliTRDtrack.h"
42 #include "AliDetector.h"
43 #include "AliHeader.h"
44 #include "AliKalmanTrack.h"
45 #include "AliLoader.h"
47 #include "AliRunLoader.h"
49 #include "AliTOFConstants.h"
50 #include "AliTOFDigitMap.h"
51 #include "AliTOFHitMap.h"
52 #include "AliTOFReconstructionerV2.h"
53 #include "AliTOFTrackV2.h"
54 #include "AliTOFdigit.h"
55 #include "AliTOFhitT0.h"
57 ClassImp(AliTOFReconstructionerV2)
59 //____________________________________________________________________________
60 AliTOFReconstructionerV2::AliTOFReconstructionerV2():TTask("AliTOFReconstructionerV2","")
64 // set all member vars to zero
74 fTOFDigitsFile ="digits.root";
75 fTPCBackTracksFile="AliTPCBackTracks.root";
77 fBranchWithTracks =0x0;
80 //____________________________________________________________________________
81 AliTOFReconstructionerV2::AliTOFReconstructionerV2(char* tpcBackTracks, char* tofDigits):TTask("AliTOFReconstructionerV2","")
85 // default arguments are specified only in
88 // tpcBackTracks -> file name with backpropagated tracks in TPC
89 // tofDigits -> file name with TOF digits
94 fField =0.2; // default value 0.2 [Tesla]
95 fNDummyTracks=20; // by default 20 test tracks used
100 fTOFDigitsFile =tofDigits;
101 fTPCBackTracksFile=tpcBackTracks;
103 fBranchWithTracks =0x0;
105 // initialize the G3 geometry
109 // add Task to //root/Tasks folder
110 TTask * roottasks = (TTask*)gROOT->GetRootFolder()->FindObject("Tasks") ;
111 roottasks->Add(this) ;
114 //____________________________________________________________________________
115 AliTOFReconstructionerV2::AliTOFReconstructionerV2(const AliTOFReconstructionerV2 & rec)
118 // Dummy copy constructor
119 // required by coding conventions
125 //____________________________________________________________________________
126 AliTOFReconstructionerV2::~AliTOFReconstructionerV2()
130 // some delete has to be moved
153 delete fTOFDigitsFile;
156 if (fTPCBackTracksFile)
158 delete fTPCBackTracksFile;
167 if (fBranchWithTracks)
169 delete fBranchWithTracks;
170 fBranchWithTracks = 0;
175 //____________________________________________________________________________
176 void AliTOFReconstructionerV2::Exec(Option_t* option)
179 // Description of the algorithm:
187 // load TOF digits and fill the digit map
188 Int_t tofDigitsLoading=LoadTOFDigits();
190 // load back-propagated tracks in TPC
191 Int_t tpcTracksLoading=LoadTPCTracks();
193 if(tofDigitsLoading || tpcTracksLoading) {
194 cout<<" Couldn't start reconstruction V2. Exit."<<endl;
197 // or load TRD reconstructed tracks
198 // Int_t trdTracksLoading=LoadTRDTracks();
200 // create a TObjArray to store reconstructed tracks
201 // and reject fake tracks
202 const Int_t maxRecTracks = 10000; // max number of reconstructed tracks
205 const Float_t stripRegionHeight = 15.3; // [cm] height in radial direction
206 // of the volume where strips are placed
207 TObjArray trackArray(maxRecTracks);
210 fTOFTracks= new TClonesArray("AliTOFTrackV2");
211 // create a reference to fill the TClonesArray
212 TClonesArray &aTOFTracks = *fTOFTracks;
214 const Int_t maxIndex = 100000; // max number of primary tracks to be analysed
215 // the index of the rtIndex array is the track label
216 // the content of the array is -1 for fake tracks
217 // and the track index for good tracks
218 Float_t dEdXarray[maxRecTracks];
219 Int_t rtIndex[maxIndex];
220 for(Int_t i = 0; i < maxIndex; i++) rtIndex[i] = -1;
222 AliKalmanTrack::SetConvConst(100/0.299792458/fField);
224 Int_t nRecTracks = (Int_t) fKalmanTree->GetEntries();
225 cout<<"Found "<<nRecTracks<<" entries in the track tree "<<endl;
227 // load the tracks into the array
228 for (Int_t i=0; i<nRecTracks; i++) {
229 AliTPCtrack *iotrack=new AliTPCtrack();
230 fBranchWithTracks->SetAddress(&iotrack);
231 fKalmanTree->GetEvent(i);
232 trackArray.AddLast(iotrack);
233 Int_t trackLabel = iotrack->GetLabel();
234 dEdXarray[i]=iotrack->GetdEdx(); // usefull for PID
236 // start filling the TClonesArray of AliTOFTrackV2
237 Float_t trdXYZ[3]={0.,0.,0.};
238 Float_t trdPxPyPz[3]={0.,0.,0.};
240 // tpc outer wall positions
241 Double_t xk=iotrack->GetX();
242 // get the running coordinates in the lrf
245 Double_t y=iotrack->GetY();
246 Double_t z=iotrack->GetZ();
247 Double_t alpha=iotrack->GetAlpha();
248 GetGlobalXYZ(alpha, x, y, z);
249 Float_t tpcXYZ[3]={x,y,z};
251 // momentum at the end of TPC
252 Float_t lambda=TMath::ATan(iotrack->GetTgl());
253 Float_t invpt=TMath::Abs(iotrack->Get1Pt());
255 if (invpt) pt= 1./invpt; // pt
256 Float_t tpcmom=1./(invpt*TMath::Cos(lambda));
257 Float_t pz=tpcmom*TMath::Sin(lambda);
258 Float_t tpcPtPz[2]={pt,pz};
260 Int_t matchingStatus=-1;
261 if(trackLabel < 0) matchingStatus=0;
262 new(aTOFTracks[i]) AliTOFTrackV2(trackLabel,matchingStatus,tpcmom,dEdXarray[i],tpcXYZ,tpcPtPz,trdXYZ,trdPxPyPz);
263 // printf("rt with %d clusters and label %d \n",
264 // iotrack->GetNumberOfClusters(), trackLabel);
266 if(trackLabel < 0) continue;
267 if(trackLabel >= maxIndex) continue;
268 rtIndex[trackLabel] = i;
272 if(strstr(option,"MC")) Comparison(rtIndex);
274 // start loop on tracks
275 // and backpropagate them from TPC to TOF
276 // backpropagation is performed only
277 // for good tracks (fake tracks rejected)
280 for (Int_t i=0; i<nRecTracks; i++) {
282 //******* tracking: extract track coordinates, momentum, etc.
283 rt = (AliTPCtrack*) trackArray.UncheckedAt(i);
284 // track length to be implemented
285 // Double_t tr_length = rt->GetLength();
287 Int_t tpcTrackLabel=rt->GetLabel();
288 // reject fake tracks
289 //if(tpcTrackLabel< 0) continue;
291 // starting backpropagation to TOF
292 // here we assume to have backpropagated tracks in TPC
293 // starting point xk=246.055
294 // starting back propagation
295 // outer wall of the TPC
296 Int_t iOuterTPCWall=rt->PropagateTo(261.53,40.,0.06124);
297 // frame with air just to the beginning of the TOF
298 Int_t iFrameWithAir=rt->PropagateTo(370.,36.66,1.2931e-3);
299 // trough the wall of the TOF plate
300 // thickness has changed according to the
302 Int_t iTOFWall=rt->PropagateTo(370.11,24.01,2.7);
305 // outer wall of the TPC
306 Int_t iOuterTPCWall=rt->PropagateTo(261.53,40.,0.06124);
307 // air in between TPC and TRD
308 Int_t iFrameWithAir=rt->PropagateTo(294.5,36.66,1.2931e-3);
310 // mean density for the TRD calculated from
311 // TRD Technical Design Report
312 // page 11 -> global thickness
313 // page 23 -> different main layers thickness (Radiator Air/ Drift Chamber Gas /G10)
314 // page 139 -> material budget and radiation lengths
315 Int_t iTRD=rt->PropagateTo(369.1,171.7,0.33);
316 // air in between TRD and TOF
317 Int_t iFrameWithAirbis=rt->PropagateTo(370.,36.66,1.2931e-3);
318 // trough the wall of the TOF plate
319 Int_t iTOFWall=rt->PropagateTo(370.11,24.01,2.7);
322 // select only cases when
323 // backpropagation succeded
324 // and particle is in the geometrical TOF acceptance along Z
326 AliTOFTrackV2* oTOFtracks=(AliTOFTrackV2*)fTOFTracks->UncheckedAt(i);
327 Bool_t outOfZacceptance=(rt->GetZ()<=380.);
328 if(outOfZacceptance) oTOFtracks->SetMatchingStatus(-2);
330 if(iOuterTPCWall==1 && iFrameWithAir==1 && iTOFWall==1 && (!outOfZacceptance)){
332 // get sigmaY and sigmaZ
333 rt->GetExternalCovariance(cc);
334 //Double_t sigmaY =TMath::Sqrt(cc[0]); // [cm]
335 //Double_t sigmaZ =TMath::Sqrt(cc[2]); // [cm]
337 // arrays used by the DigitFinder
339 TArrayI *secArray= new TArrayI(nSlot);
340 TArrayI *plaArray= new TArrayI(nSlot);
341 TArrayI *strArray= new TArrayI(nSlot);
342 TArrayI *pdzArray= new TArrayI(nSlot);
343 TArrayI *pdxArray= new TArrayI(nSlot);
345 // make fNDummyTracks clones of the current backpropagated track
346 // make a copy of the current track
347 // smear according to the backpropagated area
348 for (Int_t j=0; j<fNDummyTracks; i++) {
349 AliTPCtrack *dummyrt=new AliTPCtrack(*rt);
351 //Double_t ylrf= dummyrt->GetY(); // P0
352 //Double_t zlrf= dummyrt->GetZ(); // P1
354 // smear according to sigmaY and sigmaZ
355 //Double_t ylrfNew=gRandom->Gaus(ylrf,fScaleSigmaFactor*sigmaY);
356 //Double_t zlrfNew=gRandom->Gaus(zlrf,fScaleSigmaFactor*sigmaZ);
358 // set Y and Z accordingly
359 // setter to be added in the class AliTPCtrack
360 // here I have to modify the AliTPCtrack class
361 // adding the setters for Y and Z
362 //dummyrt->SetY(ylrfNew);
363 //dummyrt->SetZ(zlrfNew);
365 // start fine-backpropagation inside the TOF
366 Bool_t padNotFound =kTRUE;
367 Bool_t isInStripsRegion=kTRUE;
368 Double_t xk=dummyrt->GetX();
370 while (padNotFound && isInStripsRegion){
372 // here we assume a frame with air
373 dummyrt->PropagateTo(xk,36.66,1.2931e-3);
374 // get the running coordinates in the lrf
377 Double_t y=dummyrt->GetY();
378 Double_t z=dummyrt->GetZ();
379 Double_t alpha=dummyrt->GetAlpha();
380 GetGlobalXYZ(alpha, x, y, z);
382 // check if the point falls into a pad
383 // using the G3 geometry
384 Int_t* volumeID = new Int_t[AliTOFConstants::fgkmaxtoftree];
385 // volumeID[0] -> TOF Sector range [1-18]
386 // volumeID[1] -> TOF Plate range [1- 5]
387 // volumeID[2] -> TOF Strip max range [1-20]
388 // volumeID[3] -> TOF Pad along Z range [1- 2]
389 // volumeID[4] -> TOF Pad along X range [1-48]
391 Float_t zInPadFrame=0.;
392 Float_t xInPadFrame=0.;
393 IsInsideThePad((Float_t)x,(Float_t)y,(Float_t)z, volumeID, zInPadFrame, xInPadFrame);
394 // adding protection versus wrong volume numbering
395 // to be released in the next release after debugging
399 secArray->Set(nSlot-1);
400 plaArray->Set(nSlot-1);
401 strArray->Set(nSlot-1);
402 pdzArray->Set(nSlot-1);
403 pdxArray->Set(nSlot-1);
405 (*secArray)[nSlot-1]=volumeID[0];
406 (*plaArray)[nSlot-1]=volumeID[1];
407 (*strArray)[nSlot-1]=volumeID[2];
408 (*pdzArray)[nSlot-1]=volumeID[3];
409 (*pdxArray)[nSlot-1]=volumeID[4];
411 } // track falls into a pad volume
415 // check on xk to stop the fine-propagation
416 if(xk>=(370.+stripRegionHeight)) isInStripsRegion=kFALSE;
418 } // close the while for fine-propagation
421 } // end loop on test tracks
423 // start TOF digit finder
424 Int_t assignedVol[5]={0,0,0,0,0};
426 Int_t* digitTrackArray=0x0;
427 Bool_t assignedDigit=DigitFinder(secArray, plaArray, strArray, pdzArray, pdxArray, assignedVol, digitTrackArray, tdc);
431 // fill the tree for tracks with time of flight
432 // tof is given in tdc bin
433 // conversion to [ns]
434 Float_t binWidth=50.; // [ps]
435 Float_t timeOfFlight=tdc*binWidth/1000.;
437 // only the first track number contributing
438 // to the assigned digit
439 Int_t tofDigitTrackLabel=digitTrackArray[0];
441 // matching status for the current track
443 if(tpcTrackLabel==digitTrackArray[0] || tpcTrackLabel==digitTrackArray[1] || tpcTrackLabel==digitTrackArray[0]) matching=3;
444 oTOFtracks->UpdateTrack(tofDigitTrackLabel, matching, timeOfFlight);
446 // fill the TClonesArray for tracks with no time of flight
448 oTOFtracks->SetMatchingStatus(matching);
451 // delete used memory for tmp arrays used by DigitFinder
458 } // close the if for succeded backpropagation in TOF acceptance along z
460 } // end loop on reconstructed tracks
462 // free used memory for digitmap
465 // save array with TOF tracks
466 Int_t output=SaveTracks();
467 if(output) cout << "Error writing TOF tracks " << endl;
471 //__________________________________________________________________
472 void AliTOFReconstructionerV2::Init(Option_t* opt)
475 // Initialize the AliTOFReconstructionerV2
481 //__________________________________________________________________
482 Int_t AliTOFReconstructionerV2::LoadTPCTracks()
485 // Connect the tree and the branch
486 // with reconstructed tracks
487 // backpropagated in the TPC
489 gBenchmark->Start("LoadTPCTracks");
491 TFile *kalFile = TFile::Open(fTPCBackTracksFile.Data());
492 if (!kalFile->IsOpen()) {cerr<<"Can't open AliTPCBackTracks.root !\n"; return 3;}
494 // tracks from Kalman
496 char treename[100]; sprintf(treename,"TreeT_TPCb_%d",event);
497 fKalmanTree=(TTree*)kalFile->Get(treename);
498 if (!fKalmanTree) {cerr<<"Can't get a tree with TPC back tracks !\n"; return 4;}
500 // otherwise you get always 0 for 1/pt
501 AliKalmanTrack::SetConvConst(100/0.299792458/fField);
503 fBranchWithTracks=fKalmanTree->GetBranch("tracks");
504 Int_t kalEntries =(Int_t)fKalmanTree->GetEntries();
505 cout<<"Number of loaded Tracks :"<< kalEntries <<endl;
507 gBenchmark->Stop("LoadTPCTracks");
508 gBenchmark->Show("LoadTPCTracks");
512 //__________________________________________________________________
513 Int_t AliTOFReconstructionerV2::LoadTRDTracks()
516 // Connect the tree and the branch
517 // with reconstructed tracks in TRD
519 gBenchmark->Start("LoadTRDTracks");
522 const Int_t nPrimaries = 84210/16;
523 const Int_t maxIndex = nPrimaries;
524 Int_t rtIndex[maxIndex];
526 TFile *tf=TFile::Open("AliTRDtracks.root");
528 if (!tf->IsOpen()) {cerr<<"Can't open AliTRDtracks.root !\n"; return 3;}
529 TObjArray tarray(2000);
531 sprintf(tname,"TRDb_%d",nEvent);
532 TTree *tracktree=(TTree*)tf->Get(tname);
534 TBranch *tbranch=tracktree->GetBranch("tracks");
536 Int_t nRecTracks = (Int_t) tracktree->GetEntries();
537 cerr<<"Found "<<nRecTracks<<" entries in the track tree"<<endl;
539 for (Int_t i=0; i<nRecTracks; i++) {
540 AliTRDtrack *iotrack=new AliTRDtrack();
541 tbranch->SetAddress(&iotrack);
542 tracktree->GetEvent(i);
543 tarray.AddLast(iotrack);
544 Int_t trackLabel = iotrack->GetLabel();
546 // printf("rt with %d clusters and label %d \n",
547 // iotrack->GetNumberOfClusters(), trackLabel);
549 if(trackLabel < 0) continue;
550 if(trackLabel >= maxIndex) continue;
551 rtIndex[trackLabel] = i;
554 gBenchmark->Stop("LoadTRDTracks");
555 gBenchmark->Show("LoadTRDTracks");
560 //__________________________________________________________________
561 Int_t AliTOFReconstructionerV2::LoadTOFDigits()
564 // Connect the TClonesArray with TOF
565 // digits and fill the digit map
566 // used by the DigitFinder
570 gBenchmark->Start("LoadTOFDigits");
572 TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(fTOFDigitsFile.Data());
574 cout<<"headerFile already open \n";
577 if(!file)file=TFile::Open(fTOFDigitsFile.Data());
580 // Get AliRun object from file
582 gAlice = (AliRun*)file->Get("gAlice");
583 if (gAlice) printf("AliRun object found on file\n");
587 if (iEvNum == 0) iEvNum = (Int_t) gAlice->TreeE()->GetEntries();
590 AliTOFdigit *tofdigit;
592 AliTOF * tof = (AliTOF *) gAlice->GetDetector("TOF") ;
595 cout << "<LoadTOFDigits> No TOF detector found" << endl;
600 for (Int_t ievent = 0; ievent < iEvNum; ievent++) {
602 gAlice->GetEvent(ievent) ;
603 if(gAlice->TreeD()==0) {
604 cout << "<LoadTOFDigits> No TreeD found" << endl;
611 gAlice->ResetDigits();
612 gAlice->TreeD()->GetEvent(ievent);
613 fTOFDigits = tof->Digits();
615 ndig=fTOFDigits->GetEntries();
617 // create the digit map
618 fDigitsMap = new AliTOFDigitMap(fTOFDigits);
621 cout << "<LoadTOFDigits> found " << ndig
622 << " TOF digits for event " << ievent << endl;
624 for (Int_t k=0; k<ndig; k++) {
625 tofdigit= (AliTOFdigit*) fTOFDigits->UncheckedAt(k);
626 Float_t tdc=tofdigit->GetTdc();
627 // adc value can be used for weighting
628 //Float_t adc=tofdigit->GetAdc();
631 Int_t vol[5]; // location for a digit
632 Int_t sector = tofdigit->GetSector(); // range [1-18]
633 Int_t plate = tofdigit->GetPlate(); // range [1- 5]
634 Int_t strip = tofdigit->GetStrip(); // range [1-20]
635 Int_t padx = tofdigit->GetPadx(); // range [1-48]
636 Int_t padz = tofdigit->GetPadz(); // range [1- 2]
645 Bool_t isDigitBad = (sector<1 || sector>18 || plate<1 || plate >5 || padz<1 || padz>2 || padx<1 || padx>48);
648 cout << "<LoadTOFDigits> strange digit found" << endl;
653 // Fill the digit map checking if the location is already used
654 // in this case we take the earliest signal
655 if (fDigitsMap->TestHit(vol) != kEmpty) {
656 // start comparison in between the 2 digit
657 AliTOFdigit *dig = static_cast<AliTOFdigit*>(fDigitsMap->GetHit(vol));
658 if(tdc < (dig->GetTdc())) fDigitsMap->SetHit(vol,k);
659 // we can add also the check on adc value
660 // by selecting the largest adc value
662 fDigitsMap->SetHit(vol,k);
664 // to be added protection versus 2-digit on the same pad
665 // we have to have memory also of the second digit
667 } // for (k=0; k<ndig; k++)
669 } // end loop on events
671 gBenchmark->Stop("LoadTOFDigits");
672 gBenchmark->Show("LoadTOFDigits");
676 //__________________________________________________________________
677 void AliTOFReconstructionerV2::IsInsideThePad(Float_t x, Float_t y, Float_t z, Int_t *nGeom, Float_t& zPad, Float_t& xPad)
679 // input: x,y,z - coordinates of a point in the mrf [cm]
680 // output: array nGeom[]
681 // nGeom[0] - the TOF sector number, 1,2,...,18 along azimuthal direction starting from -90 deg.
682 // nGeom[1] - the TOF module number, 1,2,3,4,5=C,B,A,B,C along z-direction
683 // nGeom[2] - the TOF strip number, 1,2,... along z-direction
684 // nGeom[3] - the TOF padz number, 1,2=NPZ across a strip
685 // nGeom[4] - the TOF padx number, 1,2,...,48=NPX along a strip
686 // zPad, xPad - coordinates of the hit in the pad frame
687 // numbering is adopted for the version 3.08 of AliRoot
689 // from Hits: sec,pla,str,padz,padx=4,2,14,2,35
690 // Vol. n.0: ALIC, copy number 1
691 // Vol. n.1: B077, copy number 1
692 // Vol. n.2: B074, copy number 5
693 // Vol. n.3: BTO2, copy number 1
694 // Vol. n.4: FTOB, copy number 2
695 // Vol. n.5: FLTB, copy number 0
696 // Vol. n.6: FSTR, copy number 14
697 // Vol. n.7: FSEN, copy number 0
698 // Vol. n.8: FSEZ, copy number 2
699 // Vol. n.9: FSEX, copy number 35
700 // Vol. n.10: FPAD, copy number 0
704 Int_t sector=0,module=0,strip=0,padz=0,padx=0;
705 Int_t i,numed,nLevel,copyNumber;
710 for (i=0; i<AliTOFConstants::fgkmaxtoftree; i++) nGeom[i]=0;
718 TGeant3 * fG3Geom = (TGeant3*) gMC;
720 fG3Geom->Gmedia(xTOF, numed);
721 gcvolu=fG3Geom->Gcvolu();
722 nLevel=gcvolu->nlevel;
724 for (Int_t i=0; i<nLevel; i++) {
725 strncpy(name,(char*) (&gcvolu->names[i]),4);
726 cout<<"Vol. n."<<i<<": "<<name<<", copy number "<<gcvolu->number[i]<<endl;
730 // sector type name: B071(1,2,...,10),B074(1,2,3,4,5-PHOS),B075(1,2,3-RICH)
731 strncpy(name,(char*) (&gcvolu->names[2]),4);
732 // volume copy: 1,2,...,10 for B071, 1,2,3,4,5 for B074, 1,2,3 for B075
733 copyNumber=gcvolu->number[2];
734 if(!strcmp(name,"B071")) {
735 if (copyNumber>=6 && copyNumber<=8) {
736 sector=copyNumber+10;
737 } else if (copyNumber>=1 && copyNumber<=5){
742 } else if(!strcmp(name,"B075")) {
743 sector=copyNumber+12;
744 } else if(!strcmp(name,"B074")) {
745 if (copyNumber>=1 && copyNumber<=3){
755 // we'll use the module value in z-direction:
757 // the module order in z-direction: FTOC,FTOB,FTOA,FTOB,FTOC
758 // the module copy: 2 2 0 1 1
759 // module type name: FTOA, FTOB, FTOC
760 strncpy(name,(char*) (&gcvolu->names[4]),4);
762 copyNumber=gcvolu->number[4];
763 if(!strcmp(name,"FTOC")) {
769 } else if(!strcmp(name,"FTOB")) {
775 } else if(!strcmp(name,"FTOA")) {
784 // strip type name: FSTR
785 strncpy(name,(char*) (&gcvolu->names[6]),4);
787 copyNumber=gcvolu->number[6];
788 if(!strcmp(name,"FSTR")) strip=copyNumber;
795 // padz type name: FSEZ
796 strncpy(name,(char*) (&gcvolu->names[8]),4);
798 copyNumber=gcvolu->number[8];
799 if(!strcmp(name,"FSEZ")) padz=copyNumber;
805 // padx type name: FSEX
806 strncpy(name,(char*) (&gcvolu->names[9]),4);
808 copyNumber=gcvolu->number[9];
809 if(!strcmp(name,"FSEX")) padx=copyNumber;
821 //__________________________________________________________________
822 void AliTOFReconstructionerV2::GetGlobalXYZ(Double_t alpha, Double_t& x, Double_t& y, Double_t& z)
825 // return the current running coordinates of
826 // the track in the global reference frame
827 // x, y and z have to initialized to the
828 // local frame coordinates by the caller
829 // alpha is the alpha coordinate in the TPC Kalman
832 // it take into account differences in between
833 // TPC and TRD local coordinates frames
834 if (alpha < -TMath::Pi()) alpha += 2*TMath::Pi();
835 else if (alpha >= TMath::Pi()) alpha -= 2*TMath::Pi();
838 Double_t tmp=x*TMath::Cos(alpha) - y*TMath::Sin(alpha);
839 y=x*TMath::Sin(alpha) + y*TMath::Cos(alpha);
843 //__________________________________________________________________
844 Bool_t AliTOFReconstructionerV2::DigitFinder(TArrayI *secArray, TArrayI *plaArray, TArrayI *strArray, TArrayI *pdzArray, TArrayI *pdxArray, Int_t* assignedVol, Int_t* digitTrackArray, Float_t& tdc)
848 // input: arrays with sectors, plates, strips, padz, padx
849 // found during fine-propagation of probe tracks
851 // output kFALSE if signal is not found
852 // kTRUE if signal is found
853 // in this case the assignedVol array contains the digit volume numbers
854 // and digitTrackArray the track numbers (max 3) contributing to the
858 Int_t nFilledSlot=secArray->GetSize();
861 Float_t maxWeight=-1.;
862 Int_t indexOfMaxWeight=-1;
863 for (Int_t i = 0; i < nFilledSlot; i++) {
864 Int_t vol[5]; // location for a digit
865 vol[0] = (*secArray)[i];
866 vol[1] = (*plaArray)[i];
867 vol[2] = (*strArray)[i];
868 vol[3] = (*pdxArray)[i];
869 vol[4] = (*pdzArray)[i];
871 // check for digit in the current location
872 if (fDigitsMap->TestHit(vol) != kEmpty) {
874 AliTOFdigit *dig = static_cast<AliTOFdigit*>(fDigitsMap->GetHit(vol));
875 Float_t adcWeight=dig->GetAdc();
876 if(adcWeight > maxWeight){
880 digitTrackArray=dig->GetTracks();
882 } // if(adcWeight > maxWeight)
883 } // close if (fDigitsMap->TestHit(vol) != kEmpty)
887 if(indexOfMaxWeight!=-1){
888 assignedVol[0]=(*secArray)[indexOfMaxWeight];
889 assignedVol[1]=(*plaArray)[indexOfMaxWeight];
890 assignedVol[2]=(*strArray)[indexOfMaxWeight];
891 assignedVol[3]=(*pdxArray)[indexOfMaxWeight];
892 assignedVol[4]=(*pdzArray)[indexOfMaxWeight];
899 //__________________________________________________________________
900 Int_t AliTOFReconstructionerV2::SaveTracks(const Char_t *outname, const Int_t split)
903 // save reconstructed tracks into
906 TDirectory *savedir=gDirectory;
907 const Char_t *name="Writing Output";
908 cerr<<'\n'<<name<<"...\n";
909 gBenchmark->Start(name);
911 TFile *out=TFile::Open(outname,"RECREATE");
912 if (!out->IsOpen()) {
913 cerr<<"AliTOFReconstructionerV2::SaveTracks(): ";
914 cerr<<"file for TOF tracks is not open !\n";
919 TTree T("T","tree with TOF tracks");
920 T.Branch("tracks",&fTOFTracks,256000,split);
927 gBenchmark->Stop(name);
928 gBenchmark->Show(name);
932 //__________________________________________________________________
933 void AliTOFReconstructionerV2::Comparison(Int_t* rtIndex)
936 // perform MC comparison
937 // used also for track length
938 // for the time being
939 // Connect the AliRoot file containing Geometry, Kine, Hits, and Digits
943 Char_t *datafile = "galice.root";
945 AliRunLoader *rl = AliRunLoader::Open(datafile);
948 Error("Exec","Can not open session for file %s",datafile);
951 // Get AliRun object from file or create it if not on file
953 gAlice = rl->GetAliRun();
955 cout << "AliRun object found on file" << endl;
957 gAlice = new AliRun("gAlice","Alice test program");
960 AliTOF* TOF = (AliTOF *) gAlice->GetDetector ("TOF");
964 // Import the Trees for the event nEvent in the file
965 rl->GetEvent(nEvent);
966 const Int_t nparticles = rl->GetNumberOfEvents();
967 if (nparticles <= 0) return;
969 AliLoader* tofloader = rl->GetLoader("TOFLoader");
970 if (tofloader == 0x0)
972 Error("AliTOFReconstructioner","Can not get TOF Loader from Run Loader.");
977 // Get pointers to Alice detectors and Hits containers
978 tofloader->LoadHits();
979 Int_t ntracks = (Int_t) tofloader->TreeH()->GetEntries();
980 TOF->SetTreeAddress();
981 // Start loop on tracks in the hits containers
982 for (Int_t track=0; track < ntracks; track++) {
985 for(AliTOFhitT0* tofHit = (AliTOFhitT0*)TOF->FirstHit(track);
987 tofHit=(AliTOFhitT0*)TOF->NextHit()) {
989 Int_t ipart = tofHit->GetTrack();
990 if(ipart >= 80000) continue;
991 if(rtIndex[ipart] < 0) continue;
993 TParticle *part = gAlice->Particle(ipart);
995 // get first the pdg code
996 Int_t pdgCode=part->GetPdgCode();
999 Float_t trackLength=tofHit->GetLen(); // [cm]
1001 // update the tof TClonesArray with TOF tracks
1002 AliTOFTrackV2* oTOFtracks=(AliTOFTrackV2*)fTOFTracks->UncheckedAt(rtIndex[ipart]);
1003 oTOFtracks->UpdateTrack(pdgCode,trackLength);
1005 } // loop on hits connected to the current track
1007 } // end loop on primary tracks
1010 //__________________________________________________________________
1011 Bool_t AliTOFReconstructionerV2::operator==(const AliTOFReconstructionerV2 & tofrecv2)const
1014 // Reconstructioner are equal if their fField, fNDummyTracks, fScaleSigmaFactor and fStep are equal
1016 if( (fField==tofrecv2.fField)&&(fNDummyTracks==tofrecv2.fNDummyTracks)&&(fScaleSigmaFactor==tofrecv2.fScaleSigmaFactor)&&(fStep==tofrecv2.fStep))