only cosmetics
[u/mrichter/AliRoot.git] / PHOS / AliPHOSRecParticle.cxx
CommitLineData
6ad0bfa0 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
16//_________________________________________________________________________
17// Reconstructed Particle
18//*-- Y. Schutz: SUBATECH
19//////////////////////////////////////////////////////////////////////////////
20
21// --- ROOT system ---
22
23// --- Standard library ---
24
25// --- AliRoot header files ---
26
27#include "AliPHOSRecParticle.h"
15605d3c 28#include "TPad.h"
6ad0bfa0 29
30ClassImp(AliPHOSRecParticle)
31
32
33//____________________________________________________________________________
34 AliPHOSRecParticle::AliPHOSRecParticle(AliPHOSTrackSegment * ts)
35{
36 // ctor
37
38 fPHOSTrackSegment = new AliPHOSTrackSegment(*ts) ;
6ad0bfa0 39 fE = ts->GetEnergy() ;
40 TVector3 momdir = ts->GetMomentumDirection() ;
41 fPx = fE * momdir.X() ;
42 fPy = fE * momdir.Y() ;
43 fPz = fE * momdir.Z() ;
0dd37dda 44 fType = kUNDEFINED ;
45
6ad0bfa0 46}
47
48//____________________________________________________________________________
15605d3c 49Int_t AliPHOSRecParticle::DistancetoPrimitive(Int_t px, Int_t py)
50{
51 // Compute distance from point px,py to a AliPHOSRecParticle considered as a Tmarker
52 // Compute the closest distance of approach from point px,py to this marker.
53 // The distance is computed in pixels units.
54
55 Double_t kRADDEG = 180. / TMath::Pi() ;
56 Coord_t x = Phi() * kRADDEG ;
57 Coord_t y = Theta() * kRADDEG ;
58 const Int_t kMaxDiff = 10;
59 Int_t pxm = gPad->XtoAbsPixel(x);
60 Int_t pym = gPad->YtoAbsPixel(y);
61 Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
62
63 if (dist > kMaxDiff) return 9999;
64 return dist;
65}
66
67//___________________________________________________________________________
68 void AliPHOSRecParticle::Draw(Option_t *option)
69 {
70 // Draw this AliPHOSRecParticle with its current attributes
71
72 AppendPad(option);
73 }
74
75//______________________________________________________________________________
76void AliPHOSRecParticle::ExecuteEvent(Int_t event, Int_t px, Int_t py)
77{
78 // Execute action corresponding to one event
79 // This member function is called when a AliPHOSRecParticle is clicked with the locator
80 //
81
82 if (!gPad->IsEditable())
83 return ;
84
85 static TPaveText * clustertext = 0 ;
86
87 switch (event) {
88
89 case kButton1Down: {
90 Double_t kRADDEG = 180. / TMath::Pi() ;
91 Coord_t x = Phi() * kRADDEG ;
92 Coord_t y = Theta() * kRADDEG ;
93 clustertext = new TPaveText(x-1, y+1, x+5, y+3, "") ;
94 Text_t line1[40] ;
95 Text_t line2[40] ;
96 sprintf( line1, "PID: %s ", (const char*)Name() ) ;
97 sprintf( line2, "ENERGY: %f ", Energy() ) ;
98 clustertext ->AddText(line1) ;
99 clustertext ->AddText(line2) ;
100 clustertext ->Draw("");
101 gPad->Update() ;
102 break ;
103 }
104
105 case kButton1Up: {
106 delete clustertext ;
107 clustertext = 0 ;
108 gPad->Update() ;
109 break ;
110 }
111
112 }
113
114}
115//____________________________________________________________________________
6ad0bfa0 116TString AliPHOSRecParticle::Name()
117{
118 TString name ;
119 switch (fType) {
09fc14a0 120 case kGAMMA:
6ad0bfa0 121 name = "PHOTON" ;
122 break ;
09fc14a0 123 case kELECTRON:
6ad0bfa0 124 name = "ELECTRON" ;
125 break ;
09fc14a0 126 case kNEUTRAL:
6ad0bfa0 127 name = "NEUTRAL" ;
128 break ;
92862013 129 case kCHARGEDHADRON:
6ad0bfa0 130 name = "CHARGED HADRON" ;
131 break ;
b9bbdad1 132 case kNEUTRALHADRON:
133 name = "NEUTRAL HADRON" ;
134 break ;
135 case kNEUTRALEM:
136 name = "NEUTRAL EM" ;
09fc14a0 137 break ;
c1d256cb 138 case kGAMMAHADRON:
139 name = "PHOTON HADRON" ;
140 break ;
141
6ad0bfa0 142 }
143 return name ;
144}
145
15605d3c 146//______________________________________________________________________________
147void AliPHOSRecParticle::Paint(Option_t *)
148{
149// Paint this ALiRecParticle in theta,phi coordinate as a TMarker with its current attributes
150
151 Double_t kRADDEG = 180. / TMath::Pi() ;
152 Coord_t x = Phi() * kRADDEG ;
153 Coord_t y = Theta() * kRADDEG ;
154 Color_t markercolor = 1 ;
155 Size_t markersize = 1. ;
156 Style_t markerstyle = 5 ;
157
158 if (!gPad->IsBatch()) {
159 gVirtualX->SetMarkerColor(markercolor) ;
160 gVirtualX->SetMarkerSize (markersize) ;
161 gVirtualX->SetMarkerStyle(markerstyle) ;
162 }
163 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
164 gPad->PaintPolyMarker(1,&x,&y,"") ;
165}
166
6ad0bfa0 167//____________________________________________________________________________
168void AliPHOSRecParticle::Print()
169{
170 cout << "AliPHOSRecParticle > " << "type is " << Name() << endl
171 << " " << "Energy = " << fE << endl
172 << " " << "Px = " << fPx << endl
173 << " " << "Py = " << fPy << endl
174 << " " << "Pz = " << fPz << endl ;
175}