]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - PHOS/AliPHOSDigit.cxx
Initialize decayer before generation. Important if run inside cocktail.
[u/mrichter/AliRoot.git] / PHOS / AliPHOSDigit.cxx
... / ...
CommitLineData
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
16/* $Id$ */
17
18//_________________________________________________________________________
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
23// It would be nice to replace the 3 identifiers by an array, but, because digits are kept in a TClonesQArray,
24// it is not possible to stream such an array... (beyond my understqnding!)
25//
26//*-- Author: Laurent Aphecetche & Yves Schutz (SUBATECH)
27
28
29// --- ROOT system ---
30
31// --- Standard library ---
32
33#include <iostream.h>
34
35// --- AliRoot header files ---
36
37#include "AliPHOSDigit.h"
38
39
40ClassImp(AliPHOSDigit)
41
42//____________________________________________________________________________
43 AliPHOSDigit::AliPHOSDigit()
44{
45 // default ctor
46
47 fIndexInList = -1 ;
48 fNprimary = 0 ;
49 fNMaxPrimary = 5 ;
50}
51
52//____________________________________________________________________________
53AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t DigEnergy, Int_t index)
54{
55 // ctor with all data
56
57 fNMaxPrimary = 5 ;
58 fAmp = DigEnergy ;
59 fId = id ;
60 fIndexInList = index ;
61 if( primary != -1){
62 fNprimary = 1 ;
63 fPrimary[0] = primary ;
64 }
65 else{ //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1)
66 fNprimary = 0 ;
67 fPrimary[0] = -1 ;
68 }
69 Int_t i ;
70 for ( i = 1; i < fNMaxPrimary ; i++)
71 fPrimary[i] = -1 ;
72}
73
74//____________________________________________________________________________
75AliPHOSDigit::AliPHOSDigit(const AliPHOSDigit & digit)
76{
77 // copy ctor
78
79
80 fNMaxPrimary = digit.fNMaxPrimary ;
81 Int_t i ;
82 for ( i = 0; i < fNMaxPrimary ; i++)
83 fPrimary[i] = digit.fPrimary[i] ;
84 fAmp = digit.fAmp ;
85 fId = digit.fId;
86 fIndexInList = digit.fIndexInList ;
87 fNprimary = digit.fNprimary ;
88}
89
90//____________________________________________________________________________
91AliPHOSDigit::~AliPHOSDigit()
92{
93 // Delete array of primiries if any
94
95}
96
97//____________________________________________________________________________
98Int_t AliPHOSDigit::Compare(const TObject * obj) const
99{
100 // Compares two digits with respect to its Id
101 // to sort according increasing Id
102
103 Int_t rv ;
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}
119
120//____________________________________________________________________________
121Int_t AliPHOSDigit::GetPrimary(Int_t index) const
122{
123 // retrieves the primary particle number given its index in the list
124 Int_t rv = -1 ;
125 if ( index <= fNprimary ){
126 rv = fPrimary[index-1] ;
127 }
128
129 return rv ;
130
131}
132//____________________________________________________________________________
133void AliPHOSDigit::ShiftPrimary(Int_t shift){
134 //shifts primary nimber to BIG offset, to separate primary in different TreeK
135 Int_t index ;
136 for(index = 0; index <fNprimary; index ++ ){
137 fPrimary[index] = fPrimary[index]+ shift * 10000000 ;
138 }
139}
140//____________________________________________________________________________
141Bool_t AliPHOSDigit::operator==(AliPHOSDigit const & digit) const
142{
143 // Two digits are equal if they have the same Id
144
145 if ( fId == digit.fId )
146 return kTRUE ;
147 else
148 return kFALSE ;
149}
150
151//____________________________________________________________________________
152AliPHOSDigit& AliPHOSDigit::operator+(AliPHOSDigit const & digit)
153{
154 // Adds the amplitude of digits and completes the list of primary particles
155 // if amplitude is larger than
156
157 fAmp += digit.fAmp ;
158
159 Int_t max1 = fNprimary ;
160
161 Int_t index ;
162 for (index = 0 ; index < digit.fNprimary ; index++){
163 Bool_t deja = kTRUE ;
164 Int_t old ;
165 for ( old = 0 ; (old < max1) && deja; old++) { //already have this primary?
166 if(fPrimary[old] == (digit.fPrimary)[index])
167 deja = kFALSE;
168 }
169 if(deja){
170 fPrimary[fNprimary] = (digit.fPrimary)[index] ;
171 fNprimary++ ;
172 if(fNprimary>fNMaxPrimary) {
173 cout << "AliPHOSDigit >> Increase NMaxPrimary "<< endl ;
174 return *this ;
175 }
176 }
177 }
178
179 return *this ;
180}
181
182//____________________________________________________________________________
183ostream& operator << ( ostream& out , const AliPHOSDigit & digit)
184{
185 // Prints the data of the digit
186
187 out << "ID " << digit.fId << " Energy = " << digit.fAmp << endl ;
188 Int_t i ;
189 for(i=0;i<digit.fNprimary;i++)
190 out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ;
191 out << "Position in list = " << digit.fIndexInList << endl ;
192 return out ;
193}
194
195