]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSRecPoint.cxx
New classes: AliPHOSRecParticle, AliPHOSParticleGuesser, AliPHOSAnalyze
[u/mrichter/AliRoot.git] / PHOS / AliPHOSRecPoint.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 // PHOSRecPoint base class deriving from AliRecPoint
18 //*-- Author : Gines MARTINEZ  SUBATECH 
19 //////////////////////////////////////////////////////////////////////////////
20
21 // --- ROOT system ---
22 #include "TPad.h"
23
24 // --- Standard library ---
25 #include <iostream>
26 #include <cstdio>
27
28 // --- AliRoot header files ---
29
30 #include "AliPHOSGeometry.h"
31 #include "AliPHOSDigit.h"
32 #include "AliPHOSRecPoint.h"
33
34
35
36 ClassImp(AliPHOSRecPoint)
37
38
39 //____________________________________________________________________________
40 AliPHOSRecPoint::AliPHOSRecPoint()
41   : AliRecPoint()
42 {
43   fGeom =   AliPHOSGeometry::GetInstance() ;
44   fPHOSMod = 0;
45 }
46
47 //____________________________________________________________________________
48 AliPHOSRecPoint::~AliPHOSRecPoint()
49 {
50   // dtor
51 }
52 //____________________________________________________________________________
53 Int_t AliPHOSRecPoint::DistancetoPrimitive(Int_t px, Int_t py)
54 {
55   //Compute distance from point px,py to  a AliPHOSRecPoint considered as a Tmarker
56   //  Compute the closest distance of approach from point px,py to this marker.
57   //  The distance is computed in pixels units.
58   //
59
60    TVector3 pos(0.,0.,0.) ;
61    GetLocalPosition( pos) ;
62    Float_t x =  pos.X() ;
63    Float_t y =  pos.Z() ;
64    const Int_t kMaxDiff = 10;
65    Int_t pxm  = gPad->XtoAbsPixel(x);
66    Int_t pym  = gPad->YtoAbsPixel(y);
67    Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
68
69    if (dist > kMaxDiff) return 9999;
70    return dist;
71 }
72
73 //___________________________________________________________________________
74  void AliPHOSRecPoint::Draw(Option_t *option)
75  {
76    // Draw this AliPHOSRecPoint with its current attributes
77    
78    AppendPad(option);
79  }
80
81 //______________________________________________________________________________
82 void AliPHOSRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py)
83 {
84   // Execute action corresponding to one event
85   // This member function is called when a AliPHOSRecPoint is clicked with the locator
86   //
87   // If Left button is clicked on AliPHOSRecPoint, the digits are switched on    
88   // and switched off when the mouse button is released.
89   //
90
91   //  static Int_t pxold, pyold;
92
93    static TGraph *  DigitGraph = 0 ;
94    static TPaveText* ClusterText = 0 ;
95
96    if (!gPad->IsEditable()) return;
97
98    switch (event) {
99
100
101    case kButton1Down:{
102      AliPHOSDigit * digit ;
103      AliPHOSGeometry * PHOSGeom =  (AliPHOSGeometry *) fGeom ;
104      Int_t iDigit;
105      Int_t relid[4] ;
106      Float_t xi[fMulDigit] ;
107      Float_t zi[fMulDigit] ;
108  
109      for(iDigit=0; iDigit<fMulDigit; iDigit++) {
110        digit = (AliPHOSDigit *) fDigitsList[iDigit];
111        PHOSGeom->AbsToRelNumbering(digit->GetId(), relid) ;
112        PHOSGeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]) ;
113      }
114
115      if (!DigitGraph) {
116        DigitGraph = new TGraph(fMulDigit,xi,zi);
117        DigitGraph-> SetMarkerStyle(5) ; 
118        DigitGraph-> SetMarkerSize(1.) ;
119        DigitGraph-> SetMarkerColor(1) ;
120        DigitGraph-> Draw("P") ;
121      }
122      if (!ClusterText) {
123   
124        TVector3 pos(0.,0.,0.) ;
125        GetLocalPosition(pos) ;
126        ClusterText = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+50,pos.Z()+35,"") ;
127        Text_t  line1[40] ;
128        Text_t  line2[40] ;
129        sprintf(line1,"Energy=%1.2f GeV",GetEnergy()) ;
130        sprintf(line2,"%d Digits",GetDigitsMultiplicity()) ;
131        ClusterText ->AddText(line1) ;
132        ClusterText ->AddText(line2) ;
133        ClusterText ->Draw("");
134      }
135      gPad->Update() ; 
136      Print() ;
137   }
138
139      break;
140
141    case kButton1Up:
142      if (DigitGraph) {
143        delete DigitGraph  ;
144        DigitGraph = 0 ;
145      }
146      if (ClusterText) {
147        delete ClusterText ;
148        ClusterText = 0 ;
149      }
150      
151      break;
152      
153    }
154 }
155
156
157 //____________________________________________________________________________
158 Int_t AliPHOSRecPoint::GetPHOSMod()
159
160   if(fPHOSMod > 0) 
161     return fPHOSMod ;
162
163   Int_t relid[4] ;
164   
165   AliPHOSDigit * digit   ;
166   digit = (AliPHOSDigit *) fDigitsList[0] ;
167   AliPHOSGeometry * PHOSGeom =  (AliPHOSGeometry *) fGeom ;
168
169   PHOSGeom->AbsToRelNumbering(digit->GetId(), relid) ;
170   fPHOSMod = relid[0];
171   return fPHOSMod ;
172 }
173
174 //______________________________________________________________________________
175 void AliPHOSRecPoint::Paint(Option_t *)
176 {
177 // Paint this ALiRecPoint as a TMarker  with its current attributes
178
179    TVector3 pos(0.,0.,0.)  ;
180    GetLocalPosition(pos)   ;
181    Coord_t x = pos.X()     ;
182    Coord_t y = pos.Z()     ;
183    Color_t MarkerColor = 1 ;
184    Size_t  MarkerSize = 1. ;
185    Style_t MarkerStyle = 5 ;
186
187    if (!gPad->IsBatch()) {
188      gVirtualX->SetMarkerColor(MarkerColor) ;
189      gVirtualX->SetMarkerSize (MarkerSize)  ;
190      gVirtualX->SetMarkerStyle(MarkerStyle) ;
191    }
192    gPad->SetAttMarkerPS(MarkerColor,MarkerStyle,MarkerSize) ;
193    gPad->PaintPolyMarker(1,&x,&y,"") ;
194 }