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