#include "AliTOFrawData.h"
//#include "AliTOFRawStream.h"
+#include "AliTOFDeltaBCOffset.h"
+#include "AliTOFCTPLatency.h"
+#include "AliTOFT0Fill.h"
+
//extern TFile *gFile;
ClassImp(AliTOFClusterFinder)
Int_t ii;
Int_t dig[5]; //cluster detector indeces
- Int_t parTOF[5]; //The TOF signal parameters
+ Int_t parTOF[7]; //The TOF signal parameters
Bool_t status=kTRUE; // assume all sim channels ok in the beginning...
for (ii=0; ii<nDigits; ii++) {
AliTOFdigit *d = (AliTOFdigit*)digits->UncheckedAt(ii);
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
+ parTOF[5] = 0; // deltaBC
+ parTOF[6] = 0; // L0-L1 latency
Double_t posClus[3];
Double_t covClus[6];
UShort_t volIdClus=GetClusterVolIndex(dig);
Int_t ii;
Int_t dig[5]; //cluster detector indeces
- Int_t parTOF[5]; //The TOF signal parameters
+ Int_t parTOF[7]; //The TOF signal parameters
Bool_t status=kTRUE; // assume all sim channels ok in the beginning...
for (ii=0; ii<nDigits; ii++) {
AliTOFdigit *d = (AliTOFdigit*)digits->UncheckedAt(ii);
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
+ parTOF[5] = 0; // deltaBC
+ parTOF[6] = 0; // L0-L1 latency
Double_t posClus[3];
Double_t covClus[6];
Int_t dummy = -1;
Int_t detectorIndex[5];
- Int_t parTOF[5];
+ Int_t parTOF[7];
ofstream ftxt;
if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
parTOF[2] = tofRawDatum->GetTOT(); //ADC==TOF
parTOF[3] = -1;//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
Double_t posClus[3];
Double_t covClus[6];
UShort_t volIdClus=GetClusterVolIndex(detectorIndex);
Int_t dummy = -1;
Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
- Int_t parTOF[5];
+ Int_t parTOF[7];
ofstream ftxt;
if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
parTOF[2] = tofRawDatum->GetTOT(); // raw data have ADC=TOT
parTOF[3] = -1; //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
Double_t posClus[3];
Double_t covClus[6];
UShort_t volIdClus=GetClusterVolIndex(detectorIndex);
Int_t ii, jj;
Int_t detectorIndex[5];
- Int_t parTOF[5];
+ Int_t parTOF[7];
Int_t trackLabels[3];
Int_t digitIndex = -1;
Bool_t status=kTRUE;
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();
Double_t posClus[3];
Double_t covClus[6];
Double_t tToT;
Double_t timeCorr;
Int_t tdcCorr;
+ Float_t tdcLatencyWindow;
AliDebug(1," Calibrating TOF Clusters");
AliTOFChannelOnlineArray *calDelay = fTOFcalib->GetTOFOnlineDelay();
AliTOFChannelOnlineStatusArray *calStatus = fTOFcalib->GetTOFOnlineStatus();
TObjArray *calTOFArrayOffline = fTOFcalib->GetTOFCalArrayOffline();
+
+ AliTOFDeltaBCOffset *deltaBCOffsetObj = fTOFcalib->GetDeltaBCOffset();
+ Int_t deltaBCOffset = deltaBCOffsetObj->GetDeltaBCOffset();
+ AliTOFCTPLatency *ctpLatencyObj = fTOFcalib->GetCTPLatency();
+ Float_t ctpLatency = ctpLatencyObj->GetCTPLatency();
+ AliTOFT0Fill *t0FillObj = fTOFcalib->GetT0Fill();
+ Float_t t0Fill = t0FillObj->GetT0Fill();
TString validity = (TString)fTOFcalib->GetOfflineValidity();
Int_t calibration = -1;
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));
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 - T0Fill
+ *
+ */
+
+ 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 (T0Fill): T0Fill=%f (ps)", t0Fill));
+
+ /* deltaBC correction */
+ 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;
+
+ /*
+ * end of furhter corrections
+ */
+
tdcCorr=(Int_t)(timeCorr/AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
fTofClusters[ii]->SetTDC(tdcCorr);
} // loop on clusters