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 //_________________________________________________________________________
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
25 //*-- Author: Sahal Yacoob (LBL)
26 // based on : AliPHOSDigit
27 //__________________________________________________________________________
30 // --- ROOT system ---
32 // --- Standard library ---
36 // --- AliRoot header files ---
38 #include "AliEMCALDigit.h"
41 ClassImp(AliEMCALDigit)
43 //____________________________________________________________________________
44 AliEMCALDigit::AliEMCALDigit()
52 fNMaxiparent = fNMaxPrimary*10;
55 //____________________________________________________________________________
56 AliEMCALDigit::AliEMCALDigit(Int_t primary, Int_t iparent, Int_t id, Int_t DigEnergy, Int_t index)
61 fNMaxiparent = fNMaxPrimary*10;
64 fIndexInList = index ;
67 fPrimary[0] = primary ;
69 fIparent[0] = iparent ;
72 else{ //If the contribution of this primary smaller than fDigitThreshold (AliEMCALv1)
80 for ( i = 1; i < fNMaxPrimary ; i++)
83 for ( Int_t j =1; j< fNMaxiparent ; j++)
87 //____________________________________________________________________________
88 AliEMCALDigit::AliEMCALDigit(const AliEMCALDigit & digit)
93 fNMaxPrimary = digit.fNMaxPrimary ;
94 fNMaxiparent = digit.fNMaxiparent ;
96 for ( i = 0; i < fNMaxPrimary ; i++)
97 fPrimary[i] = digit.fPrimary[i] ;
99 for (j = 0; j< fNMaxiparent ; j++)
100 fIparent[j] = digit.fIparent[j] ;
103 fIndexInList = digit.fIndexInList ;
104 fNprimary = digit.fNprimary ;
105 fNiparent = digit.fNiparent ;
108 //____________________________________________________________________________
109 AliEMCALDigit::~AliEMCALDigit()
111 // Delete array of primiries if any
115 //____________________________________________________________________________
116 Int_t AliEMCALDigit::Compare(const TObject * obj) const
118 // Compares two digits with respect to its Id
119 // to sort according increasing Id
123 AliEMCALDigit * digit = (AliEMCALDigit *)obj ;
125 Int_t iddiff = fId - digit->GetId() ;
129 else if ( iddiff < 0 )
138 //____________________________________________________________________________
139 Int_t AliEMCALDigit::GetPrimary(Int_t index) const
141 // retrieves the primary particle number given its index in the list
143 if ( index <= fNprimary ){
144 rv = fPrimary[index-1] ;
151 //____________________________________________________________________________
152 Int_t AliEMCALDigit::GetIparent(Int_t index) const
154 // retrieves the primary particle number given its index in the list
156 if ( index <= fNiparent ){
157 rv = fIparent[index-1] ;
165 //____________________________________________________________________________
166 void AliEMCALDigit::ShiftPrimary(Int_t shift){
167 //shifts primary nimber to BIG offset, to separate primary in different TreeK
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 ;}
174 //____________________________________________________________________________
175 Bool_t AliEMCALDigit::operator==(AliEMCALDigit const & digit) const
177 // Two digits are equal if they have the same Id
179 if ( fId == digit.fId )
185 //____________________________________________________________________________
186 AliEMCALDigit& AliEMCALDigit::operator+(AliEMCALDigit const & digit)
188 // Adds the amplitude of digits and completes the list of primary particles
189 // if amplitude is larger than
193 Int_t max1 = fNprimary ;
194 Int_t max2 = fNiparent ;
196 for (index = 0 ; index < digit.fNprimary ; index++){
197 Bool_t deja = kTRUE ;
199 for ( old = 0 ; (old < max1) && deja; old++) { //already have this primary?
200 if(fPrimary[old] == (digit.fPrimary)[index])
204 fPrimary[fNprimary] = (digit.fPrimary)[index] ;
206 if(fNprimary>fNMaxPrimary) {
207 cout << "AliEMCALDigit >> Increase NMaxPrimary "<< endl ;
213 for (index = 0 ; index < digit.fNiparent ; index++){
214 Bool_t dejavu = kTRUE ;
216 for ( old = 0 ; (old < max2) && dejavu; old++) { //already have this primary?
217 if(fIparent[old] == (digit.fIparent)[index])
221 fIparent[fNiparent] = (digit.fIparent)[index] ;
223 if(fNiparent>fNMaxiparent) {
224 cout << "AliEMCALDigit >> Increase NMaxiparent "<< endl ;
233 //____________________________________________________________________________
234 ostream& operator << ( ostream& out , const AliEMCALDigit & digit)
236 // Prints the data of the digit
238 out << "ID " << digit.fId << " Energy = " << digit.fAmp << endl ;
240 for(i=0;i<digit.fNprimary;i++)
241 out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ;
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 ;