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 //_________________________________________________________________________
21 // 3 identifiers for the primary particle(s) at the origine of the digit
22 // The digits are made in FinishEvent() by summing all the hits in a single PHOS crystal or PPSD gas cell
24 //*-- Author: Laurent Aphecetche & Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
27 // --- ROOT system ---
31 // --- Standard library ---
33 // --- AliRoot header files ---
35 #include "AliPHOSDigit.h"
40 ClassImp(AliPHOSDigit)
42 //____________________________________________________________________________
43 AliPHOSDigit::AliPHOSDigit()
54 //____________________________________________________________________________
55 AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t digEnergy, Float_t time, Int_t index)
63 fIndexInList = index ;
66 fPrimary = new Int_t[fNprimary] ;
67 fPrimary[0] = primary ;
69 else{ //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1)
75 //____________________________________________________________________________
76 AliPHOSDigit::AliPHOSDigit(const AliPHOSDigit & digit) : AliDigitNew(digit)
80 fNprimary = digit.fNprimary ;
82 fPrimary = new Int_t[fNprimary] ;
83 for (Int_t i = 0; i < fNprimary ; i++)
84 fPrimary[i] = digit.fPrimary[i] ;
90 fTimeR = digit.fTimeR ;
92 fIndexInList = digit.fIndexInList ;
95 //____________________________________________________________________________
96 AliPHOSDigit::~AliPHOSDigit()
98 // Delete array of primiries if any
103 //____________________________________________________________________________
104 Int_t AliPHOSDigit::Compare(const TObject * obj) const
106 // Compares two digits with respect to its Id
107 // to sort according increasing Id
111 AliPHOSDigit * digit = (AliPHOSDigit *)obj ;
113 Int_t iddiff = fId - digit->GetId() ;
117 else if ( iddiff < 0 )
126 //____________________________________________________________________________
127 Int_t AliPHOSDigit::GetPrimary(Int_t index) const
129 // retrieves the primary particle number given its index in the list
131 if ( index <= fNprimary && index > 0){
132 rv = fPrimary[index-1] ;
138 //____________________________________________________________________________
139 void AliPHOSDigit::Print() const
141 // Print the digit together with list of primaries
142 printf("PHOS digit: Amp=%d, Id=%d, Time=%e, TimeR=%e, NPrim=%d ",fAmp,fId,fTime,fTimeR,fNprimary);
143 for(Int_t index = 0; index <fNprimary; index ++ )
144 printf(" %d ",fPrimary[index]);
147 //____________________________________________________________________________
148 void AliPHOSDigit::ShiftPrimary(Int_t shift)
150 //shifts primary number to BIG offset, to separate primary in different TreeK
151 for(Int_t index = 0; index <fNprimary; index ++ ){
152 fPrimary[index]+= shift ;
155 //____________________________________________________________________________
156 Bool_t AliPHOSDigit::operator==(AliPHOSDigit const & digit) const
158 // Two digits are equal if they have the same Id
160 if ( fId == digit.fId )
166 //____________________________________________________________________________
167 AliPHOSDigit& AliPHOSDigit::operator+(AliPHOSDigit const & digit)
170 // Adds the amplitude of digits and completes the list of primary particles
171 if(digit.fNprimary>0){
172 Int_t *tmp = new Int_t[fNprimary+digit.fNprimary] ;
173 if(fAmp < digit.fAmp){//most energetic primary in second digit => first primaries in list from second digit
174 for (Int_t index = 0 ; index < digit.fNprimary ; index++)
175 tmp[index]=(digit.fPrimary)[index] ;
176 for (Int_t index = 0 ; index < fNprimary ; index++)
177 tmp[index+digit.fNprimary]=fPrimary[index] ;
179 else{ //add new primaries to the end
180 for (Int_t index = 0 ; index < fNprimary ; index++)
181 tmp[index]=fPrimary[index] ;
182 for (Int_t index = 0 ; index < digit.fNprimary ; index++)
183 tmp[index+fNprimary]=(digit.fPrimary)[index] ;
189 fNprimary+=digit.fNprimary ;
191 if(fTime > digit.fTime)
192 fTime = digit.fTime ;
196 //____________________________________________________________________________
197 AliPHOSDigit& AliPHOSDigit::operator*(Float_t factor)
199 // Multiplies the amplitude by a factor
201 Float_t tempo = static_cast<Float_t>(fAmp) ;
203 fAmp = static_cast<Int_t>(TMath::Ceil(tempo)) ;
207 //____________________________________________________________________________
208 ostream& operator << ( ostream& out , const AliPHOSDigit & digit)
210 // Prints the data of the digit
212 // out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ;
214 // for(i=0;i<digit.fNprimary;i++)
215 // out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ;
216 // out << "Position in list = " << digit.fIndexInList << endl ;
217 digit.Warning("operator <<", "Implement differently") ;