Default branch name set to Default; Reading of TreeR delegated to AliPHOSGetter;...
[u/mrichter/AliRoot.git] / PHOS / AliPHOSRecPoint.cxx
... / ...
CommitLineData
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 PHOS 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 ---
28#include <iostream.h>
29#include <stdio.h>
30
31// --- AliRoot header files ---
32
33#include "AliPHOSGeometry.h"
34#include "AliPHOSDigit.h"
35#include "AliPHOSRecPoint.h"
36#include "AliPHOSGetter.h"
37
38ClassImp(AliPHOSRecPoint)
39
40
41//____________________________________________________________________________
42AliPHOSRecPoint::AliPHOSRecPoint()
43 : AliRecPoint()
44{
45 // ctor
46
47 fMaxTrack = 200 ;
48 fPHOSMod = 0;
49 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
50 fGeom = (AliPHOSGeometry*)gime->PHOSGeometry();
51}
52
53//____________________________________________________________________________
54Int_t AliPHOSRecPoint::DistancetoPrimitive(Int_t px, Int_t py)
55{
56 // Compute distance from point px,py to a AliPHOSRecPoint considered as a Tmarker
57 // Compute the closest distance of approach from point px,py to this marker.
58 // The distance is computed in pixels units.
59
60 TVector3 pos(0.,0.,0.) ;
61 GetLocalPosition( pos) ;
62 Float_t x = pos.X() ;
63 Float_t y = pos.Z() ;
64 const Int_t kMaxDiff = 10;
65 Int_t pxm = gPad->XtoAbsPixel(x);
66 Int_t pym = gPad->YtoAbsPixel(y);
67 Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
68
69 if (dist > kMaxDiff) return 9999;
70 return dist;
71}
72
73//___________________________________________________________________________
74 void AliPHOSRecPoint::Draw(Option_t *option)
75 {
76 // Draw this AliPHOSRecPoint with its current attributes
77
78 AppendPad(option);
79 }
80
81//______________________________________________________________________________
82void AliPHOSRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py)
83{
84 // Execute action corresponding to one event
85 // This member function is called when a AliPHOSRecPoint is clicked with the locator
86 //
87 // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
88 // and switched off when the mouse button is released.
89
90 // static Int_t pxold, pyold;
91
92 static TGraph * digitgraph = 0 ;
93 static TPaveText* clustertext = 0 ;
94
95 if (!gPad->IsEditable()) return;
96
97 switch (event) {
98
99
100 case kButton1Down:{
101 AliPHOSDigit * digit ;
102 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
103 AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
104
105 Int_t iDigit;
106 Int_t relid[4] ;
107
108 const Int_t kMulDigit=AliPHOSRecPoint::GetDigitsMultiplicity() ;
109 Float_t * xi = new Float_t [kMulDigit] ;
110 Float_t * zi = new Float_t [kMulDigit] ;
111
112 for(iDigit = 0; iDigit < kMulDigit; iDigit++) {
113 digit = (AliPHOSDigit *) fDigitsList[iDigit];
114 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
115 phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]) ;
116 }
117
118 if (!digitgraph) {
119 digitgraph = new TGraph(fMulDigit,xi,zi);
120 digitgraph-> SetMarkerStyle(5) ;
121 digitgraph-> SetMarkerSize(1.) ;
122 digitgraph-> SetMarkerColor(1) ;
123 digitgraph-> Draw("P") ;
124 }
125 if (!clustertext) {
126
127 TVector3 pos(0.,0.,0.) ;
128 GetLocalPosition(pos) ;
129 clustertext = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+50,pos.Z()+35,"") ;
130 Text_t line1[40] ;
131 Text_t line2[40] ;
132 sprintf(line1,"Energy=%1.2f GeV",GetEnergy()) ;
133 sprintf(line2,"%d Digits",GetDigitsMultiplicity()) ;
134 clustertext ->AddText(line1) ;
135 clustertext ->AddText(line2) ;
136 clustertext ->Draw("");
137 }
138 gPad->Update() ;
139 Print() ;
140 delete[] xi ;
141 delete[] zi ;
142 }
143
144break;
145
146 case kButton1Up:
147 if (digitgraph) {
148 delete digitgraph ;
149 digitgraph = 0 ;
150 }
151 if (clustertext) {
152 delete clustertext ;
153 clustertext = 0 ;
154 }
155
156 break;
157
158 }
159}
160//____________________________________________________________________________
161void AliPHOSRecPoint::EvalAll(Float_t logWeight,TClonesArray * digits) {
162 //evaluates (if necessary) all RecPoint data members
163
164 EvalPrimaries(digits) ;
165}
166//____________________________________________________________________________
167void AliPHOSRecPoint::EvalPHOSMod(AliPHOSDigit * digit)
168{
169 // Returns the PHOS module in which the RecPoint is found
170
171 if( fPHOSMod == 0){
172 Int_t relid[4] ;
173
174 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
175 AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
176
177 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
178 fPHOSMod = relid[0];
179 }
180}
181
182//______________________________________________________________________________
183void AliPHOSRecPoint::EvalPrimaries(TClonesArray * digits)
184{
185 // Constructs the list of primary particles (tracks) which have contributed to this RecPoint
186
187 AliPHOSDigit * digit ;
188 Int_t * tempo = new Int_t[fMaxTrack] ;
189
190 Int_t index ;
191 for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits
192 digit = (AliPHOSDigit *) digits->At( fDigitsList[index] ) ;
193 Int_t nprimaries = digit->GetNprimary() ;
194 Int_t * newprimaryarray = new Int_t[nprimaries] ;
195 Int_t ii ;
196 for ( ii = 0 ; ii < nprimaries ; ii++)
197 newprimaryarray[ii] = digit->GetPrimary(ii+1) ;
198
199 Int_t jndex ;
200 for ( jndex = 0 ; jndex < nprimaries ; jndex++ ) { // all primaries in digit
201 if ( fMulTrack > fMaxTrack ) {
202 fMulTrack = - 1 ;
203 cout << "AliPHOSRecPoint::GetNprimaries ERROR > increase fMaxTrack " << endl ;
204 break ;
205 }
206 Int_t newprimary = newprimaryarray[jndex] ;
207 Int_t kndex ;
208 Bool_t already = kFALSE ;
209 for ( kndex = 0 ; kndex < fMulTrack ; kndex++ ) { //check if not already stored
210 if ( newprimary == tempo[kndex] ){
211 already = kTRUE ;
212 break ;
213 }
214 } // end of check
215 if ( !already) { // store it
216 tempo[fMulTrack] = newprimary ;
217 fMulTrack++ ;
218 } // store it
219 } // all primaries in digit
220 delete newprimaryarray ;
221 } // all digits
222
223
224 fTracksList = new Int_t[fMulTrack] ;
225 for(index = 0; index < fMulTrack; index++)
226 fTracksList[index] = tempo[index] ;
227
228 delete tempo ;
229
230}
231
232//______________________________________________________________________________
233void AliPHOSRecPoint::Paint(Option_t *)
234{
235 // Paint this ALiRecPoint as a TMarker with its current attributes
236
237 TVector3 pos(0.,0.,0.) ;
238 GetLocalPosition(pos) ;
239 Coord_t x = pos.X() ;
240 Coord_t y = pos.Z() ;
241 Color_t markercolor = 1 ;
242 Size_t markersize = 1. ;
243 Style_t markerstyle = 5 ;
244
245 if (!gPad->IsBatch()) {
246 gVirtualX->SetMarkerColor(markercolor) ;
247 gVirtualX->SetMarkerSize (markersize) ;
248 gVirtualX->SetMarkerStyle(markerstyle) ;
249 }
250 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
251 gPad->PaintPolyMarker(1,&x,&y,"") ;
252}