]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSDigit.cxx
### files: AliTPCTempMap.h (.cxx)
[u/mrichter/AliRoot.git] / PHOS / AliPHOSDigit.cxx
CommitLineData
d15a28e7 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
b2a60966 16/* $Id$ */
17
702ab87e 18/* History of cvs commits:
19 *
20 * $Log$
3663622c 21 * Revision 1.39 2006/04/22 15:04:24 hristov
22 * Effective C++ initialization of data members in the default constructor
23 *
f146da82 24 * Revision 1.38 2006/04/22 10:30:17 hristov
25 * Add fEnergy to AliPHOSDigit and operate with EMC amplitude in energy units (Yu.Kharlov)
26 *
27a73a5d 27 * Revision 1.37 2005/05/28 14:19:04 schutz
28 * Compilation warnings fixed by T.P.
29 *
702ab87e 30 */
31
d15a28e7 32//_________________________________________________________________________
b2a60966 33// PHOS digit: Id
34// energy
35// 3 identifiers for the primary particle(s) at the origine of the digit
36// The digits are made in FinishEvent() by summing all the hits in a single PHOS crystal or PPSD gas cell
b2a60966 37//
9688c1dd 38//*-- Author: Laurent Aphecetche & Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
b2a60966 39
d15a28e7 40
41// --- ROOT system ---
42
88cb7938 43#include "TMath.h"
44
d15a28e7 45// --- Standard library ---
46
d15a28e7 47// --- AliRoot header files ---
48
49#include "AliPHOSDigit.h"
50
51
88cb7938 52
53
d15a28e7 54ClassImp(AliPHOSDigit)
55
cf239357 56//____________________________________________________________________________
f146da82 57AliPHOSDigit::AliPHOSDigit() :
58 AliDigitNew(),
59 fNprimary(0),
60 fPrimary(0x0),
61 fEnergy(0.),
62 fTime(0.),
63 fTimeR(0.)
64
cf239357 65{
b2a60966 66 // default ctor
cf239357 67}
68
d15a28e7 69//____________________________________________________________________________
3663622c 70AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t digEnergy, Float_t time, Int_t index) :
71 fNprimary(0),
72 fPrimary(0),
73 fEnergy(0.f),
74 fTime(0.f),
75 fTimeR(0.f)
d15a28e7 76{
b2a60966 77 // ctor with all data
78
7b7c1533 79 fAmp = digEnergy ;
27a73a5d 80 fEnergy = 0 ;
81 fTime = time ;
82 fTimeR = fTime ;
83 fId = id ;
84 fIndexInList = index ;
85 if( primary != -1){
86 fNprimary = 1 ;
87 fPrimary = new Int_t[fNprimary] ;
88 fPrimary[0] = primary ;
89 }
90 else{ //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1)
91 fNprimary = 0 ;
92 fPrimary = 0 ;
93 }
94}
95
96//____________________________________________________________________________
3663622c 97AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Float_t energy, Float_t time, Int_t index) :
98 fNprimary(0),
99 fPrimary(0),
100 fEnergy(0.f),
101 fTime(0.f),
102 fTimeR(0.f)
27a73a5d 103{
104 // ctor with all data
105
106 fAmp = 0 ;
107 fEnergy = energy ;
9688c1dd 108 fTime = time ;
04f0bda3 109 fTimeR = fTime ;
83974468 110 fId = id ;
111 fIndexInList = index ;
4a2ca5e9 112 if( primary != -1){
113 fNprimary = 1 ;
adc232ca 114 fPrimary = new Int_t[fNprimary] ;
366c5d6f 115 fPrimary[0] = primary ;
4a2ca5e9 116 }
117 else{ //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1)
adc232ca 118 fNprimary = 0 ;
119 fPrimary = 0 ;
4a2ca5e9 120 }
cf239357 121}
122
123//____________________________________________________________________________
3663622c 124AliPHOSDigit::AliPHOSDigit(const AliPHOSDigit & digit) :
125 AliDigitNew(digit),
126 fNprimary(digit.fNprimary),
127 fPrimary(0),
128 fEnergy(digit.fEnergy),
129 fTime(digit.fTime),
130 fTimeR(digit.fTimeR)
131
b2a60966 132{
133 // copy ctor
adc232ca 134 if(fNprimary){
135 fPrimary = new Int_t[fNprimary] ;
136 for (Int_t i = 0; i < fNprimary ; i++)
137 fPrimary[i] = digit.fPrimary[i] ;
138 }
139 else
140 fPrimary = 0 ;
83974468 141 fAmp = digit.fAmp ;
142 fId = digit.fId;
143 fIndexInList = digit.fIndexInList ;
ff4c968a 144}
145
2e5c3041 146//____________________________________________________________________________
36d93c12 147AliPHOSDigit::~AliPHOSDigit()
2e5c3041 148{
149 // Delete array of primiries if any
adc232ca 150 if(fPrimary)
151 delete [] fPrimary ;
2e5c3041 152}
153
d15a28e7 154//____________________________________________________________________________
037cc66d 155Int_t AliPHOSDigit::Compare(const TObject * obj) const
d15a28e7 156{
b2a60966 157 // Compares two digits with respect to its Id
158 // to sort according increasing Id
159
88714635 160 Int_t rv ;
cf239357 161
162 AliPHOSDigit * digit = (AliPHOSDigit *)obj ;
163
164 Int_t iddiff = fId - digit->GetId() ;
165
166 if ( iddiff > 0 )
167 rv = 1 ;
168 else if ( iddiff < 0 )
169 rv = -1 ;
170 else
171 rv = 0 ;
172
173 return rv ;
174
175}
26d4b141 176
177//____________________________________________________________________________
178Int_t AliPHOSDigit::GetPrimary(Int_t index) const
179{
2f04ed65 180 // retrieves the primary particle number given its index in the list
36d93c12 181 Int_t rv = -1 ;
36641f9d 182 if ( index <= fNprimary && index > 0){
36d93c12 183 rv = fPrimary[index-1] ;
184 }
26d4b141 185
186 return rv ;
366c5d6f 187
26d4b141 188}
990119d6 189//____________________________________________________________________________
702ab87e 190void AliPHOSDigit::Print(const Option_t *) const
d8ca0b45 191{
e957fea8 192 // Print the digit together with list of primaries
27a73a5d 193 printf("PHOS digit: Amp=%d/E=%.3f, Id=%d, Time=%.3e, TimeR=%.3e, NPrim=%d ",fAmp,fEnergy,fId,fTime,fTimeR,fNprimary);
adc232ca 194 for(Int_t index = 0; index <fNprimary; index ++ )
195 printf(" %d ",fPrimary[index]);
196 printf("\n") ;
d8ca0b45 197}
198//____________________________________________________________________________
a4e98857 199void AliPHOSDigit::ShiftPrimary(Int_t shift)
200{
201 //shifts primary number to BIG offset, to separate primary in different TreeK
adc232ca 202 for(Int_t index = 0; index <fNprimary; index ++ ){
203 fPrimary[index]+= shift ;
990119d6 204 }
205}
cf239357 206//____________________________________________________________________________
207Bool_t AliPHOSDigit::operator==(AliPHOSDigit const & digit) const
208{
b2a60966 209 // Two digits are equal if they have the same Id
210
cf239357 211 if ( fId == digit.fId )
d15a28e7 212 return kTRUE ;
213 else
214 return kFALSE ;
215}
cf239357 216
d15a28e7 217//____________________________________________________________________________
3663622c 218AliPHOSDigit& AliPHOSDigit::operator+=(AliPHOSDigit const & digit)
d15a28e7 219{
adc232ca 220
b2a60966 221 // Adds the amplitude of digits and completes the list of primary particles
adc232ca 222 if(digit.fNprimary>0){
223 Int_t *tmp = new Int_t[fNprimary+digit.fNprimary] ;
27a73a5d 224 if(fAmp < digit.fAmp || fEnergy < digit.fEnergy){//most energetic primary in second digit => first primaries in list from second digit
adc232ca 225 for (Int_t index = 0 ; index < digit.fNprimary ; index++)
226 tmp[index]=(digit.fPrimary)[index] ;
227 for (Int_t index = 0 ; index < fNprimary ; index++)
228 tmp[index+digit.fNprimary]=fPrimary[index] ;
229 }
230 else{ //add new primaries to the end
231 for (Int_t index = 0 ; index < fNprimary ; index++)
232 tmp[index]=fPrimary[index] ;
233 for (Int_t index = 0 ; index < digit.fNprimary ; index++)
234 tmp[index+fNprimary]=(digit.fPrimary)[index] ;
235 }
236 if(fPrimary)
237 delete []fPrimary ;
238 fPrimary = tmp ;
239 }
240 fNprimary+=digit.fNprimary ;
27a73a5d 241 fAmp += digit.fAmp ;
242 fEnergy += digit.fEnergy ;
adc232ca 243 if(fTime > digit.fTime)
244 fTime = digit.fTime ;
04f0bda3 245 fTimeR = fTime ;
adc232ca 246 return *this ;
88cb7938 247}
88cb7938 248//____________________________________________________________________________
3663622c 249AliPHOSDigit& AliPHOSDigit::operator *= (Float_t factor)
88cb7938 250{
251 // Multiplies the amplitude by a factor
bb53c80c 252
88cb7938 253 Float_t tempo = static_cast<Float_t>(fAmp) ;
254 tempo *= factor ;
255 fAmp = static_cast<Int_t>(TMath::Ceil(tempo)) ;
d15a28e7 256 return *this ;
257}
258
259//____________________________________________________________________________
cf239357 260ostream& operator << ( ostream& out , const AliPHOSDigit & digit)
d15a28e7 261{
b2a60966 262 // Prints the data of the digit
263
21cd0c07 264// out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ;
265// Int_t i ;
266// for(i=0;i<digit.fNprimary;i++)
267// out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ;
268// out << "Position in list = " << digit.fIndexInList << endl ;
269 digit.Warning("operator <<", "Implement differently") ;
d15a28e7 270 return out ;
271}
272
cf239357 273