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 **************************************************************************/
17 $Log: AliTOFClusterFinder.cxx,v $
18 Revision 1.31 2007/11/24 14:53:19 zampolli
19 Status flag implemented as UChar_t
21 Revision 1.30 2007/10/04 13:08:52 arcelli
22 updates to comply with AliTOFGeometryV5 becoming AliTOFGeometry
24 Revision 1.29 2007/10/03 10:42:33 arcelli
25 updates to handle new AliTOFcluster, inheriting form AliCluster3D
27 Revision 1.28 2007/05/31 16:06:05 arcelli
28 move instance of AliRawStream outside loop on DDL
30 Revision 1.27 2007/05/02 16:31:49 arcelli
31 Add methods to handle single event reconstruction. retrieval of Calib
32 info moved to AliTOFReconstructor ctor, and passed via a pointer to
35 Revision 1.26 2007/04/30 19:02:24 arcelli
36 hopefully the last refinements for correct type conversion in calibration
38 Revision 1.25 2007/04/30 15:22:17 arcelli
39 Change TOF digit Time, Tot etc to int type
41 Revision 1.24 2007/04/27 11:19:31 arcelli
42 updates for the new decoder
44 Revision 1.23 2007/04/23 16:51:39 decaro
45 Digits-to-raw_data conversion: correction for a more real description
46 (A.De Caro, R.Preghenella)
48 Revision 1.22 2007/04/19 17:26:32 arcelli
49 Fix a bug (add some debug printout
51 Revision 1.21 2007/04/18 17:28:12 arcelli
52 Set the ToT bin width to the one actually used...
54 Revision 1.20 2007/03/09 09:57:23 arcelli
55 Remove a forgotten include of Riostrem
57 Revision 1.19 2007/03/08 15:41:20 arcelli
58 set uncorrected times when filling RecPoints
60 Revision 1.18 2007/03/06 16:31:20 arcelli
61 Add Uncorrected TOF Time signal
63 Revision 1.17 2007/02/28 18:09:11 arcelli
64 Add protection against failed retrieval of the CDB cal object,
65 now Reconstruction exits with AliFatal
67 Revision 1.16 2007/02/20 15:57:00 decaro
68 Raw data update: to read the TOF raw data defined in UNPACKED mode
71 Revision 0.03 2005/07/28 A. De Caro
72 Implement public method
73 Raw2Digits(Int_t, AliRawReader *)
74 to convert digits from raw data in MC digits
77 Revision 0.02 2005/07/27 A. De Caro
78 Implement public method
79 Digits2RecPoint(Int_t)
80 to convert digits in clusters
82 Revision 0.02 2005/07/26 A. De Caro
83 Implement private methods
84 InsertCluster(AliTOFcluster *)
85 FindClusterIndex(Double_t)
86 originally implemented in AliTOFtracker
87 by S. Arcelli and C. Zampolli
89 Revision 0.01 2005/07/25 A. De Caro
90 Implement public methods
91 Digits2RecPoint(AliRawReader *, TTree *)
92 Digits2RecPoint(Int_t, AliRawReader *)
93 to convert raw data in clusters
96 ////////////////////////////////////////////////////////////////
98 // Class for TOF cluster finder //
100 // Starting from Raw Data, create rec points, //
101 // fill TreeR for TOF, //
102 // write TOF.RecPoints.root file //
104 ////////////////////////////////////////////////////////////////
106 #include "Riostream.h"
108 #include "TClonesArray.h"
109 #include "TStopwatch.h"
111 //#include <TGeoManager.h>
112 #include <TGeoMatrix.h>
113 //#include <TGeoPhysicalNode.h>
116 #include "AliLoader.h"
118 #include "AliRawReader.h"
119 #include "AliRunLoader.h"
120 //#include "AliAlignObj.h"
121 #include <AliGeomManager.h>
123 #include "AliTOFcalib.h"
124 #include "AliTOFChannelOnlineArray.h"
125 #include "AliTOFChannelOnlineStatusArray.h"
126 #include "AliTOFChannelOffline.h"
127 #include "AliTOFClusterFinder.h"
128 #include "AliTOFcluster.h"
129 #include "AliTOFdigit.h"
130 #include "AliTOFGeometry.h"
131 #include "AliTOFrawData.h"
133 #include "AliTOFDeltaBCOffset.h"
134 #include "AliTOFCTPLatency.h"
135 #include "AliTOFRunParams.h"
137 //extern TFile *gFile;
143 ClassImp(AliTOFClusterFinder)
145 AliTOFClusterFinder::AliTOFClusterFinder(AliTOFcalib *calib):
146 TTask("AliTOFClusterFinder",""),
151 fDigits(new TClonesArray("AliTOFdigit", 4000)),
152 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
153 fNumberOfTofClusters(0),
154 fNumberOfTofTrgPads(0),
158 fTOFRawStream(AliTOFRawStream())
164 for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=0x0;
166 TString validity = (TString)fTOFcalib->GetOfflineValidity();
167 if (validity.CompareTo("valid")==0) {
168 AliInfo(Form(" validity = %s - Using offline calibration parameters",validity.Data()));
170 AliInfo(Form(" validity = %s - Using online calibration parameters",validity.Data()));
175 //______________________________________________________________________________
177 AliTOFClusterFinder::AliTOFClusterFinder(AliRunLoader* runLoader, AliTOFcalib *calib):
178 TTask("AliTOFClusterFinder",""),
179 fRunLoader(runLoader),
180 fTOFLoader(runLoader->GetLoader("TOFLoader")),
183 fDigits(new TClonesArray("AliTOFdigit", 4000)),
184 fRecPoints(new TClonesArray("AliTOFcluster", 4000)),
185 fNumberOfTofClusters(0),
186 fNumberOfTofTrgPads(0),
190 fTOFRawStream(AliTOFRawStream())
196 for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=0x0;
198 TString validity = (TString)fTOFcalib->GetOfflineValidity();
199 if (validity.CompareTo("valid")==0) {
200 AliInfo(Form(" validity = %s - Using offline calibration parameters",validity.Data()));
202 AliInfo(Form(" validity = %s - Using online calibration parameters",validity.Data()));
207 //------------------------------------------------------------------------
208 AliTOFClusterFinder::AliTOFClusterFinder(const AliTOFClusterFinder &source) :
214 fDigits(source.fDigits),
215 fRecPoints(source.fRecPoints),
216 fNumberOfTofClusters(0),
217 fNumberOfTofTrgPads(0),
219 fDecoderVersion(source.fDecoderVersion),
220 fTOFcalib(source.fTOFcalib),
221 fTOFRawStream(source.fTOFRawStream)
225 for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=source.fTofClusters[ii];
229 //------------------------------------------------------------------------
230 AliTOFClusterFinder& AliTOFClusterFinder::operator=(const AliTOFClusterFinder &source)
237 TTask::operator=(source);
238 fDigits=source.fDigits;
239 fRecPoints=source.fRecPoints;
240 fVerbose=source.fVerbose;
241 fDecoderVersion=source.fDecoderVersion;
242 fTOFcalib=source.fTOFcalib;
243 fTOFRawStream=source.fTOFRawStream;
244 for (Int_t ii=0; ii<kTofMaxCluster; ii++) fTofClusters[ii]=source.fTofClusters[ii];
249 //______________________________________________________________________________
251 AliTOFClusterFinder::~AliTOFClusterFinder()
266 fRecPoints->Delete();
271 //if (fTofClusters || fNumberOfTofClusters) {
272 if (fNumberOfTofClusters) {
273 for (Int_t ii=0; ii<kTofMaxCluster; ii++) {
274 if (fTofClusters[ii]) fTofClusters[ii]->Delete();
275 delete fTofClusters[ii];
277 fNumberOfTofClusters=0;
280 fNumberOfTofTrgPads=0;
283 //______________________________________________________________________________
285 void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent)
288 // Converts digits to recpoints for TOF
291 TStopwatch stopwatch;
296 fRunLoader->GetEvent(iEvent);
298 fTreeD = fTOFLoader->TreeD();
300 AliFatal("AliTOFClusterFinder: Can not get TreeD");
305 fTreeD->GetBranch("TOF")->SetAutoDelete(kFALSE);
306 fTreeD->SetBranchAddress("TOF",&fDigits);
310 fTreeR = fTOFLoader->TreeR();
313 fTOFLoader->MakeTree("R");
314 fTreeR = fTOFLoader->TreeR();
317 Int_t bufsize = 32000;
318 fTreeR->Branch("TOF", &fRecPoints, bufsize);
321 Int_t nDigits = fDigits->GetEntriesFast();
322 AliDebug(2,Form("Number of TOF digits: %d",nDigits));
325 Int_t dig[5]={-1,-1,-1,-1,-1}; //cluster detector indeces
326 Int_t parTOF[7]={0,0,0,0,0,0,0}; //The TOF signal parameters
327 Bool_t status=kTRUE; // assume all sim channels ok in the beginning...
328 for (ii=0; ii<nDigits; ii++) {
329 AliTOFdigit *d = (AliTOFdigit*)fDigits->UncheckedAt(ii);
330 dig[0]=d->GetSector();
331 dig[1]=d->GetPlate();
332 dig[2]=d->GetStrip();
336 /* check valid index */
337 if (dig[0]==-1||dig[1]==-1||dig[2]==-1||dig[3]==-1||dig[4]==-1) continue;
339 // Do not reconstruct anything in the holes
340 if (dig[0]==13 || dig[0]==14 || dig[0]==15 ) { // sectors with holes
341 if (dig[1]==2) { // plate with holes
347 AliDebug(2,Form(" %2d %1d %2d %1d %2d ",dig[0],dig[1],dig[2],dig[3],dig[4]));
349 parTOF[0] = d->GetTdc(); //the TDC signal
350 parTOF[1] = d->GetToT(); //the ToT signal
351 parTOF[2] = d->GetAdc(); // the adc charge
352 parTOF[3] = d->GetTdcND(); // non decalibrated sim time
353 parTOF[4] = d->GetTdc(); // raw time, == Tdc time for the moment
354 parTOF[5] = 0; // deltaBC
355 parTOF[6] = 0; // L0-L1 latency
358 UShort_t volIdClus=GetClusterVolIndex(dig);
359 GetClusterPars(dig, posClus,covClus);
360 AliTOFcluster *tofCluster = new AliTOFcluster(volIdClus,posClus[0],posClus[1],posClus[2],covClus[0],covClus[1],covClus[2],covClus[3],covClus[4],covClus[5],d->GetTracks(),dig,parTOF,status,ii);
361 InsertCluster(tofCluster);
365 AliDebug(1,Form("Number of found clusters: %d for event: %d", fNumberOfTofClusters, iEvent));
373 fTOFLoader = fRunLoader->GetLoader("TOFLoader");
374 fTOFLoader->WriteRecPoints("OVERWRITE");
376 AliDebug(1,Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
377 stopwatch.RealTime(),stopwatch.CpuTime()));
378 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
382 //______________________________________________________________________________
384 void AliTOFClusterFinder::Digits2RecPoints(TTree* digitsTree, TTree* clusterTree)
387 // Converts digits to recpoints for TOF
390 TStopwatch stopwatch;
395 if (digitsTree == 0x0) {
396 AliFatal("AliTOFClusterFinder: Can not get TreeD");
401 digitsTree->GetBranch("TOF")->SetAutoDelete(kFALSE);
402 digitsTree->SetBranchAddress("TOF",&fDigits);
405 Int_t bufsize = 32000;
406 clusterTree->Branch("TOF", &fRecPoints, bufsize);
408 digitsTree->GetEvent(0);
409 Int_t nDigits = fDigits->GetEntriesFast();
410 AliDebug(2,Form("Number of TOF digits: %d",nDigits));
413 Int_t dig[5]={-1,-1,-1,-1,-1}; //cluster detector indeces
414 Int_t parTOF[7]={0,0,0,0,0,0,0}; //The TOF signal parameters
415 Bool_t status=kTRUE; // assume all sim channels ok in the beginning...
416 for (ii=0; ii<nDigits; ii++) {
417 AliTOFdigit *d = (AliTOFdigit*)fDigits->UncheckedAt(ii);
418 dig[0]=d->GetSector();
419 dig[1]=d->GetPlate();
420 dig[2]=d->GetStrip();
424 /* check valid index */
425 if (dig[0]==-1||dig[1]==-1||dig[2]==-1||dig[3]==-1||dig[4]==-1) continue;
427 // Do not reconstruct anything in the holes
428 if (dig[0]==13 || dig[0]==14 || dig[0]==15 ) { // sectors with holes
429 if (dig[1]==2) { // plate with holes
435 // AliDebug(2,Form(" %2d %1d %2d %1d %2d ",dig[0],dig[1],dig[2],dig[3],dig[4]));
437 parTOF[0] = d->GetTdc(); //the TDC signal
438 parTOF[1] = d->GetToT(); //the ToT signal
439 parTOF[2] = d->GetAdc(); // the adc charge
440 parTOF[3] = d->GetTdcND(); // non decalibrated sim time
441 parTOF[4] = d->GetTdc(); // raw time, == Tdc time for the moment
442 parTOF[5] = 0; // deltaBC
443 parTOF[6] = 0; // L0-L1 latency
447 UShort_t volIdClus=GetClusterVolIndex(dig);
448 GetClusterPars(dig,posClus,covClus);
449 AliTOFcluster *tofCluster = new AliTOFcluster(volIdClus,posClus[0],posClus[1],posClus[2],covClus[0],covClus[1],covClus[2],covClus[3],covClus[4],covClus[5],d->GetTracks(),dig,parTOF,status,ii);
450 InsertCluster(tofCluster);
454 AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
462 AliDebug(1,Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs",
463 stopwatch.RealTime(),stopwatch.CpuTime()));
464 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
467 //______________________________________________________________________________
469 void AliTOFClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
473 // Converts RAW data to recpoints for TOF
476 TStopwatch stopwatch;
481 const Int_t kDDL = AliDAQ::NumberOfDdls("TOF");
485 Int_t bufsize = 32000;
486 clustersTree->Branch("TOF", &fRecPoints, bufsize);
488 TClonesArray * clonesRawData;
491 Int_t detectorIndex[5]={-1,-1,-1,-1,-1};
492 Int_t parTOF[7]={-1,-1,-1,-1,-1,-1,-1};
495 if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
497 fTOFRawStream.Clear();
498 fTOFRawStream.SetRawReader(rawReader);
500 if (fDecoderVersion == 1) {
501 AliInfo("Using New Decoder");
503 else if (fDecoderVersion == 2) {
504 AliInfo("Using Enhanced Decoder");
507 AliInfo("Using Old Decoder");
511 for (indexDDL = 0; indexDDL < kDDL; indexDDL++) {
514 if (fDecoderVersion == 1) {
515 fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
517 else if (fDecoderVersion == 2) {
518 fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose);
521 fTOFRawStream.LoadRawData(indexDDL);
524 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
526 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
528 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
530 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
531 if (tofRawDatum->GetTOF()==-1) continue;
534 if (indexDDL<10) ftxt << " " << indexDDL;
535 else ftxt << " " << indexDDL;
536 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
537 else ftxt << " " << tofRawDatum->GetTRM();
538 ftxt << " " << tofRawDatum->GetTRMchain();
539 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
540 else ftxt << " " << tofRawDatum->GetTDC();
541 ftxt << " " << tofRawDatum->GetTDCchannel();
544 if ( tofRawDatum->GetTRM()==3 &&
545 (tofRawDatum->GetTDC()> 11 && tofRawDatum->GetTDC()< 15) ) FillTOFtriggerMap(indexDDL, tofRawDatum);
547 for (Int_t aa=0; aa<5; aa++) detectorIndex[aa] = -1;
549 fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
550 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
551 dummy = detectorIndex[3];
552 detectorIndex[3] = detectorIndex[4];
553 detectorIndex[4] = dummy;
556 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
557 else ftxt << " -> " << detectorIndex[0];
558 ftxt << " " << detectorIndex[1];
559 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
560 else ftxt << " " << detectorIndex[2];
561 ftxt << " " << detectorIndex[3];
562 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[4];
563 else ftxt << " " << detectorIndex[4];
566 /* check valid index */
567 if (detectorIndex[0]==-1||detectorIndex[1]==-1||detectorIndex[2]==-1||detectorIndex[3]==-1||detectorIndex[4]==-1) continue;
569 // Do not reconstruct anything in the holes
570 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
571 if (detectorIndex[1]==2) { // plate with holes
577 parTOF[0] = tofRawDatum->GetTOF(); //TDC
578 parTOF[1] = tofRawDatum->GetTOT(); // TOT
579 parTOF[2] = tofRawDatum->GetTOT(); //ADC==TOF
580 parTOF[3] = 0;//raw data: no track of undecalib sim time
581 parTOF[4] = tofRawDatum->GetTOF(); // RAW time
582 parTOF[5] = tofRawDatum->GetDeltaBC(); // deltaBC
583 parTOF[6] = tofRawDatum->GetL0L1Latency(); // L0-L1 latency
586 UShort_t volIdClus=GetClusterVolIndex(detectorIndex);
587 Int_t lab[3]={-1,-1,-1};
589 GetClusterPars(detectorIndex,posClus,covClus);
590 AliTOFcluster *tofCluster = new AliTOFcluster(volIdClus,posClus[0],posClus[1],posClus[2],covClus[0],covClus[1],covClus[2],covClus[3],covClus[4],covClus[5],lab,detectorIndex,parTOF,status,-1);
591 InsertCluster(tofCluster);
594 if (parTOF[1]<10)ftxt << " " << parTOF[1];
595 else if (parTOF[1]>=10 && parTOF[1]<100) ftxt << " " << parTOF[1];
596 else ftxt << " " << parTOF[1];
597 if (parTOF[0]<10) ftxt << " " << parTOF[0] << endl;
598 else if (parTOF[0]>=10 && parTOF[0]<100) ftxt << " " << parTOF[0] << endl;
599 else if (parTOF[0]>=100 && parTOF[0]<1000) ftxt << " " << parTOF[0] << endl;
600 else ftxt << " " << parTOF[0] << endl;
603 } // closed loop on TOF raw data per current DDL file
605 clonesRawData->Clear("C");
607 } // closed loop on DDL index
609 if (fVerbose==2) ftxt.close();
611 AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters));
613 CalibrateRecPoint(rawReader->GetTimestamp());
616 clustersTree->Fill();
620 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs",
621 stopwatch.RealTime(),stopwatch.CpuTime()));
622 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
625 //______________________________________________________________________________
627 void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader)
630 // Converts RAW data to recpoints for TOF
633 TStopwatch stopwatch;
638 const Int_t kDDL = AliDAQ::NumberOfDdls("TOF");
640 fRunLoader->GetEvent(iEvent);
642 AliDebug(2,Form(" Event number %2d ", iEvent));
644 fTreeR = fTOFLoader->TreeR();
647 fTOFLoader->MakeTree("R");
648 fTreeR = fTOFLoader->TreeR();
651 Int_t bufsize = 32000;
652 fTreeR->Branch("TOF", &fRecPoints, bufsize);
654 TClonesArray * clonesRawData;
658 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
661 if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
663 fTOFRawStream.Clear();
664 fTOFRawStream.SetRawReader(rawReader);
666 if (fDecoderVersion == 1) {
667 AliInfo("Using New Decoder");
669 else if (fDecoderVersion == 2) {
670 AliInfo("Using Enhanced Decoder");
673 AliInfo("Using Old Decoder");
677 for (indexDDL = 0; indexDDL < kDDL; indexDDL++) {
680 if (fDecoderVersion == 1) {
681 fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
683 else if (fDecoderVersion == 2) {
684 fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose);
687 fTOFRawStream.LoadRawData(indexDDL);
690 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
692 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
694 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
696 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
697 if (tofRawDatum->GetTOF()==-1) continue;
700 if (indexDDL<10) ftxt << " " << indexDDL;
701 else ftxt << " " << indexDDL;
702 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
703 else ftxt << " " << tofRawDatum->GetTRM();
704 ftxt << " " << tofRawDatum->GetTRMchain();
705 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
706 else ftxt << " " << tofRawDatum->GetTDC();
707 ftxt << " " << tofRawDatum->GetTDCchannel();
710 fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
711 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
712 dummy = detectorIndex[3];
713 detectorIndex[3] = detectorIndex[4];
714 detectorIndex[4] = dummy;
717 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
718 else ftxt << " -> " << detectorIndex[0];
719 ftxt << " " << detectorIndex[1];
720 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
721 else ftxt << " " << detectorIndex[2];
722 ftxt << " " << detectorIndex[3];
723 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[4];
724 else ftxt << " " << detectorIndex[4];
727 /* check valid index */
728 if (detectorIndex[0]==-1||detectorIndex[1]==-1||detectorIndex[2]==-1||detectorIndex[3]==-1||detectorIndex[4]==-1) continue;
730 // Do not reconstruct anything in the holes
731 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
732 if (detectorIndex[1]==2) { // plate with holes
738 parTOF[0] = tofRawDatum->GetTOF(); // TDC
739 parTOF[1] = tofRawDatum->GetTOT(); // TOT
740 parTOF[2] = tofRawDatum->GetTOT(); // raw data have ADC=TOT
741 parTOF[3] = 0; //raw data: no track of the undecalib sim time
742 parTOF[4] = tofRawDatum->GetTOF(); // Raw time == TDC
743 parTOF[5] = tofRawDatum->GetDeltaBC(); // deltaBC
744 parTOF[6] = tofRawDatum->GetL0L1Latency(); // L0-L1 latency
747 UShort_t volIdClus=GetClusterVolIndex(detectorIndex);
748 Int_t lab[3]={-1,-1,-1};
750 GetClusterPars(detectorIndex,posClus,covClus);
751 AliTOFcluster *tofCluster = new AliTOFcluster(volIdClus,posClus[0],posClus[1],posClus[2],covClus[0],covClus[1],covClus[2],covClus[3],covClus[4],covClus[5],lab,detectorIndex,parTOF,status,-1);
752 InsertCluster(tofCluster);
755 if (parTOF[1]<10)ftxt << " " << parTOF[1];
756 else if (parTOF[1]>=10 && parTOF[1]<100) ftxt << " " << parTOF[1];
757 else ftxt << " " << parTOF[1];
758 if (parTOF[0]<10) ftxt << " " << parTOF[0] << endl;
759 else if (parTOF[0]>=10 && parTOF[0]<100) ftxt << " " << parTOF[0] << endl;
760 else if (parTOF[0]>=100 && parTOF[0]<1000) ftxt << " " << parTOF[0] << endl;
761 else ftxt << " " << parTOF[0] << endl;
764 } // closed loop on TOF raw data per current DDL file
766 clonesRawData->Clear("C");
768 } // closed loop on DDL index
770 if (fVerbose==2) ftxt.close();
772 AliDebug(1,Form("Number of found clusters: %d for event: %d", fNumberOfTofClusters, iEvent));
774 CalibrateRecPoint(rawReader->GetTimestamp());
780 fTOFLoader = fRunLoader->GetLoader("TOFLoader");
781 fTOFLoader->WriteRecPoints("OVERWRITE");
783 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs",
784 stopwatch.RealTime(),stopwatch.CpuTime()));
785 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
788 //______________________________________________________________________________
790 void AliTOFClusterFinder::Raw2Digits(Int_t iEvent, AliRawReader *rawReader)
793 // Converts RAW data to MC digits for TOF
795 // (temporary solution)
798 TStopwatch stopwatch;
801 const Int_t kDDL = AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors();
803 fRunLoader->GetEvent(iEvent);
805 fTreeD = fTOFLoader->TreeD();
808 AliInfo("TreeD re-creation");
810 fTOFLoader->MakeTree("D");
811 fTreeD = fTOFLoader->TreeD();
814 AliFatal("Can not get TreeD");
818 Int_t bufsize = 32000;
820 fTreeD->Branch("TOF", &fDigits, bufsize);
822 fRunLoader->GetEvent(iEvent);
824 AliDebug(2,Form(" Event number %2d ", iEvent));
826 TClonesArray * clonesRawData;
830 Int_t detectorIndex[5];
833 fTOFRawStream.Clear();
834 fTOFRawStream.SetRawReader(rawReader);
836 if (fDecoderVersion == 1) {
837 AliInfo("Using New Decoder");
839 else if (fDecoderVersion == 2) {
840 AliInfo("Using Enhanced Decoder");
843 AliInfo("Using Old Decoder");
847 for (indexDDL = 0; indexDDL < kDDL; indexDDL++) {
850 if (fDecoderVersion == 1) {
851 fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
853 else if (fDecoderVersion == 2) {
854 fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose);
857 fTOFRawStream.LoadRawData(indexDDL);
860 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
862 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
864 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
866 //if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
867 if (tofRawDatum->GetTOF()==-1) continue;
869 fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
870 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
871 dummy = detectorIndex[3];
872 detectorIndex[3] = detectorIndex[4];
873 detectorIndex[4] = dummy;
875 digit[0] = fTOFRawStream.GetTofBin();
876 digit[1] = fTOFRawStream.GetToTbin();
877 digit[2] = fTOFRawStream.GetToTbin();
880 Int_t tracknum[3]={-1,-1,-1};
882 TClonesArray &aDigits = *fDigits;
883 Int_t last=fDigits->GetEntriesFast();
884 new (aDigits[last]) AliTOFdigit(tracknum, detectorIndex, digit);
888 clonesRawData->Clear("C");
894 fTOFLoader = fRunLoader->GetLoader("TOFLoader");
895 fTOFLoader->WriteDigits("OVERWRITE");
897 AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.2fs C:%.2fs",
898 stopwatch.RealTime(),stopwatch.CpuTime()));
902 //______________________________________________________________________________
904 void AliTOFClusterFinder::Raw2Digits(AliRawReader *rawReader, TTree* digitsTree)
907 // Converts RAW data to MC digits for TOF for the current event
911 TStopwatch stopwatch;
914 const Int_t kDDL = AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors();
918 AliError("No input digits Tree");
922 Int_t bufsize = 32000;
923 digitsTree->Branch("TOF", &fDigits, bufsize);
925 TClonesArray * clonesRawData;
928 Int_t detectorIndex[5];
931 fTOFRawStream.Clear();
932 fTOFRawStream.SetRawReader(rawReader);
934 if (fDecoderVersion == 1) {
935 AliInfo("Using New Decoder");
937 else if (fDecoderVersion == 2) {
938 AliInfo("Using Enhanced Decoder");
941 AliInfo("Using Old Decoder");
945 for (indexDDL = 0; indexDDL < kDDL; indexDDL++) {
948 if (fDecoderVersion == 1) {
949 fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose);
951 else if (fDecoderVersion == 2) {
952 fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose);
955 fTOFRawStream.LoadRawData(indexDDL);
958 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
960 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
962 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
964 //if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
965 if (tofRawDatum->GetTOF()==-1) continue;
967 fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
968 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
969 dummy = detectorIndex[3];
970 detectorIndex[3] = detectorIndex[4];
971 detectorIndex[4] = dummy;
973 digit[0] = fTOFRawStream.GetTofBin();
974 digit[1] = fTOFRawStream.GetToTbin();
975 digit[2] = fTOFRawStream.GetToTbin();
978 Int_t tracknum[3]={-1,-1,-1};
980 TClonesArray &aDigits = *fDigits;
981 Int_t last=fDigits->GetEntriesFast();
982 new (aDigits[last]) AliTOFdigit(tracknum, detectorIndex, digit);
986 clonesRawData->Clear("C");
992 AliDebug(1, Form("Got %d digits: ", fDigits->GetEntries()));
993 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
994 stopwatch.RealTime(),stopwatch.CpuTime()));
997 //______________________________________________________________________________
999 Int_t AliTOFClusterFinder::InsertCluster(AliTOFcluster *tofCluster) {
1000 //---------------------------------------------------------------------------//
1001 // This function adds a TOF cluster to the array of TOF clusters sorted in Z //
1002 //---------------------------------------------------------------------------//
1003 if (fNumberOfTofClusters==kTofMaxCluster) {
1004 AliError("Too many clusters !");
1008 if (fNumberOfTofClusters==0) {
1009 fTofClusters[fNumberOfTofClusters++] = tofCluster;
1013 Int_t ii = FindClusterIndex(tofCluster->GetZ());
1014 memmove(fTofClusters+ii+1 ,fTofClusters+ii,(fNumberOfTofClusters-ii)*sizeof(AliTOFcluster*));
1015 fTofClusters[ii] = tofCluster;
1016 fNumberOfTofClusters++;
1021 //_________________________________________________________________________
1023 Int_t AliTOFClusterFinder::FindClusterIndex(Double_t z) const {
1024 //--------------------------------------------------------------------
1025 // This function returns the index of the nearest cluster in z
1026 //--------------------------------------------------------------------
1027 if (fNumberOfTofClusters==0) return 0;
1028 if (z <= fTofClusters[0]->GetZ()) return 0;
1029 if (z > fTofClusters[fNumberOfTofClusters-1]->GetZ()) return fNumberOfTofClusters;
1030 Int_t b = 0, e = fNumberOfTofClusters-1, m = (b+e)/2;
1031 for (; b<e; m=(b+e)/2) {
1032 if (z > fTofClusters[m]->GetZ()) b=m+1;
1039 //_________________________________________________________________________
1041 void AliTOFClusterFinder::FillRecPoint()
1044 // Copy the global array of AliTOFcluster, i.e. fTofClusters (sorted
1045 // in Z) in the global TClonesArray of AliTOFcluster,
1051 Int_t detectorIndex[5];
1053 Int_t trackLabels[3];
1054 Int_t digitIndex = -1;
1055 Bool_t status=kTRUE;
1057 TClonesArray &lRecPoints = *fRecPoints;
1059 for (ii=0; ii<fNumberOfTofClusters; ii++) {
1060 AliTOFcluster* clOr = fTofClusters[ii];
1061 fTofClusters[ii] = 0;
1062 digitIndex = clOr->GetIndex();
1063 for(jj=0; jj<5; jj++) detectorIndex[jj] = clOr->GetDetInd(jj);
1064 for(jj=0; jj<3; jj++) trackLabels[jj] = clOr->GetLabel(jj);
1065 parTOF[0] = clOr->GetTDC(); // TDC
1066 parTOF[1] = clOr->GetToT(); // TOT
1067 parTOF[2] = clOr->GetADC(); // ADC=TOT
1068 parTOF[3] = clOr->GetTDCND(); // TDCND
1069 parTOF[4] = clOr->GetTDCRAW();//RAW
1070 parTOF[5] = clOr->GetDeltaBC();//deltaBC
1071 parTOF[6] = clOr->GetL0L1Latency();//L0-L1 latency
1072 status=clOr->GetStatus();
1073 Double_t posClus[3];
1074 Double_t covClus[6];
1075 UShort_t volIdClus=GetClusterVolIndex(detectorIndex);
1076 GetClusterPars(detectorIndex,posClus,covClus);
1077 new(lRecPoints[ii]) AliTOFcluster(volIdClus,posClus[0],posClus[1],posClus[2],covClus[0],covClus[1],covClus[2],covClus[3],covClus[4],covClus[5],trackLabels,detectorIndex, parTOF,status,digitIndex);
1079 AliDebug(2, Form(" %4d %4d %f %f %f %f %f %f %f %f %f %3d %3d %3d %2d %1d %2d %1d %2d %4d %3d %3d %4d %4d %1d %4d",
1080 ii, volIdClus, posClus[0], posClus[1], posClus[2],
1087 trackLabels[0], trackLabels[1], trackLabels[2],
1088 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4],
1089 parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4],
1090 status, digitIndex));
1093 } // loop on clusters
1097 //_________________________________________________________________________
1100 * OLD CALIBRATE REC POINTS FUNCTION
1104 void AliTOFClusterFinder::CalibrateRecPoint(UInt_t timestamp)
1107 // Copy the global array of AliTOFcluster, i.e. fTofClusters (sorted
1108 // in Z) in the global TClonesArray of AliTOFcluster,
1114 Int_t detectorIndex[5];
1115 Int_t digitIndex = -1;
1119 Float_t tdcLatencyWindow;
1120 AliDebug(1," Calibrating TOF Clusters");
1122 AliTOFChannelOnlineArray *calDelay = fTOFcalib->GetTOFOnlineDelay();
1123 AliTOFChannelOnlineStatusArray *calStatus = fTOFcalib->GetTOFOnlineStatus();
1124 TObjArray *calTOFArrayOffline = fTOFcalib->GetTOFCalArrayOffline();
1126 AliTOFDeltaBCOffset *deltaBCOffsetObj = fTOFcalib->GetDeltaBCOffset();
1127 Int_t deltaBCOffset = deltaBCOffsetObj->GetDeltaBCOffset();
1128 AliTOFCTPLatency *ctpLatencyObj = fTOFcalib->GetCTPLatency();
1129 Float_t ctpLatency = ctpLatencyObj->GetCTPLatency();
1130 AliTOFRunParams *runParamsObj = fTOFcalib->GetRunParams();
1131 Float_t t0 = runParamsObj->EvalT0(timestamp);
1133 TString validity = (TString)fTOFcalib->GetOfflineValidity();
1134 Int_t calibration = -1;
1135 if (validity.CompareTo("valid")==0) {
1136 //AliInfo(Form(" validity = %s - Using offline calibration parameters",validity.Data()));
1139 //AliInfo(Form(" validity = %s - Using online calibration parameters",validity.Data()));
1143 for (ii=0; ii<fNumberOfTofClusters; ii++) {
1144 digitIndex = fTofClusters[ii]->GetIndex();
1145 for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
1147 Int_t index = AliTOFGeometry::GetIndex(detectorIndex);
1149 UChar_t statusPulser=calStatus->GetPulserStatus(index);
1150 UChar_t statusNoise=calStatus->GetNoiseStatus(index);
1151 UChar_t statusHW=calStatus->GetHWStatus(index);
1152 UChar_t status=calStatus->GetStatus(index);
1153 tdcLatencyWindow = calStatus->GetLatencyWindow(index) * 1.e3; /* ns -> ps */
1155 //check the status, also unknown is fine!!!!!!!
1157 AliDebug(2, Form(" Status for channel %d = %d",index, (Int_t)status));
1158 if((statusPulser & AliTOFChannelOnlineStatusArray::kTOFPulserBad)==(AliTOFChannelOnlineStatusArray::kTOFPulserBad)||(statusNoise & AliTOFChannelOnlineStatusArray::kTOFNoiseBad)==(AliTOFChannelOnlineStatusArray::kTOFNoiseBad)||(statusHW & AliTOFChannelOnlineStatusArray::kTOFHWBad)==(AliTOFChannelOnlineStatusArray::kTOFHWBad)){
1159 AliDebug(2, Form(" Bad Status for channel %d",index));
1160 fTofClusters[ii]->SetStatus(kFALSE); //odd convention, to avoid conflict with calibration objects currently in the db (temporary solution).
1163 AliDebug(2, Form(" Good Status for channel %d",index));
1165 // Get Rough channel online equalization
1166 Double_t roughDelay=(Double_t)calDelay->GetDelay(index); // in ns
1167 AliDebug(2,Form(" channel delay (ns) = %f", roughDelay));
1168 // Get Refined channel offline calibration parameters
1169 if (calibration ==1){
1170 AliTOFChannelOffline * calChannelOffline = (AliTOFChannelOffline*)calTOFArrayOffline->At(index);
1172 for (Int_t j = 0; j<6; j++){
1173 par[j]=(Double_t)calChannelOffline->GetSlewPar(j);
1175 AliDebug(2,Form(" Calib Pars = %f, %f, %f, %f, %f, %f ",par[0],par[1],par[2],par[3],par[4],par[5]));
1176 AliDebug(2,Form(" The ToT and Time, uncorr (counts) = %d , %d", fTofClusters[ii]->GetToT(),fTofClusters[ii]->GetTDC()));
1177 tToT = (Double_t)(fTofClusters[ii]->GetToT()*AliTOFGeometry::ToTBinWidth());
1178 tToT*=1.E-3; //ToT in ns
1180 /* check TOT limits and set new TOT in case */
1181 if (tToT < AliTOFGeometry::SlewTOTMin()) tToT = AliTOFGeometry::SlewTOTMin();
1182 if (tToT > AliTOFGeometry::SlewTOTMax()) tToT = AliTOFGeometry::SlewTOTMax();
1184 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",fTofClusters[ii]->GetTDC()*AliTOFGeometry::TdcBinWidth()*1.E-3,tToT));
1185 timeCorr=par[0]+par[1]*tToT+par[2]*tToT*tToT+par[3]*tToT*tToT*tToT+par[4]*tToT*tToT*tToT*tToT+par[5]*tToT*tToT*tToT*tToT*tToT; // the time correction (ns)
1188 timeCorr = roughDelay; // correction in ns
1190 AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",fTofClusters[ii]->GetTDC()*AliTOFGeometry::TdcBinWidth()*1.E-3,fTofClusters[ii]->GetToT()*AliTOFGeometry::ToTBinWidth()));
1191 AliDebug(2,Form(" The time correction (ns) = %f", timeCorr));
1192 timeCorr=(Double_t)(fTofClusters[ii]->GetTDC())*AliTOFGeometry::TdcBinWidth()*1.E-3-timeCorr;//redefine the time
1194 AliDebug(2,Form(" The channel time, corr (ps)= %e",timeCorr ));
1196 /* here timeCorr should be already corrected for calibration.
1197 * we now go into further corrections keeping in mind that timeCorr
1200 * the following corrections are performed in this way:
1202 * time = timeRaw - deltaBC + L0L1Latency + CTPLatency - TDCLatencyWindow - T0
1206 AliDebug(2, Form("applying further corrections (DeltaBC): DeltaBC=%d (BC bins), DeltaBCoffset=%d (BC bins)", fTofClusters[ii]->GetDeltaBC(), deltaBCOffset));
1207 AliDebug(2, Form("applying further corrections (L0L1Latency): L0L1Latency=%d (BC bins)", fTofClusters[ii]->GetL0L1Latency()));
1208 AliDebug(2, Form("applying further corrections (CTPLatency): CTPLatency=%f (ps)", ctpLatency));
1209 AliDebug(2, Form("applying further corrections (TDCLatencyWindow): TDCLatencyWindow=%f (ps)", tdcLatencyWindow));
1210 AliDebug(2, Form("applying further corrections (T0): T0=%f (ps)", t0));
1212 /* deltaBC correction (inhibited for the time being) */
1213 // timeCorr -= (fTofClusters[ii]->GetDeltaBC() - deltaBCOffset) * AliTOFGeometry::BunchCrossingBinWidth();
1214 /* L0L1-latency correction */
1215 timeCorr += fTofClusters[ii]->GetL0L1Latency() * AliTOFGeometry::BunchCrossingBinWidth();
1216 /* CTP-latency correction (from OCDB) */
1217 timeCorr += ctpLatency;
1218 /* TDC latency-window correction (from OCDB) */
1219 timeCorr -= tdcLatencyWindow;
1220 /* T0 correction (from OCDB) */
1224 * end of furhter corrections
1227 tdcCorr=(Int_t)(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
1228 fTofClusters[ii]->SetTDC(tdcCorr);
1230 } // loop on clusters
1235 //_________________________________________________________________________
1237 void AliTOFClusterFinder::CalibrateRecPoint(UInt_t timestamp)
1240 // Copy the global array of AliTOFcluster, i.e. fTofClusters (sorted
1241 // in Z) in the global TClonesArray of AliTOFcluster,
1245 Int_t detectorIndex[5];
1246 Double_t time, tot, corr;
1247 Int_t deltaBC, l0l1, tdcBin;
1248 for (Int_t ii = 0; ii < fNumberOfTofClusters; ii++) {
1249 for(Int_t jj = 0; jj < 5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj);
1251 Int_t index = AliTOFGeometry::GetIndex(detectorIndex);
1253 /* check channel enabled */
1254 if (!fTOFcalib->IsChannelEnabled(index)) fTofClusters[ii]->SetStatus(kFALSE);
1256 /* get cluster info */
1257 time = fTofClusters[ii]->GetTDC() * AliTOFGeometry::TdcBinWidth(); /* ps */
1258 tot = fTofClusters[ii]->GetToT() * AliTOFGeometry::ToTBinWidth() * 1.e-3; /* ns */
1259 deltaBC = fTofClusters[ii]->GetDeltaBC();
1260 l0l1 = fTofClusters[ii]->GetL0L1Latency();
1262 /* get correction */
1263 corr = fTOFcalib->GetTimeCorrection(index, tot, deltaBC, l0l1, timestamp); /* ps */
1264 AliDebug(2, Form("calibrate index %d: time=%f (ps) tot=%f (ns) deltaBC=%d l0l1=%d timestamp=%d corr=%f (ps)", index, time, tot, deltaBC, l0l1, timestamp, corr));
1266 /* apply time correction */
1269 /* convert in TDC bins and set cluster */
1270 //tdcBin = (Int_t)(time / AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
1271 tdcBin = TMath::Nint(time / AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
1272 fTofClusters[ii]->SetTDC(tdcBin);
1276 AliTOFGeometry::GetPosPar(detectorIndex, pos);
1277 Float_t length = 0.;
1278 for (Int_t ic = 0; ic < 3; ic++) length += pos[ic] * pos[ic];
1279 length = TMath::Sqrt(length);
1280 Float_t timealligned = tdcBin*24.4 - length * 0.0333564095198152043; // subtract the minimal time in
1282 if(timealligned > -1000 && timealligned < 24000 && fTOFcalib->IsChannelEnabled(index)){
1283 fNumberOfTofTrgPads++;
1286 } // loop on clusters
1290 //______________________________________________________________________________
1292 void AliTOFClusterFinder::ResetRecpoint()
1295 // Clear the list of reconstructed points
1298 fNumberOfTofClusters = 0;
1299 fNumberOfTofTrgPads = 0;
1300 if (fRecPoints) fRecPoints->Clear();
1303 //______________________________________________________________________________
1305 void AliTOFClusterFinder::Load()
1308 // Load TOF.Digits.root and TOF.RecPoints.root files
1311 fTOFLoader->LoadDigits("READ");
1312 fTOFLoader->LoadRecPoints("recreate");
1315 //______________________________________________________________________________
1317 void AliTOFClusterFinder::LoadClusters()
1320 // Load TOF.RecPoints.root file
1323 fTOFLoader->LoadRecPoints("recreate");
1326 //______________________________________________________________________________
1328 void AliTOFClusterFinder::UnLoad()
1331 // Unload TOF.Digits.root and TOF.RecPoints.root files
1334 fTOFLoader->UnloadDigits();
1335 fTOFLoader->UnloadRecPoints();
1338 //______________________________________________________________________________
1340 void AliTOFClusterFinder::UnLoadClusters()
1343 // Unload TOF.RecPoints.root file
1346 fTOFLoader->UnloadRecPoints();
1349 //-------------------------------------------------------------------------
1350 UShort_t AliTOFClusterFinder::GetClusterVolIndex(const Int_t * const ind) const {
1352 //First of all get the volume ID to retrieve the l2t transformation...
1354 // Detector numbering scheme
1361 Int_t isector =ind[0];
1362 if (isector >= nSector)
1363 AliError(Form("Wrong sector number in TOF (%d) !",isector));
1364 Int_t iplate = ind[1];
1365 if (iplate >= nPlate)
1366 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
1367 Int_t istrip = ind[2];
1369 Int_t stripOffset = 0;
1375 stripOffset = nStripC;
1378 stripOffset = nStripC+nStripB;
1381 stripOffset = nStripC+nStripB+nStripA;
1384 stripOffset = nStripC+nStripB+nStripA+nStripB;
1387 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
1391 Int_t index= (2*(nStripC+nStripB)+nStripA)*isector +
1395 UShort_t volIndex = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF,index);
1399 //-------------------------------------------------------------------------
1400 void AliTOFClusterFinder::GetClusterPars(Int_t *ind, Double_t* pos,Double_t* cov) const {
1402 //First of all get the volume ID to retrieve the l2t transformation...
1404 UShort_t volIndex = GetClusterVolIndex(ind);
1407 //we now go in the system of the strip: determine the local coordinates
1410 // 47---------------------------------------------------0 ^ z
1411 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 |
1412 // ----------------------------------------------------- | y going outwards
1413 // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0;
1415 // ----------------------------------------------------- |
1416 // x <-----------------------------------------------------
1419 Float_t localX = (ind[4]-23.5)*AliTOFGeometry::XPad();
1421 Float_t localZ = (ind[3]- 0.5)*AliTOFGeometry::ZPad();
1423 Float_t localX = (ind[4]-AliTOFGeometry::NpadX()/2)*AliTOFGeometry::XPad()+AliTOFGeometry::XPad()/2.;
1425 Float_t localZ = (ind[3]-AliTOFGeometry::NpadZ()/2)*AliTOFGeometry::ZPad()+AliTOFGeometry::ZPad()/2.;
1426 //move to the tracking ref system
1433 const TGeoHMatrix *l2t= AliGeomManager::GetTracking2LocalMatrix(volIndex);
1434 // Get The position in the track ref system
1436 l2t->MasterToLocal(lpos,tpos);
1441 //Get The cluster covariance in the track ref system
1444 //cluster covariance in the local system:
1449 lcov[0] = AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.;
1457 lcov[8] = AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.;
1459 //cluster covariance in the tracking system:
1461 m.SetRotation(lcov);
1463 m.MultiplyLeft(&l2t->Inverse());
1464 Double_t *tcov = m.GetRotationMatrix();
1465 cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2];
1466 cov[3] = tcov[4]; cov[4] = tcov[5];
1472 //-------------------------------------------------------------------------
1473 void AliTOFClusterFinder::FillTOFtriggerMap(Int_t iDDL, AliTOFrawData *tofRawDatum)
1476 /* get cluster info */
1477 //Int_t trm = tofRawDatum->GetTRM();
1478 // Int_t tdc = tofRawDatum->GetTDC();
1479 // Int_t tdc_ch = tofRawDatum->GetTDCchannel();
1480 Int_t chain = tofRawDatum->GetTRMchain();
1481 Int_t l0l1 = tofRawDatum->GetL0L1Latency();
1482 Double_t corr = l0l1 * AliTOFGeometry::BunchCrossingBinWidth();
1483 AliTOFCTPLatency *ctpLatencyObj = fTOFcalib->GetCTPLatency();
1484 Float_t ctpLatency = ctpLatencyObj->GetCTPLatency();
1487 Double_t timeTOF=tofRawDatum->GetTOF()*AliTOFGeometry::TdcBinWidth();
1489 //Int_t timeRaw_bc = Int_t(timeTOF/1000/24.4); // per ora non usata
1491 //Int_t timeRaw_bc = Int_t((tofRawDatum->GetTOF()*AliTOFGeometry::TdcBinWidth())/1000/24.4); // per ora non usata
1494 const Int_t crate_CTTM[72] = { 0, 1, 37, 36, 2, 3, 39, 38, 4, 5,
1495 41, 40, 6, 7, 43, 42, 8, 9, 45, 44,
1496 10, 11, 47, 46, 12, 13, 49, 48, 14, 15,
1497 51, 50, 16, 17, 53, 52, 18, 19, 55, 54,
1498 20, 21, 57, 56, 22, 23, 59, 58, 24, 25,
1499 61, 60, 26, 27, 63, 62, 28, 29, 65, 64,
1500 30, 31, 67, 66, 32, 33, 69, 68, 34, 35,
1505 // Int_t cttmBit = tdc_ch + (tdc-12)*AliTOFGeometry::NCh();
1506 switch(iDDL%AliTOFGeometry::NDDL()){
1516 cttmCrate+=2*(Int_t)(iDDL/AliTOFGeometry::NDDL());
1518 if (iDDL<36) cttmCrate--;