X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TOF%2FAliTOFClusterFinder.cxx;h=d6bcc852ca005c0b7edc416bfd26d10dd152376f;hb=07bdd4b04b15b4d26a1e58f881652290150b9e62;hp=ae976e7dd2491eb16895af0bb64bd716bfb74c3e;hpb=87e6e0161921613750146bc2c0b205fbf2bba484;p=u%2Fmrichter%2FAliRoot.git diff --git a/TOF/AliTOFClusterFinder.cxx b/TOF/AliTOFClusterFinder.cxx index ae976e7dd24..d6bcc852ca0 100644 --- a/TOF/AliTOFClusterFinder.cxx +++ b/TOF/AliTOFClusterFinder.cxx @@ -129,17 +129,21 @@ Revision 0.01 2005/07/25 A. De Caro #include "AliTOFdigit.h" #include "AliTOFGeometry.h" #include "AliTOFrawData.h" -//#include "AliTOFRawStream.h" #include "AliTOFDeltaBCOffset.h" #include "AliTOFCTPLatency.h" -#include "AliTOFT0Fill.h" +#include "AliTOFRunParams.h" //extern TFile *gFile; +using std::cout; +using std::endl; +using std::ofstream; +using std::ios; ClassImp(AliTOFClusterFinder) AliTOFClusterFinder::AliTOFClusterFinder(AliTOFcalib *calib): + TTask("AliTOFClusterFinder",""), fRunLoader(0), fTOFLoader(0), fTreeD(0), @@ -147,6 +151,7 @@ AliTOFClusterFinder::AliTOFClusterFinder(AliTOFcalib *calib): fDigits(new TClonesArray("AliTOFdigit", 4000)), fRecPoints(new TClonesArray("AliTOFcluster", 4000)), fNumberOfTofClusters(0), + fNumberOfTofTrgPads(0), fVerbose(0), fDecoderVersion(0), fTOFcalib(calib), @@ -156,6 +161,8 @@ AliTOFClusterFinder::AliTOFClusterFinder(AliTOFcalib *calib): // Constructor // + for (Int_t ii=0; iiGetOfflineValidity(); if (validity.CompareTo("valid")==0) { AliInfo(Form(" validity = %s - Using offline calibration parameters",validity.Data())); @@ -168,6 +175,7 @@ AliTOFClusterFinder::AliTOFClusterFinder(AliTOFcalib *calib): //______________________________________________________________________________ AliTOFClusterFinder::AliTOFClusterFinder(AliRunLoader* runLoader, AliTOFcalib *calib): + TTask("AliTOFClusterFinder",""), fRunLoader(runLoader), fTOFLoader(runLoader->GetLoader("TOFLoader")), fTreeD(0), @@ -175,6 +183,7 @@ AliTOFClusterFinder::AliTOFClusterFinder(AliRunLoader* runLoader, AliTOFcalib *c fDigits(new TClonesArray("AliTOFdigit", 4000)), fRecPoints(new TClonesArray("AliTOFcluster", 4000)), fNumberOfTofClusters(0), + fNumberOfTofTrgPads(0), fVerbose(0), fDecoderVersion(0), fTOFcalib(calib), @@ -184,6 +193,8 @@ AliTOFClusterFinder::AliTOFClusterFinder(AliRunLoader* runLoader, AliTOFcalib *c // Constructor // + for (Int_t ii=0; iiGetOfflineValidity(); if (validity.CompareTo("valid")==0) { AliInfo(Form(" validity = %s - Using offline calibration parameters",validity.Data())); @@ -194,8 +205,8 @@ AliTOFClusterFinder::AliTOFClusterFinder(AliRunLoader* runLoader, AliTOFcalib *c } //------------------------------------------------------------------------ -AliTOFClusterFinder::AliTOFClusterFinder(const AliTOFClusterFinder &source) - :TObject(source), +AliTOFClusterFinder::AliTOFClusterFinder(const AliTOFClusterFinder &source) : + TTask(source), fRunLoader(0), fTOFLoader(0), fTreeD(0), @@ -203,12 +214,16 @@ AliTOFClusterFinder::AliTOFClusterFinder(const AliTOFClusterFinder &source) fDigits(source.fDigits), fRecPoints(source.fRecPoints), fNumberOfTofClusters(0), + fNumberOfTofTrgPads(0), fVerbose(0), fDecoderVersion(source.fDecoderVersion), fTOFcalib(source.fTOFcalib), fTOFRawStream(source.fTOFRawStream) { // copy constructor + + for (Int_t ii=0; iiDelete(); + delete fTofClusters[ii]; + } + fNumberOfTofClusters=0; + } + + fNumberOfTofTrgPads=0; + } //______________________________________________________________________________ @@ -268,21 +296,14 @@ void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent) 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 staticdigits("AliTOFdigit",10000); - staticdigits.Clear(); - TClonesArray *digits =&staticdigits; - branch->SetAddress(&digits); + fDigits->Clear(); + fTreeD->GetBranch("TOF")->SetAutoDelete(kFALSE); + fTreeD->SetBranchAddress("TOF",&fDigits); ResetRecpoint(); @@ -297,15 +318,15 @@ 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; - Int_t dig[5]; //cluster detector indeces - Int_t parTOF[7]; //The TOF signal parameters + 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(); @@ -347,7 +368,7 @@ void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent) FillRecPoint(); fTreeR->Fill(); - ResetRecpoint(); +// ResetRecpoint(); fTOFLoader = fRunLoader->GetLoader("TOFLoader"); fTOFLoader->WriteRecPoints("OVERWRITE"); @@ -371,40 +392,29 @@ void AliTOFClusterFinder::Digits2RecPoints(TTree* digitsTree, TTree* clusterTree Int_t inholes = 0; - /// fRunLoader->GetEvent(iEvent); - - if (digitsTree == 0x0) - { - AliFatal("AliTOFClusterFinder: Can not get TreeD"); - } - - 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 staticdigits("AliTOFdigit",10000); - staticdigits.Clear(); - TClonesArray *digits = & staticdigits; - 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; - Int_t dig[5]; //cluster detector indeces - Int_t parTOF[7]; //The TOF signal parameters + 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(); @@ -447,7 +457,7 @@ void AliTOFClusterFinder::Digits2RecPoints(TTree* digitsTree, TTree* clusterTree FillRecPoint(); clusterTree->Fill(); - ResetRecpoint(); +// ResetRecpoint(); AliDebug(1,Form("Execution time to read TOF digits and to write TOF clusters : R:%.4fs C:%.4fs", stopwatch.RealTime(),stopwatch.CpuTime())); @@ -476,30 +486,41 @@ void AliTOFClusterFinder::Digits2RecPoints(AliRawReader *rawReader, clustersTree->Branch("TOF", &fRecPoints, bufsize); TClonesArray * clonesRawData; - Int_t dummy = -1; - Int_t detectorIndex[5]; - Int_t parTOF[7]; + Int_t detectorIndex[5]={-1,-1,-1,-1,-1}; + Int_t parTOF[7]={-1,-1,-1,-1,-1,-1,-1}; ofstream ftxt; if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app); - //AliTOFRawStream tofInput(rawReader); fTOFRawStream.Clear(); fTOFRawStream.SetRawReader(rawReader); - if (fDecoderVersion) + 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) + if (fDecoderVersion == 1) { fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose); - else fTOFRawStream.LoadRawData(indexDDL); - + } + else if (fDecoderVersion == 2) { + fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose); + } + else { + fTOFRawStream.LoadRawData(indexDDL); + } + clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData(); for (Int_t iRawData = 0; iRawDataGetEntriesFast(); iRawData++) { @@ -520,6 +541,11 @@ void AliTOFClusterFinder::Digits2RecPoints(AliRawReader *rawReader, ftxt << " " << tofRawDatum->GetTDCchannel(); } + if ( tofRawDatum->GetTRM()==3 && + (tofRawDatum->GetTDC()> 11 && tofRawDatum->GetTDC()< 15) ) FillTOFtriggerMap(indexDDL, tofRawDatum); + + for (Int_t aa=0; aa<5; aa++) detectorIndex[aa] = -1; + fTOFRawStream.EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(), tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex); dummy = detectorIndex[3]; @@ -551,7 +577,7 @@ void AliTOFClusterFinder::Digits2RecPoints(AliRawReader *rawReader, 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 parTOF[5] = tofRawDatum->GetDeltaBC(); // deltaBC parTOF[6] = tofRawDatum->GetL0L1Latency(); // L0-L1 latency @@ -571,12 +597,12 @@ void AliTOFClusterFinder::Digits2RecPoints(AliRawReader *rawReader, if (parTOF[0]<10) ftxt << " " << parTOF[0] << endl; else if (parTOF[0]>=10 && parTOF[0]<100) ftxt << " " << parTOF[0] << endl; else if (parTOF[0]>=100 && parTOF[0]<1000) ftxt << " " << parTOF[0] << endl; - else ftxt << " " << parTOF[3] << endl; + else ftxt << " " << parTOF[0] << endl; } } // closed loop on TOF raw data per current DDL file - clonesRawData->Clear(); + clonesRawData->Clear("C"); } // closed loop on DDL index @@ -584,12 +610,12 @@ void AliTOFClusterFinder::Digits2RecPoints(AliRawReader *rawReader, AliDebug(1,Form("Number of found clusters: %d", fNumberOfTofClusters)); - CalibrateRecPoint(); + CalibrateRecPoint(rawReader->GetTimestamp()); FillRecPoint(); clustersTree->Fill(); - ResetRecpoint(); +// ResetRecpoint(); AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.4fs C:%.4fs", stopwatch.RealTime(),stopwatch.CpuTime())); @@ -634,20 +660,32 @@ void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader ofstream ftxt; if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app); - //AliTOFRawStream tofInput(rawReader); fTOFRawStream.Clear(); fTOFRawStream.SetRawReader(rawReader); - if (fDecoderVersion) + 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) + if (fDecoderVersion == 1) { fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose); - else fTOFRawStream.LoadRawData(indexDDL); + } + else if (fDecoderVersion == 2) { + fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose); + } + else { + fTOFRawStream.LoadRawData(indexDDL); + } clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData(); @@ -700,7 +738,7 @@ void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader 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 parTOF[5] = tofRawDatum->GetDeltaBC(); // deltaBC parTOF[6] = tofRawDatum->GetL0L1Latency(); // L0-L1 latency @@ -720,12 +758,12 @@ void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader if (parTOF[0]<10) ftxt << " " << parTOF[0] << endl; else if (parTOF[0]>=10 && parTOF[0]<100) ftxt << " " << parTOF[0] << endl; else if (parTOF[0]>=100 && parTOF[0]<1000) ftxt << " " << parTOF[0] << endl; - else ftxt << " " << parTOF[3] << endl; + else ftxt << " " << parTOF[0] << endl; } } // closed loop on TOF raw data per current DDL file - clonesRawData->Clear(); + clonesRawData->Clear("C"); } // closed loop on DDL index @@ -733,11 +771,11 @@ void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent, AliRawReader *rawReader AliDebug(1,Form("Number of found clusters: %d for event: %d", fNumberOfTofClusters, iEvent)); - CalibrateRecPoint(); + CalibrateRecPoint(rawReader->GetTimestamp()); FillRecPoint(); fTreeR->Fill(); - ResetRecpoint(); +// ResetRecpoint(); fTOFLoader = fRunLoader->GetLoader("TOFLoader"); fTOFLoader->WriteRecPoints("OVERWRITE"); @@ -772,10 +810,14 @@ 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); @@ -788,20 +830,32 @@ 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) + 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) + if (fDecoderVersion == 1) { fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose); - else fTOFRawStream.LoadRawData(indexDDL); + } + else if (fDecoderVersion == 2) { + fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose); + } + else { + fTOFRawStream.LoadRawData(indexDDL); + } clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData(); @@ -821,17 +875,17 @@ void AliTOFClusterFinder::Raw2Digits(Int_t iEvent, AliRawReader *rawReader) digit[0] = fTOFRawStream.GetTofBin(); digit[1] = fTOFRawStream.GetToTbin(); digit[2] = fTOFRawStream.GetToTbin(); - digit[3] = -1; + 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 @@ -840,8 +894,6 @@ void AliTOFClusterFinder::Raw2Digits(Int_t iEvent, AliRawReader *rawReader) fTOFLoader = fRunLoader->GetLoader("TOFLoader"); fTOFLoader->WriteDigits("OVERWRITE"); - delete tofDigits; - AliDebug(1, Form("Execution time to read TOF raw data and to write TOF clusters : R:%.2fs C:%.2fs", stopwatch.RealTime(),stopwatch.CpuTime())); @@ -867,31 +919,41 @@ void AliTOFClusterFinder::Raw2Digits(AliRawReader *rawReader, TTree* digitsTree) return; } - TClonesArray *tofDigits = new TClonesArray("AliTOFdigit",10000); Int_t bufsize = 32000; - digitsTree->Branch("TOF", &tofDigits, bufsize); + 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) + 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) + if (fDecoderVersion == 1) { fTOFRawStream.LoadRawDataBuffers(indexDDL,fVerbose); - else fTOFRawStream.LoadRawData(indexDDL); + } + else if (fDecoderVersion == 2) { + fTOFRawStream.LoadRawDataBuffersV2(indexDDL,fVerbose); + } + else { + fTOFRawStream.LoadRawData(indexDDL); + } clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData(); @@ -911,24 +973,22 @@ void AliTOFClusterFinder::Raw2Digits(AliRawReader *rawReader, TTree* digitsTree) digit[0] = fTOFRawStream.GetTofBin(); digit[1] = fTOFRawStream.GetToTbin(); digit[2] = fTOFRawStream.GetToTbin(); - digit[3] = -1; + 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(); - delete tofDigits; - 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())); @@ -1033,7 +1093,13 @@ void AliTOFClusterFinder::FillRecPoint() } //_________________________________________________________________________ -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 @@ -1059,8 +1125,8 @@ void AliTOFClusterFinder::CalibrateRecPoint() Int_t deltaBCOffset = deltaBCOffsetObj->GetDeltaBCOffset(); AliTOFCTPLatency *ctpLatencyObj = fTOFcalib->GetCTPLatency(); Float_t ctpLatency = ctpLatencyObj->GetCTPLatency(); - AliTOFT0Fill *t0FillObj = fTOFcalib->GetT0Fill(); - Float_t t0Fill = t0FillObj->GetT0Fill(); + AliTOFRunParams *runParamsObj = fTOFcalib->GetRunParams(); + Float_t t0 = runParamsObj->EvalT0(timestamp); TString validity = (TString)fTOFcalib->GetOfflineValidity(); Int_t calibration = -1; @@ -1106,7 +1172,7 @@ void AliTOFClusterFinder::CalibrateRecPoint() } 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) = %d , %d", fTofClusters[ii]->GetToT(),fTofClusters[ii]->GetTDC())); - tToT = (Double_t)(fTofClusters[ii]->GetToT()*AliTOFGeometry::ToTBinWidth()); + tToT = (Double_t)(fTofClusters[ii]->GetToT()*AliTOFGeometry::ToTBinWidth()); tToT*=1.E-3; //ToT in ns /* check TOT limits and set new TOT in case */ @@ -1131,7 +1197,7 @@ void AliTOFClusterFinder::CalibrateRecPoint() * * the following corrections are performed in this way: * - * time = timeRaw - deltaBC + L0L1Latency + CTPLatency - TDCLatencyWindow - T0Fill + * time = timeRaw - deltaBC + L0L1Latency + CTPLatency - TDCLatencyWindow - T0 * */ @@ -1139,18 +1205,18 @@ void AliTOFClusterFinder::CalibrateRecPoint() 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 (T0Fill): T0Fill=%f (ps)", t0Fill)); + AliDebug(2, Form("applying further corrections (T0): T0=%f (ps)", t0)); - /* deltaBC correction */ - timeCorr -= (fTofClusters[ii]->GetDeltaBC() - deltaBCOffset) * AliTOFGeometry::BunchCrossingBinWidth(); + /* 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; - /* T0Fill correction (from OCDB) */ - timeCorr -= t0Fill; + /* T0 correction (from OCDB) */ + timeCorr -= t0; /* * end of furhter corrections @@ -1158,9 +1224,67 @@ void AliTOFClusterFinder::CalibrateRecPoint() tdcCorr=(Int_t)(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts) fTofClusters[ii]->SetTDC(tdcCorr); + + } // 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); + + // noferini + Float_t pos[3]; + AliTOFGeometry::GetPosPar(detectorIndex, pos); + Float_t length = 0.; + for (Int_t ic = 0; ic < 3; ic++) length += pos[ic] * pos[ic]; + length = TMath::Sqrt(length); + Float_t timealligned = tdcBin*24.4 - length * 0.0333564095198152043; // subtract the minimal time in + + if(timealligned > -1000 && timealligned < 24000 && fTOFcalib->IsChannelEnabled(index)){ + fNumberOfTofTrgPads++; + } + } // loop on clusters } + //______________________________________________________________________________ void AliTOFClusterFinder::ResetRecpoint() @@ -1170,6 +1294,7 @@ void AliTOFClusterFinder::ResetRecpoint() // fNumberOfTofClusters = 0; + fNumberOfTofTrgPads = 0; if (fRecPoints) fRecPoints->Clear(); } @@ -1342,3 +1467,58 @@ void AliTOFClusterFinder::GetClusterPars(Int_t *ind, Double_t* pos,Double_t* cov return; } +//------------------------------------------------------------------------- +void AliTOFClusterFinder::FillTOFtriggerMap(Int_t iDDL, AliTOFrawData *tofRawDatum) +{ + + /* get cluster info */ + //Int_t trm = tofRawDatum->GetTRM(); + // Int_t tdc = tofRawDatum->GetTDC(); +// Int_t tdc_ch = tofRawDatum->GetTDCchannel(); + Int_t chain = tofRawDatum->GetTRMchain(); + Int_t l0l1 = tofRawDatum->GetL0L1Latency(); + Double_t corr = l0l1 * AliTOFGeometry::BunchCrossingBinWidth(); + AliTOFCTPLatency *ctpLatencyObj = fTOFcalib->GetCTPLatency(); + Float_t ctpLatency = ctpLatencyObj->GetCTPLatency(); + corr += ctpLatency; + + Double_t timeTOF=tofRawDatum->GetTOF()*AliTOFGeometry::TdcBinWidth(); + timeTOF-=corr; + //Int_t timeRaw_bc = Int_t(timeTOF/1000/24.4); // per ora non usata + + //Int_t timeRaw_bc = Int_t((tofRawDatum->GetTOF()*AliTOFGeometry::TdcBinWidth())/1000/24.4); // per ora non usata + + /* + const Int_t crate_CTTM[72] = { 0, 1, 37, 36, 2, 3, 39, 38, 4, 5, + 41, 40, 6, 7, 43, 42, 8, 9, 45, 44, + 10, 11, 47, 46, 12, 13, 49, 48, 14, 15, + 51, 50, 16, 17, 53, 52, 18, 19, 55, 54, + 20, 21, 57, 56, 22, 23, 59, 58, 24, 25, + 61, 60, 26, 27, 63, 62, 28, 29, 65, 64, + 30, 31, 67, 66, 32, 33, 69, 68, 34, 35, + 71, 70}; + */ + + Int_t cttmCrate=-1; +// Int_t cttmBit = tdc_ch + (tdc-12)*AliTOFGeometry::NCh(); + switch(iDDL%AliTOFGeometry::NDDL()){ + case 1: + cttmCrate=1; + break; + case 3: + cttmCrate=36; + break; + default: + break; + } + cttmCrate+=2*(Int_t)(iDDL/AliTOFGeometry::NDDL()); + if(chain==0) { + if (iDDL<36) cttmCrate--; + else cttmCrate++; + } + + + + +} +