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