#include "AliLog.h"
#include "AliTPCExB.h"
#include "TGeoMatrix.h"
+#include "AliTPCRecoParam.h"
+#include "AliTPCCalibVdrift.h"
#include "AliTPCTransform.h"
+#include <AliCTPTimeParams.h>
ClassImp(AliTPCTransform)
- AliTPCTransform::AliTPCTransform():
- AliTransform()
+AliTPCTransform::AliTPCTransform():
+ AliTransform(),
+ fCurrentRecoParam(0), //! current reconstruction parameters
+ fCurrentRun(0), //! current run
+ fCurrentTimeStamp(0) //! current time stamp
+{
+ //
+ // Speed it up a bit!
+ //
+ for (Int_t i=0;i<18;++i) {
+ Double_t alpha=TMath::DegToRad()*(10.+20.*(i%18));
+ fSins[i]=TMath::Sin(alpha);
+ fCoss[i]=TMath::Cos(alpha);
+ }
+ fPrimVtx[0]=0;
+ fPrimVtx[1]=0;
+ fPrimVtx[2]=0;
+}
+AliTPCTransform::AliTPCTransform(const AliTPCTransform& transform):
+ AliTransform(transform),
+ fCurrentRecoParam(transform.fCurrentRecoParam), //! current reconstruction parameters
+ fCurrentRun(transform.fCurrentRun), //! current run
+ fCurrentTimeStamp(transform.fCurrentTimeStamp) //! current time stamp
{
//
// Speed it up a bit!
// line approximation
//
-
Int_t row=TMath::Nint(x[0]);
Int_t pad=TMath::Nint(x[1]);
Int_t sector=i[0];
- AliTPCcalibDB* calib=AliTPCcalibDB::Instance();
+ AliTPCcalibDB* calib=AliTPCcalibDB::Instance();
//
AliTPCCalPad * time0TPC = calib->GetPadTime0();
AliTPCParam * param = calib->GetParameters();
//
// ExB correction
//
- calib->GetExB()->Correct(x,xx);
+ if(fCurrentRecoParam&&fCurrentRecoParam->GetUseExBCorrection()) {
+
+ calib->GetExB()->Correct(x,xx);
+
+ } else {
+
+ xx[0] = x[0];
+ xx[1] = x[1];
+ xx[2] = x[2];
+ }
+
//
// Time of flight correction
//
- const Int_t kNIS=param->GetNInnerSector(), kNOS=param->GetNOuterSector();
- Float_t sign=1;
- if (sector < kNIS) {
- sign = (sector < kNIS/2) ? 1 : -1;
- } else {
- sign = ((sector-kNIS) < kNOS/2) ? 1 : -1;
+ if (fCurrentRecoParam&&fCurrentRecoParam->GetUseTOFCorrection()){
+ const Int_t kNIS=param->GetNInnerSector(), kNOS=param->GetNOuterSector();
+ Float_t sign=1;
+ if (sector < kNIS) {
+ sign = (sector < kNIS/2) ? 1 : -1;
+ } else {
+ sign = ((sector-kNIS) < kNOS/2) ? 1 : -1;
+ }
+ Float_t deltaDr =0;
+ Float_t dist=0;
+ dist+=(fPrimVtx[0]-x[0])*(fPrimVtx[0]-x[0]);
+ dist+=(fPrimVtx[1]-x[1])*(fPrimVtx[1]-x[1]);
+ dist+=(fPrimVtx[2]-x[2])*(fPrimVtx[2]-x[2]);
+ dist = TMath::Sqrt(dist);
+ // drift length correction because of TOF
+ // the drift velocity is in cm/s therefore multiplication by 0.01
+ deltaDr = (dist*(0.01*param->GetDriftV()))/TMath::C();
+ xx[2]+=sign*deltaDr;
}
- Float_t deltaDr =0;
- Float_t dist=0;
- dist+=(fPrimVtx[0]-x[0])*(fPrimVtx[0]-x[0]);
- dist+=(fPrimVtx[1]-x[1])*(fPrimVtx[1]-x[1]);
- dist+=(fPrimVtx[2]-x[2])*(fPrimVtx[2]-x[2]);
- dist = TMath::Sqrt(dist);
- // drift length correction because of TOF
- // the drift velocity is in cm/s therefore multiplication by 0.01
- deltaDr = (dist*(0.01*param->GetDriftV()))/TMath::C();
- xx[2]+=sign*deltaDr;
+ //
+ //
+ //
+
//
Global2RotatedGlobal(sector,xx);
//
//
//
//
+ const Int_t kMax =60; // cache for 60 seconds
+ static Int_t lastStamp=-1; //cached values
+ static Double_t lastCorr = 1;
+ //
AliTPCcalibDB* calib=AliTPCcalibDB::Instance();
AliTPCParam * param = calib->GetParameters();
+ AliTPCCalibVdrift *driftCalib = AliTPCcalibDB::Instance()->GetVdrift(fCurrentRun);
+ Double_t driftCorr = 1.;
+ if (driftCalib){
+ //
+ // caching drift correction - temp. fix
+ // Extremally slow procedure
+ if ( TMath::Abs((lastStamp)-Int_t(fCurrentTimeStamp))<kMax){
+ driftCorr = lastCorr;
+ }else{
+ driftCorr = 1.+(driftCalib->GetPTRelative(fCurrentTimeStamp,0)+ driftCalib->GetPTRelative(fCurrentTimeStamp,1))*0.5;
+ lastCorr=driftCorr;
+ lastStamp=fCurrentTimeStamp;
+
+ }
+ }
+ //
+ // simple caching non thread save
+ static Double_t vdcorrectionTime=1;
+ static Double_t time0corrTime=0;
+ static Int_t lastStampT=-1;
+ //
+ if (lastStampT!=(Int_t)fCurrentTimeStamp){
+ lastStampT=fCurrentTimeStamp;
+ if(fCurrentRecoParam&&fCurrentRecoParam->GetUseDriftCorrectionTime()>0) {
+ vdcorrectionTime = (1+AliTPCcalibDB::Instance()->
+ GetVDriftCorrectionTime(fCurrentTimeStamp,
+ fCurrentRun,
+ sector%36>=18,
+ fCurrentRecoParam->GetUseDriftCorrectionTime()));
+ time0corrTime= AliTPCcalibDB::Instance()->
+ GetTime0CorrectionTime(fCurrentTimeStamp,
+ fCurrentRun,
+ sector%36>=18,
+ fCurrentRecoParam->GetUseDriftCorrectionTime());
+ }
+ //
+ if(fCurrentRecoParam&&fCurrentRecoParam->GetUseDriftCorrectionGY()>0) {
+ Float_t xyzPad[3];
+ AliTPCROC::Instance()->GetPositionGlobal(sector, TMath::Nint(x[0]) ,TMath::Nint(x[1]), xyzPad);
+
+ Double_t corrGy= (1+(xyzPad[1])*AliTPCcalibDB::Instance()->
+ GetVDriftCorrectionGy(fCurrentTimeStamp,
+ AliTPCcalibDB::Instance()->GetRun(),
+ sector%36>=18,
+ fCurrentRecoParam->GetUseDriftCorrectionGY()));
+ vdcorrectionTime *=corrGy;
+ }
+ }
+
+
if (!param){
AliFatal("Parameters missing");
}
//
const Int_t kNIS=param->GetNInnerSector(), kNOS=param->GetNOuterSector();
Double_t sign = 1.;
- Double_t zwidth = param->GetZWidth();
+ Double_t zwidth = param->GetZWidth()*driftCorr*vdcorrectionTime;
Double_t padWidth = 0;
Double_t padLength = 0;
Double_t maxPad = 0;
//
// Z coordinate
//
+ if (AliTPCcalibDB::Instance()->IsTrgL0()){
+ // by defualt we assume L1 trigger is used - make a correction in case of L0
+ AliCTPTimeParams* ctp = AliTPCcalibDB::Instance()->GetCTPTimeParams();
+ Double_t delay = ctp->GetDelayL1L0()*0.000000025;
+ x[2]-=delay/param->GetTSample();
+ }
+ x[2]-= param->GetNTBinsL1();
x[2]*= zwidth; // tranform time bin to the distance to the ROC
- x[2]-= 3.*param->GetZSigma() + param->GetNTBinsL1()*zwidth;
+ x[2]-= 3.*param->GetZSigma() + time0corrTime;
// subtract the time offsets
x[2] = sign*( param->GetZLength(sector) - x[2]);
}
}
+void AliTPCTransform::ApplyTransformations(Double_t */*xyz*/, Int_t /*volID*/){
+ //
+ // Modify global position
+ // xyz - global xyz position
+ // volID - volID of detector (sector number)
+ //
+ //
+
+}