]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALFastRecParticle.cxx
Update of simple generator
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALFastRecParticle.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 EMCAL response and produced by AliEMCALvFast
20 //  To become a general class of AliRoot ?    
21 //               
22 //*-- Author: Yves Schutz (SUBATECH)
23
24 // --- ROOT system ---
25
26 // --- Standard library ---
27
28 // --- AliRoot header files ---
29
30 #include "AliEMCALFastRecParticle.h"
31 #include "TPad.h"
32 #include "TPaveText.h"
33
34 ClassImp(AliEMCALFastRecParticle) ; 
35
36 //____________________________________________________________________________
37 AliEMCALFastRecParticle::AliEMCALFastRecParticle() : TParticle()
38 {
39   // ctor
40   fType = 0 ; 
41 }
42
43 //____________________________________________________________________________
44  AliEMCALFastRecParticle::AliEMCALFastRecParticle(const AliEMCALFastRecParticle & rp)
45 {
46   // copy ctor
47
48   fType        = rp.fType ;
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; 
68 }
69
70 //____________________________________________________________________________
71  AliEMCALFastRecParticle::AliEMCALFastRecParticle(const TParticle & pp)
72 {
73   // ctor from a TParticle (crummy?!)
74  
75   TParticle & pnoconst = (TParticle &)(pp) ;
76   AliEMCALFastRecParticle & p = (AliEMCALFastRecParticle &)(pnoconst) ;
77   fType        = 0  ;
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; 
97
98 }
99
100 //____________________________________________________________________________
101 Int_t AliEMCALFastRecParticle::DistancetoPrimitive(Int_t px, Int_t py)
102 {
103   //  Compute distance from point px,py to a AliEMCALFastRecParticle 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 AliEMCALFastRecParticle::Draw(Option_t *option)
121  {
122    // Draw this AliEMCALFastRecParticle with its current attributes
123     
124    AppendPad(option);
125  }
126
127 //______________________________________________________________________________
128 void AliEMCALFastRecParticle::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 AliEMCALFastRecParticle is clicked with the locator
132   
133   if (!gPad->IsEditable()) 
134     return ;
135   
136   static TPaveText * clustertext = 0 ; 
137   
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() ; 
160     break ;
161   }
162   }
163   
164 }
165
166 //____________________________________________________________________________
167 TString AliEMCALFastRecParticle::Name()const
168 {
169   // Returns the name of the particle type (only valid if PIDv1 is employed)
170
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   
203   return name ; 
204 }
205
206
207 //______________________________________________________________________________
208 void AliEMCALFastRecParticle::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
240 //______________________________________________________________________________
241 void AliEMCALFastRecParticle::Paint(Option_t *)
242 {
243   // Paint this ALiRecParticle in theta,phi coordinate as a TMarker  with its current attributes
244
245   Double_t kRADDEG = 180. / TMath::Pi() ; 
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,"") ;
259 }
260
261 //____________________________________________________________________________
262 void AliEMCALFastRecParticle::Print(Option_t * opt)const
263 {
264   // Print the type, energy and momentum of the reconstructed particle
265   
266   Info("Print", "Summary:") ; 
267   printf("AliEMCALFastRecParticle > type is  %s\n", Name().Data()) ; 
268   printf("                      Energy = %f\n", fE) ; 
269   printf("                         Px     = %f\n", fPx) ; 
270   printf("                         Py     = %f\n", fPy) ;
271   printf("                         Pz     = %f\n", fPz) ; 
272 }