]>
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 | |
27 | //__________________________________________________________________________ | |
61e0abb5 | 28 | |
29 | ||
30 | // --- ROOT system --- | |
31 | ||
32 | // --- Standard library --- | |
33 | ||
34 | #include <iostream.h> | |
35 | ||
36 | // --- AliRoot header files --- | |
37 | ||
38 | #include "AliEMCALDigit.h" | |
39 | ||
40 | ||
41 | ClassImp(AliEMCALDigit) | |
42 | ||
43 | //____________________________________________________________________________ | |
44 | AliEMCALDigit::AliEMCALDigit() | |
45 | { | |
46 | // default ctor | |
47 | ||
48 | fIndexInList = -1 ; | |
49 | fNprimary = 0 ; | |
d75bea67 | 50 | fNMaxPrimary = 21 ; |
61e0abb5 | 51 | fNiparent = 0 ; |
52 | fNMaxiparent = fNMaxPrimary*10; | |
53 | } | |
54 | ||
55 | //____________________________________________________________________________ | |
56 | AliEMCALDigit::AliEMCALDigit(Int_t primary, Int_t iparent, Int_t id, Int_t DigEnergy, Int_t index) | |
57 | { | |
58 | // ctor with all data | |
59 | ||
d75bea67 | 60 | fNMaxPrimary = 21 ; |
61e0abb5 | 61 | fNMaxiparent = fNMaxPrimary*10; |
62 | fAmp = DigEnergy ; | |
63 | fId = id ; | |
64 | fIndexInList = index ; | |
65 | if( primary != -1){ | |
66 | fNprimary = 1 ; | |
67 | fPrimary[0] = primary ; | |
68 | fNiparent = 1 ; | |
69 | fIparent[0] = iparent ; | |
70 | ||
71 | } | |
72 | else{ //If the contribution of this primary smaller than fDigitThreshold (AliEMCALv1) | |
73 | fNprimary = 0 ; | |
74 | fPrimary[0] = -1 ; | |
75 | fNiparent = 0 ; | |
76 | fIparent[0] = -1 ; | |
77 | ||
78 | } | |
79 | Int_t i ; | |
80 | for ( i = 1; i < fNMaxPrimary ; i++) | |
81 | fPrimary[i] = -1 ; | |
82 | ||
83 | for ( Int_t j =1; j< fNMaxiparent ; j++) | |
84 | fIparent[j] = -1 ; | |
85 | } | |
86 | ||
87 | //____________________________________________________________________________ | |
88 | AliEMCALDigit::AliEMCALDigit(const AliEMCALDigit & digit) | |
89 | { | |
90 | // copy ctor | |
91 | ||
92 | ||
93 | fNMaxPrimary = digit.fNMaxPrimary ; | |
94 | fNMaxiparent = digit.fNMaxiparent ; | |
95 | Int_t i ; | |
96 | for ( i = 0; i < fNMaxPrimary ; i++) | |
97 | fPrimary[i] = digit.fPrimary[i] ; | |
98 | Int_t j ; | |
99 | for (j = 0; j< fNMaxiparent ; j++) | |
100 | fIparent[j] = digit.fIparent[j] ; | |
101 | fAmp = digit.fAmp ; | |
102 | fId = digit.fId; | |
103 | fIndexInList = digit.fIndexInList ; | |
104 | fNprimary = digit.fNprimary ; | |
105 | fNiparent = digit.fNiparent ; | |
106 | } | |
107 | ||
108 | //____________________________________________________________________________ | |
109 | AliEMCALDigit::~AliEMCALDigit() | |
110 | { | |
111 | // Delete array of primiries if any | |
112 | ||
113 | } | |
114 | ||
115 | //____________________________________________________________________________ | |
116 | Int_t AliEMCALDigit::Compare(const TObject * obj) const | |
117 | { | |
118 | // Compares two digits with respect to its Id | |
119 | // to sort according increasing Id | |
120 | ||
121 | Int_t rv ; | |
122 | ||
123 | AliEMCALDigit * digit = (AliEMCALDigit *)obj ; | |
124 | ||
125 | Int_t iddiff = fId - digit->GetId() ; | |
126 | ||
127 | if ( iddiff > 0 ) | |
128 | rv = 1 ; | |
129 | else if ( iddiff < 0 ) | |
130 | rv = -1 ; | |
131 | else | |
132 | rv = 0 ; | |
133 | ||
134 | return rv ; | |
135 | ||
136 | } | |
137 | ||
138 | //____________________________________________________________________________ | |
139 | Int_t AliEMCALDigit::GetPrimary(Int_t index) const | |
140 | { | |
141 | // retrieves the primary particle number given its index in the list | |
142 | Int_t rv = -1 ; | |
143 | if ( index <= fNprimary ){ | |
144 | rv = fPrimary[index-1] ; | |
145 | } | |
146 | ||
147 | return rv ; | |
148 | ||
149 | } | |
150 | ||
151 | //____________________________________________________________________________ | |
152 | Int_t AliEMCALDigit::GetIparent(Int_t index) const | |
153 | { | |
154 | // retrieves the primary particle number given its index in the list | |
155 | Int_t rv = -1 ; | |
156 | if ( index <= fNiparent ){ | |
157 | rv = fIparent[index-1] ; | |
158 | } | |
159 | ||
160 | return rv ; | |
161 | ||
162 | } | |
163 | ||
164 | ||
165 | //____________________________________________________________________________ | |
166 | void AliEMCALDigit::ShiftPrimary(Int_t shift){ | |
167 | //shifts primary nimber to BIG offset, to separate primary in different TreeK | |
168 | Int_t index ; | |
169 | for(index = 0; index <fNprimary; index++ ){ | |
170 | fPrimary[index] = fPrimary[index]+ shift * 10000000 ;} | |
171 | for(index =0; index <fNiparent; index++){ | |
172 | fIparent[index] = fIparent[index] + shift * 10000000 ;} | |
173 | } | |
174 | //____________________________________________________________________________ | |
175 | Bool_t AliEMCALDigit::operator==(AliEMCALDigit const & digit) const | |
176 | { | |
177 | // Two digits are equal if they have the same Id | |
178 | ||
179 | if ( fId == digit.fId ) | |
180 | return kTRUE ; | |
181 | else | |
182 | return kFALSE ; | |
183 | } | |
184 | ||
185 | //____________________________________________________________________________ | |
186 | AliEMCALDigit& AliEMCALDigit::operator+(AliEMCALDigit const & digit) | |
187 | { | |
188 | // Adds the amplitude of digits and completes the list of primary particles | |
189 | // if amplitude is larger than | |
190 | ||
191 | fAmp += digit.fAmp ; | |
192 | ||
193 | Int_t max1 = fNprimary ; | |
194 | Int_t max2 = fNiparent ; | |
195 | Int_t index ; | |
196 | for (index = 0 ; index < digit.fNprimary ; index++){ | |
197 | Bool_t deja = kTRUE ; | |
198 | Int_t old ; | |
199 | for ( old = 0 ; (old < max1) && deja; old++) { //already have this primary? | |
200 | if(fPrimary[old] == (digit.fPrimary)[index]) | |
201 | deja = kFALSE; | |
202 | } | |
203 | if(deja){ | |
204 | fPrimary[fNprimary] = (digit.fPrimary)[index] ; | |
205 | fNprimary++ ; | |
206 | if(fNprimary>fNMaxPrimary) { | |
207 | cout << "AliEMCALDigit >> Increase NMaxPrimary "<< endl ; | |
208 | return *this ; | |
209 | } | |
210 | } | |
211 | } | |
212 | ||
213 | for (index = 0 ; index < digit.fNiparent ; index++){ | |
214 | Bool_t dejavu = kTRUE ; | |
215 | Int_t old ; | |
216 | for ( old = 0 ; (old < max2) && dejavu; old++) { //already have this primary? | |
217 | if(fIparent[old] == (digit.fIparent)[index]) | |
218 | dejavu = kFALSE; | |
219 | } | |
220 | if(dejavu){ | |
221 | fIparent[fNiparent] = (digit.fIparent)[index] ; | |
222 | fNiparent++ ; | |
223 | if(fNiparent>fNMaxiparent) { | |
224 | cout << "AliEMCALDigit >> Increase NMaxiparent "<< endl ; | |
225 | return *this ; | |
226 | } | |
227 | } | |
228 | } | |
229 | ||
230 | return *this ; | |
231 | } | |
232 | ||
233 | //____________________________________________________________________________ | |
234 | ostream& operator << ( ostream& out , const AliEMCALDigit & digit) | |
235 | { | |
236 | // Prints the data of the digit | |
237 | ||
238 | out << "ID " << digit.fId << " Energy = " << digit.fAmp << endl ; | |
239 | Int_t i,j ; | |
240 | for(i=0;i<digit.fNprimary;i++) | |
241 | out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ; | |
242 | ||
243 | for(j=0;j<digit.fNiparent;j++) | |
244 | out << "Iparent " << j+1 << " = " << digit.fIparent[j] << endl ; | |
245 | out << "Position in list = " << digit.fIndexInList << endl ; | |
246 | return out ; | |
247 | } | |
248 | ||
249 |