]>
Commit | Line | Data |
---|---|---|
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 | ||
d15a28e7 | 18 | //_________________________________________________________________________ |
b2a60966 | 19 | // PHOS digit: Id |
20 | // energy | |
21 | // 3 identifiers for the primary particle(s) at the origine of the digit | |
22 | // The digits are made in FinishEvent() by summing all the hits in a single PHOS crystal or PPSD gas cell | |
b2a60966 | 23 | // |
9688c1dd | 24 | //*-- Author: Laurent Aphecetche & Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH) |
b2a60966 | 25 | |
d15a28e7 | 26 | |
27 | // --- ROOT system --- | |
28 | ||
88cb7938 | 29 | #include "TMath.h" |
30 | ||
d15a28e7 | 31 | // --- Standard library --- |
32 | ||
d15a28e7 | 33 | // --- AliRoot header files --- |
34 | ||
35 | #include "AliPHOSDigit.h" | |
36 | ||
37 | ||
88cb7938 | 38 | |
39 | ||
d15a28e7 | 40 | ClassImp(AliPHOSDigit) |
41 | ||
cf239357 | 42 | //____________________________________________________________________________ |
f741ce93 | 43 | AliPHOSDigit::AliPHOSDigit() |
cf239357 | 44 | { |
b2a60966 | 45 | // default ctor |
46 | ||
83974468 | 47 | fIndexInList = -1 ; |
48 | fNprimary = 0 ; | |
88cb7938 | 49 | fPrimary = 0; |
cf239357 | 50 | } |
51 | ||
d15a28e7 | 52 | //____________________________________________________________________________ |
9688c1dd | 53 | AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t digEnergy, Float_t time, Int_t index) |
d15a28e7 | 54 | { |
b2a60966 | 55 | // ctor with all data |
56 | ||
7b7c1533 | 57 | fAmp = digEnergy ; |
9688c1dd | 58 | fTime = time ; |
83974468 | 59 | fId = id ; |
60 | fIndexInList = index ; | |
4a2ca5e9 | 61 | if( primary != -1){ |
62 | fNprimary = 1 ; | |
adc232ca | 63 | fPrimary = new Int_t[fNprimary] ; |
366c5d6f | 64 | fPrimary[0] = primary ; |
4a2ca5e9 | 65 | } |
66 | else{ //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1) | |
adc232ca | 67 | fNprimary = 0 ; |
68 | fPrimary = 0 ; | |
4a2ca5e9 | 69 | } |
cf239357 | 70 | } |
71 | ||
72 | //____________________________________________________________________________ | |
73 | AliPHOSDigit::AliPHOSDigit(const AliPHOSDigit & digit) | |
b2a60966 | 74 | { |
75 | // copy ctor | |
36d93c12 | 76 | |
adc232ca | 77 | fNprimary = digit.fNprimary ; |
78 | if(fNprimary){ | |
79 | fPrimary = new Int_t[fNprimary] ; | |
80 | for (Int_t i = 0; i < fNprimary ; i++) | |
81 | fPrimary[i] = digit.fPrimary[i] ; | |
82 | } | |
83 | else | |
84 | fPrimary = 0 ; | |
83974468 | 85 | fAmp = digit.fAmp ; |
9688c1dd | 86 | fTime = digit.fTime ; |
83974468 | 87 | fId = digit.fId; |
88 | fIndexInList = digit.fIndexInList ; | |
ff4c968a | 89 | } |
90 | ||
2e5c3041 | 91 | //____________________________________________________________________________ |
36d93c12 | 92 | AliPHOSDigit::~AliPHOSDigit() |
2e5c3041 | 93 | { |
94 | // Delete array of primiries if any | |
adc232ca | 95 | if(fPrimary) |
96 | delete [] fPrimary ; | |
2e5c3041 | 97 | } |
98 | ||
d15a28e7 | 99 | //____________________________________________________________________________ |
037cc66d | 100 | Int_t AliPHOSDigit::Compare(const TObject * obj) const |
d15a28e7 | 101 | { |
b2a60966 | 102 | // Compares two digits with respect to its Id |
103 | // to sort according increasing Id | |
104 | ||
88714635 | 105 | Int_t rv ; |
cf239357 | 106 | |
107 | AliPHOSDigit * digit = (AliPHOSDigit *)obj ; | |
108 | ||
109 | Int_t iddiff = fId - digit->GetId() ; | |
110 | ||
111 | if ( iddiff > 0 ) | |
112 | rv = 1 ; | |
113 | else if ( iddiff < 0 ) | |
114 | rv = -1 ; | |
115 | else | |
116 | rv = 0 ; | |
117 | ||
118 | return rv ; | |
119 | ||
120 | } | |
26d4b141 | 121 | |
122 | //____________________________________________________________________________ | |
123 | Int_t AliPHOSDigit::GetPrimary(Int_t index) const | |
124 | { | |
2f04ed65 | 125 | // retrieves the primary particle number given its index in the list |
36d93c12 | 126 | Int_t rv = -1 ; |
36641f9d | 127 | if ( index <= fNprimary && index > 0){ |
36d93c12 | 128 | rv = fPrimary[index-1] ; |
129 | } | |
26d4b141 | 130 | |
131 | return rv ; | |
366c5d6f | 132 | |
26d4b141 | 133 | } |
990119d6 | 134 | //____________________________________________________________________________ |
d8ca0b45 | 135 | void AliPHOSDigit::Print(Option_t *option) const |
136 | { | |
adc232ca | 137 | printf("PHOS digit: Amp=%d, Id=%d, Time=%f, NPrim=%d ",fAmp,fId,fTime,fNprimary); |
138 | for(Int_t index = 0; index <fNprimary; index ++ ) | |
139 | printf(" %d ",fPrimary[index]); | |
140 | printf("\n") ; | |
d8ca0b45 | 141 | } |
142 | //____________________________________________________________________________ | |
a4e98857 | 143 | void AliPHOSDigit::ShiftPrimary(Int_t shift) |
144 | { | |
145 | //shifts primary number to BIG offset, to separate primary in different TreeK | |
adc232ca | 146 | for(Int_t index = 0; index <fNprimary; index ++ ){ |
147 | fPrimary[index]+= shift ; | |
990119d6 | 148 | } |
149 | } | |
cf239357 | 150 | //____________________________________________________________________________ |
151 | Bool_t AliPHOSDigit::operator==(AliPHOSDigit const & digit) const | |
152 | { | |
b2a60966 | 153 | // Two digits are equal if they have the same Id |
154 | ||
cf239357 | 155 | if ( fId == digit.fId ) |
d15a28e7 | 156 | return kTRUE ; |
157 | else | |
158 | return kFALSE ; | |
159 | } | |
cf239357 | 160 | |
d15a28e7 | 161 | //____________________________________________________________________________ |
cf239357 | 162 | AliPHOSDigit& AliPHOSDigit::operator+(AliPHOSDigit const & digit) |
d15a28e7 | 163 | { |
adc232ca | 164 | |
b2a60966 | 165 | // Adds the amplitude of digits and completes the list of primary particles |
adc232ca | 166 | if(digit.fNprimary>0){ |
167 | Int_t *tmp = new Int_t[fNprimary+digit.fNprimary] ; | |
168 | if(fAmp < digit.fAmp){//most energetic primary in second digit => first primaries in list from second digit | |
169 | for (Int_t index = 0 ; index < digit.fNprimary ; index++) | |
170 | tmp[index]=(digit.fPrimary)[index] ; | |
171 | for (Int_t index = 0 ; index < fNprimary ; index++) | |
172 | tmp[index+digit.fNprimary]=fPrimary[index] ; | |
173 | } | |
174 | else{ //add new primaries to the end | |
175 | for (Int_t index = 0 ; index < fNprimary ; index++) | |
176 | tmp[index]=fPrimary[index] ; | |
177 | for (Int_t index = 0 ; index < digit.fNprimary ; index++) | |
178 | tmp[index+fNprimary]=(digit.fPrimary)[index] ; | |
179 | } | |
180 | if(fPrimary) | |
181 | delete []fPrimary ; | |
182 | fPrimary = tmp ; | |
183 | } | |
184 | fNprimary+=digit.fNprimary ; | |
185 | fAmp += digit.fAmp ; | |
186 | if(fTime > digit.fTime) | |
187 | fTime = digit.fTime ; | |
188 | return *this ; | |
88cb7938 | 189 | } |
88cb7938 | 190 | //____________________________________________________________________________ |
191 | AliPHOSDigit& AliPHOSDigit::operator*(Float_t factor) | |
192 | { | |
193 | // Multiplies the amplitude by a factor | |
bb53c80c | 194 | |
88cb7938 | 195 | Float_t tempo = static_cast<Float_t>(fAmp) ; |
196 | tempo *= factor ; | |
197 | fAmp = static_cast<Int_t>(TMath::Ceil(tempo)) ; | |
d15a28e7 | 198 | return *this ; |
199 | } | |
200 | ||
201 | //____________________________________________________________________________ | |
cf239357 | 202 | ostream& operator << ( ostream& out , const AliPHOSDigit & digit) |
d15a28e7 | 203 | { |
b2a60966 | 204 | // Prints the data of the digit |
205 | ||
21cd0c07 | 206 | // out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ; |
207 | // Int_t i ; | |
208 | // for(i=0;i<digit.fNprimary;i++) | |
209 | // out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ; | |
210 | // out << "Position in list = " << digit.fIndexInList << endl ; | |
211 | digit.Warning("operator <<", "Implement differently") ; | |
d15a28e7 | 212 | return out ; |
213 | } | |
214 | ||
cf239357 | 215 |