1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //_________________________________________________________________________
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 EMCAL 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!)
26 //*-- Author: Laurent Aphecetche & Yves Schutz (SUBATECH)
29 // --- ROOT system ---
31 // --- Standard library ---
35 // --- AliRoot header files ---
37 #include "AliEMCALDigit.h"
40 ClassImp(AliEMCALDigit)
42 //____________________________________________________________________________
43 AliEMCALDigit::AliEMCALDigit()
51 fNMaxiparent = fNMaxPrimary*10;
54 //____________________________________________________________________________
55 AliEMCALDigit::AliEMCALDigit(Int_t primary, Int_t iparent, Int_t id, Int_t DigEnergy, Int_t index)
60 fNMaxiparent = fNMaxPrimary*10;
63 fIndexInList = index ;
66 fPrimary[0] = primary ;
68 fIparent[0] = iparent ;
71 else{ //If the contribution of this primary smaller than fDigitThreshold (AliEMCALv1)
79 for ( i = 1; i < fNMaxPrimary ; i++)
82 for ( Int_t j =1; j< fNMaxiparent ; j++)
86 //____________________________________________________________________________
87 AliEMCALDigit::AliEMCALDigit(const AliEMCALDigit & digit)
92 fNMaxPrimary = digit.fNMaxPrimary ;
93 fNMaxiparent = digit.fNMaxiparent ;
95 for ( i = 0; i < fNMaxPrimary ; i++)
96 fPrimary[i] = digit.fPrimary[i] ;
98 for (j = 0; j< fNMaxiparent ; j++)
99 fIparent[j] = digit.fIparent[j] ;
102 fIndexInList = digit.fIndexInList ;
103 fNprimary = digit.fNprimary ;
104 fNiparent = digit.fNiparent ;
107 //____________________________________________________________________________
108 AliEMCALDigit::~AliEMCALDigit()
110 // Delete array of primiries if any
114 //____________________________________________________________________________
115 Int_t AliEMCALDigit::Compare(const TObject * obj) const
117 // Compares two digits with respect to its Id
118 // to sort according increasing Id
122 AliEMCALDigit * digit = (AliEMCALDigit *)obj ;
124 Int_t iddiff = fId - digit->GetId() ;
128 else if ( iddiff < 0 )
137 //____________________________________________________________________________
138 Int_t AliEMCALDigit::GetPrimary(Int_t index) const
140 // retrieves the primary particle number given its index in the list
142 if ( index <= fNprimary ){
143 rv = fPrimary[index-1] ;
150 //____________________________________________________________________________
151 Int_t AliEMCALDigit::GetIparent(Int_t index) const
153 // retrieves the primary particle number given its index in the list
155 if ( index <= fNiparent ){
156 rv = fIparent[index-1] ;
164 //____________________________________________________________________________
165 void AliEMCALDigit::ShiftPrimary(Int_t shift){
166 //shifts primary nimber to BIG offset, to separate primary in different TreeK
168 for(index = 0; index <fNprimary; index++ ){
169 fPrimary[index] = fPrimary[index]+ shift * 10000000 ;}
170 for(index =0; index <fNiparent; index++){
171 fIparent[index] = fIparent[index] + shift * 10000000 ;}
173 //____________________________________________________________________________
174 Bool_t AliEMCALDigit::operator==(AliEMCALDigit const & digit) const
176 // Two digits are equal if they have the same Id
178 if ( fId == digit.fId )
184 //____________________________________________________________________________
185 AliEMCALDigit& AliEMCALDigit::operator+(AliEMCALDigit const & digit)
187 // Adds the amplitude of digits and completes the list of primary particles
188 // if amplitude is larger than
192 Int_t max1 = fNprimary ;
193 Int_t max2 = fNiparent ;
195 for (index = 0 ; index < digit.fNprimary ; index++){
196 Bool_t deja = kTRUE ;
198 for ( old = 0 ; (old < max1) && deja; old++) { //already have this primary?
199 if(fPrimary[old] == (digit.fPrimary)[index])
203 fPrimary[fNprimary] = (digit.fPrimary)[index] ;
205 if(fNprimary>fNMaxPrimary) {
206 cout << "AliEMCALDigit >> Increase NMaxPrimary "<< endl ;
212 for (index = 0 ; index < digit.fNiparent ; index++){
213 Bool_t dejavu = kTRUE ;
215 for ( old = 0 ; (old < max2) && dejavu; old++) { //already have this primary?
216 if(fIparent[old] == (digit.fIparent)[index])
220 fIparent[fNiparent] = (digit.fIparent)[index] ;
222 if(fNiparent>fNMaxiparent) {
223 cout << "AliEMCALDigit >> Increase NMaxiparent "<< endl ;
232 //____________________________________________________________________________
233 ostream& operator << ( ostream& out , const AliEMCALDigit & digit)
235 // Prints the data of the digit
237 out << "ID " << digit.fId << " Energy = " << digit.fAmp << endl ;
239 for(i=0;i<digit.fNprimary;i++)
240 out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ;
242 for(j=0;j<digit.fNiparent;j++)
243 out << "Iparent " << j+1 << " = " << digit.fIparent[j] << endl ;
244 out << "Position in list = " << digit.fIndexInList << endl ;