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