]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSTrackSegment.cxx
This is a MAJOR modification:
[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 #include "AliPHOSIndexToObject.h"
40
41 ClassImp(AliPHOSTrackSegment)
42
43 //____________________________________________________________________________
44 AliPHOSTrackSegment::AliPHOSTrackSegment( AliPHOSEmcRecPoint * emc , AliPHOSPpsdRecPoint * ppsdrp1,
45                   AliPHOSPpsdRecPoint * ppsdrp2  ) 
46 {
47   // ctor
48
49   if( emc )   
50     fEmcRecPoint =  emc->GetIndexInList() ;
51   else 
52     fEmcRecPoint = -1 ;
53
54   if( ppsdrp1 )  
55     fPpsdUpRecPoint = ppsdrp1->GetIndexInList() ;
56  else 
57     fPpsdUpRecPoint = -1 ;
58
59   if( ppsdrp2  ) 
60     fPpsdLowRecPoint = ppsdrp2->GetIndexInList() ;
61   else 
62     fPpsdLowRecPoint = -1 ;
63
64   fIndexInList = -1 ;
65 }
66
67 //____________________________________________________________________________
68 AliPHOSTrackSegment::AliPHOSTrackSegment( const AliPHOSTrackSegment & ts) 
69 {
70   // Copy ctor
71
72   ( (AliPHOSTrackSegment &)ts ).Copy(*this) ; 
73 }
74
75
76 //____________________________________________________________________________
77 void AliPHOSTrackSegment::Copy(TObject & obj) 
78 {
79   // Copy of a track segment into another track segment
80
81    TObject::Copy(obj) ;
82    ( (AliPHOSTrackSegment &)obj ).fEmcRecPoint     = fEmcRecPoint ; 
83    ( (AliPHOSTrackSegment &)obj ).fPpsdLowRecPoint = fPpsdLowRecPoint ; 
84    ( (AliPHOSTrackSegment &)obj ).fPpsdUpRecPoint  = fPpsdUpRecPoint ; 
85    ( (AliPHOSTrackSegment &)obj ).fIndexInList     = fIndexInList ; 
86 }
87 //____________________________________________________________________________
88 Int_t AliPHOSTrackSegment::DistancetoPrimitive(Int_t px, Int_t py)
89 {
90   // Compute distance from point px,py to  a AliPHOSTrackSegment considered as a Tmarker
91   // Compute the closest distance of approach from point px,py to this marker.
92   // The distance is computed in pixels units.
93   
94   Int_t div = 1 ;  
95   Int_t dist = 9999 ; 
96   
97   TVector3 pos(0.,0.,0.) ;
98   
99   AliPHOSEmcRecPoint  * emcrp   = GetEmcRecPoint() ; 
100   AliPHOSPpsdRecPoint * ppsdlrp = GetPpsdLowRecPoint() ; 
101   AliPHOSPpsdRecPoint * ppsdurp = GetPpsdUpRecPoint() ; 
102   
103   if ( emcrp != 0 ) {
104     emcrp->GetLocalPosition( pos) ;
105     Float_t x =  pos.X() ;
106     Float_t y =  pos.Z() ;
107     if ( ppsdlrp != 0 ) {
108       ppsdlrp->GetLocalPosition( pos ) ;
109       x +=  pos.X() ;
110       y +=  pos.Z() ;
111       div++ ; 
112     }
113     if ( ppsdurp != 0 ) {
114       ppsdurp->GetLocalPosition( pos ) ;
115       x +=  pos.X() ;
116       y +=  pos.Z() ;
117       div++ ; 
118     }
119     x /= div ; 
120     y /= div ; 
121
122     const Int_t kMaxDiff = 10;
123     Int_t pxm  = gPad->XtoAbsPixel(x);
124     Int_t pym  = gPad->YtoAbsPixel(y);
125     dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
126     
127     if (dist > kMaxDiff) return 9999;
128   }
129   return dist;
130 }
131
132 //___________________________________________________________________________
133  void AliPHOSTrackSegment::Draw(Option_t *option)
134  {
135    // Draw this AliPHOSTrackSegment with its current attribute
136    
137    AppendPad(option);
138  }
139
140 //______________________________________________________________________________
141 void AliPHOSTrackSegment::ExecuteEvent(Int_t event, Int_t px, Int_t py)
142 {
143   // Execute action corresponding to one event
144   //  This member function is called when a AliPHOSTrackSegment is clicked with the locator
145   //
146   //  If Left button is clicked on AliPHOSRecPoint, the digits are switched on    
147   //  and switched off when the mouse button is released.
148  
149   static TPaveText* textTS = 0 ;
150   
151   AliPHOSEmcRecPoint  * emcrp   = GetEmcRecPoint() ; 
152
153   if (!gPad->IsEditable()) 
154     return;
155   
156   switch (event) {
157     
158   case kButton1Down:{
159     
160     if (!textTS) {
161       
162       TVector3 pos(0.,0.,0.) ;
163       emcrp->GetLocalPosition(pos) ;
164       textTS = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+5,pos.Z()+15,"") ;
165       Text_t  line1[40] ;
166       sprintf(line1,"See RecParticle for ID") ;
167       textTS ->AddText(line1) ;
168       textTS ->Draw("");
169       gPad->Update() ; 
170     }
171   }
172   
173   break;
174   
175   case kButton1Up:
176     if (textTS) {
177       delete textTS ;
178       textTS = 0 ;
179     }
180     break;  
181   }
182 }
183
184 //____________________________________________________________________________
185 Float_t AliPHOSTrackSegment::GetDistanceInPHOSPlane()
186 {
187   // Calculates the distance between the EMC RecPoint and PPSD RecPoint
188   
189   AliPHOSEmcRecPoint  * emcrp   = GetEmcRecPoint() ; 
190   AliPHOSPpsdRecPoint * ppsdlrp = GetPpsdLowRecPoint() ; 
191
192   TVector3 vecEmc ;
193   emcrp->GetLocalPosition(vecEmc) ;
194   
195   TVector3 vecPpsd ;
196   if ( ppsdlrp !=0 ) {
197     if( ppsdlrp->GetMultiplicity() )  
198       ppsdlrp->GetLocalPosition(vecPpsd)  ; 
199     else { 
200       vecPpsd.SetX(10000.) ;
201     } 
202     vecEmc -= vecPpsd ;
203   }
204   Float_t r = vecEmc.Mag();;
205
206   return r ;
207 }
208
209 //____________________________________________________________________________
210 AliPHOSEmcRecPoint * AliPHOSTrackSegment::GetEmcRecPoint() const 
211 {
212   AliPHOSIndexToObject * please =  AliPHOSIndexToObject::GetInstance() ;
213   AliPHOSEmcRecPoint * rv = 0 ;
214   if (  fEmcRecPoint > -1 )
215     rv = (AliPHOSEmcRecPoint *)please->GimeRecPoint( fEmcRecPoint, TString("emc") );
216   
217   return rv ;
218
219 }
220   
221 //____________________________________________________________________________
222  Float_t AliPHOSTrackSegment::GetEnergy()
223
224   // Returns energy in EMC
225   
226   AliPHOSEmcRecPoint  * emcrp   = GetEmcRecPoint() ; 
227   
228   return emcrp->GetTotalEnergy() ;
229 }   
230
231 //____________________________________________________________________________
232 TVector3 AliPHOSTrackSegment::GetMomentumDirection() 
233
234   // Calculates the momentum direction:
235   //   1. if only a EMC RecPoint, direction is given by IP and this RecPoint
236   //   2. if a EMC RecPoint and one PPSD RecPoint, direction is given by the line through the 2 recpoints 
237   //   3. if a EMC RecPoint and two PPSD RecPoints, dirrection is given by the average line through 
238   //      the 2 pairs of recpoints  
239   // However because of the poor position resolution of PPSD the direction is always taken as if we were 
240   //  in case 1.
241
242
243   AliPHOSEmcRecPoint  * emcrp   = GetEmcRecPoint() ; 
244   // AliPHOSPpsdRecPoint * ppsdlrp = GetPpsdLowRecPoint() ; 
245   // AliPHOSPpsdRecPoint * ppsdurp = GetPpsdUpRecPoint() ; 
246
247   TVector3 dir(0,0,0) ; 
248   TMatrix mdummy ;
249
250   TVector3 posEmc ;
251   emcrp->GetGlobalPosition(posEmc, mdummy) ;
252
253   // Correction for the depth of the shower starting point (TDR p 127) 
254
255   Float_t energy = emcrp->GetEnergy() ; 
256   Float_t para = 0.925 ; 
257   Float_t parb = 6.52 ; 
258
259   TVector3 localpos ; 
260   emcrp->GetLocalPosition(localpos) ; 
261
262   AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ; 
263   Float_t radius = geom->GetIPtoOuterCoverDistance() + geom->GetOuterBoxSize(1) ; 
264   Float_t incidencephi = TMath::ATan(localpos.X() / radius) ; 
265   Float_t incidencetheta = TMath::ATan(localpos.Z() / radius) ;
266  
267   Float_t depthx =  ( para * TMath::Log(energy) + parb ) * TMath::Sin(incidencephi) ; 
268   Float_t depthz =  ( para * TMath::Log(energy) + parb ) * TMath::Sin(incidencetheta) ; 
269   
270   localpos.SetX(localpos.X() - depthx ) ;
271   localpos.SetZ(localpos.Z() - depthz ) ;
272  
273   TVector3 emcglobalpos ;
274   TMatrix  dummy ;
275
276   emcrp->GetGlobalPosition(emcglobalpos, dummy) ;
277
278   emcglobalpos.SetX( emcglobalpos.X() - depthx ) ;  
279   emcglobalpos.SetZ( emcglobalpos.Z() - depthz ) ;   
280   
281   // The following commeneted code becomes valid once the PPSD provides 
282   // a reasonable position resolution, at least as good as EMC !
283  
284 //   TVector3 ppsdlglobalpos ;
285 //   TVector3 ppsduglobalpos ;
286
287 //   if( fPpsdLowRecPoint ){ // certainly a photon that has concerted
288         
289 //     fPpsdLowRecPoint->GetGlobalPosition(ppsdlglobalpos, mdummy) ; 
290 //     dir = emcglobalpos -  ppsdlglobalpos ; 
291      
292 //     if( fPpsdUpRecPoint ){ // nop looks like a charged
293        
294 //        fPpsdUpRecPoint->GetGlobalPosition(ppsduglobalpos, mdummy) ; 
295 //        dir = ( dir +  emcglobalpos -  ppsduglobalpos ) * 0.5 ; 
296 //      }
297 //   }
298  
299 //   else { // looks like a neutral
300
301     dir = emcglobalpos ;  
302 //  }
303
304   dir.SetZ( -dir.Z() ) ;   // why ?  
305   dir.SetMag(1.) ;
306     
307   return dir ;  
308 }
309
310 //____________________________________________________________________________
311 Int_t AliPHOSTrackSegment:: GetPHOSMod(void) 
312 {
313   
314   AliPHOSEmcRecPoint  * emcrp   = GetEmcRecPoint() ; 
315   
316   return emcrp->GetPHOSMod();  
317 }
318
319 //____________________________________________________________________________
320 AliPHOSPpsdRecPoint * AliPHOSTrackSegment::GetPpsdLowRecPoint() const 
321 {
322   AliPHOSIndexToObject * please =  AliPHOSIndexToObject::GetInstance() ;
323   AliPHOSPpsdRecPoint * rv = 0 ;
324
325   if ( fPpsdLowRecPoint > -1 )
326     rv = (AliPHOSPpsdRecPoint *)please->GimeRecPoint( fPpsdLowRecPoint, TString("ppsd") ) ;
327   
328   return rv ; 
329 }
330
331 //____________________________________________________________________________
332 AliPHOSPpsdRecPoint * AliPHOSTrackSegment::GetPpsdUpRecPoint() const 
333 {
334   AliPHOSIndexToObject * please =  AliPHOSIndexToObject::GetInstance() ;
335   AliPHOSPpsdRecPoint * rv = 0 ;
336  
337   if ( fPpsdUpRecPoint > -1 )
338     rv =  (AliPHOSPpsdRecPoint *)please->GimeRecPoint( fPpsdUpRecPoint, TString("ppsd") ) ;
339
340   return rv ;
341 }
342
343 //____________________________________________________________________________
344 Int_t *  AliPHOSTrackSegment::GetPrimariesEmc(Int_t & number) 
345
346   // Retrieves the primary particle(s) at the origin of the EMC RecPoint
347     
348   AliPHOSEmcRecPoint  * emcrp   = GetEmcRecPoint() ; 
349
350   Int_t * rv = 0 ; 
351   number = 0 ;
352   if ( emcrp )
353     rv =  emcrp->GetPrimaries(number) ; 
354
355   return rv ; 
356 }
357
358 //____________________________________________________________________________
359 Int_t *  AliPHOSTrackSegment::GetPrimariesPpsdLow(Int_t & number) 
360
361   // Retrieves the primary particle(s) at the origin of the lower PPSD RecPoint
362   
363   AliPHOSPpsdRecPoint * ppsdlrp = GetPpsdLowRecPoint() ; 
364
365   Int_t * rv = 0 ; 
366   number = 0 ;
367   if ( ppsdlrp )
368     rv =  ppsdlrp->GetPrimaries(number) ; 
369
370   return rv ; 
371 }
372
373 //____________________________________________________________________________
374 Int_t *  AliPHOSTrackSegment::GetPrimariesPpsdUp(Int_t & number) 
375
376   // Retrieves the primary particle(s) at the origin of the upper PPSD  RecPoint
377   
378   AliPHOSPpsdRecPoint * ppsdurp = GetPpsdUpRecPoint() ; 
379
380   Int_t * rv = 0 ; 
381   number = 0 ;
382   if ( ppsdurp )
383     rv =  ppsdurp->GetPrimaries(number) ; 
384
385   return rv ; 
386 }
387
388 //____________________________________________________________________________
389 void AliPHOSTrackSegment::GetPosition( TVector3 & pos ) 
390 {  
391   // Returns position of the EMC RecPoint
392   
393   AliPHOSEmcRecPoint  * emcrp   = GetEmcRecPoint() ; 
394  
395   TMatrix dummy ;
396   emcrp->GetGlobalPosition(pos, dummy) ;
397 }
398
399
400 //______________________________________________________________________________
401 void AliPHOSTrackSegment::Paint(Option_t *)
402 {
403   // Paint this AliPHOSTrackSegment as a TMarker  with its current attributes
404
405   AliPHOSEmcRecPoint  * emcrp   = GetEmcRecPoint() ; 
406   AliPHOSPpsdRecPoint * ppsdlrp = GetPpsdLowRecPoint() ; 
407   AliPHOSPpsdRecPoint * ppsdurp = GetPpsdUpRecPoint() ; 
408
409   TVector3 posemc(999., 999., 999.) ;
410   TVector3 posppsdl(999., 999., 999.) ;
411   TVector3 posppsdu(999., 999., 999.) ;
412   
413   emcrp->GetLocalPosition(posemc) ;
414   if (ppsdlrp !=0 ) 
415     ppsdlrp->GetLocalPosition(posppsdl) ;
416   if (ppsdurp !=0 ) 
417     ppsdurp->GetLocalPosition(posppsdu) ;
418   
419   Coord_t xemc   = posemc.X() ;
420   Coord_t yemc   = posemc.Z() ;
421   
422   Coord_t yppsdl = posppsdl.Z() ;
423   Coord_t xppsdl = posppsdl.X() ;
424   
425   Coord_t yppsdu = posppsdu.Z() ;
426   Coord_t xppsdu = posppsdu.X() ;
427   
428   Color_t markercolor = 1 ;
429   Size_t  markersize  = 1.5 ;
430   Style_t markerstyle = 20 ;
431   
432   if (!gPad->IsBatch()) {
433     gVirtualX->SetMarkerColor(markercolor) ;
434     gVirtualX->SetMarkerSize (markersize)  ;
435     gVirtualX->SetMarkerStyle(markerstyle) ;
436   }
437   gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
438   gPad->PaintPolyMarker(1, &xemc, &yemc, "") ;
439   
440   if (xppsdl != 999. && yppsdl != 999. ) {
441     
442     markercolor = 2 ;
443     markersize  = 1.25 ;
444     markerstyle = 21 ;
445     
446     if (!gPad->IsBatch()) {
447       gVirtualX->SetMarkerColor(markercolor) ;
448       gVirtualX->SetMarkerSize (markersize)  ;
449       gVirtualX->SetMarkerStyle(markerstyle) ;
450     }
451     gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
452     gPad->PaintPolyMarker(1, &xppsdl, &yppsdl, "") ;
453   }
454   
455   if (xppsdu != 999. && yppsdu != 999. ) {
456     
457     markercolor = 3 ;
458     markersize  = 1. ;
459     markerstyle = 22 ;
460     
461     if (!gPad->IsBatch()) {
462       gVirtualX->SetMarkerColor(markercolor) ;
463       gVirtualX->SetMarkerSize (markersize)  ;
464       gVirtualX->SetMarkerStyle(markerstyle) ;
465     }
466     gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
467     gPad->PaintPolyMarker(1, &xppsdu, &yppsdu, "") ;
468   }
469 }
470
471 //____________________________________________________________________________
472 void AliPHOSTrackSegment::Print()
473 {
474   // Print all information on this track Segment
475   
476   AliPHOSEmcRecPoint  * emcrp   = GetEmcRecPoint() ; 
477   AliPHOSPpsdRecPoint * ppsdlrp = GetPpsdLowRecPoint() ; 
478   AliPHOSPpsdRecPoint * ppsdurp = GetPpsdUpRecPoint() ; 
479   
480   TVector3 pos ;
481   TMatrix dummy ;  
482
483   cout << "--------AliPHOSTrackSegment-------- "<<endl ;
484
485   if ( emcrp != 0 ) {
486     cout << "******** EMC Reconstructed Point: " << endl;
487     emcrp->Print() ; 
488     
489     emcrp->GetGlobalPosition( pos, dummy ) ;
490     
491     cout << " Global position " << pos.X() << "   " << pos.Y() << "  " << pos.Z() << "      Energy " << emcrp->GetTotalEnergy() << endl ;
492   }
493   
494   if ( ppsdlrp != 0 ) {
495     cout << "******** PPSD Low Reconstructed Point: " << endl;
496     
497     ppsdlrp->Print() ; 
498     ppsdlrp->GetGlobalPosition( pos , dummy ) ;
499     cout << "    position " << pos.X() << "   " << pos.Y() << "  " << pos.Z() << endl ;
500   }
501
502    if( ppsdurp != 0 ) {
503      cout << "******** PPSD Up Reconstructed Point: " << endl;
504      
505      ppsdurp->Print() ; 
506      ppsdurp->GetGlobalPosition( pos, dummy ) ;
507      cout << "    position " << pos.X() << "   " << pos.Y() << "  " << pos.Z()  << endl ;
508    }
509    
510 }
511