]>
Commit | Line | Data |
---|---|---|
61e0abb5 | 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 | ||
ffa6d63b | 16 | /* $Id: */ |
61e0abb5 | 17 | |
18 | //_________________________________________________________________________ | |
ffa6d63b | 19 | // EMCAL digit: |
20 | // A Digit is the sum of the energy lost in an EMCAL Tower | |
21 | // It also stores information on Primary, and enterring particle | |
22 | // tracknumbers Digits are created using AliEMCALSDigitizer, followed | |
23 | // by AliEMCALDigitizer | |
61e0abb5 | 24 | // |
ffa6d63b | 25 | //*-- Author: Sahal Yacoob (LBL) |
26 | // based on : AliPHOSDigit | |
814ad4bf | 27 | //__________________________________________________________________________ |
61e0abb5 | 28 | |
29 | // --- ROOT system --- | |
30 | ||
31 | // --- Standard library --- | |
32 | ||
33 | #include <iostream.h> | |
34 | ||
35 | // --- AliRoot header files --- | |
36 | ||
37 | #include "AliEMCALDigit.h" | |
814ad4bf | 38 | #include "AliEMCALGeometry.h" |
88d764f0 | 39 | #include "AliEMCALGetter.h" |
61e0abb5 | 40 | |
41 | ||
42 | ClassImp(AliEMCALDigit) | |
43 | ||
44 | //____________________________________________________________________________ | |
45 | AliEMCALDigit::AliEMCALDigit() | |
46 | { | |
47 | // default ctor | |
48 | ||
49 | fIndexInList = -1 ; | |
50 | fNprimary = 0 ; | |
88d764f0 | 51 | fNMaxPrimary = 5 ; |
61e0abb5 | 52 | fNiparent = 0 ; |
53 | fNMaxiparent = fNMaxPrimary*10; | |
88d764f0 | 54 | fPrimary = new Int_t[fNMaxPrimary] ; |
55 | fIparent = new Int_t[fNMaxiparent] ; | |
61e0abb5 | 56 | } |
57 | ||
58 | //____________________________________________________________________________ | |
814ad4bf | 59 | AliEMCALDigit::AliEMCALDigit(Int_t primary, Int_t iparent, Int_t id, Int_t DigEnergy, Float_t time, Int_t index) |
61e0abb5 | 60 | { |
61 | // ctor with all data | |
62 | ||
88d764f0 | 63 | fNMaxPrimary = 5 ; |
61e0abb5 | 64 | fNMaxiparent = fNMaxPrimary*10; |
88d764f0 | 65 | fPrimary = new Int_t[fNMaxPrimary] ; |
66 | fIparent = new Int_t[fNMaxiparent] ; | |
61e0abb5 | 67 | fAmp = DigEnergy ; |
814ad4bf | 68 | fTime = time ; |
61e0abb5 | 69 | fId = id ; |
70 | fIndexInList = index ; | |
71 | if( primary != -1){ | |
72 | fNprimary = 1 ; | |
73 | fPrimary[0] = primary ; | |
74 | fNiparent = 1 ; | |
75 | fIparent[0] = iparent ; | |
76 | ||
77 | } | |
78 | else{ //If the contribution of this primary smaller than fDigitThreshold (AliEMCALv1) | |
79 | fNprimary = 0 ; | |
80 | fPrimary[0] = -1 ; | |
81 | fNiparent = 0 ; | |
82 | fIparent[0] = -1 ; | |
83 | ||
84 | } | |
85 | Int_t i ; | |
86 | for ( i = 1; i < fNMaxPrimary ; i++) | |
87 | fPrimary[i] = -1 ; | |
88 | ||
89 | for ( Int_t j =1; j< fNMaxiparent ; j++) | |
90 | fIparent[j] = -1 ; | |
91 | } | |
92 | ||
93 | //____________________________________________________________________________ | |
94 | AliEMCALDigit::AliEMCALDigit(const AliEMCALDigit & digit) | |
95 | { | |
96 | // copy ctor | |
97 | ||
98 | ||
99 | fNMaxPrimary = digit.fNMaxPrimary ; | |
100 | fNMaxiparent = digit.fNMaxiparent ; | |
88d764f0 | 101 | fPrimary = new Int_t[fNMaxPrimary] ; |
102 | fIparent = new Int_t[fNMaxiparent] ; | |
61e0abb5 | 103 | Int_t i ; |
104 | for ( i = 0; i < fNMaxPrimary ; i++) | |
105 | fPrimary[i] = digit.fPrimary[i] ; | |
106 | Int_t j ; | |
107 | for (j = 0; j< fNMaxiparent ; j++) | |
108 | fIparent[j] = digit.fIparent[j] ; | |
109 | fAmp = digit.fAmp ; | |
814ad4bf | 110 | fTime = digit.fTime ; |
61e0abb5 | 111 | fId = digit.fId; |
112 | fIndexInList = digit.fIndexInList ; | |
113 | fNprimary = digit.fNprimary ; | |
114 | fNiparent = digit.fNiparent ; | |
115 | } | |
116 | ||
117 | //____________________________________________________________________________ | |
118 | AliEMCALDigit::~AliEMCALDigit() | |
119 | { | |
120 | // Delete array of primiries if any | |
88d764f0 | 121 | delete [] fPrimary ; |
122 | delete [] fIparent ; | |
61e0abb5 | 123 | } |
124 | ||
125 | //____________________________________________________________________________ | |
126 | Int_t AliEMCALDigit::Compare(const TObject * obj) const | |
127 | { | |
128 | // Compares two digits with respect to its Id | |
129 | // to sort according increasing Id | |
130 | ||
131 | Int_t rv ; | |
132 | ||
133 | AliEMCALDigit * digit = (AliEMCALDigit *)obj ; | |
134 | ||
135 | Int_t iddiff = fId - digit->GetId() ; | |
136 | ||
137 | if ( iddiff > 0 ) | |
138 | rv = 1 ; | |
139 | else if ( iddiff < 0 ) | |
140 | rv = -1 ; | |
141 | else | |
142 | rv = 0 ; | |
143 | ||
144 | return rv ; | |
145 | ||
146 | } | |
147 | ||
814ad4bf | 148 | //____________________________________________________________________________ |
149 | const Float_t AliEMCALDigit::GetEta() const | |
150 | { | |
151 | Float_t eta=-10., phi=-10.; | |
152 | AliEMCALGeometry::GetInstance()->EtaPhiFromIndex(fId,eta,phi); | |
153 | return eta ; | |
154 | } | |
155 | ||
156 | //____________________________________________________________________________ | |
157 | const Float_t AliEMCALDigit::GetPhi() const | |
158 | { | |
159 | Float_t eta=-10., phi=-10.; | |
160 | AliEMCALGeometry::GetInstance()->EtaPhiFromIndex(fId,eta,phi); | |
161 | return phi ; | |
162 | } | |
163 | ||
61e0abb5 | 164 | //____________________________________________________________________________ |
165 | Int_t AliEMCALDigit::GetPrimary(Int_t index) const | |
166 | { | |
167 | // retrieves the primary particle number given its index in the list | |
168 | Int_t rv = -1 ; | |
814ad4bf | 169 | if ( index <= fNprimary && index > 0){ |
61e0abb5 | 170 | rv = fPrimary[index-1] ; |
171 | } | |
172 | ||
173 | return rv ; | |
174 | ||
175 | } | |
176 | ||
177 | //____________________________________________________________________________ | |
178 | Int_t AliEMCALDigit::GetIparent(Int_t index) const | |
179 | { | |
180 | // retrieves the primary particle number given its index in the list | |
181 | Int_t rv = -1 ; | |
182 | if ( index <= fNiparent ){ | |
183 | rv = fIparent[index-1] ; | |
184 | } | |
185 | ||
186 | return rv ; | |
187 | ||
188 | } | |
189 | ||
88d764f0 | 190 | //______________________________________________________________________ |
191 | const Bool_t AliEMCALDigit::IsInPreShower() const | |
192 | { | |
193 | Bool_t rv = kFALSE ; | |
194 | const AliEMCALGeometry * geom = AliEMCALGetter::GetInstance()->EMCALGeometry() ; | |
195 | if( GetId() > (geom->GetNZ() * geom->GetNPhi() )) | |
196 | rv = kTRUE; | |
197 | return rv; | |
198 | } | |
61e0abb5 | 199 | |
200 | //____________________________________________________________________________ | |
201 | void AliEMCALDigit::ShiftPrimary(Int_t shift){ | |
202 | //shifts primary nimber to BIG offset, to separate primary in different TreeK | |
203 | Int_t index ; | |
204 | for(index = 0; index <fNprimary; index++ ){ | |
205 | fPrimary[index] = fPrimary[index]+ shift * 10000000 ;} | |
206 | for(index =0; index <fNiparent; index++){ | |
207 | fIparent[index] = fIparent[index] + shift * 10000000 ;} | |
208 | } | |
209 | //____________________________________________________________________________ | |
210 | Bool_t AliEMCALDigit::operator==(AliEMCALDigit const & digit) const | |
211 | { | |
212 | // Two digits are equal if they have the same Id | |
213 | ||
214 | if ( fId == digit.fId ) | |
215 | return kTRUE ; | |
216 | else | |
217 | return kFALSE ; | |
218 | } | |
219 | ||
220 | //____________________________________________________________________________ | |
221 | AliEMCALDigit& AliEMCALDigit::operator+(AliEMCALDigit const & digit) | |
222 | { | |
223 | // Adds the amplitude of digits and completes the list of primary particles | |
224 | // if amplitude is larger than | |
225 | ||
226 | fAmp += digit.fAmp ; | |
814ad4bf | 227 | if(fTime > digit.fTime) |
228 | fTime = digit.fTime ; | |
61e0abb5 | 229 | |
230 | Int_t max1 = fNprimary ; | |
231 | Int_t max2 = fNiparent ; | |
232 | Int_t index ; | |
233 | for (index = 0 ; index < digit.fNprimary ; index++){ | |
234 | Bool_t deja = kTRUE ; | |
235 | Int_t old ; | |
236 | for ( old = 0 ; (old < max1) && deja; old++) { //already have this primary? | |
237 | if(fPrimary[old] == (digit.fPrimary)[index]) | |
238 | deja = kFALSE; | |
239 | } | |
240 | if(deja){ | |
241 | fPrimary[fNprimary] = (digit.fPrimary)[index] ; | |
242 | fNprimary++ ; | |
243 | if(fNprimary>fNMaxPrimary) { | |
244 | cout << "AliEMCALDigit >> Increase NMaxPrimary "<< endl ; | |
245 | return *this ; | |
246 | } | |
247 | } | |
248 | } | |
249 | ||
250 | for (index = 0 ; index < digit.fNiparent ; index++){ | |
251 | Bool_t dejavu = kTRUE ; | |
252 | Int_t old ; | |
253 | for ( old = 0 ; (old < max2) && dejavu; old++) { //already have this primary? | |
254 | if(fIparent[old] == (digit.fIparent)[index]) | |
255 | dejavu = kFALSE; | |
256 | } | |
257 | if(dejavu){ | |
258 | fIparent[fNiparent] = (digit.fIparent)[index] ; | |
259 | fNiparent++ ; | |
260 | if(fNiparent>fNMaxiparent) { | |
261 | cout << "AliEMCALDigit >> Increase NMaxiparent "<< endl ; | |
262 | return *this ; | |
263 | } | |
264 | } | |
265 | } | |
266 | ||
267 | return *this ; | |
268 | } | |
269 | ||
270 | //____________________________________________________________________________ | |
271 | ostream& operator << ( ostream& out , const AliEMCALDigit & digit) | |
272 | { | |
273 | // Prints the data of the digit | |
274 | ||
814ad4bf | 275 | out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ; |
61e0abb5 | 276 | Int_t i,j ; |
277 | for(i=0;i<digit.fNprimary;i++) | |
278 | out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ; | |
279 | ||
280 | for(j=0;j<digit.fNiparent;j++) | |
281 | out << "Iparent " << j+1 << " = " << digit.fIparent[j] << endl ; | |
282 | out << "Position in list = " << digit.fIndexInList << endl ; | |
283 | return out ; | |
284 | } | |
285 | ||
286 |