]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSTrackSegment.cxx
Modifications to follow the Coding Convention Rules (make check)
[u/mrichter/AliRoot.git] / PHOS / AliPHOSTrackSegment.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 //_________________________________________________________________________
17 // class of PHOS Sub Track
18 //*-- Author : Dmitri Peressounko RRC KI 
19 //////////////////////////////////////////////////////////////////////////////
20
21 // --- ROOT system ---
22  
23 #include "TVector3.h"
24 #include "TPad.h"
25
26 // --- Standard library ---
27
28 #include <iostream>
29
30 // --- AliRoot header files ---
31
32 #include "AliPHOSTrackSegment.h" 
33 #include "AliPHOSv0.h"
34
35 ClassImp(AliPHOSTrackSegment)
36
37 //____________________________________________________________________________
38 AliPHOSTrackSegment::AliPHOSTrackSegment( AliPHOSEmcRecPoint * emc , AliPHOSPpsdRecPoint * ppsdRP1,
39                   AliPHOSPpsdRecPoint * ppsdRP2  ) 
40 {     
41   if( emc )   
42     fEmcRecPoint =  emc ;
43
44   if( ppsdRP1 )  
45     fPpsdUp = ppsdRP1 ;
46
47   if( ppsdRP2  ) 
48     fPpsdLow = ppsdRP2 ;
49
50   fCutOnDispersion = 1.5 ; 
51 }
52
53 //____________________________________________________________________________
54 AliPHOSTrackSegment::AliPHOSTrackSegment( const AliPHOSTrackSegment & ts) 
55 {
56  ( (AliPHOSTrackSegment &)ts ).Copy(*this) ; 
57 }
58
59 //____________________________________________________________________________
60 AliPHOSTrackSegment::~AliPHOSTrackSegment() // dtor
61 {
62 //    fEmcRecPoint.Delete() ;   Not Owners !!!
63 //    fPpsdUp.Delete() ;
64 //    fPpsdLow.Delete() ;
65 }
66
67 //____________________________________________________________________________
68 void AliPHOSTrackSegment::Copy(TObject & obj) 
69 {
70    TObject::Copy(obj) ;
71    ( (AliPHOSTrackSegment &)obj ).fEmcRecPoint = fEmcRecPoint ; 
72    ( (AliPHOSTrackSegment &)obj ).fPpsdLow     = fPpsdLow ; 
73    ( (AliPHOSTrackSegment &)obj ).fPpsdUp      = fPpsdUp ; 
74 }
75 //____________________________________________________________________________
76 Int_t AliPHOSTrackSegment::DistancetoPrimitive(Int_t px, Int_t py)
77 {
78   //Compute distance from point px,py to  a AliPHOSTrackSegment considered as a Tmarker
79   //  Compute the closest distance of approach from point px,py to this marker.
80   //  The distance is computed in pixels units.
81   //
82   Int_t div = 1 ;  
83   TVector3 pos(0.,0.,0.) ;
84  
85   fEmcRecPoint->GetLocalPosition( pos) ;
86   Float_t x =  pos.X() ;
87   Float_t y =  pos.Z() ;
88   if ( fPpsdLow ) {
89     fPpsdLow->GetLocalPosition( pos ) ;
90     x +=  pos.X() ;
91     y +=  pos.Z() ;
92     div++ ; 
93   }
94   if ( fPpsdUp ) {
95     fPpsdUp->GetLocalPosition( pos ) ;
96     x +=  pos.X() ;
97     y +=  pos.Z() ;
98     div++ ; 
99   }
100   x /= div ; 
101   y /= div ; 
102
103    const Int_t kMaxDiff = 10;
104    Int_t pxm  = gPad->XtoAbsPixel(x);
105    Int_t pym  = gPad->YtoAbsPixel(y);
106    Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
107
108    if (dist > kMaxDiff) return 9999;
109    return dist;
110 }
111
112 //___________________________________________________________________________
113  void AliPHOSTrackSegment::Draw(Option_t *option)
114  {
115    // Draw this AliPHOSTrackSegment with its current attribute
116
117    AppendPad(option);
118  }
119
120 //______________________________________________________________________________
121 void AliPHOSTrackSegment::ExecuteEvent(Int_t event, Int_t px, Int_t py)
122 {
123   // Execute action corresponding to one event
124   //  This member function is called when a AliPHOSTrackSegment is clicked with the locator
125   //
126   //  If Left button is clicked on AliPHOSRecPoint, the digits are switched on    
127   //  and switched off when the mouse button is released.
128   //
129    static TPaveText* textTS = 0 ;
130
131    if (!gPad->IsEditable()) 
132      return;
133
134    switch (event) {
135
136    case kButton1Down:{
137     
138      if (!textTS) {
139   
140        TVector3 pos(0.,0.,0.) ;
141        fEmcRecPoint->GetLocalPosition(pos) ;
142        textTS = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+5,pos.Z()+15,"") ;
143        Text_t  line1[40] ;
144        if (GetPartType() == kGAMMA ) 
145          sprintf(line1,"PHOTON") ;
146        if (GetPartType() == kELECTRON ) 
147          sprintf(line1,"ELECTRON") ;
148        if (GetPartType() == kNEUTRAL ) 
149          sprintf(line1,"NEUTRAL") ;
150        if (GetPartType() == kCHARGEDHADRON ) 
151          sprintf(line1,"CHARGED HADRON") ;
152
153        textTS ->AddText(line1) ;
154        textTS ->Draw("");
155        gPad->Update() ; 
156      }
157    }
158
159      break;
160
161    case kButton1Up:
162      if (textTS) {
163        delete textTS ;
164        textTS = 0 ;
165      }
166      break;  
167    }
168 }
169
170
171 //____________________________________________________________________________
172 Float_t AliPHOSTrackSegment::GetDistanceInPHOSPlane()
173 {
174  
175   TVector3 vecEmc ;
176   fEmcRecPoint->GetLocalPosition(vecEmc) ;
177
178   TVector3 vecPpsd ;
179   if( fPpsdLow->GetMultiplicity() )  
180     fPpsdLow->GetLocalPosition(vecPpsd)  ; 
181   else { 
182     vecPpsd.SetX(10000.) ;
183   } 
184   vecEmc -= vecPpsd ;
185
186   Float_t r = vecEmc.Mag();;
187
188   return r ;
189 }
190
191 //____________________________________________________________________________
192 TVector3 AliPHOSTrackSegment::GetMomentumDirection() 
193 {   
194   TVector3 dir, tempo ; 
195   TMatrix mdummy ;
196
197   TVector3 posEmc ;
198   fEmcRecPoint->GetGlobalPosition(posEmc, mdummy) ;
199
200   TVector3 posPpsdl ;
201   TVector3 posPpsdup ;
202  
203 //   if( fPpsdLow ){
204 //     fPpsdLow->GetGlobalPosition(posPpsdl, mdummy) ; 
205 //     if( !fPpsdUp ) { // draw line trough 2 points
206 //       tempo = posEmc - posPpsdl;
207 //      }
208
209 //     else { // draw line through 3 points
210 //       fPpsdUp->GetGlobalPosition(posPpsdup, mdummy) ;
211 //       posPpsdl = 0.5 * ( posPpsdup + posPpsdl ) ; 
212 //       dir = posEmc - posPpsdl ;
213 //     }
214 //   }
215 //   else 
216     tempo = posEmc ; 
217     
218   dir.SetX( tempo.X() ) ;  // assumes that a neutral comes from the vertex
219   dir.SetY( tempo.Y() ) ;  
220   dir.SetZ( -tempo.Z() ) ; 
221   
222   dir.SetMag(1.) ;
223   return dir ;  
224 }
225
226 //____________________________________________________________________________
227 Int_t AliPHOSTrackSegment::GetPartType()  
228 {  
229   // Returns 0 - gamma
230   //         1 - e+, e-
231   //         2 - neutral   
232   //         3 - charged hadron
233
234   Int_t typeofparticle = kGAMMA ;
235                             
236   if( fPpsdUp == 0 ) {     // Neutral
237
238     if( fPpsdLow == 0 )    // Neutral  
239       typeofparticle = kNEUTRAL ;   
240     else                   // Gamma
241       typeofparticle = kGAMMA ;               
242
243   }
244
245   else {             // Charged           
246
247     if( fEmcRecPoint->GetDispersion() > fCutOnDispersion) 
248       typeofparticle = kCHARGEDHADRON ;
249     else  
250       typeofparticle = kELECTRON ;  
251   
252   }
253   
254   return   typeofparticle ;                     
255
256 }
257
258 //____________________________________________________________________________
259 void AliPHOSTrackSegment::GetPosition( TVector3 & pos ) 
260 {  
261   // Returns positions of hits
262   TMatrix dummy ;
263   fEmcRecPoint->GetGlobalPosition(pos, dummy) ;
264 }
265
266 //______________________________________________________________________________
267 void AliPHOSTrackSegment::Paint(Option_t *)
268 {
269   //Paint this ALiPHOSTrackSegment as a TMarker  with its current attributes
270
271    TVector3 posemc(999., 999., 999.) ;
272    TVector3 posppsdl(999., 999., 999.) ;
273    TVector3 posppsdu(999., 999., 999.) ;
274
275    fEmcRecPoint->GetLocalPosition(posemc) ;
276    if (fPpsdLow !=0 ) 
277      fPpsdLow->GetLocalPosition(posppsdl) ;
278      if (fPpsdUp !=0 ) 
279        fPpsdUp->GetLocalPosition(posppsdu) ;
280
281    Coord_t xemc   = posemc.X() ;
282    Coord_t yemc   = posemc.Z() ;
283
284    Coord_t yppsdl = posppsdl.Z() ;
285    Coord_t xppsdl = posppsdl.X() ;
286
287    Coord_t yppsdu = posppsdu.Z() ;
288    Coord_t xppsdu = posppsdu.X() ;
289
290    Color_t markercolor = 1 ;
291    Size_t  markersize  = 1.5 ;
292    Style_t markerstyle = 20 ;
293
294    if (!gPad->IsBatch()) {
295      gVirtualX->SetMarkerColor(markercolor) ;
296      gVirtualX->SetMarkerSize (markersize)  ;
297      gVirtualX->SetMarkerStyle(markerstyle) ;
298    }
299    gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
300    gPad->PaintPolyMarker(1, &xemc, &yemc, "") ;
301    
302    if (xppsdl != 999. && yppsdl != 999. ) {
303
304      markercolor = 2 ;
305      markersize  = 1.25 ;
306      markerstyle = 21 ;
307      
308      if (!gPad->IsBatch()) {
309        gVirtualX->SetMarkerColor(markercolor) ;
310        gVirtualX->SetMarkerSize (markersize)  ;
311        gVirtualX->SetMarkerStyle(markerstyle) ;
312      }
313      gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
314      gPad->PaintPolyMarker(1, &xppsdl, &yppsdl, "") ;
315    }
316
317     if (xppsdu != 999. && yppsdu != 999. ) {
318   
319       markercolor = 3 ;
320       markersize  = 1. ;
321       markerstyle = 22 ;
322       
323       if (!gPad->IsBatch()) {
324         gVirtualX->SetMarkerColor(markercolor) ;
325         gVirtualX->SetMarkerSize (markersize)  ;
326         gVirtualX->SetMarkerStyle(markerstyle) ;
327       }
328       gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
329       gPad->PaintPolyMarker(1, &xppsdu, &yppsdu, "") ;
330     }
331 }
332
333
334 //____________________________________________________________________________
335 void AliPHOSTrackSegment::Print()
336 {
337   cout << "--------AliPHOSTrackSegment-------- "<<endl ;
338   cout << "EMC Reconstructed Point: " << fEmcRecPoint << endl;
339   
340   TVector3 pos ;
341   TMatrix dummy ;  
342
343   fEmcRecPoint->GetGlobalPosition( pos, dummy ) ;
344  
345   cout << "    position " << pos.X() << "   " << pos.Y() << "  " << pos.Z() << "      Energy " << fEmcRecPoint->GetTotalEnergy() << endl ;
346   cout << "PPSD Low Reconstructed Point: " << endl;
347   
348   if(fPpsdLow){
349     fPpsdLow->GetGlobalPosition( pos , dummy ) ;
350     cout << "    position " << pos.X() << "   " << pos.Y() << "  " << pos.Z() << endl ;
351   }
352
353   cout << "PPSD Up Reconstructed Point: " << endl;
354   
355   if(fPpsdUp ){
356     fPpsdUp->GetGlobalPosition( pos, dummy ) ;
357     cout << "    position " << pos.X() << "   " << pos.Y() << "  " << pos.Z()  << endl ;
358   }
359
360 }
361