]>
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 | } |
132 | ||
cf239357 | 133 | //____________________________________________________________________________ |
134 | Bool_t AliPHOSDigit::operator==(AliPHOSDigit const & digit) const | |
135 | { | |
b2a60966 | 136 | // Two digits are equal if they have the same Id |
137 | ||
cf239357 | 138 | if ( fId == digit.fId ) |
d15a28e7 | 139 | return kTRUE ; |
140 | else | |
141 | return kFALSE ; | |
142 | } | |
cf239357 | 143 | |
d15a28e7 | 144 | //____________________________________________________________________________ |
cf239357 | 145 | AliPHOSDigit& AliPHOSDigit::operator+(AliPHOSDigit const & digit) |
d15a28e7 | 146 | { |
b2a60966 | 147 | // Adds the amplitude of digits and completes the list of primary particles |
4a2ca5e9 | 148 | // if amplitude is larger than |
36d93c12 | 149 | |
cf239357 | 150 | fAmp += digit.fAmp ; |
36d93c12 | 151 | |
f741ce93 | 152 | Int_t max1 = fNprimary ; |
153 | Int_t max2 = digit.fNprimary ; | |
36d93c12 | 154 | |
155 | if ( fNprimary + digit.fNprimary < fNMaxPrimary ) { | |
f741ce93 | 156 | fNprimary += digit.fNprimary ; |
36d93c12 | 157 | |
f741ce93 | 158 | Int_t index ; |
f741ce93 | 159 | for (index = 0 ; index < max2 ; index++) |
366c5d6f | 160 | fPrimary[index+max1] = (digit.fPrimary)[index] ; |
f741ce93 | 161 | } |
36d93c12 | 162 | else{ |
163 | cout << "AliPHOSDigit >> Increase NMaxPrimary"<< endl ; | |
164 | Int_t index ; | |
165 | for (index = max1; index < fNMaxPrimary ; index++) | |
166 | fPrimary[index] = (digit.fPrimary)[index-max1] ; | |
167 | fNprimary = fNMaxPrimary ; | |
168 | } | |
d15a28e7 | 169 | return *this ; |
170 | } | |
171 | ||
172 | //____________________________________________________________________________ | |
cf239357 | 173 | ostream& operator << ( ostream& out , const AliPHOSDigit & digit) |
d15a28e7 | 174 | { |
b2a60966 | 175 | // Prints the data of the digit |
176 | ||
36d93c12 | 177 | out << "ID " << digit.fId << " Energy = " << digit.fAmp << endl ; |
178 | Int_t i ; | |
179 | for(i=0;i<digit.fNprimary;i++) | |
180 | out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ; | |
181 | out << "Position in list = " << digit.fIndexInList << endl ; | |
d15a28e7 | 182 | return out ; |
183 | } | |
184 | ||
cf239357 | 185 |