]>
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 | ||
29 | // --- Standard library --- | |
30 | ||
d15a28e7 | 31 | // --- AliRoot header files --- |
32 | ||
33 | #include "AliPHOSDigit.h" | |
34 | ||
35 | ||
36 | ClassImp(AliPHOSDigit) | |
37 | ||
cf239357 | 38 | //____________________________________________________________________________ |
f741ce93 | 39 | AliPHOSDigit::AliPHOSDigit() |
cf239357 | 40 | { |
b2a60966 | 41 | // default ctor |
42 | ||
83974468 | 43 | fIndexInList = -1 ; |
44 | fNprimary = 0 ; | |
366c5d6f | 45 | fNMaxPrimary = 5 ; |
cf239357 | 46 | } |
47 | ||
d15a28e7 | 48 | //____________________________________________________________________________ |
9688c1dd | 49 | AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t digEnergy, Float_t time, Int_t index) |
d15a28e7 | 50 | { |
b2a60966 | 51 | // ctor with all data |
52 | ||
2e5c3041 | 53 | fNMaxPrimary = 5 ; |
7b7c1533 | 54 | fAmp = digEnergy ; |
9688c1dd | 55 | fTime = time ; |
83974468 | 56 | fId = id ; |
57 | fIndexInList = index ; | |
4a2ca5e9 | 58 | if( primary != -1){ |
59 | fNprimary = 1 ; | |
366c5d6f | 60 | fPrimary[0] = primary ; |
4a2ca5e9 | 61 | } |
62 | else{ //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1) | |
63 | fNprimary = 0 ; | |
366c5d6f | 64 | fPrimary[0] = -1 ; |
4a2ca5e9 | 65 | } |
366c5d6f | 66 | Int_t i ; |
67 | for ( i = 1; i < fNMaxPrimary ; i++) | |
68 | fPrimary[i] = -1 ; | |
cf239357 | 69 | } |
70 | ||
71 | //____________________________________________________________________________ | |
72 | AliPHOSDigit::AliPHOSDigit(const AliPHOSDigit & digit) | |
b2a60966 | 73 | { |
74 | // copy ctor | |
75 | ||
36d93c12 | 76 | |
77 | fNMaxPrimary = digit.fNMaxPrimary ; | |
78 | Int_t i ; | |
79 | for ( i = 0; i < fNMaxPrimary ; i++) | |
80 | fPrimary[i] = digit.fPrimary[i] ; | |
83974468 | 81 | fAmp = digit.fAmp ; |
9688c1dd | 82 | fTime = digit.fTime ; |
83974468 | 83 | fId = digit.fId; |
84 | fIndexInList = digit.fIndexInList ; | |
85 | fNprimary = digit.fNprimary ; | |
ff4c968a | 86 | } |
87 | ||
2e5c3041 | 88 | //____________________________________________________________________________ |
36d93c12 | 89 | AliPHOSDigit::~AliPHOSDigit() |
2e5c3041 | 90 | { |
91 | // Delete array of primiries if any | |
36d93c12 | 92 | |
2e5c3041 | 93 | } |
94 | ||
d15a28e7 | 95 | //____________________________________________________________________________ |
037cc66d | 96 | Int_t AliPHOSDigit::Compare(const TObject * obj) const |
d15a28e7 | 97 | { |
b2a60966 | 98 | // Compares two digits with respect to its Id |
99 | // to sort according increasing Id | |
100 | ||
88714635 | 101 | Int_t rv ; |
cf239357 | 102 | |
103 | AliPHOSDigit * digit = (AliPHOSDigit *)obj ; | |
104 | ||
105 | Int_t iddiff = fId - digit->GetId() ; | |
106 | ||
107 | if ( iddiff > 0 ) | |
108 | rv = 1 ; | |
109 | else if ( iddiff < 0 ) | |
110 | rv = -1 ; | |
111 | else | |
112 | rv = 0 ; | |
113 | ||
114 | return rv ; | |
115 | ||
116 | } | |
26d4b141 | 117 | |
118 | //____________________________________________________________________________ | |
119 | Int_t AliPHOSDigit::GetPrimary(Int_t index) const | |
120 | { | |
2f04ed65 | 121 | // retrieves the primary particle number given its index in the list |
36d93c12 | 122 | Int_t rv = -1 ; |
36641f9d | 123 | if ( index <= fNprimary && index > 0){ |
36d93c12 | 124 | rv = fPrimary[index-1] ; |
125 | } | |
26d4b141 | 126 | |
127 | return rv ; | |
366c5d6f | 128 | |
26d4b141 | 129 | } |
990119d6 | 130 | //____________________________________________________________________________ |
d8ca0b45 | 131 | void AliPHOSDigit::Print(Option_t *option) const |
132 | { | |
133 | printf("PHOS digit: Amp=%d, Id=%d\n",fAmp,fId); | |
134 | } | |
135 | //____________________________________________________________________________ | |
a4e98857 | 136 | void AliPHOSDigit::ShiftPrimary(Int_t shift) |
137 | { | |
138 | //shifts primary number to BIG offset, to separate primary in different TreeK | |
990119d6 | 139 | Int_t index ; |
140 | for(index = 0; index <fNprimary; index ++ ){ | |
21c293b7 | 141 | fPrimary[index] = fPrimary[index]+ shift ; |
990119d6 | 142 | } |
143 | } | |
cf239357 | 144 | //____________________________________________________________________________ |
145 | Bool_t AliPHOSDigit::operator==(AliPHOSDigit const & digit) const | |
146 | { | |
b2a60966 | 147 | // Two digits are equal if they have the same Id |
148 | ||
cf239357 | 149 | if ( fId == digit.fId ) |
d15a28e7 | 150 | return kTRUE ; |
151 | else | |
152 | return kFALSE ; | |
153 | } | |
cf239357 | 154 | |
d15a28e7 | 155 | //____________________________________________________________________________ |
cf239357 | 156 | AliPHOSDigit& AliPHOSDigit::operator+(AliPHOSDigit const & digit) |
d15a28e7 | 157 | { |
b2a60966 | 158 | // Adds the amplitude of digits and completes the list of primary particles |
4a2ca5e9 | 159 | // if amplitude is larger than |
36d93c12 | 160 | |
bb53c80c | 161 | Int_t toAdd = fNprimary ; |
162 | if(digit.fNprimary>0){ | |
163 | if(fAmp < digit.fAmp){//most energetic primary in digit => first primaries in list from second digit | |
164 | for (Int_t index = 0 ; index < digit.fNprimary ; index++){ | |
165 | for (Int_t old = 0 ; old < fNprimary ; old++) { //already have this primary? | |
166 | if(fPrimary[old] == (digit.fPrimary)[index]){ | |
167 | fPrimary[old] = -1 ; //removed | |
168 | toAdd-- ; | |
169 | break ; | |
170 | } | |
171 | } | |
172 | } | |
173 | if(digit.fNprimary+toAdd >fNMaxPrimary) //Do not change primary list | |
21cd0c07 | 174 | Error("Operator +", "Increase NMaxPrimary") ; |
bb53c80c | 175 | else{ |
176 | for(Int_t index = fNprimary-1 ; index >=0 ; index--){ //move old primaries | |
177 | if(fPrimary[index]>-1){ | |
178 | fPrimary[fNprimary+toAdd]=fPrimary[index] ; | |
179 | toAdd-- ; | |
180 | } | |
181 | } | |
182 | //copy new primaries | |
183 | for(Int_t index = 0; index < digit.fNprimary ; index++){ | |
184 | fPrimary[index] = (digit.fPrimary)[index] ; | |
185 | } | |
550bee17 | 186 | } |
187 | } | |
bb53c80c | 188 | else{ //add new primaries to the end |
189 | for(Int_t index = 0 ; index < digit.fNprimary ; index++){ | |
190 | Bool_t deja = kTRUE ; | |
191 | for(Int_t old = 0 ; old < fNprimary; old++) { //already have this primary? | |
192 | if(fPrimary[old] == (digit.fPrimary)[index]){ | |
193 | deja = kFALSE; | |
194 | break ; | |
195 | } | |
196 | } | |
197 | if(deja){ | |
198 | fPrimary[fNprimary] = (digit.fPrimary)[index] ; | |
199 | fNprimary++ ; | |
200 | if(fNprimary>fNMaxPrimary) { | |
201 | Error("Operator +", "Increase NMaxPrimary") ; | |
202 | break ; | |
203 | } | |
204 | } | |
205 | } | |
206 | ||
207 | } | |
f741ce93 | 208 | } |
550bee17 | 209 | |
bb53c80c | 210 | fAmp += digit.fAmp ; |
211 | if(fTime > digit.fTime) | |
212 | fTime = digit.fTime ; | |
213 | ||
d15a28e7 | 214 | return *this ; |
215 | } | |
216 | ||
217 | //____________________________________________________________________________ | |
cf239357 | 218 | ostream& operator << ( ostream& out , const AliPHOSDigit & digit) |
d15a28e7 | 219 | { |
b2a60966 | 220 | // Prints the data of the digit |
221 | ||
21cd0c07 | 222 | // out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ; |
223 | // Int_t i ; | |
224 | // for(i=0;i<digit.fNprimary;i++) | |
225 | // out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ; | |
226 | // out << "Position in list = " << digit.fIndexInList << endl ; | |
227 | digit.Warning("operator <<", "Implement differently") ; | |
d15a28e7 | 228 | return out ; |
229 | } | |
230 | ||
cf239357 | 231 |