]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSDigit.cxx
The call to the geometry object has been modified
[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
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
d15a28e7 28
29// --- ROOT system ---
30
31// --- Standard library ---
32
de9ec31b 33#include <iostream.h>
d15a28e7 34
35// --- AliRoot header files ---
36
37#include "AliPHOSDigit.h"
38
39
40ClassImp(AliPHOSDigit)
41
cf239357 42//____________________________________________________________________________
f741ce93 43 AliPHOSDigit::AliPHOSDigit()
cf239357 44{
b2a60966 45 // default ctor
46
83974468 47 fIndexInList = -1 ;
48 fNprimary = 0 ;
49 fPrimary1 = -1 ;
50 fPrimary2 = -1 ;
51 fPrimary3 = -1 ;
cf239357 52}
53
d15a28e7 54//____________________________________________________________________________
83974468 55AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t DigEnergy, Int_t index)
d15a28e7 56{
b2a60966 57 // ctor with all data
58
83974468 59 fAmp = DigEnergy ;
60 fId = id ;
61 fIndexInList = index ;
62 fPrimary1 = primary ;
63 fNprimary = 1 ;
22b03d33 64 fPrimary2 = -1 ;
65 fPrimary3 = -1 ;
cf239357 66}
67
68//____________________________________________________________________________
69AliPHOSDigit::AliPHOSDigit(const AliPHOSDigit & digit)
b2a60966 70{
71 // copy ctor
72
83974468 73 fAmp = digit.fAmp ;
74 fId = digit.fId;
75 fIndexInList = digit.fIndexInList ;
76 fNprimary = digit.fNprimary ;
77 fPrimary1 = digit.fPrimary1 ;
78 fPrimary2 = digit.fPrimary2 ;
79 fPrimary3 = digit.fPrimary3 ;
ff4c968a 80}
81
d15a28e7 82//____________________________________________________________________________
cf239357 83Int_t AliPHOSDigit::Compare(TObject * obj)
d15a28e7 84{
b2a60966 85 // Compares two digits with respect to its Id
86 // to sort according increasing Id
87
88714635 88 Int_t rv ;
cf239357 89
90 AliPHOSDigit * digit = (AliPHOSDigit *)obj ;
91
92 Int_t iddiff = fId - digit->GetId() ;
93
94 if ( iddiff > 0 )
95 rv = 1 ;
96 else if ( iddiff < 0 )
97 rv = -1 ;
98 else
99 rv = 0 ;
100
101 return rv ;
102
103}
26d4b141 104
105//____________________________________________________________________________
106Int_t AliPHOSDigit::GetPrimary(Int_t index) const
107{
b2a60966 108 // Returns the primary particle id index =1,2,3
109
26d4b141 110 Int_t rv = -1 ;
111 if ( index > 3 )
112 cout << "AliPHOSDigit ERROR > only 3 primaries allowed" << endl ;
113 else {
114 switch (index) {
115 case 1 :
116 rv = fPrimary1 ;
117 break ;
118 case 2 :
119 rv = fPrimary2 ;
120 break ;
121 case 3 :
122 rv = fPrimary3 ;
123 break ;
124 }
125 }
126
127 return rv ;
128
129}
130
cf239357 131//____________________________________________________________________________
132Bool_t AliPHOSDigit::operator==(AliPHOSDigit const & digit) const
133{
b2a60966 134 // Two digits are equal if they have the same Id
135
cf239357 136 if ( fId == digit.fId )
d15a28e7 137 return kTRUE ;
138 else
139 return kFALSE ;
140}
cf239357 141
d15a28e7 142//____________________________________________________________________________
cf239357 143AliPHOSDigit& AliPHOSDigit::operator+(AliPHOSDigit const & digit)
d15a28e7 144{
b2a60966 145 // Adds the amplitude of digits and completes the list of primary particles
31aa6d6c 146
cf239357 147 fAmp += digit.fAmp ;
31aa6d6c 148
26d4b141 149 // Here comes something crummy ... but I do not know how to stream pointers
150 // because AliPHOSDigit is in a TCLonesArray
f741ce93 151
152 Int_t tempo1[3] ;
153 tempo1[0] = fPrimary1 ;
154 tempo1[1] = fPrimary2 ;
155 tempo1[2] = fPrimary3 ;
156
157 Int_t tempo2[3] ;
158 tempo2[0] = digit.fPrimary1 ;
159 tempo2[1] = digit.fPrimary2 ;
160 tempo2[2] = digit.fPrimary3 ;
161
162 Int_t max1 = fNprimary ;
163 Int_t max2 = digit.fNprimary ;
164
165 if ( fNprimary >= 3 ) {
166 cout << "AliPHOSDigit + operator ERROR > too many primaries, modify AliPHOSDigit" << endl ;
167 }
168 else {
169 fNprimary += digit.fNprimary ;
170 if ( fNprimary > 3 ) {
26d4b141 171 cout << "AliPHOSDigit + operator ERROR > too many primaries, modify AliPHOSDigit" << endl ;
6a3f1304 172 fNprimary = 3 ;
26d4b141 173 }
f741ce93 174
175 Int_t tempo3[3] ;
176 Int_t index ;
31aa6d6c 177 for (index = 0 ; index < 3 ; index++)
178 tempo3[index] = 0 ;
179
f741ce93 180 for (index = 0 ; index < max1 ; index++)
181 tempo3[index] = tempo1[index] ;
31aa6d6c 182
f741ce93 183 for (index = 0 ; index < max2 ; index++)
184 tempo3[index+max1] = tempo2[index] ;
185
186 fPrimary1 = tempo3[0] ;
187 fPrimary2 = tempo3[1] ;
188 fPrimary3 = tempo3[2] ;
26d4b141 189
f741ce93 190 }
26d4b141 191 // end of crummy stuff
192
d15a28e7 193 return *this ;
194}
195
196//____________________________________________________________________________
cf239357 197ostream& operator << ( ostream& out , const AliPHOSDigit & digit)
d15a28e7 198{
b2a60966 199 // Prints the data of the digit
200
201 out << "ID " << digit.fId << " Energy = " << digit.fAmp << endl
202 << "Primary 1 = " << digit.fPrimary1 << endl
203 << "Primary 2 = " << digit.fPrimary2 << endl
83974468 204 << "Primary 3 = " << digit.fPrimary3 << endl
205 << "Position in list = " << digit.fIndexInList << endl ;
d15a28e7 206 return out ;
207}
208
cf239357 209