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.38 2006/04/22 10:30:17 hristov
22 * Add fEnergy to AliPHOSDigit and operate with EMC amplitude in energy units (Yu.Kharlov)
24 * Revision 1.37 2005/05/28 14:19:04 schutz
25 * Compilation warnings fixed by T.P.
29 //_________________________________________________________________________
32 // 3 identifiers for the primary particle(s) at the origine of the digit
33 // The digits are made in FinishEvent() by summing all the hits in a single PHOS crystal or PPSD gas cell
35 //*-- Author: Laurent Aphecetche & Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
38 // --- ROOT system ---
42 // --- Standard library ---
44 // --- AliRoot header files ---
46 #include "AliPHOSDigit.h"
51 ClassImp(AliPHOSDigit)
53 //____________________________________________________________________________
54 AliPHOSDigit::AliPHOSDigit() :
66 //____________________________________________________________________________
67 AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t digEnergy, Float_t time, Int_t index)
76 fIndexInList = index ;
79 fPrimary = new Int_t[fNprimary] ;
80 fPrimary[0] = primary ;
82 else{ //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1)
88 //____________________________________________________________________________
89 AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Float_t energy, Float_t time, Int_t index)
98 fIndexInList = index ;
101 fPrimary = new Int_t[fNprimary] ;
102 fPrimary[0] = primary ;
104 else{ //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1)
110 //____________________________________________________________________________
111 AliPHOSDigit::AliPHOSDigit(const AliPHOSDigit & digit) : AliDigitNew(digit)
115 fNprimary = digit.fNprimary ;
117 fPrimary = new Int_t[fNprimary] ;
118 for (Int_t i = 0; i < fNprimary ; i++)
119 fPrimary[i] = digit.fPrimary[i] ;
124 fEnergy = digit.fEnergy ;
125 fTime = digit.fTime ;
126 fTimeR = digit.fTimeR ;
128 fIndexInList = digit.fIndexInList ;
131 //____________________________________________________________________________
132 AliPHOSDigit::~AliPHOSDigit()
134 // Delete array of primiries if any
139 //____________________________________________________________________________
140 Int_t AliPHOSDigit::Compare(const TObject * obj) const
142 // Compares two digits with respect to its Id
143 // to sort according increasing Id
147 AliPHOSDigit * digit = (AliPHOSDigit *)obj ;
149 Int_t iddiff = fId - digit->GetId() ;
153 else if ( iddiff < 0 )
162 //____________________________________________________________________________
163 Int_t AliPHOSDigit::GetPrimary(Int_t index) const
165 // retrieves the primary particle number given its index in the list
167 if ( index <= fNprimary && index > 0){
168 rv = fPrimary[index-1] ;
174 //____________________________________________________________________________
175 void AliPHOSDigit::Print(const Option_t *) const
177 // Print the digit together with list of primaries
178 printf("PHOS digit: Amp=%d/E=%.3f, Id=%d, Time=%.3e, TimeR=%.3e, NPrim=%d ",fAmp,fEnergy,fId,fTime,fTimeR,fNprimary);
179 for(Int_t index = 0; index <fNprimary; index ++ )
180 printf(" %d ",fPrimary[index]);
183 //____________________________________________________________________________
184 void AliPHOSDigit::ShiftPrimary(Int_t shift)
186 //shifts primary number to BIG offset, to separate primary in different TreeK
187 for(Int_t index = 0; index <fNprimary; index ++ ){
188 fPrimary[index]+= shift ;
191 //____________________________________________________________________________
192 Bool_t AliPHOSDigit::operator==(AliPHOSDigit const & digit) const
194 // Two digits are equal if they have the same Id
196 if ( fId == digit.fId )
202 //____________________________________________________________________________
203 AliPHOSDigit& AliPHOSDigit::operator+(AliPHOSDigit const & digit)
206 // Adds the amplitude of digits and completes the list of primary particles
207 if(digit.fNprimary>0){
208 Int_t *tmp = new Int_t[fNprimary+digit.fNprimary] ;
209 if(fAmp < digit.fAmp || fEnergy < digit.fEnergy){//most energetic primary in second digit => first primaries in list from second digit
210 for (Int_t index = 0 ; index < digit.fNprimary ; index++)
211 tmp[index]=(digit.fPrimary)[index] ;
212 for (Int_t index = 0 ; index < fNprimary ; index++)
213 tmp[index+digit.fNprimary]=fPrimary[index] ;
215 else{ //add new primaries to the end
216 for (Int_t index = 0 ; index < fNprimary ; index++)
217 tmp[index]=fPrimary[index] ;
218 for (Int_t index = 0 ; index < digit.fNprimary ; index++)
219 tmp[index+fNprimary]=(digit.fPrimary)[index] ;
225 fNprimary+=digit.fNprimary ;
227 fEnergy += digit.fEnergy ;
228 if(fTime > digit.fTime)
229 fTime = digit.fTime ;
233 //____________________________________________________________________________
234 AliPHOSDigit& AliPHOSDigit::operator*(Float_t factor)
236 // Multiplies the amplitude by a factor
238 Float_t tempo = static_cast<Float_t>(fAmp) ;
240 fAmp = static_cast<Int_t>(TMath::Ceil(tempo)) ;
244 //____________________________________________________________________________
245 ostream& operator << ( ostream& out , const AliPHOSDigit & digit)
247 // Prints the data of the digit
249 // out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ;
251 // for(i=0;i<digit.fNprimary;i++)
252 // out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ;
253 // out << "Position in list = " << digit.fIndexInList << endl ;
254 digit.Warning("operator <<", "Implement differently") ;