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 /* History of cvs commits:
21 * Revision 1.39 2006/04/22 15:04:24 hristov
22 * Effective C++ initialization of data members in the default constructor
24 * Revision 1.38 2006/04/22 10:30:17 hristov
25 * Add fEnergy to AliPHOSDigit and operate with EMC amplitude in energy units (Yu.Kharlov)
27 * Revision 1.37 2005/05/28 14:19:04 schutz
28 * Compilation warnings fixed by T.P.
32 //_________________________________________________________________________
35 // 3 identifiers for the primary particle(s) at the origine of the digit
36 // The digits are made in FinishEvent() by summing all the hits in a single PHOS crystal or PPSD gas cell
38 //*-- Author: Laurent Aphecetche & Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
41 // --- ROOT system ---
45 // --- Standard library ---
47 // --- AliRoot header files ---
49 #include "AliPHOSDigit.h"
54 ClassImp(AliPHOSDigit)
56 //____________________________________________________________________________
57 AliPHOSDigit::AliPHOSDigit() :
69 //____________________________________________________________________________
70 AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t digEnergy, Float_t time, Int_t index) :
84 fIndexInList = index ;
87 fPrimary = new Int_t[fNprimary] ;
88 fPrimary[0] = primary ;
90 else{ //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1)
96 //____________________________________________________________________________
97 AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Float_t energy, Float_t time, Int_t index) :
104 // ctor with all data
111 fIndexInList = index ;
114 fPrimary = new Int_t[fNprimary] ;
115 fPrimary[0] = primary ;
117 else{ //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1)
123 //____________________________________________________________________________
124 AliPHOSDigit::AliPHOSDigit(const AliPHOSDigit & digit) :
126 fNprimary(digit.fNprimary),
128 fEnergy(digit.fEnergy),
135 fPrimary = new Int_t[fNprimary] ;
136 for (Int_t i = 0; i < fNprimary ; i++)
137 fPrimary[i] = digit.fPrimary[i] ;
143 fIndexInList = digit.fIndexInList ;
146 //____________________________________________________________________________
147 AliPHOSDigit::~AliPHOSDigit()
149 // Delete array of primiries if any
154 //____________________________________________________________________________
155 Int_t AliPHOSDigit::Compare(const TObject * obj) const
157 // Compares two digits with respect to its Id
158 // to sort according increasing Id
162 AliPHOSDigit * digit = (AliPHOSDigit *)obj ;
164 Int_t iddiff = fId - digit->GetId() ;
168 else if ( iddiff < 0 )
177 //____________________________________________________________________________
178 Int_t AliPHOSDigit::GetPrimary(Int_t index) const
180 // retrieves the primary particle number given its index in the list
182 if ( index <= fNprimary && index > 0){
183 rv = fPrimary[index-1] ;
189 //____________________________________________________________________________
190 void AliPHOSDigit::Print(const Option_t *) const
192 // Print the digit together with list of primaries
193 printf("PHOS digit: Amp=%d/E=%.3f, Id=%d, Time=%.3e, TimeR=%.3e, NPrim=%d ",fAmp,fEnergy,fId,fTime,fTimeR,fNprimary);
194 for(Int_t index = 0; index <fNprimary; index ++ )
195 printf(" %d ",fPrimary[index]);
198 //____________________________________________________________________________
199 void AliPHOSDigit::ShiftPrimary(Int_t shift)
201 //shifts primary number to BIG offset, to separate primary in different TreeK
202 for(Int_t index = 0; index <fNprimary; index ++ ){
203 fPrimary[index]+= shift ;
206 //____________________________________________________________________________
207 Bool_t AliPHOSDigit::operator==(AliPHOSDigit const & digit) const
209 // Two digits are equal if they have the same Id
211 if ( fId == digit.fId )
217 //____________________________________________________________________________
218 AliPHOSDigit& AliPHOSDigit::operator+=(AliPHOSDigit const & digit)
221 // Adds the amplitude of digits and completes the list of primary particles
222 if(digit.fNprimary>0){
223 Int_t *tmp = new Int_t[fNprimary+digit.fNprimary] ;
224 if(fAmp < digit.fAmp || fEnergy < digit.fEnergy){//most energetic primary in second digit => first primaries in list from second digit
225 for (Int_t index = 0 ; index < digit.fNprimary ; index++)
226 tmp[index]=(digit.fPrimary)[index] ;
227 for (Int_t index = 0 ; index < fNprimary ; index++)
228 tmp[index+digit.fNprimary]=fPrimary[index] ;
230 else{ //add new primaries to the end
231 for (Int_t index = 0 ; index < fNprimary ; index++)
232 tmp[index]=fPrimary[index] ;
233 for (Int_t index = 0 ; index < digit.fNprimary ; index++)
234 tmp[index+fNprimary]=(digit.fPrimary)[index] ;
240 fNprimary+=digit.fNprimary ;
242 fEnergy += digit.fEnergy ;
243 if(fTime > digit.fTime)
244 fTime = digit.fTime ;
248 //____________________________________________________________________________
249 AliPHOSDigit& AliPHOSDigit::operator *= (Float_t factor)
251 // Multiplies the amplitude by a factor
253 Float_t tempo = static_cast<Float_t>(fAmp) ;
255 fAmp = static_cast<Int_t>(TMath::Ceil(tempo)) ;
259 //____________________________________________________________________________
260 ostream& operator << ( ostream& out , const AliPHOSDigit & digit)
262 // Prints the data of the digit
264 // out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ;
266 // for(i=0;i<digit.fNprimary;i++)
267 // out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ;
268 // out << "Position in list = " << digit.fIndexInList << endl ;
269 digit.Warning("operator <<", "Implement differently") ;