]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSTrackSegment.cxx
Changes imposed by HP-UX which ignores the new C++ standart
[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 /* $Id$ */
17
18 //_________________________________________________________________________
19 //  Track segment in PHOS
20 //  Can be : 1 EmcRecPoint
21 //           1 EmcRecPoint + 1 PPSD
22 //           1 EmcRecPoint + 1 PPSD + 1 PPSD     
23 //                  
24 //*-- Author:  Dmitri Peressounko (RRC KI & SUBATECH)
25
26 // --- ROOT system ---
27  
28 #include "TVector3.h"
29 #include "TPad.h"
30
31 // --- Standard library ---
32
33 #include <iostream.h>
34
35 // --- AliRoot header files ---
36
37 #include "AliPHOSTrackSegment.h" 
38 #include "AliPHOSv0.h"
39
40 ClassImp(AliPHOSTrackSegment)
41
42 //____________________________________________________________________________
43 AliPHOSTrackSegment::AliPHOSTrackSegment( AliPHOSEmcRecPoint * emc , AliPHOSPpsdRecPoint * ppsdRP1,
44                   AliPHOSPpsdRecPoint * ppsdRP2  ) 
45 {
46   // ctor
47
48   if( emc )   
49     fEmcRecPoint =  emc ;
50
51   if( ppsdRP1 )  
52     fPpsdUp = ppsdRP1 ;
53
54   if( ppsdRP2  ) 
55     fPpsdLow = ppsdRP2 ;
56
57 }
58
59 //____________________________________________________________________________
60 AliPHOSTrackSegment::AliPHOSTrackSegment( const AliPHOSTrackSegment & ts) 
61 {
62   // Copy ctor
63
64   ( (AliPHOSTrackSegment &)ts ).Copy(*this) ; 
65 }
66
67
68 //____________________________________________________________________________
69 void AliPHOSTrackSegment::Copy(TObject & obj) 
70 {
71   // Copy of a track segment into another track segment
72
73    TObject::Copy(obj) ;
74    ( (AliPHOSTrackSegment &)obj ).fEmcRecPointId = fEmcRecPointId ; 
75    ( (AliPHOSTrackSegment &)obj ).fPpsdLowId     = fPpsdLowId ; 
76    ( (AliPHOSTrackSegment &)obj ).fPpsdUpId      = fPpsdUpId ; 
77 }
78 //____________________________________________________________________________
79 Int_t AliPHOSTrackSegment::DistancetoPrimitive(Int_t px, Int_t py)
80 {
81   // Compute distance from point px,py to  a AliPHOSTrackSegment considered as a Tmarker
82   // Compute the closest distance of approach from point px,py to this marker.
83   // The distance is computed in pixels units.
84   
85   Int_t div = 1 ;  
86   TVector3 pos(0.,0.,0.) ;
87   
88   fEmcRecPoint->GetLocalPosition( pos) ;
89   Float_t x =  pos.X() ;
90   Float_t y =  pos.Z() ;
91   if ( fPpsdLow ) {
92     fPpsdLow->GetLocalPosition( pos ) ;
93     x +=  pos.X() ;
94     y +=  pos.Z() ;
95     div++ ; 
96   }
97   if ( fPpsdUp ) {
98     fPpsdUp->GetLocalPosition( pos ) ;
99     x +=  pos.X() ;
100     y +=  pos.Z() ;
101     div++ ; 
102   }
103   x /= div ; 
104   y /= div ; 
105
106    const Int_t kMaxDiff = 10;
107    Int_t pxm  = gPad->XtoAbsPixel(x);
108    Int_t pym  = gPad->YtoAbsPixel(y);
109    Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
110
111    if (dist > kMaxDiff) return 9999;
112    return dist;
113 }
114
115 //___________________________________________________________________________
116  void AliPHOSTrackSegment::Draw(Option_t *option)
117  {
118    // Draw this AliPHOSTrackSegment with its current attribute
119    
120    AppendPad(option);
121  }
122
123 //______________________________________________________________________________
124 void AliPHOSTrackSegment::ExecuteEvent(Int_t event, Int_t px, Int_t py)
125 {
126   // Execute action corresponding to one event
127   //  This member function is called when a AliPHOSTrackSegment is clicked with the locator
128   //
129   //  If Left button is clicked on AliPHOSRecPoint, the digits are switched on    
130   //  and switched off when the mouse button is released.
131  
132   static TPaveText* textTS = 0 ;
133   
134   if (!gPad->IsEditable()) 
135     return;
136   
137   switch (event) {
138     
139   case kButton1Down:{
140     
141     if (!textTS) {
142       
143       TVector3 pos(0.,0.,0.) ;
144       fEmcRecPoint->GetLocalPosition(pos) ;
145       textTS = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+5,pos.Z()+15,"") ;
146       Text_t  line1[40] ;
147       sprintf(line1,"See RecParticle for ID") ;
148       textTS ->AddText(line1) ;
149       textTS ->Draw("");
150       gPad->Update() ; 
151     }
152   }
153   
154   break;
155   
156   case kButton1Up:
157     if (textTS) {
158       delete textTS ;
159       textTS = 0 ;
160     }
161     break;  
162   }
163 }
164
165 //____________________________________________________________________________
166 Float_t AliPHOSTrackSegment::GetDistanceInPHOSPlane()
167 {
168   // Calculates the distance between the EMC RecPoint and PPSD RecPoint
169   
170   TVector3 vecEmc ;
171   fEmcRecPoint->GetLocalPosition(vecEmc) ;
172   
173   TVector3 vecPpsd ;
174   if( fPpsdLow->GetMultiplicity() )  
175     fPpsdLow->GetLocalPosition(vecPpsd)  ; 
176   else { 
177     vecPpsd.SetX(10000.) ;
178   } 
179   vecEmc -= vecPpsd ;
180
181   Float_t r = vecEmc.Mag();;
182
183   return r ;
184 }
185
186 //____________________________________________________________________________
187 TVector3 AliPHOSTrackSegment::GetMomentumDirection() 
188
189   // Calculates the momentum direction:
190   //   1. if only a EMC RecPoint, direction is given by IP and this RecPoint
191   //   2. if a EMC RecPoint and one PPSD RecPoint, direction is given by the line through the 2 recpoints 
192   //   3. if a EMC RecPoint and two PPSD RecPoints, dirrection is given by the average line through 
193   //      the 2 pairs of recpoints  
194   // However because of the poor position resolution of PPSD the direction is always taken as if we were 
195   //  in case 1.
196
197   TVector3 dir(0,0,0) ; 
198   TMatrix mdummy ;
199
200   TVector3 posEmc ;
201   fEmcRecPoint->GetGlobalPosition(posEmc, mdummy) ;
202
203   // Correction for the depth of the shower starting point (TDR p 127) 
204
205   Float_t energy = fEmcRecPoint->GetEnergy() ; 
206   Float_t para = 0.925 ; 
207   Float_t parb = 6.52 ; 
208
209   TVector3 localpos ; 
210   fEmcRecPoint->GetLocalPosition(localpos) ; 
211
212   AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ; 
213   Float_t radius = geom->GetIPtoOuterCoverDistance() + geom->GetOuterBoxSize(1) ; 
214   Float_t incidencephi = TMath::ATan(localpos.X() / radius) ; 
215   Float_t incidencetheta = TMath::ATan(localpos.Z() / radius) ;
216  
217   Float_t depthx =  ( para * TMath::Log(energy) + parb ) * TMath::Sin(incidencephi) ; 
218   Float_t depthz =  ( para * TMath::Log(energy) + parb ) * TMath::Sin(incidencetheta) ; 
219   
220   localpos.SetX(localpos.X() - depthx ) ;
221   localpos.SetZ(localpos.Z() - depthz ) ;
222  
223   TVector3 emcglobalpos ;
224   TMatrix  dummy ;
225
226   fEmcRecPoint->GetGlobalPosition(emcglobalpos, dummy) ;
227
228   emcglobalpos.SetX( emcglobalpos.X() - depthx ) ;  
229   emcglobalpos.SetZ( emcglobalpos.Z() - depthz ) ;   
230   
231   // The following commeneted code becomes valid once the PPSD provides 
232   // a reasonable position resolution, at least as good as EMC !
233  
234 //   TVector3 ppsdlglobalpos ;
235 //   TVector3 ppsduglobalpos ;
236
237 //   if( fPpsdLow ){ // certainly a photon that has concerted
238         
239 //     fPpsdLow->GetGlobalPosition(ppsdlglobalpos, mdummy) ; 
240 //     dir = emcglobalpos -  ppsdlglobalpos ; 
241      
242 //     if( fPpsdUp ){ // nop looks like a charged
243        
244 //        fPpsdUp->GetGlobalPosition(ppsduglobalpos, mdummy) ; 
245 //        dir = ( dir +  emcglobalpos -  ppsduglobalpos ) * 0.5 ; 
246 //      }
247 //   }
248  
249 //   else { // looks like a neutral
250
251     dir = emcglobalpos ;  
252 //  }
253
254   dir.SetZ( -dir.Z() ) ;   // why ?  
255   dir.SetMag(1.) ;
256     
257   return dir ;  
258 }
259
260 //____________________________________________________________________________
261 Int_t *  AliPHOSTrackSegment::GetPrimariesEmc(Int_t & number) 
262
263   // Retrieves the primary particle(s) at the origin of the EMC RecPoint
264   
265   Int_t * rv = 0 ; 
266   number = 0 ;
267   if ( fEmcRecPoint )
268     rv =  fEmcRecPoint->GetPrimaries(number) ; 
269
270   return rv ; 
271 }
272
273 //____________________________________________________________________________
274 Int_t *  AliPHOSTrackSegment::GetPrimariesPpsdLow(Int_t & number) 
275
276   // Retrieves the primary particle(s) at the origin of the lower PPSD RecPoint
277   
278   Int_t * rv = 0 ; 
279   number = 0 ;
280   if ( fPpsdLow )
281     rv =  fPpsdLow->GetPrimaries(number) ; 
282
283   return rv ; 
284 }
285
286 //____________________________________________________________________________
287 Int_t *  AliPHOSTrackSegment::GetPrimariesPpsdUp(Int_t & number) 
288
289   // Retrieves the primary particle(s) at the origin of the upper PPSD  RecPoint
290   
291   Int_t * rv = 0 ; 
292   number = 0 ;
293   if ( fPpsdUp )
294     rv =  fPpsdUp->GetPrimaries(number) ; 
295
296   return rv ; 
297 }
298
299 //____________________________________________________________________________
300 void AliPHOSTrackSegment::GetPosition( TVector3 & pos ) 
301 {  
302   // Returns position of the EMC RecPoint
303
304   TMatrix dummy ;
305   fEmcRecPoint->GetGlobalPosition(pos, dummy) ;
306 }
307
308
309 //______________________________________________________________________________
310 void AliPHOSTrackSegment::Paint(Option_t *)
311 {
312   // Paint this ALiPHOSTrackSegment as a TMarker  with its current attributes
313
314   TVector3 posemc(999., 999., 999.) ;
315   TVector3 posppsdl(999., 999., 999.) ;
316   TVector3 posppsdu(999., 999., 999.) ;
317   
318   fEmcRecPoint->GetLocalPosition(posemc) ;
319   if (fPpsdLow !=0 ) 
320     fPpsdLow->GetLocalPosition(posppsdl) ;
321   if (fPpsdUp !=0 ) 
322     fPpsdUp->GetLocalPosition(posppsdu) ;
323   
324   Coord_t xemc   = posemc.X() ;
325   Coord_t yemc   = posemc.Z() ;
326   
327   Coord_t yppsdl = posppsdl.Z() ;
328   Coord_t xppsdl = posppsdl.X() ;
329   
330   Coord_t yppsdu = posppsdu.Z() ;
331   Coord_t xppsdu = posppsdu.X() ;
332   
333   Color_t markercolor = 1 ;
334   Size_t  markersize  = 1.5 ;
335   Style_t markerstyle = 20 ;
336   
337   if (!gPad->IsBatch()) {
338     gVirtualX->SetMarkerColor(markercolor) ;
339     gVirtualX->SetMarkerSize (markersize)  ;
340     gVirtualX->SetMarkerStyle(markerstyle) ;
341   }
342   gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
343   gPad->PaintPolyMarker(1, &xemc, &yemc, "") ;
344   
345   if (xppsdl != 999. && yppsdl != 999. ) {
346     
347     markercolor = 2 ;
348     markersize  = 1.25 ;
349     markerstyle = 21 ;
350     
351     if (!gPad->IsBatch()) {
352       gVirtualX->SetMarkerColor(markercolor) ;
353       gVirtualX->SetMarkerSize (markersize)  ;
354       gVirtualX->SetMarkerStyle(markerstyle) ;
355     }
356     gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
357     gPad->PaintPolyMarker(1, &xppsdl, &yppsdl, "") ;
358   }
359   
360   if (xppsdu != 999. && yppsdu != 999. ) {
361     
362     markercolor = 3 ;
363     markersize  = 1. ;
364     markerstyle = 22 ;
365     
366     if (!gPad->IsBatch()) {
367       gVirtualX->SetMarkerColor(markercolor) ;
368       gVirtualX->SetMarkerSize (markersize)  ;
369       gVirtualX->SetMarkerStyle(markerstyle) ;
370     }
371     gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
372     gPad->PaintPolyMarker(1, &xppsdu, &yppsdu, "") ;
373   }
374 }
375
376 //____________________________________________________________________________
377 void AliPHOSTrackSegment::Print()
378 {
379   // Print all information on this track Segment
380   
381   cout << "--------AliPHOSTrackSegment-------- "<<endl ;
382   cout << "EMC Reconstructed Point: " << fEmcRecPoint << endl;
383   
384   TVector3 pos ;
385   TMatrix dummy ;  
386
387   fEmcRecPoint->GetGlobalPosition( pos, dummy ) ;
388  
389   cout << "    position " << pos.X() << "   " << pos.Y() << "  " << pos.Z() << "      Energy " << fEmcRecPoint->GetTotalEnergy() << endl ;
390   cout << "PPSD Low Reconstructed Point: " << endl;
391   
392   if(fPpsdLow){
393     fPpsdLow->GetGlobalPosition( pos , dummy ) ;
394     cout << "    position " << pos.X() << "   " << pos.Y() << "  " << pos.Z() << endl ;
395   }
396
397   cout << "PPSD Up Reconstructed Point: " << endl;
398   
399   if(fPpsdUp ){
400     fPpsdUp->GetGlobalPosition( pos, dummy ) ;
401     cout << "    position " << pos.X() << "   " << pos.Y() << "  " << pos.Z()  << endl ;
402   }
403
404 }
405