]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSTrackSegment.cxx
Implements all the new classes (JB, AM)
[u/mrichter/AliRoot.git] / PHOS / AliPHOSTrackSegment.cxx
CommitLineData
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 **************************************************************************/
15
b2a60966 16/* $Id$ */
17
d15a28e7 18//_________________________________________________________________________
b2a60966 19// Track segment in PHOS
20// Can be : 1 EmcRecPoint
21// 1 EmcRecPoint + 1 PPSD
22// 1 EmcRecPoint + 1 PPSD + 1 PPSD
23//
24//*-- Author: Dmitri Peressounko (RRC KI & SUBATECH)
d15a28e7 25
26// --- ROOT system ---
27
28#include "TVector3.h"
9f616d61 29#include "TPad.h"
d15a28e7 30
31// --- Standard library ---
32
de9ec31b 33#include <iostream.h>
d15a28e7 34
35// --- AliRoot header files ---
36
37#include "AliPHOSTrackSegment.h"
38#include "AliPHOSv0.h"
83974468 39#include "AliPHOSIndexToObject.h"
d15a28e7 40
41ClassImp(AliPHOSTrackSegment)
42
43//____________________________________________________________________________
83974468 44AliPHOSTrackSegment::AliPHOSTrackSegment( AliPHOSEmcRecPoint * emc , AliPHOSPpsdRecPoint * ppsdrp1,
45 AliPHOSPpsdRecPoint * ppsdrp2 )
b2a60966 46{
47 // ctor
48
d15a28e7 49 if( emc )
83974468 50 fEmcRecPoint = emc->GetIndexInList() ;
51 else
52 fEmcRecPoint = -1 ;
d15a28e7 53
83974468 54 if( ppsdrp1 )
55 fPpsdUpRecPoint = ppsdrp1->GetIndexInList() ;
56 else
57 fPpsdUpRecPoint = -1 ;
d15a28e7 58
83974468 59 if( ppsdrp2 )
60 fPpsdLowRecPoint = ppsdrp2->GetIndexInList() ;
61 else
62 fPpsdLowRecPoint = -1 ;
d15a28e7 63
83974468 64 fIndexInList = -1 ;
d15a28e7 65}
66
6ad0bfa0 67//____________________________________________________________________________
68AliPHOSTrackSegment::AliPHOSTrackSegment( const AliPHOSTrackSegment & ts)
69{
b2a60966 70 // Copy ctor
71
c198e326 72 ( (AliPHOSTrackSegment &)ts ).Copy(*this) ;
6ad0bfa0 73}
74
d15a28e7 75
6ad0bfa0 76//____________________________________________________________________________
77void AliPHOSTrackSegment::Copy(TObject & obj)
78{
b2a60966 79 // Copy of a track segment into another track segment
80
6ad0bfa0 81 TObject::Copy(obj) ;
83974468 82 ( (AliPHOSTrackSegment &)obj ).fEmcRecPoint = fEmcRecPoint ;
83 ( (AliPHOSTrackSegment &)obj ).fPpsdLowRecPoint = fPpsdLowRecPoint ;
84 ( (AliPHOSTrackSegment &)obj ).fPpsdUpRecPoint = fPpsdUpRecPoint ;
85 ( (AliPHOSTrackSegment &)obj ).fIndexInList = fIndexInList ;
6ad0bfa0 86}
9f616d61 87//____________________________________________________________________________
88Int_t AliPHOSTrackSegment::DistancetoPrimitive(Int_t px, Int_t py)
89{
b2a60966 90 // Compute distance from point px,py to a AliPHOSTrackSegment considered as a Tmarker
91 // Compute the closest distance of approach from point px,py to this marker.
92 // The distance is computed in pixels units.
93
6ad0bfa0 94 Int_t div = 1 ;
83974468 95 Int_t dist = 9999 ;
96
6ad0bfa0 97 TVector3 pos(0.,0.,0.) ;
b2a60966 98
83974468 99 AliPHOSEmcRecPoint * emcrp = GetEmcRecPoint() ;
100 AliPHOSPpsdRecPoint * ppsdlrp = GetPpsdLowRecPoint() ;
101 AliPHOSPpsdRecPoint * ppsdurp = GetPpsdUpRecPoint() ;
102
103 if ( emcrp != 0 ) {
104 emcrp->GetLocalPosition( pos) ;
105 Float_t x = pos.X() ;
106 Float_t y = pos.Z() ;
107 if ( ppsdlrp != 0 ) {
108 ppsdlrp->GetLocalPosition( pos ) ;
109 x += pos.X() ;
110 y += pos.Z() ;
111 div++ ;
112 }
113 if ( ppsdurp != 0 ) {
114 ppsdurp->GetLocalPosition( pos ) ;
115 x += pos.X() ;
116 y += pos.Z() ;
117 div++ ;
118 }
119 x /= div ;
120 y /= div ;
9f616d61 121
83974468 122 const Int_t kMaxDiff = 10;
123 Int_t pxm = gPad->XtoAbsPixel(x);
124 Int_t pym = gPad->YtoAbsPixel(y);
125 dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
126
127 if (dist > kMaxDiff) return 9999;
128 }
129 return dist;
9f616d61 130}
131
132//___________________________________________________________________________
133 void AliPHOSTrackSegment::Draw(Option_t *option)
134 {
6ad0bfa0 135 // Draw this AliPHOSTrackSegment with its current attribute
b2a60966 136
6ad0bfa0 137 AppendPad(option);
9f616d61 138 }
139
140//______________________________________________________________________________
141void AliPHOSTrackSegment::ExecuteEvent(Int_t event, Int_t px, Int_t py)
142{
6ad0bfa0 143 // Execute action corresponding to one event
144 // This member function is called when a AliPHOSTrackSegment is clicked with the locator
145 //
146 // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
147 // and switched off when the mouse button is released.
b2a60966 148
149 static TPaveText* textTS = 0 ;
150
83974468 151 AliPHOSEmcRecPoint * emcrp = GetEmcRecPoint() ;
152
b2a60966 153 if (!gPad->IsEditable())
154 return;
155
156 switch (event) {
9f616d61 157
b2a60966 158 case kButton1Down:{
159
160 if (!textTS) {
161
162 TVector3 pos(0.,0.,0.) ;
83974468 163 emcrp->GetLocalPosition(pos) ;
b2a60966 164 textTS = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+5,pos.Z()+15,"") ;
165 Text_t line1[40] ;
166 sprintf(line1,"See RecParticle for ID") ;
167 textTS ->AddText(line1) ;
168 textTS ->Draw("");
169 gPad->Update() ;
170 }
171 }
172
173 break;
9f616d61 174
b2a60966 175 case kButton1Up:
176 if (textTS) {
177 delete textTS ;
178 textTS = 0 ;
179 }
180 break;
181 }
9f616d61 182}
183
d15a28e7 184//____________________________________________________________________________
185Float_t AliPHOSTrackSegment::GetDistanceInPHOSPlane()
186{
b2a60966 187 // Calculates the distance between the EMC RecPoint and PPSD RecPoint
188
83974468 189 AliPHOSEmcRecPoint * emcrp = GetEmcRecPoint() ;
190 AliPHOSPpsdRecPoint * ppsdlrp = GetPpsdLowRecPoint() ;
191
d15a28e7 192 TVector3 vecEmc ;
83974468 193 emcrp->GetLocalPosition(vecEmc) ;
b2a60966 194
d15a28e7 195 TVector3 vecPpsd ;
83974468 196 if ( ppsdlrp !=0 ) {
197 if( ppsdlrp->GetMultiplicity() )
198 ppsdlrp->GetLocalPosition(vecPpsd) ;
199 else {
200 vecPpsd.SetX(10000.) ;
201 }
202 vecEmc -= vecPpsd ;
203 }
92862013 204 Float_t r = vecEmc.Mag();;
d15a28e7 205
92862013 206 return r ;
d15a28e7 207}
208
83974468 209//____________________________________________________________________________
210AliPHOSEmcRecPoint * AliPHOSTrackSegment::GetEmcRecPoint() const
211{
212 AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ;
213 AliPHOSEmcRecPoint * rv = 0 ;
214 if ( fEmcRecPoint > -1 )
215 rv = (AliPHOSEmcRecPoint *)please->GimeRecPoint( fEmcRecPoint, TString("emc") );
216
217 return rv ;
218
219}
220
221//____________________________________________________________________________
222 Float_t AliPHOSTrackSegment::GetEnergy()
223{
224 // Returns energy in EMC
225
226 AliPHOSEmcRecPoint * emcrp = GetEmcRecPoint() ;
227
228 return emcrp->GetTotalEnergy() ;
229}
230
d15a28e7 231//____________________________________________________________________________
6ad0bfa0 232TVector3 AliPHOSTrackSegment::GetMomentumDirection()
b2a60966 233{
234 // Calculates the momentum direction:
235 // 1. if only a EMC RecPoint, direction is given by IP and this RecPoint
236 // 2. if a EMC RecPoint and one PPSD RecPoint, direction is given by the line through the 2 recpoints
237 // 3. if a EMC RecPoint and two PPSD RecPoints, dirrection is given by the average line through
238 // the 2 pairs of recpoints
239 // However because of the poor position resolution of PPSD the direction is always taken as if we were
240 // in case 1.
241
83974468 242
243 AliPHOSEmcRecPoint * emcrp = GetEmcRecPoint() ;
244 // AliPHOSPpsdRecPoint * ppsdlrp = GetPpsdLowRecPoint() ;
245 // AliPHOSPpsdRecPoint * ppsdurp = GetPpsdUpRecPoint() ;
246
b2a60966 247 TVector3 dir(0,0,0) ;
6ad0bfa0 248 TMatrix mdummy ;
d15a28e7 249
6ad0bfa0 250 TVector3 posEmc ;
83974468 251 emcrp->GetGlobalPosition(posEmc, mdummy) ;
6ad0bfa0 252
b2a60966 253 // Correction for the depth of the shower starting point (TDR p 127)
98569bc2 254
83974468 255 Float_t energy = emcrp->GetEnergy() ;
98569bc2 256 Float_t para = 0.925 ;
257 Float_t parb = 6.52 ;
258
259 TVector3 localpos ;
83974468 260 emcrp->GetLocalPosition(localpos) ;
98569bc2 261
262 AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ;
263 Float_t radius = geom->GetIPtoOuterCoverDistance() + geom->GetOuterBoxSize(1) ;
264 Float_t incidencephi = TMath::ATan(localpos.X() / radius) ;
265 Float_t incidencetheta = TMath::ATan(localpos.Z() / radius) ;
266
b2a60966 267 Float_t depthx = ( para * TMath::Log(energy) + parb ) * TMath::Sin(incidencephi) ;
268 Float_t depthz = ( para * TMath::Log(energy) + parb ) * TMath::Sin(incidencetheta) ;
98569bc2 269
b2a60966 270 localpos.SetX(localpos.X() - depthx ) ;
271 localpos.SetZ(localpos.Z() - depthz ) ;
d15a28e7 272
b2a60966 273 TVector3 emcglobalpos ;
274 TMatrix dummy ;
6ad0bfa0 275
83974468 276 emcrp->GetGlobalPosition(emcglobalpos, dummy) ;
b2a60966 277
278 emcglobalpos.SetX( emcglobalpos.X() - depthx ) ;
279 emcglobalpos.SetZ( emcglobalpos.Z() - depthz ) ;
6ad0bfa0 280
b2a60966 281 // The following commeneted code becomes valid once the PPSD provides
282 // a reasonable position resolution, at least as good as EMC !
283
284// TVector3 ppsdlglobalpos ;
285// TVector3 ppsduglobalpos ;
286
83974468 287// if( fPpsdLowRecPoint ){ // certainly a photon that has concerted
b2a60966 288
83974468 289// fPpsdLowRecPoint->GetGlobalPosition(ppsdlglobalpos, mdummy) ;
b2a60966 290// dir = emcglobalpos - ppsdlglobalpos ;
291
83974468 292// if( fPpsdUpRecPoint ){ // nop looks like a charged
b2a60966 293
83974468 294// fPpsdUpRecPoint->GetGlobalPosition(ppsduglobalpos, mdummy) ;
b2a60966 295// dir = ( dir + emcglobalpos - ppsduglobalpos ) * 0.5 ;
296// }
297// }
298
299// else { // looks like a neutral
300
301 dir = emcglobalpos ;
302// }
303
304 dir.SetZ( -dir.Z() ) ; // why ?
6ad0bfa0 305 dir.SetMag(1.) ;
b2a60966 306
6ad0bfa0 307 return dir ;
d15a28e7 308}
309
83974468 310//____________________________________________________________________________
311Int_t AliPHOSTrackSegment:: GetPHOSMod(void)
312{
313
314 AliPHOSEmcRecPoint * emcrp = GetEmcRecPoint() ;
315
316 return emcrp->GetPHOSMod();
317}
318
319//____________________________________________________________________________
320AliPHOSPpsdRecPoint * AliPHOSTrackSegment::GetPpsdLowRecPoint() const
321{
322 AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ;
323 AliPHOSPpsdRecPoint * rv = 0 ;
324
325 if ( fPpsdLowRecPoint > -1 )
326 rv = (AliPHOSPpsdRecPoint *)please->GimeRecPoint( fPpsdLowRecPoint, TString("ppsd") ) ;
327
328 return rv ;
329}
330
331//____________________________________________________________________________
332AliPHOSPpsdRecPoint * AliPHOSTrackSegment::GetPpsdUpRecPoint() const
333{
334 AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ;
335 AliPHOSPpsdRecPoint * rv = 0 ;
336
337 if ( fPpsdUpRecPoint > -1 )
338 rv = (AliPHOSPpsdRecPoint *)please->GimeRecPoint( fPpsdUpRecPoint, TString("ppsd") ) ;
339
340 return rv ;
341}
342
b2a60966 343//____________________________________________________________________________
344Int_t * AliPHOSTrackSegment::GetPrimariesEmc(Int_t & number)
345{
346 // Retrieves the primary particle(s) at the origin of the EMC RecPoint
83974468 347
348 AliPHOSEmcRecPoint * emcrp = GetEmcRecPoint() ;
349
b2a60966 350 Int_t * rv = 0 ;
351 number = 0 ;
83974468 352 if ( emcrp )
353 rv = emcrp->GetPrimaries(number) ;
b2a60966 354
355 return rv ;
356}
357
358//____________________________________________________________________________
359Int_t * AliPHOSTrackSegment::GetPrimariesPpsdLow(Int_t & number)
360{
361 // Retrieves the primary particle(s) at the origin of the lower PPSD RecPoint
362
83974468 363 AliPHOSPpsdRecPoint * ppsdlrp = GetPpsdLowRecPoint() ;
364
b2a60966 365 Int_t * rv = 0 ;
366 number = 0 ;
83974468 367 if ( ppsdlrp )
368 rv = ppsdlrp->GetPrimaries(number) ;
b2a60966 369
370 return rv ;
371}
372
373//____________________________________________________________________________
374Int_t * AliPHOSTrackSegment::GetPrimariesPpsdUp(Int_t & number)
375{
376 // Retrieves the primary particle(s) at the origin of the upper PPSD RecPoint
377
83974468 378 AliPHOSPpsdRecPoint * ppsdurp = GetPpsdUpRecPoint() ;
379
b2a60966 380 Int_t * rv = 0 ;
381 number = 0 ;
83974468 382 if ( ppsdurp )
383 rv = ppsdurp->GetPrimaries(number) ;
b2a60966 384
385 return rv ;
386}
d15a28e7 387
388//____________________________________________________________________________
389void AliPHOSTrackSegment::GetPosition( TVector3 & pos )
390{
b2a60966 391 // Returns position of the EMC RecPoint
83974468 392
393 AliPHOSEmcRecPoint * emcrp = GetEmcRecPoint() ;
394
92862013 395 TMatrix dummy ;
83974468 396 emcrp->GetGlobalPosition(pos, dummy) ;
d15a28e7 397}
398
b2a60966 399
9f616d61 400//______________________________________________________________________________
401void AliPHOSTrackSegment::Paint(Option_t *)
402{
83974468 403 // Paint this AliPHOSTrackSegment as a TMarker with its current attributes
404
405 AliPHOSEmcRecPoint * emcrp = GetEmcRecPoint() ;
406 AliPHOSPpsdRecPoint * ppsdlrp = GetPpsdLowRecPoint() ;
407 AliPHOSPpsdRecPoint * ppsdurp = GetPpsdUpRecPoint() ;
6ad0bfa0 408
b2a60966 409 TVector3 posemc(999., 999., 999.) ;
410 TVector3 posppsdl(999., 999., 999.) ;
411 TVector3 posppsdu(999., 999., 999.) ;
6ad0bfa0 412
83974468 413 emcrp->GetLocalPosition(posemc) ;
414 if (ppsdlrp !=0 )
415 ppsdlrp->GetLocalPosition(posppsdl) ;
416 if (ppsdurp !=0 )
417 ppsdurp->GetLocalPosition(posppsdu) ;
b2a60966 418
419 Coord_t xemc = posemc.X() ;
420 Coord_t yemc = posemc.Z() ;
421
422 Coord_t yppsdl = posppsdl.Z() ;
423 Coord_t xppsdl = posppsdl.X() ;
424
425 Coord_t yppsdu = posppsdu.Z() ;
426 Coord_t xppsdu = posppsdu.X() ;
427
428 Color_t markercolor = 1 ;
429 Size_t markersize = 1.5 ;
430 Style_t markerstyle = 20 ;
431
432 if (!gPad->IsBatch()) {
433 gVirtualX->SetMarkerColor(markercolor) ;
434 gVirtualX->SetMarkerSize (markersize) ;
435 gVirtualX->SetMarkerStyle(markerstyle) ;
436 }
437 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
438 gPad->PaintPolyMarker(1, &xemc, &yemc, "") ;
439
440 if (xppsdl != 999. && yppsdl != 999. ) {
441
442 markercolor = 2 ;
443 markersize = 1.25 ;
444 markerstyle = 21 ;
445
446 if (!gPad->IsBatch()) {
447 gVirtualX->SetMarkerColor(markercolor) ;
448 gVirtualX->SetMarkerSize (markersize) ;
449 gVirtualX->SetMarkerStyle(markerstyle) ;
450 }
451 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
452 gPad->PaintPolyMarker(1, &xppsdl, &yppsdl, "") ;
453 }
454
455 if (xppsdu != 999. && yppsdu != 999. ) {
456
457 markercolor = 3 ;
458 markersize = 1. ;
459 markerstyle = 22 ;
460
461 if (!gPad->IsBatch()) {
462 gVirtualX->SetMarkerColor(markercolor) ;
463 gVirtualX->SetMarkerSize (markersize) ;
464 gVirtualX->SetMarkerStyle(markerstyle) ;
6ad0bfa0 465 }
b2a60966 466 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
467 gPad->PaintPolyMarker(1, &xppsdu, &yppsdu, "") ;
468 }
9f616d61 469}
470
d15a28e7 471//____________________________________________________________________________
472void AliPHOSTrackSegment::Print()
473{
b2a60966 474 // Print all information on this track Segment
475
83974468 476 AliPHOSEmcRecPoint * emcrp = GetEmcRecPoint() ;
477 AliPHOSPpsdRecPoint * ppsdlrp = GetPpsdLowRecPoint() ;
478 AliPHOSPpsdRecPoint * ppsdurp = GetPpsdUpRecPoint() ;
d15a28e7 479
480 TVector3 pos ;
92862013 481 TMatrix dummy ;
d15a28e7 482
83974468 483 cout << "--------AliPHOSTrackSegment-------- "<<endl ;
d15a28e7 484
83974468 485 if ( emcrp != 0 ) {
486 cout << "******** EMC Reconstructed Point: " << endl;
487 emcrp->Print() ;
488
489 emcrp->GetGlobalPosition( pos, dummy ) ;
490
491 cout << " Global position " << pos.X() << " " << pos.Y() << " " << pos.Z() << " Energy " << emcrp->GetTotalEnergy() << endl ;
492 }
d15a28e7 493
83974468 494 if ( ppsdlrp != 0 ) {
495 cout << "******** PPSD Low Reconstructed Point: " << endl;
496
497 ppsdlrp->Print() ;
498 ppsdlrp->GetGlobalPosition( pos , dummy ) ;
499 cout << " position " << pos.X() << " " << pos.Y() << " " << pos.Z() << endl ;
d15a28e7 500 }
501
83974468 502 if( ppsdurp != 0 ) {
503 cout << "******** PPSD Up Reconstructed Point: " << endl;
504
505 ppsdurp->Print() ;
506 ppsdurp->GetGlobalPosition( pos, dummy ) ;
507 cout << " position " << pos.X() << " " << pos.Y() << " " << pos.Z() << endl ;
508 }
509
d15a28e7 510}
511