X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TOF%2FAliTOFClusterFinder.cxx;h=f266fd71bc7ed47f9569de3085eecb9eb047ba30;hb=d6d4cfcee5f957750475adc502b7aed757c24b98;hp=58cd7767dc3df7d20a9e39483266e1574c99b95f;hpb=ef58b2af59cab4bd41517b2de289ae050473f92c;p=u%2Fmrichter%2FAliRoot.git diff --git a/TOF/AliTOFClusterFinder.cxx b/TOF/AliTOFClusterFinder.cxx index 58cd7767dc3..f266fd71bc7 100644 --- a/TOF/AliTOFClusterFinder.cxx +++ b/TOF/AliTOFClusterFinder.cxx @@ -14,9 +14,23 @@ **************************************************************************/ /* -$Log$ +$Log: AliTOFClusterFinder.cxx,v $ +Revision 1.31 2007/11/24 14:53:19 zampolli +Status flag implemented as UChar_t + +Revision 1.30 2007/10/04 13:08:52 arcelli +updates to comply with AliTOFGeometryV5 becoming AliTOFGeometry + +Revision 1.29 2007/10/03 10:42:33 arcelli +updates to handle new AliTOFcluster, inheriting form AliCluster3D + +Revision 1.28 2007/05/31 16:06:05 arcelli +move instance of AliRawStream outside loop on DDL + Revision 1.27 2007/05/02 16:31:49 arcelli -Add methods to handle single event reconstruction. retrieval of Calib info moved to AliTOFReconstructor ctor, and passed via a pointer to AliTOFcalib +Add methods to handle single event reconstruction. retrieval of Calib +info moved to AliTOFReconstructor ctor, and passed via a pointer to +AliTOFcalib Revision 1.26 2007/04/30 19:02:24 arcelli hopefully the last refinements for correct type conversion in calibration @@ -28,7 +42,8 @@ Revision 1.24 2007/04/27 11:19:31 arcelli updates for the new decoder Revision 1.23 2007/04/23 16:51:39 decaro -Digits-to-raw_data conversion: correction for a more real description (A.De Caro, R.Preghenella) +Digits-to-raw_data conversion: correction for a more real description +(A.De Caro, R.Preghenella) Revision 1.22 2007/04/19 17:26:32 arcelli Fix a bug (add some debug printout @@ -46,7 +61,8 @@ Revision 1.18 2007/03/06 16:31:20 arcelli Add Uncorrected TOF Time signal Revision 1.17 2007/02/28 18:09:11 arcelli -Add protection against failed retrieval of the CDB cal object, now Reconstruction exits with AliFatal +Add protection against failed retrieval of the CDB cal object, +now Reconstruction exits with AliFatal Revision 1.16 2007/02/20 15:57:00 decaro Raw data update: to read the TOF raw data defined in UNPACKED mode @@ -87,96 +103,119 @@ Revision 0.01 2005/07/25 A. De Caro // // //////////////////////////////////////////////////////////////// +#include "Riostream.h" #include "TClonesArray.h" -//#include "TFile.h" #include "TStopwatch.h" #include "TTree.h" +//#include +#include +//#include #include "AliDAQ.h" #include "AliLoader.h" #include "AliLog.h" #include "AliRawReader.h" #include "AliRunLoader.h" +//#include "AliAlignObj.h" +#include -#include "AliTOFCal.h" #include "AliTOFcalib.h" -#include "AliTOFChannel.h" +#include "AliTOFChannelOnlineArray.h" +#include "AliTOFChannelOnlineStatusArray.h" +#include "AliTOFChannelOffline.h" #include "AliTOFClusterFinder.h" #include "AliTOFcluster.h" #include "AliTOFdigit.h" #include "AliTOFGeometry.h" -#include "AliTOFGeometryV5.h" #include "AliTOFrawData.h" -#include "AliTOFRawStream.h" -#include "Riostream.h" + +#include "AliTOFDeltaBCOffset.h" +#include "AliTOFCTPLatency.h" +#include "AliTOFRunParams.h" //extern TFile *gFile; ClassImp(AliTOFClusterFinder) AliTOFClusterFinder::AliTOFClusterFinder(AliTOFcalib *calib): + TTask("AliTOFClusterFinder",""), fRunLoader(0), fTOFLoader(0), fTreeD(0), fTreeR(0), - fTOFGeometry(new AliTOFGeometryV5()), fDigits(new TClonesArray("AliTOFdigit", 4000)), fRecPoints(new TClonesArray("AliTOFcluster", 4000)), fNumberOfTofClusters(0), fVerbose(0), fDecoderVersion(0), - fTOFcalib(calib) + fTOFcalib(calib), + fTOFRawStream(AliTOFRawStream()) { // // Constructor // - AliInfo("V5 TOF Geometry is taken as the default"); + for (Int_t ii=0; iiGetOfflineValidity(); + if (validity.CompareTo("valid")==0) { + AliInfo(Form(" validity = %s - Using offline calibration parameters",validity.Data())); + } else { + AliInfo(Form(" validity = %s - Using online calibration parameters",validity.Data())); + } } + //______________________________________________________________________________ AliTOFClusterFinder::AliTOFClusterFinder(AliRunLoader* runLoader, AliTOFcalib *calib): + TTask("AliTOFClusterFinder",""), fRunLoader(runLoader), fTOFLoader(runLoader->GetLoader("TOFLoader")), fTreeD(0), fTreeR(0), - fTOFGeometry(new AliTOFGeometryV5()), fDigits(new TClonesArray("AliTOFdigit", 4000)), fRecPoints(new TClonesArray("AliTOFcluster", 4000)), fNumberOfTofClusters(0), fVerbose(0), fDecoderVersion(0), - fTOFcalib(calib) + fTOFcalib(calib), + fTOFRawStream(AliTOFRawStream()) { // // Constructor // + for (Int_t ii=0; iiGetOfflineValidity(); + if (validity.CompareTo("valid")==0) { + AliInfo(Form(" validity = %s - Using offline calibration parameters",validity.Data())); + } else { + AliInfo(Form(" validity = %s - Using online calibration parameters",validity.Data())); + } + } //------------------------------------------------------------------------ -AliTOFClusterFinder::AliTOFClusterFinder(const AliTOFClusterFinder &source) - :TObject(), +AliTOFClusterFinder::AliTOFClusterFinder(const AliTOFClusterFinder &source) : + TTask(source), fRunLoader(0), fTOFLoader(0), fTreeD(0), fTreeR(0), - fTOFGeometry(new AliTOFGeometryV5()), - fDigits(new TClonesArray("AliTOFdigit", 4000)), - fRecPoints(new TClonesArray("AliTOFcluster", 4000)), + fDigits(source.fDigits), + fRecPoints(source.fRecPoints), fNumberOfTofClusters(0), fVerbose(0), - fDecoderVersion(0), - fTOFcalib(0) + fDecoderVersion(source.fDecoderVersion), + fTOFcalib(source.fTOFcalib), + fTOFRawStream(source.fTOFRawStream) { // copy constructor - this->fDigits=source.fDigits; - this->fRecPoints=source.fRecPoints; - this->fTOFGeometry=source.fTOFGeometry; - this->fDecoderVersion=source.fDecoderVersion; - this->fTOFcalib=source.fTOFcalib; + + for (Int_t ii=0; iifDigits=source.fDigits; - this->fRecPoints=source.fRecPoints; - this->fTOFGeometry=source.fTOFGeometry; - this->fVerbose=source.fVerbose; - this->fDecoderVersion=source.fDecoderVersion; - this->fTOFcalib=source.fTOFcalib; + + if (this == &source) + return *this; + + TTask::operator=(source); + fDigits=source.fDigits; + fRecPoints=source.fRecPoints; + fVerbose=source.fVerbose; + fDecoderVersion=source.fDecoderVersion; + fTOFcalib=source.fTOFcalib; + fTOFRawStream=source.fTOFRawStream; + for (Int_t ii=0; iiDelete(); + fNumberOfTofClusters=0; + } } //______________________________________________________________________________ @@ -229,22 +280,19 @@ void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent) TStopwatch stopwatch; stopwatch.Start(); + Int_t inholes = 0; + fRunLoader->GetEvent(iEvent); fTreeD = fTOFLoader->TreeD(); - if (fTreeD == 0x0) - { - AliFatal("AliTOFClusterFinder: Can not get TreeD"); - } - - TBranch *branch = fTreeD->GetBranch("TOF"); - if (!branch) { - AliError("can't get the branch with the TOF digits !"); + if (fTreeD == 0x0) { + AliFatal("AliTOFClusterFinder: Can not get TreeD"); return; } - TClonesArray *digits = new TClonesArray("AliTOFdigit",10000); - branch->SetAddress(&digits); + fDigits->Clear(); + fTreeD->GetBranch("TOF")->SetAutoDelete(kFALSE); + fTreeD->SetBranchAddress("TOF",&fDigits); ResetRecpoint(); @@ -259,43 +307,51 @@ void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent) fTreeR->Branch("TOF", &fRecPoints, bufsize); fTreeD->GetEvent(0); - Int_t nDigits = digits->GetEntriesFast(); + Int_t nDigits = fDigits->GetEntriesFast(); AliDebug(2,Form("Number of TOF digits: %d",nDigits)); - Int_t ii, jj; - Int_t dig[5]; //cluster detector indeces - Float_t g[3]; //cluster cartesian coord - Double_t h[3]; // the cluster spatial cyl. coordinates - Int_t parTOF[5]; //The TOF signal parameters + Int_t ii; + Int_t dig[5]={-1,-1,-1,-1,-1}; //cluster detector indeces + Int_t parTOF[7]={0,0,0,0,0,0,0}; //The TOF signal parameters Bool_t status=kTRUE; // assume all sim channels ok in the beginning... for (ii=0; iiUncheckedAt(ii); + AliTOFdigit *d = (AliTOFdigit*)fDigits->UncheckedAt(ii); dig[0]=d->GetSector(); dig[1]=d->GetPlate(); dig[2]=d->GetStrip(); dig[3]=d->GetPadz(); dig[4]=d->GetPadx(); - // AliDebug(2,Form(" %2i %1i %2i %1i %2i ",dig[0],dig[1],dig[2],dig[3],dig[4])); + /* check valid index */ + if (dig[0]==-1||dig[1]==-1||dig[2]==-1||dig[3]==-1||dig[4]==-1) continue; - for (jj=0; jj<3; jj++) g[jj] = 0.; - fTOFGeometry->GetPos(dig,g); + // Do not reconstruct anything in the holes + if (dig[0]==13 || dig[0]==14 || dig[0]==15 ) { // sectors with holes + if (dig[1]==2) { // plate with holes + inholes++; + continue; + } + } - h[0] = TMath::Sqrt(g[0]*g[0]+g[1]*g[1]); - h[1] = TMath::ATan2(g[1],g[0]); - h[2] = g[2]; + AliDebug(2,Form(" %2d %1d %2d %1d %2d ",dig[0],dig[1],dig[2],dig[3],dig[4])); parTOF[0] = d->GetTdc(); //the TDC signal parTOF[1] = d->GetToT(); //the ToT signal parTOF[2] = d->GetAdc(); // the adc charge parTOF[3] = d->GetTdcND(); // non decalibrated sim time parTOF[4] = d->GetTdc(); // raw time, == Tdc time for the moment - AliTOFcluster *tofCluster = new AliTOFcluster(h,dig,parTOF,status,d->GetTracks(),ii); + parTOF[5] = 0; // deltaBC + parTOF[6] = 0; // L0-L1 latency + Double_t posClus[3]; + Double_t covClus[6]; + UShort_t volIdClus=GetClusterVolIndex(dig); + GetClusterPars(dig, posClus,covClus); + 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); InsertCluster(tofCluster); } - AliInfo(Form("Number of found clusters: %i for event: %i", fNumberOfTofClusters, iEvent)); + AliDebug(1,Form("Number of found clusters: %d for event: %d", fNumberOfTofClusters, iEvent)); CalibrateRecPoint(); FillRecPoint(); @@ -306,11 +362,10 @@ void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent) fTOFLoader = fRunLoader->GetLoader("TOFLoader"); fTOFLoader->WriteRecPoints("OVERWRITE"); - AliInfo(Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs", - stopwatch.RealTime(),stopwatch.CpuTime())); + AliDebug(1,Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs", + stopwatch.RealTime(),stopwatch.CpuTime())); + if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes)); - digits->Delete(); - delete digits; } //______________________________________________________________________________ @@ -324,66 +379,68 @@ void AliTOFClusterFinder::Digits2RecPoints(TTree* digitsTree, TTree* clusterTree TStopwatch stopwatch; stopwatch.Start(); - /// fRunLoader->GetEvent(iEvent); - - if (digitsTree == 0x0) - { - AliFatal("AliTOFClusterFinder: Can not get TreeD"); - } + Int_t inholes = 0; - TBranch *branch = digitsTree->GetBranch("TOF"); - if (!branch) { - AliError("can't get the branch with the TOF digits !"); + if (digitsTree == 0x0) { + AliFatal("AliTOFClusterFinder: Can not get TreeD"); return; } - TClonesArray *digits = new TClonesArray("AliTOFdigit",10000); - branch->SetAddress(&digits); + fDigits->Clear(); + digitsTree->GetBranch("TOF")->SetAutoDelete(kFALSE); + digitsTree->SetBranchAddress("TOF",&fDigits); ResetRecpoint(); - - fTreeR=clusterTree; Int_t bufsize = 32000; - fTreeR->Branch("TOF", &fRecPoints, bufsize); + clusterTree->Branch("TOF", &fRecPoints, bufsize); digitsTree->GetEvent(0); - Int_t nDigits = digits->GetEntriesFast(); + Int_t nDigits = fDigits->GetEntriesFast(); AliDebug(2,Form("Number of TOF digits: %d",nDigits)); - Int_t ii, jj; - Int_t dig[5]; //cluster detector indeces - Float_t g[3]; //cluster cartesian coord - Double_t h[3]; // the cluster spatial cyl. coordinates - Int_t parTOF[5]; //The TOF signal parameters + Int_t ii; + Int_t dig[5]={-1,-1,-1,-1,-1}; //cluster detector indeces + Int_t parTOF[7]={0,0,0,0,0,0,0}; //The TOF signal parameters Bool_t status=kTRUE; // assume all sim channels ok in the beginning... for (ii=0; iiUncheckedAt(ii); + AliTOFdigit *d = (AliTOFdigit*)fDigits->UncheckedAt(ii); dig[0]=d->GetSector(); dig[1]=d->GetPlate(); dig[2]=d->GetStrip(); dig[3]=d->GetPadz(); dig[4]=d->GetPadx(); - // AliDebug(2,Form(" %2i %1i %2i %1i %2i ",dig[0],dig[1],dig[2],dig[3],dig[4])); + /* check valid index */ + if (dig[0]==-1||dig[1]==-1||dig[2]==-1||dig[3]==-1||dig[4]==-1) continue; - for (jj=0; jj<3; jj++) g[jj] = 0.; - fTOFGeometry->GetPos(dig,g); + // Do not reconstruct anything in the holes + if (dig[0]==13 || dig[0]==14 || dig[0]==15 ) { // sectors with holes + if (dig[1]==2) { // plate with holes + inholes++; + continue; + } + } - h[0] = TMath::Sqrt(g[0]*g[0]+g[1]*g[1]); - h[1] = TMath::ATan2(g[1],g[0]); - h[2] = g[2]; + // AliDebug(2,Form(" %2d %1d %2d %1d %2d ",dig[0],dig[1],dig[2],dig[3],dig[4])); parTOF[0] = d->GetTdc(); //the TDC signal parTOF[1] = d->GetToT(); //the ToT signal parTOF[2] = d->GetAdc(); // the adc charge parTOF[3] = d->GetTdcND(); // non decalibrated sim time parTOF[4] = d->GetTdc(); // raw time, == Tdc time for the moment - AliTOFcluster *tofCluster = new AliTOFcluster(h,dig,parTOF,status,d->GetTracks(),ii); + parTOF[5] = 0; // deltaBC + parTOF[6] = 0; // L0-L1 latency + + Double_t posClus[3]; + Double_t covClus[6]; + UShort_t volIdClus=GetClusterVolIndex(dig); + GetClusterPars(dig,posClus,covClus); + 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); InsertCluster(tofCluster); } - AliInfo(Form("Number of found clusters: %i", fNumberOfTofClusters)); + AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters)); CalibrateRecPoint(); FillRecPoint(); @@ -391,11 +448,10 @@ void AliTOFClusterFinder::Digits2RecPoints(TTree* digitsTree, TTree* clusterTree clusterTree->Fill(); ResetRecpoint(); - AliInfo(Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs", - stopwatch.RealTime(),stopwatch.CpuTime())); + AliDebug(1,Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs", + stopwatch.RealTime(),stopwatch.CpuTime())); + if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes)); - digits->Delete(); - delete digits; } //______________________________________________________________________________ @@ -409,7 +465,8 @@ void AliTOFClusterFinder::Digits2RecPoints(AliRawReader *rawReader, TStopwatch stopwatch; stopwatch.Start(); - //const Int_t kDDL = fTOFGeometry->NDDL()*fTOFGeometry->NSectors(); + Int_t inholes = 0; + const Int_t kDDL = AliDAQ::NumberOfDdls("TOF"); ResetRecpoint(); @@ -418,37 +475,49 @@ void AliTOFClusterFinder::Digits2RecPoints(AliRawReader *rawReader, clustersTree->Branch("TOF", &fRecPoints, bufsize); TClonesArray * clonesRawData; - - Int_t ii = 0; Int_t dummy = -1; Int_t detectorIndex[5]; - Float_t position[3]; - Double_t cylindricalPosition[3]; - Int_t parTOF[5]; + Int_t parTOF[7]; ofstream ftxt; if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app); - AliTOFRawStream tofInput(rawReader); + fTOFRawStream.Clear(); + fTOFRawStream.SetRawReader(rawReader); + + if (fDecoderVersion == 1) { + AliInfo("Using New Decoder"); + } + else if (fDecoderVersion == 2) { + AliInfo("Using Enhanced Decoder"); + } + else { + AliInfo("Using Old Decoder"); + } Int_t indexDDL = 0; for (indexDDL = 0; indexDDL < kDDL; indexDDL++) { rawReader->Reset(); - if (fDecoderVersion) { - AliInfo("Using New Decoder \n"); - tofInput.LoadRawDataBuffers(indexDDL,fVerbose); + if (fDecoderVersion == 1) { + fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose); } - else tofInput.LoadRawData(indexDDL); - - clonesRawData = (TClonesArray*)tofInput.GetRawData(); + else if (fDecoderVersion == 2) { + fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose); + } + else { + fTOFRawStream.LoadRawData(indexDDL); + } + + clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData(); for (Int_t iRawData = 0; iRawDataGetEntriesFast(); iRawData++) { AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData); - if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue; + //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue; + if (tofRawDatum->GetTOF()==-1) continue; if (fVerbose==2) { if (indexDDL<10) ftxt << " " << indexDDL; @@ -461,8 +530,8 @@ void AliTOFClusterFinder::Digits2RecPoints(AliRawReader *rawReader, ftxt << " " << tofRawDatum->GetTDCchannel(); } - tofInput.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(), - tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex); + fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(), + tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex); dummy = detectorIndex[3]; detectorIndex[3] = detectorIndex[4]; detectorIndex[4] = dummy; @@ -478,19 +547,31 @@ void AliTOFClusterFinder::Digits2RecPoints(AliRawReader *rawReader, else ftxt << " " << detectorIndex[4]; } - for (ii=0; ii<3; ii++) position[ii] = 0.; - fTOFGeometry->GetPos(detectorIndex, position); + /* check valid index */ + if (detectorIndex[0]==-1||detectorIndex[1]==-1||detectorIndex[2]==-1||detectorIndex[3]==-1||detectorIndex[4]==-1) continue; - cylindricalPosition[0] = TMath::Sqrt(position[0]*position[0] + position[1]*position[1]); - cylindricalPosition[1] = TMath::ATan2(position[1], position[0]); - cylindricalPosition[2] = position[2]; + // Do not reconstruct anything in the holes + if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes + if (detectorIndex[1]==2) { // plate with holes + inholes++; + continue; + } + } parTOF[0] = tofRawDatum->GetTOF(); //TDC parTOF[1] = tofRawDatum->GetTOT(); // TOT parTOF[2] = tofRawDatum->GetTOT(); //ADC==TOF - parTOF[3] = -1;//raw data: no track of undecalib sim time + parTOF[3] = 0;//raw data: no track of undecalib sim time parTOF[4] = tofRawDatum->GetTOF(); // RAW time - AliTOFcluster *tofCluster = new AliTOFcluster(cylindricalPosition, detectorIndex, parTOF); + parTOF[5] = tofRawDatum->GetDeltaBC(); // deltaBC + parTOF[6] = tofRawDatum->GetL0L1Latency(); // L0-L1 latency + Double_t posClus[3]; + Double_t covClus[6]; + UShort_t volIdClus=GetClusterVolIndex(detectorIndex); + Int_t lab[3]={-1,-1,-1}; + Bool_t status=kTRUE; + GetClusterPars(detectorIndex,posClus,covClus); + 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); InsertCluster(tofCluster); if (fVerbose==2) { @@ -505,15 +586,15 @@ void AliTOFClusterFinder::Digits2RecPoints(AliRawReader *rawReader, } // closed loop on TOF raw data per current DDL file - clonesRawData->Clear(); + clonesRawData->Clear("C"); } // closed loop on DDL index if (fVerbose==2) ftxt.close(); - AliInfo(Form("Number of found clusters: %i", fNumberOfTofClusters)); + AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters)); - CalibrateRecPoint(); + CalibrateRecPoint(rawReader->GetTimestamp()); FillRecPoint(); clustersTree->Fill(); @@ -522,6 +603,7 @@ void AliTOFClusterFinder::Digits2RecPoints(AliRawReader *rawReader, AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs", stopwatch.RealTime(),stopwatch.CpuTime())); + if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes)); } //______________________________________________________________________________ @@ -535,12 +617,13 @@ void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader TStopwatch stopwatch; stopwatch.Start(); - //const Int_t kDDL = fTOFGeometry->NDDL()*fTOFGeometry->NSectors(); + Int_t inholes = 0; + const Int_t kDDL = AliDAQ::NumberOfDdls("TOF"); fRunLoader->GetEvent(iEvent); - AliDebug(2,Form(" Event number %2i ", iEvent)); + AliDebug(2,Form(" Event number %2d ", iEvent)); fTreeR = fTOFLoader->TreeR(); @@ -554,35 +637,48 @@ void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader TClonesArray * clonesRawData; - Int_t ii = 0; Int_t dummy = -1; Int_t detectorIndex[5] = {-1, -1, -1, -1, -1}; - Float_t position[3]; - Double_t cylindricalPosition[5]; - Int_t parTOF[5]; + Int_t parTOF[7]; ofstream ftxt; if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app); - AliTOFRawStream tofInput(rawReader); + fTOFRawStream.Clear(); + fTOFRawStream.SetRawReader(rawReader); + + if (fDecoderVersion == 1) { + AliInfo("Using New Decoder"); + } + else if (fDecoderVersion == 2) { + AliInfo("Using Enhanced Decoder"); + } + else { + AliInfo("Using Old Decoder"); + } Int_t indexDDL = 0; for (indexDDL = 0; indexDDL < kDDL; indexDDL++) { rawReader->Reset(); - if (fDecoderVersion) { - AliInfo("Using New Decoder \n"); - tofInput.LoadRawDataBuffers(indexDDL,fVerbose); + if (fDecoderVersion == 1) { + fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose); + } + else if (fDecoderVersion == 2) { + fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose); + } + else { + fTOFRawStream.LoadRawData(indexDDL); } - else tofInput.LoadRawData(indexDDL); - clonesRawData = (TClonesArray*)tofInput.GetRawData(); + clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData(); for (Int_t iRawData = 0; iRawDataGetEntriesFast(); iRawData++) { AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData); - if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue; + //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue; + if (tofRawDatum->GetTOF()==-1) continue; if (fVerbose==2) { if (indexDDL<10) ftxt << " " << indexDDL; @@ -595,8 +691,8 @@ void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader ftxt << " " << tofRawDatum->GetTDCchannel(); } - tofInput.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(), - tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex); + fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(), + tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex); dummy = detectorIndex[3]; detectorIndex[3] = detectorIndex[4]; detectorIndex[4] = dummy; @@ -612,18 +708,31 @@ void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader else ftxt << " " << detectorIndex[4]; } - for (ii=0; ii<3; ii++) position[ii] = 0.; - fTOFGeometry->GetPos(detectorIndex, position); + /* check valid index */ + if (detectorIndex[0]==-1||detectorIndex[1]==-1||detectorIndex[2]==-1||detectorIndex[3]==-1||detectorIndex[4]==-1) continue; + + // Do not reconstruct anything in the holes + if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes + if (detectorIndex[1]==2) { // plate with holes + inholes++; + continue; + } + } - cylindricalPosition[0] = TMath::Sqrt(position[0]*position[0] + position[1]*position[1]); - cylindricalPosition[1] = TMath::ATan2(position[1], position[0]); - cylindricalPosition[2] = position[2]; parTOF[0] = tofRawDatum->GetTOF(); // TDC parTOF[1] = tofRawDatum->GetTOT(); // TOT parTOF[2] = tofRawDatum->GetTOT(); // raw data have ADC=TOT - parTOF[3] = -1; //raw data: no track of the undecalib sim time + parTOF[3] = 0; //raw data: no track of the undecalib sim time parTOF[4] = tofRawDatum->GetTOF(); // Raw time == TDC - AliTOFcluster *tofCluster = new AliTOFcluster(cylindricalPosition, detectorIndex, parTOF); + parTOF[5] = tofRawDatum->GetDeltaBC(); // deltaBC + parTOF[6] = tofRawDatum->GetL0L1Latency(); // L0-L1 latency + Double_t posClus[3]; + Double_t covClus[6]; + UShort_t volIdClus=GetClusterVolIndex(detectorIndex); + Int_t lab[3]={-1,-1,-1}; + Bool_t status=kTRUE; + GetClusterPars(detectorIndex,posClus,covClus); + 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); InsertCluster(tofCluster); if (fVerbose==2) { @@ -638,15 +747,15 @@ void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader } // closed loop on TOF raw data per current DDL file - clonesRawData->Clear(); + clonesRawData->Clear("C"); } // closed loop on DDL index if (fVerbose==2) ftxt.close(); - AliInfo(Form("Number of found clusters: %i for event: %i", fNumberOfTofClusters, iEvent)); + AliDebug(1,Form("Number of found clusters: %d for event: %d", fNumberOfTofClusters, iEvent)); - CalibrateRecPoint(); + CalibrateRecPoint(rawReader->GetTimestamp()); FillRecPoint(); fTreeR->Fill(); @@ -657,6 +766,7 @@ void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs", stopwatch.RealTime(),stopwatch.CpuTime())); + if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes)); } //______________________________________________________________________________ @@ -672,8 +782,7 @@ void AliTOFClusterFinder::Raw2Digits(Int_t iEvent, AliRawReader *rawReader) TStopwatch stopwatch; stopwatch.Start(); - //const Int_t kDDL = fTOFGeometry->NDDL()*fTOFGeometry->NSectors(); - const Int_t kDDL = fTOFGeometry->NDDL()*fTOFGeometry->NSectors(); + const Int_t kDDL = AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); fRunLoader->GetEvent(iEvent); @@ -685,14 +794,18 @@ void AliTOFClusterFinder::Raw2Digits(Int_t iEvent, AliRawReader *rawReader) fTOFLoader->MakeTree("D"); fTreeD = fTOFLoader->TreeD(); } + else { + AliFatal("Can not get TreeD"); + return; + } - TClonesArray *tofDigits = new TClonesArray("AliTOFdigit",10000); Int_t bufsize = 32000; - fTreeD->Branch("TOF", &tofDigits, bufsize); + fDigits->Clear(); + fTreeD->Branch("TOF", &fDigits, bufsize); fRunLoader->GetEvent(iEvent); - AliDebug(2,Form(" Event number %2i ", iEvent)); + AliDebug(2,Form(" Event number %2d ", iEvent)); TClonesArray * clonesRawData; @@ -701,46 +814,62 @@ void AliTOFClusterFinder::Raw2Digits(Int_t iEvent, AliRawReader *rawReader) Int_t detectorIndex[5]; Int_t digit[4]; - AliTOFRawStream tofInput(rawReader); + fTOFRawStream.Clear(); + fTOFRawStream.SetRawReader(rawReader); + + if (fDecoderVersion == 1) { + AliInfo("Using New Decoder"); + } + else if (fDecoderVersion == 2) { + AliInfo("Using Enhanced Decoder"); + } + else { + AliInfo("Using Old Decoder"); + } Int_t indexDDL = 0; for (indexDDL = 0; indexDDL < kDDL; indexDDL++) { rawReader->Reset(); - if (fDecoderVersion) { - AliInfo("Using New Decoder \n"); - tofInput.LoadRawDataBuffers(indexDDL,fVerbose); + if (fDecoderVersion == 1) { + fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose); + } + else if (fDecoderVersion == 2) { + fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose); + } + else { + fTOFRawStream.LoadRawData(indexDDL); } - else tofInput.LoadRawData(indexDDL); - clonesRawData = (TClonesArray*)tofInput.GetRawData(); + clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData(); for (Int_t iRawData = 0; iRawDataGetEntriesFast(); iRawData++) { AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData); - if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue; + //if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue; + if (tofRawDatum->GetTOF()==-1) continue; - tofInput.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(), - tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex); + fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(), + tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex); dummy = detectorIndex[3]; detectorIndex[3] = detectorIndex[4]; detectorIndex[4] = dummy; - digit[0] = tofInput.GetTofBin(); - digit[1] = tofInput.GetToTbin(); - digit[2] = tofInput.GetToTbin(); - digit[3] = -1; + digit[0] = fTOFRawStream.GetTofBin(); + digit[1] = fTOFRawStream.GetToTbin(); + digit[2] = fTOFRawStream.GetToTbin(); + digit[3] = 0; Int_t tracknum[3]={-1,-1,-1}; - TClonesArray &aDigits = *tofDigits; - Int_t last=tofDigits->GetEntriesFast(); + TClonesArray &aDigits = *fDigits; + Int_t last=fDigits->GetEntriesFast(); new (aDigits[last]) AliTOFdigit(tracknum, detectorIndex, digit); } // while loop - clonesRawData->Clear(); + clonesRawData->Clear("C"); } // DDL Loop @@ -748,7 +877,7 @@ void AliTOFClusterFinder::Raw2Digits(Int_t iEvent, AliRawReader *rawReader) fTOFLoader = fRunLoader->GetLoader("TOFLoader"); fTOFLoader->WriteDigits("OVERWRITE"); - + AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.2fs C:%.2fs", stopwatch.RealTime(),stopwatch.CpuTime())); @@ -766,7 +895,7 @@ void AliTOFClusterFinder::Raw2Digits(AliRawReader *rawReader, TTree* digitsTree) TStopwatch stopwatch; stopwatch.Start(); - const Int_t kDDL = fTOFGeometry->NDDL()*fTOFGeometry->NSectors(); + const Int_t kDDL = AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); if (!digitsTree) { @@ -774,67 +903,77 @@ void AliTOFClusterFinder::Raw2Digits(AliRawReader *rawReader, TTree* digitsTree) return; } - TClonesArray *tofDigits = new TClonesArray("AliTOFdigit",10000); Int_t bufsize = 32000; - digitsTree->Branch("TOF", &tofDigits, bufsize); - - /// fRunLoader->GetEvent(iEvent); - - /// AliDebug(2,Form(" Event number %2i ", iEvent)); + digitsTree->Branch("TOF", &fDigits, bufsize); TClonesArray * clonesRawData; - Int_t dummy = -1; Int_t detectorIndex[5]; Int_t digit[4]; - AliTOFRawStream tofInput(rawReader); + fTOFRawStream.Clear(); + fTOFRawStream.SetRawReader(rawReader); + + if (fDecoderVersion == 1) { + AliInfo("Using New Decoder"); + } + else if (fDecoderVersion == 2) { + AliInfo("Using Enhanced Decoder"); + } + else { + AliInfo("Using Old Decoder"); + } Int_t indexDDL = 0; for (indexDDL = 0; indexDDL < kDDL; indexDDL++) { rawReader->Reset(); - if (fDecoderVersion) { - AliInfo("Using New Decoder \n"); - tofInput.LoadRawDataBuffers(indexDDL,fVerbose); + if (fDecoderVersion == 1) { + fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose); + } + else if (fDecoderVersion == 2) { + fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose); + } + else { + fTOFRawStream.LoadRawData(indexDDL); } - else tofInput.LoadRawData(indexDDL); - clonesRawData = (TClonesArray*)tofInput.GetRawData(); + clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData(); for (Int_t iRawData = 0; iRawDataGetEntriesFast(); iRawData++) { AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData); - if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue; + //if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue; + if (tofRawDatum->GetTOF()==-1) continue; - tofInput.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(), - tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex); + fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(), + tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex); dummy = detectorIndex[3]; detectorIndex[3] = detectorIndex[4]; detectorIndex[4] = dummy; - digit[0] = tofInput.GetTofBin(); - digit[1] = tofInput.GetToTbin(); - digit[2] = tofInput.GetToTbin(); - digit[3] = -1; + digit[0] = fTOFRawStream.GetTofBin(); + digit[1] = fTOFRawStream.GetToTbin(); + digit[2] = fTOFRawStream.GetToTbin(); + digit[3] = 0; Int_t tracknum[3]={-1,-1,-1}; - TClonesArray &aDigits = *tofDigits; - Int_t last=tofDigits->GetEntriesFast(); + TClonesArray &aDigits = *fDigits; + Int_t last=fDigits->GetEntriesFast(); new (aDigits[last]) AliTOFdigit(tracknum, detectorIndex, digit); } // while loop - clonesRawData->Clear(); + clonesRawData->Clear("C"); } // DDL Loop digitsTree->Fill(); - AliDebug(1, Form("Got %d digits: ", tofDigits->GetEntries())); + AliDebug(1, Form("Got %d digits: ", fDigits->GetEntries())); AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs", stopwatch.RealTime(),stopwatch.CpuTime())); @@ -867,7 +1006,7 @@ Int_t AliTOFClusterFinder::InsertCluster(AliTOFcluster *tofCluster) { Int_t AliTOFClusterFinder::FindClusterIndex(Double_t z) const { //-------------------------------------------------------------------- - // This function returns the index of the nearest cluster + // This function returns the index of the nearest cluster in z //-------------------------------------------------------------------- if (fNumberOfTofClusters==0) return 0; if (z <= fTofClusters[0]->GetZ()) return 0; @@ -894,8 +1033,7 @@ void AliTOFClusterFinder::FillRecPoint() Int_t ii, jj; Int_t detectorIndex[5]; - Double_t cylindricalPosition[3]; - Int_t parTOF[5]; + Int_t parTOF[7]; Int_t trackLabels[3]; Int_t digitIndex = -1; Bool_t status=kTRUE; @@ -907,23 +1045,45 @@ void AliTOFClusterFinder::FillRecPoint() digitIndex = fTofClusters[ii]->GetIndex(); for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj); for(jj=0; jj<3; jj++) trackLabels[jj] = fTofClusters[ii]->GetLabel(jj); - cylindricalPosition[0] = fTofClusters[ii]->GetR(); - cylindricalPosition[1] = fTofClusters[ii]->GetPhi(); - cylindricalPosition[2] = fTofClusters[ii]->GetZ(); parTOF[0] = fTofClusters[ii]->GetTDC(); // TDC parTOF[1] = fTofClusters[ii]->GetToT(); // TOT parTOF[2] = fTofClusters[ii]->GetADC(); // ADC=TOT parTOF[3] = fTofClusters[ii]->GetTDCND(); // TDCND parTOF[4] = fTofClusters[ii]->GetTDCRAW();//RAW + parTOF[5] = fTofClusters[ii]->GetDeltaBC();//deltaBC + parTOF[6] = fTofClusters[ii]->GetL0L1Latency();//L0-L1 latency status=fTofClusters[ii]->GetStatus(); - new(lRecPoints[ii]) AliTOFcluster(cylindricalPosition, detectorIndex, parTOF,status,trackLabels,digitIndex); + Double_t posClus[3]; + Double_t covClus[6]; + UShort_t volIdClus=GetClusterVolIndex(detectorIndex); + GetClusterPars(detectorIndex,posClus,covClus); + 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); + + 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", + ii, volIdClus, posClus[0], posClus[1], posClus[2], + fTofClusters[ii]->GetSigmaX2(), + fTofClusters[ii]->GetSigmaXY(), + fTofClusters[ii]->GetSigmaXZ(), + fTofClusters[ii]->GetSigmaY2(), + fTofClusters[ii]->GetSigmaYZ(), + fTofClusters[ii]->GetSigmaZ2(), + trackLabels[0], trackLabels[1], trackLabels[2], + detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[3], detectorIndex[4], + parTOF[0], parTOF[1], parTOF[2], parTOF[3], parTOF[4], + status, digitIndex)); } // loop on clusters } //_________________________________________________________________________ -void AliTOFClusterFinder::CalibrateRecPoint() + +/* + * OLD CALIBRATE REC POINTS FUNCTION + */ + +#if 0 +void AliTOFClusterFinder::CalibrateRecPoint(UInt_t timestamp) { // // Copy the global array of AliTOFcluster, i.e. fTofClusters (sorted @@ -938,45 +1098,164 @@ void AliTOFClusterFinder::CalibrateRecPoint() Double_t tToT; Double_t timeCorr; Int_t tdcCorr; - AliInfo(" Calibrating TOF Clusters: ") + Float_t tdcLatencyWindow; + AliDebug(1," Calibrating TOF Clusters"); + + AliTOFChannelOnlineArray *calDelay = fTOFcalib->GetTOFOnlineDelay(); + AliTOFChannelOnlineStatusArray *calStatus = fTOFcalib->GetTOFOnlineStatus(); + TObjArray *calTOFArrayOffline = fTOFcalib->GetTOFCalArrayOffline(); - AliTOFCal *calTOFArray = fTOFcalib->GetTOFCalArray(); + AliTOFDeltaBCOffset *deltaBCOffsetObj = fTOFcalib->GetDeltaBCOffset(); + Int_t deltaBCOffset = deltaBCOffsetObj->GetDeltaBCOffset(); + AliTOFCTPLatency *ctpLatencyObj = fTOFcalib->GetCTPLatency(); + Float_t ctpLatency = ctpLatencyObj->GetCTPLatency(); + AliTOFRunParams *runParamsObj = fTOFcalib->GetRunParams(); + Float_t t0 = runParamsObj->EvalT0(timestamp); + + TString validity = (TString)fTOFcalib->GetOfflineValidity(); + Int_t calibration = -1; + if (validity.CompareTo("valid")==0) { + //AliInfo(Form(" validity = %s - Using offline calibration parameters",validity.Data())); + calibration = 1; + } else { + //AliInfo(Form(" validity = %s - Using online calibration parameters",validity.Data())); + calibration = 0 ; + } for (ii=0; iiGetIndex(); for(jj=0; jj<5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj); - Int_t index = fTOFcalib->GetIndex(detectorIndex); + Int_t index = AliTOFGeometry::GetIndex(detectorIndex); - AliTOFChannel * calChannel = calTOFArray->GetChannel(index); - - // Get channel status - Bool_t status=calChannel->GetStatus(); - if(status)fTofClusters[ii]->SetStatus(!status); //odd convention, to avoid conflict with calibration objects currently in the db (temporary solution). + UChar_t statusPulser=calStatus->GetPulserStatus(index); + UChar_t statusNoise=calStatus->GetNoiseStatus(index); + UChar_t statusHW=calStatus->GetHWStatus(index); + UChar_t status=calStatus->GetStatus(index); + tdcLatencyWindow = calStatus->GetLatencyWindow(index) * 1.e3; /* ns -> ps */ + + //check the status, also unknown is fine!!!!!!! + + AliDebug(2, Form(" Status for channel %d = %d",index, (Int_t)status)); + if((statusPulser & AliTOFChannelOnlineStatusArray::kTOFPulserBad)==(AliTOFChannelOnlineStatusArray::kTOFPulserBad)||(statusNoise & AliTOFChannelOnlineStatusArray::kTOFNoiseBad)==(AliTOFChannelOnlineStatusArray::kTOFNoiseBad)||(statusHW & AliTOFChannelOnlineStatusArray::kTOFHWBad)==(AliTOFChannelOnlineStatusArray::kTOFHWBad)){ + AliDebug(2, Form(" Bad Status for channel %d",index)); + fTofClusters[ii]->SetStatus(kFALSE); //odd convention, to avoid conflict with calibration objects currently in the db (temporary solution). + } + else { + AliDebug(2, Form(" Good Status for channel %d",index)); + } // Get Rough channel online equalization - Float_t roughDelay=calChannel->GetDelay(); - AliDebug(2,Form(" channel delay = %f", roughDelay)); + Double_t roughDelay=(Double_t)calDelay->GetDelay(index); // in ns + AliDebug(2,Form(" channel delay (ns) = %f", roughDelay)); // Get Refined channel offline calibration parameters - Float_t par[6]; - for (Int_t j = 0; j<6; j++){ - par[j]=calChannel->GetSlewPar(j); + if (calibration ==1){ + AliTOFChannelOffline * calChannelOffline = (AliTOFChannelOffline*)calTOFArrayOffline->At(index); + Double_t par[6]; + for (Int_t j = 0; j<6; j++){ + par[j]=(Double_t)calChannelOffline->GetSlewPar(j); + } AliDebug(2,Form(" Calib Pars = %f, %f, %f, %f, %f, %f ",par[0],par[1],par[2],par[3],par[4],par[5])); - } - AliDebug(2,Form(" The ToT and Time, uncorr (counts) = %i , %i", fTofClusters[ii]->GetToT(),fTofClusters[ii]->GetTDC())); - tToT = (Double_t)(fTofClusters[ii]->GetToT()*AliTOFGeometry::ToTBinWidth()); tToT*=1.E-3; //ToT in ns - AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",fTofClusters[ii]->GetTDC()*AliTOFGeometry::TdcBinWidth()*1.E-3,tToT)); - 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+roughDelay; // the time correction + AliDebug(2,Form(" The ToT and Time, uncorr (counts) = %d , %d", fTofClusters[ii]->GetToT(),fTofClusters[ii]->GetTDC())); + tToT = (Double_t)(fTofClusters[ii]->GetToT()*AliTOFGeometry::ToTBinWidth()); + tToT*=1.E-3; //ToT in ns + + /* check TOT limits and set new TOT in case */ + if (tToT < AliTOFGeometry::SlewTOTMin()) tToT = AliTOFGeometry::SlewTOTMin(); + if (tToT > AliTOFGeometry::SlewTOTMax()) tToT = AliTOFGeometry::SlewTOTMax(); + + AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",fTofClusters[ii]->GetTDC()*AliTOFGeometry::TdcBinWidth()*1.E-3,tToT)); + 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) + } + else { + timeCorr = roughDelay; // correction in ns + } + AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",fTofClusters[ii]->GetTDC()*AliTOFGeometry::TdcBinWidth()*1.E-3,fTofClusters[ii]->GetToT()*AliTOFGeometry::ToTBinWidth())); AliDebug(2,Form(" The time correction (ns) = %f", timeCorr)); timeCorr=(Double_t)(fTofClusters[ii]->GetTDC())*AliTOFGeometry::TdcBinWidth()*1.E-3-timeCorr;//redefine the time timeCorr*=1.E3; AliDebug(2,Form(" The channel time, corr (ps)= %e",timeCorr )); + + /* here timeCorr should be already corrected for calibration. + * we now go into further corrections keeping in mind that timeCorr + * is in ps. + * + * the following corrections are performed in this way: + * + * time = timeRaw - deltaBC + L0L1Latency + CTPLatency - TDCLatencyWindow - T0 + * + */ + + AliDebug(2, Form("applying further corrections (DeltaBC): DeltaBC=%d (BC bins), DeltaBCoffset=%d (BC bins)", fTofClusters[ii]->GetDeltaBC(), deltaBCOffset)); + AliDebug(2, Form("applying further corrections (L0L1Latency): L0L1Latency=%d (BC bins)", fTofClusters[ii]->GetL0L1Latency())); + AliDebug(2, Form("applying further corrections (CTPLatency): CTPLatency=%f (ps)", ctpLatency)); + AliDebug(2, Form("applying further corrections (TDCLatencyWindow): TDCLatencyWindow=%f (ps)", tdcLatencyWindow)); + AliDebug(2, Form("applying further corrections (T0): T0=%f (ps)", t0)); + + /* deltaBC correction (inhibited for the time being) */ + // timeCorr -= (fTofClusters[ii]->GetDeltaBC() - deltaBCOffset) * AliTOFGeometry::BunchCrossingBinWidth(); + /* L0L1-latency correction */ + timeCorr += fTofClusters[ii]->GetL0L1Latency() * AliTOFGeometry::BunchCrossingBinWidth(); + /* CTP-latency correction (from OCDB) */ + timeCorr += ctpLatency; + /* TDC latency-window correction (from OCDB) */ + timeCorr -= tdcLatencyWindow; + /* T0 correction (from OCDB) */ + timeCorr -= t0; + + /* + * end of furhter corrections + */ + tdcCorr=(Int_t)(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts) fTofClusters[ii]->SetTDC(tdcCorr); - AliDebug(2,Form(" The channel time, corr (counts) = %i",fTofClusters[ii]->GetTDC())); + } // loop on clusters + +} +#endif + +//_________________________________________________________________________ + +void AliTOFClusterFinder::CalibrateRecPoint(UInt_t timestamp) +{ + // + // Copy the global array of AliTOFcluster, i.e. fTofClusters (sorted + // in Z) in the global TClonesArray of AliTOFcluster, + // i.e. fRecPoints. + // + + Int_t detectorIndex[5]; + Double_t time, tot, corr; + Int_t deltaBC, l0l1, tdcBin; + for (Int_t ii = 0; ii < fNumberOfTofClusters; ii++) { + for(Int_t jj = 0; jj < 5; jj++) detectorIndex[jj] = fTofClusters[ii]->GetDetInd(jj); + + Int_t index = AliTOFGeometry::GetIndex(detectorIndex); + + /* check channel enabled */ + if (!fTOFcalib->IsChannelEnabled(index)) fTofClusters[ii]->SetStatus(kFALSE); + + /* get cluster info */ + time = fTofClusters[ii]->GetTDC() * AliTOFGeometry::TdcBinWidth(); /* ps */ + tot = fTofClusters[ii]->GetToT() * AliTOFGeometry::ToTBinWidth() * 1.e-3; /* ns */ + deltaBC = fTofClusters[ii]->GetDeltaBC(); + l0l1 = fTofClusters[ii]->GetL0L1Latency(); + + /* get correction */ + corr = fTOFcalib->GetTimeCorrection(index, tot, deltaBC, l0l1, timestamp); /* ps */ + 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)); + + /* apply time correction */ + time -= corr; + + /* convert in TDC bins and set cluster */ + //tdcBin = (Int_t)(time / AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts) + tdcBin = TMath::Nint(time / AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts) + fTofClusters[ii]->SetTDC(tdcBin); } // loop on clusters } + //______________________________________________________________________________ void AliTOFClusterFinder::ResetRecpoint() @@ -1035,4 +1314,126 @@ void AliTOFClusterFinder::UnLoadClusters() fTOFLoader->UnloadRecPoints(); } -//______________________________________________________________________________ +//------------------------------------------------------------------------- +UShort_t AliTOFClusterFinder::GetClusterVolIndex(const Int_t * const ind) const { + + //First of all get the volume ID to retrieve the l2t transformation... + // + // Detector numbering scheme + Int_t nSector = 18; + Int_t nPlate = 5; + Int_t nStripA = 15; + Int_t nStripB = 19; + Int_t nStripC = 19; + + Int_t isector =ind[0]; + if (isector >= nSector) + AliError(Form("Wrong sector number in TOF (%d) !",isector)); + Int_t iplate = ind[1]; + if (iplate >= nPlate) + AliError(Form("Wrong plate number in TOF (%d) !",iplate)); + Int_t istrip = ind[2]; + + Int_t stripOffset = 0; + switch (iplate) { + case 0: + stripOffset = 0; + break; + case 1: + stripOffset = nStripC; + break; + case 2: + stripOffset = nStripC+nStripB; + break; + case 3: + stripOffset = nStripC+nStripB+nStripA; + break; + case 4: + stripOffset = nStripC+nStripB+nStripA+nStripB; + break; + default: + AliError(Form("Wrong plate number in TOF (%d) !",iplate)); + break; + }; + + Int_t index= (2*(nStripC+nStripB)+nStripA)*isector + + stripOffset + + istrip; + + UShort_t volIndex = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF,index); + return volIndex; +} +// +//------------------------------------------------------------------------- +void AliTOFClusterFinder::GetClusterPars(Int_t *ind, Double_t* pos,Double_t* cov) const { + + //First of all get the volume ID to retrieve the l2t transformation... + // + UShort_t volIndex = GetClusterVolIndex(ind); + // + // + //we now go in the system of the strip: determine the local coordinates + // + // + // 47---------------------------------------------------0 ^ z + // | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 | + // ----------------------------------------------------- | y going outwards + // | | | | | | | | | | | | | | | | | | | | | | | | | | | 0 | par[0]=0; + + // ----------------------------------------------------- | + // x <----------------------------------------------------- + + /* + Float_t localX = (ind[4]-23.5)*AliTOFGeometry::XPad(); + Float_t localY = 0; + Float_t localZ = (ind[3]- 0.5)*AliTOFGeometry::ZPad(); + */ + Float_t localX = (ind[4]-AliTOFGeometry::NpadX()/2)*AliTOFGeometry::XPad()+AliTOFGeometry::XPad()/2.; + Float_t localY = 0; + Float_t localZ = (ind[3]-AliTOFGeometry::NpadZ()/2)*AliTOFGeometry::ZPad()+AliTOFGeometry::ZPad()/2.; + //move to the tracking ref system + + Double_t lpos[3]; + lpos[0] = localX; + lpos[1] = localY; + lpos[2] = localZ; + + const TGeoHMatrix *l2t= AliGeomManager::GetTracking2LocalMatrix(volIndex); + // Get The position in the track ref system + Double_t tpos[3]; + l2t->MasterToLocal(lpos,tpos); + pos[0] = tpos[0]; + pos[1] = tpos[1]; + pos[2] = tpos[2]; + + //Get The cluster covariance in the track ref system + Double_t lcov[9]; + + //cluster covariance in the local system: + // sx2 0 0 + // 0 0 0 + // 0 0 sz2 + + lcov[0] = AliTOFGeometry::XPad()*AliTOFGeometry::XPad()/12.; + lcov[1] = 0; + lcov[2] = 0; + lcov[3] = 0; + lcov[4] = 0; + lcov[5] = 0; + lcov[6] = 0; + lcov[7] = 0; + lcov[8] = AliTOFGeometry::ZPad()*AliTOFGeometry::ZPad()/12.; + + //cluster covariance in the tracking system: + TGeoHMatrix m; + m.SetRotation(lcov); + m.Multiply(l2t); + m.MultiplyLeft(&l2t->Inverse()); + Double_t *tcov = m.GetRotationMatrix(); + cov[0] = tcov[0]; cov[1] = tcov[1]; cov[2] = tcov[2]; + cov[3] = tcov[4]; cov[4] = tcov[5]; + cov[5] = tcov[8]; + + return; + +}