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:
23 //_________________________________________________________________________
26 // 3 identifiers for the primary particle(s) at the origine of the digit
27 // The digits are made in FinishEvent() by summing all the hits in a single PHOS crystal or PPSD gas cell
29 //*-- Author: Laurent Aphecetche & Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
32 // --- ROOT system ---
36 // --- Standard library ---
38 // --- AliRoot header files ---
40 #include "AliPHOSDigit.h"
45 ClassImp(AliPHOSDigit)
47 //____________________________________________________________________________
48 AliPHOSDigit::AliPHOSDigit()
59 //____________________________________________________________________________
60 AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t digEnergy, Float_t time, Int_t index)
68 fIndexInList = index ;
71 fPrimary = new Int_t[fNprimary] ;
72 fPrimary[0] = primary ;
74 else{ //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1)
80 //____________________________________________________________________________
81 AliPHOSDigit::AliPHOSDigit(const AliPHOSDigit & digit) : AliDigitNew(digit)
85 fNprimary = digit.fNprimary ;
87 fPrimary = new Int_t[fNprimary] ;
88 for (Int_t i = 0; i < fNprimary ; i++)
89 fPrimary[i] = digit.fPrimary[i] ;
95 fTimeR = digit.fTimeR ;
97 fIndexInList = digit.fIndexInList ;
100 //____________________________________________________________________________
101 AliPHOSDigit::~AliPHOSDigit()
103 // Delete array of primiries if any
108 //____________________________________________________________________________
109 Int_t AliPHOSDigit::Compare(const TObject * obj) const
111 // Compares two digits with respect to its Id
112 // to sort according increasing Id
116 AliPHOSDigit * digit = (AliPHOSDigit *)obj ;
118 Int_t iddiff = fId - digit->GetId() ;
122 else if ( iddiff < 0 )
131 //____________________________________________________________________________
132 Int_t AliPHOSDigit::GetPrimary(Int_t index) const
134 // retrieves the primary particle number given its index in the list
136 if ( index <= fNprimary && index > 0){
137 rv = fPrimary[index-1] ;
143 //____________________________________________________________________________
144 void AliPHOSDigit::Print(const Option_t *) const
146 // Print the digit together with list of primaries
147 printf("PHOS digit: Amp=%d, Id=%d, Time=%e, TimeR=%e, NPrim=%d ",fAmp,fId,fTime,fTimeR,fNprimary);
148 for(Int_t index = 0; index <fNprimary; index ++ )
149 printf(" %d ",fPrimary[index]);
152 //____________________________________________________________________________
153 void AliPHOSDigit::ShiftPrimary(Int_t shift)
155 //shifts primary number to BIG offset, to separate primary in different TreeK
156 for(Int_t index = 0; index <fNprimary; index ++ ){
157 fPrimary[index]+= shift ;
160 //____________________________________________________________________________
161 Bool_t AliPHOSDigit::operator==(AliPHOSDigit const & digit) const
163 // Two digits are equal if they have the same Id
165 if ( fId == digit.fId )
171 //____________________________________________________________________________
172 AliPHOSDigit& AliPHOSDigit::operator+(AliPHOSDigit const & digit)
175 // Adds the amplitude of digits and completes the list of primary particles
176 if(digit.fNprimary>0){
177 Int_t *tmp = new Int_t[fNprimary+digit.fNprimary] ;
178 if(fAmp < digit.fAmp){//most energetic primary in second digit => first primaries in list from second digit
179 for (Int_t index = 0 ; index < digit.fNprimary ; index++)
180 tmp[index]=(digit.fPrimary)[index] ;
181 for (Int_t index = 0 ; index < fNprimary ; index++)
182 tmp[index+digit.fNprimary]=fPrimary[index] ;
184 else{ //add new primaries to the end
185 for (Int_t index = 0 ; index < fNprimary ; index++)
186 tmp[index]=fPrimary[index] ;
187 for (Int_t index = 0 ; index < digit.fNprimary ; index++)
188 tmp[index+fNprimary]=(digit.fPrimary)[index] ;
194 fNprimary+=digit.fNprimary ;
196 if(fTime > digit.fTime)
197 fTime = digit.fTime ;
201 //____________________________________________________________________________
202 AliPHOSDigit& AliPHOSDigit::operator*(Float_t factor)
204 // Multiplies the amplitude by a factor
206 Float_t tempo = static_cast<Float_t>(fAmp) ;
208 fAmp = static_cast<Int_t>(TMath::Ceil(tempo)) ;
212 //____________________________________________________________________________
213 ostream& operator << ( ostream& out , const AliPHOSDigit & digit)
215 // Prints the data of the digit
217 // out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ;
219 // for(i=0;i<digit.fNprimary;i++)
220 // out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ;
221 // out << "Position in list = " << digit.fIndexInList << endl ;
222 digit.Warning("operator <<", "Implement differently") ;