New PID version that uses TPrincipal
[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
de9ec31b 28#include <iostream.h>
a73f33f0 29
30// --- AliRoot header files ---
31
32#include "AliPHOSFastRecParticle.h"
33#include "TPad.h"
34#include "TPaveText.h"
35
9ec91567 36ClassImp(AliPHOSFastRecParticle) ;
a73f33f0 37
38//____________________________________________________________________________
39 AliPHOSFastRecParticle::AliPHOSFastRecParticle(const AliPHOSFastRecParticle & rp)
40{
b2a60966 41 // copy ctor
42
6a40c29e 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
31aa6d6c 70 TParticle & pnoconst = (TParticle &)(pp) ;
71 AliPHOSFastRecParticle & p = (AliPHOSFastRecParticle &)(pnoconst) ;
a73f33f0 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;
78022019 92
a73f33f0 93}
94
95//____________________________________________________________________________
a73f33f0 96Int_t AliPHOSFastRecParticle::DistancetoPrimitive(Int_t px, Int_t py)
97{
98 // Compute distance from point px,py to a AliPHOSFastRecParticle considered as a Tmarker
99 // Compute the closest distance of approach from point px,py to this marker.
100 // The distance is computed in pixels units.
101
102 Double_t kRADDEG = 180. / TMath::Pi() ;
103 Coord_t x = Phi() * kRADDEG ;
104 Coord_t y = Theta() * kRADDEG ;
105 const Int_t kMaxDiff = 10;
106 Int_t pxm = gPad->XtoAbsPixel(x);
107 Int_t pym = gPad->YtoAbsPixel(y);
108 Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
109
110 if (dist > kMaxDiff) return 9999;
111 return dist;
112}
113
114//___________________________________________________________________________
115 void AliPHOSFastRecParticle::Draw(Option_t *option)
116 {
117 // Draw this AliPHOSFastRecParticle with its current attributes
118
119 AppendPad(option);
120 }
121
122//______________________________________________________________________________
123void AliPHOSFastRecParticle::ExecuteEvent(Int_t event, Int_t px, Int_t py)
124{
125 // Execute action corresponding to one event
126 // This member function is called when a AliPHOSFastRecParticle is clicked with the locator
b2a60966 127
a73f33f0 128 if (!gPad->IsEditable())
129 return ;
130
131 static TPaveText * clustertext = 0 ;
132
133 switch (event) {
134
135 case kButton1Down: {
136 Double_t kRADDEG = 180. / TMath::Pi() ;
137 Coord_t x = Phi() * kRADDEG ;
138 Coord_t y = Theta() * kRADDEG ;
139 clustertext = new TPaveText(x-1, y+1, x+5, y+3, "") ;
140 Text_t line1[40] ;
141 Text_t line2[40] ;
142 sprintf( line1, "PID: %s ", (const char*)Name() ) ;
143 sprintf( line2, "ENERGY: %f ", Energy() ) ;
144 clustertext ->AddText(line1) ;
145 clustertext ->AddText(line2) ;
146 clustertext ->Draw("");
147 gPad->Update() ;
148 break ;
149 }
150
151 case kButton1Up: {
152 delete clustertext ;
153 clustertext = 0 ;
154 gPad->Update() ;
a4e98857 155 break ;
a73f33f0 156 }
a73f33f0 157 }
a73f33f0 158}
b2a60966 159
160//____________________________________________________________________________
a73f33f0 161TString AliPHOSFastRecParticle::Name()
162{
b2a60966 163 // Returns the name of the particle type
164
a73f33f0 165 TString name ;
166 switch (fType) {
9688c1dd 167 case kNEUTRALEMFAST:
a73f33f0 168 name = "PHOTON" ;
169 break ;
9688c1dd 170 case kCHARGEDEMFAST:
a73f33f0 171 name = "ELECTRON" ;
172 break ;
9688c1dd 173 case kCHARGEDHAFAST:
174 name = "CHARGED_HA_FAST" ;
a73f33f0 175 break ;
9688c1dd 176 case kNEUTRALHASLOW:
177 name = "NEUTRAL_HA_SLOW" ;
a73f33f0 178 break ;
9688c1dd 179 case kNEUTRALEMSLOW:
180 name = "NEUTRAL_EM_SLOW" ;
a73f33f0 181 break ;
9688c1dd 182 case kNEUTRALHAFAST:
183 name = "NEUTRAL_HA_FAST" ;
a73f33f0 184 break ;
185
186 }
187 return name ;
188}
189
190//______________________________________________________________________________
191void AliPHOSFastRecParticle::Paint(Option_t *)
192{
b2a60966 193 // Paint this ALiRecParticle in theta,phi coordinate as a TMarker with its current attributes
a73f33f0 194
195 Double_t kRADDEG = 180. / TMath::Pi() ;
b2a60966 196 Coord_t x = Phi() * kRADDEG ;
197 Coord_t y = Theta() * kRADDEG ;
198 Color_t markercolor = 1 ;
199 Size_t markersize = 1. ;
200 Style_t markerstyle = 5 ;
201
202 if (!gPad->IsBatch()) {
203 gVirtualX->SetMarkerColor(markercolor) ;
204 gVirtualX->SetMarkerSize (markersize) ;
205 gVirtualX->SetMarkerStyle(markerstyle) ;
206 }
207 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
208 gPad->PaintPolyMarker(1,&x,&y,"") ;
a73f33f0 209}
210
211//____________________________________________________________________________
0a6d52e3 212void AliPHOSFastRecParticle::Print(const char * opt)
a73f33f0 213{
a4e98857 214 // Print the type, energy and momentum of the reconstructed particle
b2a60966 215
a73f33f0 216 cout << "AliPHOSFastRecParticle > " << "type is " << Name() << endl
217 << " " << "Energy = " << fE << endl
218 << " " << "Px = " << fPx << endl
219 << " " << "Py = " << fPy << endl
220 << " " << "Pz = " << fPz << endl ;
221}