]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSFastRecParticle.cxx
1d7a04b50bca194856cdcb4f8b43ea6ee581d3f1
[u/mrichter/AliRoot.git] / PHOS / AliPHOSFastRecParticle.cxx
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 /* $Id$ */
17
18 //_________________________________________________________________________
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)
23
24 // --- ROOT system ---
25
26 // --- Standard library ---
27
28 #include <iostream.h>
29
30 // --- AliRoot header files ---
31
32 #include "AliPHOSFastRecParticle.h"
33 #include "TPad.h"
34 #include "TPaveText.h"
35
36 ClassImp(AliPHOSFastRecParticle) ; 
37
38 //____________________________________________________________________________
39  AliPHOSFastRecParticle::AliPHOSFastRecParticle(const AliPHOSFastRecParticle & rp)
40 {
41   // copy ctor
42
43   fType        = rp.fType ;
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; 
63 }
64
65 //____________________________________________________________________________
66  AliPHOSFastRecParticle::AliPHOSFastRecParticle(const TParticle & pp)
67 {
68   // ctor from a TParticle (crummy?!)
69  
70   TParticle & pnoconst = (TParticle &)(pp) ;
71   AliPHOSFastRecParticle & p = (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
95 //____________________________________________________________________________
96 Int_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 //______________________________________________________________________________
123 void 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
127      
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() ; 
155     break ;
156   }
157   }
158 }
159
160 //____________________________________________________________________________
161 TString AliPHOSFastRecParticle::Name()
162 {
163   // Returns the name of the particle type
164   
165   TString  name ; 
166   switch (fType) {
167   case kNEUTRALEMFAST:
168     name = "PHOTON" ;
169     break ; 
170    case kCHARGEDEMFAST:
171      name = "ELECTRON" ;
172     break ; 
173    case kCHARGEDHAFAST:
174     name = "CHARGED_HA_FAST" ;
175     break ; 
176   case kNEUTRALHASLOW:
177     name = "NEUTRAL_HA_SLOW" ; 
178     break ; 
179   case kNEUTRALEMSLOW:
180     name = "NEUTRAL_EM_SLOW" ; 
181     break ; 
182   case kNEUTRALHAFAST:
183     name = "NEUTRAL_HA_FAST" ; 
184     break ; 
185
186   }
187   return name ; 
188 }
189
190 //______________________________________________________________________________
191 void AliPHOSFastRecParticle::Paint(Option_t *)
192 {
193   // Paint this ALiRecParticle in theta,phi coordinate as a TMarker  with its current attributes
194
195   Double_t kRADDEG = 180. / TMath::Pi() ; 
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,"") ;
209 }
210
211 //____________________________________________________________________________
212 void AliPHOSFastRecParticle::Print(const char * opt)
213 {
214   // Print the type, energy and momentum of the reconstructed particle
215   
216   cout << "AliPHOSFastRecParticle > " << "type is  " << Name() << endl 
217        << "                     " << "Energy = " << fE << endl 
218        << "                     " << "Px     = " << fPx << endl 
219        << "                     " << "Py     = " << fPy << endl 
220        << "                     " << "Pz     = " << fPz << endl ; 
221 }