]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/Rec/AliTPCseed.cxx
Merge branch 'master' into TRDdev
[u/mrichter/AliRoot.git] / TPC / Rec / AliTPCseed.cxx
index 544b3559d7cd3437fcd9d7e9f813960b146b3450..0c87dd04753dbb13c6e514b16be0c087681ccc64 100644 (file)
@@ -37,6 +37,7 @@
 #include "AliSplineFit.h"
 #include "AliCDBManager.h"
 #include "AliTPCcalibDButil.h"
+#include <AliCTPTimeParams.h>
 
 
 ClassImp(AliTPCseed)
@@ -989,6 +990,7 @@ Float_t  AliTPCseed::CookdEdxNorm(Double_t low, Double_t up, Int_t type, Int_t i
   //
   if (AliTPCcalibDB::Instance()->GetParameters()){
     gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000;  //relative gas gain
+    gainGG *= AliTPCcalibDB::Instance()->GetParameters()->GetNtot()/36.82;//correction for the ionisation
   }
 
   const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
@@ -1167,6 +1169,8 @@ Float_t  AliTPCseed::CookdEdxAnalytical(Double_t low, Double_t up, Int_t type, I
 
   AliTPCClusterParam * parcl = AliTPCcalibDB::Instance()->GetClusterParam();
   AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
+  AliTPCTransform * trans = AliTPCcalibDB::Instance()->GetTransform();
+  const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
   if (!parcl)  return 0;
   if (!param) return 0;
   Int_t row0 = param->GetNRowLow();
@@ -1186,7 +1190,18 @@ Float_t  AliTPCseed::CookdEdxAnalytical(Double_t low, Double_t up, Int_t type, I
   //
   if (AliTPCcalibDB::Instance()->GetParameters()){
     gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000;  //relative gas gain
+    gainGG *= AliTPCcalibDB::Instance()->GetParameters()->GetNtot()/36.82;//correction for the ionisation
+  }
+  Double_t timeCut=0;
+  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;
+    delay/=param->GetTSample();    
+    timeCut=delay;
   }
+  timeCut += recoParam->GetSkipTimeBins();
+
   //
   // extract time-dependent correction for pressure and temperature variations
   //
@@ -1194,20 +1209,19 @@ Float_t  AliTPCseed::CookdEdxAnalytical(Double_t low, Double_t up, Int_t type, I
   Float_t corrTimeGain = 1;
   TObjArray * timeGainSplines = 0x0;
   TGraphErrors * grPadEqual = 0x0;
-  TGraphErrors*  grChamberGain[3]={0x0,0x0,0x0};
+  TGraphErrors*  grChamberGain[4]={0x0,0x0,0x0,0x0};
+  TF1*  funDipAngle[4]={0x0,0x0,0x0,0x0};
   //
-  AliTPCTransform * trans = AliTPCcalibDB::Instance()->GetTransform();
-  const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
   //
   if (recoParam->GetNeighborRowsDedx() == 0) rowThres = 0;     
   UInt_t time = 1;//
   //
   if (trans) {
       runNumber = trans->GetCurrentRunNumber();
+      time = trans->GetCurrentTimeStamp();
       //AliTPCcalibDB::Instance()->SetRun(runNumber);
       timeGainSplines = AliTPCcalibDB::Instance()->GetTimeGainSplinesRun(runNumber);
       if (timeGainSplines && recoParam->GetUseGainCorrectionTime()>0) {
-       time = trans->GetCurrentTimeStamp();
        AliSplineFit * fitMIP = (AliSplineFit *) timeGainSplines->At(0);
        AliSplineFit * fitFPcosmic = (AliSplineFit *) timeGainSplines->At(1);
        if (fitMIP) {
@@ -1218,9 +1232,12 @@ Float_t  AliTPCseed::CookdEdxAnalytical(Double_t low, Double_t up, Int_t type, I
        //
        if (type==1) grPadEqual = (TGraphErrors * ) timeGainSplines->FindObject("TGRAPHERRORS_MEANQMAX_PADREGIONGAIN_BEAM_ALL");
        if (type==0) grPadEqual = (TGraphErrors * ) timeGainSplines->FindObject("TGRAPHERRORS_MEANQTOT_PADREGIONGAIN_BEAM_ALL");
-        const char* names[3]={"SHORT","MEDIUM","LONG"};
-        for (Int_t iPadRegion=0; iPadRegion<3; ++iPadRegion)
+        const char* names[4]={"SHORT","MEDIUM","LONG","ABSOLUTE"};
+        for (Int_t iPadRegion=0; iPadRegion<4; ++iPadRegion) {
           grChamberGain[iPadRegion]=(TGraphErrors*)timeGainSplines->FindObject(Form("TGRAPHERRORS_MEAN_CHAMBERGAIN_%s_BEAM_ALL",names[iPadRegion]));
+         if (type==1) funDipAngle[iPadRegion]=(TF1*)timeGainSplines->FindObject(Form("TF1_QMAX_DIPANGLE_%s_BEAM_ALL",names[iPadRegion]));
+         if (type==0) funDipAngle[iPadRegion]=(TF1*)timeGainSplines->FindObject(Form("TF1_QTOT_DIPANGLE_%s_BEAM_ALL",names[iPadRegion]));
+       }
       }
   }
   
@@ -1243,6 +1260,7 @@ Float_t  AliTPCseed::CookdEdxAnalytical(Double_t low, Double_t up, Int_t type, I
       if (isClBefore && isClAfter) nclBelowThr++;
     }
     if (!cluster) continue;
+    if (cluster->GetTimeBin()<timeCut) continue; //reject  clusters at the gating grid opening
     //
     //
     if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
@@ -1319,9 +1337,21 @@ Float_t  AliTPCseed::CookdEdxAnalytical(Double_t low, Double_t up, Int_t type, I
     // chamber-by-chamber equalization outside gain map
     //
     Float_t gainChamber = 1;
-    if (grChamberGain[ipad] && recoParam->GetUseGainCorrectionTime()>0) gainChamber = grChamberGain[ipad]->Eval(cluster->GetDetector());
+    if (grChamberGain[ipad] && recoParam->GetUseGainCorrectionTime()>0) {
+      gainChamber = grChamberGain[ipad]->Eval(cluster->GetDetector());
+      if (gainChamber==0) gainChamber=1; // in case old calibation was used before use no correction
+    }
+    //
+    // dip angle correction
     //
+    Float_t corrDipAngle = 1;
+    Float_t corrDipAngleAbs = 1;
+    //    if (grDipAngle[ipad]) corrDipAngle = grDipAngle[ipad]->Eval(GetTgl());
+    Double_t tgl=GetTgl();
+    if (funDipAngle[ipad]) corrDipAngle = funDipAngle[ipad]->Eval(tgl);
+    if (funDipAngle[3]) corrDipAngleAbs = funDipAngle[3]->Eval(tgl);
     //
+    // pressure temperature and high voltage correction
     //
     Double_t correctionHVandPT = AliTPCcalibDB::Instance()->GetGainCorrectionHVandPT(time, runNumber,cluster->GetDetector(), 5 , recoParam->GetGainCorrectionHVandPTMode());
     //
@@ -1332,6 +1362,8 @@ Float_t  AliTPCseed::CookdEdxAnalytical(Double_t low, Double_t up, Int_t type, I
     amp[ncl]/=corrPos;
     amp[ncl]/=gainEqualPadRegion;
     amp[ncl]/=gainChamber;
+    amp[ncl]/=corrDipAngle;
+    amp[ncl]/=corrDipAngleAbs;
     //
     ncl++;
   }