Changes imposed by HP-UX which ignores the new C++ standart
[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
b2a60966 16/* $Id$ */
17
d15a28e7 18//_________________________________________________________________________
b2a60966 19// Track segment in PHOS
20// Can be : 1 EmcRecPoint
21// 1 EmcRecPoint + 1 PPSD
22// 1 EmcRecPoint + 1 PPSD + 1 PPSD
23//
24//*-- Author: Dmitri Peressounko (RRC KI & SUBATECH)
d15a28e7 25
26// --- ROOT system ---
27
28#include "TVector3.h"
9f616d61 29#include "TPad.h"
d15a28e7 30
31// --- Standard library ---
32
de9ec31b 33#include <iostream.h>
d15a28e7 34
35// --- AliRoot header files ---
36
37#include "AliPHOSTrackSegment.h"
38#include "AliPHOSv0.h"
39
40ClassImp(AliPHOSTrackSegment)
41
42//____________________________________________________________________________
43AliPHOSTrackSegment::AliPHOSTrackSegment( AliPHOSEmcRecPoint * emc , AliPHOSPpsdRecPoint * ppsdRP1,
44 AliPHOSPpsdRecPoint * ppsdRP2 )
b2a60966 45{
46 // ctor
47
d15a28e7 48 if( emc )
49 fEmcRecPoint = emc ;
50
51 if( ppsdRP1 )
52 fPpsdUp = ppsdRP1 ;
53
54 if( ppsdRP2 )
55 fPpsdLow = ppsdRP2 ;
56
d15a28e7 57}
58
59//____________________________________________________________________________
6ad0bfa0 60AliPHOSTrackSegment::AliPHOSTrackSegment( const AliPHOSTrackSegment & ts)
61{
b2a60966 62 // Copy ctor
63
c198e326 64 ( (AliPHOSTrackSegment &)ts ).Copy(*this) ;
6ad0bfa0 65}
66
d15a28e7 67
68//____________________________________________________________________________
6ad0bfa0 69void AliPHOSTrackSegment::Copy(TObject & obj)
70{
b2a60966 71 // Copy of a track segment into another track segment
72
6ad0bfa0 73 TObject::Copy(obj) ;
b2a60966 74 ( (AliPHOSTrackSegment &)obj ).fEmcRecPointId = fEmcRecPointId ;
75 ( (AliPHOSTrackSegment &)obj ).fPpsdLowId = fPpsdLowId ;
76 ( (AliPHOSTrackSegment &)obj ).fPpsdUpId = fPpsdUpId ;
6ad0bfa0 77}
78//____________________________________________________________________________
9f616d61 79Int_t AliPHOSTrackSegment::DistancetoPrimitive(Int_t px, Int_t py)
80{
b2a60966 81 // Compute distance from point px,py to a AliPHOSTrackSegment considered as a Tmarker
82 // Compute the closest distance of approach from point px,py to this marker.
83 // The distance is computed in pixels units.
84
6ad0bfa0 85 Int_t div = 1 ;
86 TVector3 pos(0.,0.,0.) ;
b2a60966 87
6ad0bfa0 88 fEmcRecPoint->GetLocalPosition( pos) ;
89 Float_t x = pos.X() ;
90 Float_t y = pos.Z() ;
91 if ( fPpsdLow ) {
92 fPpsdLow->GetLocalPosition( pos ) ;
93 x += pos.X() ;
94 y += pos.Z() ;
95 div++ ;
96 }
97 if ( fPpsdUp ) {
98 fPpsdUp->GetLocalPosition( pos ) ;
99 x += pos.X() ;
100 y += pos.Z() ;
101 div++ ;
102 }
103 x /= div ;
104 y /= div ;
105
9f616d61 106 const Int_t kMaxDiff = 10;
107 Int_t pxm = gPad->XtoAbsPixel(x);
108 Int_t pym = gPad->YtoAbsPixel(y);
109 Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
110
111 if (dist > kMaxDiff) return 9999;
112 return dist;
113}
114
115//___________________________________________________________________________
116 void AliPHOSTrackSegment::Draw(Option_t *option)
117 {
6ad0bfa0 118 // Draw this AliPHOSTrackSegment with its current attribute
b2a60966 119
6ad0bfa0 120 AppendPad(option);
9f616d61 121 }
122
123//______________________________________________________________________________
124void AliPHOSTrackSegment::ExecuteEvent(Int_t event, Int_t px, Int_t py)
125{
6ad0bfa0 126 // Execute action corresponding to one event
127 // This member function is called when a AliPHOSTrackSegment is clicked with the locator
128 //
129 // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
130 // and switched off when the mouse button is released.
b2a60966 131
132 static TPaveText* textTS = 0 ;
133
134 if (!gPad->IsEditable())
135 return;
136
137 switch (event) {
9f616d61 138
b2a60966 139 case kButton1Down:{
140
141 if (!textTS) {
142
143 TVector3 pos(0.,0.,0.) ;
144 fEmcRecPoint->GetLocalPosition(pos) ;
145 textTS = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+5,pos.Z()+15,"") ;
146 Text_t line1[40] ;
147 sprintf(line1,"See RecParticle for ID") ;
148 textTS ->AddText(line1) ;
149 textTS ->Draw("");
150 gPad->Update() ;
151 }
152 }
153
154 break;
9f616d61 155
b2a60966 156 case kButton1Up:
157 if (textTS) {
158 delete textTS ;
159 textTS = 0 ;
160 }
161 break;
162 }
9f616d61 163}
164
9f616d61 165//____________________________________________________________________________
d15a28e7 166Float_t AliPHOSTrackSegment::GetDistanceInPHOSPlane()
167{
b2a60966 168 // Calculates the distance between the EMC RecPoint and PPSD RecPoint
169
d15a28e7 170 TVector3 vecEmc ;
171 fEmcRecPoint->GetLocalPosition(vecEmc) ;
b2a60966 172
d15a28e7 173 TVector3 vecPpsd ;
174 if( fPpsdLow->GetMultiplicity() )
175 fPpsdLow->GetLocalPosition(vecPpsd) ;
176 else {
177 vecPpsd.SetX(10000.) ;
178 }
179 vecEmc -= vecPpsd ;
180
92862013 181 Float_t r = vecEmc.Mag();;
d15a28e7 182
92862013 183 return r ;
d15a28e7 184}
185
186//____________________________________________________________________________
6ad0bfa0 187TVector3 AliPHOSTrackSegment::GetMomentumDirection()
b2a60966 188{
189 // Calculates the momentum direction:
190 // 1. if only a EMC RecPoint, direction is given by IP and this RecPoint
191 // 2. if a EMC RecPoint and one PPSD RecPoint, direction is given by the line through the 2 recpoints
192 // 3. if a EMC RecPoint and two PPSD RecPoints, dirrection is given by the average line through
193 // the 2 pairs of recpoints
194 // However because of the poor position resolution of PPSD the direction is always taken as if we were
195 // in case 1.
196
197 TVector3 dir(0,0,0) ;
6ad0bfa0 198 TMatrix mdummy ;
d15a28e7 199
6ad0bfa0 200 TVector3 posEmc ;
201 fEmcRecPoint->GetGlobalPosition(posEmc, mdummy) ;
202
b2a60966 203 // Correction for the depth of the shower starting point (TDR p 127)
98569bc2 204
205 Float_t energy = fEmcRecPoint->GetEnergy() ;
206 Float_t para = 0.925 ;
207 Float_t parb = 6.52 ;
208
209 TVector3 localpos ;
210 fEmcRecPoint->GetLocalPosition(localpos) ;
211
212 AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ;
213 Float_t radius = geom->GetIPtoOuterCoverDistance() + geom->GetOuterBoxSize(1) ;
214 Float_t incidencephi = TMath::ATan(localpos.X() / radius) ;
215 Float_t incidencetheta = TMath::ATan(localpos.Z() / radius) ;
216
b2a60966 217 Float_t depthx = ( para * TMath::Log(energy) + parb ) * TMath::Sin(incidencephi) ;
218 Float_t depthz = ( para * TMath::Log(energy) + parb ) * TMath::Sin(incidencetheta) ;
98569bc2 219
b2a60966 220 localpos.SetX(localpos.X() - depthx ) ;
221 localpos.SetZ(localpos.Z() - depthz ) ;
d15a28e7 222
b2a60966 223 TVector3 emcglobalpos ;
224 TMatrix dummy ;
6ad0bfa0 225
b2a60966 226 fEmcRecPoint->GetGlobalPosition(emcglobalpos, dummy) ;
227
228 emcglobalpos.SetX( emcglobalpos.X() - depthx ) ;
229 emcglobalpos.SetZ( emcglobalpos.Z() - depthz ) ;
6ad0bfa0 230
b2a60966 231 // The following commeneted code becomes valid once the PPSD provides
232 // a reasonable position resolution, at least as good as EMC !
233
234// TVector3 ppsdlglobalpos ;
235// TVector3 ppsduglobalpos ;
236
237// if( fPpsdLow ){ // certainly a photon that has concerted
238
239// fPpsdLow->GetGlobalPosition(ppsdlglobalpos, mdummy) ;
240// dir = emcglobalpos - ppsdlglobalpos ;
241
242// if( fPpsdUp ){ // nop looks like a charged
243
244// fPpsdUp->GetGlobalPosition(ppsduglobalpos, mdummy) ;
245// dir = ( dir + emcglobalpos - ppsduglobalpos ) * 0.5 ;
246// }
247// }
248
249// else { // looks like a neutral
250
251 dir = emcglobalpos ;
252// }
253
254 dir.SetZ( -dir.Z() ) ; // why ?
6ad0bfa0 255 dir.SetMag(1.) ;
b2a60966 256
6ad0bfa0 257 return dir ;
d15a28e7 258}
259
b2a60966 260//____________________________________________________________________________
261Int_t * AliPHOSTrackSegment::GetPrimariesEmc(Int_t & number)
262{
263 // Retrieves the primary particle(s) at the origin of the EMC RecPoint
264
265 Int_t * rv = 0 ;
266 number = 0 ;
267 if ( fEmcRecPoint )
268 rv = fEmcRecPoint->GetPrimaries(number) ;
269
270 return rv ;
271}
272
273//____________________________________________________________________________
274Int_t * AliPHOSTrackSegment::GetPrimariesPpsdLow(Int_t & number)
275{
276 // Retrieves the primary particle(s) at the origin of the lower PPSD RecPoint
277
278 Int_t * rv = 0 ;
279 number = 0 ;
280 if ( fPpsdLow )
281 rv = fPpsdLow->GetPrimaries(number) ;
282
283 return rv ;
284}
285
286//____________________________________________________________________________
287Int_t * AliPHOSTrackSegment::GetPrimariesPpsdUp(Int_t & number)
288{
289 // Retrieves the primary particle(s) at the origin of the upper PPSD RecPoint
290
291 Int_t * rv = 0 ;
292 number = 0 ;
293 if ( fPpsdUp )
294 rv = fPpsdUp->GetPrimaries(number) ;
295
296 return rv ;
297}
d15a28e7 298
299//____________________________________________________________________________
300void AliPHOSTrackSegment::GetPosition( TVector3 & pos )
301{
b2a60966 302 // Returns position of the EMC RecPoint
303
92862013 304 TMatrix dummy ;
305 fEmcRecPoint->GetGlobalPosition(pos, dummy) ;
d15a28e7 306}
307
b2a60966 308
9f616d61 309//______________________________________________________________________________
310void AliPHOSTrackSegment::Paint(Option_t *)
311{
b2a60966 312 // Paint this ALiPHOSTrackSegment as a TMarker with its current attributes
6ad0bfa0 313
b2a60966 314 TVector3 posemc(999., 999., 999.) ;
315 TVector3 posppsdl(999., 999., 999.) ;
316 TVector3 posppsdu(999., 999., 999.) ;
6ad0bfa0 317
b2a60966 318 fEmcRecPoint->GetLocalPosition(posemc) ;
319 if (fPpsdLow !=0 )
320 fPpsdLow->GetLocalPosition(posppsdl) ;
321 if (fPpsdUp !=0 )
322 fPpsdUp->GetLocalPosition(posppsdu) ;
323
324 Coord_t xemc = posemc.X() ;
325 Coord_t yemc = posemc.Z() ;
326
327 Coord_t yppsdl = posppsdl.Z() ;
328 Coord_t xppsdl = posppsdl.X() ;
329
330 Coord_t yppsdu = posppsdu.Z() ;
331 Coord_t xppsdu = posppsdu.X() ;
332
333 Color_t markercolor = 1 ;
334 Size_t markersize = 1.5 ;
335 Style_t markerstyle = 20 ;
336
337 if (!gPad->IsBatch()) {
338 gVirtualX->SetMarkerColor(markercolor) ;
339 gVirtualX->SetMarkerSize (markersize) ;
340 gVirtualX->SetMarkerStyle(markerstyle) ;
341 }
342 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
343 gPad->PaintPolyMarker(1, &xemc, &yemc, "") ;
344
345 if (xppsdl != 999. && yppsdl != 999. ) {
346
347 markercolor = 2 ;
348 markersize = 1.25 ;
349 markerstyle = 21 ;
350
351 if (!gPad->IsBatch()) {
352 gVirtualX->SetMarkerColor(markercolor) ;
353 gVirtualX->SetMarkerSize (markersize) ;
354 gVirtualX->SetMarkerStyle(markerstyle) ;
355 }
356 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
357 gPad->PaintPolyMarker(1, &xppsdl, &yppsdl, "") ;
358 }
359
360 if (xppsdu != 999. && yppsdu != 999. ) {
361
362 markercolor = 3 ;
363 markersize = 1. ;
364 markerstyle = 22 ;
365
366 if (!gPad->IsBatch()) {
367 gVirtualX->SetMarkerColor(markercolor) ;
368 gVirtualX->SetMarkerSize (markersize) ;
369 gVirtualX->SetMarkerStyle(markerstyle) ;
6ad0bfa0 370 }
b2a60966 371 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
372 gPad->PaintPolyMarker(1, &xppsdu, &yppsdu, "") ;
373 }
9f616d61 374}
375
d15a28e7 376//____________________________________________________________________________
377void AliPHOSTrackSegment::Print()
378{
b2a60966 379 // Print all information on this track Segment
380
d15a28e7 381 cout << "--------AliPHOSTrackSegment-------- "<<endl ;
382 cout << "EMC Reconstructed Point: " << fEmcRecPoint << endl;
383
384 TVector3 pos ;
92862013 385 TMatrix dummy ;
d15a28e7 386
92862013 387 fEmcRecPoint->GetGlobalPosition( pos, dummy ) ;
d15a28e7 388
389 cout << " position " << pos.X() << " " << pos.Y() << " " << pos.Z() << " Energy " << fEmcRecPoint->GetTotalEnergy() << endl ;
390 cout << "PPSD Low Reconstructed Point: " << endl;
391
392 if(fPpsdLow){
92862013 393 fPpsdLow->GetGlobalPosition( pos , dummy ) ;
d15a28e7 394 cout << " position " << pos.X() << " " << pos.Y() << " " << pos.Z() << endl ;
395 }
396
397 cout << "PPSD Up Reconstructed Point: " << endl;
398
399 if(fPpsdUp ){
92862013 400 fPpsdUp->GetGlobalPosition( pos, dummy ) ;
d15a28e7 401 cout << " position " << pos.X() << " " << pos.Y() << " " << pos.Z() << endl ;
402 }
403
404}
405