Correct path of images and src
[u/mrichter/AliRoot.git] / PHOS / AliPHOSFastRecParticle.cxx
CommitLineData
a73f33f0 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
a73f33f0 18//_________________________________________________________________________
b2a60966 19// A Particle modified by PHOS response and produced by AliPHOSvFast
20// To become a general class of AliRoot ?
21//
22//*-- Author: Yves Schutz (SUBATECH)
a73f33f0 23
24// --- ROOT system ---
25
26// --- Standard library ---
27
28#include <iostream>
29
30// --- AliRoot header files ---
31
32#include "AliPHOSFastRecParticle.h"
33#include "TPad.h"
34#include "TPaveText.h"
35
36ClassImp(AliPHOSFastRecParticle)
37
38//____________________________________________________________________________
39 AliPHOSFastRecParticle::AliPHOSFastRecParticle(const AliPHOSFastRecParticle & rp)
40{
b2a60966 41 // copy ctor
42
a73f33f0 43 fType = rp.fType ;
cafda784 44 fPdgCode = rp.fPdgCode;
45 fStatusCode = rp.fStatusCode;
46 fMother[0] = rp.fMother[0];
47 fMother[1] = rp.fMother[1];
48 fDaughter[0] = rp.fDaughter[0];
49 fDaughter[1] = rp.fDaughter[1];
50 fWeight = rp.fWeight;
51 fCalcMass = rp.fCalcMass;
52 fPx = rp.fPx;
53 fPy = rp.fPy;
54 fPz = rp.fPz;
55 fE = rp.fE;
56 fVx = rp.fVx;
57 fVy = rp.fVy;
58 fVz = rp.fVz;
59 fVt = rp.fVt;
60 fPolarTheta = rp.fPolarTheta;
61 fPolarPhi = rp.fPolarPhi;
62 fParticlePDG = rp.fParticlePDG;
a73f33f0 63}
64
65//____________________________________________________________________________
66 AliPHOSFastRecParticle::AliPHOSFastRecParticle(const TParticle & pp)
67{
b2a60966 68 // ctor from a TParticle (crummy?!)
69
a73f33f0 70 TParticle & pnoconst = const_cast<TParticle &>(pp) ;
71 AliPHOSFastRecParticle & p = static_cast<AliPHOSFastRecParticle&>(pnoconst) ;
72
73 fPdgCode = p.fPdgCode;
74 fStatusCode = p.fStatusCode;
75 fMother[0] = p.fMother[0];
76 fMother[1] = p.fMother[1];
77 fDaughter[0] = p.fDaughter[0];
78 fDaughter[1] = p.fDaughter[1];
79 fWeight = p.fWeight;
80 fCalcMass = p.fCalcMass;
81 fPx = p.fPx;
82 fPy = p.fPy;
83 fPz = p.fPz;
84 fE = p.fE;
85 fVx = p.fVx;
86 fVy = p.fVy;
87 fVz = p.fVz;
88 fVt = p.fVt;
89 fPolarTheta = p.fPolarTheta;
90 fPolarPhi = p.fPolarPhi;
91 fParticlePDG = p.fParticlePDG;
92}
93
94//____________________________________________________________________________
a73f33f0 95Int_t AliPHOSFastRecParticle::DistancetoPrimitive(Int_t px, Int_t py)
96{
97 // Compute distance from point px,py to a AliPHOSFastRecParticle considered as a Tmarker
98 // Compute the closest distance of approach from point px,py to this marker.
99 // The distance is computed in pixels units.
100
101 Double_t kRADDEG = 180. / TMath::Pi() ;
102 Coord_t x = Phi() * kRADDEG ;
103 Coord_t y = Theta() * kRADDEG ;
104 const Int_t kMaxDiff = 10;
105 Int_t pxm = gPad->XtoAbsPixel(x);
106 Int_t pym = gPad->YtoAbsPixel(y);
107 Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
108
109 if (dist > kMaxDiff) return 9999;
110 return dist;
111}
112
113//___________________________________________________________________________
114 void AliPHOSFastRecParticle::Draw(Option_t *option)
115 {
116 // Draw this AliPHOSFastRecParticle with its current attributes
117
118 AppendPad(option);
119 }
120
121//______________________________________________________________________________
122void AliPHOSFastRecParticle::ExecuteEvent(Int_t event, Int_t px, Int_t py)
123{
124 // Execute action corresponding to one event
125 // This member function is called when a AliPHOSFastRecParticle is clicked with the locator
b2a60966 126
a73f33f0 127 if (!gPad->IsEditable())
128 return ;
129
130 static TPaveText * clustertext = 0 ;
131
132 switch (event) {
133
134 case kButton1Down: {
135 Double_t kRADDEG = 180. / TMath::Pi() ;
136 Coord_t x = Phi() * kRADDEG ;
137 Coord_t y = Theta() * kRADDEG ;
138 clustertext = new TPaveText(x-1, y+1, x+5, y+3, "") ;
139 Text_t line1[40] ;
140 Text_t line2[40] ;
141 sprintf( line1, "PID: %s ", (const char*)Name() ) ;
142 sprintf( line2, "ENERGY: %f ", Energy() ) ;
143 clustertext ->AddText(line1) ;
144 clustertext ->AddText(line2) ;
145 clustertext ->Draw("");
146 gPad->Update() ;
147 break ;
148 }
149
150 case kButton1Up: {
151 delete clustertext ;
152 clustertext = 0 ;
153 gPad->Update() ;
154 break ;
155 }
156
157 }
158
159}
b2a60966 160
161//____________________________________________________________________________
162Int_t * AliPHOSFastRecParticle::GetPrimaries(Int_t & number)
163{
164 // Retrieves the unique primary particle at the origine of the present reconstruced particle
165
166 number = 1 ;
167 Int_t * list = new Int_t[1] ;
168 list[0] = fPrimary ;
169
170 return list ;
171}
172
a73f33f0 173//____________________________________________________________________________
174TString AliPHOSFastRecParticle::Name()
175{
b2a60966 176 // Returns the name of the particle type
177
a73f33f0 178 TString name ;
179 switch (fType) {
180 case kGAMMA:
181 name = "PHOTON" ;
182 break ;
183 case kELECTRON:
184 name = "ELECTRON" ;
185 break ;
186 case kNEUTRAL:
187 name = "NEUTRAL" ;
188 break ;
189 case kCHARGEDHADRON:
190 name = "CHARGED HADRON" ;
191 break ;
192 case kNEUTRALHADRON:
193 name = "NEUTRAL HADRON" ;
194 break ;
195 case kNEUTRALEM:
196 name = "NEUTRAL EM" ;
197 break ;
198 case kGAMMAHADRON:
199 name = "PHOTON HADRON" ;
200 break ;
201
202 }
203 return name ;
204}
205
206//______________________________________________________________________________
207void AliPHOSFastRecParticle::Paint(Option_t *)
208{
b2a60966 209 // Paint this ALiRecParticle in theta,phi coordinate as a TMarker with its current attributes
a73f33f0 210
211 Double_t kRADDEG = 180. / TMath::Pi() ;
b2a60966 212 Coord_t x = Phi() * kRADDEG ;
213 Coord_t y = Theta() * kRADDEG ;
214 Color_t markercolor = 1 ;
215 Size_t markersize = 1. ;
216 Style_t markerstyle = 5 ;
217
218 if (!gPad->IsBatch()) {
219 gVirtualX->SetMarkerColor(markercolor) ;
220 gVirtualX->SetMarkerSize (markersize) ;
221 gVirtualX->SetMarkerStyle(markerstyle) ;
222 }
223 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
224 gPad->PaintPolyMarker(1,&x,&y,"") ;
a73f33f0 225}
226
227//____________________________________________________________________________
228void AliPHOSFastRecParticle::Print()
229{
b2a60966 230 // Print the typr, energy and momentum
231
a73f33f0 232 cout << "AliPHOSFastRecParticle > " << "type is " << Name() << endl
233 << " " << "Energy = " << fE << endl
234 << " " << "Px = " << fPx << endl
235 << " " << "Py = " << fPy << endl
236 << " " << "Pz = " << fPz << endl ;
237}