]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCcalibTimeGain.cxx
reco update
[u/mrichter/AliRoot.git] / TPC / AliTPCcalibTimeGain.cxx
index e03c9c5a67d92ac6222b9c4c00e8c27e8be1d2ed..a32e33b815d89c4190f0cc65529812dfcd9a5c95 100644 (file)
@@ -164,6 +164,7 @@ TGaxis *axis = new TGaxis(xmax,ymin,xmax,ymax,ymin,ymax,50510,"+L");
 #include "AliTracker.h"
 #include "AliMagF.h"
 #include "AliTPCCalROC.h"
+#include "AliESDv0.h"
 
 #include "AliLog.h"
 
@@ -179,6 +180,7 @@ TGaxis *axis = new TGaxis(xmax,ymin,xmax,ymax,ymin,ymax,50510,"+L");
 
 ClassImp(AliTPCcalibTimeGain)
 
+Double_t AliTPCcalibTimeGain::fgMergeEntriesCut=10000000.;
 
 AliTPCcalibTimeGain::AliTPCcalibTimeGain() 
   :AliTPCcalibBase(), 
@@ -200,7 +202,7 @@ AliTPCcalibTimeGain::AliTPCcalibTimeGain()
   //
   // Default constructor
   //
-  AliInfo("Default Constructor");  
+  AliDebug(5,"Default Constructor");  
 }
 
 
@@ -227,19 +229,19 @@ AliTPCcalibTimeGain::AliTPCcalibTimeGain(const Text_t *name, const Text_t *title
   SetName(name);
   SetTitle(title);
   
-  AliInfo("Non Default Constructor");
+  AliDebug(5,"Non Default Constructor");
   
   fIntegrationTimeDeDx = deltaIntegrationTimeGain;
   
   Double_t deltaTime = EndTime - StartTime;
   
   
-  // main histogram for time dependence: dE/dx, time, type (1-muon cosmic,2-pion beam data), meanDriftlength, momenta (only filled if enough space is available), run number
+  // main histogram for time dependence: dE/dx, time, type (1-muon cosmic,2-pion beam data, 3&4 - proton points at higher dE/dx), meanDriftlength, momenta (only filled if enough space is available), run number, eta
   Int_t timeBins = TMath::Nint(deltaTime/deltaIntegrationTimeGain);
-  Int_t binsGainTime[6]    = {150,  timeBins,    2,  25, 200, 10000000};
-  Double_t xminGainTime[6] = {0.5, StartTime,  0.5,   0, 0.1,    -0.5};
-  Double_t xmaxGainTime[6] = {  8,   EndTime,  2.5, 250,  50, 9999999.5};
-  fHistGainTime = new THnSparseF("HistGainTime","dEdx time dep.;dEdx,time,type,driftlength,momenta,run number;dEdx",6,binsGainTime,xminGainTime,xmaxGainTime);
+  Int_t binsGainTime[7]    = {150,  timeBins,    4,  25, 200, 10000000, 20};
+  Double_t xminGainTime[7] = {0.5, StartTime,  0.5,   0, 0.1,    -0.5,  -1};
+  Double_t xmaxGainTime[7] = {  8,   EndTime,  4.5, 250,  50, 9999999.5, 1};
+  fHistGainTime = new THnSparseF("HistGainTime","dEdx time dep.;dEdx,time,type,driftlength,momenta,run number, eta;dEdx",7,binsGainTime,xminGainTime,xmaxGainTime);
   BinLogX(fHistGainTime, 4);
   //
   fHistDeDxTotal = new TH2F("DeDx","dEdx; momentum p (GeV); TPC signal (a.u.)",250,0.01,100.,1000,0.,8);
@@ -248,8 +250,8 @@ AliTPCcalibTimeGain::AliTPCcalibTimeGain(const Text_t *name, const Text_t *title
   // default values for dE/dx
   fMIP = 50.;
   fUseMax = kTRUE;
-  fLowerTrunc = 0.0;
-  fUpperTrunc = 0.7;
+  fLowerTrunc = 0.02;
+  fUpperTrunc = 0.6;
   fUseShapeNorm = kTRUE;
   fUsePosNorm = kFALSE;
   fUsePadNorm = kFALSE;
@@ -281,7 +283,12 @@ void AliTPCcalibTimeGain::Process(AliESDEvent *event) {
     Printf("ERROR: ESD not available");
     return;
   }
-  
+  AliESDfriend *ESDfriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
+  if (!ESDfriend) {
+   return;
+  }
+  if (ESDfriend->TestSkipBit()) return;
+
   if (fIsCosmic) { // this should be removed at some point based on trigger mask !?
     ProcessCosmicEvent(event);
   } else {
@@ -305,12 +312,12 @@ void AliTPCcalibTimeGain::ProcessCosmicEvent(AliESDEvent *event) {
   }
   //
   UInt_t time = event->GetTimeStamp();
-  Int_t ntracks = event->GetNumberOfTracks();
+  Int_t nFriendTracks = esdFriend->GetNumberOfTracks();
   Int_t runNumber = event->GetRunNumber();
   //
   // track loop
   //
-  for (Int_t i=0;i<ntracks;++i) {
+  for (Int_t i=0;i<nFriendTracks;++i) {
 
     AliESDtrack *track = event->GetTrack(i);
     if (!track) continue;
@@ -368,12 +375,12 @@ void AliTPCcalibTimeGain::ProcessBeamEvent(AliESDEvent *event) {
   }
   //
   UInt_t time = event->GetTimeStamp();
-  Int_t ntracks = event->GetNumberOfTracks();
+  Int_t nFriendTracks = esdFriend->GetNumberOfTracks();
   Int_t runNumber = event->GetRunNumber();
   //
   // track loop
   //
-  for (Int_t i=0;i<ntracks;++i) {
+  for (Int_t i=0;i<nFriendTracks;++i) { // begin track loop
 
     AliESDtrack *track = event->GetTrack(i);
     if (!track) continue;
@@ -392,8 +399,16 @@ void AliTPCcalibTimeGain::ProcessBeamEvent(AliESDEvent *event) {
 
     // exclude tracks which do not look like primaries or are simply too short or on wrong sectors
     if (nclsDeDx < 60) continue;     
-    if (TMath::Abs(trackIn->GetTgl()) > 1) continue;
-    if (TMath::Abs(trackIn->GetSnp()) > 0.6) continue;
+    //if (TMath::Abs(trackIn->GetTgl()) > 1) continue;
+    //if (TMath::Abs(trackIn->GetSnp()) > 0.6) continue;
+    if (TMath::Abs(trackIn->Eta()) > 1) continue;
+    UInt_t status = track->GetStatus();
+    if ((status&AliESDtrack::kTPCrefit)==0) continue;
+    //if (track->GetNcls(0) < 3) continue; // ITS clusters
+    Float_t dca[2], cov[3];
+    track->GetImpactParameters(dca,cov);
+    if (TMath::Abs(dca[0]) > 7 || TMath::Abs(dca[0]) < 0.0000001 || TMath::Abs(dca[1]) > 25 ) continue; // cut in xy
+    Double_t eta = trackIn->Eta();
     
     // Get seeds
     TObject *calibObject;
@@ -402,19 +417,70 @@ void AliTPCcalibTimeGain::ProcessBeamEvent(AliESDEvent *event) {
       if ((seed=dynamic_cast<AliTPCseed*>(calibObject))) break;
     }    
 
-    if (seed) { 
-      if (fLowMemoryConsumption) {
-       if (meanP > 0.5 || meanP < 0.4) continue;
-       meanP = 0.45; // set all momenta to one in order to save memory
-      }
+    if (seed) {
+      Int_t particleCase = 0;
+      if (meanP < 0.5  && meanP > 0.4)  particleCase = 2; // MIP pions
+      if (meanP < 0.57 && meanP > 0.56) particleCase = 3; // protons 1
+      if (meanP < 0.66 && meanP > 0.65) particleCase = 4; // protons 2
+      //
+      if (fLowMemoryConsumption && particleCase == 0) continue;
+      //
       Double_t tpcSignal = GetTPCdEdx(seed);
       fHistDeDxTotal->Fill(meanP, tpcSignal);
       //
-      //dE/dx, time, type (1-muon cosmic,2-pion beam data), momenta
-      Double_t vec[6] = {tpcSignal,time,2,meanDrift,meanP,runNumber};
+      //dE/dx, time, type (1-muon cosmic,2-pion beam data, 3&4 protons), momenta, runNumner, eta
+      Double_t vec[7] = {tpcSignal,time,particleCase,meanDrift,meanP,runNumber, eta};
       fHistGainTime->Fill(vec);
     }
     
+  } // end track loop
+  //
+  // V0 loop -- in beam events the cosmic part of the histogram is filled with GammaConversions
+  //
+  for(Int_t iv0 = 0; iv0 < event->GetNumberOfV0s(); iv0++) {
+    AliESDv0 * v0 = event->GetV0(iv0);
+    if (!v0->GetOnFlyStatus()) continue;
+    if (v0->GetEffMass(0,0) > 0.02) continue; // select low inv. mass
+    Double_t xyz[3];
+    v0->GetXYZ(xyz[0], xyz[1], xyz[2]);
+    if (TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]) < 3 || TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]) > 30) continue;
+    //
+    // "loop over daughters" 
+    //
+    for(Int_t idaughter = 0; idaughter < 2; idaughter++) { // daughter loop
+      Int_t index = idaughter == 0 ? v0->GetPindex() : v0->GetNindex();
+      AliESDtrack * trackP = event->GetTrack(index);
+      AliESDfriendTrack *friendTrackP = esdFriend->GetTrack(index);
+      if (!friendTrackP) continue;
+      const AliExternalTrackParam * trackPIn = trackP->GetInnerParam();
+      const AliExternalTrackParam * trackPOut = friendTrackP->GetTPCOut();
+      if (!trackPIn) continue;
+      if (!trackPOut) continue;
+      // calculate necessary track parameters
+      Double_t meanP = trackPIn->GetP();
+      Double_t meanDrift = 250 - 0.5*TMath::Abs(trackPIn->GetZ() + trackPOut->GetZ());
+      Int_t nclsDeDx = trackP->GetTPCNcls();
+      // exclude tracks which do not look like primaries or are simply too short or on wrong sectors
+      if (nclsDeDx < 60) continue;     
+      if (TMath::Abs(trackPIn->GetTgl()) > 1) continue;
+      //
+      TObject *calibObject;
+      AliTPCseed *seed = 0;
+      for (Int_t l=0;(calibObject=friendTrackP->GetCalibObject(l));++l) {
+      if ((seed=dynamic_cast<AliTPCseed*>(calibObject))) break;
+      }    
+      if (seed) { 
+       if (fLowMemoryConsumption) {
+         if (meanP > 0.5 || meanP < 0.4) continue;
+         meanP = 0.45; // set all momenta to one in order to save memory
+      }
+       Double_t tpcSignal = GetTPCdEdx(seed);
+       //dE/dx, time, type (1-muon cosmic,2-pion beam data), momenta
+       Double_t vec[6] = {tpcSignal,time,1,meanDrift,meanP,runNumber};
+       fHistGainTime->Fill(vec);
+      }
+    }
+    
   }
 
 }
@@ -485,11 +551,23 @@ Long64_t AliTPCcalibTimeGain::Merge(TCollection *li) {
     }
 
     // add histograms here...
-    if (cal->GetHistGainTime()) fHistGainTime->Add(cal->GetHistGainTime());
+    if (cal->GetHistGainTime() && fHistGainTime ) 
+    {
+      if ((fHistGainTime->GetEntries() + cal->GetHistGainTime()->GetEntries()) < fgMergeEntriesCut) 
+      {
+        //AliInfo(Form("fHistGainTime has %.0f tracks, going to add %.0f\n",fHistGainTime->GetEntries(),cal->GetHistGainTime()->GetEntries()));
+        fHistGainTime->Add(cal->GetHistGainTime());
+      }
+      else
+      {
+        AliInfo(Form("fHistGainTime full (has %.0f merged tracks, max allowed: %.0f)",fHistGainTime->GetEntries(),fgMergeEntriesCut));
+      }
+    }
+
     if (cal->GetHistDeDxTotal()) fHistDeDxTotal->Add(cal->GetHistDeDxTotal());
 
   }
-  
+  delete iter;
   return 0;
   
 }
@@ -583,7 +661,7 @@ void AliTPCcalibTimeGain::BinLogX(THnSparse *h, Int_t axisDim) {
    newBins[i] = factor * newBins[i-1];
   }
   axis->Set(bins, newBins);
-  delete newBins;
+  delete[] newBins;
   
 }
 
@@ -606,7 +684,7 @@ void AliTPCcalibTimeGain::BinLogX(TH1 *h) {
    newBins[i] = factor * newBins[i-1];
   }
   axis->Set(bins, newBins);
-  delete newBins;
+  delete[] newBins;
   
 }