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() :
72 //____________________________________________________________________________
73 AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t digEnergy, Float_t time, Int_t index) :
91 fIndexInList = index ;
94 fPrimary = new Int_t[fNprimary] ;
95 fPrimary[0] = primary ;
97 else{ //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1)
103 //____________________________________________________________________________
104 AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Float_t energy, Float_t time, Int_t index) :
115 // ctor with all data
122 fIndexInList = index ;
125 fPrimary = new Int_t[fNprimary] ;
126 fPrimary[0] = primary ;
128 else{ //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1)
134 //____________________________________________________________________________
135 AliPHOSDigit::AliPHOSDigit(const AliPHOSDigit & digit) :
137 fNprimary(digit.fNprimary),
139 fEnergy(digit.fEnergy),
141 fTimeR(digit.fTimeR),
149 fPrimary = new Int_t[fNprimary] ;
150 for (Int_t i = 0; i < fNprimary ; i++)
151 fPrimary[i] = digit.fPrimary[i] ;
157 fIndexInList = digit.fIndexInList ;
160 //____________________________________________________________________________
161 AliPHOSDigit & AliPHOSDigit::operator = (const AliPHOSDigit &)
163 Fatal("operator =", "not implemented");
166 //____________________________________________________________________________
167 AliPHOSDigit::~AliPHOSDigit()
169 // Delete array of primaries if any
170 if (fPrimary) delete [] fPrimary ;
171 // Delete arrays of ALTRO samples if any
172 if (fSamplesHG) delete [] fSamplesHG;
173 if (fSamplesLG) delete [] fSamplesLG;
176 //____________________________________________________________________________
177 Int_t AliPHOSDigit::Compare(const TObject * obj) const
179 // Compares two digits with respect to its Id
180 // to sort according increasing Id
184 AliPHOSDigit * digit = (AliPHOSDigit *)obj ;
186 Int_t iddiff = fId - digit->GetId() ;
190 else if ( iddiff < 0 )
199 //____________________________________________________________________________
200 Int_t AliPHOSDigit::GetPrimary(Int_t index) const
202 // retrieves the primary particle number given its index in the list
204 if ( index <= fNprimary && index > 0){
205 rv = fPrimary[index-1] ;
212 //____________________________________________________________________________
213 void AliPHOSDigit::SetALTROSamplesHG(Int_t nSamplesHG, Int_t *samplesHG)
215 fNSamplesHG = nSamplesHG;
216 if (fSamplesHG) delete [] fSamplesHG;
217 fSamplesHG = new UShort_t[fNSamplesHG];
219 for (i=0; i<fNSamplesHG; i++) {
220 fSamplesHG[i] = samplesHG[i];
223 //____________________________________________________________________________
224 void AliPHOSDigit::SetALTROSamplesLG(Int_t nSamplesLG, Int_t *samplesLG)
226 fNSamplesLG = nSamplesLG;
227 if (fSamplesLG) delete [] fSamplesLG;
228 fSamplesLG = new UShort_t[fNSamplesLG];
230 for (i=0; i<fNSamplesLG; i++) {
231 fSamplesLG[i] = samplesLG[i];
234 //____________________________________________________________________________
235 void AliPHOSDigit::Print(const Option_t *) const
237 // Print the digit together with list of primaries
238 TString line = Form("PHOS digit: E=%.3f, Id=%d, Time=%.3e, TimeR=%.3e, NPrim=%d, nHG=%d, nLG=%d \n",
239 fEnergy,fId,fTime,fTimeR,fNprimary,fNSamplesHG,fNSamplesLG);
240 line += "\tList of primaries: ";
241 for (Int_t index = 0; index <fNprimary; index ++ )
242 line += Form(" %d ",fPrimary[index]);
244 line += "\tSamples HG: ";
245 for (Int_t i = 0; i <fNSamplesHG; i++)
246 line += Form(" %d ",fSamplesHG[i]);
248 line += "\tSamples LG: ";
249 for (Int_t i = 0; i <fNSamplesLG; i++)
250 line += Form(" %d ",fSamplesLG[i]);
254 //____________________________________________________________________________
255 void AliPHOSDigit::ShiftPrimary(Int_t shift)
257 //shifts primary number to BIG offset, to separate primary in different TreeK
258 for(Int_t index = 0; index <fNprimary; index ++ ){
259 fPrimary[index]+= shift ;
262 //____________________________________________________________________________
263 Bool_t AliPHOSDigit::operator==(AliPHOSDigit const & digit) const
265 // Two digits are equal if they have the same Id
267 if ( fId == digit.fId )
273 //____________________________________________________________________________
274 AliPHOSDigit& AliPHOSDigit::operator+=(AliPHOSDigit const & digit)
277 // Adds the amplitude of digits and completes the list of primary particles
278 if(digit.fNprimary>0){
279 Int_t *tmp = new Int_t[fNprimary+digit.fNprimary] ;
280 if(fAmp < digit.fAmp || fEnergy < digit.fEnergy){//most energetic primary in second digit => first primaries in list from second digit
281 for (Int_t index = 0 ; index < digit.fNprimary ; index++)
282 tmp[index]=(digit.fPrimary)[index] ;
283 for (Int_t index = 0 ; index < fNprimary ; index++)
284 tmp[index+digit.fNprimary]=fPrimary[index] ;
286 else{ //add new primaries to the end
287 for (Int_t index = 0 ; index < fNprimary ; index++)
288 tmp[index]=fPrimary[index] ;
289 for (Int_t index = 0 ; index < digit.fNprimary ; index++)
290 tmp[index+fNprimary]=(digit.fPrimary)[index] ;
296 fNprimary+=digit.fNprimary ;
298 fEnergy += digit.fEnergy ;
299 if(fTime > digit.fTime)
300 fTime = digit.fTime ;
303 // Add high-gain ALTRO samples
305 if (digit.fNSamplesHG > fNSamplesHG) {
306 UShort_t newNSamplesHG = digit.fNSamplesHG;
307 UShort_t *newSamplesHG = new UShort_t[newNSamplesHG];
308 for (i=0; i<newNSamplesHG; i++) {
310 newSamplesHG[i] = TMath::Max(1023,fSamplesHG[i] + (digit.fSamplesHG)[i]);
312 newSamplesHG[i] = (digit.fSamplesHG)[i];
314 delete [] fSamplesHG;
315 fSamplesHG = new UShort_t[newNSamplesHG];
316 for (i=0; i<newNSamplesHG; i++) {
317 fSamplesHG[i] = newSamplesHG[i];
319 delete [] newSamplesHG;
322 for (i=0; i<fNSamplesHG; i++)
323 fSamplesHG[i] = TMath::Max(1023,fSamplesHG[i] + (digit.fSamplesHG)[i]);
326 // Add low-gain ALTRO samples
327 if (digit.fNSamplesLG > fNSamplesLG) {
328 UShort_t newNSamplesLG = digit.fNSamplesLG;
329 UShort_t *newSamplesLG = new UShort_t[newNSamplesLG];
330 for (i=0; i<newNSamplesLG; i++) {
332 newSamplesLG[i] = TMath::Max(1023,fSamplesLG[i] + (digit.fSamplesLG)[i]);
334 newSamplesLG[i] = (digit.fSamplesLG)[i];
336 delete [] fSamplesLG;
337 fSamplesLG = new UShort_t[newNSamplesLG];
338 for (i=0; i<newNSamplesLG; i++) {
339 fSamplesLG[i] = newSamplesLG[i];
341 delete [] newSamplesLG;
344 for (i=0; i<fNSamplesLG; i++)
345 fSamplesLG[i] = TMath::Max(1023,fSamplesLG[i] + (digit.fSamplesLG)[i]);
350 //____________________________________________________________________________
351 AliPHOSDigit& AliPHOSDigit::operator *= (Float_t factor)
353 // Multiplies the amplitude by a factor
355 Float_t tempo = static_cast<Float_t>(fAmp) ;
357 fAmp = static_cast<Int_t>(TMath::Ceil(tempo)) ;
361 //____________________________________________________________________________
362 ostream& operator << ( ostream& out , const AliPHOSDigit & digit)
364 // Prints the data of the digit
366 // out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ;
368 // for(i=0;i<digit.fNprimary;i++)
369 // out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ;
370 // out << "Position in list = " << digit.fIndexInList << endl ;
371 digit.Warning("operator <<", "Implement differently") ;