]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSTrackSegment.cxx
only cosmetics
[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 }
51
52 //____________________________________________________________________________
53 AliPHOSTrackSegment::AliPHOSTrackSegment( const AliPHOSTrackSegment & ts) 
54 {
55   ( (AliPHOSTrackSegment &)ts ).Copy(*this) ; 
56 }
57
58 //____________________________________________________________________________
59 AliPHOSTrackSegment::~AliPHOSTrackSegment() // dtor
60 {
61 //    fEmcRecPoint.Delete() ;   Not Owners !!!
62 //    fPpsdUp.Delete() ;
63 //    fPpsdLow.Delete() ;
64 }
65
66 //____________________________________________________________________________
67 void AliPHOSTrackSegment::Copy(TObject & obj) 
68 {
69    TObject::Copy(obj) ;
70    ( (AliPHOSTrackSegment &)obj ).fEmcRecPoint = fEmcRecPoint ; 
71    ( (AliPHOSTrackSegment &)obj ).fPpsdLow     = fPpsdLow ; 
72    ( (AliPHOSTrackSegment &)obj ).fPpsdUp      = fPpsdUp ; 
73 }
74 //____________________________________________________________________________
75 Int_t AliPHOSTrackSegment::DistancetoPrimitive(Int_t px, Int_t py)
76 {
77   //Compute distance from point px,py to  a AliPHOSTrackSegment considered as a Tmarker
78   //  Compute the closest distance of approach from point px,py to this marker.
79   //  The distance is computed in pixels units.
80   //
81   Int_t div = 1 ;  
82   TVector3 pos(0.,0.,0.) ;
83  
84   fEmcRecPoint->GetLocalPosition( pos) ;
85   Float_t x =  pos.X() ;
86   Float_t y =  pos.Z() ;
87   if ( fPpsdLow ) {
88     fPpsdLow->GetLocalPosition( pos ) ;
89     x +=  pos.X() ;
90     y +=  pos.Z() ;
91     div++ ; 
92   }
93   if ( fPpsdUp ) {
94     fPpsdUp->GetLocalPosition( pos ) ;
95     x +=  pos.X() ;
96     y +=  pos.Z() ;
97     div++ ; 
98   }
99   x /= div ; 
100   y /= div ; 
101
102    const Int_t kMaxDiff = 10;
103    Int_t pxm  = gPad->XtoAbsPixel(x);
104    Int_t pym  = gPad->YtoAbsPixel(y);
105    Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
106
107    if (dist > kMaxDiff) return 9999;
108    return dist;
109 }
110
111 //___________________________________________________________________________
112  void AliPHOSTrackSegment::Draw(Option_t *option)
113  {
114    // Draw this AliPHOSTrackSegment with its current attribute
115
116    AppendPad(option);
117  }
118
119 //______________________________________________________________________________
120 void AliPHOSTrackSegment::ExecuteEvent(Int_t event, Int_t px, Int_t py)
121 {
122   // Execute action corresponding to one event
123   //  This member function is called when a AliPHOSTrackSegment is clicked with the locator
124   //
125   //  If Left button is clicked on AliPHOSRecPoint, the digits are switched on    
126   //  and switched off when the mouse button is released.
127   //
128    static TPaveText* textTS = 0 ;
129
130    if (!gPad->IsEditable()) 
131      return;
132
133    switch (event) {
134
135    case kButton1Down:{
136     
137      if (!textTS) {
138   
139        TVector3 pos(0.,0.,0.) ;
140        fEmcRecPoint->GetLocalPosition(pos) ;
141        textTS = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+5,pos.Z()+15,"") ;
142        Text_t  line1[40] ;
143        sprintf(line1,"See RecParticle for ID") ;
144        textTS ->AddText(line1) ;
145        textTS ->Draw("");
146        gPad->Update() ; 
147      }
148    }
149
150      break;
151
152    case kButton1Up:
153      if (textTS) {
154        delete textTS ;
155        textTS = 0 ;
156      }
157      break;  
158    }
159 }
160
161
162 //____________________________________________________________________________
163 Float_t AliPHOSTrackSegment::GetDistanceInPHOSPlane()
164 {
165  
166   TVector3 vecEmc ;
167   fEmcRecPoint->GetLocalPosition(vecEmc) ;
168
169   TVector3 vecPpsd ;
170   if( fPpsdLow->GetMultiplicity() )  
171     fPpsdLow->GetLocalPosition(vecPpsd)  ; 
172   else { 
173     vecPpsd.SetX(10000.) ;
174   } 
175   vecEmc -= vecPpsd ;
176
177   Float_t r = vecEmc.Mag();;
178
179   return r ;
180 }
181
182 //____________________________________________________________________________
183 TVector3 AliPHOSTrackSegment::GetMomentumDirection() 
184 {   
185   TVector3 dir, tempo ; 
186   TMatrix mdummy ;
187
188   TVector3 posEmc ;
189   fEmcRecPoint->GetGlobalPosition(posEmc, mdummy) ;
190
191   TVector3 posPpsdl ;
192   TVector3 posPpsdup ;
193  
194 //   if( fPpsdLow ){
195 //     fPpsdLow->GetGlobalPosition(posPpsdl, mdummy) ; 
196 //     if( !fPpsdUp ) { // draw line trough 2 points
197 //       tempo = posEmc - posPpsdl;
198 //      }
199
200 //     else { // draw line through 3 points
201 //       fPpsdUp->GetGlobalPosition(posPpsdup, mdummy) ;
202 //       posPpsdl = 0.5 * ( posPpsdup + posPpsdl ) ; 
203 //       dir = posEmc - posPpsdl ;
204 //     }
205 //   }
206 //   else 
207     tempo = posEmc ; 
208     
209   dir.SetX( tempo.X() ) ;  // assumes that a neutral comes from the vertex
210   dir.SetY( tempo.Y() ) ;  
211   dir.SetZ( -tempo.Z() ) ; 
212   
213   dir.SetMag(1.) ;
214   return dir ;  
215 }
216
217
218 //____________________________________________________________________________
219 void AliPHOSTrackSegment::GetPosition( TVector3 & pos ) 
220 {  
221   // Returns positions of hits
222   TMatrix dummy ;
223   fEmcRecPoint->GetGlobalPosition(pos, dummy) ;
224 }
225
226 //______________________________________________________________________________
227 void AliPHOSTrackSegment::Paint(Option_t *)
228 {
229   //Paint this ALiPHOSTrackSegment as a TMarker  with its current attributes
230
231    TVector3 posemc(999., 999., 999.) ;
232    TVector3 posppsdl(999., 999., 999.) ;
233    TVector3 posppsdu(999., 999., 999.) ;
234
235    fEmcRecPoint->GetLocalPosition(posemc) ;
236    if (fPpsdLow !=0 ) 
237      fPpsdLow->GetLocalPosition(posppsdl) ;
238      if (fPpsdUp !=0 ) 
239        fPpsdUp->GetLocalPosition(posppsdu) ;
240
241    Coord_t xemc   = posemc.X() ;
242    Coord_t yemc   = posemc.Z() ;
243
244    Coord_t yppsdl = posppsdl.Z() ;
245    Coord_t xppsdl = posppsdl.X() ;
246
247    Coord_t yppsdu = posppsdu.Z() ;
248    Coord_t xppsdu = posppsdu.X() ;
249
250    Color_t markercolor = 1 ;
251    Size_t  markersize  = 1.5 ;
252    Style_t markerstyle = 20 ;
253
254    if (!gPad->IsBatch()) {
255      gVirtualX->SetMarkerColor(markercolor) ;
256      gVirtualX->SetMarkerSize (markersize)  ;
257      gVirtualX->SetMarkerStyle(markerstyle) ;
258    }
259    gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
260    gPad->PaintPolyMarker(1, &xemc, &yemc, "") ;
261    
262    if (xppsdl != 999. && yppsdl != 999. ) {
263
264      markercolor = 2 ;
265      markersize  = 1.25 ;
266      markerstyle = 21 ;
267      
268      if (!gPad->IsBatch()) {
269        gVirtualX->SetMarkerColor(markercolor) ;
270        gVirtualX->SetMarkerSize (markersize)  ;
271        gVirtualX->SetMarkerStyle(markerstyle) ;
272      }
273      gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
274      gPad->PaintPolyMarker(1, &xppsdl, &yppsdl, "") ;
275    }
276
277     if (xppsdu != 999. && yppsdu != 999. ) {
278   
279       markercolor = 3 ;
280       markersize  = 1. ;
281       markerstyle = 22 ;
282       
283       if (!gPad->IsBatch()) {
284         gVirtualX->SetMarkerColor(markercolor) ;
285         gVirtualX->SetMarkerSize (markersize)  ;
286         gVirtualX->SetMarkerStyle(markerstyle) ;
287       }
288       gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
289       gPad->PaintPolyMarker(1, &xppsdu, &yppsdu, "") ;
290     }
291 }
292
293
294 //____________________________________________________________________________
295 void AliPHOSTrackSegment::Print()
296 {
297   cout << "--------AliPHOSTrackSegment-------- "<<endl ;
298   cout << "EMC Reconstructed Point: " << fEmcRecPoint << endl;
299   
300   TVector3 pos ;
301   TMatrix dummy ;  
302
303   fEmcRecPoint->GetGlobalPosition( pos, dummy ) ;
304  
305   cout << "    position " << pos.X() << "   " << pos.Y() << "  " << pos.Z() << "      Energy " << fEmcRecPoint->GetTotalEnergy() << endl ;
306   cout << "PPSD Low Reconstructed Point: " << endl;
307   
308   if(fPpsdLow){
309     fPpsdLow->GetGlobalPosition( pos , dummy ) ;
310     cout << "    position " << pos.X() << "   " << pos.Y() << "  " << pos.Z() << endl ;
311   }
312
313   cout << "PPSD Up Reconstructed Point: " << endl;
314   
315   if(fPpsdUp ){
316     fPpsdUp->GetGlobalPosition( pos, dummy ) ;
317     cout << "    position " << pos.X() << "   " << pos.Y() << "  " << pos.Z()  << endl ;
318   }
319
320 }
321