]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSPpsdRecPoint.cxx
New Version from Alla
[u/mrichter/AliRoot.git] / PHOS / AliPHOSPpsdRecPoint.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
16//_________________________________________________________________________
17// RecPoint in the PHOS PPSD: a list of AliPHOSDigit's
18//*-- Author : Yves Schutz SUBATECH
19//////////////////////////////////////////////////////////////////////////////
20
21// --- ROOT system ---
9f616d61 22#include "TPad.h"
d15a28e7 23// --- Standard library ---
24
9f616d61 25#include <iostream>
26#include <cassert>
d15a28e7 27
28// --- AliRoot header files ---
29
30#include "AliPHOSGeometry.h"
31#include "AliPHOSPpsdRecPoint.h"
32#include "AliRun.h"
33
34ClassImp(AliPHOSPpsdRecPoint)
35
36//____________________________________________________________________________
37AliPHOSPpsdRecPoint::AliPHOSPpsdRecPoint(void)
38{
39 fMulDigit = 0 ;
40 AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ;
41 fDelta = geom->GetCrystalSize(0) ;
42 fLocPos.SetX(1000000.) ; //Local position should be evaluated
43}
44
45//____________________________________________________________________________
46AliPHOSPpsdRecPoint::~AliPHOSPpsdRecPoint(void) // dtor
47{
9f616d61 48 //dtor
d15a28e7 49}
50
51//____________________________________________________________________________
52void AliPHOSPpsdRecPoint::AddDigit(AliDigitNew & digit, Float_t Energy)
53{
54 // adds a digit to the digits list
55 // and accumulates the total amplitude and the multiplicity
56
57
58 if ( fMulDigit >= fMaxDigit ) { // increase the size of the lists
9f616d61 59 fMaxDigit*=2 ;
60 int * tempo = new ( int[fMaxDigit] ) ;
d15a28e7 61 Int_t index ;
62
63 for ( index = 0 ; index < fMulDigit ; index++ )
64 tempo[index] = fDigitsList[index] ;
65
9f616d61 66 delete [] fDigitsList ;
67 fDigitsList = new ( int[fMaxDigit] ) ;
68
69 for ( index = 0 ; index < fMulDigit ; index++ )
70 fDigitsList[index] = tempo[index] ;
71
72 delete [] tempo ;
d15a28e7 73 }
9f616d61 74
d15a28e7 75 fDigitsList[fMulDigit++] = (int) &digit ;
76 fAmp += Energy ;
77}
78
79
80
81
82//____________________________________________________________________________
83Int_t AliPHOSPpsdRecPoint::Compare(TObject * obj)
84{
85 Int_t rv ;
86
87 AliPHOSPpsdRecPoint * clu = (AliPHOSPpsdRecPoint *)obj ;
88
89
90 Float_t x1 , z1 ;
91 Float_t x2 , z2 ;
92
93 Int_t PhosMod1 ;
94 Int_t PhosMod2 ;
95
96 Int_t up1 ;
97 Int_t up2 ;
98
99 if(GetUp()) // upper layer
100 up1 = 0 ;
101 else // lower layer
102 up1 = 1 ;
103
104 if(clu->GetUp()) // upper layer
105 up2 = 0 ;
106 else // lower layer
107 up2 = 1 ;
108
109 TVector3 PosLoc ;
110 this->GetLocalPosition(PosLoc) ;
111 x1 = PosLoc.X() ;
112 z1 = PosLoc.Z() ;
113 PhosMod1 = this->GetPHOSMod();
114 clu->GetLocalPosition(PosLoc) ;
115 x2 = PosLoc.X() ;
116 z2 = PosLoc.Z() ;
117 PhosMod2 = clu->GetPHOSMod();
118
119 if(PhosMod1 == PhosMod2 ) {
120
121 if(up1 == up2 ){
122 Int_t rowdif = (Int_t)TMath::Ceil(x1/fDelta) - (Int_t) TMath::Ceil(x2/fDelta) ;
123
124 if (rowdif> 0)
125 rv = -1 ;
126 else if(rowdif < 0)
127 rv = 1 ;
128 else if(z1>z2)
129 rv = -1 ;
130 else
131 rv = 1 ;
132 }
133
134 else {
135
136 if(up1 < up2 ) // Upper level first (up = True or False, True > False)
137 rv = 1 ;
138 else
139 rv = - 1 ;
140 }
141
142 } // if PhosMod1 == PhosMod2
143
144 else {
145
146 if(PhosMod1 < PhosMod2 )
147 rv = -1 ;
148 else
149 rv = 1 ;
150
151}
152
153 return rv ;
154}
155
156//____________________________________________________________________________
157void AliPHOSPpsdRecPoint::GetLocalPosition(TVector3 &LPos){
158
159 if( fLocPos.X() < 1000000.) { //allready evaluated
160 LPos = fLocPos ;
161 return ;
162 }
163
164 Int_t relid[4] ;
165
166 Float_t x = 0. ;
167 Float_t z = 0. ;
168
169 AliPHOSGeometry * PHOSGeom = (AliPHOSGeometry *) fGeom ;
170
171 AliPHOSDigit * digit ;
172 Int_t iDigit;
173
174 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
175 digit = (AliPHOSDigit *) fDigitsList[iDigit];
176
177 Float_t xi ;
178 Float_t zi ;
179 PHOSGeom->AbsToRelNumbering(digit->GetId(), relid) ;
180 PHOSGeom->RelPosInModule(relid, xi, zi);
181 x += xi ;
182 z += zi ;
183 }
184
185 x /= fMulDigit ;
186 z /= fMulDigit ;
187
188 fLocPos.SetX(x) ;
189 fLocPos.SetY(0.) ;
190 fLocPos.SetZ(z) ;
191
192 LPos = fLocPos ;
193}
194
195//____________________________________________________________________________
196Bool_t AliPHOSPpsdRecPoint::GetUp()
197{
198 Int_t relid[4] ;
199
200 AliPHOSGeometry * PHOSGeom = (AliPHOSGeometry *) fGeom ;
201
202 AliPHOSDigit *digit = (AliPHOSDigit *)fDigitsList[0] ;
203
204 PHOSGeom->AbsToRelNumbering(digit->GetId(),relid);
205 Bool_t up ;
206
207 if((Int_t)TMath::Ceil((Float_t)relid[1]/
208 (PHOSGeom->GetNumberOfModulesPhi()*PHOSGeom->GetNumberOfModulesZ())-0.0001 ) > 1)
209 up = kFALSE ;
210 else
211 up = kTRUE ;
212
213 return up ;
214}
9f616d61 215//______________________________________________________________________________
216void AliPHOSPpsdRecPoint::Paint(Option_t *)
217{
218//*-*-*-*-*-*-*-*-*-*-*Paint this ALiRecPoint as a TMarker with its current attributes*-*-*-*-*-*-*
219//*-* =============================================
220 TVector3 pos(0.,0.,0.) ;
221 GetLocalPosition(pos) ;
222 Coord_t x = pos.X() ;
223 Coord_t y = pos.Z() ;
224 Color_t MarkerColor = 1 ;
225 Size_t MarkerSize = 1. ;
226 Style_t MarkerStyle = 2 ;
227 if (GetUp())
228 MarkerStyle = 3 ;
229
230 if (!gPad->IsBatch()) {
231 gVirtualX->SetMarkerColor(MarkerColor);
232 gVirtualX->SetMarkerSize (MarkerSize);
233 gVirtualX->SetMarkerStyle(MarkerStyle);
234 }
235 gPad->SetAttMarkerPS(MarkerColor,MarkerStyle,MarkerSize);
236 gPad->PaintPolyMarker(1,&x,&y,"");
237
238
239}
d15a28e7 240
241//____________________________________________________________________________
242void AliPHOSPpsdRecPoint::Print(Option_t * option)
243{
244 cout << "AliPHOSPpsdRecPoint: " << endl ;
245
246 AliPHOSDigit * digit ;
d15a28e7 247 Int_t iDigit;
9f616d61 248 AliPHOSGeometry * PHOSGeom = (AliPHOSGeometry *) fGeom ;
249
250 Float_t xi ;
251 Float_t zi ;
252 Int_t relid[4] ;
d15a28e7 253
254 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
255 digit = (AliPHOSDigit *) fDigitsList[iDigit];
9f616d61 256 PHOSGeom->AbsToRelNumbering(digit->GetId(), relid) ;
257 PHOSGeom->RelPosInModule(relid, xi, zi);
258 cout << " Id = " << digit->GetId() ;
259 cout << " Phos mod = " << relid[0] ;
260 cout << " PPSD mod = " << relid[1] ;
261 cout << " x = " << xi ;
262 cout << " z = " << zi ;
263 cout << " Energy = " << digit->GetAmp() << endl ;
d15a28e7 264 }
265 cout << " Multiplicity = " << fMulDigit << endl ;
266}
267
268
269// //____________________________________________________________________________
270// AliPHOSPpsdRecPoint& AliPHOSPpsdRecPoint::operator = (AliPHOSPpsdRecPoint Clu)
271// {
272// int* DL = Clu.GetDigitsList() ;
273
274// if(fDigitsList)
275// delete fDigitsList ;
276
277// AliPHOSDigit * digit ;
278
279// Int_t iDigit;
280
281// for(iDigit=0; iDigit<fMulDigit; iDigit++) {
282// digit = (AliPHOSDigit *) DL[iDigit];
283// AddDigit(*digit) ;
284// }
285
286// fDelta = Clu.GetDelta() ;
287// delete DL ;
288
289// fAmp = Clu.GetEnergy() ;
290// fGeom = Clu.GetGeom() ;
291// TVector3 LocPos;
292// Clu.GetLocalPosition(LocPos) ;
293// fLocPos = LocPos;
294// fMulDigit = Clu.GetMultiplicity() ;
295// fMaxDigit = Clu.GetMaximumMultiplicity() ;
296// fPHOSMod = Clu.GetPHOSMod() ;
297
298
299// return *this ;
300// }