]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliPoints.cxx
Change global directory to original (Marian)
[u/mrichter/AliRoot.git] / STEER / AliPoints.cxx
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 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 //  This class contains the points for the ALICE event display               //
21 //                                                                           //
22 //Begin_Html
23 /*
24 <img src="picts/AliPointsClass.gif">
25 */
26 //End_Html
27 //                                                                           //
28 //                                                                           //
29 ///////////////////////////////////////////////////////////////////////////////
30
31 #include "TPad.h"
32 #include "TParticle.h"
33 #include "TView.h"
34
35 #include "AliDetector.h"
36 #include "AliMC.h"
37 #include "AliPoints.h"
38 #include "AliRun.h"
39  
40 ClassImp(AliPoints)
41
42 //_______________________________________________________________________
43 AliPoints::AliPoints():
44   fDetector(0),
45   fIndex(0)
46 {
47   //
48   // Default constructor
49   //
50 }
51
52 //_______________________________________________________________________
53 AliPoints::AliPoints(const AliPoints &pts):
54   TPolyMarker3D(pts),
55   fDetector(0),
56   fIndex(0)
57 {
58   //
59   // Copy constructor
60   //
61   pts.Copy(*this);
62 }
63
64 //_______________________________________________________________________
65 AliPoints::AliPoints(Int_t nhits):
66   TPolyMarker3D(nhits),
67   fDetector(0),
68   fIndex(0)
69 {
70   //
71   // Standard constructor
72   //
73   ResetBit(kCanDelete);
74 }
75          
76 //_______________________________________________________________________
77 AliPoints::~AliPoints()
78 {
79   //
80   // Default destructor
81   //
82 }
83
84 //_______________________________________________________________________
85 void AliPoints::Copy(TObject &pts) const
86 {
87   //
88   // Copy *this onto pts
89   //
90   if((TObject*)this != &pts) {
91     ((TPolyMarker3D*)this)->Copy(dynamic_cast<TPolyMarker3D&>(pts));
92     (dynamic_cast<AliPoints&>(pts)).fGLList = fGLList;
93     (dynamic_cast<AliPoints&>(pts)).fLastPoint = fLastPoint;
94     (dynamic_cast<AliPoints&>(pts)).fDetector = fDetector;
95     (dynamic_cast<AliPoints&>(pts)).fIndex = fIndex;
96   }
97 }
98
99 //_______________________________________________________________________
100 Int_t AliPoints::DistancetoPrimitive(Int_t px, Int_t py)
101 {
102   //
103   //*-*-*-*-*-*-*Compute distance from point px,py to a 3-D polymarker*-*-*-*-*
104   //*-*          =====================================================
105   //*-*
106   //*-*  Compute the closest distance of approach from point
107   //*-*  px,py to each segment
108   //*-*  of the polyline.
109   //*-*  Returns when the distance found is below DistanceMaximum.
110   //*-*  The distance is computed in pixels units.
111   //*-*
112   //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
113
114   //const Int_t inaxis = 7;
115   //Int_t dist = 9999;
116   return TPolyMarker3D::DistancetoPrimitive(px,py);
117 }
118
119 //_______________________________________________________________________
120 void AliPoints::DumpParticle() const
121 {
122   //
123   //   Dump particle corresponding to this point
124   //
125   TParticle *particle = GetParticle();
126   if (particle) particle->Dump();
127 }
128
129 //_______________________________________________________________________
130 void AliPoints::ExecuteEvent(Int_t event, Int_t px, Int_t py)
131 {
132   //
133   //*-*-*-*-*-*-*-*-*-*Execute action corresponding to one event*-*-*-*-*-*-*-*
134   //*-*                =========================================
135   //*-*
136   //*-*  This member function must be implemented to realize the action
137   //*-*  corresponding to the mouse click on the object in the window
138   //*-*
139   //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
140
141   gPad->SetCursor(kCross);
142   
143   if (gPad->GetView())
144     gPad->GetView()->ExecuteRotateView(event, px, py);
145
146 }
147
148 //_______________________________________________________________________
149 const Text_t *AliPoints::GetName() const
150 {
151   //
152   // Return name of the Geant3 particle corresponding to this point
153   //
154   TParticle *particle = GetParticle();
155   if (!particle) return "Particle";
156   return particle->GetName();
157 }
158
159 //_______________________________________________________________________
160 Text_t *AliPoints::GetObjectInfo(Int_t, Int_t) const
161 {
162   //
163   //   Redefines TObject::GetObjectInfo.
164   //   Displays the info (particle,etc
165   //   corresponding to cursor position px,py
166   //
167   static char info[64];
168   sprintf(info,"%s %d",GetName(),fIndex);
169   return info;
170 }
171
172 //_______________________________________________________________________
173 TParticle *AliPoints::GetParticle() const
174 {
175   //
176   //   Returns pointer to particle index in AliRun::fParticles
177   //
178   if (fIndex < 0 || fIndex >= gAlice->GetMCApp()->GetNtrack()) return 0;
179   else return gAlice->GetMCApp()->Particle(fIndex);
180 }
181
182 //_______________________________________________________________________
183 void AliPoints::InspectParticle() const
184 {
185   //
186   //   Inspect particle corresponding to this point
187   //
188   TParticle *particle = GetParticle();
189   if (particle) particle->Inspect();
190 }
191
192 //_______________________________________________________________________
193 void AliPoints::Propagate()
194 {
195   //
196   //   Set attributes of all detectors to be the attributes of this point
197   //
198   Int_t ntracks,track;
199   TObjArray *points;
200   AliPoints *pm;
201   //  
202   TIter next(gAlice->Detectors());
203   AliDetector *detector;
204   while((detector = (AliDetector*)(next()))) {
205     if (!detector->IsActive()) continue;
206     points = detector->Points();
207     if (!points) continue;
208     ntracks = points->GetEntriesFast();
209     for (track=0;track<ntracks;track++) {
210       pm = dynamic_cast<AliPoints*>(points->UncheckedAt(track));
211       if (!pm) continue;
212       if (fIndex == pm->GetIndex()) {
213         pm->SetMarkerColor(GetMarkerColor());
214         pm->SetMarkerSize(GetMarkerSize());
215         pm->SetMarkerStyle(GetMarkerStyle());
216       }
217     }
218   }
219 }