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