Implemented Copy() function for all esd objects to allow for assignment of AliESDEven...
[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
24
25
26#include "AliESDZDC.h"
27
28ClassImp(AliESDZDC)
29
d1d3e36b 30float fCParCentr(const int n) {return 1.8936-0.7126/(n + 0.7179);}
31
d5ebf00e 32//______________________________________________________________________________
33AliESDZDC::AliESDZDC() :
34 TObject(),
35 fZDCN1Energy(0),
36 fZDCP1Energy(0),
37 fZDCN2Energy(0),
38 fZDCP2Energy(0),
f6536de8 39 fZDCEMEnergy(0),
40 fZDCEMEnergy1(0),
d5ebf00e 41 fZDCParticipants(0)
42{
a85132e7 43 for(int i=0; i<5; i++){
44 fZN1TowerEnergy[i] = fZN2TowerEnergy[i] = 0.;
45 fZP1TowerEnergy[i] = fZP2TowerEnergy[i] = 0.;
46 fZN1TowerEnergyLR[i] = fZN2TowerEnergyLR[i] = 0.;
47 fZP1TowerEnergyLR[i] = fZP2TowerEnergyLR[i] = 0.;
48 }
d5ebf00e 49}
50
51AliESDZDC::AliESDZDC(const AliESDZDC& zdc) :
52 TObject(zdc),
53 fZDCN1Energy(zdc.fZDCN1Energy),
54 fZDCP1Energy(zdc.fZDCP1Energy),
55 fZDCN2Energy(zdc.fZDCN2Energy),
56 fZDCP2Energy(zdc.fZDCP2Energy),
f6536de8 57 fZDCEMEnergy(zdc.fZDCEMEnergy),
58 fZDCEMEnergy1(zdc.fZDCEMEnergy1),
d5ebf00e 59 fZDCParticipants(zdc.fZDCParticipants)
60{
61 // copy constructor
a85132e7 62 for(int i=0; i<5; i++){
63 fZN1TowerEnergy[i] = zdc.fZN1TowerEnergy[i];
64 fZN2TowerEnergy[i] = zdc.fZN2TowerEnergy[i];
65 fZP1TowerEnergy[i] = zdc.fZP1TowerEnergy[i];
66 fZP2TowerEnergy[i] = zdc.fZP2TowerEnergy[i];
67 fZN1TowerEnergyLR[i] = zdc.fZN1TowerEnergyLR[i];
68 fZN2TowerEnergyLR[i] = zdc.fZN2TowerEnergyLR[i];
69 fZP1TowerEnergyLR[i] = zdc.fZP1TowerEnergyLR[i];
70 fZP2TowerEnergyLR[i] = zdc.fZP2TowerEnergyLR[i];
71 }
d5ebf00e 72}
73
74AliESDZDC& AliESDZDC::operator=(const AliESDZDC&zdc)
75{
76 // assigment operator
77 if(this!=&zdc) {
78 TObject::operator=(zdc);
79 fZDCN1Energy = zdc.fZDCN1Energy;
80 fZDCP1Energy = zdc.fZDCP1Energy;
81 fZDCN2Energy = zdc.fZDCN2Energy;
82 fZDCP2Energy = zdc.fZDCP2Energy;
d5ebf00e 83 fZDCParticipants = zdc.fZDCParticipants;
f6536de8 84 fZDCEMEnergy = zdc.fZDCEMEnergy;
85 fZDCEMEnergy1 = zdc.fZDCEMEnergy1;
a85132e7 86 for(Int_t i=0; i<5; i++){
7b4458a2 87 fZN1TowerEnergy[i] = zdc.fZN1TowerEnergy[i];
88 fZN2TowerEnergy[i] = zdc.fZN2TowerEnergy[i];
a85132e7 89 fZP1TowerEnergy[i] = zdc.fZP1TowerEnergy[i];
90 fZP2TowerEnergy[i] = zdc.fZP2TowerEnergy[i];
91 fZN1TowerEnergyLR[i] = zdc.fZN1TowerEnergyLR[i];
92 fZN2TowerEnergyLR[i] = zdc.fZN2TowerEnergyLR[i];
93 fZP1TowerEnergyLR[i] = zdc.fZP1TowerEnergyLR[i];
94 fZP2TowerEnergyLR[i] = zdc.fZP2TowerEnergyLR[i];
7b4458a2 95 }
d5ebf00e 96 }
97 return *this;
98}
99
732a24fe 100void AliESDZDC::Copy(TObject &obj) const {
101
102 // this overwrites the virtual TOBject::Copy()
103 // to allow run time copying without casting
104 // in AliESDEvent
105
106 if(this==&obj)return;
107 AliESDZDC *robj = dynamic_cast<AliESDZDC*>(&obj);
108 if(!robj)return; // not an AliESDZDC
109 *robj = *this;
110
111}
112
d5ebf00e 113
114//______________________________________________________________________________
115void AliESDZDC::Reset()
116{
117 // reset all data members
118 fZDCN1Energy=0;
119 fZDCP1Energy=0;
120 fZDCN2Energy=0;
121 fZDCP2Energy=0;
7b4458a2 122 fZDCParticipants=0;
f6536de8 123 fZDCEMEnergy=0;
124 fZDCEMEnergy1=0;
19652c51 125 for(int i=0; i<5; i++){
a85132e7 126 fZN1TowerEnergy[i] = fZN2TowerEnergy[i] = 0.;
127 fZP1TowerEnergy[i] = fZP2TowerEnergy[i] = 0.;
128 fZN1TowerEnergyLR[i] = fZN2TowerEnergyLR[i] = 0.;
129 fZP1TowerEnergyLR[i] = fZP2TowerEnergyLR[i] = 0.;
130 }
d5ebf00e 131}
132
133//______________________________________________________________________________
134void AliESDZDC::Print(const Option_t *) const
135{
a85132e7 136 // Print ESD for the ZDC
137 printf("\n \t ZN1Energy = %f TeV, ZP1Energy = %f TeV, ZN2Energy = %f TeV,"
138 " ZP2Energy = %f, Nparticipants = %d\n",
139 fZDCN1Energy,fZDCP1Energy,fZDCN2Energy,fZDCP2Energy,fZDCParticipants);
d5ebf00e 140}
141
d1d3e36b 142//______________________________________________________________________________
143const Float_t * AliESDZDC::GetZNCCentroid(int NspecnC) const
144{
145 // Provide coordinates of centroid over ZN (side C) front face
146 Float_t CentrCoord[2];
147 Float_t x[4] = {-1.75, 1.75, -1.75, 1.75};
148 Float_t y[4] = {-1.75, -1.72, 1.75, 1.75};
149 Float_t NumX=0., NumY=0., Den=0.;
150 Float_t alpha=0.395, w;
151 for(Int_t i=1; i<5; i++){
152 w = TMath::Power(fZN1TowerEnergy[i], alpha);
153 NumX += x[i]*w;
154 NumY += y[i]*w;
155 Den += w;
156 }
157 if(Den!=0){
158 CentrCoord[0] = fCParCentr(NspecnC)*NumX/Den;
159 CentrCoord[1] = fCParCentr(NspecnC)*NumY/Den;
160 }
161 return CentrCoord;
162}
7b4458a2 163
d1d3e36b 164//______________________________________________________________________________
165const Float_t * AliESDZDC::GetZNACentroid(int NspecnA) const
166{
167 // Provide coordinates of centroid over ZN (side A) front face
168 Float_t CentrCoord[2];
169 Float_t x[4] = {-1.75, 1.75, -1.75, 1.75};
170 Float_t y[4] = {-1.75, -1.72, 1.75, 1.75};
171 Float_t NumX=0., NumY=0., Den=0.;
172 Float_t alpha=0.395, w;
173 for(Int_t i=1; i<5; i++){
174 w = TMath::Power(fZN2TowerEnergy[i], alpha);
175 NumX += x[i]*w;
176 NumY += y[i]*w;
177 Den += w;
178 }
ce099621 179 //
180 if(Den!=0){
181 CentrCoord[0] = fCParCentr(NspecnA)*NumX/Den;
182 CentrCoord[1] = fCParCentr(NspecnA)*NumY/Den;
183 }
d1d3e36b 184 return CentrCoord;
185}