]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDCalibTask.cxx
Split dEdxUtils into dEdxBaseUtils, dEdxCalibUtils, dEdxReconUtils and one CalibHistA...
[u/mrichter/AliRoot.git] / TRD / AliTRDCalibTask.cxx
index 7e4f6cc47a2c4552856f1051f8ec67b0e9c85bc8..d6605a29a0ebd0a273ed44a208b3bd8e927239f7 100644 (file)
@@ -78,6 +78,9 @@ using namespace std;
 #include "AliLog.h"
 
 #include "AliTRDCalibChamberStatus.h"
+#include "AliTRDdEdxBaseUtils.h"
+#include "AliTRDdEdxCalibHistArray.h"
+#include "AliTRDdEdxCalibUtils.h"
 
 #include "AliTRDCalibTask.h"
 
@@ -87,7 +90,6 @@ ClassImp(AliTRDCalibTask)
 //________________________________________________________________________
   AliTRDCalibTask::AliTRDCalibTask(const char *name) 
     : AliAnalysisTaskSE(name), fESD(0),
-      fESDfriend(0),
       fkEsdTrack(0),
       fFriendTrack(0),
       fCalibObject(0),
@@ -125,7 +127,10 @@ ClassImp(AliTRDCalibTask)
       fVector2d(kFALSE),
       fVdriftLinear(kTRUE),
       fExbAlt(kFALSE),
+      fDebugLevelTRDCalibraFillHisto(0),
       fNbTimeBins(0),
+      fNumberBinCharge(50),
+      fSelectTrigger(kTRUE),
       fSelectedTrigger(new TObjArray()),
       fRejected(kTRUE),
       fEsdTrackCuts(0),
@@ -135,7 +140,11 @@ ClassImp(AliTRDCalibTask)
       fMinNbContributors(0),
       fRangePrimaryVertexZ(9999999.0),
       fMinNbTracks(9),
-      fMaxNbTracks(500),
+      fMaxNbTracks(999999999),
+      fCutWithVdriftCalib(kFALSE),
+      fMinNbTRDtracklets(0),
+      fMinTRDMomentum(0),
+      fScaleGainWithTPCSignal(kFALSE),
       fLow(0),
       fHigh(30),
       fFillZero(kFALSE),
@@ -160,7 +169,7 @@ ClassImp(AliTRDCalibTask)
       fCalDetGain(0x0),
       fMaxEvent(0),
       fCounter(0),
-      fDebug(0)
+      fPHQon(kTRUE)
 {
   //
   // Default constructor
@@ -174,6 +183,7 @@ ClassImp(AliTRDCalibTask)
   fNrphi[1] = 0;
   fNrphi[2] = 0;
 
+  
   // Define input and output slots here
   // Input slot #0 works with a TChain
   DefineInput(0, TChain::Class());
@@ -215,6 +225,10 @@ AliTRDCalibTask::~AliTRDCalibTask()
   if(fCH2dTest) delete fCH2dTest;
   if(fPH2dTest) delete fPH2dTest;
   if(fLinearVdriftTest) delete fLinearVdriftTest;
+  if(IsPHQon()){
+    AliTRDdEdxCalibUtils::DeleteHistArray();
+  }
+
   if(fCalDetGain) delete fCalDetGain;
   
   if(fSelectedTrigger) {
@@ -259,6 +273,10 @@ void AliTRDCalibTask::UserCreateOutputObjects()
   // instance calibration 
   fTRDCalibraFillHisto = AliTRDCalibraFillHisto::Instance();
   if(fOnInstance) {
+    fTRDCalibraFillHisto->SetNumberBinCharge(fNumberBinCharge); // set number of bin of the charge distribution
+    fTRDCalibraFillHisto->SetCutWithVdriftCalib(fCutWithVdriftCalib); // cut vdrift
+    fTRDCalibraFillHisto->SetMinNbTRDtracklets(fMinNbTRDtracklets); // min number of TRD tracklets
+    fTRDCalibraFillHisto->SetMinTRDMomentum(fMinTRDMomentum); // min TRD momentum
     fTRDCalibraFillHisto->SetHisto2d(fHisto2d); // choose to use histograms
     fTRDCalibraFillHisto->SetVector2d(fVector2d); // choose to use vectors
     fTRDCalibraFillHisto->SetCH2dOn();  // choose to calibrate the gain
@@ -267,6 +285,7 @@ void AliTRDCalibTask::UserCreateOutputObjects()
     fTRDCalibraFillHisto->SetLinearFitterOn(fVdriftLinear); // Other possibility vdrift VDRIFT
     fTRDCalibraFillHisto->SetLinearFitterDebugOn(fVdriftLinear); // Other possibility vdrift
     fTRDCalibraFillHisto->SetExbAltFitOn(fExbAlt); // Alternative method for exb
+    fTRDCalibraFillHisto->SetScaleWithTPCSignal(fScaleGainWithTPCSignal); // Scale Gain with TPC signal
     for(Int_t k = 0; k < 3; k++){
       if(((fNz[k] != 10) && (fNrphi[k] != 10)) && ((fNz[k] != 100) && (fNrphi[k] != 100))) {
        fTRDCalibraFillHisto->SetNz(k,fNz[k]);                                    // Mode calibration
@@ -295,7 +314,7 @@ void AliTRDCalibTask::UserCreateOutputObjects()
     fTRDCalibraFillHisto->SetNumberClustersf(fHigh); // At least 11 clusters
     
     // For testing only
-    if(fDebug > 2) fTRDCalibraFillHisto->SetDebugLevel(1); //debug stuff
+    fTRDCalibraFillHisto->SetDebugLevel(fDebugLevelTRDCalibraFillHisto); //debug stuff
     
     if(fHisto2d) {  
       fListHist->Add(fTRDCalibraFillHisto->GetCH2d());
@@ -331,6 +350,15 @@ void AliTRDCalibTask::UserCreateOutputObjects()
   fAbsoluteGain->Sumw2();
   fListHist->Add(fAbsoluteGain);
   
+  if(IsPHQon()){
+    printf("\n        AliTRDCalibTask PHQ is on!!     \n\n");
+    AliTRDdEdxBaseUtils::PrintControl();
+    AliTRDdEdxCalibUtils::IniHistArray(fListHist, kTRUE);
+  }
+  else{
+    printf("\n        AliTRDCalibTask PHQ is off!!     \n\n");
+  }
+
   /////////////////////////////////////////
   // First debug level
   ///////////////////////////////////////
@@ -552,13 +580,13 @@ void AliTRDCalibTask::UserExec(Option_t *)
   //cout << "event = " << fCounter << endl;
   
   //printf("Counter %d\n",fCounter);
-  
+
   ///////////////////
   // Check trigger
   ///////////////////
   Bool_t pass = kTRUE;
 
-  if (strstr(type,"p-p")) {
+  if (fSelectTrigger) {
    
     //printf("Will check the triggers\n");
 
@@ -638,8 +666,10 @@ void AliTRDCalibTask::UserExec(Option_t *)
     //printf("centrality %f, centralityb %f\n",centrality,centralityb);
   }
   
-  if (strstr(type,"Pb-Pb")) {
-    //printf("Will check the number of good tracks\n");
+  //printf("Beam type %s\n",(const char*)type);
+  if (!strstr(type,"p-p")) {
+    //if (strstr(type,"A-A")) {
+    //printf("Will check the number of good tracks %f %f %f\n",nGoodParticles,fMinNbTracks,fMaxNbTracks);
     if((nGoodParticles < fMinNbTracks) || (nGoodParticles > fMaxNbTracks)) {
       PostData(1, fListHist);
       return;
@@ -658,7 +688,7 @@ void AliTRDCalibTask::UserExec(Option_t *)
   Int_t nbtrackTPC = 0;
   
 
-  
+
   if (nbTracks <= 0.0) {
     
     if(fDebug > 1) {
@@ -669,8 +699,8 @@ void AliTRDCalibTask::UserExec(Option_t *)
     PostData(1, fListHist);
     return;
   }
-  
-  
+
+
   fESDfriend = dynamic_cast<AliESDfriend*> (fESD->FindListObject("AliESDfriend"));
   if(!fESDfriend){
     AliError("fESDfriend not available");
@@ -682,7 +712,7 @@ void AliTRDCalibTask::UserExec(Option_t *)
     PostData(1, fListHist);
     return;
   }
-  
+
   //printf("has friends\n");
 
   /////////////////////////////////////
@@ -748,7 +778,7 @@ void AliTRDCalibTask::UserExec(Option_t *)
       //printf("Not a good track\n");
       continue;
     }
-    
+
     // First Absolute gain calibration
     Int_t trdNTracklets = (Int_t) fkEsdTrack->GetTRDntracklets();
     Int_t trdNTrackletsPID = (Int_t) fkEsdTrack->GetTRDntrackletsPID(); 
@@ -770,12 +800,19 @@ void AliTRDCalibTask::UserExec(Option_t *)
 
     if(good && fOnInstance) {
       //cout << "good" << endl;
-      fTRDCalibraFillHisto->UpdateHistogramsV1(fTrdTrack);
+      fTRDCalibraFillHisto->UpdateHistogramsV1(fTrdTrack,fkEsdTrack);
       //printf("Fill fTRDCalibraFillHisto\n");
     }
-      
-      
-         
+
+    if(IsPHQon()){
+      const Double_t mag = AliTRDdEdxBaseUtils::IsExBOn() ? fESD->GetMagneticField() : -1;
+      const Int_t charge = AliTRDdEdxBaseUtils::IsExBOn() ? fkEsdTrack->Charge() : -1;
+      const Double_t toTPCscale = AliTRDdEdxCalibUtils::GetCalibTPCscale(fkEsdTrack->GetTPCncls(), fkEsdTrack->GetTPCsignal());
+      if(toTPCscale>0){
+        AliTRDdEdxCalibUtils::FillHist(fTrdTrack, 0, mag, charge, toTPCscale);
+      }
+    }
+
     //////////////////////////////////
     // Debug 
     ////////////////////////////////
@@ -796,7 +833,7 @@ void AliTRDCalibTask::UserExec(Option_t *)
       Double_t phtb[AliTRDseedV1::kNtb];
       memset(phtb, 0, AliTRDseedV1::kNtb*sizeof(Double_t));
       Double_t sum = 0.0;
-      Float_t normalisation = 6.67;
+      Float_t normalisation = 1.13;
       Int_t detector = 0;
       Int_t sector = 0;
       for(Int_t itr = 0; itr < 6; ++itr){
@@ -828,7 +865,8 @@ void AliTRDCalibTask::UserExec(Option_t *)
          if(!(fCl = tracklet->GetClusters(ic))) continue;
          ++nbclusters;
          time = fCl->GetPadTime();
-         ch =  tracklet->GetdQdl(ic);
+         //ch =  tracklet->GetdQdl(ic);
+         ch =  tracklet->GetQperTB(ic);
          qcl = TMath::Abs(fCl->GetQ());
          detector = fCl->GetDetector();          
          // Add the charge if shared cluster
@@ -1313,7 +1351,7 @@ Bool_t AliTRDCalibTask::SetVersionSubversion(){
   // Load Chamber Gain factors into the Tender supply
   //
   
-  printf("SetVersionSubversion\n");
+  //printf("SetVersionSubversion\n");
 
   //find previous entry from the UserInfo
   TTree *tree=((TChain*)GetInputData(0))->GetTree();
@@ -1356,12 +1394,13 @@ Bool_t AliTRDCalibTask::SetVersionSubversion(){
       fFirstRunGainLocal = id->GetFirstRun();
       fVersionGainLocalUsed = id->GetVersion();
       fSubVersionGainLocalUsed = id->GetSubVersion();
-    } else if(os->GetString().Contains("TRD/Calib/ChamberExB")){
+    } else if((os->GetString().Contains("TRD/Calib/ChamberExB")) && (!os->GetString().Contains("TRD/Calib/ChamberExBAlt"))){
       // Get Old drift velocity calibration
       AliCDBId *id=AliCDBId::MakeFromString(os->GetString());
       fFirstRunExB = id->GetFirstRun();
       fVersionExBUsed = id->GetVersion();
       fSubVersionExBUsed = id->GetSubVersion();
+      //printf("Version %d and subversion %d\n",fVersionExBUsed,fSubVersionExBUsed);
     }
   }