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 //--------------------------------------------------------------------//
18 // AliTOFtracker Class //
19 // Task: Perform association of the ESD tracks to TOF Clusters //
20 // and Update ESD track with associated TOF Cluster parameters //
22 // -- Authors : S. Arcelli, C. Zampolli (Bologna University and INFN) //
23 // -- Contacts: Annalisa.De.Caro@cern.ch //
24 // -- : Chiara.Zampolli@bo.infn.it //
25 // -- : Silvia.Arcelli@bo.infn.it //
27 //--------------------------------------------------------------------//
32 #include <TSeqCollection.h>
33 #include <TClonesArray.h>
34 #include <TObjArray.h>
35 #include <TGeoManager.h>
40 #include "AliGeomManager.h"
41 #include "AliESDtrack.h"
42 #include "AliESDEvent.h"
43 #include "AliESDpid.h"
45 #include "AliTrackPointArray.h"
46 #include "AliCDBManager.h"
48 //#include "AliTOFpidESD.h"
49 #include "AliTOFRecoParam.h"
50 #include "AliTOFReconstructor.h"
51 #include "AliTOFcluster.h"
52 #include "AliTOFGeometry.h"
53 #include "AliTOFtracker.h"
54 #include "AliTOFtrack.h"
56 extern TGeoManager *gGeoManager;
60 ClassImp(AliTOFtracker)
62 //_____________________________________________________________________________
63 AliTOFtracker::AliTOFtracker():
73 fTracks(new TClonesArray("AliTOFtrack")),
74 fSeeds(new TObjArray(100)),
75 fTOFtrackPoints(new TObjArray(10)),
94 //AliTOFtracker main Ctor
96 for (Int_t ii=0; ii<kMaxCluster; ii++) fClusters[ii]=0x0;
98 // Gettimg the geometry
99 fGeom= new AliTOFGeometry();
104 //_____________________________________________________________________________
105 AliTOFtracker::~AliTOFtracker() {
112 if(!(AliCDBManager::Instance()->GetCacheFlag())){
118 delete fHDigClusTime;
124 delete fHRecSigYVsPWin;
125 delete fHRecSigZVsPWin;
137 if (fTOFtrackPoints){
138 fTOFtrackPoints->Delete();
139 delete fTOFtrackPoints;
144 for (Int_t ii=0; ii<kMaxCluster; ii++)
145 if (fClusters[ii]) fClusters[ii]->Delete();
149 //_____________________________________________________________________________
150 void AliTOFtracker::GetPidSettings(AliESDpid *esdPID) {
152 // Sets TOF resolution from RecoParams
155 esdPID->GetTOFResponse().SetTimeResolution(fkRecoParam->GetTimeResolution());
157 AliWarning("fkRecoParam not yet set; cannot set PID settings");
159 //_____________________________________________________________________________
160 Int_t AliTOFtracker::PropagateBack(AliESDEvent * const event) {
162 // Gets seeds from ESD event and Match with TOF Clusters
165 // initialize RecoParam for current event
166 AliDebug(1,"Initializing params for TOF");
168 fkRecoParam = AliTOFReconstructor::GetRecoParam(); // instantiate reco param from STEER...
170 if (fkRecoParam == 0x0) {
171 AliFatal("No Reco Param found for TOF!!!");
173 //fkRecoParam->Dump();
174 //if(fkRecoParam->GetApplyPbPbCuts())fkRecoParam=fkRecoParam->GetPbPbparam();
175 //fkRecoParam->PrintParameters();
177 //Initialise some counters
186 Int_t ntrk=event->GetNumberOfTracks();
190 //Load ESD tracks into a local Array of ESD Seeds
191 for (Int_t i=0; i<fNseeds; i++)
192 fSeeds->AddLast(event->GetTrack(i));
194 //Prepare ESD tracks candidates for TOF Matching
197 //First Step with Strict Matching Criterion
200 //Second Step with Looser Matching Criterion
203 AliInfo(Form("Number of matched tracks = %d (good = %d, bad = %d)",fnmatch,fngoodmatch,fnbadmatch));
205 //Update the matched ESD tracks
207 for (Int_t i=0; i<ntrk; i++) {
208 AliESDtrack *t=event->GetTrack(i);
209 AliESDtrack *seed =(AliESDtrack*)fSeeds->At(i);
211 if ( (seed->GetStatus()&AliESDtrack::kTOFin)!=0 ) {
212 t->SetStatus(AliESDtrack::kTOFin);
213 //if(seed->GetTOFsignal()>0){
214 if ( (seed->GetStatus()&AliESDtrack::kTOFout)!=0 ) {
215 t->SetStatus(AliESDtrack::kTOFout);
216 t->SetTOFsignal(seed->GetTOFsignal());
217 t->SetTOFcluster(seed->GetTOFcluster());
218 t->SetTOFsignalToT(seed->GetTOFsignalToT());
219 t->SetTOFsignalRaw(seed->GetTOFsignalRaw());
220 t->SetTOFsignalDz(seed->GetTOFsignalDz());
221 t->SetTOFsignalDx(seed->GetTOFsignalDx());
222 t->SetTOFDeltaBC(seed->GetTOFDeltaBC());
223 t->SetTOFL0L1(seed->GetTOFL0L1());
224 t->SetTOFCalChannel(seed->GetTOFCalChannel());
225 Int_t tlab[3]; seed->GetTOFLabel(tlab);
226 t->SetTOFLabel(tlab);
228 Double_t alphaA = (Double_t)t->GetAlpha();
229 Double_t xA = (Double_t)t->GetX();
230 Double_t yA = (Double_t)t->GetY();
231 Double_t zA = (Double_t)t->GetZ();
232 Double_t p1A = (Double_t)t->GetSnp();
233 Double_t p2A = (Double_t)t->GetTgl();
234 Double_t p3A = (Double_t)t->GetSigned1Pt();
235 const Double_t *covA = (Double_t*)t->GetCovariance();
237 // Make attention, please:
238 // AliESDtrack::fTOFInfo array does not be stored in the AliESDs.root file
239 // it is there only for a check during the reconstruction step.
240 Float_t info[10]; seed->GetTOFInfo(info);
242 AliDebug(3,Form(" distance=%f; residual in the pad reference frame: dX=%f, dZ=%f", info[0],info[1],info[2]));
245 // by calling the AliESDtrack::UpdateTrackParams,
246 // the current track parameters are changed
247 // and it could cause refit problems.
248 // We need to update only the following track parameters:
249 // the track length and expected times.
250 // Removed AliESDtrack::UpdateTrackParams call
251 // Called AliESDtrack::SetIntegratedTimes(...) and
252 // AliESDtrack::SetIntegratedLength() routines.
254 AliTOFtrack *track = new AliTOFtrack(*seed);
255 t->UpdateTrackParams(track,AliESDtrack::kTOFout); // to be checked - AdC
257 Double_t time[10]; t->GetIntegratedTimes(time);
260 Double_t time[10]; seed->GetIntegratedTimes(time);
261 t->SetIntegratedTimes(time);
263 Double_t length = seed->GetIntegratedLength();
264 t->SetIntegratedLength(length);
266 Double_t alphaB = (Double_t)t->GetAlpha();
267 Double_t xB = (Double_t)t->GetX();
268 Double_t yB = (Double_t)t->GetY();
269 Double_t zB = (Double_t)t->GetZ();
270 Double_t p1B = (Double_t)t->GetSnp();
271 Double_t p2B = (Double_t)t->GetTgl();
272 Double_t p3B = (Double_t)t->GetSigned1Pt();
273 const Double_t *covB = (Double_t*)t->GetCovariance();
274 AliDebug(2,"Track params -now(before)-:");
275 AliDebug(2,Form(" X: %f(%f), Y: %f(%f), Z: %f(%f) --- alpha: %f(%f)",
280 AliDebug(2,Form(" p1: %f(%f), p2: %f(%f), p3: %f(%f)",
284 AliDebug(2,Form(" cov1: %f(%f), cov2: %f(%f), cov3: %f(%f)"
285 " cov4: %f(%f), cov5: %f(%f), cov6: %f(%f)"
286 " cov7: %f(%f), cov8: %f(%f), cov9: %f(%f)"
287 " cov10: %f(%f), cov11: %f(%f), cov12: %f(%f)"
288 " cov13: %f(%f), cov14: %f(%f), cov15: %f(%f)",
305 AliDebug(3,Form(" TOF params: %6d %f %f %f %f %f %6d %3d %f %f %f %f %f %f",
307 t->GetTOFsignalRaw(),
309 t->GetTOFsignalToT(),
312 t->GetTOFCalChannel(),
314 t->GetIntegratedLength(),
315 time[0], time[1], time[2], time[3], time[4]
323 // Now done in AliESDpid
324 // fPid->MakePID(event,timeZero);
332 //_________________________________________________________________________
333 void AliTOFtracker::CollectESD() {
334 //prepare the set of ESD tracks to be matched to clusters in TOF
339 TClonesArray &aTOFTrack = *fTracks;
340 for (Int_t i=0; i<fNseeds; i++) {
342 AliESDtrack *t =(AliESDtrack*)fSeeds->At(i);
343 if ((t->GetStatus()&AliESDtrack::kTPCout)==0)continue;
345 AliTOFtrack *track = new AliTOFtrack(*t); // New
346 Float_t x = (Float_t)track->GetX(); //New
348 // TRD 'good' tracks, already propagated at 371 cm
349 if ( ( (t->GetStatus()&AliESDtrack::kTRDout)!=0 ) &&
350 ( x >= AliTOFGeometry::Rmin() ) ) {
351 if ( track->PropagateToInnerTOF() ) {
353 AliDebug(1,Form(" TRD propagated track till rho = %fcm."
354 " And then the track has been propagated till rho = %fcm.",
355 x, (Float_t)track->GetX()));
357 track->SetSeedIndex(i);
358 t->UpdateTrackParams(track,AliESDtrack::kTOFin);
359 new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
366 // Propagate the rest of TPCbp
368 if ( track->PropagateToInnerTOF() ) {
370 AliDebug(1,Form(" TPC propagated track till rho = %fcm."
371 " And then the track has been propagated till rho = %fcm.",
372 x, (Float_t)track->GetX()));
374 track->SetSeedIndex(i);
375 t->UpdateTrackParams(track,AliESDtrack::kTOFin);
376 new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
384 AliInfo(Form("Number of TOF seeds = %d (Type 1 = %d, Type 2 = %d)",fNseedsTOF,seedsTOF1,seedsTOF2));
386 // Sort according uncertainties on track position
390 //_________________________________________________________________________
391 void AliTOFtracker::MatchTracks( Bool_t mLastStep){
394 // Parameters used/regulating the reconstruction
396 static Float_t corrLen=0.75;
397 static Float_t detDepth=15.3;
398 static Float_t padDepth=0.5;
400 const Float_t kSpeedOfLight= 2.99792458e-2; // speed of light [cm/ps]
401 const Float_t kTimeOffset = 0.; // time offset for tracking algorithm [ps]
403 Float_t dY=AliTOFGeometry::XPad();
404 Float_t dZ=AliTOFGeometry::ZPad();
406 Float_t sensRadius = fkRecoParam->GetSensRadius();
407 Float_t stepSize = fkRecoParam->GetStepSize();
408 Float_t scaleFact = fkRecoParam->GetWindowScaleFact();
409 Float_t dyMax=fkRecoParam->GetWindowSizeMaxY();
410 Float_t dzMax=fkRecoParam->GetWindowSizeMaxZ();
411 Float_t dCut=fkRecoParam->GetDistanceCut();
412 Double_t maxChi2=fkRecoParam->GetMaxChi2TRD();
413 Bool_t timeWalkCorr = fkRecoParam->GetTimeWalkCorr();
415 AliDebug(1,"++++++++++++++TOF Reconstruction Parameters:++++++++++++ \n");
416 AliDebug(1,Form("TOF sens radius: %f",sensRadius));
417 AliDebug(1,Form("TOF step size: %f",stepSize));
418 AliDebug(1,Form("TOF Window scale factor: %f",scaleFact));
419 AliDebug(1,Form("TOF Window max dy: %f",dyMax));
420 AliDebug(1,Form("TOF Window max dz: %f",dzMax));
421 AliDebug(1,Form("TOF distance Cut: %f",dCut));
422 AliDebug(1,Form("TOF Max Chi2: %f",maxChi2));
423 AliDebug(1,Form("Time Walk Correction? : %d",timeWalkCorr));
426 //Match ESD tracks to clusters in TOF
428 // Get the number of propagation steps
429 Int_t nSteps=(Int_t)(detDepth/stepSize);
431 //PH Arrays (moved outside of the loop)
432 Float_t * trackPos[4];
433 for (Int_t ii=0; ii<4; ii++) trackPos[ii] = new Float_t[nSteps];
434 Int_t * clind = new Int_t[fN];
437 const Int_t kNclusterMax = 1000; // related to fN value
438 TGeoHMatrix global[kNclusterMax];
441 for (Int_t iseed=0; iseed<fNseedsTOF; iseed++) {
443 fTOFtrackPoints->Clear();
445 for (Int_t ii=0; ii<kNclusterMax; ii++)
447 AliTOFtrack *track =(AliTOFtrack*)fTracks->UncheckedAt(iseed);
448 AliESDtrack *t =(AliESDtrack*)fSeeds->At(track->GetSeedIndex());
449 //if ( t->GetTOFsignal()>0. ) continue;
450 if ( (t->GetStatus()&AliESDtrack::kTOFout)!=0 ) continue;
451 AliTOFtrack *trackTOFin = new AliTOFtrack(*track);
453 // Determine a window around the track
455 trackTOFin->GetExternalParameters(x,par);
457 trackTOFin->GetExternalCovariance(cov);
459 if (cov[0]<0. || cov[2]<0.) {
460 AliWarning(Form("Very strange track (%d)! At least one of its covariance matrix diagonal elements is negative!",iseed));
467 ((5*TMath::Sqrt(TMath::Abs(cov[0])) + 0.5*dY + 2.5*TMath::Abs(par[2]))/sensRadius);
470 (5*TMath::Sqrt(TMath::Abs(cov[2])) + 0.5*dZ + 2.5*TMath::Abs(par[3]));
472 Double_t phi=TMath::ATan2(par[0],x) + trackTOFin->GetAlpha();
473 if (phi<-TMath::Pi())phi+=2*TMath::Pi();
474 if (phi>=TMath::Pi())phi-=2*TMath::Pi();
477 //upper limit on window's size.
478 if (dz> dzMax) dz=dzMax;
479 if (dphi*sensRadius> dyMax) dphi=dyMax/sensRadius;
482 // find the clusters in the window of the track
484 for (Int_t k=FindClusterIndex(z-dz); k<fN; k++) {
486 if (nc>=kNclusterMax) {
487 AliWarning("No more matchable clusters can be stored! Please, increase the corresponding vectors size.");
491 AliTOFcluster *c=fClusters[k];
492 if (c->GetZ() > z+dz) break;
493 if (c->IsUsed()) continue;
494 if (!c->GetStatus()) {
495 AliDebug(1,"Cluster in channel declared bad!");
496 continue; // skip bad channels as declared in OCDB
499 Double_t dph=TMath::Abs(c->GetPhi()-phi);
500 if (dph>TMath::Pi()) dph-=2.*TMath::Pi();
501 if (TMath::Abs(dph)>dphi) continue;
503 Double_t yc=(c->GetPhi() - trackTOFin->GetAlpha())*c->GetR();
504 Double_t p[2]={yc, c->GetZ()};
505 Double_t cov2[3]= {dY*dY/12., 0., dZ*dZ/12.};
506 if (trackTOFin->AliExternalTrackParam::GetPredictedChi2(p,cov2) > maxChi2)continue;
511 ind[0]=c->GetDetInd(0);
512 ind[1]=c->GetDetInd(1);
513 ind[2]=c->GetDetInd(2);
514 ind[3]=c->GetDetInd(3);
515 ind[4]=c->GetDetInd(4);
516 fGeom->GetVolumePath(ind,path);
517 gGeoManager->cd(path);
518 global[nc] = *gGeoManager->GetCurrentMatrix();
522 AliDebug(1,Form(" Number of matchable TOF clusters for the track number %d: %d",iseed,nc));
524 //start fine propagation
526 Int_t nStepsDone = 0;
527 for( Int_t istep=0; istep<nSteps; istep++){
529 Float_t xs=AliTOFGeometry::RinTOF()+istep*0.1;
530 Double_t ymax=xs*TMath::Tan(0.5*AliTOFGeometry::GetAlpha());
533 Double_t ysect=trackTOFin->GetYat(xs,skip);
536 if (!trackTOFin->Rotate(AliTOFGeometry::GetAlpha())) {
539 } else if (ysect <-ymax) {
540 if (!trackTOFin->Rotate(-AliTOFGeometry::GetAlpha())) {
545 if(!trackTOFin->PropagateTo(xs)) {
551 // store the running point (Globalrf) - fine propagation
554 trackTOFin->GetXYZ(r);
555 trackPos[0][istep]= (Float_t) r[0];
556 trackPos[1][istep]= (Float_t) r[1];
557 trackPos[2][istep]= (Float_t) r[2];
558 trackPos[3][istep]= trackTOFin->GetIntegratedLength();
563 Bool_t accept = kFALSE;
564 Bool_t isInside = kFALSE;
565 for (Int_t istep=0; istep<nStepsDone; istep++) {
567 Float_t ctrackPos[3];
568 ctrackPos[0] = trackPos[0][istep];
569 ctrackPos[1] = trackPos[1][istep];
570 ctrackPos[2] = trackPos[2][istep];
572 //now see whether the track matches any of the TOF clusters
576 for (Int_t i=0; i<nc; i++) {
577 isInside = fGeom->IsInsideThePad(global[i],ctrackPos,dist3d);
580 Float_t yLoc = dist3d[1];
581 Float_t rLoc = TMath::Sqrt(dist3d[0]*dist3d[0]+dist3d[2]*dist3d[2]);
582 accept = (TMath::Abs(yLoc)<padDepth*0.5 && rLoc<dCut);
583 AliDebug(2," I am in the case mLastStep==kTRUE ");
590 fTOFtrackPoints->AddLast(new AliTOFtrackPoint(clind[i],
591 TMath::Sqrt(dist3d[0]*dist3d[0] + dist3d[1]*dist3d[1] + dist3d[2]*dist3d[2]),
592 dist3d[2], dist3d[0],
593 AliTOFGeometry::RinTOF()+istep*0.1,trackPos[3][istep]));
595 AliDebug(2,Form(" dist3dLoc[0] = %f, dist3dLoc[1] = %f, dist3dLoc[2] = %f ",dist3d[0],dist3d[1],dist3d[2]));
597 if(accept &&!mLastStep)break;
600 } //end for on the clusters
601 if(accept &&!mLastStep)break;
602 } //end for on the steps
604 AliDebug(1,Form(" Number of track points for the track number %d: %d",iseed,nfound));
615 // now choose the cluster to be matched with the track.
620 Float_t mindist=1000.;
623 for (Int_t iclus= 0; iclus<nfound;iclus++){
624 AliTOFtrackPoint *matchableTOFcluster = (AliTOFtrackPoint*)fTOFtrackPoints->At(iclus);
625 if (matchableTOFcluster->Distance()<mindist) {
626 mindist = matchableTOFcluster->Distance();
627 mindistZ = matchableTOFcluster->DistanceZ(); // Z distance in the
632 mindistY = matchableTOFcluster->DistanceY(); // Y distance in the
637 xpos = matchableTOFcluster->PropRadius();
638 idclus = matchableTOFcluster->Index();
639 recL = matchableTOFcluster->Length() + corrLen*0.5;
641 } // loop on found TOF track points
644 AliDebug(1,Form("Reconstructed track %d doesn't match any TOF cluster", iseed));
649 AliTOFcluster *c=fClusters[idclus];
651 AliDebug(2, Form("%7d %7d %10d %10d %10d %10d %7d",
654 TMath::Abs(trackTOFin->GetLabel()),
655 c->GetLabel(0), c->GetLabel(1), c->GetLabel(2),
660 // Track length correction for matching Step 2
663 Float_t rc = TMath::Sqrt(c->GetR()*c->GetR() + c->GetZ()*c->GetZ());
664 Float_t rt = TMath::Sqrt(trackPos[0][70]*trackPos[0][70]
665 +trackPos[1][70]*trackPos[1][70]
666 +trackPos[2][70]*trackPos[2][70]);
668 recL=trackPos[3][70]+dlt;
672 (c->GetLabel(0)==TMath::Abs(trackTOFin->GetLabel()))
674 (c->GetLabel(1)==TMath::Abs(trackTOFin->GetLabel()))
676 (c->GetLabel(2)==TMath::Abs(trackTOFin->GetLabel()))
680 AliDebug(2,Form(" track label good %5d",trackTOFin->GetLabel()));
686 AliDebug(2,Form(" track label bad %5d",trackTOFin->GetLabel()));
692 // Store quantities to be used in the TOF Calibration
693 Float_t tToT=AliTOFGeometry::ToTBinWidth()*c->GetToT()*1E-3; // in ns
694 t->SetTOFsignalToT(tToT);
695 Float_t rawTime=AliTOFGeometry::TdcBinWidth()*c->GetTDCRAW()+kTimeOffset; // RAW time,in ps
696 t->SetTOFsignalRaw(rawTime);
697 t->SetTOFsignalDz(mindistZ);
698 t->SetTOFsignalDx(mindistY);
699 t->SetTOFDeltaBC(c->GetDeltaBC());
700 t->SetTOFL0L1(c->GetL0L1Latency());
702 Float_t info[10] = {mindist,mindistY,mindistZ,
703 0.,0.,0.,0.,0.,0.,0.};
705 AliDebug(2,Form(" distance=%f; residual in the pad reference frame: dX=%f, dZ=%f", info[0],info[1],info[2]));
709 ind[0]=c->GetDetInd(0);
710 ind[1]=c->GetDetInd(1);
711 ind[2]=c->GetDetInd(2);
712 ind[3]=c->GetDetInd(3);
713 ind[4]=c->GetDetInd(4);
714 Int_t calindex = AliTOFGeometry::GetIndex(ind);
715 t->SetTOFCalChannel(calindex);
717 // keep track of the track labels in the matched cluster
719 tlab[0]=c->GetLabel(0);
720 tlab[1]=c->GetLabel(1);
721 tlab[2]=c->GetLabel(2);
722 AliDebug(2,Form(" tdc time of the matched track %6d = ",c->GetTDC()));
723 Double_t tof=AliTOFGeometry::TdcBinWidth()*c->GetTDC()+kTimeOffset; // in ps
724 AliDebug(2,Form(" tof time of the matched track: %f = ",tof));
725 Double_t tofcorr=tof;
726 if(timeWalkCorr)tofcorr=CorrectTimeWalk(mindistZ,tof);
727 AliDebug(2,Form(" tof time of the matched track, after TW corr: %f = ",tofcorr));
728 //Set TOF time signal and pointer to the matched cluster
729 t->SetTOFsignal(tofcorr);
730 t->SetTOFcluster(idclus); // pointing to the recPoints tree
732 AliDebug(2,Form(" Setting TOF raw time: %f, z distance: %f corrected time: %f ",rawTime,mindistZ,tofcorr));
735 Double_t time[AliPID::kSPECIES]; t->GetIntegratedTimes(time); // in ps
736 Double_t mom=t->GetP();
737 AliDebug(2,Form(" Momentum for track %d -> %f", iseed,mom));
738 for (Int_t j=0;j<AliPID::kSPECIES;j++) {
739 Double_t mass=AliPID::ParticleMass(j);
740 time[j]+=(recL-trackPos[3][0])/kSpeedOfLight*TMath::Sqrt(mom*mom+mass*mass)/mom;
743 AliTOFtrack *trackTOFout = new AliTOFtrack(*t);
744 trackTOFout->PropagateTo(xpos);
746 // Fill the track residual histograms.
747 FillResiduals(trackTOFout,c,kFALSE);
749 t->UpdateTrackParams(trackTOFout,AliESDtrack::kTOFout);
750 t->SetIntegratedLength(recL);
751 t->SetIntegratedTimes(time);
752 t->SetTOFLabel(tlab);
755 // Fill Reco-QA histos for Reconstruction
756 fHRecNClus->Fill(nc);
757 fHRecDist->Fill(mindist);
759 fHRecSigYVsP->Fill(mom,TMath::Sqrt(cov[0]));
761 fHRecSigYVsP->Fill(mom,-TMath::Sqrt(-cov[0]));
763 fHRecSigZVsP->Fill(mom,TMath::Sqrt(cov[2]));
765 fHRecSigZVsP->Fill(mom,-TMath::Sqrt(-cov[2]));
766 fHRecSigYVsPWin->Fill(mom,dphi*sensRadius);
767 fHRecSigZVsPWin->Fill(mom,dz);
769 // Fill Tree for on-the-fly offline Calibration
771 if ( !((t->GetStatus() & AliESDtrack::kTIME)==0 ) ) {
783 for (Int_t ii=0; ii<4; ii++) delete [] trackPos[ii];
787 //_________________________________________________________________________
788 Int_t AliTOFtracker::LoadClusters(TTree *cTree) {
789 //--------------------------------------------------------------------
790 //This function loads the TOF clusters
791 //--------------------------------------------------------------------
793 Int_t npadX = AliTOFGeometry::NpadX();
794 Int_t npadZ = AliTOFGeometry::NpadZ();
795 Int_t nStripA = AliTOFGeometry::NStripA();
796 Int_t nStripB = AliTOFGeometry::NStripB();
797 Int_t nStripC = AliTOFGeometry::NStripC();
799 TBranch *branch=cTree->GetBranch("TOF");
801 AliError("can't get the branch with the TOF clusters !");
805 static TClonesArray dummy("AliTOFcluster",10000);
807 TClonesArray *clusters=&dummy;
808 branch->SetAddress(&clusters);
811 Int_t nc=clusters->GetEntriesFast();
812 fHDigNClus->Fill(nc);
814 AliInfo(Form("Number of clusters: %d",nc));
816 for (Int_t i=0; i<nc; i++) {
817 AliTOFcluster *c=(AliTOFcluster*)clusters->UncheckedAt(i);
818 //PH fClusters[i]=new AliTOFcluster(*c); fN++;
819 fClusters[i]=c; fN++;
821 // Fill Digits QA histos
823 Int_t isector = c->GetDetInd(0);
824 Int_t iplate = c->GetDetInd(1);
825 Int_t istrip = c->GetDetInd(2);
826 Int_t ipadX = c->GetDetInd(4);
827 Int_t ipadZ = c->GetDetInd(3);
829 Float_t time =(AliTOFGeometry::TdcBinWidth()*c->GetTDC())*1E-3; // in ns
830 Float_t tot = (AliTOFGeometry::TdcBinWidth()*c->GetToT())*1E-3;//in ns
832 Int_t stripOffset = 0;
838 stripOffset = nStripC;
841 stripOffset = nStripC+nStripB;
844 stripOffset = nStripC+nStripB+nStripA;
847 stripOffset = nStripC+nStripB+nStripA+nStripB;
850 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
853 Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
854 Int_t phiindex=npadX*isector+ipadX+1;
855 fHDigClusMap->Fill(zindex,phiindex);
856 fHDigClusTime->Fill(time);
857 fHDigClusToT->Fill(tot);
864 //_________________________________________________________________________
865 void AliTOFtracker::UnloadClusters() {
866 //--------------------------------------------------------------------
867 //This function unloads TOF clusters
868 //--------------------------------------------------------------------
869 for (Int_t i=0; i<fN; i++) {
870 //PH delete fClusters[i];
876 //_________________________________________________________________________
877 Int_t AliTOFtracker::FindClusterIndex(Double_t z) const {
878 //--------------------------------------------------------------------
879 // This function returns the index of the nearest cluster
880 //--------------------------------------------------------------------
882 if (z <= fClusters[0]->GetZ()) return 0;
883 if (z > fClusters[fN-1]->GetZ()) return fN;
884 Int_t b=0, e=fN-1, m=(b+e)/2;
885 for (; b<e; m=(b+e)/2) {
886 if (z > fClusters[m]->GetZ()) b=m+1;
892 //_________________________________________________________________________
893 Bool_t AliTOFtracker::GetTrackPoint(Int_t index, AliTrackPoint& p) const
895 // Get track space point with index i
896 // Coordinates are in the global system
897 AliTOFcluster *cl = fClusters[index];
899 xyz[0] = cl->GetR()*TMath::Cos(cl->GetPhi());
900 xyz[1] = cl->GetR()*TMath::Sin(cl->GetPhi());
902 Float_t phiangle = (Int_t(cl->GetPhi()*TMath::RadToDeg()/20.)+0.5)*20.*TMath::DegToRad();
903 Float_t sinphi = TMath::Sin(phiangle), cosphi = TMath::Cos(phiangle);
904 Float_t tiltangle = AliTOFGeometry::GetAngles(cl->GetDetInd(1),cl->GetDetInd(2))*TMath::DegToRad();
905 Float_t sinth = TMath::Sin(tiltangle), costh = TMath::Cos(tiltangle);
906 Float_t sigmay2 = AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
907 Float_t sigmaz2 = AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
909 cov[0] = sinphi*sinphi*sigmay2 + cosphi*cosphi*sinth*sinth*sigmaz2;
910 cov[1] = -sinphi*cosphi*sigmay2 + sinphi*cosphi*sinth*sinth*sigmaz2;
911 cov[2] = -cosphi*sinth*costh*sigmaz2;
912 cov[3] = cosphi*cosphi*sigmay2 + sinphi*sinphi*sinth*sinth*sigmaz2;
913 cov[4] = -sinphi*sinth*costh*sigmaz2;
914 cov[5] = costh*costh*sigmaz2;
915 p.SetXYZ(xyz[0],xyz[1],xyz[2],cov);
917 // Detector numbering scheme
918 Int_t nSector = AliTOFGeometry::NSectors();
919 Int_t nPlate = AliTOFGeometry::NPlates();
920 Int_t nStripA = AliTOFGeometry::NStripA();
921 Int_t nStripB = AliTOFGeometry::NStripB();
922 Int_t nStripC = AliTOFGeometry::NStripC();
924 Int_t isector = cl->GetDetInd(0);
925 if (isector >= nSector)
926 AliError(Form("Wrong sector number in TOF (%d) !",isector));
927 Int_t iplate = cl->GetDetInd(1);
928 if (iplate >= nPlate)
929 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
930 Int_t istrip = cl->GetDetInd(2);
932 Int_t stripOffset = 0;
938 stripOffset = nStripC;
941 stripOffset = nStripC+nStripB;
944 stripOffset = nStripC+nStripB+nStripA;
947 stripOffset = nStripC+nStripB+nStripA+nStripB;
950 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
954 Int_t idet = (2*(nStripC+nStripB)+nStripA)*isector +
957 UShort_t volid = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF,idet);
958 p.SetVolumeID((UShort_t)volid);
961 //_________________________________________________________________________
962 void AliTOFtracker::InitCheckHists() {
964 //Init histos for Digits/Reco QA and Calibration
967 TDirectory *dir = gDirectory;
968 TFile *logFileTOF = 0;
970 TSeqCollection *list = gROOT->GetListOfFiles();
971 int n = list->GetEntries();
972 Bool_t isThere=kFALSE;
973 for(int i=0; i<n; i++) {
974 logFileTOF = (TFile*)list->At(i);
975 if (strstr(logFileTOF->GetName(), "TOFQA.root")){
981 if(!isThere)logFileTOF = new TFile( "TOFQA.root","RECREATE");
984 fCalTree = new TTree("CalTree", "Tree for TOF calibration");
985 fCalTree->Branch("TOFchannelindex",&fIch,"iTOFch/I");
986 fCalTree->Branch("ToT",&fToT,"TOFToT/F");
987 fCalTree->Branch("TOFtime",&fTime,"TOFtime/F");
988 fCalTree->Branch("PionExpTime",&fExpTimePi,"PiExpTime/F");
989 fCalTree->Branch("KaonExpTime",&fExpTimeKa,"KaExpTime/F");
990 fCalTree->Branch("ProtonExpTime",&fExpTimePr,"PrExpTime/F");
993 fHDigClusMap = new TH2F("TOFDig_ClusMap", "",182,0.5,182.5,864, 0.5,864.5);
994 fHDigNClus = new TH1F("TOFDig_NClus", "",200,0.5,200.5);
995 fHDigClusTime = new TH1F("TOFDig_ClusTime", "",2000,0.,200.);
996 fHDigClusToT = new TH1F("TOFDig_ClusToT", "",500,0.,100);
999 fHRecNClus =new TH1F("TOFRec_NClusW", "",50,0.5,50.5);
1000 fHRecDist=new TH1F("TOFRec_Dist", "",50,0.5,10.5);
1001 fHRecSigYVsP=new TH2F("TOFDig_SigYVsP", "",40,0.,4.,100, 0.,5.);
1002 fHRecSigZVsP=new TH2F("TOFDig_SigZVsP", "",40,0.,4.,100, 0.,5.);
1003 fHRecSigYVsPWin=new TH2F("TOFDig_SigYVsPWin", "",40,0.,4.,100, 0.,50.);
1004 fHRecSigZVsPWin=new TH2F("TOFDig_SigZVsPWin", "",40,0.,4.,100, 0.,50.);
1010 //_________________________________________________________________________
1011 void AliTOFtracker::SaveCheckHists() {
1013 //write histos for Digits/Reco QA and Calibration
1015 TDirectory *dir = gDirectory;
1016 TFile *logFileTOF = 0;
1018 TSeqCollection *list = gROOT->GetListOfFiles();
1019 int n = list->GetEntries();
1020 Bool_t isThere=kFALSE;
1021 for(int i=0; i<n; i++) {
1022 logFileTOF = (TFile*)list->At(i);
1023 if (strstr(logFileTOF->GetName(), "TOFQA.root")){
1030 AliError(Form("File TOFQA.root not found!! not wring histograms...."));
1034 fHDigClusMap->Write(fHDigClusMap->GetName(), TObject::kOverwrite);
1035 fHDigNClus->Write(fHDigNClus->GetName(), TObject::kOverwrite);
1036 fHDigClusTime->Write(fHDigClusTime->GetName(), TObject::kOverwrite);
1037 fHDigClusToT->Write(fHDigClusToT->GetName(), TObject::kOverwrite);
1038 fHRecNClus->Write(fHRecNClus->GetName(), TObject::kOverwrite);
1039 fHRecDist->Write(fHRecDist->GetName(), TObject::kOverwrite);
1040 fHRecSigYVsP->Write(fHRecSigYVsP->GetName(), TObject::kOverwrite);
1041 fHRecSigZVsP->Write(fHRecSigZVsP->GetName(), TObject::kOverwrite);
1042 fHRecSigYVsPWin->Write(fHRecSigYVsPWin->GetName(), TObject::kOverwrite);
1043 fHRecSigZVsPWin->Write(fHRecSigZVsPWin->GetName(), TObject::kOverwrite);
1044 fCalTree->Write(fCalTree->GetName(),TObject::kOverwrite);
1045 logFileTOF->Flush();
1049 //_________________________________________________________________________
1050 Float_t AliTOFtracker::CorrectTimeWalk( Float_t dist, Float_t tof) const {
1052 //dummy, for the moment
1054 if(dist<AliTOFGeometry::ZPad()*0.5){
1056 //place here the actual correction
1062 //_________________________________________________________________________
1064 void AliTOFtracker::FillClusterArray(TObjArray* arr) const
1067 // Returns the TOF cluster array
1073 for (Int_t i=0; i<fN; ++i) arr->Add(fClusters[i]);
1076 //_________________________________________________________________________