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