]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSDigit.cxx
New class wrapping the access of files in the AliEn catalogue
[u/mrichter/AliRoot.git] / PHOS / AliPHOSDigit.cxx
CommitLineData
d15a28e7 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
b2a60966 16/* $Id$ */
17
d15a28e7 18//_________________________________________________________________________
b2a60966 19// PHOS digit: Id
20// energy
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
b2a60966 23//
9688c1dd 24//*-- Author: Laurent Aphecetche & Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
b2a60966 25
d15a28e7 26
27// --- ROOT system ---
28
88cb7938 29#include "TMath.h"
30
d15a28e7 31// --- Standard library ---
32
d15a28e7 33// --- AliRoot header files ---
34
35#include "AliPHOSDigit.h"
36
37
88cb7938 38
39
d15a28e7 40ClassImp(AliPHOSDigit)
41
cf239357 42//____________________________________________________________________________
f741ce93 43 AliPHOSDigit::AliPHOSDigit()
cf239357 44{
b2a60966 45 // default ctor
46
83974468 47 fIndexInList = -1 ;
48 fNprimary = 0 ;
88cb7938 49 fPrimary = 0;
cf239357 50}
51
d15a28e7 52//____________________________________________________________________________
9688c1dd 53AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t digEnergy, Float_t time, Int_t index)
d15a28e7 54{
b2a60966 55 // ctor with all data
56
7b7c1533 57 fAmp = digEnergy ;
9688c1dd 58 fTime = time ;
83974468 59 fId = id ;
60 fIndexInList = index ;
4a2ca5e9 61 if( primary != -1){
62 fNprimary = 1 ;
adc232ca 63 fPrimary = new Int_t[fNprimary] ;
366c5d6f 64 fPrimary[0] = primary ;
4a2ca5e9 65 }
66 else{ //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1)
adc232ca 67 fNprimary = 0 ;
68 fPrimary = 0 ;
4a2ca5e9 69 }
cf239357 70}
71
72//____________________________________________________________________________
a8c47ab6 73AliPHOSDigit::AliPHOSDigit(const AliPHOSDigit & digit) : AliDigitNew(digit)
b2a60966 74{
75 // copy ctor
36d93c12 76
adc232ca 77 fNprimary = digit.fNprimary ;
78 if(fNprimary){
79 fPrimary = new Int_t[fNprimary] ;
80 for (Int_t i = 0; i < fNprimary ; i++)
81 fPrimary[i] = digit.fPrimary[i] ;
82 }
83 else
84 fPrimary = 0 ;
83974468 85 fAmp = digit.fAmp ;
9688c1dd 86 fTime = digit.fTime ;
83974468 87 fId = digit.fId;
88 fIndexInList = digit.fIndexInList ;
ff4c968a 89}
90
2e5c3041 91//____________________________________________________________________________
36d93c12 92AliPHOSDigit::~AliPHOSDigit()
2e5c3041 93{
94 // Delete array of primiries if any
adc232ca 95 if(fPrimary)
96 delete [] fPrimary ;
2e5c3041 97}
98
d15a28e7 99//____________________________________________________________________________
037cc66d 100Int_t AliPHOSDigit::Compare(const TObject * obj) const
d15a28e7 101{
b2a60966 102 // Compares two digits with respect to its Id
103 // to sort according increasing Id
104
88714635 105 Int_t rv ;
cf239357 106
107 AliPHOSDigit * digit = (AliPHOSDigit *)obj ;
108
109 Int_t iddiff = fId - digit->GetId() ;
110
111 if ( iddiff > 0 )
112 rv = 1 ;
113 else if ( iddiff < 0 )
114 rv = -1 ;
115 else
116 rv = 0 ;
117
118 return rv ;
119
120}
26d4b141 121
122//____________________________________________________________________________
123Int_t AliPHOSDigit::GetPrimary(Int_t index) const
124{
2f04ed65 125 // retrieves the primary particle number given its index in the list
36d93c12 126 Int_t rv = -1 ;
36641f9d 127 if ( index <= fNprimary && index > 0){
36d93c12 128 rv = fPrimary[index-1] ;
129 }
26d4b141 130
131 return rv ;
366c5d6f 132
26d4b141 133}
990119d6 134//____________________________________________________________________________
e957fea8 135void AliPHOSDigit::Print() const
d8ca0b45 136{
e957fea8 137 // Print the digit together with list of primaries
adc232ca 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]);
141 printf("\n") ;
d8ca0b45 142}
143//____________________________________________________________________________
a4e98857 144void AliPHOSDigit::ShiftPrimary(Int_t shift)
145{
146 //shifts primary number to BIG offset, to separate primary in different TreeK
adc232ca 147 for(Int_t index = 0; index <fNprimary; index ++ ){
148 fPrimary[index]+= shift ;
990119d6 149 }
150}
cf239357 151//____________________________________________________________________________
152Bool_t AliPHOSDigit::operator==(AliPHOSDigit const & digit) const
153{
b2a60966 154 // Two digits are equal if they have the same Id
155
cf239357 156 if ( fId == digit.fId )
d15a28e7 157 return kTRUE ;
158 else
159 return kFALSE ;
160}
cf239357 161
d15a28e7 162//____________________________________________________________________________
cf239357 163AliPHOSDigit& AliPHOSDigit::operator+(AliPHOSDigit const & digit)
d15a28e7 164{
adc232ca 165
b2a60966 166 // Adds the amplitude of digits and completes the list of primary particles
adc232ca 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] ;
174 }
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] ;
180 }
181 if(fPrimary)
182 delete []fPrimary ;
183 fPrimary = tmp ;
184 }
185 fNprimary+=digit.fNprimary ;
186 fAmp += digit.fAmp ;
187 if(fTime > digit.fTime)
188 fTime = digit.fTime ;
189 return *this ;
88cb7938 190}
88cb7938 191//____________________________________________________________________________
192AliPHOSDigit& AliPHOSDigit::operator*(Float_t factor)
193{
194 // Multiplies the amplitude by a factor
bb53c80c 195
88cb7938 196 Float_t tempo = static_cast<Float_t>(fAmp) ;
197 tempo *= factor ;
198 fAmp = static_cast<Int_t>(TMath::Ceil(tempo)) ;
d15a28e7 199 return *this ;
200}
201
202//____________________________________________________________________________
cf239357 203ostream& operator << ( ostream& out , const AliPHOSDigit & digit)
d15a28e7 204{
b2a60966 205 // Prints the data of the digit
206
21cd0c07 207// out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ;
208// Int_t i ;
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") ;
d15a28e7 213 return out ;
214}
215
cf239357 216