A lot of changes here:
[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"
c4073cad 37#include "AliPHOSCpvRecPoint.h"
d15a28e7 38#include "AliRun.h"
7b7c1533 39#include "AliPHOSGetter.h"
d15a28e7 40
41ClassImp(AliPHOSPpsdRecPoint)
42
43//____________________________________________________________________________
44AliPHOSPpsdRecPoint::AliPHOSPpsdRecPoint(void)
45{
b2a60966 46 // ctor
47
d15a28e7 48 fMulDigit = 0 ;
d15a28e7 49 fLocPos.SetX(1000000.) ; //Local position should be evaluated
50}
51
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 ;
2731cd1e 78 EvalPHOSMod(&digit) ;
d15a28e7 79}
80
d15a28e7 81//____________________________________________________________________________
2a941f4e 82Int_t AliPHOSPpsdRecPoint::Compare(const TObject * obj) const
d15a28e7 83{
b2a60966 84 // Compares according to the position
2731cd1e 85 Float_t delta = 1 ; //width of the "Sorting row"
86
d15a28e7 87 Int_t rv ;
88
c4073cad 89 if( (strcmp(obj->ClassName() , "AliPHOSPpsdRecPoint" )) == 0) // PPSD Rec Point
90 {
91 AliPHOSPpsdRecPoint * clu = (AliPHOSPpsdRecPoint *)obj ;
92
2731cd1e 93 Float_t x1 , z1 ; //This rec point
94 Float_t x2 , z2 ; //
c4073cad 95
96 Int_t phosmod1 ;
97 Int_t phosmod2 ;
98
99 Int_t up1 ;
100 Int_t up2 ;
d15a28e7 101
c4073cad 102 if(GetUp()) // upper layer
103 up1 = 0 ;
104 else // lower layer
105 up1 = 1 ;
106
107 if(clu->GetUp()) // upper layer
108 up2 = 0 ;
109 else // lower layer
110 up2 = 1 ;
111
112 TVector3 posloc ;
2731cd1e 113 GetLocalPosition(posloc) ;
c4073cad 114 x1 = posloc.X() ;
115 z1 = posloc.Z() ;
2731cd1e 116 phosmod1 = GetPHOSMod();
c4073cad 117 clu->GetLocalPosition(posloc) ;
118 x2 = posloc.X() ;
119 z2 = posloc.Z() ;
120 phosmod2 = clu->GetPHOSMod();
121
122 if(phosmod1 == phosmod2 ) {
123
124 if(up1 == up2 ){
2731cd1e 125 Int_t rowdif = (Int_t)TMath::Ceil(x1/delta) - (Int_t) TMath::Ceil(x2/delta) ;
c4073cad 126
127 if (rowdif> 0)
2731cd1e 128 rv = 1 ;
129 else if(rowdif < 0)
c4073cad 130 rv = -1 ;
c4073cad 131 else if(z1>z2)
132 rv = -1 ;
133 else
134 rv = 1 ;
135 }
136
137 else {
138
139 if(up1 < up2 ) // Upper level first (up = True or False, True > False)
2731cd1e 140 rv = -1 ;
c4073cad 141 else
2731cd1e 142 rv = 1 ;
c4073cad 143 }
144
145 } // if phosmod1 == phosmod2
146
147 else {
148
149 if(phosmod1 < phosmod2 )
150 rv = -1 ;
151 else
152 rv = 1 ;
153
154 }
155
156 return rv ;
d15a28e7 157 }
c4073cad 158 else
159 {
160 AliPHOSCpvRecPoint * clu = (AliPHOSCpvRecPoint *) obj ;
2731cd1e 161 if(GetPHOSMod() < clu->GetPHOSMod() )
c4073cad 162 rv = -1 ;
d15a28e7 163 else
c4073cad 164 rv = 1 ;
165 return rv ;
d15a28e7 166 }
d15a28e7 167
d15a28e7 168
d15a28e7 169}
170
171//____________________________________________________________________________
a4e98857 172void AliPHOSPpsdRecPoint::EvalAll(Float_t logWeight,TClonesArray * digits )
173{
174 // calculates all the characteristics of the RecPoint
2731cd1e 175 AliPHOSRecPoint::EvalAll(logWeight,digits) ;
176 EvalLocalPosition(logWeight,digits) ;
177 EvalUp(digits) ;
ad8cfaf4 178}
179
180//____________________________________________________________________________
2731cd1e 181void AliPHOSPpsdRecPoint::EvalLocalPosition(Float_t logWeight,TClonesArray * digits )
b2a60966 182{
a4e98857 183 // Calculates the local position in the PHOS-PPSD-module coordinates
b2a60966 184
d15a28e7 185 Int_t relid[4] ;
186
187 Float_t x = 0. ;
188 Float_t z = 0. ;
189
7b7c1533 190 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
191 AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
d15a28e7 192
193 AliPHOSDigit * digit ;
194 Int_t iDigit;
195
6ad0bfa0 196 for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
2731cd1e 197 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
d15a28e7 198
199 Float_t xi ;
200 Float_t zi ;
92862013 201 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
202 phosgeom->RelPosInModule(relid, xi, zi);
d15a28e7 203 x += xi ;
204 z += zi ;
205 }
206
6ad0bfa0 207 x /= fMulDigit ;
208 z /= fMulDigit ;
d15a28e7 209
210 fLocPos.SetX(x) ;
211 fLocPos.SetY(0.) ;
212 fLocPos.SetZ(z) ;
213
d15a28e7 214}
215
216//____________________________________________________________________________
2731cd1e 217void AliPHOSPpsdRecPoint::EvalUp(TClonesArray * digits)
d15a28e7 218{
6c370def 219 // Are we in the uper PPSD module ?
220
d15a28e7 221 Int_t relid[4] ;
222
7b7c1533 223 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
224 AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
d15a28e7 225
83974468 226
2731cd1e 227 AliPHOSDigit *digit = (AliPHOSDigit *) digits->At(fDigitsList[0]) ;
d15a28e7 228
92862013 229 phosgeom->AbsToRelNumbering(digit->GetId(),relid);
d15a28e7 230
231 if((Int_t)TMath::Ceil((Float_t)relid[1]/
92862013 232 (phosgeom->GetNumberOfModulesPhi()*phosgeom->GetNumberOfModulesZ())-0.0001 ) > 1)
2731cd1e 233 fUp = kFALSE ;
d15a28e7 234 else
2731cd1e 235 fUp = kTRUE ;
d15a28e7 236
d15a28e7 237}
9f616d61 238//______________________________________________________________________________
239void AliPHOSPpsdRecPoint::Paint(Option_t *)
240{
b2a60966 241 //*-*-*-*-*-*-*-*-*-*-*Paint this ALiRecPoint as a TMarker with its current attributes*-*-*-*-*-*-*
242 //*-* =============================================
243
244 TVector3 pos(0.,0.,0.) ;
245 GetLocalPosition(pos) ;
246 Coord_t x = pos.X() ;
247 Coord_t y = pos.Z() ;
248 Color_t markercolor = 1 ;
249 Size_t markersize = 1. ;
250 Style_t markerstyle = 2 ;
251 if (GetUp())
252 markerstyle = 3 ;
253
254 if (!gPad->IsBatch()) {
255 gVirtualX->SetMarkerColor(markercolor);
256 gVirtualX->SetMarkerSize (markersize);
257 gVirtualX->SetMarkerStyle(markerstyle);
258 }
259 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize);
260 gPad->PaintPolyMarker(1,&x,&y,"");
261
262
9f616d61 263}
d15a28e7 264
265//____________________________________________________________________________
266void AliPHOSPpsdRecPoint::Print(Option_t * option)
267{
b2a60966 268 // Print the digits information
269
d15a28e7 270 cout << "AliPHOSPpsdRecPoint: " << endl ;
271
2731cd1e 272 Int_t iDigit;
273 cout << " Digit{s} # " ;
274 for(iDigit=0; iDigit<fMulDigit; iDigit++)
275 cout << fDigitsList[iDigit] << " " ;
276 cout << endl ;
277
d15a28e7 278 cout << " Multiplicity = " << fMulDigit << endl ;
83974468 279 cout << " Stored at position " << fIndexInList << endl ;
d15a28e7 280}
281
282