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