]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSPpsdRecPoint.cxx
Removed global's to comply with Coding Conventions
[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
b2a60966 16/* $Id$ */
17
d15a28e7 18//_________________________________________________________________________
b2a60966 19// A RecPoint (cluster) in the PPSD
20// A PPSD RecPoint ends up to be a single digit
21//
22//*-- Yves Schutz (SUBATECH)
d15a28e7 23
24// --- ROOT system ---
b2a60966 25
9f616d61 26#include "TPad.h"
b2a60966 27
d15a28e7 28// --- Standard library ---
29
de9ec31b 30#include <iostream.h>
d15a28e7 31
32// --- AliRoot header files ---
33
34#include "AliPHOSGeometry.h"
35#include "AliPHOSPpsdRecPoint.h"
36#include "AliRun.h"
83974468 37#include "AliPHOSIndexToObject.h"
d15a28e7 38
39ClassImp(AliPHOSPpsdRecPoint)
40
41//____________________________________________________________________________
42AliPHOSPpsdRecPoint::AliPHOSPpsdRecPoint(void)
43{
b2a60966 44 // ctor
45
d15a28e7 46 fMulDigit = 0 ;
47 AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ;
48 fDelta = geom->GetCrystalSize(0) ;
49 fLocPos.SetX(1000000.) ; //Local position should be evaluated
50}
51
d15a28e7 52//____________________________________________________________________________
83974468 53void AliPHOSPpsdRecPoint::AddDigit(AliPHOSDigit & digit, Float_t Energy)
d15a28e7 54{
55 // adds a digit to the digits list
56 // and accumulates the total amplitude and the multiplicity
57
58
59 if ( fMulDigit >= fMaxDigit ) { // increase the size of the lists
9f616d61 60 fMaxDigit*=2 ;
61 int * tempo = new ( int[fMaxDigit] ) ;
d15a28e7 62 Int_t index ;
63
64 for ( index = 0 ; index < fMulDigit ; index++ )
65 tempo[index] = fDigitsList[index] ;
66
9f616d61 67 delete [] fDigitsList ;
68 fDigitsList = new ( int[fMaxDigit] ) ;
69
70 for ( index = 0 ; index < fMulDigit ; index++ )
71 fDigitsList[index] = tempo[index] ;
72
73 delete [] tempo ;
d15a28e7 74 }
9f616d61 75
83974468 76 fDigitsList[fMulDigit++] = digit.GetIndexInList() ;
d15a28e7 77 fAmp += Energy ;
78}
79
d15a28e7 80//____________________________________________________________________________
81Int_t AliPHOSPpsdRecPoint::Compare(TObject * obj)
82{
b2a60966 83 // Compares according to the position
84
d15a28e7 85 Int_t rv ;
86
87 AliPHOSPpsdRecPoint * clu = (AliPHOSPpsdRecPoint *)obj ;
88
89
90 Float_t x1 , z1 ;
91 Float_t x2 , z2 ;
92
92862013 93 Int_t phosmod1 ;
94 Int_t phosmod2 ;
d15a28e7 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
92862013 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 ) {
d15a28e7 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
92862013 142 } // if phosmod1 == phosmod2
d15a28e7 143
144 else {
145
92862013 146 if(phosmod1 < phosmod2 )
d15a28e7 147 rv = -1 ;
148 else
149 rv = 1 ;
150
151}
152
153 return rv ;
154}
155
156//____________________________________________________________________________
b2a60966 157void AliPHOSPpsdRecPoint::GetLocalPosition(TVector3 &LPos)
158{
159 // Calculates the local position in the PHOS-PPSD-module corrdinates
160
83974468 161 AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ;
162
d15a28e7 163 if( fLocPos.X() < 1000000.) { //allready evaluated
164 LPos = fLocPos ;
165 return ;
166 }
167
168 Int_t relid[4] ;
169
170 Float_t x = 0. ;
171 Float_t z = 0. ;
172
92862013 173 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
d15a28e7 174
175 AliPHOSDigit * digit ;
176 Int_t iDigit;
177
6ad0bfa0 178 for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
83974468 179 digit = (AliPHOSDigit *) ( please->GimeDigit(fDigitsList[iDigit]) );
d15a28e7 180
181 Float_t xi ;
182 Float_t zi ;
92862013 183 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
184 phosgeom->RelPosInModule(relid, xi, zi);
d15a28e7 185 x += xi ;
186 z += zi ;
187 }
188
6ad0bfa0 189 x /= fMulDigit ;
190 z /= fMulDigit ;
d15a28e7 191
192 fLocPos.SetX(x) ;
193 fLocPos.SetY(0.) ;
194 fLocPos.SetZ(z) ;
195
196 LPos = fLocPos ;
6ad0bfa0 197
d15a28e7 198}
199
200//____________________________________________________________________________
201Bool_t AliPHOSPpsdRecPoint::GetUp()
202{
203 Int_t relid[4] ;
204
83974468 205 AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ;
206
92862013 207 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
d15a28e7 208
83974468 209
210 AliPHOSDigit *digit = (AliPHOSDigit *) ( please->GimeDigit(fDigitsList[0]) ) ;
d15a28e7 211
92862013 212 phosgeom->AbsToRelNumbering(digit->GetId(),relid);
d15a28e7 213 Bool_t up ;
214
215 if((Int_t)TMath::Ceil((Float_t)relid[1]/
92862013 216 (phosgeom->GetNumberOfModulesPhi()*phosgeom->GetNumberOfModulesZ())-0.0001 ) > 1)
d15a28e7 217 up = kFALSE ;
218 else
219 up = kTRUE ;
220
221 return up ;
222}
9f616d61 223//______________________________________________________________________________
224void AliPHOSPpsdRecPoint::Paint(Option_t *)
225{
b2a60966 226 //*-*-*-*-*-*-*-*-*-*-*Paint this ALiRecPoint as a TMarker with its current attributes*-*-*-*-*-*-*
227 //*-* =============================================
228
229 TVector3 pos(0.,0.,0.) ;
230 GetLocalPosition(pos) ;
231 Coord_t x = pos.X() ;
232 Coord_t y = pos.Z() ;
233 Color_t markercolor = 1 ;
234 Size_t markersize = 1. ;
235 Style_t markerstyle = 2 ;
236 if (GetUp())
237 markerstyle = 3 ;
238
239 if (!gPad->IsBatch()) {
240 gVirtualX->SetMarkerColor(markercolor);
241 gVirtualX->SetMarkerSize (markersize);
242 gVirtualX->SetMarkerStyle(markerstyle);
243 }
244 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize);
245 gPad->PaintPolyMarker(1,&x,&y,"");
246
247
9f616d61 248}
d15a28e7 249
250//____________________________________________________________________________
251void AliPHOSPpsdRecPoint::Print(Option_t * option)
252{
b2a60966 253 // Print the digits information
254
d15a28e7 255 cout << "AliPHOSPpsdRecPoint: " << endl ;
256
257 AliPHOSDigit * digit ;
d15a28e7 258 Int_t iDigit;
92862013 259 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
9f616d61 260
261 Float_t xi ;
262 Float_t zi ;
263 Int_t relid[4] ;
d15a28e7 264
83974468 265 AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ;
d15a28e7 266 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
83974468 267 digit = please->GimeDigit( fDigitsList[iDigit] ) ;
268 if (digit) {
269 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
270 phosgeom->RelPosInModule(relid, xi, zi);
271 cout << " Id = " << digit->GetId() ;
272 cout << " Phos mod = " << relid[0] ;
273 cout << " PPSD mod = " << relid[1] ;
274 cout << " x = " << xi ;
275 cout << " z = " << zi ;
276 cout << " Energy = " << digit->GetAmp() << endl ;
277 }
d15a28e7 278 }
279 cout << " Multiplicity = " << fMulDigit << endl ;
83974468 280 cout << " Stored at position " << fIndexInList << endl ;
d15a28e7 281}
282
283