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()
53 //____________________________________________________________________________
54 AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t digEnergy, Float_t time, Int_t index)
62 fIndexInList = index ;
63 fPrimary = new Int_t[fNMaxPrimary] ;
66 fPrimary[0] = primary ;
68 else{ //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1)
73 for ( i = 1; i < fNMaxPrimary ; i++)
77 //____________________________________________________________________________
78 AliPHOSDigit::AliPHOSDigit(const AliPHOSDigit & digit)
83 fNMaxPrimary = digit.fNMaxPrimary ;
84 fPrimary = new Int_t[fNMaxPrimary] ;
86 for ( i = 0; i < fNMaxPrimary ; i++)
87 fPrimary[i] = digit.fPrimary[i] ;
91 fIndexInList = digit.fIndexInList ;
92 fNprimary = digit.fNprimary ;
95 //____________________________________________________________________________
96 AliPHOSDigit::~AliPHOSDigit()
98 // Delete array of primiries if any
102 //____________________________________________________________________________
103 Int_t AliPHOSDigit::Compare(const TObject * obj) const
105 // Compares two digits with respect to its Id
106 // to sort according increasing Id
110 AliPHOSDigit * digit = (AliPHOSDigit *)obj ;
112 Int_t iddiff = fId - digit->GetId() ;
116 else if ( iddiff < 0 )
125 //____________________________________________________________________________
126 Int_t AliPHOSDigit::GetPrimary(Int_t index) const
128 // retrieves the primary particle number given its index in the list
130 if ( index <= fNprimary && index > 0){
131 rv = fPrimary[index-1] ;
137 //____________________________________________________________________________
138 void AliPHOSDigit::Print(Option_t *option) const
140 printf("PHOS digit: Amp=%d, Id=%d\n",fAmp,fId);
142 //____________________________________________________________________________
143 void AliPHOSDigit::ShiftPrimary(Int_t shift)
145 //shifts primary number to BIG offset, to separate primary in different TreeK
147 for(index = 0; index <fNprimary; index ++ ){
148 fPrimary[index] = 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)
165 // Adds the amplitude of digits and completes the list of primary particles
166 // if amplitude is larger than
169 if(fTime > digit.fTime)
170 fTime = digit.fTime ;
172 Int_t max1 = fNprimary ;
175 for (index = 0 ; index < digit.fNprimary ; index++){
176 Bool_t deja = kTRUE ;
178 for ( old = 0 ; (old < max1) && deja; old++) { //already have this primary?
179 if(fPrimary[old] == (digit.fPrimary)[index])
183 fPrimary[fNprimary] = (digit.fPrimary)[index] ;
185 if(fNprimary>fNMaxPrimary) {
186 Error("Operator +", "Increase NMaxPrimary") ;
195 //____________________________________________________________________________
196 AliPHOSDigit& AliPHOSDigit::operator*(Float_t factor)
198 // Multiplies the amplitude by a factor
200 Float_t tempo = static_cast<Float_t>(fAmp) ;
202 fAmp = static_cast<Int_t>(TMath::Ceil(tempo)) ;
206 //____________________________________________________________________________
207 ostream& operator << ( ostream& out , const AliPHOSDigit & digit)
209 // Prints the data of the digit
211 // out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ;
213 // for(i=0;i<digit.fNprimary;i++)
214 // out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ;
215 // out << "Position in list = " << digit.fIndexInList << endl ;
216 digit.Warning("operator <<", "Implement differently") ;