]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDCalibraFillHisto.cxx
Fix of sigmaZ for crossing tracklets from Alex
[u/mrichter/AliRoot.git] / TRD / AliTRDCalibraFillHisto.cxx
index 42603d89cb45dd776df3752296364fe91a864afc..e3ce45ac3af327efb2fb347f23db8394145e314e 100644 (file)
@@ -53,6 +53,7 @@
 
 #include "AliLog.h"
 
+#include "AliESDtrack.h"
 #include "AliTRDCalibraFillHisto.h"
 #include "AliTRDCalibraMode.h"
 #include "AliTRDCalibraVector.h"
@@ -141,6 +142,7 @@ AliTRDCalibraFillHisto::AliTRDCalibraFillHisto()
   ,fLinearFitterOn(kFALSE)
   ,fLinearFitterDebugOn(kFALSE)
   ,fExbAltFitOn(kFALSE)
+  ,fScaleWithTPCSignal(kFALSE)
   ,fRelativeScale(0)
   ,fThresholdClusterPRF2(15.0)
   ,fLimitChargeIntegration(kFALSE)
@@ -148,6 +150,9 @@ AliTRDCalibraFillHisto::AliTRDCalibraFillHisto()
   ,fNormalizeNbOfCluster(kFALSE)
   ,fMaxCluster(0)
   ,fNbMaxCluster(0)
+  ,fCutWithVdriftCalib(kFALSE)
+  ,fMinNbTRDtracklets(0)
+  ,fMinTRDMomentum(0.0)
   ,fFirstRunGain(0)
   ,fVersionGainUsed(0)
   ,fSubVersionGainUsed(0)
@@ -177,6 +182,7 @@ AliTRDCalibraFillHisto::AliTRDCalibraFillHisto()
   ,fNumberTrack(0)
   ,fTimeMax(0)
   ,fSf(10.0)
+  ,fRangeHistoCharge(150)
   ,fNumberBinCharge(50)
   ,fNumberBinPRF(10)
   ,fNgroupprf(3)
@@ -228,6 +234,7 @@ AliTRDCalibraFillHisto::AliTRDCalibraFillHisto(const AliTRDCalibraFillHisto &c)
   ,fLinearFitterOn(c.fLinearFitterOn)
   ,fLinearFitterDebugOn(c.fLinearFitterDebugOn)
   ,fExbAltFitOn(c.fExbAltFitOn)
+  ,fScaleWithTPCSignal(c.fScaleWithTPCSignal)
   ,fRelativeScale(c.fRelativeScale)
   ,fThresholdClusterPRF2(c.fThresholdClusterPRF2)
   ,fLimitChargeIntegration(c.fLimitChargeIntegration)
@@ -235,6 +242,9 @@ 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)
@@ -264,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)
@@ -659,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
@@ -670,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;
@@ -694,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
@@ -724,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;
@@ -739,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->GetQperTB(jc),group,row,col,cls); //tracklet->GetdQdl(jc)
+      //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)
+      }
+    
     }
     
     ////////////////////////////////////////
@@ -754,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
   }
   
@@ -915,7 +1000,7 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtrackletV1(const AliTRDseedV1 *track
   /////////////////////////////// 
 
 
-  //if(fDebugLevel > 0){
+  if(fDebugLevel > 1){
     if ( !fDebugStreamer ) {
       //debug stream
       TDirectory *backup = gDirectory;
@@ -951,7 +1036,7 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtrackletV1(const AliTRDseedV1 *track
       "ncl="<<ncl<<
       "\n";
 
-    //}
+  }
   
   /////////////////////////
   // Cuts quality
@@ -1174,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;
@@ -1560,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");
@@ -1607,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_____________________________
@@ -2202,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;
@@ -2641,7 +2730,7 @@ void AliTRDCalibraFillHisto::CreateCH2d(Int_t nn)
   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");
@@ -2657,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) {
@@ -2679,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