Loading Geant3
[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
a73f33f0 28// --- AliRoot header files ---
29
30#include "AliPHOSFastRecParticle.h"
31#include "TPad.h"
32#include "TPaveText.h"
33
9ec91567 34ClassImp(AliPHOSFastRecParticle) ;
a73f33f0 35
36//____________________________________________________________________________
03c03c49 37AliPHOSFastRecParticle::AliPHOSFastRecParticle() : TParticle()
38{
39 // ctor
40 fType = 0 ;
41}
42
43//____________________________________________________________________________
a73f33f0 44 AliPHOSFastRecParticle::AliPHOSFastRecParticle(const AliPHOSFastRecParticle & rp)
45{
b2a60966 46 // copy ctor
47
6a40c29e 48 fType = rp.fType ;
cafda784 49 fPdgCode = rp.fPdgCode;
50 fStatusCode = rp.fStatusCode;
51 fMother[0] = rp.fMother[0];
52 fMother[1] = rp.fMother[1];
53 fDaughter[0] = rp.fDaughter[0];
54 fDaughter[1] = rp.fDaughter[1];
55 fWeight = rp.fWeight;
56 fCalcMass = rp.fCalcMass;
57 fPx = rp.fPx;
58 fPy = rp.fPy;
59 fPz = rp.fPz;
60 fE = rp.fE;
61 fVx = rp.fVx;
62 fVy = rp.fVy;
63 fVz = rp.fVz;
64 fVt = rp.fVt;
65 fPolarTheta = rp.fPolarTheta;
66 fPolarPhi = rp.fPolarPhi;
67 fParticlePDG = rp.fParticlePDG;
a73f33f0 68}
69
70//____________________________________________________________________________
71 AliPHOSFastRecParticle::AliPHOSFastRecParticle(const TParticle & pp)
72{
b2a60966 73 // ctor from a TParticle (crummy?!)
74
31aa6d6c 75 TParticle & pnoconst = (TParticle &)(pp) ;
76 AliPHOSFastRecParticle & p = (AliPHOSFastRecParticle &)(pnoconst) ;
03c03c49 77 fType = 0 ;
a73f33f0 78 fPdgCode = p.fPdgCode;
79 fStatusCode = p.fStatusCode;
80 fMother[0] = p.fMother[0];
81 fMother[1] = p.fMother[1];
82 fDaughter[0] = p.fDaughter[0];
83 fDaughter[1] = p.fDaughter[1];
84 fWeight = p.fWeight;
85 fCalcMass = p.fCalcMass;
86 fPx = p.fPx;
87 fPy = p.fPy;
88 fPz = p.fPz;
89 fE = p.fE;
90 fVx = p.fVx;
91 fVy = p.fVy;
92 fVz = p.fVz;
93 fVt = p.fVt;
94 fPolarTheta = p.fPolarTheta;
95 fPolarPhi = p.fPolarPhi;
96 fParticlePDG = p.fParticlePDG;
78022019 97
a73f33f0 98}
99
100//____________________________________________________________________________
a73f33f0 101Int_t AliPHOSFastRecParticle::DistancetoPrimitive(Int_t px, Int_t py)
102{
103 // Compute distance from point px,py to a AliPHOSFastRecParticle considered as a Tmarker
104 // Compute the closest distance of approach from point px,py to this marker.
105 // The distance is computed in pixels units.
106
107 Double_t kRADDEG = 180. / TMath::Pi() ;
108 Coord_t x = Phi() * kRADDEG ;
109 Coord_t y = Theta() * kRADDEG ;
110 const Int_t kMaxDiff = 10;
111 Int_t pxm = gPad->XtoAbsPixel(x);
112 Int_t pym = gPad->YtoAbsPixel(y);
113 Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
114
115 if (dist > kMaxDiff) return 9999;
116 return dist;
117}
118
119//___________________________________________________________________________
120 void AliPHOSFastRecParticle::Draw(Option_t *option)
121 {
122 // Draw this AliPHOSFastRecParticle with its current attributes
123
124 AppendPad(option);
125 }
126
127//______________________________________________________________________________
128void AliPHOSFastRecParticle::ExecuteEvent(Int_t event, Int_t px, Int_t py)
129{
130 // Execute action corresponding to one event
131 // This member function is called when a AliPHOSFastRecParticle is clicked with the locator
794c2bc3 132
a73f33f0 133 if (!gPad->IsEditable())
134 return ;
794c2bc3 135
a73f33f0 136 static TPaveText * clustertext = 0 ;
794c2bc3 137
a73f33f0 138 switch (event) {
139
140 case kButton1Down: {
141 Double_t kRADDEG = 180. / TMath::Pi() ;
142 Coord_t x = Phi() * kRADDEG ;
143 Coord_t y = Theta() * kRADDEG ;
144 clustertext = new TPaveText(x-1, y+1, x+5, y+3, "") ;
145 Text_t line1[40] ;
146 Text_t line2[40] ;
147 sprintf( line1, "PID: %s ", (const char*)Name() ) ;
148 sprintf( line2, "ENERGY: %f ", Energy() ) ;
149 clustertext ->AddText(line1) ;
150 clustertext ->AddText(line2) ;
151 clustertext ->Draw("");
152 gPad->Update() ;
153 break ;
154 }
155
156 case kButton1Up: {
157 delete clustertext ;
158 clustertext = 0 ;
159 gPad->Update() ;
a4e98857 160 break ;
a73f33f0 161 }
a73f33f0 162 }
794c2bc3 163
a73f33f0 164}
794c2bc3 165
b2a60966 166//____________________________________________________________________________
14f6a871 167TString AliPHOSFastRecParticle::Name()const
a73f33f0 168{
794c2bc3 169 // Returns the name of the particle type (only valid if PIDv1 is employed)
a73f33f0 170
794c2bc3 171 TString name ;
172
173 if(fType == 127)
174 name = "PHOTON_LOPU_HIEF" ; //PCA = 001 TOF = 111 CPV = 111
175
176 if(fType == 511)
177 name = "PHOTON_HIPU_LOEF" ; //PCA = 011 TOF = 111 CPV = 111
178
179 if(fType == 255)
180 name = "PHOTON_MED_PU_EF" ; //PCA = 111 TOF = 111 CPV = 111
181
182 if((fType == 383)||(fType == 447))
183 name = "PHOTON_STRANGE" ; //PCA = 101 or 110 TOF = 111 CPV = 111
184
185 if(fType == 63)
186 name = "NEUTRAL_FAST_HADRON" ; //PCA = 000 TOF = 111 CPV = 111
187
188 if((fType == 504) || (fType == 505) ||(fType == 248)||(fType == 249)||(fType == 120)||(fType == 121))
189 name = "CHARGED_FAST_EM" ; //PCA = 111, 011 or 001 TOF =111 CPV = 000 or 001
190
191 if((fType == 56)||(fType == 57))
192 name = "CHARGED_FAST_HADRON" ; //PCA = 000 TOF = 111 CPV = 000 or 001
193
194 if((fType < 8)&&(fType > 0))
195 name = "NEUTRAL_SLOW_HADRON" ; //PCA = 000 TOF = 000 CPV = 001 or 011 or 111
196
197 if((fType == 0))
198 name = "CHARGED_SLOW_HADRON" ; //PCA = 000 TOF = 000 CPV = 000
199
200 if((fType == 448) || (fType == 449) ||(fType == 192)||(fType == 193)||(fType == 64)||(fType == 64))
201 name = "CHARGED_SLOW_EM" ; //PCA = 111, 011 or 001 TOF =000 CPV = 000 or 001
202
a73f33f0 203 return name ;
204}
205
14f6a871 206
207//______________________________________________________________________________
208void AliPHOSFastRecParticle::SetType(Int_t type) {
209 // sets the particle type
210 fType = type ;
211
212 if((type == 127) || (fType == 511) || (fType == 255) ||(fType == 383)||(fType == 447)){
213 fPdgCode = 22 ;
214 return ;
215 }
216
217 if ((fType == 63)|| ((fType < 8)&&(fType > 0)) ){
218 fPdgCode = 2112 ;
219 return ;
220 }
221 if ( ((fType == 504) || (fType == 505) ||(fType == 248)||(fType == 249)||(fType == 120)||(fType == 121)) ){
222 fPdgCode = 11 ;
223 return ;
224 }
225 if ((fType == 448) || (fType == 449) ||(fType == 192)||(fType == 193)||(fType == 64)||(fType == 64)){
226 fPdgCode = 13 ;
227 return ;
228 }
229 if((fType == 56)||(fType == 57)){
230 fPdgCode = 211 ;
231 return ;
232 }
233 if (fType == 0){
234 fPdgCode = 2212 ;
235 return ;
236 }
237
238}
239
a73f33f0 240//______________________________________________________________________________
241void AliPHOSFastRecParticle::Paint(Option_t *)
242{
b2a60966 243 // Paint this ALiRecParticle in theta,phi coordinate as a TMarker with its current attributes
a73f33f0 244
245 Double_t kRADDEG = 180. / TMath::Pi() ;
b2a60966 246 Coord_t x = Phi() * kRADDEG ;
247 Coord_t y = Theta() * kRADDEG ;
248 Color_t markercolor = 1 ;
249 Size_t markersize = 1. ;
250 Style_t markerstyle = 5 ;
251
252 if (!gPad->IsBatch()) {
253 gVirtualX->SetMarkerColor(markercolor) ;
254 gVirtualX->SetMarkerSize (markersize) ;
255 gVirtualX->SetMarkerStyle(markerstyle) ;
256 }
257 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
258 gPad->PaintPolyMarker(1,&x,&y,"") ;
a73f33f0 259}
260
261//____________________________________________________________________________
14f6a871 262void AliPHOSFastRecParticle::Print(Option_t * opt)const
a73f33f0 263{
a4e98857 264 // Print the type, energy and momentum of the reconstructed particle
b2a60966 265
21cd0c07 266 TString message ;
267 message = "AliPHOSFastRecParticle > type is %s\n" ;
53ad38d8 268 message += " Energy = %e\n" ;
269 message += " Px = %e\n" ;
270 message += " Py = %e\n" ;
271 message += " Pz = %e\n" ;
21cd0c07 272 Info("Print", message.Data(),
273 Name().Data(),
53ad38d8 274 Energy(),
275 Px(),
276 Py(),
277 Pz() );
a73f33f0 278}