]>
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 | |
23 | // It would be nice to replace the 3 identifiers by an array, but, because digits are kept in a TClonesQArray, | |
24 | // it is not possible to stream such an array... (beyond my understqnding!) | |
25 | // | |
26 | //*-- Author: Laurent Aphecetche & Yves Schutz (SUBATECH) | |
27 | ||
d15a28e7 | 28 | |
29 | // --- ROOT system --- | |
30 | ||
31 | // --- Standard library --- | |
32 | ||
de9ec31b | 33 | #include <iostream.h> |
d15a28e7 | 34 | |
35 | // --- AliRoot header files --- | |
36 | ||
37 | #include "AliPHOSDigit.h" | |
38 | ||
39 | ||
40 | ClassImp(AliPHOSDigit) | |
41 | ||
cf239357 | 42 | //____________________________________________________________________________ |
f741ce93 | 43 | AliPHOSDigit::AliPHOSDigit() |
cf239357 | 44 | { |
b2a60966 | 45 | // default ctor |
46 | ||
83974468 | 47 | fIndexInList = -1 ; |
48 | fNprimary = 0 ; | |
366c5d6f | 49 | fNMaxPrimary = 5 ; |
cf239357 | 50 | } |
51 | ||
d15a28e7 | 52 | //____________________________________________________________________________ |
83974468 | 53 | AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t DigEnergy, Int_t index) |
d15a28e7 | 54 | { |
b2a60966 | 55 | // ctor with all data |
56 | ||
2e5c3041 | 57 | fNMaxPrimary = 5 ; |
83974468 | 58 | fAmp = DigEnergy ; |
59 | fId = id ; | |
60 | fIndexInList = index ; | |
4a2ca5e9 | 61 | if( primary != -1){ |
62 | fNprimary = 1 ; | |
366c5d6f | 63 | fPrimary[0] = primary ; |
4a2ca5e9 | 64 | } |
65 | else{ //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1) | |
66 | fNprimary = 0 ; | |
366c5d6f | 67 | fPrimary[0] = -1 ; |
4a2ca5e9 | 68 | } |
366c5d6f | 69 | Int_t i ; |
70 | for ( i = 1; i < fNMaxPrimary ; i++) | |
71 | fPrimary[i] = -1 ; | |
cf239357 | 72 | } |
73 | ||
74 | //____________________________________________________________________________ | |
75 | AliPHOSDigit::AliPHOSDigit(const AliPHOSDigit & digit) | |
b2a60966 | 76 | { |
77 | // copy ctor | |
78 | ||
36d93c12 | 79 | |
80 | fNMaxPrimary = digit.fNMaxPrimary ; | |
81 | Int_t i ; | |
82 | for ( i = 0; i < fNMaxPrimary ; i++) | |
83 | fPrimary[i] = digit.fPrimary[i] ; | |
83974468 | 84 | fAmp = digit.fAmp ; |
85 | fId = digit.fId; | |
86 | fIndexInList = digit.fIndexInList ; | |
87 | fNprimary = digit.fNprimary ; | |
ff4c968a | 88 | } |
89 | ||
2e5c3041 | 90 | //____________________________________________________________________________ |
36d93c12 | 91 | AliPHOSDigit::~AliPHOSDigit() |
2e5c3041 | 92 | { |
93 | // Delete array of primiries if any | |
36d93c12 | 94 | |
2e5c3041 | 95 | } |
96 | ||
d15a28e7 | 97 | //____________________________________________________________________________ |
037cc66d | 98 | Int_t AliPHOSDigit::Compare(const TObject * obj) const |
d15a28e7 | 99 | { |
b2a60966 | 100 | // Compares two digits with respect to its Id |
101 | // to sort according increasing Id | |
102 | ||
88714635 | 103 | Int_t rv ; |
cf239357 | 104 | |
105 | AliPHOSDigit * digit = (AliPHOSDigit *)obj ; | |
106 | ||
107 | Int_t iddiff = fId - digit->GetId() ; | |
108 | ||
109 | if ( iddiff > 0 ) | |
110 | rv = 1 ; | |
111 | else if ( iddiff < 0 ) | |
112 | rv = -1 ; | |
113 | else | |
114 | rv = 0 ; | |
115 | ||
116 | return rv ; | |
117 | ||
118 | } | |
26d4b141 | 119 | |
120 | //____________________________________________________________________________ | |
121 | Int_t AliPHOSDigit::GetPrimary(Int_t index) const | |
122 | { | |
2f04ed65 | 123 | // retrieves the primary particle number given its index in the list |
36d93c12 | 124 | Int_t rv = -1 ; |
125 | if ( index <= fNprimary ){ | |
126 | rv = fPrimary[index-1] ; | |
127 | } | |
26d4b141 | 128 | |
129 | return rv ; | |
366c5d6f | 130 | |
26d4b141 | 131 | } |
990119d6 | 132 | //____________________________________________________________________________ |
133 | void AliPHOSDigit::ShiftPrimary(Int_t shift){ | |
134 | //shifts primary nimber to BIG offset, to separate primary in different TreeK | |
135 | Int_t index ; | |
136 | for(index = 0; index <fNprimary; index ++ ){ | |
137 | fPrimary[index] = fPrimary[index]+ shift * 10000000 ; | |
138 | } | |
139 | } | |
cf239357 | 140 | //____________________________________________________________________________ |
141 | Bool_t AliPHOSDigit::operator==(AliPHOSDigit const & digit) const | |
142 | { | |
b2a60966 | 143 | // Two digits are equal if they have the same Id |
144 | ||
cf239357 | 145 | if ( fId == digit.fId ) |
d15a28e7 | 146 | return kTRUE ; |
147 | else | |
148 | return kFALSE ; | |
149 | } | |
cf239357 | 150 | |
d15a28e7 | 151 | //____________________________________________________________________________ |
cf239357 | 152 | AliPHOSDigit& AliPHOSDigit::operator+(AliPHOSDigit const & digit) |
d15a28e7 | 153 | { |
b2a60966 | 154 | // Adds the amplitude of digits and completes the list of primary particles |
4a2ca5e9 | 155 | // if amplitude is larger than |
36d93c12 | 156 | |
cf239357 | 157 | fAmp += digit.fAmp ; |
36d93c12 | 158 | |
f741ce93 | 159 | Int_t max1 = fNprimary ; |
36d93c12 | 160 | |
550bee17 | 161 | Int_t index ; |
162 | for (index = 0 ; index < digit.fNprimary ; index++){ | |
163 | Bool_t deja = kTRUE ; | |
164 | Int_t old ; | |
165 | for ( old = 0 ; (old < max1) && deja; old++) { //already have this primary? | |
166 | if(fPrimary[old] == (digit.fPrimary)[index]) | |
167 | deja = kFALSE; | |
168 | } | |
169 | if(deja){ | |
170 | fPrimary[fNprimary] = (digit.fPrimary)[index] ; | |
171 | fNprimary++ ; | |
172 | if(fNprimary>fNMaxPrimary) { | |
173 | cout << "AliPHOSDigit >> Increase NMaxPrimary "<< endl ; | |
174 | return *this ; | |
175 | } | |
176 | } | |
f741ce93 | 177 | } |
550bee17 | 178 | |
d15a28e7 | 179 | return *this ; |
180 | } | |
181 | ||
182 | //____________________________________________________________________________ | |
cf239357 | 183 | ostream& operator << ( ostream& out , const AliPHOSDigit & digit) |
d15a28e7 | 184 | { |
b2a60966 | 185 | // Prints the data of the digit |
186 | ||
36d93c12 | 187 | out << "ID " << digit.fId << " Energy = " << digit.fAmp << endl ; |
188 | Int_t i ; | |
189 | for(i=0;i<digit.fNprimary;i++) | |
190 | out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ; | |
191 | out << "Position in list = " << digit.fIndexInList << endl ; | |
d15a28e7 | 192 | return out ; |
193 | } | |
194 | ||
cf239357 | 195 |