Merged ITS-working with HEAD. Improved some of the documentation and
[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
d15a28e7 50}
51
52//____________________________________________________________________________
6ad0bfa0 53AliPHOSTrackSegment::AliPHOSTrackSegment( const AliPHOSTrackSegment & ts)
54{
c198e326 55 ( (AliPHOSTrackSegment &)ts ).Copy(*this) ;
6ad0bfa0 56}
57
58//____________________________________________________________________________
d15a28e7 59AliPHOSTrackSegment::~AliPHOSTrackSegment() // dtor
60{
61// fEmcRecPoint.Delete() ; Not Owners !!!
62// fPpsdUp.Delete() ;
63// fPpsdLow.Delete() ;
64}
65
66//____________________________________________________________________________
6ad0bfa0 67void AliPHOSTrackSegment::Copy(TObject & obj)
68{
69 TObject::Copy(obj) ;
70 ( (AliPHOSTrackSegment &)obj ).fEmcRecPoint = fEmcRecPoint ;
71 ( (AliPHOSTrackSegment &)obj ).fPpsdLow = fPpsdLow ;
72 ( (AliPHOSTrackSegment &)obj ).fPpsdUp = fPpsdUp ;
73}
74//____________________________________________________________________________
9f616d61 75Int_t AliPHOSTrackSegment::DistancetoPrimitive(Int_t px, Int_t py)
76{
6ad0bfa0 77 //Compute distance from point px,py to a AliPHOSTrackSegment considered as a Tmarker
78 // Compute the closest distance of approach from point px,py to this marker.
79 // The distance is computed in pixels units.
80 //
81 Int_t div = 1 ;
82 TVector3 pos(0.,0.,0.) ;
83
84 fEmcRecPoint->GetLocalPosition( pos) ;
85 Float_t x = pos.X() ;
86 Float_t y = pos.Z() ;
87 if ( fPpsdLow ) {
88 fPpsdLow->GetLocalPosition( pos ) ;
89 x += pos.X() ;
90 y += pos.Z() ;
91 div++ ;
92 }
93 if ( fPpsdUp ) {
94 fPpsdUp->GetLocalPosition( pos ) ;
95 x += pos.X() ;
96 y += pos.Z() ;
97 div++ ;
98 }
99 x /= div ;
100 y /= div ;
101
9f616d61 102 const Int_t kMaxDiff = 10;
103 Int_t pxm = gPad->XtoAbsPixel(x);
104 Int_t pym = gPad->YtoAbsPixel(y);
105 Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
106
107 if (dist > kMaxDiff) return 9999;
108 return dist;
109}
110
111//___________________________________________________________________________
112 void AliPHOSTrackSegment::Draw(Option_t *option)
113 {
6ad0bfa0 114 // Draw this AliPHOSTrackSegment with its current attribute
115
116 AppendPad(option);
9f616d61 117 }
118
119//______________________________________________________________________________
120void AliPHOSTrackSegment::ExecuteEvent(Int_t event, Int_t px, Int_t py)
121{
6ad0bfa0 122 // Execute action corresponding to one event
123 // This member function is called when a AliPHOSTrackSegment is clicked with the locator
124 //
125 // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
126 // and switched off when the mouse button is released.
127 //
92862013 128 static TPaveText* textTS = 0 ;
9f616d61 129
6ad0bfa0 130 if (!gPad->IsEditable())
131 return;
9f616d61 132
133 switch (event) {
134
135 case kButton1Down:{
136
92862013 137 if (!textTS) {
9f616d61 138
139 TVector3 pos(0.,0.,0.) ;
140 fEmcRecPoint->GetLocalPosition(pos) ;
92862013 141 textTS = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+5,pos.Z()+15,"") ;
9f616d61 142 Text_t line1[40] ;
09fc14a0 143 sprintf(line1,"See RecParticle for ID") ;
92862013 144 textTS ->AddText(line1) ;
145 textTS ->Draw("");
6ad0bfa0 146 gPad->Update() ;
9f616d61 147 }
148 }
149
150 break;
151
152 case kButton1Up:
92862013 153 if (textTS) {
154 delete textTS ;
155 textTS = 0 ;
9f616d61 156 }
157 break;
158 }
159}
160
161
162//____________________________________________________________________________
d15a28e7 163Float_t AliPHOSTrackSegment::GetDistanceInPHOSPlane()
164{
165
166 TVector3 vecEmc ;
167 fEmcRecPoint->GetLocalPosition(vecEmc) ;
168
169 TVector3 vecPpsd ;
170 if( fPpsdLow->GetMultiplicity() )
171 fPpsdLow->GetLocalPosition(vecPpsd) ;
172 else {
173 vecPpsd.SetX(10000.) ;
174 }
175 vecEmc -= vecPpsd ;
176
92862013 177 Float_t r = vecEmc.Mag();;
d15a28e7 178
92862013 179 return r ;
d15a28e7 180}
181
182//____________________________________________________________________________
6ad0bfa0 183TVector3 AliPHOSTrackSegment::GetMomentumDirection()
d15a28e7 184{
6ad0bfa0 185 TVector3 dir, tempo ;
186 TMatrix mdummy ;
d15a28e7 187
6ad0bfa0 188 TVector3 posEmc ;
189 fEmcRecPoint->GetGlobalPosition(posEmc, mdummy) ;
190
98569bc2 191 // need to correct here for the depth of the shower start point (TDR p 127) ?
192
193 Float_t energy = fEmcRecPoint->GetEnergy() ;
194 Float_t para = 0.925 ;
195 Float_t parb = 6.52 ;
196
197 TVector3 localpos ;
198 fEmcRecPoint->GetLocalPosition(localpos) ;
199
200 AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ;
201 Float_t radius = geom->GetIPtoOuterCoverDistance() + geom->GetOuterBoxSize(1) ;
202 Float_t incidencephi = TMath::ATan(localpos.X() / radius) ;
203 Float_t incidencetheta = TMath::ATan(localpos.Z() / radius) ;
204
205 Float_t depthx = - ( para * TMath::Log(energy) + parb ) * TMath::Sin(incidencephi) ;
206 Float_t depthz = - ( para * TMath::Log(energy) + parb ) * TMath::Sin(incidencetheta) ;
207
6ad0bfa0 208 TVector3 posPpsdl ;
209 TVector3 posPpsdup ;
d15a28e7 210
6ad0bfa0 211// if( fPpsdLow ){
212// fPpsdLow->GetGlobalPosition(posPpsdl, mdummy) ;
213// if( !fPpsdUp ) { // draw line trough 2 points
214// tempo = posEmc - posPpsdl;
215// }
216
217// else { // draw line through 3 points
218// fPpsdUp->GetGlobalPosition(posPpsdup, mdummy) ;
219// posPpsdl = 0.5 * ( posPpsdup + posPpsdl ) ;
220// dir = posEmc - posPpsdl ;
221// }
222// }
223// else
224 tempo = posEmc ;
225
98569bc2 226 dir.SetX( tempo.X() + depthx ) ; // assumes that a neutral comes from the vertex
6ad0bfa0 227 dir.SetY( tempo.Y() ) ;
98569bc2 228 dir.SetZ( -tempo.Z() - depthz ) ;
6ad0bfa0 229
230 dir.SetMag(1.) ;
231 return dir ;
d15a28e7 232}
233
d15a28e7 234
235//____________________________________________________________________________
236void AliPHOSTrackSegment::GetPosition( TVector3 & pos )
237{
238 // Returns positions of hits
92862013 239 TMatrix dummy ;
240 fEmcRecPoint->GetGlobalPosition(pos, dummy) ;
d15a28e7 241}
242
9f616d61 243//______________________________________________________________________________
244void AliPHOSTrackSegment::Paint(Option_t *)
245{
6ad0bfa0 246 //Paint this ALiPHOSTrackSegment as a TMarker with its current attributes
247
248 TVector3 posemc(999., 999., 999.) ;
249 TVector3 posppsdl(999., 999., 999.) ;
250 TVector3 posppsdu(999., 999., 999.) ;
251
252 fEmcRecPoint->GetLocalPosition(posemc) ;
253 if (fPpsdLow !=0 )
254 fPpsdLow->GetLocalPosition(posppsdl) ;
255 if (fPpsdUp !=0 )
256 fPpsdUp->GetLocalPosition(posppsdu) ;
257
258 Coord_t xemc = posemc.X() ;
259 Coord_t yemc = posemc.Z() ;
9f616d61 260
6ad0bfa0 261 Coord_t yppsdl = posppsdl.Z() ;
262 Coord_t xppsdl = posppsdl.X() ;
263
264 Coord_t yppsdu = posppsdu.Z() ;
265 Coord_t xppsdu = posppsdu.X() ;
266
92862013 267 Color_t markercolor = 1 ;
268 Size_t markersize = 1.5 ;
269 Style_t markerstyle = 20 ;
9f616d61 270
271 if (!gPad->IsBatch()) {
92862013 272 gVirtualX->SetMarkerColor(markercolor) ;
273 gVirtualX->SetMarkerSize (markersize) ;
274 gVirtualX->SetMarkerStyle(markerstyle) ;
9f616d61 275 }
92862013 276 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
6ad0bfa0 277 gPad->PaintPolyMarker(1, &xemc, &yemc, "") ;
278
279 if (xppsdl != 999. && yppsdl != 999. ) {
280
92862013 281 markercolor = 2 ;
282 markersize = 1.25 ;
283 markerstyle = 21 ;
6ad0bfa0 284
285 if (!gPad->IsBatch()) {
92862013 286 gVirtualX->SetMarkerColor(markercolor) ;
287 gVirtualX->SetMarkerSize (markersize) ;
288 gVirtualX->SetMarkerStyle(markerstyle) ;
6ad0bfa0 289 }
92862013 290 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
6ad0bfa0 291 gPad->PaintPolyMarker(1, &xppsdl, &yppsdl, "") ;
292 }
293
294 if (xppsdu != 999. && yppsdu != 999. ) {
295
92862013 296 markercolor = 3 ;
297 markersize = 1. ;
298 markerstyle = 22 ;
6ad0bfa0 299
300 if (!gPad->IsBatch()) {
92862013 301 gVirtualX->SetMarkerColor(markercolor) ;
302 gVirtualX->SetMarkerSize (markersize) ;
303 gVirtualX->SetMarkerStyle(markerstyle) ;
6ad0bfa0 304 }
92862013 305 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
6ad0bfa0 306 gPad->PaintPolyMarker(1, &xppsdu, &yppsdu, "") ;
307 }
9f616d61 308}
309
310
d15a28e7 311//____________________________________________________________________________
312void AliPHOSTrackSegment::Print()
313{
314 cout << "--------AliPHOSTrackSegment-------- "<<endl ;
315 cout << "EMC Reconstructed Point: " << fEmcRecPoint << endl;
316
317 TVector3 pos ;
92862013 318 TMatrix dummy ;
d15a28e7 319
92862013 320 fEmcRecPoint->GetGlobalPosition( pos, dummy ) ;
d15a28e7 321
322 cout << " position " << pos.X() << " " << pos.Y() << " " << pos.Z() << " Energy " << fEmcRecPoint->GetTotalEnergy() << endl ;
323 cout << "PPSD Low Reconstructed Point: " << endl;
324
325 if(fPpsdLow){
92862013 326 fPpsdLow->GetGlobalPosition( pos , dummy ) ;
d15a28e7 327 cout << " position " << pos.X() << " " << pos.Y() << " " << pos.Z() << endl ;
328 }
329
330 cout << "PPSD Up Reconstructed Point: " << endl;
331
332 if(fPpsdUp ){
92862013 333 fPpsdUp->GetGlobalPosition( pos, dummy ) ;
d15a28e7 334 cout << " position " << pos.X() << " " << pos.Y() << " " << pos.Z() << endl ;
335 }
336
337}
338