]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG/FLOW/Base/AliFlowTrackSimpleCuts.cxx
coverity fixes
[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), Redmer Bertens (rbertens@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   fCutEtaGap(kFALSE),
45   fEtaGapMax(0.),
46   fEtaGapMin(0.),
47   fCutPhi(kFALSE),
48   fPhiMax(FLT_MAX),
49   fPhiMin(-FLT_MAX),
50   fCutPID(kFALSE),
51   fPID(0),
52   fCutCharge(kFALSE),
53   fCharge(0),
54   fCutMass(kFALSE),
55   fMassMax(FLT_MAX),
56   fMassMin(-FLT_MAX),
57   fPOItype(1)
58 {
59   //constructor 
60 }
61
62 ////-----------------------------------------------------------------------
63 //AliFlowTrackSimpleCuts::AliFlowTrackSimpleCuts(const AliFlowTrackSimpleCuts& someCuts):
64 //  TNamed(),
65 //  fCutPt(someCuts.fCutPt),
66 //  fPtMax(someCuts.fPtMax),
67 //  fPtMin(someCuts.fPtMin),
68 //  fCutEta(someCuts.fCutEta),
69 //  fEtaMax(someCuts.fEtaMax),
70 //  fEtaMin(someCuts.fEtaMin),
71 //  fCutPhi(someCuts.fCutPhi),
72 //  fPhiMax(someCuts.fPhiMax),
73 //  fPhiMin(someCuts.fPhiMin),
74 //  fCutPID(someCuts.fCutPID),
75 //  fPID(someCuts.fPID),
76 //  fCutCharge(someCuts.fCutCharge),
77 //  fCharge(someCuts.fCharge)
78 //{
79 //  //copy constructor 
80 //}
81 //
82 ////-----------------------------------------------------------------------
83 //AliFlowTrackSimpleCuts& AliFlowTrackSimpleCuts::operator=(const AliFlowTrackSimpleCuts& someCuts)
84 //{
85 //  TNamed::operator=(someCuts);
86 //  fCutPt  = someCuts.fCutPt;
87 //  fPtMax  = someCuts.fPtMax;
88 //  fPtMin  = someCuts.fPtMin;
89 //  fCutEta = someCuts.fCutEta;
90 //  fEtaMax = someCuts.fEtaMax;
91 //  fEtaMin = someCuts.fEtaMin;
92 //  fCutPhi = someCuts.fCutPhi;
93 //  fPhiMax = someCuts.fPhiMax;
94 //  fPhiMin = someCuts.fPhiMin;
95 //  fCutPID = someCuts.fCutPID;
96 //  fPID    = someCuts.fPID;
97 //  fCutCharge = someCuts.fCutCharge;
98 //  fCharge = someCuts.fCharge;
99 //
100 //  return *this;
101 //}
102
103 //----------------------------------------------------------------------- 
104 Bool_t AliFlowTrackSimpleCuts::IsSelected(TObject* obj, Int_t)
105 {
106   //check cuts
107   TParticle* p = dynamic_cast<TParticle*>(obj);
108   if (p) return PassesCuts(p);
109   AliFlowTrackSimple* ts = dynamic_cast<AliFlowTrackSimple*>(obj);
110   if (ts) return PassesCuts(ts);
111   return kFALSE; //default when passed a wrong type of object
112 }
113
114 //----------------------------------------------------------------------- 
115 Bool_t AliFlowTrackSimpleCuts::PassesCuts(const AliFlowTrackSimple *track) const
116 {
117   //simple method to check if the simple track passes the simple cuts
118   if(fCutPt) {if (track->Pt() < fPtMin || track->Pt() >= fPtMax ) return kFALSE;}
119   if(fCutEta) {if (track->Eta() < fEtaMin || track->Eta() >= fEtaMax ) return kFALSE;}
120   if(fCutPhi) {if (track->Phi() < fPhiMin || track->Phi() >= fPhiMax ) return kFALSE;}
121   if(fCutCharge) {if (track->Charge() != fCharge) return kFALSE;}
122   if(fCutMass) {if (track->Mass() < fMassMin || track->Mass() >= fMassMax ) return kFALSE;}
123   if(fCutEtaGap) {if (track->Eta() > fEtaGapMin && track->Eta() < fEtaGapMax) return kFALSE;}
124   //if(fCutPID) {if (track->PID() != fPID) return kFALSE;}
125   return kTRUE;
126 }
127
128 //----------------------------------------------------------------------- 
129 Bool_t AliFlowTrackSimpleCuts::PassesCuts(TParticle* track) const
130 {
131   //simple method to check if the simple track passes the simple cuts
132   if(fCutPt)  {if (track->Pt() < fPtMin || track->Pt() >= fPtMax ) return kFALSE;}
133   if(fCutEta) {if (track->Eta() < fEtaMin || track->Eta() >= fEtaMax ) return kFALSE;}
134   if(fCutPhi) {if (track->Phi() < fPhiMin || track->Phi() >= fPhiMax ) return kFALSE;}
135   if(fCutEtaGap) {if (track->Eta() > fEtaGapMin && track->Eta() < fEtaGapMax) return kFALSE;}
136
137   //if(fCutPID) {if (track->GetPdgCode() != fPID) return kFALSE;}
138
139   //getting the charge from a tparticle is expensive
140   //only do it if neccesary
141   if (fCutCharge) 
142   {
143     TParticlePDG* ppdg = track->GetPDG();
144     Int_t charge = TMath::Nint(ppdg->Charge()/3.0); //mc particles have charge in units of 1/3e
145     return (charge==fCharge);
146   }
147
148   if (fCutMass) {
149     TParticlePDG* ppdg = track->GetPDG();
150     if (ppdg->Mass() < fMassMin || ppdg->Mass() >= fMassMax )
151       return kFALSE;
152   }
153
154   return kTRUE;
155 }