]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSDigit.cxx
Coding violations corrected
[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;
04f0bda3 50 fTime = 0. ;
51 fTimeR = 0. ;
cf239357 52}
53
d15a28e7 54//____________________________________________________________________________
9688c1dd 55AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t digEnergy, Float_t time, Int_t index)
d15a28e7 56{
b2a60966 57 // ctor with all data
58
7b7c1533 59 fAmp = digEnergy ;
9688c1dd 60 fTime = time ;
04f0bda3 61 fTimeR = fTime ;
83974468 62 fId = id ;
63 fIndexInList = index ;
4a2ca5e9 64 if( primary != -1){
65 fNprimary = 1 ;
adc232ca 66 fPrimary = new Int_t[fNprimary] ;
366c5d6f 67 fPrimary[0] = primary ;
4a2ca5e9 68 }
69 else{ //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1)
adc232ca 70 fNprimary = 0 ;
71 fPrimary = 0 ;
4a2ca5e9 72 }
cf239357 73}
74
75//____________________________________________________________________________
a8c47ab6 76AliPHOSDigit::AliPHOSDigit(const AliPHOSDigit & digit) : AliDigitNew(digit)
b2a60966 77{
78 // copy ctor
36d93c12 79
adc232ca 80 fNprimary = digit.fNprimary ;
81 if(fNprimary){
82 fPrimary = new Int_t[fNprimary] ;
83 for (Int_t i = 0; i < fNprimary ; i++)
84 fPrimary[i] = digit.fPrimary[i] ;
85 }
86 else
87 fPrimary = 0 ;
83974468 88 fAmp = digit.fAmp ;
9688c1dd 89 fTime = digit.fTime ;
04f0bda3 90 fTimeR = digit.fTimeR ;
83974468 91 fId = digit.fId;
92 fIndexInList = digit.fIndexInList ;
ff4c968a 93}
94
2e5c3041 95//____________________________________________________________________________
36d93c12 96AliPHOSDigit::~AliPHOSDigit()
2e5c3041 97{
98 // Delete array of primiries if any
adc232ca 99 if(fPrimary)
100 delete [] fPrimary ;
2e5c3041 101}
102
d15a28e7 103//____________________________________________________________________________
037cc66d 104Int_t AliPHOSDigit::Compare(const TObject * obj) const
d15a28e7 105{
b2a60966 106 // Compares two digits with respect to its Id
107 // to sort according increasing Id
108
88714635 109 Int_t rv ;
cf239357 110
111 AliPHOSDigit * digit = (AliPHOSDigit *)obj ;
112
113 Int_t iddiff = fId - digit->GetId() ;
114
115 if ( iddiff > 0 )
116 rv = 1 ;
117 else if ( iddiff < 0 )
118 rv = -1 ;
119 else
120 rv = 0 ;
121
122 return rv ;
123
124}
26d4b141 125
126//____________________________________________________________________________
127Int_t AliPHOSDigit::GetPrimary(Int_t index) const
128{
2f04ed65 129 // retrieves the primary particle number given its index in the list
36d93c12 130 Int_t rv = -1 ;
36641f9d 131 if ( index <= fNprimary && index > 0){
36d93c12 132 rv = fPrimary[index-1] ;
133 }
26d4b141 134
135 return rv ;
366c5d6f 136
26d4b141 137}
990119d6 138//____________________________________________________________________________
e957fea8 139void AliPHOSDigit::Print() const
d8ca0b45 140{
e957fea8 141 // Print the digit together with list of primaries
04f0bda3 142 printf("PHOS digit: Amp=%d, Id=%d, Time=%e, TimeR=%e, NPrim=%d ",fAmp,fId,fTime,fTimeR,fNprimary);
adc232ca 143 for(Int_t index = 0; index <fNprimary; index ++ )
144 printf(" %d ",fPrimary[index]);
145 printf("\n") ;
d8ca0b45 146}
147//____________________________________________________________________________
a4e98857 148void AliPHOSDigit::ShiftPrimary(Int_t shift)
149{
150 //shifts primary number to BIG offset, to separate primary in different TreeK
adc232ca 151 for(Int_t index = 0; index <fNprimary; index ++ ){
152 fPrimary[index]+= shift ;
990119d6 153 }
154}
cf239357 155//____________________________________________________________________________
156Bool_t AliPHOSDigit::operator==(AliPHOSDigit const & digit) const
157{
b2a60966 158 // Two digits are equal if they have the same Id
159
cf239357 160 if ( fId == digit.fId )
d15a28e7 161 return kTRUE ;
162 else
163 return kFALSE ;
164}
cf239357 165
d15a28e7 166//____________________________________________________________________________
cf239357 167AliPHOSDigit& AliPHOSDigit::operator+(AliPHOSDigit const & digit)
d15a28e7 168{
adc232ca 169
b2a60966 170 // Adds the amplitude of digits and completes the list of primary particles
adc232ca 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] ;
178 }
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] ;
184 }
185 if(fPrimary)
186 delete []fPrimary ;
187 fPrimary = tmp ;
188 }
189 fNprimary+=digit.fNprimary ;
190 fAmp += digit.fAmp ;
191 if(fTime > digit.fTime)
192 fTime = digit.fTime ;
04f0bda3 193 fTimeR = fTime ;
adc232ca 194 return *this ;
88cb7938 195}
88cb7938 196//____________________________________________________________________________
197AliPHOSDigit& AliPHOSDigit::operator*(Float_t factor)
198{
199 // Multiplies the amplitude by a factor
bb53c80c 200
88cb7938 201 Float_t tempo = static_cast<Float_t>(fAmp) ;
202 tempo *= factor ;
203 fAmp = static_cast<Int_t>(TMath::Ceil(tempo)) ;
d15a28e7 204 return *this ;
205}
206
207//____________________________________________________________________________
cf239357 208ostream& operator << ( ostream& out , const AliPHOSDigit & digit)
d15a28e7 209{
b2a60966 210 // Prints the data of the digit
211
21cd0c07 212// out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ;
213// Int_t i ;
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") ;
d15a28e7 218 return out ;
219}
220
cf239357 221