Updates on PID by Alexandru
authorcblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 25 Jun 2007 12:02:44 +0000 (12:02 +0000)
committercblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 25 Jun 2007 12:02:44 +0000 (12:02 +0000)
TRD/AliTRDRawStream.cxx
TRD/AliTRDgeometry.cxx
TRD/AliTRDgeometry.h
TRD/AliTRDgtuTrack.cxx
TRD/AliTRDpidESD.cxx
TRD/AliTRDpidESD.h
TRD/AliTRDtrack.cxx
TRD/Cal/AliTRDCalPIDLQ.cxx
TRD/Cal/AliTRDCalPIDLQ.h

index cf249cc..5b65761 100644 (file)
@@ -422,7 +422,6 @@ Bool_t AliTRDRawStream::Next()
   while (fNextStatus != fkStop)
     { // !fkStop
       NextData();
-            
       if (fNextStatus == fkNextMCM || fNextStatus == fkNextData)
        {
          fHCdataCtr += 4;
index f451be9..fe5eefe 100644 (file)
@@ -1606,7 +1606,7 @@ Int_t AliTRDgeometry::GetDetector(Int_t p, Int_t c, Int_t s)
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDgeometry::GetPlane(Int_t d) const
+Int_t AliTRDgeometry::GetPlane(Int_t d)
 {
   //
   // Reconstruct the plane number from the detector number
index 2c6e626..0fc1eb8 100644 (file)
@@ -54,7 +54,7 @@ class AliTRDgeometry : public AliGeometry {
 
   static  Int_t    GetDetectorSec(Int_t p, Int_t c);
   static  Int_t    GetDetector(Int_t p, Int_t c, Int_t s);
-  virtual Int_t    GetPlane(Int_t d) const;
+  static  Int_t    GetPlane(Int_t d);
   virtual Int_t    GetChamber(Int_t d) const;
   virtual Int_t    GetSector(Int_t d) const;
 
index dad3d16..e08f09b 100644 (file)
@@ -451,9 +451,10 @@ void AliTRDgtuTrack::MakePID()
                // A.Bercuci on 2nd May 2007
                // Temporary modification to deal with more energy slices. The values
                // attached to charge slices and track length are dummy
-               Double_t dedx[3];
-               dedx[0] = dedx[1] = q*3.; dedx[2] = 0.;
-               Double_t length = 3.7;
+                Float_t dedx[3];
+                dedx[0] = dedx[1] = q*3.; dedx[2] = 0.;
+                Float_t length = 3.7;
+
     probEle *= pd->GetProbability(0, TMath::Abs(fPt), dedx, length);
     probPio *= pd->GetProbability(2, TMath::Abs(fPt), dedx, length);
 
index fb255d8..4442cf7 100644 (file)
@@ -34,6 +34,7 @@
 #include "AliLog.h"
 #include "AliESD.h"
 #include "AliESDtrack.h"
+#include "AliTracker.h"
 
 #include "AliTRDpidESD.h"
 #include "AliTRDgeometry.h"
@@ -42,6 +43,7 @@
 #include "AliTRDtrack.h"
 #include "Cal/AliTRDCalPIDLQ.h"
 
+
 ClassImp(AliTRDpidESD)
 
   Bool_t AliTRDpidESD::fCheckTrackStatus = kTRUE;
@@ -50,7 +52,7 @@ ClassImp(AliTRDpidESD)
 
 //_____________________________________________________________________________
 AliTRDpidESD::AliTRDpidESD()
-  :TObject()
+  :TObject(), fTrack(0x0)
 {
   //
   // Default constructor
@@ -60,7 +62,7 @@ AliTRDpidESD::AliTRDpidESD()
 
 //_____________________________________________________________________________
 AliTRDpidESD::AliTRDpidESD(const AliTRDpidESD &p)
-  :TObject(p)
+  :TObject(p), fTrack(0x0)
 {
   //
   // AliTRDpidESD copy constructor
@@ -71,6 +73,15 @@ AliTRDpidESD::AliTRDpidESD(const AliTRDpidESD &p)
 }
 
 //_____________________________________________________________________________
+AliTRDpidESD::~AliTRDpidESD()
+{
+  //
+  // Destructor
+  //
+       if(fTrack) delete fTrack;
+}
+
+//_____________________________________________________________________________
 AliTRDpidESD &AliTRDpidESD::operator=(const AliTRDpidESD &p)
 {
   //
@@ -92,7 +103,8 @@ void AliTRDpidESD::Copy(TObject &p) const
   ((AliTRDpidESD &) p).fCheckTrackStatus          = fCheckTrackStatus;
   ((AliTRDpidESD &) p).fCheckKinkStatus           = fCheckKinkStatus;
   ((AliTRDpidESD &) p).fMinPlane                  = fMinPlane;
-
+  ((AliTRDpidESD &) p).fTrack                     = 0x0;
+       
 }
 
 //_____________________________________________________________________________
@@ -125,29 +137,28 @@ Int_t AliTRDpidESD::MakePID(AliESD *event)
                return -1;
        }
 
-
        // Loop through all ESD tracks
        Double_t p[10];
        AliESDtrack *t = 0x0;
-       Double_t dedx[AliTRDtrack::kNslice], dEdx;
-       Int_t    timebin;
-       Float_t mom, length, probTotal;
-       Int_t nPlanePID;
+       Float_t dedx[AliTRDtrack::kNslice], dEdx;
+       Int_t   timebin;
+       Float_t mom, length;
+       Int_t   nPlanePID;
        for (Int_t i=0; i<event->GetNumberOfTracks(); i++) {
                t = event->GetTrack(i);
-
+               
                // Check track
                if(!CheckTrack(t)) continue;
+
                                                
                // Skip tracks which have no TRD signal at all
                if (t->GetTRDsignal() == 0.) continue;
        
                // Loop over detector layers
-               mom       = 0.; //t->GetP();
-               length    = 0.;
-               probTotal = 0.;
+               mom          = 0.;
+               length       = 0.;
                nPlanePID    = 0;
-               for (Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) p[iSpecies] = 1.;
+               for (Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) p[iSpecies] = 1./AliPID::kSPECIES;
                for (Int_t iPlan = 0; iPlan < AliTRDgeometry::kNplan; iPlan++) {
                        // read data for track segment
                        for(int iSlice=0; iSlice<AliTRDtrack::kNslice; iSlice++)
@@ -159,7 +170,7 @@ Int_t AliTRDpidESD::MakePID(AliESD *event)
                        if ((dEdx <=  0.) || (timebin <= -1.)) continue;
 
                        // retrive kinematic info for this track segment
-                       if(!GetTrackSegmentKine(t, iPlan, mom, length)) continue;
+                       if(!RecalculateTrackSegmentKine(t, iPlan, mom, length)) continue;
                        
                        // this track segment has fulfilled all requierments
                        nPlanePID++;
@@ -167,20 +178,24 @@ Int_t AliTRDpidESD::MakePID(AliESD *event)
                        // Get the probabilities for the different particle species
                        for (Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) {
                                p[iSpecies] *= pd->GetProbability(iSpecies, mom, dedx, length);
-                               p[iSpecies] *= pd->GetProbabilityT(iSpecies, mom, timebin);
-                               probTotal   += p[iSpecies];
+                               //p[iSpecies] *= pd->GetProbabilityT(iSpecies, mom, timebin);
                        }
                }
-
+               if(nPlanePID == 0) continue;
+               
                // normalize probabilities
-               if(probTotal > 0.)
-                       for (Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++)
-                               if(nPlanePID > fMinPlane) p[iSpecies] /= probTotal;
-                               else p[iSpecies] = 1.0;
-
+               Double_t probTotal = 0.;
+               for (Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) probTotal   += p[iSpecies];
+               if(probTotal <= 0.){
+                       AliWarningGeneral("AliTRDpidESD::MakePID()",
+                       Form("The total probability over all species <= 0 in ESD track %d. This may be caused by some error in reference data. Calculation continue but results might be corrupted.", i));
+                       continue;
+               }
+               for(Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) p[iSpecies] /= probTotal;
 
                // book PID to the track
                t->SetTRDpid(p);
+               t->SetTRDpidQuality(nPlanePID);
        }
        
        return 0;
@@ -206,53 +221,56 @@ Bool_t AliTRDpidESD::CheckTrack(AliESDtrack *t)
 }
 
 //_____________________________________________________________________________
-Bool_t AliTRDpidESD::GetTrackSegmentKine(AliESDtrack *t, Int_t plan, Float_t &mom, Float_t &length)
+Bool_t AliTRDpidESD::RecalculateTrackSegmentKine(AliESDtrack *esd, Int_t plan, Float_t &mom, Float_t &length)
 {
   //
   // Retrive momentum "mom" and track "length" in TRD chamber from plane
   // "plan" according to information stored in AliESDtrack "t".
-  // 
+  //
+  // Origin
+  // Alex Bercuci (A.Bercuci@gsi.de)   
 
-       if(!gAlice){
-               AliErrorGeneral("AliTRDpidESD::GetTrackSegmentKine()"
-               ,"No gAlice object to retrive TRDgeometry and Magnetic fied  - this has to be removed in the future.");
-               return kFALSE;
-       }
-       
-       // Retrieve TRD geometry -> Maybe there is a better way to do this
-       AliTRDgeometry trdGeom;
        const Float_t kAmHalfWidth = AliTRDgeometry::AmThick() / 2.;
         const Float_t kDrWidth     = AliTRDgeometry::DrThick();
-       
+       const Float_t kTime0       = AliTRDgeometry::GetTime0(plan);
 
-       // retrive the magnetic field
-       Double_t xyz0[3] = { 0., 0., 0.}, xyz1[3];
-       Double_t b[3], alpha;
-       gAlice->Field(xyz0,b);      // b[] is in kilo Gauss
-       Float_t field = b[2] * 0.1; // Tesla
+       // set initial length value to chamber height 
+       length = 2 * kAmHalfWidth + kDrWidth;
                
-       // find momentum at chamber entrance and track length in chamber
-       AliExternalTrackParam *param = (plan<3) ? new AliExternalTrackParam(*t->GetInnerParam()) : new AliExternalTrackParam(*t->GetOuterParam());
-
-       param->PropagateTo(trdGeom.GetTime0(plan)+kAmHalfWidth, field);
-       param->GetXYZ(xyz0);
-       alpha = param->GetAlpha();
-       param->PropagateTo(trdGeom.GetTime0(plan)-kAmHalfWidth-kDrWidth, field);
-       // eliminate track segments which are crossing SM boundaries along chamber
-       if(TMath::Abs(alpha-param->GetAlpha())>.01){
-               delete param;
+       // retrive track's outer param
+       const AliExternalTrackParam *op = esd->GetOuterParam();
+       if(!op){
+               mom    = esd->GetP();
                return kFALSE;
        }
-       param->GetXYZ(xyz1);
-       length = sqrt(
-               (xyz1[0]-xyz0[0])*(xyz1[0]-xyz0[0])+
-               (xyz1[1]-xyz0[1])*(xyz1[1]-xyz0[1])+
-               (xyz1[2]-xyz0[2])*(xyz1[2]-xyz0[2])
-       );
-       param->GetPxPyPz(xyz1);
-       mom = sqrt(xyz1[0]*xyz1[0] + xyz1[1]*xyz1[1] + xyz1[2]*xyz1[2]);
-       delete param;
 
+       AliExternalTrackParam *param = 0x0;
+       if(!fTrack){
+               fTrack = new AliExternalTrackParam(*op);
+               param = fTrack;
+       } else param = new(&fTrack) AliExternalTrackParam(*op);
+
+       // retrive the magnetic field
+       Double_t xyz0[3];
+       op->GetXYZ(xyz0);
+       Float_t field = AliTracker::GetBz(xyz0); // Bz in kG at point xyz0
+       // propagate to chamber entrance
+       if(!param->PropagateTo(kTime0-kAmHalfWidth-kDrWidth, field)){
+               mom = op->GetP();
+               return kFALSE;
+       }
+       mom        = param->GetP();
+       Double_t s = param->GetSnp();
+       Double_t t = param->GetTgl();
+       length    /= TMath::Sqrt((1. - s*s) / (1. - t*t));
+
+       // check if track is crossing tracking sector by propagating to chamber exit- maybe is too much :)
+       Double_t alpha = param->GetAlpha();
+       if(!param->PropagateTo(kTime0+kAmHalfWidth, field)) return kFALSE;
+               
+       // mark track segments which are crossing SM boundaries along chamber
+       if(TMath::Abs(alpha-param->GetAlpha())>.01) return kFALSE;
+       
        return kTRUE;
 }
 
index 0f29454..0d73b3a 100644 (file)
 
 class AliESD;
 class AliESDtrack;
+class AliExternalTrackParam;
 class AliTRDpidESD : public TObject {
 
  public:
 
   AliTRDpidESD();
   AliTRDpidESD(const AliTRDpidESD &p);
-  virtual ~AliTRDpidESD() {}
+  virtual ~AliTRDpidESD();
   AliTRDpidESD &operator=(const AliTRDpidESD &p);
 
   virtual void    Copy(TObject &p) const;
   static  Bool_t  CheckTrack(AliESDtrack *t);
-  static  Int_t   MakePID(AliESD *event);
+          Int_t   MakePID(AliESD *event);
 
           void    SetCheckTrackStatus(Bool_t status = kTRUE) { fCheckTrackStatus = status; };
           void    SetCheckKinkStatus(Bool_t status = kTRUE)  { fCheckKinkStatus  = status; };
@@ -37,13 +38,18 @@ class AliTRDpidESD : public TObject {
          Bool_t  GetCheckTrackStatus()                      { return fCheckTrackStatus;   };      
          Bool_t  GetCheckKinkStatus()                       { return fCheckKinkStatus;    };      
           Int_t   GetMinPlane()                              { return fMinPlane;           };
-  static  Bool_t  GetTrackSegmentKine(AliESDtrack *t, Int_t plan, Float_t &mom, Float_t &length);
- private:
+
+private:
+  Bool_t  RecalculateTrackSegmentKine(AliESDtrack *t, Int_t plan, Float_t &mom, Float_t &length);
+
+private:
 
   static  Bool_t  fCheckTrackStatus;    // Enable check on ESD track status
   static  Bool_t  fCheckKinkStatus;     // Enable check on ESD kink track
   static  Int_t   fMinPlane;            // Minimum number of planes
 
+       AliExternalTrackParam *fTrack;                          //! Memory holder for Track segment calculations
+       
   ClassDef(AliTRDpidESD,2)              // TRD PID class
 
 };
index 5ce8128..c29a59c 100644 (file)
@@ -393,48 +393,38 @@ Int_t AliTRDtrack::Compare(const TObject *o) const
 }                
 
 //_____________________________________________________________________________
-void AliTRDtrack::CookdEdx(Double_t low, Double_t up) 
+void AliTRDtrack::CookdEdx(Double_t low, Double_t up)
 {
   //
   // Calculates the truncated dE/dx within the "low" and "up" cuts.
   //
 
-  Int_t   i  = 0;
-
   // Array to sort the dEdx values according to amplitude
   Float_t sorted[kMAXCLUSTERSPERTRACK];
-
-  // Number of clusters used for dedx
-  Int_t   nc = fNdedx; 
-
+  fdEdx = 0.0;
+   
   // Require at least 10 clusters for a dedx measurement
-  if (nc < 10) {
-    SetdEdx(0);
-    return;
-  }
-
-  // Lower and upper bound
-  Int_t nl = Int_t(low * nc);
-  Int_t nu = Int_t( up * nc);
+  if (fNdedx < 10) return;
 
   // Can fdQdl be negative ????
-  for (i = 0; i < nc; i++) {
+  for (Int_t i = 0; i < fNdedx; i++) {
     sorted[i] = TMath::Abs(fdQdl[i]);
   }
-
   // Sort the dedx values by amplitude
-  Int_t *index = new Int_t[nc];
-  TMath::Sort(nc,sorted,index,kFALSE);
+  Int_t *index = new Int_t[fNdedx];
+  TMath::Sort(fNdedx, sorted, index, kFALSE);
 
-  // Sum up the truncated charge between nl and nu  
-  Float_t dedx = 0.0;
-  for (i = nl; i <= nu; i++) {
-    dedx += sorted[index[i]];
+  // Sum up the truncated charge between lower and upper bounds
+  Int_t nl = Int_t(low * fNdedx);
+  Int_t nu = Int_t( up * fNdedx);
+  for (Int_t i = nl; i <= nu; i++) {
+    fdEdx += sorted[index[i]];
   }
-  dedx /= (nu - nl + 1.0);
-  SetdEdx(dedx);
+  fdEdx /= (nu - nl + 1.0);
 
-}                     
+  delete[] index;
+
+}                    
 
 //_____________________________________________________________________________
 Bool_t AliTRDtrack::PropagateTo(Double_t xk, Double_t x0, Double_t rho)
index 909339b..bd46dac 100644 (file)
@@ -397,7 +397,7 @@ TH1* AliTRDCalPIDLQ::GetHistogramT(Int_t k, Int_t ip) const
 }
 
 //_________________________________________________________________________
-Double_t AliTRDCalPIDLQ::GetProbability(Int_t spec, Double_t mom, Double_t *dedx, Double_t length) const 
+Double_t AliTRDCalPIDLQ::GetProbability(Int_t spec, Float_t mom, Float_t *dedx, Float_t length) const
 {
   //
        // Core function of AliTRDCalPIDLQ class for calculating the
@@ -669,8 +669,10 @@ Bool_t AliTRDCalPIDLQ::WriteReferences(Char_t *File, Char_t *dir)
                                                if ((dEdx <=  0.) || (timebin <= -1.)) continue;
                        
                                                // retrive kinematic info for this track segment
-                                               if(!AliTRDpidESD::GetTrackSegmentKine(esdTrack, iPlane, mom, length)) continue;
-                                               
+                                               // Temporary fix
+                                               //if(!AliTRDpidESD::RecalculateTrackSegmentKine(esdTrack, iPlane, mom, length)) continue;
+                                               mom = esdTrack->GetOuterParam()->GetP();
+
                                                // find segment length and momentum bin
                                                Int_t jmom = 1, refMom = -1;
                                                while(jmom<fNMom-1 && mom>fTrackMomentum[jmom]) jmom++;
index e47b291..1cfa2bc 100644 (file)
@@ -49,7 +49,7 @@ class AliTRDCalPIDLQ : public TNamed {
   TH1*         GetHistogram(Int_t iType, Int_t ip/*, Int_t il*/) const;
   TH1*         GetHistogramT(Int_t iType, Int_t ip) const;
 
-  Double_t     GetProbability(Int_t spec, Double_t mom, Double_t *dedx, Double_t length) const;
+  Double_t     GetProbability(Int_t spec, Float_t mom, Float_t *dedx, Float_t length) const;
   Double_t     GetProbabilityT(Int_t spec, Double_t mom, Int_t timbin) const;
   //Int_t      GetNbins() const                       { return fNbins;   }
   //Double_t   GetBinSize() const                     { return fBinSize; }