]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDCalibraFillHisto.cxx
re-activate contrib code
[u/mrichter/AliRoot.git] / TRD / AliTRDCalibraFillHisto.cxx
index e7b2d356995019e6145d9632a9c78fc3e3b09176..e3ce45ac3af327efb2fb347f23db8394145e314e 100644 (file)
 
 #include "AliLog.h"
 
+#include "AliESDtrack.h"
 #include "AliTRDCalibraFillHisto.h"
 #include "AliTRDCalibraMode.h"
 #include "AliTRDCalibraVector.h"
 #include "AliTRDCalibraVdriftLinearFit.h"
+#include "AliTRDCalibraExbAltFit.h"
 #include "AliTRDcalibDB.h"
 #include "AliTRDCommonParam.h"
 #include "AliTRDpadPlane.h"
@@ -65,6 +67,7 @@
 #include "AliRawReader.h"
 #include "AliRawReaderDate.h"
 #include "AliTRDgeometry.h"
+#include "AliTRDfeeParam.h"
 #include "./Cal/AliTRDCalROC.h"
 #include "./Cal/AliTRDCalPad.h"
 #include "./Cal/AliTRDCalDet.h"
@@ -138,6 +141,8 @@ AliTRDCalibraFillHisto::AliTRDCalibraFillHisto()
   ,fVector2d(kFALSE)
   ,fLinearFitterOn(kFALSE)
   ,fLinearFitterDebugOn(kFALSE)
+  ,fExbAltFitOn(kFALSE)
+  ,fScaleWithTPCSignal(kFALSE)
   ,fRelativeScale(0)
   ,fThresholdClusterPRF2(15.0)
   ,fLimitChargeIntegration(kFALSE)
@@ -145,12 +150,21 @@ AliTRDCalibraFillHisto::AliTRDCalibraFillHisto()
   ,fNormalizeNbOfCluster(kFALSE)
   ,fMaxCluster(0)
   ,fNbMaxCluster(0)
+  ,fCutWithVdriftCalib(kFALSE)
+  ,fMinNbTRDtracklets(0)
+  ,fMinTRDMomentum(0.0)
+  ,fFirstRunGain(0)
   ,fVersionGainUsed(0)
   ,fSubVersionGainUsed(0)
+  ,fFirstRunGainLocal(0)
   ,fVersionGainLocalUsed(0)
   ,fSubVersionGainLocalUsed(0)
+  ,fFirstRunVdrift(0)
   ,fVersionVdriftUsed(0) 
   ,fSubVersionVdriftUsed(0)
+  ,fFirstRunExB(0)
+  ,fVersionExBUsed(0) 
+  ,fSubVersionExBUsed(0)
   ,fCalibraMode(new AliTRDCalibraMode())
   ,fDebugStreamer(0)
   ,fDebugLevel(0)
@@ -168,6 +182,7 @@ AliTRDCalibraFillHisto::AliTRDCalibraFillHisto()
   ,fNumberTrack(0)
   ,fTimeMax(0)
   ,fSf(10.0)
+  ,fRangeHistoCharge(150)
   ,fNumberBinCharge(50)
   ,fNumberBinPRF(10)
   ,fNgroupprf(3)
@@ -184,6 +199,7 @@ AliTRDCalibraFillHisto::AliTRDCalibraFillHisto()
   ,fCH2d(0x0)
   ,fLinearFitterArray(540)
   ,fLinearVdriftFit(0x0)
+  ,fExbAltFit(0x0)
   ,fCalDetGain(0x0)
   ,fCalROCGain(0x0)
 {
@@ -217,6 +233,8 @@ AliTRDCalibraFillHisto::AliTRDCalibraFillHisto(const AliTRDCalibraFillHisto &c)
   ,fVector2d(c.fVector2d)
   ,fLinearFitterOn(c.fLinearFitterOn)
   ,fLinearFitterDebugOn(c.fLinearFitterDebugOn)
+  ,fExbAltFitOn(c.fExbAltFitOn)
+  ,fScaleWithTPCSignal(c.fScaleWithTPCSignal)
   ,fRelativeScale(c.fRelativeScale)
   ,fThresholdClusterPRF2(c.fThresholdClusterPRF2)
   ,fLimitChargeIntegration(c.fLimitChargeIntegration)
@@ -224,12 +242,21 @@ AliTRDCalibraFillHisto::AliTRDCalibraFillHisto(const AliTRDCalibraFillHisto &c)
   ,fNormalizeNbOfCluster(c.fNormalizeNbOfCluster)
   ,fMaxCluster(c.fMaxCluster)
   ,fNbMaxCluster(c.fNbMaxCluster)
+  ,fCutWithVdriftCalib(c.fCutWithVdriftCalib)
+  ,fMinNbTRDtracklets(c.fMinNbTRDtracklets)
+  ,fMinTRDMomentum(c.fMinTRDMomentum)
+  ,fFirstRunGain(c.fFirstRunGain)
   ,fVersionGainUsed(c.fVersionGainUsed)
   ,fSubVersionGainUsed(c.fSubVersionGainUsed)
+  ,fFirstRunGainLocal(c.fFirstRunGainLocal)
   ,fVersionGainLocalUsed(c.fVersionGainLocalUsed)
   ,fSubVersionGainLocalUsed(c.fSubVersionGainLocalUsed)
+  ,fFirstRunVdrift(c.fFirstRunVdrift)
   ,fVersionVdriftUsed(c.fVersionVdriftUsed) 
   ,fSubVersionVdriftUsed(c.fSubVersionVdriftUsed)
+  ,fFirstRunExB(c.fFirstRunExB)
+  ,fVersionExBUsed(c.fVersionExBUsed) 
+  ,fSubVersionExBUsed(c.fSubVersionExBUsed)
   ,fCalibraMode(0x0)
   ,fDebugStreamer(0)
   ,fDebugLevel(c.fDebugLevel)
@@ -247,6 +274,7 @@ AliTRDCalibraFillHisto::AliTRDCalibraFillHisto(const AliTRDCalibraFillHisto &c)
   ,fNumberTrack(c.fNumberTrack)
   ,fTimeMax(c.fTimeMax)
   ,fSf(c.fSf)
+  ,fRangeHistoCharge(c.fRangeHistoCharge)
   ,fNumberBinCharge(c.fNumberBinCharge)
   ,fNumberBinPRF(c.fNumberBinPRF)
   ,fNgroupprf(c.fNgroupprf)
@@ -263,6 +291,7 @@ AliTRDCalibraFillHisto::AliTRDCalibraFillHisto(const AliTRDCalibraFillHisto &c)
   ,fCH2d(0x0)
   ,fLinearFitterArray(540)
   ,fLinearVdriftFit(0x0)
+  ,fExbAltFit(0x0)
   ,fCalDetGain(0x0)
   ,fCalROCGain(0x0)
 {
@@ -286,6 +315,9 @@ AliTRDCalibraFillHisto::AliTRDCalibraFillHisto(const AliTRDCalibraFillHisto &c)
   if(c.fLinearVdriftFit){
     fLinearVdriftFit = new AliTRDCalibraVdriftLinearFit(*c.fLinearVdriftFit);
   }
+  if(c.fExbAltFit){
+    fExbAltFit = new AliTRDCalibraExbAltFit(*c.fExbAltFit);
+  }
 
   if(c.fCalDetGain)  fCalDetGain   = new AliTRDCalDet(*c.fCalDetGain);
   if(c.fCalROCGain)  fCalROCGain   = new AliTRDCalROC(*c.fCalROCGain);
@@ -329,6 +361,7 @@ AliTRDCalibraFillHisto::~AliTRDCalibraFillHisto()
     if(f) { delete f;}
   }
   if(fLinearVdriftFit) delete fLinearVdriftFit;
+  if(fExbAltFit) delete fExbAltFit;
   if (fGeo) {
     delete fGeo;
   }
@@ -500,6 +533,17 @@ Bool_t AliTRDCalibraFillHisto::Init2Dhistos(Int_t nboftimebin)
       }
     }
     fLinearVdriftFit = new AliTRDCalibraVdriftLinearFit();
+    TString nameee("Ver");
+    nameee += fVersionExBUsed;
+    nameee += "Subver";
+    nameee += fSubVersionExBUsed;
+    nameee += "FirstRun";
+    nameee += fFirstRunExB;
+    nameee += "Nz";
+    fLinearVdriftFit->SetNameCalibUsed(nameee); 
+  }
+  if(fExbAltFitOn){
+    fExbAltFit = new AliTRDCalibraExbAltFit();
   }
 
   if (fPRF2dOn) {
@@ -525,7 +569,7 @@ Bool_t AliTRDCalibraFillHisto::InitCalDet()
 
   // DB Setting
   // Get cal
-  AliCDBEntry *entry = AliCDBManager::Instance()->Get("TRD/Calib/ChamberGainFactor",AliCDBManager::Instance()->GetRun(),fVersionGainUsed,fSubVersionGainUsed);
+  AliCDBEntry *entry = AliCDBManager::Instance()->Get("TRD/Calib/ChamberGainFactor",fFirstRunGain,fVersionGainUsed,fSubVersionGainUsed);
   if(!entry) {
     AliError("No gain det calibration entry found");
     return kFALSE;
@@ -548,6 +592,8 @@ Bool_t AliTRDCalibraFillHisto::InitCalDet()
   name += fVersionGainUsed;
   name += "Subver";
   name += fSubVersionGainUsed;
+  name += "FirstRun";
+  name += fFirstRunGain;
   name += "Nz";
   name += fCalibraMode->GetNz(0);
   name += "Nrphi";
@@ -560,6 +606,8 @@ Bool_t AliTRDCalibraFillHisto::InitCalDet()
   namee += fVersionVdriftUsed;
   namee += "Subver";
   namee += fSubVersionVdriftUsed;
+  namee += "FirstRun";
+  namee += fFirstRunVdrift;
   namee += "Nz";
   namee += fCalibraMode->GetNz(1);
   namee += "Nrphi";
@@ -567,6 +615,19 @@ Bool_t AliTRDCalibraFillHisto::InitCalDet()
   
   fPH2d->SetTitle(namee);  
 
+  // title AliTRDCalibraVdriftLinearFit
+  TString nameee("Ver");
+  nameee += fVersionExBUsed;
+  nameee += "Subver";
+  nameee += fSubVersionExBUsed;
+  nameee += "FirstRun";
+  nameee += fFirstRunExB;
+  nameee += "Nz";
+
+  
+  fLinearVdriftFit->SetNameCalibUsed(nameee);  
+
+
 
   return kTRUE;
 
@@ -609,7 +670,7 @@ Bool_t AliTRDCalibraFillHisto::InitCalPad(Int_t detector)
 
 }
 //____________Offline tracking in the AliTRDtracker____________________________
-Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(const AliTRDtrackV1 *t)
+Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(const AliTRDtrackV1 *t,const AliESDtrack *esdtrack)
 {
   //
   // Use AliTRDtrackV1 for the calibration
@@ -620,15 +681,19 @@ Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(const AliTRDtrackV1 *t)
   AliTRDcluster *cl      = 0x0;                // cluster attached now to the tracklet
   AliTRDcluster *cls     = 0x0;                // shared cluster attached now to the tracklet
   Bool_t         newtr   = kTRUE;              // new track
-  
-  // Get cal
-  //  AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
-  /*
-  if (!cal) {
-    AliInfo("Could not get calibDB");
-    return kFALSE;
-  }
-*/
+
+
+  //
+  // Cut on the number of TRD tracklets
+  //
+  Int_t numberoftrdtracklets = t->GetNumberOfTracklets();
+  if(numberoftrdtracklets < fMinNbTRDtracklets) return kFALSE;
+
+  Double_t tpcsignal = 1.0;
+  if(esdtrack) tpcsignal = esdtrack->GetTPCsignal()/50.0;
+  if(fScaleWithTPCSignal && tpcsignal <0.00001) return kFALSE;
+
+  //
   if (!fCalibDB) {
     AliInfo("Could not get calibDB");
     return kFALSE;
@@ -644,6 +709,9 @@ Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(const AliTRDtrackV1 *t)
     if(!tracklet->IsOK()) continue;
     fNumberTrack++; 
     ResetfVariablestracklet();
+    Float_t momentum = t->GetMomentum(itr);
+    if(TMath::Abs(momentum) < fMinTRDMomentum)  continue;
+
 
     //////////////////////////////////////////
     // localisation of the tracklet and dqdl
@@ -674,6 +742,7 @@ Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(const AliTRDtrackV1 *t)
     ////////////////////////////
     // loop over the clusters
     ////////////////////////////
+    Double_t chargeQ = 0.0;
     Int_t nbclusters = 0;
     for(int jc=0; jc<AliTRDseedV1::kNtb; jc++){
       if(!(cl = tracklet->GetClusters(jc))) continue;
@@ -689,7 +758,15 @@ Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(const AliTRDtrackV1 *t)
       // Add the charge if shared cluster
       cls = tracklet->GetClusters(jc+AliTRDseedV1::kNtb);
       //
-      StoreInfoCHPHtrack(cl, tracklet->GetdQdl(jc),group,row,col,cls);
+      //Scale with TPC signal or not
+      if(!fScaleWithTPCSignal) {
+       chargeQ += StoreInfoCHPHtrack(cl, tracklet->GetQperTB(jc),group,row,col,cls); //tracklet->GetdQdl(jc)
+       //printf("Do not scale now\n");
+      }
+      else {
+       chargeQ += StoreInfoCHPHtrack(cl, tracklet->GetQperTB(jc)/tpcsignal,group,row,col,cls); //tracklet->GetdQdl(jc)
+      }
+    
     }
     
     ////////////////////////////////////////
@@ -704,16 +781,74 @@ Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(const AliTRDtrackV1 *t)
 
       // Gain calibration
       if (fCH2dOn) {
-       FillTheInfoOfTheTrackCH(nbclusters);
+       if(fCutWithVdriftCalib) {
+         if(pass) FillTheInfoOfTheTrackCH(nbclusters);
+       } else {
+         FillTheInfoOfTheTrackCH(nbclusters);
+       }
       }
        
       // PH calibration
       if (fPH2dOn) {
-       FillTheInfoOfTheTrackPH();    
+       if(fCutWithVdriftCalib) {
+         if(pass) FillTheInfoOfTheTrackPH();
+       }
+       else {
+         FillTheInfoOfTheTrackPH();
+       }    
       }
        
       if(pass && fPRF2dOn) HandlePRFtrackletV1(tracklet,nbclusters);
-               
+       
+
+      /////////////////////////////////////////////////////////
+      // Debug
+      ////////////////////////////////////////////////////////
+      if(fDebugLevel > 0){
+               //printf("test\n");
+       if ( !fDebugStreamer ) {
+         //debug stream
+         TDirectory *backup = gDirectory;
+         fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root");
+         if ( backup ) backup->cd();  //we don't want to be cd'd to the debug streamer
+       }     
+       
+       Int_t    stacke = AliTRDgeometry::GetStack(detector);
+       Int_t    sme    = AliTRDgeometry::GetSector(detector);
+       Int_t    layere  = AliTRDgeometry::GetLayer(detector);
+       // Some variables
+       Float_t b[2] = {0.0,0.0};
+       Float_t bCov[3] = {0.0,0.0,0.0};
+       if(esdtrack) esdtrack->GetImpactParameters(b,bCov);
+       if (bCov[0]<=0 || bCov[2]<=0) {
+         bCov[0]=0; bCov[2]=0;
+       }
+       Float_t dcaxy = b[0];
+       Float_t dcaz = b[1];
+       Int_t tpcnbclusters = 0;
+       if(esdtrack) tpcnbclusters = esdtrack->GetTPCclusters(0);
+       Double_t ttpcsignal = 0.0;
+       if(esdtrack) ttpcsignal = esdtrack->GetTPCsignal();
+        Int_t    cutvdriftlinear = 0;
+       if(!pass) cutvdriftlinear = 1;
+       
+       (* fDebugStreamer) << "FillCharge"<<
+         "detector="<<detector<<
+         "stack="<<stacke<<
+         "sm="<<sme<<
+         "layere="<<layere<<
+         "dcaxy="<<dcaxy<<
+         "dcaz="<<dcaz<<
+         "nbtpccls="<<tpcnbclusters<<
+         "tpcsignal="<<ttpcsignal<<
+         "cutvdriftlinear="<<cutvdriftlinear<<
+         "ptrd="<<momentum<<
+         "nbtrdtracklet="<<numberoftrdtracklets<<
+         "charge="<<chargeQ<<
+         "\n"; 
+      }
+      
+      
     } // if a good tracklet
   }
   
@@ -786,8 +921,24 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtrackletV1(const AliTRDseedV1 *track
   //////////////////////////////////
   // Loop clusters
   //////////////////////////////////
+
+  Float_t sigArr[AliTRDfeeParam::GetNcol()];
+  memset(sigArr, 0, AliTRDfeeParam::GetNcol()*sizeof(sigArr[0]));
+  Int_t ncl=0, tbf=0, tbl=0;
+
   for(int ic=0; ic<AliTRDseedV1::kNtb; ic++){
     if(!(cl = tracklet->GetClusters(ic))) continue;
+
+    if(!tbf) tbf=ic;
+    tbl=ic;
+    ncl++;
+    Int_t col = cl->GetPadCol();
+    for(int ip=-1, jp=2; jp<5; ip++, jp++){
+      Int_t idx=col+ip;
+      if(idx<0 || idx>=AliTRDfeeParam::GetNcol()) continue;
+      sigArr[idx]+=((Float_t)cl->GetSignals()[jp]);
+    }
+
     if((fLimitChargeIntegration) && (!cl->IsInChamber())) continue;
     
     Double_t ycluster                 = cl->GetY();
@@ -814,18 +965,42 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtrackletV1(const AliTRDseedV1 *track
   TVectorD pars;
   fLinearFitterTracklet->Eval();
   fLinearFitterTracklet->GetParameters(pars);
-  pointError  =  TMath::Sqrt(fLinearFitterTracklet->GetChisquare()/(nbli-2));
+  pointError  =  TMath::Sqrt(TMath::Abs(fLinearFitterTracklet->GetChisquare()/(nbli-2)));
   errorpar    =  fLinearFitterTracklet->GetParError(1)*pointError;
   dydt        = pars[1]; 
   //printf("chis %f, nbli %d, pointError %f, parError %f, errorpar %f\n",fLinearFitterTracklet->GetChisquare(),nbli,pointError,fLinearFitterTracklet->GetParError(1),errorpar);
   fLinearFitterTracklet->ClearPoints();  
+
+  ////////////////////////////////////
+  // Calc the projection of the clusters on the y direction
+  ///////////////////////////////////
+
+  Float_t signalSum(0.);
+  Float_t mean = 0.0, rms = 0.0;
+  Float_t dydx = tracklet->GetYref(1), tilt = tracklet->GetTilt(); // ,dzdx = tracklet->GetZref(1); (identical to the previous definition!)
+  Float_t dz = dzdx*(tbl-tbf)/10;
+  if(ncl>10){
+    for(Int_t ip(0); ip<AliTRDfeeParam::GetNcol(); ip++){
+      signalSum+=sigArr[ip]; 
+      mean+=ip*sigArr[ip];
+    } 
+    if(signalSum > 0.0) mean/=signalSum;
+  
+    for(Int_t ip = 0; ip<AliTRDfeeParam::GetNcol(); ip++) 
+      rms+=sigArr[ip]*(ip-mean)*(ip-mean);
+    
+    if(signalSum > 0.0) rms = TMath::Sqrt(TMath::Abs(rms/signalSum));
+    
+    rms -= TMath::Abs(dz*tilt);
+    dydx -= dzdx*tilt;
+  }
  
   ////////////////////////////////
   // Debug stuff
   /////////////////////////////// 
 
 
-  if(fDebugLevel > 0){
+  if(fDebugLevel > 1){
     if ( !fDebugStreamer ) {
       //debug stream
       TDirectory *backup = gDirectory;
@@ -833,7 +1008,8 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtrackletV1(const AliTRDseedV1 *track
       if ( backup ) backup->cd();  //we don't want to be cd'd to the debug streamer
     } 
     
-
+    float xcoord = tnp-dzdx*tnt;
+    float pt = tracklet->GetPt();
     Int_t layer = GetLayer(fDetectorPreviousTrack);
            
     (* fDebugStreamer) << "FindP1TrackPHtrackletV1"<<
@@ -851,6 +1027,13 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtrackletV1(const AliTRDseedV1 *track
       "crossrow="<<crossrow<<
       "errorpar="<<errorpar<<
       "pointError="<<pointError<<
+      "xcoord="<<xcoord<<
+      "pt="<<pt<<
+      "rms="<<rms<<
+      "dydx="<<dydx<<
+      "dz="<<dz<<
+      "tilt="<<tilt<<
+      "ncl="<<ncl<<
       "\n";
 
   }
@@ -879,6 +1062,9 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtrackletV1(const AliTRDseedV1 *track
       fLinearVdriftFit->Update(fDetectorPreviousTrack,x,pars[1]);
     }
   }
+  if(fExbAltFitOn){
+    fExbAltFit->Update(fDetectorPreviousTrack,dydx,rms);
+  }
   
   return kTRUE;
 }
@@ -1073,7 +1259,7 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtrackletV1(const AliTRDseedV1 *tracklet,
     // Debug stuff
     ////////////////////
 
-    if(fDebugLevel > 0){
+    if(fDebugLevel > 1){
       if ( !fDebugStreamer ) {
        //debug stream
        TDirectory *backup = gDirectory;
@@ -1276,8 +1462,8 @@ Bool_t AliTRDCalibraFillHisto::IsPadOn(Int_t detector, Int_t row, Int_t col) con
     return kFALSE;
   }
   
-  if (!cal->IsChamberInstalled(detector)     || 
-       cal->IsChamberMasked(detector)        ||
+  if (!cal->IsChamberGood(detector)     || 
+       cal->IsChamberNoData(detector)        ||
        cal->IsPadMasked(detector,col,row)) {
     return kFALSE;
   }
@@ -1459,12 +1645,14 @@ void AliTRDCalibraFillHisto::SetNumberGroupsPRF(Short_t numberGroupsPRF)
 // Per tracklet: store or reset the info, fill the histos with the info
 //////////////////////////////////////////////////////////////////////////////////////////
 //_____________________________________________________________________________
-void AliTRDCalibraFillHisto::StoreInfoCHPHtrack(const AliTRDcluster *cl,const Double_t dqdl,const Int_t *group,const Int_t row,const Int_t col,const AliTRDcluster *cls)
+Float_t AliTRDCalibraFillHisto::StoreInfoCHPHtrack(const AliTRDcluster *cl,const Double_t dqdl,const Int_t *group,const Int_t row,const Int_t col,const AliTRDcluster *cls)
 {
   //
   // Store the infos in fAmpTotal, fPHPlace and fPHValue
   // Correct from the gain correction before
   // cls is shared cluster if any
+  // Return the charge
+  // 
   //
   
   //printf("StoreInfoCHPHtrack\n");
@@ -1484,7 +1672,7 @@ void AliTRDCalibraFillHisto::StoreInfoCHPHtrack(const AliTRDcluster *cl,const Do
   if(fIsHLT) correctthegain = fCalDetGain->GetValue(fDetectorPreviousTrack);
   else correctthegain = fCalDetGain->GetValue(fDetectorPreviousTrack)*fCalROCGain->GetValue(col,row);
   Float_t correction    = 1.0;
-  Float_t normalisation = 6.67;
+  Float_t normalisation = 1.13; //org: 6.67; 1st: 1.056; 2nd: 1.13;
   // we divide with gain in AliTRDclusterizer::Transform...
   if( correctthegain > 0 ) normalisation /= correctthegain;
 
@@ -1506,6 +1694,8 @@ void AliTRDCalibraFillHisto::StoreInfoCHPHtrack(const AliTRDcluster *cl,const Do
     fPHPlace[time] = group[1];
     fPHValue[time] = charge;
   }
+
+  return correction;
   
 }
 //____________Offine tracking in the AliTRDtracker_____________________________
@@ -2101,7 +2291,7 @@ Int_t AliTRDCalibraFillHisto::FillDAQ(Double_t phvalue[16][144][36]){
   /////////////////////////////////////////////////////////
   // Debug
   ////////////////////////////////////////////////////////
-  if(fDebugLevel > 0){
+  if(fDebugLevel > 1){
     if ( !fDebugStreamer ) {
       //debug stream
       TDirectory *backup = gDirectory;
@@ -2505,6 +2695,8 @@ void AliTRDCalibraFillHisto::CreatePH2d(Int_t nn)
   name += fVersionVdriftUsed;
   name += "Subver";
   name += fSubVersionVdriftUsed;
+  name += "FirstRun";
+  name += fFirstRunVdrift;
   name += "Nz";
   name += fCalibraMode->GetNz(1);
   name += "Nrphi";
@@ -2530,13 +2722,15 @@ void AliTRDCalibraFillHisto::CreateCH2d(Int_t nn)
   name += fVersionGainUsed;
   name += "Subver";
   name += fSubVersionGainUsed;
+  name += "FirstRun";
+  name += fFirstRunGain;
   name += "Nz";
   name += fCalibraMode->GetNz(0);
   name += "Nrphi";
   name += fCalibraMode->GetNrphi(0);
   
   fCH2d = new TH2I("CH2d",(const Char_t *) name
-                  ,fNumberBinCharge,0,300,nn,0,nn);
+                  ,(Int_t)fNumberBinCharge,0,fRangeHistoCharge,nn,0,nn);
   fCH2d->SetYTitle("Det/pad groups");
   fCH2d->SetXTitle("charge deposit [a.u]");
   fCH2d->SetZTitle("counts");
@@ -2552,7 +2746,7 @@ void AliTRDCalibraFillHisto::SetRelativeScale(Float_t RelativeScale)
 {
   //
   // Set the factor that will divide the deposited charge
-  // to fit in the histo range [0,300]
+  // to fit in the histo range [0,fRangeHistoCharge]
   //
  
   if (RelativeScale > 0.0) {
@@ -2574,10 +2768,11 @@ void  AliTRDCalibraFillHisto::FillCH2d(Int_t x, Float_t y)
   // 
   
   //skip simply the value out of range
-  if((y>=300.0) || (y<0.0)) return;
+  if((y>=fRangeHistoCharge) || (y<0.0)) return;
+  if(fRangeHistoCharge < 0.0) return;
   
   //Calcul the y place
-  Int_t yplace = (Int_t) (fNumberBinCharge*y/300.0)+1;
+  Int_t yplace = (Int_t) (fNumberBinCharge*y/fRangeHistoCharge)+1;
   Int_t place = (fNumberBinCharge+2)*(x+1)+yplace;
   
   //Fill