Correct particle type for gamma and neutrons
[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{
6ad0bfa0 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 //
9f616d61 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}
6ad0bfa0 72
9f616d61 73//___________________________________________________________________________
74 void AliPHOSRecPoint::Draw(Option_t *option)
75 {
6ad0bfa0 76 // Draw this AliPHOSRecPoint with its current attributes
77
78 AppendPad(option);
9f616d61 79 }
80
81//______________________________________________________________________________
82void AliPHOSRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py)
83{
6ad0bfa0 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 //
9f616d61 90
91 // static Int_t pxold, pyold;
92
92862013 93 static TGraph * digitgraph = 0 ;
94 static TPaveText* clustertext = 0 ;
9f616d61 95
96 if (!gPad->IsEditable()) return;
97
98 switch (event) {
99
100
101 case kButton1Down:{
102 AliPHOSDigit * digit ;
92862013 103 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
9f616d61 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];
92862013 111 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
112 phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]) ;
9f616d61 113 }
114
92862013 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") ;
9f616d61 121 }
92862013 122 if (!clustertext) {
9f616d61 123
124 TVector3 pos(0.,0.,0.) ;
125 GetLocalPosition(pos) ;
92862013 126 clustertext = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+50,pos.Z()+35,"") ;
9f616d61 127 Text_t line1[40] ;
128 Text_t line2[40] ;
129 sprintf(line1,"Energy=%1.2f GeV",GetEnergy()) ;
130 sprintf(line2,"%d Digits",GetDigitsMultiplicity()) ;
92862013 131 clustertext ->AddText(line1) ;
132 clustertext ->AddText(line2) ;
133 clustertext ->Draw("");
9f616d61 134 }
135 gPad->Update() ;
136 Print() ;
137 }
138
139 break;
140
141 case kButton1Up:
92862013 142 if (digitgraph) {
143 delete digitgraph ;
144 digitgraph = 0 ;
9f616d61 145 }
92862013 146 if (clustertext) {
147 delete clustertext ;
148 clustertext = 0 ;
9f616d61 149 }
150
151 break;
152
153 }
154}
155
d15a28e7 156
157//____________________________________________________________________________
158Int_t AliPHOSRecPoint::GetPHOSMod()
159{
6ad0bfa0 160 if(fPHOSMod > 0)
161 return fPHOSMod ;
162
d15a28e7 163 Int_t relid[4] ;
164
165 AliPHOSDigit * digit ;
166 digit = (AliPHOSDigit *) fDigitsList[0] ;
92862013 167 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
d15a28e7 168
92862013 169 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
d15a28e7 170 fPHOSMod = relid[0];
171 return fPHOSMod ;
172}
6ad0bfa0 173
9f616d61 174//______________________________________________________________________________
175void AliPHOSRecPoint::Paint(Option_t *)
176{
6ad0bfa0 177// Paint this ALiRecPoint as a TMarker with its current attributes
178
9f616d61 179 TVector3 pos(0.,0.,0.) ;
180 GetLocalPosition(pos) ;
181 Coord_t x = pos.X() ;
182 Coord_t y = pos.Z() ;
92862013 183 Color_t markercolor = 1 ;
184 Size_t markersize = 1. ;
185 Style_t markerstyle = 5 ;
9f616d61 186
187 if (!gPad->IsBatch()) {
92862013 188 gVirtualX->SetMarkerColor(markercolor) ;
189 gVirtualX->SetMarkerSize (markersize) ;
190 gVirtualX->SetMarkerStyle(markerstyle) ;
9f616d61 191 }
92862013 192 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
9f616d61 193 gPad->PaintPolyMarker(1,&x,&y,"") ;
194}