]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG/FLOW/Base/AliFlowTrackSimpleCuts.cxx
AOD handeling, added mass to the flowtracks, new task to reuse flowevent
[u/mrichter/AliRoot.git] / PWG / FLOW / Base / AliFlowTrackSimpleCuts.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */ 
17
18 // AliFlowTrackSimpleCuts:
19 // A simple track cut class to the the AliFlowTrackSimple 
20 // for basic kinematic cuts
21 //
22 // author: N. van der Kolk (kolk@nikhef.nl)
23 // mods: Mikolaj Krzewicki (mikolaj.krzewicki@cern.ch)
24
25 #include <limits.h>
26 #include <float.h>
27 #include "TNamed.h"
28 #include "TParticle.h"
29 #include "TParticlePDG.h"
30 #include "AliFlowTrackSimpleCuts.h"
31 #include "AliFlowTrackSimple.h"
32
33 ClassImp(AliFlowTrackSimpleCuts)
34
35 //-----------------------------------------------------------------------
36 AliFlowTrackSimpleCuts::AliFlowTrackSimpleCuts(const char* name):
37   TNamed(name,name),
38   fCutPt(kFALSE),
39   fPtMax(FLT_MAX),
40   fPtMin(-FLT_MAX),
41   fCutEta(kFALSE),
42   fEtaMax(FLT_MAX),
43   fEtaMin(-FLT_MAX),
44   fCutPhi(kFALSE),
45   fPhiMax(FLT_MAX),
46   fPhiMin(-FLT_MAX),
47   fCutPID(kFALSE),
48   fPID(0),
49   fCutCharge(kFALSE),
50   fCharge(0),
51   fCutMass(kFALSE),
52   fMassMax(FLT_MAX),
53   fMassMin(-FLT_MAX)
54 {
55   //constructor 
56 }
57
58 ////-----------------------------------------------------------------------
59 //AliFlowTrackSimpleCuts::AliFlowTrackSimpleCuts(const AliFlowTrackSimpleCuts& someCuts):
60 //  TNamed(),
61 //  fCutPt(someCuts.fCutPt),
62 //  fPtMax(someCuts.fPtMax),
63 //  fPtMin(someCuts.fPtMin),
64 //  fCutEta(someCuts.fCutEta),
65 //  fEtaMax(someCuts.fEtaMax),
66 //  fEtaMin(someCuts.fEtaMin),
67 //  fCutPhi(someCuts.fCutPhi),
68 //  fPhiMax(someCuts.fPhiMax),
69 //  fPhiMin(someCuts.fPhiMin),
70 //  fCutPID(someCuts.fCutPID),
71 //  fPID(someCuts.fPID),
72 //  fCutCharge(someCuts.fCutCharge),
73 //  fCharge(someCuts.fCharge)
74 //{
75 //  //copy constructor 
76 //}
77 //
78 ////-----------------------------------------------------------------------
79 //AliFlowTrackSimpleCuts& AliFlowTrackSimpleCuts::operator=(const AliFlowTrackSimpleCuts& someCuts)
80 //{
81 //  TNamed::operator=(someCuts);
82 //  fCutPt  = someCuts.fCutPt;
83 //  fPtMax  = someCuts.fPtMax;
84 //  fPtMin  = someCuts.fPtMin;
85 //  fCutEta = someCuts.fCutEta;
86 //  fEtaMax = someCuts.fEtaMax;
87 //  fEtaMin = someCuts.fEtaMin;
88 //  fCutPhi = someCuts.fCutPhi;
89 //  fPhiMax = someCuts.fPhiMax;
90 //  fPhiMin = someCuts.fPhiMin;
91 //  fCutPID = someCuts.fCutPID;
92 //  fPID    = someCuts.fPID;
93 //  fCutCharge = someCuts.fCutCharge;
94 //  fCharge = someCuts.fCharge;
95 //
96 //  return *this;
97 //}
98
99 //----------------------------------------------------------------------- 
100 Bool_t AliFlowTrackSimpleCuts::IsSelected(TObject* obj, Int_t)
101 {
102   //check cuts
103   TParticle* p = dynamic_cast<TParticle*>(obj);
104   if (p) return PassesCuts(p);
105   AliFlowTrackSimple* ts = dynamic_cast<AliFlowTrackSimple*>(obj);
106   if (ts) return PassesCuts(ts);
107   return kFALSE; //default when passed a wrong type of object
108 }
109
110 //----------------------------------------------------------------------- 
111 Bool_t AliFlowTrackSimpleCuts::PassesCuts(const AliFlowTrackSimple *track) const
112 {
113   //simple method to check if the simple track passes the simple cuts
114   if(fCutPt) {if (track->Pt() < fPtMin || track->Pt() >= fPtMax ) return kFALSE;}
115   if(fCutEta) {if (track->Eta() < fEtaMin || track->Eta() >= fEtaMax ) return kFALSE;}
116   if(fCutPhi) {if (track->Phi() < fPhiMin || track->Phi() >= fPhiMax ) return kFALSE;}
117   if(fCutCharge) {if (track->Charge() != fCharge) return kFALSE;}
118   if(fCutMass) {if (track->Mass() < fMassMin || track->Mass() >= fMassMax ) return kFALSE;}
119   //if(fCutPID) {if (track->PID() != fPID) return kFALSE;}
120   return kTRUE;
121 }
122
123 //----------------------------------------------------------------------- 
124 Bool_t AliFlowTrackSimpleCuts::PassesCuts(TParticle* track) const
125 {
126   //simple method to check if the simple track passes the simple cuts
127   if(fCutPt)  {if (track->Pt() < fPtMin || track->Pt() >= fPtMax ) return kFALSE;}
128   if(fCutEta) {if (track->Eta() < fEtaMin || track->Eta() >= fEtaMax ) return kFALSE;}
129   if(fCutPhi) {if (track->Phi() < fPhiMin || track->Phi() >= fPhiMax ) return kFALSE;}
130   //if(fCutPID) {if (track->GetPdgCode() != fPID) return kFALSE;}
131
132   //getting the charge from a tparticle is expensive
133   //only do it if neccesary
134   if (fCutCharge) 
135   {
136     TParticlePDG* ppdg = track->GetPDG();
137     Int_t charge = TMath::Nint(ppdg->Charge()/3.0); //mc particles have charge in units of 1/3e
138     return (charge==fCharge);
139   }
140
141   if (fCutMass) {
142     TParticlePDG* ppdg = track->GetPDG();
143     if (ppdg->Mass() < fMassMin || ppdg->Mass() >= fMassMax )
144       return kFALSE;
145   }
146
147   return kTRUE;
148 }