Coding rule violations corrected.
[u/mrichter/AliRoot.git] / STEER / AOD / AliAODZDC.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2007, 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 for AOD ZDC data
18 //     Author: Chiara Oppedisano
19 //     Chiara.Oppedisano@cern.ch March 2011
20 //-------------------------------------------------------------------------
21
22 #include <TMath.h>
23 #include "AliAODZDC.h"
24
25 ClassImp(AliAODZDC)
26
27 AliAODZDC::AliAODZDC() :
28   AliVZDC(),
29   fZNCEnergy(-999.),
30   fZNAEnergy(-999.),
31   fZPCEnergy(-999.),
32   fZPAEnergy(-999.),
33   fZEM1Energy(0.),
34   fZEM2Energy(0.),
35   fZDCParticipants(0),
36   fZDCPartSideA(0),
37   fZDCPartSideC(0),
38   fImpactParameter(0),
39   fImpactParamSideA(0),
40   fImpactParamSideC(0),
41   fZDCTDCSum(0),         
42   fZDCTDCDifference(0)
43 {
44 // Default constructor
45   for(Int_t i=0; i<5; i++){
46     fZNCTowerEnergy[i] = fZNATowerEnergy[i] = 0.;
47     fZPCTowerEnergy[i] = fZPATowerEnergy[i] = 0.;
48     fZNCTowerEnergyLR[i] = fZNATowerEnergyLR[i] = 0.;
49   }
50 }
51
52 //__________________________________________________________________________
53 AliAODZDC::AliAODZDC(const AliAODZDC &zdcAOD) :
54   AliVZDC(zdcAOD),
55   fZNCEnergy(zdcAOD.fZNCEnergy),
56   fZNAEnergy(zdcAOD.fZNAEnergy),
57   fZPCEnergy(zdcAOD.fZPCEnergy),
58   fZPAEnergy(zdcAOD.fZPAEnergy),
59   fZEM1Energy(zdcAOD.fZEM1Energy),
60   fZEM2Energy(zdcAOD.fZEM2Energy),
61   fZDCParticipants(zdcAOD.fZDCParticipants),
62   fZDCPartSideA(zdcAOD.fZDCPartSideA),
63   fZDCPartSideC(zdcAOD.fZDCPartSideC),
64   fImpactParameter(zdcAOD.fImpactParameter),
65   fImpactParamSideA(zdcAOD.fImpactParamSideA),
66   fImpactParamSideC(zdcAOD.fImpactParamSideC),
67   fZDCTDCSum(zdcAOD.fZDCTDCSum),         
68   fZDCTDCDifference(zdcAOD.fZDCTDCDifference)
69 {
70 // Constructor
71   for(Int_t i=0; i<5; i++){
72     fZNCTowerEnergy[i] = zdcAOD.fZNCTowerEnergy[i];
73     fZNATowerEnergy[i] = zdcAOD.fZNATowerEnergy[i];
74     fZPCTowerEnergy[i] = zdcAOD.fZPCTowerEnergy[i];
75     fZPATowerEnergy[i] = zdcAOD.fZPATowerEnergy[i];
76     fZNCTowerEnergyLR[i] = zdcAOD.fZNCTowerEnergyLR[i];
77     fZNATowerEnergyLR[i] = zdcAOD.fZNATowerEnergyLR[i];
78   }
79 }
80
81 //__________________________________________________________________________
82 AliAODZDC& AliAODZDC::operator=(const AliAODZDC& zdcAOD)
83 {
84   // Assignment operator
85   //
86   if(this!=&zdcAOD) {
87     TObject::operator=(zdcAOD);
88     fZNCEnergy  = zdcAOD.fZNCEnergy;
89     fZNAEnergy  = zdcAOD.fZNAEnergy;
90     fZPCEnergy  = zdcAOD.fZPCEnergy;
91     fZPAEnergy  = zdcAOD.fZPAEnergy;
92     fZEM1Energy = zdcAOD.fZEM1Energy;
93     fZEM2Energy = zdcAOD.fZEM2Energy;
94     for(Int_t i=0; i<5; i++){
95        fZNCTowerEnergy[i] = zdcAOD.fZNCTowerEnergy[i];
96        fZNATowerEnergy[i] = zdcAOD.fZNATowerEnergy[i];
97        fZPCTowerEnergy[i] = zdcAOD.fZPCTowerEnergy[i];
98        fZPATowerEnergy[i] = zdcAOD.fZPATowerEnergy[i];
99        fZNCTowerEnergyLR[i] = zdcAOD.fZNCTowerEnergyLR[i];
100        fZNATowerEnergyLR[i] = zdcAOD.fZNATowerEnergyLR[i];
101     }
102     //
103     fZDCParticipants = zdcAOD.fZDCParticipants;
104     fZDCPartSideA = zdcAOD.fZDCPartSideA;
105     fZDCPartSideC = zdcAOD.fZDCPartSideC;
106     fImpactParameter = zdcAOD.fImpactParameter;
107     fImpactParamSideA = zdcAOD.fImpactParamSideA;
108     fImpactParamSideC = zdcAOD.fImpactParamSideC;
109     //
110     //for(Int_t i=0; i<2; i++){
111     //     fZNACentrCoord[i] = zdcAOD.fZNACentrCoord[i];
112     //     fZNCCentrCoord[i] = zdcAOD.fZNCCentrCoord[i];
113     //}
114     //
115     fZDCTDCSum = zdcAOD.fZDCTDCSum;    
116     fZDCTDCDifference = zdcAOD.fZDCTDCDifference;
117   } 
118   return *this;
119 }
120
121 //______________________________________________________________________________
122 Double_t  AliAODZDC::GetZNCEnergy() const
123 {
124 // Return ZNC energy
125     if (fZNCEnergy < 0.) {
126         fZNCEnergy = 0.;
127         for(Int_t i=0; i<5; i++) fZNCEnergy += fZNCTowerEnergy[i];
128     }
129     return fZNCEnergy;
130 }
131
132 //______________________________________________________________________________
133 Double_t  AliAODZDC::GetZNAEnergy() const
134 {
135 // Return ZNA Energy
136     if (fZNAEnergy < 0.) {
137         fZNAEnergy = 0.;
138         for(Int_t i=0; i<5; i++) fZNAEnergy += fZNATowerEnergy[i];
139     }
140     return fZNAEnergy;
141 }
142
143 //______________________________________________________________________________
144 Double_t  AliAODZDC::GetZPCEnergy() const
145 {
146 // Return ZPC Energy
147     if (fZPCEnergy < 0.) {
148         fZPCEnergy = 0.;
149         for(Int_t i=0; i<5; i++) fZPCEnergy += fZPCTowerEnergy[i];
150     }
151     return fZPCEnergy;
152 }
153
154 //______________________________________________________________________________
155 Double_t  AliAODZDC::GetZPAEnergy() const
156 {
157 // Return ZPA Energy
158     if (fZPAEnergy < 0.) {
159         fZPAEnergy = 0.;
160         for(Int_t i=0; i<5; i++) fZPAEnergy += fZPATowerEnergy[i];
161     }
162     return fZPAEnergy;
163 }
164
165 //______________________________________________________________________________
166 void  AliAODZDC::SetZNCTowers(const Double_t value[5], const Double_t valueLR[5])
167 {
168   // Sets ZNC towers
169   for(Int_t i=0; i<5; i++){
170     fZNCTowerEnergy[i] = value[i];
171     fZNCTowerEnergyLR[i] = valueLR[i];
172   }
173 }
174
175 //______________________________________________________________________________
176 void  AliAODZDC::SetZNATowers(const Double_t value[5], const Double_t valueLR[5])
177 {
178   // Sets ZNA towers
179   for(Int_t i=0; i<5; i++){
180     fZNATowerEnergy[i] = value[i];
181     fZNATowerEnergyLR[i] = valueLR[i];
182   }
183 }
184
185 //______________________________________________________________________________
186 Bool_t AliAODZDC::GetZNCentroidInPbPb(Float_t beamEne, Double_t centrZNC[2], Double_t centrZNA[2]) 
187 {
188   // Provides coordinates of centroid over ZN (side C) front face in PbPb
189    if(beamEne==0){
190     printf(" ZDC centroid in PbPb can't be calculated with E_beam = 0 !!!\n");
191     //for(Int_t jj=0; jj<2; jj++) fZNCCentrCoord[jj] = 999.;
192     return kFALSE;
193   }
194
195   const Float_t x[4] = {-1.75, 1.75, -1.75, 1.75};
196   const Float_t y[4] = {-1.75, -1.75, 1.75, 1.75};
197   const Float_t alpha=0.395;
198   Float_t numXZNC=0., numYZNC=0., denZNC=0., cZNC, wZNC; 
199   Float_t numXZNA=0., numYZNA=0., denZNA=0., cZNA, wZNA; 
200   Float_t zncEnergy=0., znaEnergy=0.;
201   //
202   for(Int_t i=0; i<5; i++){
203     zncEnergy += fZNCTowerEnergy[i];
204     znaEnergy += fZNCTowerEnergy[i];
205   }
206   for(Int_t i=0; i<4; i++){
207     if(fZNCTowerEnergy[i+1]>0.) {
208       wZNC = TMath::Power(fZNCTowerEnergy[i+1], alpha);
209       numXZNC += x[i]*wZNC;
210       numYZNC += y[i]*wZNC;
211       denZNC += wZNC;
212     }
213     if(fZNATowerEnergy[i+1]>0.) {
214       wZNA = TMath::Power(fZNATowerEnergy[i+1], alpha);
215       numXZNA += x[i]*wZNA;
216       numYZNA += y[i]*wZNA;
217       denZNA += wZNA;
218     }
219   }
220   //
221   if(denZNC!=0){
222     Float_t nSpecnC = zncEnergy/beamEne;
223     cZNC = 1.89358-0.71262/(nSpecnC+0.71789);
224     centrZNC[0] = cZNC*numXZNC/denZNC;
225     centrZNC[1] = cZNC*numYZNC/denZNC;
226   } 
227   else{
228     centrZNC[0] = centrZNC[1] = 999.;
229   }
230   if(denZNA!=0){
231     Float_t nSpecnA = znaEnergy/beamEne;
232     cZNA = 1.89358-0.71262/(nSpecnA+0.71789);
233     centrZNA[0] = cZNA*numXZNA/denZNA;
234     centrZNA[1] = cZNA*numYZNA/denZNA;
235   } 
236   else{
237     centrZNA[0] = centrZNA[1] = 999.;
238   }
239  
240   
241   return kTRUE;
242 }
243
244 //______________________________________________________________________________
245 Bool_t AliAODZDC::GetZNCentroidInpp(Double_t centrZNC[2], Double_t centrZNA[2]) 
246 {
247   // Provides coordinates of centroid over ZN (side C) front face in pp
248   const Float_t x[4] = {-1.75, 1.75, -1.75, 1.75};
249   const Float_t y[4] = {-1.75, -1.75, 1.75, 1.75};
250   const Float_t alpha=0.5;
251   Float_t numXZNC=0., numYZNC=0., denZNC=0., wZNC; 
252   Float_t numXZNA=0., numYZNA=0., denZNA=0., wZNA; 
253   //
254   for(Int_t i=0; i<4; i++){
255     if(fZNCTowerEnergy[i+1]>0.) {
256       wZNC = TMath::Power(fZNCTowerEnergy[i+1], alpha);
257       numXZNC += x[i]*wZNC;
258       numYZNC += y[i]*wZNC;
259       denZNC += wZNC;
260     }
261     if(fZNATowerEnergy[i+1]>0.) {
262       wZNA = TMath::Power(fZNATowerEnergy[i+1], alpha);
263       numXZNA += x[i]*wZNA;
264       numYZNA += y[i]*wZNA;
265       denZNA += wZNA;
266     }
267   }
268   //
269   if(denZNC!=0){
270     centrZNC[0] = numXZNC/denZNC;
271     centrZNC[1] = numYZNC/denZNC;
272   } 
273   else{
274     centrZNC[0] = centrZNC[1] = 999.;
275   }
276   if(denZNA!=0){
277     centrZNA[0] = numXZNA/denZNA;
278     centrZNA[1] = numYZNA/denZNA;
279   } 
280   else{
281     centrZNA[0] = centrZNA[1] = 999.;
282   }
283   
284   return kTRUE;
285 }