]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSDigit.cxx
04-jul-2001 NvE Storage of calorimeters introduced in AliEvent and ResetVertices()
[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//
24//*-- Author: Laurent Aphecetche & Yves Schutz (SUBATECH)
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//____________________________________________________________________________
83974468 51AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t DigEnergy, Int_t index)
d15a28e7 52{
b2a60966 53 // ctor with all data
54
2e5c3041 55 fNMaxPrimary = 5 ;
83974468 56 fAmp = DigEnergy ;
57 fId = id ;
58 fIndexInList = index ;
4a2ca5e9 59 if( primary != -1){
60 fNprimary = 1 ;
366c5d6f 61 fPrimary[0] = primary ;
4a2ca5e9 62 }
63 else{ //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1)
64 fNprimary = 0 ;
366c5d6f 65 fPrimary[0] = -1 ;
4a2ca5e9 66 }
366c5d6f 67 Int_t i ;
68 for ( i = 1; i < fNMaxPrimary ; i++)
69 fPrimary[i] = -1 ;
cf239357 70}
71
72//____________________________________________________________________________
73AliPHOSDigit::AliPHOSDigit(const AliPHOSDigit & digit)
b2a60966 74{
75 // copy ctor
76
36d93c12 77
78 fNMaxPrimary = digit.fNMaxPrimary ;
79 Int_t i ;
80 for ( i = 0; i < fNMaxPrimary ; i++)
81 fPrimary[i] = digit.fPrimary[i] ;
83974468 82 fAmp = digit.fAmp ;
83 fId = digit.fId;
84 fIndexInList = digit.fIndexInList ;
85 fNprimary = digit.fNprimary ;
ff4c968a 86}
87
2e5c3041 88//____________________________________________________________________________
36d93c12 89AliPHOSDigit::~AliPHOSDigit()
2e5c3041 90{
91 // Delete array of primiries if any
36d93c12 92
2e5c3041 93}
94
d15a28e7 95//____________________________________________________________________________
037cc66d 96Int_t AliPHOSDigit::Compare(const TObject * obj) const
d15a28e7 97{
b2a60966 98 // Compares two digits with respect to its Id
99 // to sort according increasing Id
100
88714635 101 Int_t rv ;
cf239357 102
103 AliPHOSDigit * digit = (AliPHOSDigit *)obj ;
104
105 Int_t iddiff = fId - digit->GetId() ;
106
107 if ( iddiff > 0 )
108 rv = 1 ;
109 else if ( iddiff < 0 )
110 rv = -1 ;
111 else
112 rv = 0 ;
113
114 return rv ;
115
116}
26d4b141 117
118//____________________________________________________________________________
119Int_t AliPHOSDigit::GetPrimary(Int_t index) const
120{
2f04ed65 121 // retrieves the primary particle number given its index in the list
36d93c12 122 Int_t rv = -1 ;
123 if ( index <= fNprimary ){
124 rv = fPrimary[index-1] ;
125 }
26d4b141 126
127 return rv ;
366c5d6f 128
26d4b141 129}
990119d6 130//____________________________________________________________________________
a4e98857 131void AliPHOSDigit::ShiftPrimary(Int_t shift)
132{
133 //shifts primary number to BIG offset, to separate primary in different TreeK
990119d6 134 Int_t index ;
135 for(index = 0; index <fNprimary; index ++ ){
136 fPrimary[index] = fPrimary[index]+ shift * 10000000 ;
137 }
138}
cf239357 139//____________________________________________________________________________
140Bool_t AliPHOSDigit::operator==(AliPHOSDigit const & digit) const
141{
b2a60966 142 // Two digits are equal if they have the same Id
143
cf239357 144 if ( fId == digit.fId )
d15a28e7 145 return kTRUE ;
146 else
147 return kFALSE ;
148}
cf239357 149
d15a28e7 150//____________________________________________________________________________
cf239357 151AliPHOSDigit& AliPHOSDigit::operator+(AliPHOSDigit const & digit)
d15a28e7 152{
b2a60966 153 // Adds the amplitude of digits and completes the list of primary particles
4a2ca5e9 154 // if amplitude is larger than
36d93c12 155
cf239357 156 fAmp += digit.fAmp ;
36d93c12 157
f741ce93 158 Int_t max1 = fNprimary ;
36d93c12 159
550bee17 160 Int_t index ;
161 for (index = 0 ; index < digit.fNprimary ; index++){
162 Bool_t deja = kTRUE ;
163 Int_t old ;
164 for ( old = 0 ; (old < max1) && deja; old++) { //already have this primary?
165 if(fPrimary[old] == (digit.fPrimary)[index])
166 deja = kFALSE;
167 }
168 if(deja){
169 fPrimary[fNprimary] = (digit.fPrimary)[index] ;
170 fNprimary++ ;
171 if(fNprimary>fNMaxPrimary) {
172 cout << "AliPHOSDigit >> Increase NMaxPrimary "<< endl ;
173 return *this ;
174 }
175 }
f741ce93 176 }
550bee17 177
d15a28e7 178 return *this ;
179}
180
181//____________________________________________________________________________
cf239357 182ostream& operator << ( ostream& out , const AliPHOSDigit & digit)
d15a28e7 183{
b2a60966 184 // Prints the data of the digit
185
36d93c12 186 out << "ID " << digit.fId << " Energy = " << digit.fAmp << endl ;
187 Int_t i ;
188 for(i=0;i<digit.fNprimary;i++)
189 out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ;
190 out << "Position in list = " << digit.fIndexInList << endl ;
d15a28e7 191 return out ;
192}
193
cf239357 194