restructured the class AliTRDv0Info
authorabercuci <abercuci@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 10 May 2010 12:54:41 +0000 (12:54 +0000)
committerabercuci <abercuci@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 10 May 2010 12:54:41 +0000 (12:54 +0000)
- filling of the V0 list relevant for TRD in AliTRDinfoGen
- open posibility to set V0 cuts in AliTRDinfoGen class
- connect V0 list to AliTRDcheckPID for performance monitoring

PWG1/TRD/AliTRDcheckPID.cxx
PWG1/TRD/AliTRDcheckPID.h
PWG1/TRD/AliTRDinfoGen.cxx
PWG1/TRD/AliTRDinfoGen.h
PWG1/TRD/AliTRDpidRefMaker.cxx
PWG1/TRD/AliTRDpidRefMaker.h
PWG1/TRD/info/AliTRDv0Info.cxx
PWG1/TRD/info/AliTRDv0Info.h

index 93200e9..806fc0e 100644 (file)
@@ -64,6 +64,7 @@ AliTRDcheckPID::AliTRDcheckPID()
   ,fUtil(NULL)
   ,fGraph(NULL)
   ,fPID(NULL)
+  ,fV0s(NULL)
   ,fMomentumAxis(NULL)
   ,fMinNTracklets(AliTRDgeometry::kNlayer)
   ,fMaxNTracklets(AliTRDgeometry::kNlayer)
@@ -82,6 +83,7 @@ AliTRDcheckPID::AliTRDcheckPID(char* name )
   ,fUtil(NULL)
   ,fGraph(NULL)
   ,fPID(NULL)
+  ,fV0s(NULL)
   ,fMomentumAxis(NULL)
   ,fMinNTracklets(AliTRDgeometry::kNlayer)
   ,fMaxNTracklets(AliTRDgeometry::kNlayer)
@@ -147,6 +149,7 @@ void AliTRDcheckPID::UserExec(Option_t *opt)
   //
 
   fPID->Delete();
+  fV0s = dynamic_cast<TObjArray *>(GetInputData(2));
 
   AliTRDrecoTask::UserExec(opt);
 
index 34fe1f6..e598e67 100644 (file)
@@ -89,6 +89,7 @@ private:
   AliTRDpidUtil       *fUtil;              // utility class for PID calculations
   TObjArray           *fGraph;             //! array of graphs filled in PostProcess
   TObjArray           *fPID;               //! array of PID info/track for calibration
+  TObjArray           *fV0s;               //! array of V0 info
   TObjArray           *fEfficiency[AliPID::kSPECIES];      //! array of histograms with efficiency
   TAxis               *fMomentumAxis;      // helper mementum binning
   Int_t                fMinNTracklets;     // minimum number of required Tracklets (for systematic studies)
index e93b5de..ee4bc74 100644 (file)
@@ -53,6 +53,7 @@
 #include "AliESDfriendTrack.h"
 #include "AliESDHeader.h"
 #include "AliESDtrack.h"
+#include "AliESDv0.h"
 #include "AliESDtrackCuts.h"
 #include "AliMCParticle.h"
 #include "AliPID.h"
@@ -99,6 +100,7 @@ AliTRDinfoGen::AliTRDinfoGen()
   ,fMCev(NULL)
   ,fEventCut(NULL)
   ,fTrackCut(NULL)
+  ,fV0Cut(NULL)
   ,fTrackInfo(NULL)
   ,fEventInfo(NULL)
   ,fV0Info(NULL)
@@ -122,6 +124,7 @@ AliTRDinfoGen::AliTRDinfoGen(char* name)
   ,fMCev(NULL)
   ,fEventCut(NULL)
   ,fTrackCut(NULL)
+  ,fV0Cut(NULL)
   ,fTrackInfo(NULL)
   ,fEventInfo(NULL)
   ,fV0Info(NULL)
@@ -149,6 +152,7 @@ AliTRDinfoGen::~AliTRDinfoGen()
   
   if(fDebugStream) delete fDebugStream;
   if(fEvTrigger) delete fEvTrigger;
+  if(fV0Cut) delete fV0Cut;
   if(fTrackCut) delete fTrackCut;
   if(fEventCut) delete fEventCut;
   if(fTrackInfo) delete fTrackInfo; fTrackInfo = NULL;
@@ -167,7 +171,8 @@ AliTRDinfoGen::~AliTRDinfoGen()
     fTracksKink = NULL;
   }
   if(fV0List){ 
-    fV0List->Delete(); delete fV0List;
+    fV0List->Delete(); 
+    delete fV0List;
     fV0List = NULL;
   }
 }
@@ -278,6 +283,7 @@ void AliTRDinfoGen::UserExec(Option_t *){
   AliTRDtrackV1 *track = NULL;
   AliTRDseedV1 *tracklet = NULL;
   AliTRDcluster *cl = NULL;
+  // LOOP 0 - over ESD tracks
   for(Int_t itrk = 0; itrk < nTracksESD; itrk++){
     new(fTrackInfo) AliTRDtrackInfo();
     esdTrack = fESDev->GetTrack(itrk);
@@ -437,13 +443,38 @@ void AliTRDinfoGen::UserExec(Option_t *){
     fTrackInfo->Delete("");
   }
 
-//   AliESDv0 *v0 = NULL;
-//   for(Int_t iv0=0; iv0<fESD->GetNumberOfV0s(); iv0++){
-//     if(!(v0 = fESD->GetV0(iv0))) continue;
-//     fV0List->Add(new AliTRDv0Info(v0));
-//   }
+  // LOOP 1 - over ESD v0s
+  Bool_t kFOUND(kFALSE);
+  Float_t bField(fESDev->GetMagneticField());
+  AliESDv0 *v0(NULL);
+  for(Int_t iv0(0); iv0<fESDev->GetNumberOfV0s(); iv0++){
+    if(!(v0 = fESDev->GetV0(iv0))) continue;
+
+    if(fV0Cut) new(fV0Info) AliTRDv0Info(*fV0Cut);
+    else new(fV0Info) AliTRDv0Info();
+    fV0Info->SetMagField(bField);
+    fV0Info->SetV0tracks(fESDev->GetTrack(v0->GetPindex()), fESDev->GetTrack(v0->GetNindex()));
+    fV0Info->SetV0Info(v0);
+    // purge V0 irelevant for TRD
+    for(Int_t ib(0); ib<nBarrel; ib++){ 
+      if(fV0Info->HasTrack((AliTRDtrackInfo*)fTracksBarrel->At(ib))){
+        kFOUND=kTRUE;
+        break;
+      }
+    }
+    if(!kFOUND){
+      for(Int_t ik(0); ik<nKink; ik++){ 
+        if(fV0Info->HasTrack((AliTRDtrackInfo*)fTracksKink->At(ik))){
+          kFOUND=kTRUE;
+          break;
+        }
+      }
+    }
+    if(!kFOUND) continue;
+    fV0List->Add(new AliTRDv0Info(*fV0Info));
+  }
 
-  // Insert also MC tracks which are passing TRD where the track is not reconstructed
+  // LOOP 2 - over MC tracks which are passing TRD where the track is not reconstructed
   if(HasMCdata()){
     AliDebug(10, "Output of the MC track map:");
     for(Int_t itk = 0; itk < nTracksMC;  itk++) AliDebug(10, Form("trackMap[%d] = %s", itk, trackMap[itk] == kTRUE ? "TRUE" : "kFALSE"));
@@ -501,10 +532,10 @@ void AliTRDinfoGen::UserExec(Option_t *){
     delete[] trackMap;
   }
   AliDebug(2, Form(
-    "\nEv[%3d] Tracks: ESD[%d] MC[%d]\n"
+    "\nEv[%3d] Tracks: ESD[%d] MC[%d] V0[%d]\n"
     "        TPCout[%d] TRDin[%d] TRDout[%d]\n"
     "        Barrel[%3d+%3d=%3d] SA[%2d+%2d=%2d] Kink[%2d+%2d=%2d]"
-    ,(Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), nTracksESD, nTracksMC
+    ,(Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), nTracksESD, nTracksMC, fV0List->GetEntries()
     , nTPC, nTRDin, nTRDout
     ,nBarrel, nBarrelMC, fTracksBarrel->GetEntries()
     ,nSA, nSAMC, fTracksSA->GetEntries()
@@ -519,6 +550,15 @@ void AliTRDinfoGen::UserExec(Option_t *){
 }
 
 //____________________________________________________________________
+void AliTRDinfoGen::SetLocalV0Selection(AliTRDv0Info *v0)
+{
+// Set V0 cuts from outside
+
+  if(!fV0Cut) fV0Cut = new AliTRDv0Info(*v0);
+  else new(fV0Cut) AliTRDv0Info(*v0);
+}
+
+//____________________________________________________________________
 void AliTRDinfoGen::SetTrigger(const Char_t *trigger)
 {
   if(!fEvTrigger) fEvTrigger = new TString(trigger);
index 9f12d4e..0b77e72 100644 (file)
@@ -54,6 +54,7 @@ public:
   void    SetLocalEvSelection(Bool_t use=kTRUE) {SetBit(kUseLocalEvSelection, use);}
   void    SetLocalTrkSelection(AliESDtrackCuts */*cut*/){;} 
   void    SetLocalTrkSelection(Bool_t use=kTRUE) {SetBit(kUseLocalTrkSelection, use);}
+  void    SetLocalV0Selection(AliTRDv0Info *v0);
   void    SetMCdata(Bool_t mc = kTRUE) {SetBit(kMCdata, mc);}
   void    SetTrigger(const Char_t *trigger);
 
@@ -89,6 +90,7 @@ private:
   // event/track cuts OO - to be used
   AliTRDeventCuts  *fEventCut;       // event cut
   AliESDtrackCuts  *fTrackCut;       // track cut
+  AliTRDv0Info     *fV0Cut;          // v0 cut
   AliTRDtrackInfo  *fTrackInfo;      //! Track info
   AliTRDeventInfo  *fEventInfo;             //! Event info
   AliTRDv0Info     *fV0Info;         //! V0 info
index 148365c..8df8c5e 100644 (file)
@@ -292,7 +292,7 @@ void AliTRDpidRefMaker::LinkPIDdata()
 }
 
 //________________________________________________________________________
-void AliTRDpidRefMaker::SetRefPID(ETRDpidRefMakerSource select, void *source, Float_t *pid) 
+void AliTRDpidRefMaker::SetRefPID(ETRDpidRefMakerSource select, AliTRDtrackInfo *track, Float_t *pid) 
 {
 // Fill the reference PID values "pid" from "source" object
 // according to the option "select". Possible options are
@@ -300,20 +300,22 @@ void AliTRDpidRefMaker::SetRefPID(ETRDpidRefMakerSource select, void *source, Fl
 // - kMC  - MC truth [default]
 // - kRec - outside detectors
 
-
+  if(!track){
+    AliError("No trackInfo found");
+    return;
+  }
   memset(fPID, 0, AliPID::kSPECIES*sizeof(Float_t));
   switch(select){ 
   case kV0:
     {
-      AliTRDtrackInfo *track = static_cast<AliTRDtrackInfo*>(source);
-      if(!track){
-        AliError("No trackInfo found");
-        return;
-      }
-
       //Get V0 PID decisions from the AliTRDv0Info for all particle species (implemented so far : electrons from conversions, pions from K0s and protons from Lambdas) :
-      AliTRDv0Info v0;
-      for(Int_t is=AliPID::kSPECIES; is--;) fPID[is] = v0.GetV0PID(is, track);
+      AliTRDv0Info *v0(NULL);
+      for(Int_t iv(0); iv<fV0s->GetEntriesFast(); iv++){
+        if(!(v0 = (AliTRDv0Info*)fV0s->At(iv))) continue;
+        if(!v0->HasTrack(track)) continue;
+        for(Int_t is=AliPID::kSPECIES; is--;) fPID[is] = v0->GetPID(is, track);
+        break;
+      }
     }
     break;
   case kMC:
@@ -321,35 +323,31 @@ void AliTRDpidRefMaker::SetRefPID(ETRDpidRefMakerSource select, void *source, Fl
       AliError("Could not retrive reference PID from MC");
       return;
     }
-    {
-      AliTRDtrackInfo *track = static_cast<AliTRDtrackInfo*>(source);
-      switch(track->GetPDG()){
-      case kElectron:
-      case kPositron:
-        fPID[AliPID::kElectron] = 1.;
-        break;
-      case kMuonPlus:
-      case kMuonMinus:
-        fPID[AliPID::kMuon] = 1.;
-        break;
-      case kPiPlus:
-      case kPiMinus:
-        fPID[AliPID::kPion] = 1.;
-        break;
-      case kKPlus:
-      case kKMinus:
-        fPID[AliPID::kKaon] = 1.;
-        break;
-      case kProton:
-      case kProtonBar:
-        fPID[AliPID::kProton] = 1.;
-        break;
-      }
+    switch(track->GetPDG()){
+    case kElectron:
+    case kPositron:
+      fPID[AliPID::kElectron] = 1.;
+      break;
+    case kMuonPlus:
+    case kMuonMinus:
+      fPID[AliPID::kMuon] = 1.;
+      break;
+    case kPiPlus:
+    case kPiMinus:
+      fPID[AliPID::kPion] = 1.;
+      break;
+    case kKPlus:
+    case kKMinus:
+      fPID[AliPID::kKaon] = 1.;
+      break;
+    case kProton:
+    case kProtonBar:
+      fPID[AliPID::kProton] = 1.;
+      break;
     }
     break;
   case kRec:
     { 
-      AliTRDtrackInfo *track = static_cast<AliTRDtrackInfo*>(source);
       AliTRDtrackV1 *trackTRD = track->GetTrack();
       trackTRD -> SetReconstructor(fReconstructor);
       //fReconstructor -> SetOption("nn");
index 54cc84d..856fcec 100644 (file)
@@ -30,6 +30,7 @@ class TTree;
 class TObjArray;
 class AliTRDReconstructor;
 class AliTRDseedV1;
+class AliTRDtrackInfo;
 class AliTRDpidRefMaker : public AliTRDrecoTask
 {
 public:
@@ -87,7 +88,7 @@ public:
 
   void    SetAbundance(Float_t train);
   void    SetPthreshold(Float_t t) { fPthreshold = t;}
-  void    SetRefPID(ETRDpidRefMakerSource select, void *source, Float_t *pid);
+  void    SetRefPID(ETRDpidRefMakerSource select, AliTRDtrackInfo *t, Float_t *pid);
   void    SetSource(ETRDpidRefMakerSource pid, ETRDpidRefMakerSource momentum) {fRefPID = pid; fRefP = momentum;}
 
 
index d2eb783..b87715d 100644 (file)
@@ -37,8 +37,6 @@
 
 #include "AliESDtrack.h"
 #include "AliESDv0.h"
-#include "AliESDInputHandler.h"
-#include "AliAnalysisManager.h"
 #include "AliLog.h"
 
 #include "AliTRDv0Info.h"
@@ -50,21 +48,16 @@ ClassImp(AliTRDv0Info)
 //_________________________________________________
 AliTRDv0Info::AliTRDv0Info()
   : TObject()
-  ,fESD(0x0)
-  ,fHasV0(0)      
-  ,fQuality(0)    
-  ,fMomentum(0)
+  ,fQuality(0)
   ,fDCA(10)
   ,fPointingAngle(10)
   ,fOpenAngle(10)
   ,fPsiPair(99)
   ,fMagField(0)
   ,fRadius(0)
-  ,fTrackID(0)
   ,fV0Momentum(0)
-  ,fTrackP(0x0)
-  ,fTrackN(0x0)
-  ,fTrack(0x0)
+  ,fTrackP(NULL)
+  ,fTrackN(NULL)
   ,fNindex(0)
   ,fPindex(0)
 {
@@ -178,19 +171,58 @@ AliTRDv0Info::AliTRDv0Info()
 
   fDownComPIDnegPart[AliPID::kProton] = 0.05;
   fDownComPIDposPart[AliPID::kProton] = 0.05;
+}
+
+//_________________________________________________
+AliTRDv0Info::AliTRDv0Info(const AliTRDv0Info &ref)
+  : TObject()
+  ,fQuality(ref.fQuality)
+  ,fDCA(ref.fDCA)
+  ,fPointingAngle(ref.fPointingAngle)
+  ,fOpenAngle(ref.fOpenAngle)
+  ,fPsiPair(ref.fPsiPair)
+  ,fMagField(ref.fMagField)
+  ,fRadius(ref.fMagField)
+  ,fV0Momentum(ref.fV0Momentum)
+  ,fTrackP(ref.fTrackP)
+  ,fTrackN(ref.fTrackN)
+  ,fNindex(ref.fNindex)
+  ,fPindex(ref.fPindex)
+{
+  //
+  // Copy constructor
+  //
 
-  //////////////////////////////////////////////////////////////////////////////////
+  memcpy(fPplus, ref.fPplus, 2*kNlayer*sizeof(Float_t));
+  memcpy(fPminus, ref.fPminus, 2*kNlayer*sizeof(Float_t));
+  memcpy(fDetPID, ref.fDetPID, 2*kNDaughters*kNDetectors*AliPID::kSPECIES*sizeof(Float_t));
+  memcpy(fComPID, ref.fComPID, 2*kNDaughters*AliPID::kSPECIES*sizeof(Float_t));
+  memcpy(fInvMass, ref.fInvMass, kNMomBins*kNDecays*sizeof(Double_t));
 
+  //Upper limit for distance of closest approach of two daughter tracks :
+  memcpy(fUpDCA, ref.fUpDCA, kNDecays*sizeof(Float_t));
+  memcpy(fUpPointingAngle, ref.fUpPointingAngle, kNDecays*sizeof(Float_t));
+  memcpy(fUpOpenAngle, ref.fUpOpenAngle, kNDecays*sizeof(Float_t));
+  memcpy(fDownOpenAngle, ref.fDownOpenAngle, kNDecays*sizeof(Float_t));
+  memcpy(fUpPsiPair, ref.fUpPsiPair, kNDecays*sizeof(Float_t));
+  memcpy(fDownPsiPair, ref.fDownPsiPair, kNDecays*sizeof(Float_t));
+  memcpy(fUpInvMass, ref.fUpInvMass, kNDecays*kNMomBins*sizeof(Double_t));
+  memcpy(fDownInvMass, ref.fDownInvMass, kNDecays*sizeof(Double_t));
+  memcpy(fUpRadius, ref.fUpRadius, kNDecays*sizeof(Float_t));
+  memcpy(fDownRadius, ref.fDownRadius, kNDecays*sizeof(Float_t));
+  memcpy(fDownTPCPIDneg, ref.fDownTPCPIDneg, AliPID::kSPECIES*sizeof(Float_t));
+  memcpy(fDownTPCPIDpos, ref.fDownTPCPIDpos, AliPID::kSPECIES*sizeof(Float_t));
+  memcpy(fDownComPIDneg, ref.fDownComPIDneg, AliPID::kSPECIES*sizeof(Float_t));
+  memcpy(fDownComPIDpos, ref.fDownComPIDpos, AliPID::kSPECIES*sizeof(Float_t));
+  memcpy(fDownComPIDnegPart, ref.fDownComPIDnegPart, AliPID::kSPECIES*sizeof(Float_t));
+  memcpy(fDownComPIDposPart, ref.fDownComPIDposPart, AliPID::kSPECIES*sizeof(Float_t));
 }
 
 //_________________________________________________
-void AliTRDv0Info::GetESDv0Info(AliESDv0 *esdv0)
+void AliTRDv0Info::SetV0Info(AliESDv0 *esdv0)
 {//Gets values of ESDv0 and daughter track properties
   //See header file for description of variables
 
-  Int_t part1 = -1;
-  Int_t part2 = -1;
-
   fQuality = Quality(esdv0);//Attributes an Int_t to the V0 due to quality cuts (= 1 if V0 is accepted, other integers depending on cut which excludes the vertex)    
 
   fRadius = Radius(esdv0);//distance from secondary vertex to primary vertex in x-y plane
@@ -205,32 +237,26 @@ void AliTRDv0Info::GetESDv0Info(AliESDv0 *esdv0)
 
   fV0Momentum = V0Momentum(esdv0);//Reconstructed momentum of the mother particle
       
-  for(Int_t idecay = 0; idecay < kNDecays; idecay++)//4 decay types : conversions, K0s, Lambda, Anti-Lambda 
+  //4 decay types : conversions, K0s, Lambda, Anti-Lambda 
     //five particle types: electrons, muons, pions, kaons, protons (muons and kaons not involved)
-    {
-      if(idecay == kLambda)//protons and pions from Lambda
-  {
-    part1 = AliPID::kProton;
-    part2 = AliPID::kPion;
-  }
-      else if(idecay == kAntiLambda)//antiprotons and pions from Anti-Lambda
-  {
-    part1 = AliPID::kPion;
-    part2 = AliPID::kProton;
+  for(Int_t idecay(0), part1(-1), part2(-1); idecay < kNDecays; idecay++){
+    if(idecay == kLambda){ //protons and pions from Lambda
+      part1 = AliPID::kProton;
+      part2 = AliPID::kPion;
+    } else if(idecay == kAntiLambda) { //antiprotons and pions from Anti-Lambda
+      part1 = AliPID::kPion;
+      part2 = AliPID::kProton;
+    } else if(idecay == kK0s) {//pions from K0s
+      part1 = part2 = AliPID::kPion;
+    } else if(idecay == kGamma) {//electrons from conversions
+      part1 = part2 = AliPID::kElectron;
+    } 
+    fInvMass[idecay] = InvMass(part1, part2, esdv0);//Calculate invariant mass for all of our four supposed decays
   }
-      else if(idecay == kK0s)//pions from K0s
-  part1 = part2 = AliPID::kPion;
-      else if(idecay == kGamma)//electrons from conversions
-  part1 = part2 = AliPID::kElectron;
-    
-      fInvMass[idecay] = InvMass(part1, part2, esdv0);//Calculate invariant mass for all of our four supposed decays
-    }
-  GetDetectorPID();//Gets all likelihood values from TPC, TOF and ITS PID for the fDetPID[kNDaughters][kNDetectors][AliPID::kSPECIES] array
-  CombinePID();//Bayesian combination of likelihoods from TPC and TOF
-
-  fMomentum = fTrack->GetOuterParam()->P();
-
-    
+  //Gets all likelihood values from TPC, TOF and ITS PID for the fDetPID[kNDaughters][kNDetectors][AliPID::kSPECIES] array
+  GetDetectorPID();
+  //Bayesian combination of likelihoods from TPC and TOF
+  CombinePID();
 }
 //_________________________________________________
 Float_t  AliTRDv0Info::V0Momentum(AliESDv0 *esdv0) const
@@ -358,31 +384,17 @@ Float_t AliTRDv0Info::PsiPair(AliESDv0 *esdv0)
 }
 
 //_________________________________________________
-void AliTRDv0Info::V0fromTrack(AliTRDtrackInfo * const track, Int_t ivertex)
-{//Checks if track is a secondary vertex daughter (due to V0 finder)
+Bool_t AliTRDv0Info::HasTrack(AliTRDtrackInfo * const track)
+{
+//Checks if track is a secondary vertex daughter (due to V0 finder)
   
-  fMagField = fESD->GetMagneticField();
-
-  fTrackID =  track->GetTrackId();//index of the track
-
-  fTrack = fESD->GetTrack(fTrackID);//sets track information
-
-  fMomentum = fTrack->GetOuterParam()->P();//Get track momentum from outer parameters
-
-  fHasV0 = 0;
+  Int_t trackID(track->GetTrackId());//index of the track
 
   //comparing index of track with indices of pos./neg. V0 daughter :
-  AliESDv0 * esdv0 = fESD->GetV0(ivertex);
-  if((esdv0->GetIndex(0) == fTrackID)||(esdv0->GetIndex(1) == fTrackID))
-    {
-      fHasV0 = 1;//track belongs to vertex found by V0 finder!
-      fNindex = esdv0->GetIndex(0);
-      fPindex = esdv0->GetIndex(1);
-      fTrackN = fESD->GetTrack(esdv0->GetIndex(0));//providing information about the other of the two daughter tracks 
-      fTrackP = fESD->GetTrack(esdv0->GetIndex(1));
-      GetESDv0Info(esdv0);//gets all the relevant information about our V0
-    }
+  if((fNindex == trackID)||(fPindex == trackID)) return kTRUE;
+  return kFALSE;
 }
+
 //_________________________________________________
 void AliTRDv0Info::GetDetectorPID()
 {//PID likelihoods from TPC, TOF, and ITS, for all particle species
@@ -500,143 +512,98 @@ Int_t AliTRDv0Info::Quality(AliESDv0 *const esdv0)
   return fQuality;
 }
 //_________________________________________________
-Bool_t AliTRDv0Info::GetV0PID(Int_t ipart, AliTRDtrackInfo *track)
-{//decides if track is accepted for one of the reference data samples
+Int_t AliTRDv0Info::GetPID(Int_t ipart, AliTRDtrackInfo *track)
+{
+// Decides if track is accepted for one of the reference data samples
   
+  if(!(track)) {
+    AliError("No track info");
+    return 0;
+  }
+  if(!HasTrack(track)){
+    AliDebug(2, "Track not attached to v0.");
+    return 0;
+  }
+  Int_t trackID(track->GetTrackId());
+
+  //translate ipart to decay (Anti-Lambda will be treated separately)
   Int_t iDecay = -1;
+  switch(ipart){
+  case AliPID::kElectron: iDecay = kGamma; break;
+  case AliPID::kPion: iDecay = kK0s; break;
+  case AliPID::kProton: iDecay = kLambda; break;
+  default:
+    AliWarning(Form("Hypothesis \"ipart=%d\" not handled", ipart));
+    return 0;
+  }
 
-  //decide which decay has to be considered for which particle sample (Anti-Lambda will be treated separately)
-  if(ipart == AliPID::kElectron)
-    iDecay = kGamma;
-  else if(ipart == AliPID::kPion)
-    iDecay = kK0s;
-  else if(ipart == AliPID::kProton)
-    iDecay = kLambda;
+  //... it fulfills our quality criteria
+  if(!(fQuality == 1)) return 0;
+  //... distance of closest approach between daughters is reasonably small
+  if((fDCA > fUpDCA[iDecay])) return 0;
+  //... pointing angle between momentum of mother particle and vector from prim. to sec. vertex is small
+  if((fPointingAngle > fUpPointingAngle[iDecay])) return 0;
+  //... x-y plane distance of decay point to prim. vertex is bigger than a certain minimum value (for conversions)
+  if((fRadius < fDownRadius[iDecay])) return 0;
+  //...or smaller than a maximum value (for K0s)
+  if((fRadius > fUpRadius[iDecay])) return 0;
+  //... opening angle is close enough to zero (for conversions)
+  if((fOpenAngle > fUpOpenAngle[iDecay])) return 0;
+  //... Psi-pair angle is close enough to zero(for conversions)
+  if((TMath::Abs(fPsiPair) > fUpPsiPair[iDecay])) return 0;
+
+
+  //Mother momentum slots above/below 2.5 GeV
+  Int_t iPSlot(fV0Momentum > 2.5);
+
+  //specific cut criteria :
+  if(ipart == AliPID::kProton) {
+    if((fInvMass[kK0s] < fUpInvMass[kK0s][iPSlot]) && (fInvMass[kK0s] > fDownInvMass[kK0s])) return 0;//explicit exclusion of K0s decays
+  
+    //for proton sample: separate treatment of Lamba and Anti-Lambda decays:
+    //for Anti-Lambda:
+    //Combined PID likelihoods high enough for pi+ and anti-proton ; invariant mass calculated postulating these two particle species...
+    if((fComPID[kNeg][AliPID::kProton] > fDownComPIDneg[AliPID::kProton]) && (fComPID[kPos][AliPID::kPion] > fDownComPIDposPart[AliPID::kPion])) {
+      if(fNindex == trackID) {
+        if((fInvMass[kAntiLambda] < fUpInvMass[kAntiLambda][iPSlot]) && (fInvMass[kAntiLambda] > fDownInvMass[kAntiLambda])) return 1;
+      }
+    }
+    //for Lambda:
+    //TPC PID likelihoods high enough for pi- and proton ; invariant mass calculated accordingly
+    if((fComPID[kNeg][AliPID::kPion] > fDownComPIDnegPart[AliPID::kPion]) && (fComPID[kPos][AliPID::kProton] > fDownComPIDpos[AliPID::kProton])) {
+      if(fPindex == trackID) {
+        if((fInvMass[kLambda] < fUpInvMass[kLambda][iPSlot]) && (fInvMass[kLambda] > fDownInvMass[kLambda])) return 1;
+      }
+    }
+  }
 
-  Int_t iPSlot;//Mother momentum slots above/below 2.5 GeV
+  //Invariant mass cut for K0s and photons, assuming two pions/two electrons as daughters:
+  if((fInvMass[iDecay] > fUpInvMass[iDecay][iPSlot]) || (fInvMass[iDecay] < fDownInvMass[iDecay])) return 0;
 
-  
-  Bool_t pid = 0;//return value for V0 PID decision
+  //for K0s decays: equal TPC PID likelihood criteria for both daughters ; invariant mass calculated postulating two pions
+  if(ipart == AliPID::kPion) {
+    //explicit exclusion of Lambda decays
+    if((fInvMass[kLambda] < fUpInvMass[kLambda][iPSlot]) && (fInvMass[kLambda] > fDownInvMass[kLambda])) return 0;
+    //explicit exclusion of Anti-Lambda decays
+    if((fInvMass[kAntiLambda] < fUpInvMass[kAntiLambda][iPSlot]) && (fInvMass[kAntiLambda] > fDownInvMass[kAntiLambda])) return 0;
 
-  if(!(track))
-    {
-      AliError("AliTRDv0Info::GetV0PID(Int_t ipart, AliTRDtrackInfo *track) : No track info found.\n");
-      return 0;
-    }
+    if((fDetPID[kNeg][kTPC][ipart] > fDownTPCPIDneg[ipart]) && (fDetPID[kPos][kTPC][ipart] > fDownTPCPIDpos[ipart])) return 1;
+  }
 
-  AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
-  if(!esdH)
-    {
-      AliError("AliTRDv0Info::GetV0PID(Int_t ipart, AliTRDtrackInfo *track) : ERROR - ESD input handler not found");
-      return 0;
-    } 
-      
-  
-  fESD = esdH->GetEvent();
-  
-  for(Int_t ivertex=0; ivertex<fESD->GetNumberOfV0s(); ivertex++)
-    {
-    
-      if(pid == 0)
-       {     
-         V0fromTrack(track, ivertex);//Get the V0 corresponding to the track (if there is a V0)
-    
-         if(fV0Momentum > 2.5)//divide into slots according to reconstructed momentum of the mother particle
-           {iPSlot = 1;}
-         else
-           {iPSlot = 0;}
-         //Accept track for a sample only if...
-
-         if(!(fHasV0))//... there is a V0 found for it
-           continue;
-         if(!(fQuality == 1))//... it fulfills our quality criteria
-           continue;
-         if((fDCA > fUpDCA[iDecay]))//... distance of closest approach between daughters is reasonably small
-           continue;
-         if((fPointingAngle > fUpPointingAngle[iDecay]))//... pointing angle between momentum of mother particle and vector from prim. to sec. vertex is small
-           continue;                             
-         if((fRadius < fDownRadius[iDecay]))//... x-y plane distance of decay point to prim. vertex is bigger than a certain minimum value (for conversions)
-           continue;
-         if((fRadius > fUpRadius[iDecay]))//...or smaller than a maximum value (for K0s)
-           continue;
-         if((fOpenAngle > fUpOpenAngle[iDecay]))//... opening angle is close enough to zero (for conversions)
-           continue;
-         if((TMath::Abs(fPsiPair) > fUpPsiPair[iDecay]))//... Psi-pair angle is close enough to zero(for conversions)
-           continue;
-
-         //specific cut criteria :
-         if(ipart == AliPID::kProton)
-           {
-             if((fInvMass[kK0s] < fUpInvMass[kK0s][iPSlot]) && (fInvMass[kK0s] > fDownInvMass[kK0s]))
-               continue;//explicit exclusion of K0s decays
-
-             //for proton sample: separate treatment of Lamba and Anti-Lambda decays:
-             //for Anti-Lambda:
-             //Combined PID likelihoods high enough for pi+ and anti-proton ; invariant mass calculated postulating these two particle species...
-             if((fComPID[kNeg][AliPID::kProton] > fDownComPIDneg[AliPID::kProton]) && (fComPID[kPos][AliPID::kPion] > fDownComPIDposPart[AliPID::kPion]))
-               {
-                 if(fNindex == fTrackID)
-                   {
-                     if((fInvMass[kAntiLambda] < fUpInvMass[kAntiLambda][iPSlot]) && (fInvMass[kAntiLambda] > fDownInvMass[kAntiLambda]))
-                       {
-                         pid = 1;
-                       }
-                   }
-               }
-             //for Lambda:
-             //TPC PID likelihoods high enough for pi- and proton ; invariant mass calculated accordingly
-             if((fComPID[kNeg][AliPID::kPion] > fDownComPIDnegPart[AliPID::kPion]) && (fComPID[kPos][AliPID::kProton] > fDownComPIDpos[AliPID::kProton]))
-               {
-                 if(fPindex == fTrackID)
-                   {
-                     if((fInvMass[kLambda] < fUpInvMass[kLambda][iPSlot]) && (fInvMass[kLambda] > fDownInvMass[kLambda]))
-                       {
-                         pid = 1;
-                       }
-                   }
-               }
-           }
-
-         //Invariant mass cut for K0s and photons, assuming two pions/two electrons as daughters:
-         if((fInvMass[iDecay] > fUpInvMass[iDecay][iPSlot]) || (fInvMass[iDecay] < fDownInvMass[iDecay]))
-           continue;
-         //for K0s decays: equal TPC PID likelihood criteria for both daughters ; invariant mass calculated postulating two pions
-         if(ipart == AliPID::kPion)
-           {
-             if((fInvMass[kLambda] < fUpInvMass[kLambda][iPSlot]) && (fInvMass[kLambda] > fDownInvMass[kLambda]))
-               continue;//explicit exclusion of Lambda decays
-             if((fInvMass[kAntiLambda] < fUpInvMass[kAntiLambda][iPSlot]) && (fInvMass[kAntiLambda] > fDownInvMass[kAntiLambda]))
-               continue;//explicit exclusion of Anti-Lambda decays
-
-             if((fDetPID[kNeg][kTPC][ipart] > fDownTPCPIDneg[ipart]) && (fDetPID[kPos][kTPC][ipart] > fDownTPCPIDpos[ipart]))
-               {
-                 pid = 1;                                                
-               }
-           }
-         //for photon conversions: equal combined PID likelihood criteria for both daughters ; invariant mass calculated postulating two electrons
-         //No Lambda/K0s exclusion is provided, since these contributions hardly ever interfere with gamma invariant mass!
-         if(ipart == AliPID::kElectron)
-           {
-             if(fMomentum > 1.75)
-               {//since combined PID performs a little worse in simulations than TPC standalone for higher momenta, ONLY TPC PID is used here
-                 if((fDetPID[kNeg][kTPC][ipart] > fDownTPCPIDneg[ipart]) && (fDetPID[kPos][kTPC][ipart] > fDownTPCPIDpos[ipart]))
-                   {
-                     pid = 1;                                            
-                   }
-               }
-             else
-               {//for low momenta, combined PID from TOF and TPC is used to get rid of proton contamination
-                 if((fComPID[kNeg][ipart] > fDownComPIDneg[ipart]) && (fComPID[kPos][ipart] > fDownComPIDpos[ipart]))
-                   {
-                     pid = 1;                                            
-                   }
-               }
-           }     
-       } 
+  //for photon conversions: equal combined PID likelihood criteria for both daughters ; invariant mass calculated postulating two electrons
+  //No Lambda/K0s exclusion is provided, since these contributions hardly ever interfere with gamma invariant mass!
+  Float_t momentum(track->GetESDinfo()->GetOuterParam()->P());
+  if(ipart == AliPID::kElectron) {
+    if(momentum > 1.75) {//since combined PID performs a little worse in simulations than TPC standalone for higher momenta, ONLY TPC PID is used here
+      if((fDetPID[kNeg][kTPC][ipart] > fDownTPCPIDneg[ipart]) && (fDetPID[kPos][kTPC][ipart] > fDownTPCPIDpos[ipart])) return 1;
+    } else {//for low momenta, combined PID from TOF and TPC is used to get rid of proton contamination
+      if((fComPID[kNeg][ipart] > fDownComPIDneg[ipart]) && (fComPID[kPos][ipart] > fDownComPIDpos[ipart])) return 1;
     }
-  return pid;
-  
+  }
+  return 0;
 }
+
+
 //_________________________________________________
 void AliTRDv0Info::Print(Option_t */*opt*/) const
 {
index d7ad20b..8ec6fe7 100644 (file)
@@ -26,8 +26,7 @@
 
 class AliESDv0;
 class AliESDtrack;
-class AliESDEvent;
-class AliTRDtrackV1;
+//class AliTRDtrackV1;
 class AliTRDtrackInfo;
 class AliTRDv0Info : public TObject
 {
@@ -61,22 +60,22 @@ public:
 
 
   AliTRDv0Info();
+  AliTRDv0Info(const AliTRDv0Info &ref);
   virtual ~AliTRDv0Info(){}
+  
+  Int_t  GetPID(Int_t ipart, AliTRDtrackInfo *track);
+  Bool_t HasTrack(AliTRDtrackInfo * const track);
 
-/*   Float_t Pplus[2*kNlayer];       // Positives */
-/*   Float_t Pminus[2*kNlayer];      // Negatives */
+  void   Print(Option_t *opt=0x0) const;
 
-  void Print(Option_t *opt=0x0) const;
-  Bool_t GetV0PID(Int_t ipart, AliTRDtrackInfo *track);//decides if a track is accepted for one of the reference samples!!
+  void   SetMagField(Float_t b) {fMagField = b;}
+  void   SetV0tracks(AliESDtrack *p, AliESDtrack *n) {fTrackP = p; fTrackN = n;}
 
   //Set values of measured/calculated variables:
   void SetQuality(Int_t SQuality){fQuality = SQuality;}
   void SetPplus(Int_t iLayer, Float_t SPplus){fPplus[iLayer] = SPplus;}
   void SetPminus(Int_t iLayer, Float_t SPminus){fPminus[iLayer] = SPminus;}
   void SetDCA(Float_t SDCA){fDCA = SDCA;}
-  void SetMomentum(Float_t SMomentum){fMomentum = SMomentum;}
   void SetPointingAngle(Float_t SPointingAngle){fPointingAngle = SPointingAngle;}
   void SetOpenAngle(Float_t SOpenAngle){fOpenAngle = SOpenAngle;}
   void SetPsiPair(Float_t SPsiPair){fPsiPair = SPsiPair;}
@@ -88,29 +87,28 @@ public:
 //____________________________________________________________
  //Set cut values:
 
- void SetUpDCA(Int_t iDecay, Float_t UpDCA){fUpDCA[iDecay] = UpDCA;}
- void SetUpPointingAngle(Int_t iDecay, Float_t UpPointingAngle){fUpPointingAngle[iDecay] = UpPointingAngle;}
- void SetUpOpenAngle(Int_t iDecay, Float_t UpOpenAngle){fUpOpenAngle[iDecay] = UpOpenAngle;}
- void SetDownOpenAngle(Int_t iDecay, Float_t DownOpenAngle){fDownOpenAngle[iDecay] = DownOpenAngle;}
- void SetUpPsiPair(Int_t iDecay, Float_t UpPsiPair){fUpPsiPair[iDecay] = UpPsiPair;}
- void SetDownPsiPair(Int_t iDecay, Float_t DownPsiPair){fDownPsiPair[iDecay] = DownPsiPair;}
- void SetUpRadius(Int_t iDecay, Float_t UpRadius){fUpRadius[iDecay] = UpRadius;}
- void SetDownRadius(Int_t iDecay, Float_t DownRadius){fDownRadius[iDecay] = DownRadius;}
- void SetUpInvMass(Int_t iDecay, Int_t iMomentum, Double_t UpInvMass){fUpInvMass[iDecay][iMomentum] = UpInvMass;}
- void SetDownInvMass(Int_t iDecay, Double_t DownInvMass){fDownInvMass[iDecay] = DownInvMass;}
- void SetDownTPCPIDneg(Int_t iPart, Double_t DownTPCPIDneg){fDownTPCPIDneg[iPart] = DownTPCPIDneg;}
- void SetDownTPCPIDpos(Int_t iPart, Double_t DownTPCPIDpos){fDownTPCPIDpos[iPart] = DownTPCPIDpos;}
- void SetDownComPIDneg(Int_t iPart, Double_t DownComPIDneg){fDownComPIDneg[iPart] = DownComPIDneg;}
- void SetDownComPIDpos(Int_t iPart, Double_t DownComPIDpos){fDownComPIDpos[iPart] = DownComPIDpos;}
- void SetDownComPIDnegPart(Int_t iPart, Double_t DownComPIDnegPart){fDownComPIDnegPart[iPart] = DownComPIDnegPart;}
- void SetDownComPIDposPart(Int_t iPart, Double_t DownComPIDposPart){fDownComPIDposPart[iPart] = DownComPIDposPart;}
-
+  void SetUpDCA(Int_t iDecay, Float_t UpDCA){fUpDCA[iDecay] = UpDCA;}
+  void SetUpPointingAngle(Int_t iDecay, Float_t UpPointingAngle){fUpPointingAngle[iDecay] = UpPointingAngle;}
+  void SetUpOpenAngle(Int_t iDecay, Float_t UpOpenAngle){fUpOpenAngle[iDecay] = UpOpenAngle;}
+  void SetDownOpenAngle(Int_t iDecay, Float_t DownOpenAngle){fDownOpenAngle[iDecay] = DownOpenAngle;}
+  void SetUpPsiPair(Int_t iDecay, Float_t UpPsiPair){fUpPsiPair[iDecay] = UpPsiPair;}
+  void SetDownPsiPair(Int_t iDecay, Float_t DownPsiPair){fDownPsiPair[iDecay] = DownPsiPair;}
+  void SetUpRadius(Int_t iDecay, Float_t UpRadius){fUpRadius[iDecay] = UpRadius;}
+  void SetDownRadius(Int_t iDecay, Float_t DownRadius){fDownRadius[iDecay] = DownRadius;}
+  void SetUpInvMass(Int_t iDecay, Int_t iMomentum, Double_t UpInvMass){fUpInvMass[iDecay][iMomentum] = UpInvMass;}
+  void SetDownInvMass(Int_t iDecay, Double_t DownInvMass){fDownInvMass[iDecay] = DownInvMass;}
+  void SetDownTPCPIDneg(Int_t iPart, Double_t DownTPCPIDneg){fDownTPCPIDneg[iPart] = DownTPCPIDneg;}
+  void SetDownTPCPIDpos(Int_t iPart, Double_t DownTPCPIDpos){fDownTPCPIDpos[iPart] = DownTPCPIDpos;}
+  void SetDownComPIDneg(Int_t iPart, Double_t DownComPIDneg){fDownComPIDneg[iPart] = DownComPIDneg;}
+  void SetDownComPIDpos(Int_t iPart, Double_t DownComPIDpos){fDownComPIDpos[iPart] = DownComPIDpos;}
+  void SetDownComPIDnegPart(Int_t iPart, Double_t DownComPIDnegPart){fDownComPIDnegPart[iPart] = DownComPIDnegPart;}
+  void SetDownComPIDposPart(Int_t iPart, Double_t DownComPIDposPart){fDownComPIDposPart[iPart] = DownComPIDposPart;}
+
+  void SetV0Info(AliESDv0 *v0);//gets most of the variables below
 
 private:
-  AliTRDv0Info(const AliTRDv0Info&);
   AliTRDv0Info& operator=(const AliTRDv0Info&);
 
-  void GetESDv0Info(AliESDv0 *esdv0);//gets most of the variables below
   void GetDetectorPID();//operating with likelihood values of different detectors
   void CombinePID();//Bayesian combination of TPC and TOF likelihoods
   Int_t Quality(AliESDv0 * const esdv0);//checks for track/vertex quality criteria
@@ -121,12 +119,6 @@ private:
   Float_t DCA() const {return fDCA;}//distance of closest approach between supposed daughter tracks
   Float_t PointingAngle() const {return fPointingAngle;}//pointing angle: between vector from primary to secondary vertex and reconstructed momentum of V0 mother particle
   Float_t V0Momentum(AliESDv0 *esdv0) const;//reconstructed momentum of V0 mother particle
-  void V0fromTrack(AliTRDtrackInfo * const track, Int_t ivertex);//checks if a track belongs to a vertex found by V0 finder
-  
-  AliESDEvent *fESD; // ESD event
-
-  Bool_t fHasV0; //Does this track belong to a vertex from a V0 finder?
   Int_t fQuality;              // track quality status for both V0 daughters; OnFly, TPCrefit, Kinks, TPC clusters
  
   Float_t fPplus[2*kNlayer];    // momentum and variance for the positive daughter  
@@ -134,25 +126,13 @@ private:
   Double_t fDetPID[kNDaughters][kNDetectors][AliPID::kSPECIES]; // PID provided by TPC, TOF and ITS
   Double_t fComPID[kNDaughters][AliPID::kSPECIES];//Combined PID, momentarily from TPC and TOF only
 
-  Float_t fMomentum;  // Momentum of track at the vertex
-
   Float_t fDCA;  // Distance of closest approach of daughter tracks
-  
   Float_t fPointingAngle;// = TMath::ACos(esdv0->GetV0CosineOfPointingAngle()); // Cosine of pointing angle
-  
   Float_t fOpenAngle;  // opening angle between daughters
-  
   Float_t fPsiPair; // /Angle between daughter momentum plane and plane perpendicular to magnetic field
-  
   Double_t fInvMass[kNDecays];  // invariant mass for different decay scenarios (conversions, K0s, Lambda->p+pi-, Lambda->p-pi+)
-
   Double_t fMagField; //magnetic field strength
-
   Float_t fRadius; //distance of decay/conversion from primary vertex in x-y plane
-
-  Int_t fTrackID;//track index
-
-
   Float_t fV0Momentum; //V0 mother's momentum
 
   //____________________________________________________________
@@ -175,16 +155,14 @@ private:
   Float_t fDownComPIDnegPart[AliPID::kSPECIES]; // Combined PID positive partner daughters (NOT the daughter track that would go into the reference data; here: pion daughters from Lambda decays; lower limit
   Float_t fDownComPIDposPart[AliPID::kSPECIES]; // Combined PID positive partner daughters (NOT the daughter track that would go into the reference data; here: pion daughters from Lambda decays; lower limit
  
-  AliESDtrack *fTrackP; //positive daughter
-  AliESDtrack *fTrackN; //negative daughter
-  AliESDtrack *fTrack; //the current track in the ESDtrack loop (either positive or negative)
-
+  AliESDtrack *fTrackP; //!positive daughter
+  AliESDtrack *fTrackN; //!negative daughter
 
-  Int_t fNindex; //indices of positive and negative daughter track
-  Int_t fPindex; //indices of positive and negative daughter track
+  Int_t       fNindex; //indices of positive and negative daughter track
+  Int_t       fPindex; //indices of positive and negative daughter track
   
   
-  ClassDef(AliTRDv0Info, 0) // extracted V0 MC information
+  ClassDef(AliTRDv0Info, 1) // extracted V0 MC information
 };