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