]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - PHOS/AliPHOSPpsdRecPoint.cxx
The web becomes richer
[u/mrichter/AliRoot.git] / PHOS / AliPHOSPpsdRecPoint.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// A RecPoint (cluster) in the PPSD
20// A PPSD RecPoint ends up to be a single digit
21//
22//*-- Yves Schutz (SUBATECH)
23
24// --- ROOT system ---
25
26#include "TPad.h"
27
28// --- Standard library ---
29
30#include <iostream>
31
32// --- AliRoot header files ---
33
34#include "AliPHOSGeometry.h"
35#include "AliPHOSPpsdRecPoint.h"
36#include "AliRun.h"
37
38ClassImp(AliPHOSPpsdRecPoint)
39
40//____________________________________________________________________________
41AliPHOSPpsdRecPoint::AliPHOSPpsdRecPoint(void)
42{
43 // ctor
44
45 fMulDigit = 0 ;
46 AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ;
47 fDelta = geom->GetCrystalSize(0) ;
48 fLocPos.SetX(1000000.) ; //Local position should be evaluated
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
59 fMaxDigit*=2 ;
60 int * tempo = new ( int[fMaxDigit] ) ;
61 Int_t index ;
62
63 for ( index = 0 ; index < fMulDigit ; index++ )
64 tempo[index] = fDigitsList[index] ;
65
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 ;
73 }
74
75 fDigitsList[fMulDigit++] = (int) &digit ;
76 fAmp += Energy ;
77}
78
79//____________________________________________________________________________
80Int_t AliPHOSPpsdRecPoint::Compare(TObject * obj)
81{
82 // Compares according to the position
83
84 Int_t rv ;
85
86 AliPHOSPpsdRecPoint * clu = (AliPHOSPpsdRecPoint *)obj ;
87
88
89 Float_t x1 , z1 ;
90 Float_t x2 , z2 ;
91
92 Int_t phosmod1 ;
93 Int_t phosmod2 ;
94
95 Int_t up1 ;
96 Int_t up2 ;
97
98 if(GetUp()) // upper layer
99 up1 = 0 ;
100 else // lower layer
101 up1 = 1 ;
102
103 if(clu->GetUp()) // upper layer
104 up2 = 0 ;
105 else // lower layer
106 up2 = 1 ;
107
108 TVector3 posloc ;
109 this->GetLocalPosition(posloc) ;
110 x1 = posloc.X() ;
111 z1 = posloc.Z() ;
112 phosmod1 = this->GetPHOSMod();
113 clu->GetLocalPosition(posloc) ;
114 x2 = posloc.X() ;
115 z2 = posloc.Z() ;
116 phosmod2 = clu->GetPHOSMod();
117
118 if(phosmod1 == phosmod2 ) {
119
120 if(up1 == up2 ){
121 Int_t rowdif = (Int_t)TMath::Ceil(x1/fDelta) - (Int_t) TMath::Ceil(x2/fDelta) ;
122
123 if (rowdif> 0)
124 rv = -1 ;
125 else if(rowdif < 0)
126 rv = 1 ;
127 else if(z1>z2)
128 rv = -1 ;
129 else
130 rv = 1 ;
131 }
132
133 else {
134
135 if(up1 < up2 ) // Upper level first (up = True or False, True > False)
136 rv = 1 ;
137 else
138 rv = - 1 ;
139 }
140
141 } // if phosmod1 == phosmod2
142
143 else {
144
145 if(phosmod1 < phosmod2 )
146 rv = -1 ;
147 else
148 rv = 1 ;
149
150}
151
152 return rv ;
153}
154
155//____________________________________________________________________________
156void AliPHOSPpsdRecPoint::GetLocalPosition(TVector3 &LPos)
157{
158 // Calculates the local position in the PHOS-PPSD-module corrdinates
159
160 if( fLocPos.X() < 1000000.) { //allready evaluated
161 LPos = fLocPos ;
162 return ;
163 }
164
165 Int_t relid[4] ;
166
167 Float_t x = 0. ;
168 Float_t z = 0. ;
169
170 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
171
172 AliPHOSDigit * digit ;
173 Int_t iDigit;
174
175 for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
176 digit = (AliPHOSDigit *) fDigitsList[iDigit];
177
178 Float_t xi ;
179 Float_t zi ;
180 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
181 phosgeom->RelPosInModule(relid, xi, zi);
182 x += xi ;
183 z += zi ;
184 }
185
186 x /= fMulDigit ;
187 z /= fMulDigit ;
188
189 fLocPos.SetX(x) ;
190 fLocPos.SetY(0.) ;
191 fLocPos.SetZ(z) ;
192
193 LPos = fLocPos ;
194
195}
196
197//____________________________________________________________________________
198Bool_t AliPHOSPpsdRecPoint::GetUp()
199{
200 Int_t relid[4] ;
201
202 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
203
204 AliPHOSDigit *digit = (AliPHOSDigit *)fDigitsList[0] ;
205
206 phosgeom->AbsToRelNumbering(digit->GetId(),relid);
207 Bool_t up ;
208
209 if((Int_t)TMath::Ceil((Float_t)relid[1]/
210 (phosgeom->GetNumberOfModulesPhi()*phosgeom->GetNumberOfModulesZ())-0.0001 ) > 1)
211 up = kFALSE ;
212 else
213 up = kTRUE ;
214
215 return up ;
216}
217//______________________________________________________________________________
218void AliPHOSPpsdRecPoint::Paint(Option_t *)
219{
220 //*-*-*-*-*-*-*-*-*-*-*Paint this ALiRecPoint as a TMarker with its current attributes*-*-*-*-*-*-*
221 //*-* =============================================
222
223 TVector3 pos(0.,0.,0.) ;
224 GetLocalPosition(pos) ;
225 Coord_t x = pos.X() ;
226 Coord_t y = pos.Z() ;
227 Color_t markercolor = 1 ;
228 Size_t markersize = 1. ;
229 Style_t markerstyle = 2 ;
230 if (GetUp())
231 markerstyle = 3 ;
232
233 if (!gPad->IsBatch()) {
234 gVirtualX->SetMarkerColor(markercolor);
235 gVirtualX->SetMarkerSize (markersize);
236 gVirtualX->SetMarkerStyle(markerstyle);
237 }
238 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize);
239 gPad->PaintPolyMarker(1,&x,&y,"");
240
241
242}
243
244//____________________________________________________________________________
245void AliPHOSPpsdRecPoint::Print(Option_t * option)
246{
247 // Print the digits information
248
249 cout << "AliPHOSPpsdRecPoint: " << endl ;
250
251 AliPHOSDigit * digit ;
252 Int_t iDigit;
253 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
254
255 Float_t xi ;
256 Float_t zi ;
257 Int_t relid[4] ;
258
259 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
260 digit = (AliPHOSDigit *) fDigitsList[iDigit];
261 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
262 phosgeom->RelPosInModule(relid, xi, zi);
263 cout << " Id = " << digit->GetId() ;
264 cout << " Phos mod = " << relid[0] ;
265 cout << " PPSD mod = " << relid[1] ;
266 cout << " x = " << xi ;
267 cout << " z = " << zi ;
268 cout << " Energy = " << digit->GetAmp() << endl ;
269 }
270 cout << " Multiplicity = " << fMulDigit << endl ;
271}
272
273