]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDCalibTask.cxx
minor code cleanup and coding rules
[u/mrichter/AliRoot.git] / TRD / AliTRDCalibTask.cxx
index 7e4f6cc47a2c4552856f1051f8ec67b0e9c85bc8..6df00b04cf061acfee53486491b8c5ce13c066db 100644 (file)
@@ -78,6 +78,7 @@ using namespace std;
 #include "AliLog.h"
 
 #include "AliTRDCalibChamberStatus.h"
+#include "AliTRDdEdxUtils.h"
 
 #include "AliTRDCalibTask.h"
 
@@ -87,7 +88,6 @@ ClassImp(AliTRDCalibTask)
 //________________________________________________________________________
   AliTRDCalibTask::AliTRDCalibTask(const char *name) 
     : AliAnalysisTaskSE(name), fESD(0),
-      fESDfriend(0),
       fkEsdTrack(0),
       fFriendTrack(0),
       fCalibObject(0),
@@ -125,7 +125,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 +138,10 @@ ClassImp(AliTRDCalibTask)
       fMinNbContributors(0),
       fRangePrimaryVertexZ(9999999.0),
       fMinNbTracks(9),
-      fMaxNbTracks(500),
+      fMaxNbTracks(999999999),
+      fCutWithVdriftCalib(kFALSE),
+      fMinNbTRDtracklets(0),
+      fMinTRDMomentum(0),
       fLow(0),
       fHigh(30),
       fFillZero(kFALSE),
@@ -159,8 +165,7 @@ ClassImp(AliTRDCalibTask)
       fSubVersionExBUsed(-1),
       fCalDetGain(0x0),
       fMaxEvent(0),
-      fCounter(0),
-      fDebug(0)
+      fCounter(0)
 {
   //
   // Default constructor
@@ -174,6 +179,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 +221,7 @@ AliTRDCalibTask::~AliTRDCalibTask()
   if(fCH2dTest) delete fCH2dTest;
   if(fPH2dTest) delete fPH2dTest;
   if(fLinearVdriftTest) delete fLinearVdriftTest;
+  AliTRDdEdxUtils::DeleteCalibHist();
   if(fCalDetGain) delete fCalDetGain;
   
   if(fSelectedTrigger) {
@@ -259,6 +266,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
@@ -295,7 +306,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 +342,8 @@ void AliTRDCalibTask::UserCreateOutputObjects()
   fAbsoluteGain->Sumw2();
   fListHist->Add(fAbsoluteGain);
   
+  AliTRDdEdxUtils::PrintControl();
+  AliTRDdEdxUtils::IniCalibHist(fListHist, kTRUE);
   /////////////////////////////////////////
   // First debug level
   ///////////////////////////////////////
@@ -552,13 +565,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 +651,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 +673,7 @@ void AliTRDCalibTask::UserExec(Option_t *)
   Int_t nbtrackTPC = 0;
   
 
-  
+
   if (nbTracks <= 0.0) {
     
     if(fDebug > 1) {
@@ -669,8 +684,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 +697,7 @@ void AliTRDCalibTask::UserExec(Option_t *)
     PostData(1, fListHist);
     return;
   }
-  
+
   //printf("has friends\n");
 
   /////////////////////////////////////
@@ -748,7 +763,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 +785,17 @@ void AliTRDCalibTask::UserExec(Option_t *)
 
     if(good && fOnInstance) {
       //cout << "good" << endl;
-      fTRDCalibraFillHisto->UpdateHistogramsV1(fTrdTrack);
+      fTRDCalibraFillHisto->UpdateHistogramsV1(fTrdTrack,fkEsdTrack);
       //printf("Fill fTRDCalibraFillHisto\n");
     }
-      
-      
-         
+
+    const Double_t mag = AliTRDdEdxUtils::IsExBOn() ? fESD->GetMagneticField() : -1;
+    const Int_t charge = AliTRDdEdxUtils::IsExBOn() ? fkEsdTrack->Charge() : -1;
+    const Double_t toTPCscale = AliTRDdEdxUtils::GetCalibTPCscale(fkEsdTrack->GetTPCncls(), fkEsdTrack->GetTPCsignal());
+    if(toTPCscale>0){
+      AliTRDdEdxUtils::FillCalibHist(fTrdTrack, 0, mag, charge, toTPCscale);
+    }
+
     //////////////////////////////////
     // Debug 
     ////////////////////////////////
@@ -796,7 +816,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 +848,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 +1334,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 +1377,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);
     }
   }