]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG/FLOW/Base/AliFlowVector.cxx
initial checkin of the new flow development - from an OLD diff!
[u/mrichter/AliRoot.git] / PWG / FLOW / Base / AliFlowVector.cxx
1 /*************************************************************************
2 * Copyright(c) 1998-2008, 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 #include "AliFlowVector.h"
17 #include "AliFlowTrackSimple.h"
18 #include "TMath.h"
19
20 //********************************************************************
21 // AliFlowVector:                                                    *
22 // Class to hold the flow vector and multiplicity for flow analysis. *
23 // Author: A. Bilandzic (anteb@nikhef.nl)                            *
24 // extended: M.Krzewicki (mikolaj.krzewicki@cern.ch)                 *
25 //********************************************************************
26
27 ClassImp(AliFlowVector)
28
29 //________________________________________________________________________
30
31 AliFlowVector::AliFlowVector():
32   TVector2(0.0,0.0),
33   fMult(0.0),
34   fHarmonic(2),
35   fPOItype(0),
36   fSubeventNumber(-1)
37 {
38   // default constructor
39 }
40
41 //________________________________________________________________________
42
43 AliFlowVector::AliFlowVector(const AliFlowVector& aVector):
44   TVector2(aVector),
45   fMult(aVector.fMult),
46   fHarmonic(aVector.fHarmonic),
47   fPOItype(aVector.fPOItype),
48   fSubeventNumber(aVector.fSubeventNumber)
49 {
50   // copy constructor
51 }
52
53 //________________________________________________________________________
54
55 AliFlowVector::AliFlowVector(Double_t *y, Double_t m, Int_t h, Int_t t, Int_t s):
56   TVector2(y),
57   fMult(m),
58   fHarmonic(h),
59   fPOItype(t),
60   fSubeventNumber(s)
61 {
62   // Analogue of TVector2 constructor. Sets (x,y) and multiplicity 1.
63 }
64
65  //________________________________________________________________________
66
67 AliFlowVector::AliFlowVector(const TVector2 &v, Double_t m, Int_t h, Int_t t, Int_t s):
68   TVector2(v),
69   fMult(m),
70   fHarmonic(h),
71   fPOItype(t),
72   fSubeventNumber(s)
73 {
74   // custom constructor, Sets vector and multiplicity
75 }
76
77  //________________________________________________________________________
78
79 AliFlowVector::AliFlowVector(Double_t x, Double_t y, Double_t m, Int_t h, Int_t t, Int_t s):
80   TVector2(x,y),
81   fMult(m),
82   fHarmonic(h),
83   fPOItype(t),
84   fSubeventNumber(s)
85 {
86   // custom constructor analogue of TVector2 constructor
87 }
88
89 //________________________________________________________________________ 
90
91 AliFlowVector::~AliFlowVector()
92 {
93   // default destructor 
94 }
95
96 void AliFlowVector::SetMagPhi(Double_t size, Double_t angle, Double_t mult)
97 {
98    // Analogue to SetMagPhi for a TVector2 but here including a sum of weights
99    TVector2::SetMagPhi(size,angle);
100    SetMult(mult);
101 }
102
103 //________________________________________________________________________
104
105 AliFlowVector& AliFlowVector::operator=(const AliFlowVector& aVector)
106 {
107   // assignement operator
108   if (this==&aVector) return *this;
109   fX = aVector.X();
110   fY = aVector.Y();
111   fMult = aVector.GetMult();
112   return *this;
113 }
114
115 //________________________________________________________________________
116
117 AliFlowVector& AliFlowVector::operator+=(const AliFlowVector& aVector)
118 {
119   // addition operator
120   fX += aVector.X(); 
121   fY += aVector.Y(); 
122   fMult += aVector.GetMult(); 
123   return *this;
124 }
125
126 AliFlowVector& AliFlowVector::operator-=(const AliFlowVector& aVector)
127 {
128   // subtraction operator
129   fX -= aVector.X(); 
130   fY -= aVector.Y(); 
131   fMult -= aVector.GetMult();
132   return *this;
133 }
134
135 AliFlowVector& AliFlowVector::operator*=(Double_t w)
136 {
137    // multiply by a weight operator
138    fX*=w;
139    fY*=w;
140    fMult*=w;
141    return *this;
142 }
143
144 //________________________________________________________________________
145 void AliFlowVector::Clear(Option_t* /*option*/)
146 {
147   //clear
148   fX=0.;
149   fY=0.;
150   fMult=0;
151   fHarmonic=2;
152   fPOItype=AliFlowTrackSimple::kRP;
153   fSubeventNumber=-1;
154 }
155
156 //________________________________________________________________________
157 Int_t AliFlowVector::SubtractTrackWithDaughters( const AliFlowTrackSimple* track, 
158                                                 Double_t extraWeight 
159                                               )
160 {
161   //subtract a track and all its daughters, only if tagged with flowTag and in specified
162   //subevent (-1 for no subevent selection)
163   //to only subtract if it was actually used in the construction of the vector)
164   //TODO: maybe make recursive if it ever becomes needed
165   //for complicated decay topologies
166   Bool_t inSubEvent=kTRUE;
167   if (fSubeventNumber>=0) 
168   {
169     inSubEvent = track->InSubevent(fSubeventNumber);
170   }
171   if (track->IsPOItype(fPOItype) && inSubEvent )
172   {
173     fX -= extraWeight * track->Weight() * TMath::Cos(fHarmonic*track->Phi());
174     fY -= extraWeight * track->Weight() * TMath::Sin(fHarmonic*track->Phi());
175   }
176   
177   Int_t numberOfsubtractedDaughters=0;
178   for (Int_t i=0; i<track->GetNDaughters(); i++)
179   {
180     AliFlowTrackSimple* daughter = track->GetDaughter(i);
181     if (!daughter) continue;
182     inSubEvent=kTRUE;
183     if (fSubeventNumber>=0) 
184     {
185       inSubEvent = daughter->InSubevent(fSubeventNumber);
186     }
187     if (daughter->IsPOItype(fPOItype) && inSubEvent )
188     {
189       fX -= extraWeight * daughter->Weight() * TMath::Cos(fHarmonic*daughter->Phi());
190       fY -= extraWeight * daughter->Weight() * TMath::Sin(fHarmonic*daughter->Phi());
191       numberOfsubtractedDaughters++;
192     }
193   }
194   return numberOfsubtractedDaughters;
195 }