From 701f71c1b724da02b3b8548a286cefcbaf3b9c66 Mon Sep 17 00:00:00 2001 From: snelling Date: Tue, 10 Aug 2010 15:51:08 +0000 Subject: [PATCH] Added charge to the tracks --- .../FLOW/AliFlowCommon/AliFlowEventSimple.cxx | 26 +++++++++------ .../FLOW/AliFlowCommon/AliFlowTrackSimple.cxx | 13 ++++++-- PWG2/FLOW/AliFlowCommon/AliFlowTrackSimple.h | 16 +++++++--- .../AliFlowCommon/AliFlowTrackSimpleCuts.cxx | 32 +++++++++++++------ .../AliFlowCommon/AliFlowTrackSimpleCuts.h | 7 +++- PWG2/FLOW/AliFlowTasks/AliFlowEvent.cxx | 20 +++--------- PWG2/FLOW/AliFlowTasks/AliFlowTrack.cxx | 7 +++- 7 files changed, 78 insertions(+), 43 deletions(-) diff --git a/PWG2/FLOW/AliFlowCommon/AliFlowEventSimple.cxx b/PWG2/FLOW/AliFlowCommon/AliFlowEventSimple.cxx index 6cbf50e61d6..8d956fc3456 100644 --- a/PWG2/FLOW/AliFlowCommon/AliFlowEventSimple.cxx +++ b/PWG2/FLOW/AliFlowCommon/AliFlowEventSimple.cxx @@ -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; iUniform(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(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(fTrackCollection->At(i)); if (!track) continue; - if (cuts->PassesCuts(track)) track->SetForPOISelection(); + Bool_t pass=cuts->PassesCuts(track); + track->SetForPOISelection(pass); } } diff --git a/PWG2/FLOW/AliFlowCommon/AliFlowTrackSimple.cxx b/PWG2/FLOW/AliFlowCommon/AliFlowTrackSimple.cxx index f8012d8da3e..6b81f7f2f7a 100644 --- a/PWG2/FLOW/AliFlowCommon/AliFlowTrackSimple.cxx +++ b/PWG2/FLOW/AliFlowCommon/AliFlowTrackSimple.cxx @@ -24,8 +24,10 @@ #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; diff --git a/PWG2/FLOW/AliFlowCommon/AliFlowTrackSimple.h b/PWG2/FLOW/AliFlowCommon/AliFlowTrackSimple.h index 3e0f113e11a..a954b0dea12 100644 --- a/PWG2/FLOW/AliFlowCommon/AliFlowTrackSimple.h +++ b/PWG2/FLOW/AliFlowCommon/AliFlowTrackSimple.h @@ -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); } diff --git a/PWG2/FLOW/AliFlowCommon/AliFlowTrackSimpleCuts.cxx b/PWG2/FLOW/AliFlowCommon/AliFlowTrackSimpleCuts.cxx index 2f274653076..fd6ce8872f8 100644 --- a/PWG2/FLOW/AliFlowCommon/AliFlowTrackSimpleCuts.cxx +++ b/PWG2/FLOW/AliFlowCommon/AliFlowTrackSimpleCuts.cxx @@ -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; } diff --git a/PWG2/FLOW/AliFlowCommon/AliFlowTrackSimpleCuts.h b/PWG2/FLOW/AliFlowCommon/AliFlowTrackSimpleCuts.h index 894b8f6e742..e66068bd1f2 100644 --- a/PWG2/FLOW/AliFlowCommon/AliFlowTrackSimpleCuts.h +++ b/PWG2/FLOW/AliFlowCommon/AliFlowTrackSimpleCuts.h @@ -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) }; diff --git a/PWG2/FLOW/AliFlowTasks/AliFlowEvent.cxx b/PWG2/FLOW/AliFlowTasks/AliFlowEvent.cxx index b234270366f..0a59cd908ec 100644 --- a/PWG2/FLOW/AliFlowTasks/AliFlowEvent.cxx +++ b/PWG2/FLOW/AliFlowTasks/AliFlowEvent.cxx @@ -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) diff --git a/PWG2/FLOW/AliFlowTasks/AliFlowTrack.cxx b/PWG2/FLOW/AliFlowTasks/AliFlowTrack.cxx index fdf49535ffb..3ebfd14ccf1 100644 --- a/PWG2/FLOW/AliFlowTasks/AliFlowTrack.cxx +++ b/PWG2/FLOW/AliFlowTasks/AliFlowTrack.cxx @@ -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()); } //----------------------------------------------------------------------- -- 2.43.0