]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDtracker.cxx
Fix a bug in getting a TOF volume path (in case of holes for PHOS)
[u/mrichter/AliRoot.git] / TRD / AliTRDtracker.cxx
index c7628e3839136ea6c1ef0451e17ec3fb46bc7147..9efdabc4de9ea76068c72b4a84c9c459c6f1c38b 100644 (file)
 
 
 #include <Riostream.h>
-#include <TFile.h>
 #include <TBranch.h>
-#include <TTree.h>  
-#include <TObjArray.h> 
-#include <TTreeStream.h>
+#include <TFile.h>
 #include <TGraph.h>
-#include <TLinearFitter.h>
 #include <TH1D.h>
 #include <TH2D.h>
+#include <TLinearFitter.h>
+#include <TObjArray.h> 
+#include <TROOT.h>
+#include <TTree.h>  
+#include <TTreeStream.h>
 
 #include "AliESD.h"
 #include "AliAlignObj.h"
@@ -53,7 +54,8 @@
 #include "AliTRDCommonParam.h"
 #include "AliTRDtracker.h"
 #include "AliTRDReconstructor.h"
-#include "AliTRDCalibra.h"
+#include "AliTRDCalibraFillHisto.h"
+
 ClassImp(AliTRDtracker)
 
 const  Float_t  AliTRDtracker::fgkMinClustersInTrack =  0.5;  
@@ -191,7 +193,7 @@ AliTRDtracker::AliTRDtracker(const TFile *geomfile)
   savedir->cd();  
 
   for (Int_t geomS = 0; geomS < kTrackingSectors; geomS++) {
-    Int_t trS   = CookSectorIndex(geomS);
+    Int_t trS   = geomS;
     fTrSec[trS] = new AliTRDtrackingSector(fGeom,geomS);
     for (Int_t icham = 0; icham < AliTRDgeometry::kNcham; icham++) {
       fHoles[icham][trS] = fGeom->IsHole(0,icham,geomS);
@@ -204,7 +206,10 @@ AliTRDtracker::AliTRDtracker(const TFile *geomfile)
     fNoTilt = kTRUE;
   }
 
-  fTimeBinsPerPlane =  AliTRDcalibDB::Instance()->GetNumberOfTimeBins();
+  if (!AliTRDcalibDB::Instance()) {
+    AliFatal("Could not get calibration object");
+  }
+  fTimeBinsPerPlane = AliTRDcalibDB::Instance()->GetNumberOfTimeBins();
 
   fDebugStreamer    = new TTreeSRedirector("TRDdebug.root");
 
@@ -374,9 +379,9 @@ Bool_t  AliTRDtracker::Transform(AliTRDcluster *cluster)
 
   cluster->SetY(cluster->GetY() - driftX*exB);
   Double_t xplane = (Double_t) AliTRDgeometry::GetTime0(plane); 
-  cluster->SetX(xplane- cluster->GetX());
+  cluster->SetX(xplane - cluster->GetX());
 
-  TGeoHMatrix *matrix =  fGeom->GetCorrectionMatrix(cluster->GetDetector());
+  TGeoHMatrix *matrix = fGeom->GetCorrectionMatrix(cluster->GetDetector());
   if (!matrix) {
     // No matrix found - if somebody used geometry with holes
     AliError("Invalid Geometry - Default Geometry used\n");
@@ -399,7 +404,7 @@ Bool_t  AliTRDtracker::Transform(AliTRDcluster *cluster)
   }
 
   if (plane == 5) {
-     cluster->SetX(localPosTracker[0]+kX0shift5);
+    cluster->SetX(localPosTracker[0]+kX0shift5);
   }
   else {
     cluster->SetX(localPosTracker[0]+kX0shift);
@@ -790,11 +795,11 @@ Int_t AliTRDtracker::PropagateBack(AliESD *event)
     /**/
     // Debug part of tracking
     TTreeSRedirector &cstream = *fDebugStreamer;
-    Int_t eventNr = event->GetEventNumber();
+    Int_t eventNrInFile = event->GetEventNumberInFile(); // This is most likely NOT the event number you'd like to use. It has nothing to do with the 'real' event number.
     if (AliTRDReconstructor::StreamLevel() > 0) {
       if (track->GetBackupTrack()) {
        cstream << "Tracks"
-               << "EventNr="  << eventNr
+               << "EventNrInFile="  << eventNrInFile
                << "ESD.="     << seed
                << "trd.="     << track
                << "trdback.=" << track->GetBackupTrack()
@@ -802,7 +807,7 @@ Int_t AliTRDtracker::PropagateBack(AliESD *event)
       }
       else {
        cstream << "Tracks"
-               << "EventNr="  << eventNr
+               << "EventNrInFile="  << eventNrInFile
                << "ESD.="     << seed
                << "trd.="     << track
                << "trdback.=" << track
@@ -1213,7 +1218,7 @@ Int_t AliTRDtracker::FollowBackProlongation(AliTRDtrack &t)
   AliTRDtracklet tracklet;
 
   // Calibration fill 2D
-  AliTRDCalibra *calibra = AliTRDCalibra::Instance();
+  AliTRDCalibraFillHisto *calibra = AliTRDCalibraFillHisto::Instance();
   if (!calibra) {
     AliInfo("Could not get Calibra instance\n");
   }
@@ -1456,7 +1461,7 @@ Int_t AliTRDtracker::LoadClusters(TTree *cTree)
     Int_t localTimeBin   = c->GetLocalTimeBin();
     Int_t sector         = fGeom->GetSector(detector);
     Int_t plane          = fGeom->GetPlane(detector);
-    Int_t trackingSector = CookSectorIndex(sector);
+    Int_t trackingSector = sector;
 
     //if (c->GetLabel(0) > 0) {
     if (c->GetQ() > 10) {
@@ -2623,7 +2628,7 @@ void AliTRDtracker::MakeSeedsMI(Int_t /*inner*/, Int_t /*outer*/, AliESD *esd)
          }
        }
 
-       Int_t eventNr = esd->GetEventNumber();
+       Int_t eventNrInFile = esd->GetEventNumberInFile(); // This is most likely NOT the event number you'd like to use. It has nothing to do with the 'real' event number.
        TTreeSRedirector &cstream = *fDebugStreamer;
 
        //
@@ -2642,7 +2647,7 @@ void AliTRDtracker::MakeSeedsMI(Int_t /*inner*/, Int_t /*outer*/, AliESD *esd)
          TTreeSRedirector &cstream = *fDebugStreamer;
          if (AliTRDReconstructor::StreamLevel() > 0) {
            cstream << "Tracks"
-                   << "EventNr="  << eventNr
+                   << "EventNrInFile="  << eventNrInFile
                    << "ESD.="     << &esdtrack
                    << "trd.="     << track
                    << "trdback.=" << track
@@ -2672,7 +2677,7 @@ void AliTRDtracker::MakeSeedsMI(Int_t /*inner*/, Int_t /*outer*/, AliESD *esd)
                  << "Findable="  << findable
                  << "NUsed="     << nused
                  << "sLayer="    << sLayer
-                 << "EventNr="   << eventNr
+                 << "EventNrInFile="   << eventNrInFile
                  << "\n";
        }
 
@@ -3061,7 +3066,7 @@ AliTRDtracker::AliTRDtrackingSector
     }
 
     dx        = AliTRDcalibDB::Instance()->GetVdrift(0,0,0)
-              / AliTRDcalibDB::Instance()->GetSamplingFrequency();
+              / commonParam->GetSamplingFrequency();
     rho       = 0.00295 * 0.85; //????
     radLength = 11.0;  
 
@@ -3463,48 +3468,65 @@ Double_t AliTRDtracker::GetTiltFactor(const AliTRDcluster *c)
 void AliTRDtracker::CookdEdxTimBin(AliTRDtrack &TRDtrack)
 {
   //
-  // This is setting fdEdxPlane and fTimBinPlane
-  // Sums up the charge in each plane for track TRDtrack and also get the 
-  // Time bin for Max. Cluster
-  // Prashant Shukla (shukla@physi.uni-heidelberg.de)
+  // Build the information needed for TRD PID calculations. This are:
+  // - dE/dx - total
+  // - dE/dx - slices (0-14, 15-22, NONE). The Edep per slice is
+  //    calculated as the sum of clusters charge weighted with average
+  //    value from the <PH> spectrum
+  // - Time bin for Max. Cluster
   //
+  // Authors:
+  // Prashant Shukla (shukla@physi.uni-heidelberg.de)
+  // Alex Bercuci (a.bercuci@gsi.de)
 
   Double_t  clscharge[AliESDtrack::kNPlane][AliESDtrack::kNSlice];
   Double_t  maxclscharge[AliESDtrack::kNPlane];
   Int_t     nCluster[AliESDtrack::kNPlane][AliESDtrack::kNSlice];
   Int_t     timebin[AliESDtrack::kNPlane];
 
-  // Initialization of cluster charge per plane.  
+  // Initialization of variables  
   for (Int_t iPlane = 0; iPlane < AliESDtrack::kNPlane; iPlane++) {
     for (Int_t iSlice = 0; iSlice < AliESDtrack::kNSlice; iSlice++) {
-      clscharge[iPlane][iSlice] = 0.0;
+      clscharge[iPlane][iSlice] = 0.;
       nCluster[iPlane][iSlice]  = 0;
     }
-  }
-
-  // Initialization of cluster charge per plane.  
-  for (Int_t iPlane = 0; iPlane < AliESDtrack::kNPlane; iPlane++) {
     timebin[iPlane]      =  -1;
     maxclscharge[iPlane] = 0.0;
   }
 
+       // Average PH spectrum used for weighting the edep. It has to
+       // come eather from caligration DB or as parameter of the class. To
+       // be discuss with software responsibles
+       const Float_t fAveragePH[] = { 5.010e-03, 2.017e-02, 6.221e-02, 6.706e-02
+                                     , 5.551e-02, 4.812e-02, 4.395e-02, 4.219e-02
+                                     , 4.172e-02, 4.156e-02, 4.162e-02, 4.204e-02
+                                     , 4.278e-02, 4.367e-02, 4.460e-02, 4.554e-02
+                                     , 4.674e-02, 4.810e-02, 5.005e-02, 5.258e-02
+                                     , 5.587e-02, 5.892e-02, 5.587e-02, 5.258e-02 };
+       
   // Loop through all clusters associated to track TRDtrack
-  Int_t nClus = TRDtrack.GetNumberOfClusters();  // from Kalmantrack
-  for (Int_t iClus = 0; iClus < nClus; iClus++) {
+  AliTRDcluster *pTRDcluster = 0x0;
+  for (Int_t iClus = 0; iClus < TRDtrack.GetNumberOfClusters(); iClus++) {
     Double_t charge = TRDtrack.GetClusterdQdl(iClus);
     Int_t    index  = TRDtrack.GetClusterIndex(iClus);
-    AliTRDcluster *pTRDcluster = (AliTRDcluster *) GetCluster(index); 
-    if (!pTRDcluster) {
-      continue;
-    }
-    Int_t    tb     = pTRDcluster->GetLocalTimeBin();
-    if (!tb) {
-      continue;
-    }
+    if (!(pTRDcluster = (AliTRDcluster*)GetCluster(index))) continue;
+    
+               // check negative time bins ?!?!?
+               Int_t    tb     = pTRDcluster->GetLocalTimeBin();
+
+               // temporary until fix in GetT0
+               if(tb<0){
+                       Warning("CookdEdxTimBin()", Form("Negative time bin value in track %d cluster %d", TRDtrack.GetLabel(), iClus));
+                       continue;
+               }
+               
     Int_t detector  = pTRDcluster->GetDetector();
     Int_t iPlane    = fGeom->GetPlane(detector);
-    Int_t iSlice    = tb * AliESDtrack::kNSlice / AliTRDtrack::kNtimeBins;
-    clscharge[iPlane][iSlice] = clscharge[iPlane][iSlice] + charge;
+
+               // 2 slices method
+               Int_t iSlice = (tb < AliTRDtrack::kMidTimeBin) ? 0 : 1;
+               // weighted edep with <PH>
+               clscharge[iPlane][iSlice] += charge * fAveragePH[tb];
     if (charge > maxclscharge[iPlane]) {
       maxclscharge[iPlane] = charge;
       timebin[iPlane]      = tb;
@@ -3512,31 +3534,18 @@ void AliTRDtracker::CookdEdxTimBin(AliTRDtrack &TRDtrack)
     nCluster[iPlane][iSlice]++;
   } // End of loop over cluster
 
-  // Setting the fdEdxPlane and fTimBinPlane variabales 
-  Double_t totalCharge = 0.0;
-
+  // Setting the fdEdxPlane and fTimBinPlane variables
+  Double_t totalCharge = 0.;
   for (Int_t iPlane = 0; iPlane < AliESDtrack::kNPlane; iPlane++) {
-    for (Int_t iSlice = 0; iSlice < AliESDtrack::kNSlice; iSlice++) {
-      if (nCluster[iPlane][iSlice]) {
-        clscharge[iPlane][iSlice] /= nCluster[iPlane][iSlice];
-      }
+               for (Int_t iSlice = 0; iSlice < AliESDtrack::kNSlice; iSlice++) {
+      //if (nCluster[iPlane][iSlice]) {
+      //  clscharge[iPlane][iSlice] /= nCluster[iPlane][iSlice];
+      //}
       TRDtrack.SetPIDsignals(clscharge[iPlane][iSlice],iPlane,iSlice);
-      totalCharge = totalCharge+clscharge[iPlane][iSlice];
+      totalCharge += clscharge[iPlane][iSlice];
     }
-    TRDtrack.SetPIDTimBin(timebin[iPlane],iPlane);     
+    TRDtrack.SetPIDTimBin(timebin[iPlane],iPlane);
   }
-
-  // Still needed ????
-  //  Int_t i;
-  //  Int_t nc=TRDtrack.GetNumberOfClusters(); 
-  //  Float_t dedx=0;
-  //  for (i=0; i<nc; i++) dedx += TRDtrack.GetClusterdQdl(i);
-  //  dedx /= nc;
-  //  for (Int_t iPlane = 0; iPlane < kNPlane; iPlane++) {
-  //    TRDtrack.SetPIDsignals(dedx, iPlane);
-  //    TRDtrack.SetPIDTimBin(timbin[iPlane], iPlane);
-  //  }
-
 }
 
 //_____________________________________________________________________________