]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALRecPoint.cxx
method RectGeomCellPos in float is added
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALRecPoint.cxx
CommitLineData
ab48128d 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/* $Id$ */
16//_________________________________________________________________________
17// Base Class for EMCAL Reconstructed Points
18// Why should I put meaningless comments
19// just to satisfy
20// the code checker
21//*-- Author: Gines Martinez (SUBATECH)
22
23// --- ROOT system ---
24#include "TPad.h"
25#include "TClonesArray.h"
26
27// --- Standard library ---
ab48128d 28
29// --- AliRoot header files ---
30
31#include "AliEMCALGeometry.h"
32#include "AliEMCALDigit.h"
33#include "AliEMCALRecPoint.h"
34#include "AliEMCALGetter.h"
35
36ClassImp(AliEMCALRecPoint)
37
38
39//____________________________________________________________________________
40AliEMCALRecPoint::AliEMCALRecPoint()
41 : AliRecPoint()
42{
43 // ctor
44
692088ae 45 fMaxTrack = 0 ;
ab48128d 46 fTheta = fPhi = 0. ;
692088ae 47 fEMCALArm = 0;
88cb7938 48 fPRESection = fECASection = fHCASection = kFALSE ;
ab48128d 49}
50
51//____________________________________________________________________________
52AliEMCALRecPoint::AliEMCALRecPoint(const char * opt) : AliRecPoint(opt)
53{
54 // ctor
55
56 fMaxTrack = 200 ;
57 fTheta = fPhi = 0. ;
58 fEMCALArm = 1;
59
60}
61
62//____________________________________________________________________________
63Int_t AliEMCALRecPoint::DistancetoPrimitive(Int_t px, Int_t py)
64{
65 // Compute distance from point px,py to a AliEMCALRecPoint considered as a Tmarker
66 // Compute the closest distance of approach from point px,py to this marker.
67 // The distance is computed in pixels units.
68
69 TVector3 pos(0.,0.,0.) ;
70 GetLocalPosition( pos) ;
71 Float_t x = pos.X() ;
72 Float_t y = pos.Z() ;
73 const Int_t kMaxDiff = 10;
74 Int_t pxm = gPad->XtoAbsPixel(x);
75 Int_t pym = gPad->YtoAbsPixel(y);
76 Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
77
78 if (dist > kMaxDiff) return 9999;
79 return dist;
80}
81
82//___________________________________________________________________________
83 void AliEMCALRecPoint::Draw(Option_t *option)
84 {
85 // Draw this AliEMCALRecPoint with its current attributes
86
87 AppendPad(option);
88 }
89
90//______________________________________________________________________________
91void AliEMCALRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py)
92{
93 // Execute action corresponding to one event
94 // This member function is called when a AliEMCALRecPoint is clicked with the locator
95 //
96 // If Left button is clicked on AliEMCALRecPoint, the digits are switched on
97 // and switched off when the mouse button is released.
98
99 // static Int_t pxold, pyold;
100
101 static TGraph * digitgraph = 0 ;
102 static TPaveText* clustertext = 0 ;
103
104 if (!gPad->IsEditable()) return;
105
106 switch (event) {
107
108
109 case kButton1Down:{
110 AliEMCALDigit * digit ;
88cb7938 111 AliEMCALGeometry * emcalgeom = (AliEMCALGetter::Instance())->EMCALGeometry() ;
ab48128d 112
113 Int_t iDigit;
114 Int_t relid[4] ;
115
116 const Int_t kMulDigit=AliEMCALRecPoint::GetDigitsMultiplicity() ;
117 Float_t * xi = new Float_t [kMulDigit] ;
118 Float_t * zi = new Float_t [kMulDigit] ;
119
120 for(iDigit = 0; iDigit < kMulDigit; iDigit++) {
121 Fatal("AliEMCALRecPoint::ExecuteEvent", " -> Something wrong with the code");
122 digit = 0 ; //dynamic_cast<AliEMCALDigit *>((fDigitsList)[iDigit]);
123 emcalgeom->AbsToRelNumbering(digit->GetId(), relid) ;
124 emcalgeom->PosInAlice(relid, xi[iDigit], zi[iDigit]) ;
125 }
126
127 if (!digitgraph) {
128 digitgraph = new TGraph(fMulDigit,xi,zi);
129 digitgraph-> SetMarkerStyle(5) ;
130 digitgraph-> SetMarkerSize(1.) ;
131 digitgraph-> SetMarkerColor(1) ;
132 digitgraph-> Draw("P") ;
133 }
134 if (!clustertext) {
135
136 TVector3 pos(0.,0.,0.) ;
137 GetLocalPosition(pos) ;
138 clustertext = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+50,pos.Z()+35,"") ;
139 Text_t line1[40] ;
140 Text_t line2[40] ;
141 sprintf(line1,"Energy=%1.2f GeV",GetEnergy()) ;
142 sprintf(line2,"%d Digits",GetDigitsMultiplicity()) ;
143 clustertext ->AddText(line1) ;
144 clustertext ->AddText(line2) ;
145 clustertext ->Draw("");
146 }
147 gPad->Update() ;
148 Print() ;
149 delete[] xi ;
150 delete[] zi ;
151 }
152
153break;
154
155 case kButton1Up:
156 if (digitgraph) {
157 delete digitgraph ;
158 digitgraph = 0 ;
159 }
160 if (clustertext) {
161 delete clustertext ;
162 clustertext = 0 ;
163 }
164
165 break;
166
167 }
168}
169//____________________________________________________________________________
88cb7938 170void AliEMCALRecPoint::EvalAll(Float_t logWeight,TClonesArray * digits)
171{
ab48128d 172 //evaluates (if necessary) all RecPoint data members
173
174 EvalPrimaries(digits) ;
175}
176
177//____________________________________________________________________________
178void AliEMCALRecPoint::EvalEMCALArm(AliEMCALDigit * digit)
179{
180 // Returns the EMCAL module in which the RecPoint is found
181
182
183 if( fEMCALArm == 0){
184 Int_t relid[4] ;
185
88cb7938 186 AliEMCALGeometry * emcalgeom = (AliEMCALGetter::Instance())->EMCALGeometry();
ab48128d 187
188 emcalgeom->AbsToRelNumbering(digit->GetId(), relid) ;
189 fEMCALArm = relid[0];
190 }
191}
192
193//______________________________________________________________________________
194void AliEMCALRecPoint::EvalPrimaries(TClonesArray * digits)
195{
196 // Constructs the list of primary particles (tracks) which have contributed to this RecPoint
197
198 AliEMCALDigit * digit ;
199 Int_t * tempo = new Int_t[fMaxTrack] ;
200
201 Int_t index ;
202 for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits
203 digit = dynamic_cast<AliEMCALDigit *>(digits->At( fDigitsList[index] )) ;
204 Int_t nprimaries = digit->GetNprimary() ;
205 Int_t * newprimaryarray = new Int_t[nprimaries] ;
206 Int_t ii ;
207 for ( ii = 0 ; ii < nprimaries ; ii++)
208 newprimaryarray[ii] = digit->GetPrimary(ii+1) ;
209
210 Int_t jndex ;
211 for ( jndex = 0 ; jndex < nprimaries ; jndex++ ) { // all primaries in digit
212 if ( fMulTrack > fMaxTrack ) {
213 fMulTrack = - 1 ;
9859bfc0 214 Error("GetNprimaries", "increase fMaxTrack ") ;
ab48128d 215 break ;
216 }
217 Int_t newprimary = newprimaryarray[jndex] ;
218 Int_t kndex ;
219 Bool_t already = kFALSE ;
220 for ( kndex = 0 ; kndex < fMulTrack ; kndex++ ) { //check if not already stored
221 if ( newprimary == tempo[kndex] ){
222 already = kTRUE ;
223 break ;
224 }
225 } // end of check
226 if ( !already) { // store it
227 tempo[fMulTrack] = newprimary ;
228 fMulTrack++ ;
229 } // store it
230 } // all primaries in digit
231 delete newprimaryarray ;
232 } // all digits
233
234
235 fTracksList = new Int_t[fMulTrack] ;
236 for(index = 0; index < fMulTrack; index++)
237 fTracksList[index] = tempo[index] ;
238
239 delete tempo ;
240
241}
7ee5c5be 242
ab48128d 243//____________________________________________________________________________
244void AliEMCALRecPoint::GetGlobalPosition(TVector3 & gpos) const
245{
246 // returns the position of the cluster in the global reference system of ALICE
ab48128d 247
88cb7938 248 AliEMCALGeometry * emcalgeom = AliEMCALGetter::Instance()->EMCALGeometry();
ab48128d 249 gpos.SetX(fPhi) ;
88cb7938 250 if ( IsInECA() )
251 gpos.SetY(emcalgeom->GetIP2ECASection()) ;
aad8e277 252 else if ( IsInPRE() )
253 gpos.SetY(emcalgeom->GetIP2PRESection()) ;
88cb7938 254 else if ( IsInHCA() )
255 gpos.SetY(emcalgeom->GetIP2HCASection()) ;
7ee5c5be 256 else
aad8e277 257 Fatal("GetGlobalPosition", "Unexpected tower section") ;
ab48128d 258 gpos.SetZ(fTheta) ;
ab48128d 259}
260
aad8e277 261//____________________________________________________________________________
262void AliEMCALRecPoint::GetLocalPosition(TVector3 & lpos) const
263{
264 // returns the position of the cluster in the global reference system of ALICE
265
266 lpos.SetX(fLocPos.X()) ;
267 lpos.SetY(fLocPos.Y()) ;
268 lpos.SetZ(fLocPos.Z()) ;
269}
ab48128d 270
271//______________________________________________________________________________
272void AliEMCALRecPoint::Paint(Option_t *)
273{
274 // Paint this ALiRecPoint as a TMarker with its current attributes
275
276 TVector3 pos(0.,0.,0.) ;
277 GetLocalPosition(pos) ;
278 Coord_t x = pos.X() ;
279 Coord_t y = pos.Z() ;
280 Color_t markercolor = 1 ;
281 Size_t markersize = 1. ;
282 Style_t markerstyle = 5 ;
283
284 if (!gPad->IsBatch()) {
285 gVirtualX->SetMarkerColor(markercolor) ;
286 gVirtualX->SetMarkerSize (markersize) ;
287 gVirtualX->SetMarkerStyle(markerstyle) ;
288 }
289 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
290 gPad->PaintPolyMarker(1,&x,&y,"") ;
291}