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