Extension for AOD
[u/mrichter/AliRoot.git] / STEER / STEERBase / AliEventplane.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 //*****************************************************
17 //   Class AliEventplane
18 //   author: Alberica Toia, Johanna Gramling
19 //*****************************************************
20 /// A container for the event plane stored in AOD in ESD
21  
22 #include "AliEventplane.h"
23 #include "TVector2.h"
24 #include "AliVTrack.h"
25 #include "TObjArray.h"
26 #include "TArrayF.h"
27
28 ClassImp(AliEventplane)
29
30 AliEventplane::AliEventplane() : TNamed("Eventplane", "Eventplane"),
31   fQVector(0),
32   fQContributionX(0),
33   fQContributionY(0),
34   fQContributionXsub1(0),
35   fQContributionYsub1(0),
36   fQContributionXsub2(0),
37   fQContributionYsub2(0),
38   fEventplaneQ(-1),
39   fQsub1(0),
40   fQsub2(0),
41   fQsubRes(0)
42 {
43   /// constructor
44   fQContributionX = new TArrayF(0);
45   fQContributionY = new TArrayF(0);
46   fQContributionXsub1 = new TArrayF(0);
47   fQContributionYsub1 = new TArrayF(0);
48   fQContributionXsub2 = new TArrayF(0);
49   fQContributionYsub2 = new TArrayF(0);
50 }
51
52 AliEventplane::AliEventplane(const AliEventplane& ep) : 
53   TNamed(),
54   fQVector(0),
55   fQContributionX(0),
56   fQContributionY(0),
57   fQContributionXsub1(0),
58   fQContributionYsub1(0),
59   fQContributionXsub2(0),
60   fQContributionYsub2(0),
61   fEventplaneQ(0),
62   fQsub1(0),
63   fQsub2(0),
64   fQsubRes(0)
65 {
66   /// Copy constructor
67   ((AliEventplane &) ep).CopyEP(*this);
68 }
69
70 AliEventplane& AliEventplane::operator=(const AliEventplane& ep)
71 {
72   /// Assignment operator
73   if (this!=&ep)
74     ((AliEventplane &) ep).CopyEP(*this);
75
76   return *this;
77 }
78
79 void AliEventplane::CopyEP(AliEventplane& ep) const
80 { // copy function
81
82   AliEventplane& target = (AliEventplane &) ep;
83   if (fQContributionX)
84       target.fQContributionX = fQContributionX;
85   if (fQContributionY)
86       target.fQContributionY = fQContributionY;
87   if (fQContributionXsub1)
88       target.fQContributionXsub1 = fQContributionXsub1;
89   if (fQContributionYsub1)
90       target.fQContributionYsub1 = fQContributionYsub1;
91   if (fQContributionXsub2)
92       target.fQContributionXsub2 = fQContributionXsub2;
93   if (fQContributionYsub2)
94       target.fQContributionYsub2 = fQContributionYsub2;
95   if (fEventplaneQ)
96       target.fEventplaneQ = fEventplaneQ;
97   if (fQVector)
98       target.fQVector = dynamic_cast<TVector2*> (fQVector->Clone());
99   if (fQsub1)
100       target.fQsub1 = dynamic_cast<TVector2*> (fQsub1->Clone());
101   if (fQsub2)
102       target.fQsub2 = dynamic_cast<TVector2*> (fQsub2->Clone());
103   if (fQsubRes)
104       target.fQsubRes = fQsubRes;
105 }
106
107 AliEventplane::~AliEventplane()
108 {
109   /// destructor
110   if (fQContributionX){
111       delete fQContributionX;
112       fQContributionX = 0;
113   }
114   if (fQContributionY){
115       delete fQContributionY;
116       fQContributionY = 0;
117   }
118   if (fQContributionXsub1){
119       delete fQContributionXsub1;
120       fQContributionXsub1 = 0;
121   }
122   if (fQContributionYsub1){
123       delete fQContributionYsub1;
124       fQContributionYsub1 = 0;
125   }
126   if (fQContributionXsub2){
127       delete fQContributionXsub2;
128       fQContributionXsub2 = 0;
129   }
130   if (fQContributionYsub2){
131       delete fQContributionYsub2;
132       fQContributionYsub2 = 0;
133   }
134   if (fQVector){
135       delete fQVector;
136       fQVector = 0;
137   }
138   if (fQsub1){
139       delete fQsub1;
140       fQsub1 = 0;
141   }
142     if (fQsub2){
143       delete fQsub2;
144       fQsub2 = 0;
145   }
146 }
147
148 TVector2* AliEventplane::GetQVector()
149 {
150   return fQVector;
151 }
152
153 Double_t AliEventplane::GetEventplane(const char *x)
154 {
155   TString method = x;
156   if(method.CompareTo("Q")==0)      return fEventplaneQ;
157   return -1;
158 }
159
160 TVector2* AliEventplane::GetQsub1()
161 {
162   return fQsub1;
163 }
164
165 TVector2* AliEventplane::GetQsub2()
166 {
167   return fQsub2;
168 }
169
170 Double_t AliEventplane::GetQsubRes()
171 {
172   return fQsubRes;
173 }
174
175 Bool_t AliEventplane::IsEventInEventplaneClass(Double_t a, Double_t b, const char *x)
176 {
177   TString method = x;
178   if ((method.CompareTo("Q")==0) && (fEventplaneQ >=a && fEventplaneQ < b)) return kTRUE;
179   else return kFALSE;
180 }
181
182 Double_t AliEventplane::GetQContributionX(AliVTrack* track)
183
184   return fQContributionX->GetAt(track->GetID());
185 }
186
187 Double_t AliEventplane::GetQContributionY(AliVTrack* track)
188
189   return fQContributionY->GetAt(track->GetID());
190 }
191
192 Double_t AliEventplane::GetQContributionXsub1(AliVTrack* track)
193
194   return fQContributionXsub1->GetAt(track->GetID());
195 }
196
197 Double_t AliEventplane::GetQContributionYsub1(AliVTrack* track)
198
199   return fQContributionYsub1->GetAt(track->GetID());
200 }
201
202 Double_t AliEventplane::GetQContributionXsub2(AliVTrack* track)
203
204   return fQContributionXsub2->GetAt(track->GetID());
205 }
206
207 Double_t AliEventplane::GetQContributionYsub2(AliVTrack* track)
208
209   return fQContributionYsub2->GetAt(track->GetID());
210 }
211
212 void AliEventplane::Reset()
213
214   delete fQVector; fQVector=0;
215   fQContributionX->Reset();
216   fQContributionY->Reset();
217   fQContributionXsub1->Reset();
218   fQContributionYsub1->Reset();
219   fQContributionXsub2->Reset();
220   fQContributionYsub2->Reset();
221   fEventplaneQ = -1;
222   delete fQsub1; fQsub1=0;
223   delete fQsub2; fQsub2=0;
224   fQsubRes = 0;
225 }