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