]>
Commit | Line | Data |
---|---|---|
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 | // Base Class for PHOS Reconstructed Points |
2f04ed65 | 18 | // Why should I put meaningless comments |
19 | // just to satisfy | |
20 | // the code checker | |
b2a60966 | 21 | //*-- Author: Gines Martinez (SUBATECH) |
d15a28e7 | 22 | |
23 | // --- ROOT system --- | |
9f616d61 | 24 | #include "TPad.h" |
e957fea8 | 25 | #include "TGraph.h" |
26 | #include "TPaveText.h" | |
2731cd1e | 27 | #include "TClonesArray.h" |
d15a28e7 | 28 | |
29 | // --- Standard library --- | |
30 | ||
31 | // --- AliRoot header files --- | |
32 | ||
33 | #include "AliPHOSGeometry.h" | |
34 | #include "AliPHOSDigit.h" | |
35 | #include "AliPHOSRecPoint.h" | |
7b7c1533 | 36 | #include "AliPHOSGetter.h" |
b48eb81e | 37 | #include "AliGeomManager.h" |
9f616d61 | 38 | |
d15a28e7 | 39 | ClassImp(AliPHOSRecPoint) |
40 | ||
41 | ||
42 | //____________________________________________________________________________ | |
43 | AliPHOSRecPoint::AliPHOSRecPoint() | |
9ee9f78d | 44 | : AliCluster(),fPHOSMod(0), |
45 | fMulTrack(0),fMaxDigit(100),fMulDigit(0),fMaxTrack(0), | |
46 | fDigitsList(0),fTracksList(0),fAmp(0), | |
47 | fIndexInList(-1), // to be set when the point is already stored | |
48 | fLocPos(0,0,0),fLocPosM(0) | |
d15a28e7 | 49 | { |
b2a60966 | 50 | // ctor |
51 | ||
d15a28e7 | 52 | } |
53 | ||
73a68ccb | 54 | //____________________________________________________________________________ |
9ee9f78d | 55 | AliPHOSRecPoint::AliPHOSRecPoint(const char * ) |
56 | : AliCluster(),fPHOSMod(0), | |
57 | fMulTrack(0),fMaxDigit(100),fMulDigit(0),fMaxTrack(200), | |
58 | fDigitsList(new int[fMaxDigit]),fTracksList(new int[fMaxTrack]),fAmp(0), | |
59 | fIndexInList(-1), // to be set when the point is already stored | |
60 | fLocPos(0,0,0),fLocPosM(new TMatrixF(3,3)) | |
61 | ||
73a68ccb | 62 | { |
63 | // ctor | |
64 | ||
55fe9d13 | 65 | } |
9ee9f78d | 66 | //_______________________________________________________________________ |
67 | AliPHOSRecPoint::~AliPHOSRecPoint() | |
68 | { | |
69 | // dtor | |
70 | ||
71 | delete fLocPosM ; | |
72 | delete [] fDigitsList ; | |
73 | delete [] fTracksList ; | |
74 | ||
75 | } | |
76 | //____________________________________________________________________________ | |
77 | AliPHOSRecPoint::AliPHOSRecPoint(const AliPHOSRecPoint &rp) : | |
78 | AliCluster(rp), | |
79 | fPHOSMod(rp.fPHOSMod),fMulTrack(rp.fMulTrack),fMaxDigit(rp.fMaxDigit), | |
80 | fMulDigit(rp.fMulDigit),fMaxTrack(rp.fMaxTrack),fDigitsList(new int[rp.fMaxDigit]), | |
81 | fTracksList(new int[rp.fMaxTrack]),fAmp(rp.fAmp),fIndexInList(rp.fIndexInList), | |
82 | fLocPos(rp.fLocPos),fLocPosM(rp.fLocPosM) | |
83 | { | |
84 | //copy ctor | |
55fe9d13 | 85 | |
9ee9f78d | 86 | for(Int_t i=0; i<fMaxDigit; i++) |
87 | fDigitsList[i] = rp.fDigitsList[i]; | |
88 | ||
89 | for(Int_t i=0; i<fMaxTrack; i++) | |
90 | fTracksList[i] = rp.fTracksList[i]; | |
91 | ||
92 | } | |
93 | //____________________________________________________________________________ | |
94 | AliPHOSRecPoint& AliPHOSRecPoint::operator= (const AliPHOSRecPoint &rp) | |
95 | { | |
96 | if(&rp == this) return *this; | |
97 | ||
98 | fPHOSMod = rp.fPHOSMod; | |
99 | fMulTrack = rp.fMulTrack; | |
100 | fMaxDigit = rp.fMaxDigit; | |
101 | fMulDigit = rp.fMulDigit; | |
102 | fMaxTrack = rp.fMaxTrack; | |
103 | fAmp = rp.fAmp; | |
104 | fIndexInList = rp.fIndexInList; | |
105 | fLocPos = rp.fLocPos; | |
106 | fLocPosM = rp.fLocPosM; | |
107 | ||
108 | for(Int_t i=0; i<fMaxDigit; i++) | |
109 | fDigitsList[i] = rp.fDigitsList[i]; | |
110 | ||
111 | for(Int_t i=0; i<fMaxTrack; i++) | |
112 | fTracksList[i] = rp.fTracksList[i]; | |
113 | ||
114 | return *this; | |
115 | } | |
9f616d61 | 116 | //____________________________________________________________________________ |
117 | Int_t AliPHOSRecPoint::DistancetoPrimitive(Int_t px, Int_t py) | |
118 | { | |
b2a60966 | 119 | // Compute distance from point px,py to a AliPHOSRecPoint considered as a Tmarker |
120 | // Compute the closest distance of approach from point px,py to this marker. | |
121 | // The distance is computed in pixels units. | |
122 | ||
123 | TVector3 pos(0.,0.,0.) ; | |
124 | GetLocalPosition( pos) ; | |
125 | Float_t x = pos.X() ; | |
126 | Float_t y = pos.Z() ; | |
127 | const Int_t kMaxDiff = 10; | |
128 | Int_t pxm = gPad->XtoAbsPixel(x); | |
129 | Int_t pym = gPad->YtoAbsPixel(y); | |
130 | Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym); | |
131 | ||
132 | if (dist > kMaxDiff) return 9999; | |
133 | return dist; | |
9f616d61 | 134 | } |
6ad0bfa0 | 135 | |
9f616d61 | 136 | //___________________________________________________________________________ |
137 | void AliPHOSRecPoint::Draw(Option_t *option) | |
138 | { | |
6ad0bfa0 | 139 | // Draw this AliPHOSRecPoint with its current attributes |
140 | ||
141 | AppendPad(option); | |
9f616d61 | 142 | } |
143 | ||
144 | //______________________________________________________________________________ | |
8f2a3661 | 145 | void AliPHOSRecPoint::ExecuteEvent(Int_t event, Int_t, Int_t) |
9f616d61 | 146 | { |
6ad0bfa0 | 147 | // Execute action corresponding to one event |
148 | // This member function is called when a AliPHOSRecPoint is clicked with the locator | |
149 | // | |
150 | // If Left button is clicked on AliPHOSRecPoint, the digits are switched on | |
151 | // and switched off when the mouse button is released. | |
9f616d61 | 152 | |
153 | // static Int_t pxold, pyold; | |
154 | ||
b2a60966 | 155 | static TGraph * digitgraph = 0 ; |
156 | static TPaveText* clustertext = 0 ; | |
157 | ||
158 | if (!gPad->IsEditable()) return; | |
9f616d61 | 159 | |
b2a60966 | 160 | switch (event) { |
161 | ||
162 | ||
163 | case kButton1Down:{ | |
164 | AliPHOSDigit * digit ; | |
88cb7938 | 165 | |
166 | // Accessing geometry this way is equivalent to getting from gAlice | |
167 | // to have Detector in Folder one have to load gAlice anyway | |
168 | // AliPHOSLoader * gime = AliPHOSLoader::GetInstance(); | |
169 | // AliPHOSGeometry * phosgeom = const_cast<AliPHOSGeometry*>(gime->PHOSGeometry()); | |
170 | ||
171 | AliPHOSGeometry * phosgeom = AliPHOSLoader::GetPHOSGeometry(); | |
7b7c1533 | 172 | |
b2a60966 | 173 | Int_t iDigit; |
174 | Int_t relid[4] ; | |
31aa6d6c | 175 | |
88714635 | 176 | const Int_t kMulDigit=AliPHOSRecPoint::GetDigitsMultiplicity() ; |
177 | Float_t * xi = new Float_t [kMulDigit] ; | |
178 | Float_t * zi = new Float_t [kMulDigit] ; | |
b2a60966 | 179 | |
88714635 | 180 | for(iDigit = 0; iDigit < kMulDigit; iDigit++) { |
4696e514 | 181 | Fatal("AliPHOSRecPoint::ExecuteEvent", "-> Something wrong with the code"); |
7a9d98f9 | 182 | digit = 0 ; //dynamic_cast<AliPHOSDigit *>((fDigitsList)[iDigit]); |
b2a60966 | 183 | phosgeom->AbsToRelNumbering(digit->GetId(), relid) ; |
184 | phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]) ; | |
185 | } | |
186 | ||
187 | if (!digitgraph) { | |
188 | digitgraph = new TGraph(fMulDigit,xi,zi); | |
189 | digitgraph-> SetMarkerStyle(5) ; | |
190 | digitgraph-> SetMarkerSize(1.) ; | |
191 | digitgraph-> SetMarkerColor(1) ; | |
192 | digitgraph-> Draw("P") ; | |
193 | } | |
194 | if (!clustertext) { | |
195 | ||
196 | TVector3 pos(0.,0.,0.) ; | |
197 | GetLocalPosition(pos) ; | |
198 | clustertext = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+50,pos.Z()+35,"") ; | |
199 | Text_t line1[40] ; | |
200 | Text_t line2[40] ; | |
201 | sprintf(line1,"Energy=%1.2f GeV",GetEnergy()) ; | |
202 | sprintf(line2,"%d Digits",GetDigitsMultiplicity()) ; | |
203 | clustertext ->AddText(line1) ; | |
204 | clustertext ->AddText(line2) ; | |
205 | clustertext ->Draw(""); | |
206 | } | |
207 | gPad->Update() ; | |
a8c47ab6 | 208 | Print("dummy") ; |
31aa6d6c | 209 | delete[] xi ; |
210 | delete[] zi ; | |
211 | } | |
b2a60966 | 212 | |
31aa6d6c | 213 | break; |
b2a60966 | 214 | |
215 | case kButton1Up: | |
216 | if (digitgraph) { | |
217 | delete digitgraph ; | |
218 | digitgraph = 0 ; | |
219 | } | |
220 | if (clustertext) { | |
221 | delete clustertext ; | |
222 | clustertext = 0 ; | |
223 | } | |
224 | ||
225 | break; | |
226 | ||
9f616d61 | 227 | } |
9f616d61 | 228 | } |
ad8cfaf4 | 229 | //____________________________________________________________________________ |
e957fea8 | 230 | void AliPHOSRecPoint::EvalAll(TClonesArray * digits) |
88cb7938 | 231 | { |
ad8cfaf4 | 232 | //evaluates (if necessary) all RecPoint data members |
9f616d61 | 233 | |
2731cd1e | 234 | EvalPrimaries(digits) ; |
ad8cfaf4 | 235 | } |
88cb7938 | 236 | |
d15a28e7 | 237 | //____________________________________________________________________________ |
2731cd1e | 238 | void AliPHOSRecPoint::EvalPHOSMod(AliPHOSDigit * digit) |
b2a60966 | 239 | { |
240 | // Returns the PHOS module in which the RecPoint is found | |
83974468 | 241 | |
2731cd1e | 242 | if( fPHOSMod == 0){ |
ad8cfaf4 | 243 | Int_t relid[4] ; |
88cb7938 | 244 | |
245 | AliPHOSGeometry * phosgeom = (AliPHOSGetter::Instance())->PHOSGeometry(); | |
d15a28e7 | 246 | |
92862013 | 247 | phosgeom->AbsToRelNumbering(digit->GetId(), relid) ; |
d15a28e7 | 248 | fPHOSMod = relid[0]; |
2731cd1e | 249 | } |
d15a28e7 | 250 | } |
6ad0bfa0 | 251 | |
cf239357 | 252 | //______________________________________________________________________________ |
2731cd1e | 253 | void AliPHOSRecPoint::EvalPrimaries(TClonesArray * digits) |
cf239357 | 254 | { |
2731cd1e | 255 | // Constructs the list of primary particles (tracks) which have contributed to this RecPoint |
b2a60966 | 256 | |
cf239357 | 257 | AliPHOSDigit * digit ; |
2731cd1e | 258 | Int_t * tempo = new Int_t[fMaxTrack] ; |
259 | ||
260 | Int_t index ; | |
cf239357 | 261 | for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits |
7a9d98f9 | 262 | digit = dynamic_cast<AliPHOSDigit *>(digits->At( fDigitsList[index] )) ; |
88cb7938 | 263 | Int_t nprimaries = digit->GetNprimary() ; |
264 | if(nprimaries){ | |
265 | Int_t * newprimaryarray = new Int_t[nprimaries] ; | |
266 | Int_t ii ; | |
267 | for ( ii = 0 ; ii < nprimaries ; ii++) | |
268 | newprimaryarray[ii] = digit->GetPrimary(ii+1) ; | |
269 | ||
270 | Int_t jndex ; | |
271 | for ( jndex = 0 ; jndex < nprimaries ; jndex++ ) { // all primaries in digit | |
272 | if ( fMulTrack > fMaxTrack ) { | |
273 | fMulTrack = - 1 ; | |
274 | Error("EvalPrimaries", "GetNprimaries ERROR > increase fMaxTrack" ) ; | |
275 | break ; | |
276 | } | |
277 | Int_t newprimary = newprimaryarray[jndex] ; | |
278 | Int_t kndex ; | |
279 | Bool_t already = kFALSE ; | |
280 | for ( kndex = 0 ; kndex < fMulTrack ; kndex++ ) { //check if not already stored | |
281 | if ( newprimary == tempo[kndex] ){ | |
282 | already = kTRUE ; | |
884e9693 | 283 | break ; |
284 | } | |
88cb7938 | 285 | } // end of check |
286 | if ( !already) { // store it | |
287 | tempo[fMulTrack] = newprimary ; | |
288 | fMulTrack++ ; | |
289 | } // store it | |
290 | } // all primaries in digit | |
291 | delete [] newprimaryarray ; | |
884e9693 | 292 | } |
cf239357 | 293 | } // all digits |
294 | ||
884e9693 | 295 | if(fMulTrack) |
296 | fTracksList = new Int_t[fMulTrack] ; | |
2731cd1e | 297 | for(index = 0; index < fMulTrack; index++) |
884e9693 | 298 | fTracksList[index] = tempo[index] ; |
299 | ||
780a31c1 | 300 | delete [] tempo ; |
884e9693 | 301 | |
cf239357 | 302 | } |
4b45b217 | 303 | //____________________________________________________________________________ |
e8d02863 | 304 | void AliPHOSRecPoint::GetGlobalPosition(TVector3 & gpos, TMatrixF & gmat) const |
4b45b217 | 305 | { |
306 | // returns the position of the cluster in the global reference system of ALICE | |
307 | // and the uncertainty on this position | |
9ee9f78d | 308 | |
309 | (AliPHOSGetter::Instance())->PHOSGeometry()->GetGlobalPHOS(this, gpos, gmat); | |
310 | ||
311 | // Float_t xyz[3]; | |
312 | // GetGlobalXYZ(xyz); | |
313 | // gpos.SetXYZ(xyz[0],xyz[1],xyz[2]); | |
314 | ||
315 | ||
4b45b217 | 316 | } |
317 | ||
cf239357 | 318 | |
9f616d61 | 319 | //______________________________________________________________________________ |
320 | void AliPHOSRecPoint::Paint(Option_t *) | |
321 | { | |
b2a60966 | 322 | // Paint this ALiRecPoint as a TMarker with its current attributes |
323 | ||
324 | TVector3 pos(0.,0.,0.) ; | |
325 | GetLocalPosition(pos) ; | |
326 | Coord_t x = pos.X() ; | |
327 | Coord_t y = pos.Z() ; | |
328 | Color_t markercolor = 1 ; | |
329 | Size_t markersize = 1. ; | |
330 | Style_t markerstyle = 5 ; | |
331 | ||
332 | if (!gPad->IsBatch()) { | |
333 | gVirtualX->SetMarkerColor(markercolor) ; | |
334 | gVirtualX->SetMarkerSize (markersize) ; | |
335 | gVirtualX->SetMarkerStyle(markerstyle) ; | |
336 | } | |
337 | gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ; | |
338 | gPad->PaintPolyMarker(1,&x,&y,"") ; | |
9f616d61 | 339 | } |
88cb7938 | 340 | //______________________________________________________________________________ |
9ee9f78d | 341 | void AliPHOSRecPoint::GetLocalPosition(TVector3 & pos) const |
342 | { | |
343 | // returns the position of the cluster in the local reference system | |
344 | // of the sub-detector | |
345 | ||
346 | pos = fLocPos; | |
347 | } | |
b48eb81e | 348 | |
349 | //____________________________________________________________________________ | |
350 | void AliPHOSRecPoint::EvalLocal2TrackingCSTransform() | |
351 | { | |
352 | //Evaluates local to "tracking" c.s. transformation (B.P.). | |
353 | //All evaluations should be completed before calling for this function. | |
354 | //See ALICE PPR Chapter 5 p.18 for "tracking" c.s. definition, | |
355 | //or just ask Jouri Belikov. :) | |
356 | ||
357 | if(IsEmc()) { | |
358 | SetVolumeId(AliGeomManager::LayerToVolUID(AliGeomManager::kPHOS1,GetPHOSMod()-1)); | |
359 | } | |
360 | else | |
361 | return; | |
362 | ||
363 | Double_t lxyz[3] = {fLocPos.X(),0,fLocPos.Z()}; | |
364 | Double_t txyz[3] = {0,0,0}; | |
365 | ||
366 | const TGeoHMatrix* tr2loc = GetTracking2LocalMatrix(); | |
367 | if(!tr2loc) AliFatal(Form("No Tracking2LocalMatrix found.")); | |
368 | ||
369 | tr2loc->MasterToLocal(lxyz,txyz); | |
370 | SetX(0.); SetY(txyz[1]); SetY(txyz[2]); | |
371 | ||
372 | } |