]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliEventplane.cxx
Coverity 15850
[u/mrichter/AliRoot.git] / STEER / 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   fEventplaneQ(-1),
35   fQsub1(0),
36   fQsub2(0),
37   fQsubRes(0)
38 {
39   /// constructor
40   fQContributionX = new TArrayF(0);
41   fQContributionY = new TArrayF(0);
42 }
43
44 AliEventplane::AliEventplane(const AliEventplane& ep) : 
45   TNamed(),
46   fQVector(0),
47   fQContributionX(0),
48   fQContributionY(0),
49   fEventplaneQ(0),
50   fQsub1(0),
51   fQsub2(0),
52   fQsubRes(0)
53 {
54   /// Copy constructor
55   ((AliEventplane &) ep).CopyEP(*this);
56 }
57
58 AliEventplane& AliEventplane::operator=(const AliEventplane& ep)
59 {
60   /// Assignment operator
61   if (this!=&ep)
62     ((AliEventplane &) ep).CopyEP(*this);
63
64   return *this;
65 }
66
67 void AliEventplane::CopyEP(AliEventplane& ep) const
68 { // copy function
69
70   AliEventplane& target = (AliEventplane &) ep;
71   if (fQContributionX)
72       target.fQContributionX = fQContributionX;
73   if (fQContributionY)
74       target.fQContributionY = fQContributionY;
75   if (fEventplaneQ)
76       target.fEventplaneQ = fEventplaneQ;
77   if (fQVector)
78       target.fQVector = dynamic_cast<TVector2*> (fQVector->Clone());
79   if (fQsub1)
80       target.fQsub1 = dynamic_cast<TVector2*> (fQsub1->Clone());
81   if (fQsub2)
82       target.fQsub2 = dynamic_cast<TVector2*> (fQsub2->Clone());
83   if (fQsubRes)
84       target.fQsubRes = fQsubRes;
85 }
86
87 AliEventplane::~AliEventplane()
88 {
89   /// destructor
90   if (fQContributionX){
91       delete fQContributionX;
92       fQContributionX = 0;
93   }
94   if (fQContributionY){
95       delete fQContributionY;
96       fQContributionY = 0;
97   }
98   if (fQVector){
99       delete fQVector;
100       fQVector = 0;
101   }
102   if (fQsub1){
103       delete fQsub1;
104       fQsub1 = 0;
105   }
106     if (fQsub2){
107       delete fQsub2;
108       fQsub2 = 0;
109   }
110 }
111
112 TVector2* AliEventplane::GetQVector()
113 {
114   return fQVector;
115 }
116
117 Double_t AliEventplane::GetEventplane(const char *x)
118 {
119   TString method = x;
120   if(method.CompareTo("Q")==0)      return fEventplaneQ;
121   return -1;
122 }
123
124 TVector2* AliEventplane::GetQsub1()
125 {
126   return fQsub1;
127 }
128
129 TVector2* AliEventplane::GetQsub2()
130 {
131   return fQsub2;
132 }
133
134 Double_t AliEventplane::GetQsubRes()
135 {
136   return fQsubRes;
137 }
138
139 Bool_t AliEventplane::IsEventInEventplaneClass(Double_t a, Double_t b, const char *x)
140 {
141   TString method = x;
142   if ((method.CompareTo("Q")==0) && (fEventplaneQ >=a && fEventplaneQ < b)) return kTRUE;
143   else return kFALSE;
144 }
145
146 Double_t AliEventplane::GetQContributionX(AliVTrack* track)
147
148   return fQContributionX->GetAt(track->GetID());
149 }
150
151 Double_t AliEventplane::GetQContributionY(AliVTrack* track)
152
153   return fQContributionY->GetAt(track->GetID());
154 }
155
156 void AliEventplane::Reset()
157
158   delete fQVector; fQVector=0;
159   fQContributionX->Reset();
160   fQContributionY->Reset();
161   fEventplaneQ = -1;
162   delete fQsub1; fQsub1=0;
163   delete fQsub2; fQsub2=0;
164   fQsubRes = 0;
165 }