New Version from Alla
[u/mrichter/AliRoot.git] / PHOS / AliPHOSTrackSegment.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// class of PHOS Sub Track
18//*-- Author : Dmitri Peressounko RRC KI
19//////////////////////////////////////////////////////////////////////////////
20
21// --- ROOT system ---
22
23#include "TVector3.h"
9f616d61 24#include "TPad.h"
d15a28e7 25
26// --- Standard library ---
27
9f616d61 28#include <iostream>
d15a28e7 29
30// --- AliRoot header files ---
31
32#include "AliPHOSTrackSegment.h"
33#include "AliPHOSv0.h"
34
35ClassImp(AliPHOSTrackSegment)
36
37//____________________________________________________________________________
38AliPHOSTrackSegment::AliPHOSTrackSegment( AliPHOSEmcRecPoint * emc , AliPHOSPpsdRecPoint * ppsdRP1,
39 AliPHOSPpsdRecPoint * ppsdRP2 )
40{
41 if( emc )
42 fEmcRecPoint = emc ;
43
44 if( ppsdRP1 )
45 fPpsdUp = ppsdRP1 ;
46
47 if( ppsdRP2 )
48 fPpsdLow = ppsdRP2 ;
49
50 fCutOnDispersion = 1.5 ;
51}
52
53//____________________________________________________________________________
54AliPHOSTrackSegment::~AliPHOSTrackSegment() // dtor
55{
56// fEmcRecPoint.Delete() ; Not Owners !!!
57// fPpsdUp.Delete() ;
58// fPpsdLow.Delete() ;
59}
60
61//____________________________________________________________________________
9f616d61 62Int_t AliPHOSTrackSegment::DistancetoPrimitive(Int_t px, Int_t py)
63{
64//*-*-*-*-*-*-*-*-*-*-*Compute distance from point px,py to a AliPHOSTrackSegment considered as a Tmarker*-*-*-*-*-*
65//*-* ===========================================
66// Compute the closest distance of approach from point px,py to this marker.
67// The distance is computed in pixels units.
68//
69
70 TVector3 pos(0.,0.,0.) ;
71 fEmcRecPoint->GetLocalPosition( pos) ;
72 Float_t x = pos.X() ;
73 Float_t y = pos.Z() ;
74 const Int_t kMaxDiff = 10;
75 Int_t pxm = gPad->XtoAbsPixel(x);
76 Int_t pym = gPad->YtoAbsPixel(y);
77 Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
78
79 if (dist > kMaxDiff) return 9999;
80 return dist;
81}
82
83//___________________________________________________________________________
84 void AliPHOSTrackSegment::Draw(Option_t *option)
85 {
86// //*-*-*-*-*-*-*-*-*-*-*Draw this AliPHOSTrackSegment with its current attributes*-*-*-*-*-*-*
87// //*-*
88 // assert(0==1);
89 AppendPad(option);
90 }
91
92//______________________________________________________________________________
93void AliPHOSTrackSegment::ExecuteEvent(Int_t event, Int_t px, Int_t py)
94{
95//*-*-*-*-*-*-*-*-*-*-*Execute action corresponding to one event*-*-*-*
96//*-* =========================================
97// This member function is called when a AliPHOSTrackSegment is clicked with the locator
98//
99// If Left button is clicked on AliPHOSRecPoint, the digits are switched on
100// and switched off when the mouse button is released.
101//
102 static TPaveText* TrackSegmentText = 0 ;
103
104 if (!gPad->IsEditable()) return;
105
106 switch (event) {
107
108 case kButton1Down:{
109
110 if (!TrackSegmentText) {
111
112 TVector3 pos(0.,0.,0.) ;
113 fEmcRecPoint->GetLocalPosition(pos) ;
114 TrackSegmentText = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+50,pos.Z()+35,"") ;
115 Text_t line1[40] ;
116 if (GetPartType() == 0 ) sprintf(line1,"PHOTON") ;
117 if (GetPartType() == 1 ) sprintf(line1,"NEUTRAL HADRON") ;
118 if (GetPartType() == 2 ) sprintf(line1,"CHARGED HADRON") ;
119 if (GetPartType() == 3 ) sprintf(line1,"ELECTRON") ;
120 TrackSegmentText ->AddText(line1) ;
121 TrackSegmentText ->Paint("");
122 }
123 }
124
125 break;
126
127 case kButton1Up:
128 if (TrackSegmentText) {
129 delete TrackSegmentText ;
130 TrackSegmentText = 0 ;
131 }
132 break;
133 }
134}
135
136
137//____________________________________________________________________________
d15a28e7 138Float_t AliPHOSTrackSegment::GetDistanceInPHOSPlane()
139{
140
141 TVector3 vecEmc ;
142 fEmcRecPoint->GetLocalPosition(vecEmc) ;
143
144 TVector3 vecPpsd ;
145 if( fPpsdLow->GetMultiplicity() )
146 fPpsdLow->GetLocalPosition(vecPpsd) ;
147 else {
148 vecPpsd.SetX(10000.) ;
149 }
150 vecEmc -= vecPpsd ;
151
152 Float_t R = vecEmc.Mag();;
153
154 return R ;
155}
156
157//____________________________________________________________________________
158Bool_t AliPHOSTrackSegment::GetMomentumDirection( TVector3 & dir )
159{
160 // True if determined
161 Bool_t ifdeterm = kTRUE ;
162
163 if( fPpsdLow ){
164 TMatrix mdummy ;
165 if( fPpsdUp->GetMultiplicity() ) { // draw line trough 2 points
166 TVector3 posEmc ;
167 fEmcRecPoint->GetGlobalPosition(posEmc,mdummy) ;
168 TVector3 posPpsd ;
169 fPpsdLow->GetGlobalPosition(posPpsd,mdummy) ;
170 dir = posEmc - posPpsd ;
171 dir.SetMag(1.) ;
172 }
173
174 else { // draw line through 3 pionts
175 TVector3 posEmc ;
176 fEmcRecPoint->GetGlobalPosition(posEmc,mdummy) ;
177 TVector3 posPpsdl ;
178 fPpsdLow->GetGlobalPosition(posPpsdl,mdummy) ;
179 TVector3 posPpsdup ;
180 fPpsdUp->GetGlobalPosition(posPpsdup,mdummy) ;
181 posPpsdl = 0.5*( posPpsdup+posPpsdl ) ;
182 dir = posEmc - posPpsdl ;
183 dir.SetMag(1.) ;
184 }
185
186 }
187 else
188 ifdeterm = kFALSE ;
189
190 return ifdeterm ;
191}
192
193//____________________________________________________________________________
194Int_t AliPHOSTrackSegment::GetPartType()
195{
196 // Returns 0 - gamma
197 // 1 - e+, e-
198 // 2 - neutral hadron
199 // 3 - charged hadron
200
201 Int_t PartType =0;
202 if( fPpsdUp ){ // Neutral
203
204 if( fPpsdLow ) // Neutral hadron
205 PartType = 2 ;
206 else // Gamma
207 PartType = 0 ;
208
209 }
210
211 else { // Charged
212
213 if( fEmcRecPoint->GetDispersion() > fCutOnDispersion)
214 PartType = 3 ;
215 else
216 PartType = 1 ;
217
218 }
219
220 return PartType ;
221
222}
223
224//____________________________________________________________________________
225void AliPHOSTrackSegment::GetPosition( TVector3 & pos )
226{
227 // Returns positions of hits
228 TMatrix Dummy ;
229 fEmcRecPoint->GetGlobalPosition(pos, Dummy) ;
230}
231
9f616d61 232//______________________________________________________________________________
233void AliPHOSTrackSegment::Paint(Option_t *)
234{
235//*-*-*-*-*-*-*-*-*-*-*Paint this ALiPHOSTrackSegment as a TMarker with its current attributes*-*-*-*-*-*-*
236//*-* =============================================
237 TVector3 pos(0.,0.,0.) ;
238 fEmcRecPoint->GetLocalPosition(pos) ;
239 Coord_t x = pos.X() ;
240 Coord_t y = pos.Z() ;
241 Color_t MarkerColor = 1 ;
242 Size_t MarkerSize = 1. ;
243 Style_t MarkerStyle = 29 ;
244
245 if (GetPartType() == 0 ) MarkerStyle = 20 ;
246 if (GetPartType() == 1 ) MarkerStyle = 21 ;
247 if (GetPartType() == 2 ) MarkerStyle = 22 ;
248 if (GetPartType() == 3 ) MarkerStyle = 23 ;
249
250 if (!gPad->IsBatch()) {
251 gVirtualX->SetMarkerColor(MarkerColor) ;
252 gVirtualX->SetMarkerSize (MarkerSize) ;
253 gVirtualX->SetMarkerStyle(MarkerStyle) ;
254 }
255 gPad->SetAttMarkerPS(MarkerColor,MarkerStyle,MarkerSize) ;
256 gPad->PaintPolyMarker(1,&x,&y,"") ;
257}
258
259
d15a28e7 260//____________________________________________________________________________
261void AliPHOSTrackSegment::Print()
262{
263 cout << "--------AliPHOSTrackSegment-------- "<<endl ;
264 cout << "EMC Reconstructed Point: " << fEmcRecPoint << endl;
265
266 TVector3 pos ;
267 TMatrix Dummy ;
268
269 fEmcRecPoint->GetGlobalPosition( pos, Dummy ) ;
270
271 cout << " position " << pos.X() << " " << pos.Y() << " " << pos.Z() << " Energy " << fEmcRecPoint->GetTotalEnergy() << endl ;
272 cout << "PPSD Low Reconstructed Point: " << endl;
273
274 if(fPpsdLow){
275 fPpsdLow->GetGlobalPosition( pos , Dummy ) ;
276 cout << " position " << pos.X() << " " << pos.Y() << " " << pos.Z() << endl ;
277 }
278
279 cout << "PPSD Up Reconstructed Point: " << endl;
280
281 if(fPpsdUp ){
282 fPpsdUp->GetGlobalPosition( pos, Dummy ) ;
283 cout << " position " << pos.X() << " " << pos.Y() << " " << pos.Z() << endl ;
284 }
285
286}
287