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()
52 //____________________________________________________________________________
53 AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t digEnergy, Float_t time, Int_t index)
60 fIndexInList = index ;
63 fPrimary = new Int_t[fNprimary] ;
64 fPrimary[0] = primary ;
66 else{ //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1)
72 //____________________________________________________________________________
73 AliPHOSDigit::AliPHOSDigit(const AliPHOSDigit & digit) : AliDigitNew(digit)
77 fNprimary = digit.fNprimary ;
79 fPrimary = new Int_t[fNprimary] ;
80 for (Int_t i = 0; i < fNprimary ; i++)
81 fPrimary[i] = digit.fPrimary[i] ;
88 fIndexInList = digit.fIndexInList ;
91 //____________________________________________________________________________
92 AliPHOSDigit::~AliPHOSDigit()
94 // Delete array of primiries if any
99 //____________________________________________________________________________
100 Int_t AliPHOSDigit::Compare(const TObject * obj) const
102 // Compares two digits with respect to its Id
103 // to sort according increasing Id
107 AliPHOSDigit * digit = (AliPHOSDigit *)obj ;
109 Int_t iddiff = fId - digit->GetId() ;
113 else if ( iddiff < 0 )
122 //____________________________________________________________________________
123 Int_t AliPHOSDigit::GetPrimary(Int_t index) const
125 // retrieves the primary particle number given its index in the list
127 if ( index <= fNprimary && index > 0){
128 rv = fPrimary[index-1] ;
134 //____________________________________________________________________________
135 void AliPHOSDigit::Print() const
137 // Print the digit together with list of primaries
138 printf("PHOS digit: Amp=%d, Id=%d, Time=%f, NPrim=%d ",fAmp,fId,fTime,fNprimary);
139 for(Int_t index = 0; index <fNprimary; index ++ )
140 printf(" %d ",fPrimary[index]);
143 //____________________________________________________________________________
144 void AliPHOSDigit::ShiftPrimary(Int_t shift)
146 //shifts primary number to BIG offset, to separate primary in different TreeK
147 for(Int_t index = 0; index <fNprimary; index ++ ){
148 fPrimary[index]+= shift ;
151 //____________________________________________________________________________
152 Bool_t AliPHOSDigit::operator==(AliPHOSDigit const & digit) const
154 // Two digits are equal if they have the same Id
156 if ( fId == digit.fId )
162 //____________________________________________________________________________
163 AliPHOSDigit& AliPHOSDigit::operator+(AliPHOSDigit const & digit)
166 // Adds the amplitude of digits and completes the list of primary particles
167 if(digit.fNprimary>0){
168 Int_t *tmp = new Int_t[fNprimary+digit.fNprimary] ;
169 if(fAmp < digit.fAmp){//most energetic primary in second digit => first primaries in list from second digit
170 for (Int_t index = 0 ; index < digit.fNprimary ; index++)
171 tmp[index]=(digit.fPrimary)[index] ;
172 for (Int_t index = 0 ; index < fNprimary ; index++)
173 tmp[index+digit.fNprimary]=fPrimary[index] ;
175 else{ //add new primaries to the end
176 for (Int_t index = 0 ; index < fNprimary ; index++)
177 tmp[index]=fPrimary[index] ;
178 for (Int_t index = 0 ; index < digit.fNprimary ; index++)
179 tmp[index+fNprimary]=(digit.fPrimary)[index] ;
185 fNprimary+=digit.fNprimary ;
187 if(fTime > digit.fTime)
188 fTime = digit.fTime ;
191 //____________________________________________________________________________
192 AliPHOSDigit& AliPHOSDigit::operator*(Float_t factor)
194 // Multiplies the amplitude by a factor
196 Float_t tempo = static_cast<Float_t>(fAmp) ;
198 fAmp = static_cast<Int_t>(TMath::Ceil(tempo)) ;
202 //____________________________________________________________________________
203 ostream& operator << ( ostream& out , const AliPHOSDigit & digit)
205 // Prints the data of the digit
207 // out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ;
209 // for(i=0;i<digit.fNprimary;i++)
210 // out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ;
211 // out << "Position in list = " << digit.fIndexInList << endl ;
212 digit.Warning("operator <<", "Implement differently") ;