]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSPpsdRecPoint.cxx
The web becomes richer
[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
9f616d61 30#include <iostream>
d15a28e7 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{
b2a60966 43 // ctor
44
d15a28e7 45 fMulDigit = 0 ;
46 AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ;
47 fDelta = geom->GetCrystalSize(0) ;
48 fLocPos.SetX(1000000.) ; //Local position should be evaluated
49}
50
d15a28e7 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
d15a28e7 79//____________________________________________________________________________
80Int_t AliPHOSPpsdRecPoint::Compare(TObject * obj)
81{
b2a60966 82 // Compares according to the position
83
d15a28e7 84 Int_t rv ;
85
86 AliPHOSPpsdRecPoint * clu = (AliPHOSPpsdRecPoint *)obj ;
87
88
89 Float_t x1 , z1 ;
90 Float_t x2 , z2 ;
91
92862013 92 Int_t phosmod1 ;
93 Int_t phosmod2 ;
d15a28e7 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
92862013 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 ) {
d15a28e7 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
92862013 141 } // if phosmod1 == phosmod2
d15a28e7 142
143 else {
144
92862013 145 if(phosmod1 < phosmod2 )
d15a28e7 146 rv = -1 ;
147 else
148 rv = 1 ;
149
150}
151
152 return rv ;
153}
154
155//____________________________________________________________________________
b2a60966 156void AliPHOSPpsdRecPoint::GetLocalPosition(TVector3 &LPos)
157{
158 // Calculates the local position in the PHOS-PPSD-module corrdinates
159
d15a28e7 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
92862013 170 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
d15a28e7 171
172 AliPHOSDigit * digit ;
173 Int_t iDigit;
174
6ad0bfa0 175 for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
d15a28e7 176 digit = (AliPHOSDigit *) fDigitsList[iDigit];
177
178 Float_t xi ;
179 Float_t zi ;
92862013 180 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
181 phosgeom->RelPosInModule(relid, xi, zi);
d15a28e7 182 x += xi ;
183 z += zi ;
184 }
185
6ad0bfa0 186 x /= fMulDigit ;
187 z /= fMulDigit ;
d15a28e7 188
189 fLocPos.SetX(x) ;
190 fLocPos.SetY(0.) ;
191 fLocPos.SetZ(z) ;
192
193 LPos = fLocPos ;
6ad0bfa0 194
d15a28e7 195}
196
197//____________________________________________________________________________
198Bool_t AliPHOSPpsdRecPoint::GetUp()
199{
200 Int_t relid[4] ;
201
92862013 202 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
d15a28e7 203
204 AliPHOSDigit *digit = (AliPHOSDigit *)fDigitsList[0] ;
205
92862013 206 phosgeom->AbsToRelNumbering(digit->GetId(),relid);
d15a28e7 207 Bool_t up ;
208
209 if((Int_t)TMath::Ceil((Float_t)relid[1]/
92862013 210 (phosgeom->GetNumberOfModulesPhi()*phosgeom->GetNumberOfModulesZ())-0.0001 ) > 1)
d15a28e7 211 up = kFALSE ;
212 else
213 up = kTRUE ;
214
215 return up ;
216}
9f616d61 217//______________________________________________________________________________
218void AliPHOSPpsdRecPoint::Paint(Option_t *)
219{
b2a60966 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
9f616d61 242}
d15a28e7 243
244//____________________________________________________________________________
245void AliPHOSPpsdRecPoint::Print(Option_t * option)
246{
b2a60966 247 // Print the digits information
248
d15a28e7 249 cout << "AliPHOSPpsdRecPoint: " << endl ;
250
251 AliPHOSDigit * digit ;
d15a28e7 252 Int_t iDigit;
92862013 253 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
9f616d61 254
255 Float_t xi ;
256 Float_t zi ;
257 Int_t relid[4] ;
d15a28e7 258
259 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
260 digit = (AliPHOSDigit *) fDigitsList[iDigit];
92862013 261 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
262 phosgeom->RelPosInModule(relid, xi, zi);
9f616d61 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 ;
d15a28e7 269 }
270 cout << " Multiplicity = " << fMulDigit << endl ;
271}
272
273