Casting TH1 to TH2
[u/mrichter/AliRoot.git] / STEER / AliESDZDC.cxx
CommitLineData
d5ebf00e 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
17//-------------------------------------------------------------------------
18// Implementation of Class AliESDZDC
19// This is a class that summarizes the ZDC data
20// for the ESD
21// Origin: Christian Klein-Boesing, CERN, Christian.Klein-Boesing@cern.ch
22//-------------------------------------------------------------------------
23
cb6a0388 24#include <TMath.h>
d5ebf00e 25
26#include "AliESDZDC.h"
27
28ClassImp(AliESDZDC)
29
30//______________________________________________________________________________
31AliESDZDC::AliESDZDC() :
32 TObject(),
33 fZDCN1Energy(0),
34 fZDCP1Energy(0),
35 fZDCN2Energy(0),
36 fZDCP2Energy(0),
f6536de8 37 fZDCEMEnergy(0),
38 fZDCEMEnergy1(0),
2b6cdc43 39 fZDCParticipants(0),
5f0ec064 40 fZDCPartSideA(0),
41 fZDCPartSideC(0),
42 fImpactParameter(0),
43 fImpactParamSideA(0),
44 fImpactParamSideC(0),
45 fESDQuality(0)
d5ebf00e 46{
89291556 47 for(Int_t i=0; i<5; i++){
a85132e7 48 fZN1TowerEnergy[i] = fZN2TowerEnergy[i] = 0.;
49 fZP1TowerEnergy[i] = fZP2TowerEnergy[i] = 0.;
50 fZN1TowerEnergyLR[i] = fZN2TowerEnergyLR[i] = 0.;
51 fZP1TowerEnergyLR[i] = fZP2TowerEnergyLR[i] = 0.;
52 }
89291556 53 for(Int_t i=0; i<2; i++){
54 fZNACentrCoord[i] = fZNCCentrCoord[i] = 0.;
55 }
82dffa48 56 for(Int_t i=0; i<32; i++){
57 fVMEScaler[i]=0;
9e05925b 58 for(Int_t y=0; y<4; y++){
59 fZDCTDCData[i][y]=0.;
60 fZNCTime[y]=0.;
61 fZNATime[y]=0.;
62 }
82dffa48 63 }
d5ebf00e 64}
65
2b6cdc43 66//______________________________________________________________________________
d5ebf00e 67AliESDZDC::AliESDZDC(const AliESDZDC& zdc) :
68 TObject(zdc),
69 fZDCN1Energy(zdc.fZDCN1Energy),
70 fZDCP1Energy(zdc.fZDCP1Energy),
71 fZDCN2Energy(zdc.fZDCN2Energy),
72 fZDCP2Energy(zdc.fZDCP2Energy),
f6536de8 73 fZDCEMEnergy(zdc.fZDCEMEnergy),
74 fZDCEMEnergy1(zdc.fZDCEMEnergy1),
2b6cdc43 75 fZDCParticipants(zdc.fZDCParticipants),
5f0ec064 76 fZDCPartSideA(zdc.fZDCPartSideA),
77 fZDCPartSideC(zdc.fZDCPartSideC),
78 fImpactParameter(zdc.fImpactParameter),
8c755c03 79 fImpactParamSideA(zdc.fImpactParamSideA),
80 fImpactParamSideC(zdc.fImpactParamSideC),
5f0ec064 81 fESDQuality(zdc.fESDQuality)
d5ebf00e 82{
83 // copy constructor
89291556 84 for(Int_t i=0; i<5; i++){
a85132e7 85 fZN1TowerEnergy[i] = zdc.fZN1TowerEnergy[i];
86 fZN2TowerEnergy[i] = zdc.fZN2TowerEnergy[i];
87 fZP1TowerEnergy[i] = zdc.fZP1TowerEnergy[i];
88 fZP2TowerEnergy[i] = zdc.fZP2TowerEnergy[i];
89 fZN1TowerEnergyLR[i] = zdc.fZN1TowerEnergyLR[i];
90 fZN2TowerEnergyLR[i] = zdc.fZN2TowerEnergyLR[i];
91 fZP1TowerEnergyLR[i] = zdc.fZP1TowerEnergyLR[i];
92 fZP2TowerEnergyLR[i] = zdc.fZP2TowerEnergyLR[i];
93 }
89291556 94 for(Int_t i=0; i<2; i++){
95 fZNACentrCoord[i] = zdc.fZNACentrCoord[i];
96 fZNCCentrCoord[i] = zdc.fZNCCentrCoord[i];
97 }
82dffa48 98 for(Int_t i=0; i<32; i++){
99 fVMEScaler[i] = zdc.fVMEScaler[i];
9e05925b 100 for(Int_t y=0; y<4; y++){
101 fZDCTDCData[i][y] = zdc.fZDCTDCData[i][y];
102 fZNCTime[y] = zdc.fZNCTime[y];
103 fZNATime[y] = zdc.fZNATime[y];
104 }
82dffa48 105 }
d5ebf00e 106}
107
2b6cdc43 108//______________________________________________________________________________
d5ebf00e 109AliESDZDC& AliESDZDC::operator=(const AliESDZDC&zdc)
110{
111 // assigment operator
112 if(this!=&zdc) {
113 TObject::operator=(zdc);
114 fZDCN1Energy = zdc.fZDCN1Energy;
115 fZDCP1Energy = zdc.fZDCP1Energy;
116 fZDCN2Energy = zdc.fZDCN2Energy;
117 fZDCP2Energy = zdc.fZDCP2Energy;
f6536de8 118 fZDCEMEnergy = zdc.fZDCEMEnergy;
119 fZDCEMEnergy1 = zdc.fZDCEMEnergy1;
a85132e7 120 for(Int_t i=0; i<5; i++){
7b4458a2 121 fZN1TowerEnergy[i] = zdc.fZN1TowerEnergy[i];
122 fZN2TowerEnergy[i] = zdc.fZN2TowerEnergy[i];
a85132e7 123 fZP1TowerEnergy[i] = zdc.fZP1TowerEnergy[i];
124 fZP2TowerEnergy[i] = zdc.fZP2TowerEnergy[i];
125 fZN1TowerEnergyLR[i] = zdc.fZN1TowerEnergyLR[i];
126 fZN2TowerEnergyLR[i] = zdc.fZN2TowerEnergyLR[i];
127 fZP1TowerEnergyLR[i] = zdc.fZP1TowerEnergyLR[i];
128 fZP2TowerEnergyLR[i] = zdc.fZP2TowerEnergyLR[i];
7b4458a2 129 }
5f0ec064 130 //
131 fZDCParticipants = zdc.fZDCParticipants;
132 fZDCPartSideA = zdc.fZDCPartSideA;
133 fZDCPartSideC = zdc.fZDCPartSideC;
134 fImpactParameter = zdc.fImpactParameter;
135 fImpactParamSideA = zdc.fImpactParamSideA;
136 fImpactParamSideC = zdc.fImpactParamSideC;
137 //
89291556 138 for(Int_t i=0; i<2; i++){
139 fZNACentrCoord[i] = zdc.fZNACentrCoord[i];
140 fZNCCentrCoord[i] = zdc.fZNCCentrCoord[i];
141 }
5f0ec064 142 //
143 fESDQuality = zdc.fESDQuality;
82dffa48 144 for(Int_t i=0; i<32; i++){
145 fVMEScaler[i] = zdc.fVMEScaler[i];
9e05925b 146 for(Int_t y=0; y<4; y++){
147 fZDCTDCData[i][y] = zdc.fZDCTDCData[i][y];
148 fZNCTime[y] = zdc.fZNCTime[y];
149 fZNATime[y] = zdc.fZNATime[y];
150 }
82dffa48 151 }
d5ebf00e 152 }
153 return *this;
154}
155
2b6cdc43 156//______________________________________________________________________________
732a24fe 157void AliESDZDC::Copy(TObject &obj) const {
158
159 // this overwrites the virtual TOBject::Copy()
160 // to allow run time copying without casting
161 // in AliESDEvent
162
163 if(this==&obj)return;
164 AliESDZDC *robj = dynamic_cast<AliESDZDC*>(&obj);
165 if(!robj)return; // not an AliESDZDC
166 *robj = *this;
167
168}
169
d5ebf00e 170
171//______________________________________________________________________________
172void AliESDZDC::Reset()
173{
174 // reset all data members
175 fZDCN1Energy=0;
176 fZDCP1Energy=0;
177 fZDCN2Energy=0;
178 fZDCP2Energy=0;
f6536de8 179 fZDCEMEnergy=0;
180 fZDCEMEnergy1=0;
89291556 181 for(Int_t i=0; i<5; i++){
a85132e7 182 fZN1TowerEnergy[i] = fZN2TowerEnergy[i] = 0.;
183 fZP1TowerEnergy[i] = fZP2TowerEnergy[i] = 0.;
184 fZN1TowerEnergyLR[i] = fZN2TowerEnergyLR[i] = 0.;
185 fZP1TowerEnergyLR[i] = fZP2TowerEnergyLR[i] = 0.;
186 }
5f0ec064 187 fZDCParticipants=0;
188 fZDCPartSideA=0;
189 fZDCPartSideC=0;
190 fImpactParameter=0;
191 fImpactParamSideA=0;
192 fImpactParamSideC=0;
89291556 193 for(Int_t i=0; i<2; i++){
194 fZNACentrCoord[i] = fZNCCentrCoord[i] = 0.;
195 }
5f0ec064 196 fESDQuality=0;
82dffa48 197 for(Int_t i=0; i<32; i++){
198 fVMEScaler[i] = 0;
9e05925b 199 for(Int_t y=0; y<4; y++){
200 fZDCTDCData[i][y] = 0.;
201 fZNCTime[y] = 0.;
202 fZNATime[y] = 0.;
203 }
82dffa48 204 }
d5ebf00e 205}
206
207//______________________________________________________________________________
208void AliESDZDC::Print(const Option_t *) const
209{
a85132e7 210 // Print ESD for the ZDC
5f0ec064 211 printf("\n \t E_{ZNC} = %f TeV, E_{ZPC} = %f TeV, E_{ZNA} = %f TeV, E_{ZPA} = %f TeV,"
212 " E_{ZEM} = %f GeV, Npart = %d, b = %1.2f fm\n",
213 fZDCN1Energy/1000.,fZDCP1Energy/1000.,fZDCN2Energy/1000.,fZDCP2Energy/1000.,
214 fZDCEMEnergy+fZDCEMEnergy1, fZDCParticipants,fImpactParameter);
54c6a92c 215 //
82dffa48 216 printf(" ### VMEScaler (!=0): \n");
217 for(Int_t i=0; i<32; i++) if(fVMEScaler[i]!=0) printf("\t %d \n",fVMEScaler[i]);
218 printf("\n");
219 //
220 printf(" ### TDCData (!=0): \n");
32e2fda5 221 for(Int_t i=0; i<32; i++){
222 for(Int_t j=0; j<4; j++)
223 if(fZDCTDCData[i][j]!=0) printf("\t %d \n",fZDCTDCData[i][j]);
224 }
54c6a92c 225 printf("\n");
d5ebf00e 226}
227
d1d3e36b 228//______________________________________________________________________________
789b8a8d 229Bool_t AliESDZDC::GetZNCentroidInPbPb(Float_t beamEne, Double_t centrZNC[2], Double_t centrZNA[2])
d1d3e36b 230{
231 // Provide coordinates of centroid over ZN (side C) front face
789b8a8d 232 if(beamEne==0){
233 printf(" ZDC centroid in PbPb can't be calculated with E_beam = 0 !!!\n");
234 for(Int_t jj=0; jj<2; jj++) fZNCCentrCoord[jj] = 999.;
235 return kFALSE;
236 }
237
b19cc8d0 238 const Float_t x[4] = {-1.75, 1.75, -1.75, 1.75};
239 const Float_t y[4] = {-1.75, -1.75, 1.75, 1.75};
b19cc8d0 240 const Float_t alpha=0.395;
789b8a8d 241 Float_t numXZNC=0., numYZNC=0., denZNC=0., cZNC, wZNC;
242 Float_t numXZNA=0., numYZNA=0., denZNA=0., cZNA, wZNA;
5f0ec064 243 //
789b8a8d 244 for(Int_t i=0; i<4; i++){
b19cc8d0 245 if(fZN1TowerEnergy[i+1]>0.) {
789b8a8d 246 wZNC = TMath::Power(fZN1TowerEnergy[i+1], alpha);
247 numXZNC += x[i]*wZNC;
248 numYZNC += y[i]*wZNC;
249 denZNC += wZNC;
b19cc8d0 250 }
b19cc8d0 251 if(fZN2TowerEnergy[i+1]>0.) {
6dec52cf 252 wZNA = TMath::Power(fZN2TowerEnergy[i+1], alpha);
789b8a8d 253 numXZNA += x[i]*wZNA;
254 numYZNA += y[i]*wZNA;
255 denZNA += wZNA;
b19cc8d0 256 }
789b8a8d 257 }
ce099621 258 //
789b8a8d 259 if(denZNC!=0){
260 Float_t nSpecnC = fZDCN1Energy/beamEne;
261 cZNC = 1.89358-0.71262/(nSpecnC+0.71789);
262 fZNCCentrCoord[0] = cZNC*numXZNC/denZNC;
263 fZNCCentrCoord[1] = cZNC*numYZNC/denZNC;
264 }
265 else{
266 fZNCCentrCoord[0] = fZNCCentrCoord[1] = 999.;
b19cc8d0 267 }
789b8a8d 268 if(denZNA!=0){
9e05925b 269 Float_t nSpecnA = fZDCN2Energy/beamEne;
789b8a8d 270 cZNA = 1.89358-0.71262/(nSpecnA+0.71789);
db3c6990 271 fZNACentrCoord[0] = cZNA*numXZNA/denZNA;
272 fZNACentrCoord[1] = cZNA*numYZNA/denZNA;
789b8a8d 273 }
274 else{
275 fZNACentrCoord[0] = fZNACentrCoord[1] = 999.;
276 }
277 //
278 for(Int_t il=0; il<2; il++){
279 centrZNC[il] = fZNCCentrCoord[il];
280 centrZNA[il] = fZNACentrCoord[il];
281 }
282
283 return kTRUE;
b19cc8d0 284}
285
286//______________________________________________________________________________
789b8a8d 287Bool_t AliESDZDC::GetZNCentroidInpp(Double_t centrZNC[2], Double_t centrZNA[2])
b19cc8d0 288{
289 // Provide coordinates of centroid over ZN (side C) front face
290 const Float_t x[4] = {-1.75, 1.75, -1.75, 1.75};
291 const Float_t y[4] = {-1.75, -1.75, 1.75, 1.75};
b19cc8d0 292 const Float_t alpha=0.5;
789b8a8d 293 Float_t numXZNC=0., numYZNC=0., denZNC=0., wZNC;
294 Float_t numXZNA=0., numYZNA=0., denZNA=0., wZNA;
b19cc8d0 295 //
789b8a8d 296 for(Int_t i=0; i<4; i++){
b19cc8d0 297 if(fZN1TowerEnergy[i+1]>0.) {
789b8a8d 298 wZNC = TMath::Power(fZN1TowerEnergy[i+1], alpha);
299 numXZNC += x[i]*wZNC;
300 numYZNC += y[i]*wZNC;
301 denZNC += wZNC;
b19cc8d0 302 }
b19cc8d0 303 if(fZN2TowerEnergy[i+1]>0.) {
789b8a8d 304 wZNA = TMath::Power(fZN2TowerEnergy[i+1], alpha);
305 numXZNA += x[i]*wZNA;
306 numYZNA += y[i]*wZNA;
307 denZNA += wZNA;
b19cc8d0 308 }
789b8a8d 309 }
310 //
311 if(denZNC!=0){
312 fZNCCentrCoord[0] = numXZNC/denZNC;
313 fZNCCentrCoord[1] = numYZNC/denZNC;
314 }
315 else{
316 fZNCCentrCoord[0] = fZNCCentrCoord[1] = 999.;
317 }
318 if(denZNA!=0){
319 fZNACentrCoord[0] = numXZNA/denZNA;
320 fZNACentrCoord[1] = numYZNA/denZNA;
321 }
322 else{
323 fZNACentrCoord[0] = fZNACentrCoord[1] = 999.;
324 }
b19cc8d0 325 //
789b8a8d 326 for(Int_t il=0; il<2; il++){
327 centrZNC[il] = fZNCCentrCoord[il];
328 centrZNA[il] = fZNACentrCoord[il];
ce099621 329 }
789b8a8d 330
331 return kTRUE;
d1d3e36b 332}