]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliESDCaloCluster.cxx
Corrected copy constructor and destructor
[u/mrichter/AliRoot.git] / STEER / AliESDCaloCluster.cxx
CommitLineData
85c60a8e 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/* $Id$ */
17/* $Log $ */
18
19//-----------------------------------------------------------------
20// Implementation of the ESD Calorimeter cluster class
21// ESD = Event Summary Data
22// This is the class to deal with during the phisics analysis of data
23//
24// J.L. Klay (LLNL)
25//-----------------------------------------------------------------
26
27#include "AliESDCaloCluster.h"
28
29ClassImp(AliESDCaloCluster)
30
31//_______________________________________________________________________
32AliESDCaloCluster::AliESDCaloCluster() :
33 fID(0),
34 fClusterType(-1),
35 fEMCALCluster(kFALSE),
36 fEnergy(-1),
37 fDispersion(-1),
38 fChi2(-1),
e3e93796 39 fPrimaryIndex(-1),
40 fM20(0),
41 fM02(0),
42 fM11(0),
43 fNExMax(0),
44 fEmcCpvDistance(9999),
85c60a8e 45 fNumberOfDigits(0),
46 fDigitAmplitude(0),
47 fDigitTime(0),
48 fDigitIndex(0)
49{
50 //
51 // The default ESD constructor
52 //
53 fGlobalPos[0] = fGlobalPos[1] = fGlobalPos[2] = 0.;
54 for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = 0.;
55}
56
57//_______________________________________________________________________
58AliESDCaloCluster::AliESDCaloCluster(const AliESDCaloCluster& clus) :
59 TObject(clus),
60 fID(clus.fID),
61 fClusterType(clus.fClusterType),
62 fEMCALCluster(clus.fEMCALCluster),
63 fEnergy(clus.fEnergy),
64 fDispersion(clus.fDispersion),
65 fChi2(clus.fChi2),
e3e93796 66 fPrimaryIndex(clus.fPrimaryIndex),
67 fM20(clus.fM20),
68 fM02(clus.fM02),
e0af7ed2 69 fM11(clus.fM11),
e3e93796 70 fNExMax(clus.fNExMax),
71 fEmcCpvDistance(clus.fEmcCpvDistance),
85c60a8e 72 fNumberOfDigits(clus.fNumberOfDigits)
73{
74 //
75 // The copy constructor
76 //
77 fGlobalPos[0] = clus.fGlobalPos[0];
78 fGlobalPos[1] = clus.fGlobalPos[1];
79 fGlobalPos[2] = clus.fGlobalPos[2];
80
81 for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = clus.fPID[i];
82
e0af7ed2 83 fDigitAmplitude = 0x0;
84 fDigitTime = 0x0;
85 fDigitIndex = 0x0;
85c60a8e 86
e0af7ed2 87 if (clus.fNumberOfDigits > 0) {
88 if (clus.fDigitAmplitude) {
89 fDigitAmplitude = new UShort_t[clus.fNumberOfDigits];
90 for (Int_t i=0; i<clus.fNumberOfDigits; i++)
91 fDigitAmplitude[i]=clus.fDigitAmplitude[i];
92 }
93 if (clus.fDigitTime) {
94 fDigitTime = new UShort_t[clus.fNumberOfDigits];
95 for (Int_t i=0; i<clus.fNumberOfDigits; i++)
96 fDigitTime[i]=clus.fDigitTime[i];
97 }
98 if (clus.fDigitIndex) {
99 fDigitIndex = new UShort_t[clus.fNumberOfDigits];
100 for (Int_t i=0; i<clus.fNumberOfDigits; i++)
101 fDigitIndex[i]=clus.fDigitIndex[i];
102 }
103 }
85c60a8e 104}
105
106
107//_______________________________________________________________________
108AliESDCaloCluster::~AliESDCaloCluster(){
109 //
110 // This is destructor according Coding Conventrions
111 //
e0af7ed2 112 // AliESDCaloCluster is the owner of the arrays
113 // even if they are created outside
114
115 delete[] fDigitAmplitude;
116 delete[] fDigitTime;
117 delete[] fDigitIndex;
118
85c60a8e 119}
120
121//_______________________________________________________________________
122void AliESDCaloCluster::SetPid(const Float_t *p) {
123 // Sets the probability of each particle type
124 // Copied from AliESDtrack SetPIDValues
125 // This function copies "n" PID weights from "scr" to "dest"
126 // and normalizes their sum to 1 thus producing conditional
127 // probabilities.
128 // The negative weights are set to 0.
129 // In case all the weights are non-positive they are replaced by
130 // uniform probabilities
131
132 Int_t n = AliPID::kSPECIESN;
133
134 Float_t uniform = 1./(Float_t)n;
135
136 Float_t sum = 0;
137 for (Int_t i=0; i<n; i++)
138 if (p[i]>=0) {
139 sum+=p[i];
140 fPID[i] = p[i];
141 }
142 else {
143 fPID[i] = 0;
144 }
145
146 if(sum>0)
147 for (Int_t i=0; i<n; i++) fPID[i] /= sum;
148 else
149 for (Int_t i=0; i<n; i++) fPID[i] = uniform;
150
151}