]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Added charge to the tracks
authorsnelling <snelling@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 10 Aug 2010 15:51:08 +0000 (15:51 +0000)
committersnelling <snelling@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 10 Aug 2010 15:51:08 +0000 (15:51 +0000)
PWG2/FLOW/AliFlowCommon/AliFlowEventSimple.cxx
PWG2/FLOW/AliFlowCommon/AliFlowTrackSimple.cxx
PWG2/FLOW/AliFlowCommon/AliFlowTrackSimple.h
PWG2/FLOW/AliFlowCommon/AliFlowTrackSimpleCuts.cxx
PWG2/FLOW/AliFlowCommon/AliFlowTrackSimpleCuts.h
PWG2/FLOW/AliFlowTasks/AliFlowEvent.cxx
PWG2/FLOW/AliFlowTasks/AliFlowTrack.cxx

index 6cbf50e61d693b8df67a7e0be63ef13778a3d946..8d956fc3456ce5bb382a8b9d491a3f7fd8fea874 100644 (file)
@@ -38,8 +38,8 @@
 #include "TBrowser.h"
 #include "AliFlowVector.h"
 #include "AliFlowTrackSimple.h"
-#include "AliFlowEventSimple.h"
 #include "AliFlowTrackSimpleCuts.h"
+#include "AliFlowEventSimple.h"
 #include "TRandom.h"
 
 ClassImp(AliFlowEventSimple)
@@ -120,6 +120,7 @@ AliFlowEventSimple::AliFlowEventSimple(const AliFlowEventSimple& anEvent):
 AliFlowEventSimple& AliFlowEventSimple::operator=(const AliFlowEventSimple& anEvent)
 {
   //assignment operator
+  if (fTrackCollection) fTrackCollection->Delete();
   delete fTrackCollection;
   fTrackCollection = (TObjArray*)(anEvent.fTrackCollection)->Clone(); //deep copy
   fReferenceMultiplicity = anEvent.fReferenceMultiplicity;
@@ -157,9 +158,12 @@ void AliFlowEventSimple::Generate(Int_t nParticles,
   //according to the specified pt distribution
   for (Int_t i=0; i<nParticles; i++)
   {
-    AddTrack(new AliFlowTrackSimple( gRandom->Uniform(phiMin,phiMax),
-                                     gRandom->Uniform(etaMin,etaMax),
-                                     ptDist->GetRandom(),1.));
+    AliFlowTrackSimple* track = new AliFlowTrackSimple();
+    track->SetPhi( gRandom->Uniform(phiMin,phiMax) );
+    track->SetEta( gRandom->Uniform(etaMin,etaMax) );
+    track->SetPt( ptDist->GetRandom() );
+    track->SetCharge( (gRandom->Uniform()-0.5<0)?-1:1 );
+    AddTrack(track);
   }
 }
 
@@ -250,7 +254,7 @@ AliFlowVector AliFlowEventSimple::GetQ(Int_t n, TList *weightsList, Bool_t usePh
         dPhi = pTrack->Phi();
         dPt  = pTrack->Pt();
         dEta = pTrack->Eta();
-       dWeight = pTrack->Weight();
+             dWeight = pTrack->Weight();
 
         // determine Phi weight: (to be improved, I should here only access it + the treatment of gaps in the if statement)
         if(phiWeights && nBinsPhi)
@@ -620,11 +624,12 @@ void AliFlowEventSimple::TagRP( AliFlowTrackSimpleCuts* cuts )
   {
     AliFlowTrackSimple* track = static_cast<AliFlowTrackSimple*>(fTrackCollection->At(i));
     if (!track) continue;
-    if (cuts->PassesCuts(track)) 
-    {
-      track->SetForRPSelection();
+    Bool_t pass=cuts->PassesCuts(track);
+    track->SetForRPSelection(pass);
+    if (pass) 
       fNumberOfRPs++;
-    }
+    else
+      fNumberOfRPs--;
   }
 }
 
@@ -636,7 +641,8 @@ void AliFlowEventSimple::TagPOI( AliFlowTrackSimpleCuts* cuts )
   {
     AliFlowTrackSimple* track = static_cast<AliFlowTrackSimple*>(fTrackCollection->At(i));
     if (!track) continue;
-    if (cuts->PassesCuts(track)) track->SetForPOISelection();
+    Bool_t pass=cuts->PassesCuts(track);
+    track->SetForPOISelection(pass);
   }
 }
 
index f8012d8da3e4526527cedd22cbb002a80792ea31..6b81f7f2f7a8802d21178574d901bee5df3872ab 100644 (file)
 
 #include "TObject.h"
 #include "TParticle.h"
+#include "TParticlePDG.h"
 #include "AliFlowTrackSimple.h"
 #include "TRandom.h"
+#include "TMath.h"
 
 ClassImp(AliFlowTrackSimple)
 
@@ -36,6 +38,7 @@ AliFlowTrackSimple::AliFlowTrackSimple():
   fPt(0),
   fPhi(0),
   fTrackWeight(1.),
+  fCharge(0),
   fFlowBits(0),
   fSubEventBits(0)
 {
@@ -43,12 +46,13 @@ AliFlowTrackSimple::AliFlowTrackSimple():
 }
 
 //-----------------------------------------------------------------------
-AliFlowTrackSimple::AliFlowTrackSimple(Double_t phi, Double_t eta, Double_t pt, Double_t weight):
+AliFlowTrackSimple::AliFlowTrackSimple(Double_t phi, Double_t eta, Double_t pt, Double_t weight, Int_t charge):
   TObject(),
   fEta(eta),
   fPt(pt),
   fPhi(phi),
   fTrackWeight(weight),
+  fCharge(charge),
   fFlowBits(0),
   fSubEventBits(0)
 {
@@ -56,16 +60,19 @@ AliFlowTrackSimple::AliFlowTrackSimple(Double_t phi, Double_t eta, Double_t pt,
 }
 
 //-----------------------------------------------------------------------
-AliFlowTrackSimple::AliFlowTrackSimple(const TParticle* p):
+AliFlowTrackSimple::AliFlowTrackSimple( TParticle* p ):
   TObject(),
   fEta(p->Eta()),
   fPt(p->Pt()),
   fPhi(p->Phi()),
   fTrackWeight(1.),
+  fCharge(0),
   fFlowBits(0),
   fSubEventBits(0)
 {
   //ctor
+  TParticlePDG* ppdg = p->GetPDG();
+  fCharge = TMath::Nint(ppdg->Charge()/3.0);
 }
 
 //-----------------------------------------------------------------------
@@ -75,6 +82,7 @@ AliFlowTrackSimple::AliFlowTrackSimple(const AliFlowTrackSimple& aTrack):
   fPt(aTrack.fPt),
   fPhi(aTrack.fPhi),
   fTrackWeight(aTrack.fTrackWeight),
+  fCharge(aTrack.fCharge),
   fFlowBits(aTrack.fFlowBits),
   fSubEventBits(aTrack.fSubEventBits)
 {
@@ -95,6 +103,7 @@ AliFlowTrackSimple& AliFlowTrackSimple::operator=(const AliFlowTrackSimple& aTra
   fPt = aTrack.fPt;
   fPhi = aTrack.fPhi;
   fTrackWeight = aTrack.fTrackWeight;
+  fCharge = aTrack.fCharge;
   fFlowBits = aTrack.fFlowBits;
   fSubEventBits = aTrack.fSubEventBits;
 
index 3e0f113e11ac78bafe31c44886d0a39e5128ab99..a954b0dea12dfed56539d0d37f47614fb7953342 100644 (file)
@@ -18,9 +18,8 @@ class AliFlowTrackSimple: public TObject {
 
 public:
   AliFlowTrackSimple();
-  AliFlowTrackSimple(const TParticle* p);
+  AliFlowTrackSimple(TParticle* p);
   AliFlowTrackSimple(const AliFlowTrackSimple& aTrack);
-  AliFlowTrackSimple(Double_t phi, Double_t eta, Double_t pt, Double_t weight);
   virtual AliFlowTrackSimple& operator=(const AliFlowTrackSimple& aTrack);
   virtual  ~AliFlowTrackSimple();
   virtual AliFlowTrackSimple* Clone(const char* option="") const;
@@ -33,6 +32,8 @@ public:
   Double_t Pt()  const; 
   Double_t Phi() const;
   Double_t Weight() const; 
+  Int_t Charge() const;
+  
 
   Bool_t InRPSelection() const; 
   Bool_t InPOISelection() const; 
@@ -43,6 +44,7 @@ public:
   void SetPt(Double_t pt); 
   void SetPhi(Double_t phi);
   void SetWeight(Double_t weight);
+  void SetCharge(Int_t charge);
   void SetForRPSelection(Bool_t b=kTRUE); 
   void SetForPOISelection(Bool_t b=kTRUE); 
   void SetForSubevent(Int_t i); 
@@ -73,10 +75,12 @@ public:
   const TBits* GetFlowBits() const {return &fFlowBits;}
 
  private:
+  AliFlowTrackSimple(Double_t phi, Double_t eta, Double_t pt, Double_t weight, Int_t charge);
   Double_t fEta;         // eta
   Double_t fPt;          // pt
   Double_t fPhi;         // phi
   Double_t fTrackWeight; // weight
+  Int_t fCharge;         //charge
   TBits    fFlowBits;    // bits to set if track is selected
   TBits    fSubEventBits;// bits to set if track is selected for a subevent
 
@@ -84,7 +88,7 @@ public:
 
 };
 
-//Setters
+//Getters
 inline Double_t AliFlowTrackSimple::Eta() const { 
   return this->fEta; }
 inline Double_t AliFlowTrackSimple::Pt() const {  
@@ -93,6 +97,8 @@ inline Double_t AliFlowTrackSimple::Phi() const {
   return this->fPhi; }
 inline Double_t AliFlowTrackSimple::Weight() const { 
   return this->fTrackWeight; }
+inline Int_t AliFlowTrackSimple::Charge() const { 
+  return this->fCharge; }
 //TBits
 inline Bool_t AliFlowTrackSimple::InRPSelection() const { 
   return this->fFlowBits.TestBitNumber(0); }
@@ -101,7 +107,7 @@ inline Bool_t AliFlowTrackSimple::InPOISelection() const {
 inline Bool_t AliFlowTrackSimple::InSubevent(Int_t i) const { 
   return this->fSubEventBits.TestBitNumber(i); }
 
-//Getters
+//Setters
 inline void AliFlowTrackSimple::SetEta(Double_t val) {
   fEta = val; }
 inline void AliFlowTrackSimple::SetPt(Double_t val) {
@@ -110,6 +116,8 @@ inline void AliFlowTrackSimple::SetPhi(Double_t val) {
   fPhi = val; }
 inline void AliFlowTrackSimple::SetWeight(Double_t val) {
   fTrackWeight = val; }
+inline void AliFlowTrackSimple::SetCharge(Int_t val) {
+  fCharge = val; }
 //TBits
 inline void AliFlowTrackSimple::SetForRPSelection(Bool_t val) {
   fFlowBits.SetBitNumber(0,val); }
index 2f274653076f851ab97b3240892a85cc125bf6ce..fd6ce8872f82f8272d2e3971550024ad3672f781 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "TNamed.h"
 #include "TParticle.h"
+#include "TParticlePDG.h"
 #include "AliFlowTrackSimpleCuts.h"
 #include "AliFlowTrackSimple.h"
 
@@ -37,7 +38,8 @@ AliFlowTrackSimpleCuts::AliFlowTrackSimpleCuts():
   fEtaMin(0.),
   fPhiMax(0.),
   fPhiMin(0.),
-  fPID(0) 
+  fPID(0),
+  fCharge(fgkIgnoreCharge)
 {
   //constructor 
   
@@ -52,7 +54,8 @@ AliFlowTrackSimpleCuts::AliFlowTrackSimpleCuts(const AliFlowTrackSimpleCuts& som
   fEtaMin(someCuts.fEtaMin),
   fPhiMax(someCuts.fPhiMax),
   fPhiMin(someCuts.fPhiMin),
-  fPID(someCuts.fPID)
+  fPID(someCuts.fPID),
+  fCharge(someCuts.fCharge)
 {
   //copy constructor 
 }
@@ -67,6 +70,7 @@ AliFlowTrackSimpleCuts& AliFlowTrackSimpleCuts::operator=(const AliFlowTrackSimp
   fPhiMax = someCuts.fPhiMax;
   fPhiMin = someCuts.fPhiMin;
   fPID    = someCuts.fPID;
+  fCharge = someCuts.fCharge;
 
   return *this;
 
@@ -85,20 +89,28 @@ Bool_t AliFlowTrackSimpleCuts::PassesCuts(const AliFlowTrackSimple *track) const
   //simple method to check if the simple track passes the simple cuts
   if(track->Pt() >= fPtMin && track->Pt() < fPtMax &&
      track->Eta() >= fEtaMin && track->Eta() < fEtaMax &&
-     track->Phi() >= fPhiMin && track->Phi() < fPhiMax)
+     track->Phi() >= fPhiMin && track->Phi() < fPhiMax &&
+     (track->Charge()==fCharge || fCharge==fgkIgnoreCharge))
     { return kTRUE; } 
   else
     { return kFALSE; }  
 }
 
 //----------------------------------------------------------------------- 
-Bool_t AliFlowTrackSimpleCuts::PassesCuts(const TParticle* track) const
+Bool_t AliFlowTrackSimpleCuts::PassesCuts(TParticle* track) const
 {
   //simple method to check if the simple track passes the simple cuts
-  if(track->Pt() >= fPtMin && track->Pt() < fPtMax &&
-     track->Eta() >= fEtaMin && track->Eta() < fEtaMax &&
-     track->Phi() >= fPhiMin && track->Phi() < fPhiMax)
-    return kTRUE; 
-  else
-    return kFALSE; 
+  Bool_t result = (track->Pt() >= fPtMin && track->Pt() < fPtMax &&
+                   track->Eta() >= fEtaMin && track->Eta() < fEtaMax &&
+                   track->Phi() >= fPhiMin && track->Phi() < fPhiMax);
+
+  //getting the charge from a tparticle is expensive
+  //only do it if neccesary
+  if (fCharge!=fgkIgnoreCharge) 
+  {
+    TParticlePDG* ppdg = track->GetPDG();
+    Int_t charge = TMath::Nint(ppdg->Charge()/3.0);
+    result = (charge==fCharge) && result;
+  }
+  return result;
 }
index 894b8f6e7428af0faedfa6fe704d4361540c0bfe..e66068bd1f2769994e3e3edd2662bbc632df7466 100644 (file)
@@ -32,6 +32,7 @@ class AliFlowTrackSimpleCuts : public TNamed {
   void SetPhiMax(Double_t max)  {this->fPhiMax = max; }
   void SetPhiMin(Double_t min)  {this->fPhiMin = min; }
   void SetPID(Int_t pid)        {this->fPID = pid; }
+  void SetCharge(Int_t c)       {this->fCharge = c; }
   
   //getters
   Double_t GetPtMax() const     {return this->fPtMax; }
@@ -41,10 +42,11 @@ class AliFlowTrackSimpleCuts : public TNamed {
   Double_t GetPhiMax() const    {return this->fPhiMax; }
   Double_t GetPhiMin() const    {return this->fPhiMin; }
   Int_t    GetPID() const       {return this->fPID; }
+  Int_t    GetCharge() const    {return this->fCharge; }
   
   //simple method to check if the simple track passes the simple cuts:
   Bool_t PassesCuts(const AliFlowTrackSimple *track) const;
-  Bool_t PassesCuts(const TParticle* p) const;
+  Bool_t PassesCuts(TParticle* p) const;
 
  private:
   Double_t fPtMax;
@@ -54,6 +56,9 @@ class AliFlowTrackSimpleCuts : public TNamed {
   Double_t fPhiMax;
   Double_t fPhiMin;
   Int_t    fPID;
+  Int_t    fCharge;
+
+  static const Int_t fgkIgnoreCharge=999;
 
   ClassDef(AliFlowTrackSimpleCuts,1)
 };
index b234270366f70cfb1f6b89fadb85b537c758f2a1..0a59cd908ec6179202ad83e185037a74ffa65c4b 100644 (file)
@@ -337,18 +337,14 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
     if (!(rpOK || poiOK)) continue;
 
     //make new AliFlowTrack
-    AliFlowTrack* pTrack = new AliFlowTrack();
+    AliFlowTrack* pTrack = NULL;
     if(anOption == kESDkine)   //take the PID from the MC & the kinematics from the ESD
     {
-      pTrack->SetPt(pParticle->Pt() );
-      pTrack->SetEta(pParticle->Eta() );
-      pTrack->SetPhi(pParticle->Phi() );
+      pTrack = new AliFlowTrack(pParticle);
     }
     else if (anOption == kMCkine)   //take the PID and kinematics from the MC
     {
-      pTrack->SetPt(pMcParticle->Pt() );
-      pTrack->SetEta(pMcParticle->Eta() );
-      pTrack->SetPhi(pMcParticle->Phi() );
+      pTrack = new AliFlowTrack(pMcParticle);
     }
 
     if (rpOK && rpCFManager)
@@ -388,10 +384,7 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
       if (!poiOK) continue;
       
       //make new AliFLowTrack
-      AliFlowTrack* pTrack = new AliFlowTrack();
-      pTrack->SetPt(pParticle->Pt() );
-      pTrack->SetEta(pParticle->Eta() );
-      pTrack->SetPhi(pParticle->Phi() );
+      AliFlowTrack* pTrack = new AliFlowTrack(pParticle);
           
       //marking the particles used for the particle of interest (POI) selection:
       if(poiOK && poiCFManager)
@@ -456,10 +449,7 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
       if (!poiOK) continue;
  
       //make new AliFLowTrack
-      AliFlowTrack* pTrack = new AliFlowTrack();
-      pTrack->SetPt(pParticle->Pt() );
-      pTrack->SetEta(pParticle->Eta() );
-      pTrack->SetPhi(pParticle->Phi() );
+      AliFlowTrack* pTrack = new AliFlowTrack(pParticle);
           
       //marking the particles used for the particle of interest (POI) selection:
       if(poiOK && poiCFManager)
index fdf49535ffbf5a0dda9113e39e80c1795389203d..3ebfd14ccf14767afba4922bd0dc1758e916322d 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "AliVParticle.h"
 #include "AliFlowTrack.h"
+#include "AliFlowTrackSimple.h"
 
 ClassImp(AliFlowTrack)
 
@@ -34,10 +35,14 @@ AliFlowTrack::AliFlowTrack():
 
 //-----------------------------------------------------------------------
 AliFlowTrack::AliFlowTrack(AliVParticle* p):
-  AliFlowTrackSimple(p->Phi(),p->Eta(),p->Pt(),1.),
+  AliFlowTrackSimple(),
   fTrackSourceBits()
 {
   //constructor 
+  SetPhi(p->Phi());
+  SetEta(p->Eta());
+  SetPt(p->Pt());
+  SetCharge(p->Charge());
 }
 
 //-----------------------------------------------------------------------