]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSDigit.cxx
Removing unused variables
[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
29// --- Standard library ---
30
de9ec31b 31#include <iostream.h>
d15a28e7 32
33// --- AliRoot header files ---
34
35#include "AliPHOSDigit.h"
36
37
38ClassImp(AliPHOSDigit)
39
cf239357 40//____________________________________________________________________________
f741ce93 41 AliPHOSDigit::AliPHOSDigit()
cf239357 42{
b2a60966 43 // default ctor
44
83974468 45 fIndexInList = -1 ;
46 fNprimary = 0 ;
366c5d6f 47 fNMaxPrimary = 5 ;
cf239357 48}
49
d15a28e7 50//____________________________________________________________________________
9688c1dd 51AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t digEnergy, Float_t time, Int_t index)
d15a28e7 52{
b2a60966 53 // ctor with all data
54
2e5c3041 55 fNMaxPrimary = 5 ;
7b7c1533 56 fAmp = digEnergy ;
9688c1dd 57 fTime = time ;
83974468 58 fId = id ;
59 fIndexInList = index ;
4a2ca5e9 60 if( primary != -1){
61 fNprimary = 1 ;
366c5d6f 62 fPrimary[0] = primary ;
4a2ca5e9 63 }
64 else{ //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1)
65 fNprimary = 0 ;
366c5d6f 66 fPrimary[0] = -1 ;
4a2ca5e9 67 }
366c5d6f 68 Int_t i ;
69 for ( i = 1; i < fNMaxPrimary ; i++)
70 fPrimary[i] = -1 ;
cf239357 71}
72
73//____________________________________________________________________________
74AliPHOSDigit::AliPHOSDigit(const AliPHOSDigit & digit)
b2a60966 75{
76 // copy ctor
77
36d93c12 78
79 fNMaxPrimary = digit.fNMaxPrimary ;
80 Int_t i ;
81 for ( i = 0; i < fNMaxPrimary ; i++)
82 fPrimary[i] = digit.fPrimary[i] ;
83974468 83 fAmp = digit.fAmp ;
9688c1dd 84 fTime = digit.fTime ;
83974468 85 fId = digit.fId;
86 fIndexInList = digit.fIndexInList ;
87 fNprimary = digit.fNprimary ;
ff4c968a 88}
89
2e5c3041 90//____________________________________________________________________________
36d93c12 91AliPHOSDigit::~AliPHOSDigit()
2e5c3041 92{
93 // Delete array of primiries if any
36d93c12 94
2e5c3041 95}
96
d15a28e7 97//____________________________________________________________________________
037cc66d 98Int_t AliPHOSDigit::Compare(const TObject * obj) const
d15a28e7 99{
b2a60966 100 // Compares two digits with respect to its Id
101 // to sort according increasing Id
102
88714635 103 Int_t rv ;
cf239357 104
105 AliPHOSDigit * digit = (AliPHOSDigit *)obj ;
106
107 Int_t iddiff = fId - digit->GetId() ;
108
109 if ( iddiff > 0 )
110 rv = 1 ;
111 else if ( iddiff < 0 )
112 rv = -1 ;
113 else
114 rv = 0 ;
115
116 return rv ;
117
118}
26d4b141 119
120//____________________________________________________________________________
121Int_t AliPHOSDigit::GetPrimary(Int_t index) const
122{
2f04ed65 123 // retrieves the primary particle number given its index in the list
36d93c12 124 Int_t rv = -1 ;
36641f9d 125 if ( index <= fNprimary && index > 0){
36d93c12 126 rv = fPrimary[index-1] ;
127 }
26d4b141 128
129 return rv ;
366c5d6f 130
26d4b141 131}
990119d6 132//____________________________________________________________________________
d8ca0b45 133void AliPHOSDigit::Print(Option_t *option) const
134{
135 printf("PHOS digit: Amp=%d, Id=%d\n",fAmp,fId);
136}
137//____________________________________________________________________________
a4e98857 138void AliPHOSDigit::ShiftPrimary(Int_t shift)
139{
140 //shifts primary number to BIG offset, to separate primary in different TreeK
990119d6 141 Int_t index ;
142 for(index = 0; index <fNprimary; index ++ ){
21c293b7 143 fPrimary[index] = fPrimary[index]+ shift ;
990119d6 144 }
145}
cf239357 146//____________________________________________________________________________
147Bool_t AliPHOSDigit::operator==(AliPHOSDigit const & digit) const
148{
b2a60966 149 // Two digits are equal if they have the same Id
150
cf239357 151 if ( fId == digit.fId )
d15a28e7 152 return kTRUE ;
153 else
154 return kFALSE ;
155}
cf239357 156
d15a28e7 157//____________________________________________________________________________
cf239357 158AliPHOSDigit& AliPHOSDigit::operator+(AliPHOSDigit const & digit)
d15a28e7 159{
b2a60966 160 // Adds the amplitude of digits and completes the list of primary particles
4a2ca5e9 161 // if amplitude is larger than
36d93c12 162
cf239357 163 fAmp += digit.fAmp ;
9688c1dd 164 if(fTime > digit.fTime)
165 fTime = digit.fTime ;
36d93c12 166
f741ce93 167 Int_t max1 = fNprimary ;
36d93c12 168
550bee17 169 Int_t index ;
170 for (index = 0 ; index < digit.fNprimary ; index++){
171 Bool_t deja = kTRUE ;
172 Int_t old ;
173 for ( old = 0 ; (old < max1) && deja; old++) { //already have this primary?
174 if(fPrimary[old] == (digit.fPrimary)[index])
175 deja = kFALSE;
176 }
177 if(deja){
178 fPrimary[fNprimary] = (digit.fPrimary)[index] ;
179 fNprimary++ ;
180 if(fNprimary>fNMaxPrimary) {
181 cout << "AliPHOSDigit >> Increase NMaxPrimary "<< endl ;
182 return *this ;
183 }
184 }
f741ce93 185 }
550bee17 186
d15a28e7 187 return *this ;
188}
189
190//____________________________________________________________________________
cf239357 191ostream& operator << ( ostream& out , const AliPHOSDigit & digit)
d15a28e7 192{
b2a60966 193 // Prints the data of the digit
194
9688c1dd 195 out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ;
36d93c12 196 Int_t i ;
197 for(i=0;i<digit.fNprimary;i++)
198 out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ;
199 out << "Position in list = " << digit.fIndexInList << endl ;
d15a28e7 200 return out ;
201}
202
cf239357 203