]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliPoints.cxx
New version from M.Kowalski
[u/mrichter/AliRoot.git] / STEER / AliPoints.cxx
1 ///////////////////////////////////////////////////////////////////////////////
2 //                                                                           //
3 //  This class contains the points for the ALICE event display               //
4 //                                                                           //
5 //Begin_Html
6 /*
7 <img src="picts/AliPointsClass.gif">
8 */
9 //End_Html
10 //                                                                           //
11 //                                                                           //
12 ///////////////////////////////////////////////////////////////////////////////
13
14 #include "AliPoints.h"
15 #include "AliRun.h"
16 #include "AliDetector.h"
17 #include "TPad.h"
18 #include "TView.h"
19  
20 ClassImp(AliPoints)
21
22 //_____________________________________________________________________________
23 AliPoints::AliPoints()
24 {
25   //
26   // Default constructor
27   //
28   fDetector = 0;        
29   fIndex    = 0;
30 }
31
32 //_____________________________________________________________________________
33 AliPoints::AliPoints(Int_t nhits)
34   :TPolyMarker3D(nhits)
35 {
36   //
37   // Standard constructor
38   //
39   fDetector = 0;        
40   fIndex    = 0;
41   ResetBit(kCanDelete);
42 }
43          
44 //_____________________________________________________________________________
45 AliPoints::~AliPoints()
46 {
47   //
48   // Default constructor
49   //
50   fDetector = 0;        
51   fIndex    = 0;
52 }
53
54 //_____________________________________________________________________________
55 Int_t AliPoints::DistancetoPrimitive(Int_t px, Int_t py)
56 {
57   //
58   //*-*-*-*-*-*-*Compute distance from point px,py to a 3-D polymarker*-*-*-*-*
59   //*-*          =====================================================
60   //*-*
61   //*-*  Compute the closest distance of approach from point
62   //*-*  px,py to each segment
63   //*-*  of the polyline.
64   //*-*  Returns when the distance found is below DistanceMaximum.
65   //*-*  The distance is computed in pixels units.
66   //*-*
67   //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
68
69   //const Int_t inaxis = 7;
70   //Int_t dist = 9999;
71   return TPolyMarker3D::DistancetoPrimitive(px,py);
72 }
73
74 //_____________________________________________________________________________
75 void AliPoints::DumpParticle()
76 {
77   //
78   //   Dump particle corresponding to this point
79   //
80   TParticle *particle = GetParticle();
81   if (particle) particle->Dump();
82 }
83
84 //_____________________________________________________________________________
85 void AliPoints::ExecuteEvent(Int_t event, Int_t px, Int_t py)
86 {
87   //
88   //*-*-*-*-*-*-*-*-*-*Execute action corresponding to one event*-*-*-*-*-*-*-*
89   //*-*                =========================================
90   //*-*
91   //*-*  This member function must be implemented to realize the action
92   //*-*  corresponding to the mouse click on the object in the window
93   //*-*
94   //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
95
96   gPad->SetCursor(kCross);
97   
98   if (gPad->GetView())
99     gPad->GetView()->ExecuteRotateView(event, px, py);
100
101 }
102
103 //_____________________________________________________________________________
104 const Text_t *AliPoints::GetName() const
105 {
106   //
107   // Return name of the Geant3 particle corresponding to this point
108   //
109   TParticle *particle = GetParticle();
110   if (!particle) return "Particle";
111   return particle->GetName();
112 }
113
114 //_____________________________________________________________________________
115 Text_t *AliPoints::GetObjectInfo(Int_t, Int_t)
116 {
117   //
118   //   Redefines TObject::GetObjectInfo.
119   //   Displays the info (particle,etc
120   //   corresponding to cursor position px,py
121   //
122   static char info[64];
123   sprintf(info,"%s %d",GetName(),fIndex);
124   return info;
125 }
126
127 //_____________________________________________________________________________
128 TParticle *AliPoints::GetParticle() const
129 {
130   //
131   //   Returns pointer to particle index in AliRun::fParticles
132   //
133   TClonesArray *particles = gAlice->Particles();
134   Int_t nparticles = particles->GetEntriesFast();
135   if (fIndex < 0 || fIndex >= nparticles) return 0;
136   return (TParticle*)particles->UncheckedAt(fIndex);
137 }
138
139 //_____________________________________________________________________________
140 void AliPoints::InspectParticle()
141 {
142   //
143   //   Inspect particle corresponding to this point
144   //
145   TParticle *particle = GetParticle();
146   if (particle) particle->Inspect();
147 }
148
149 //_____________________________________________________________________________
150 void AliPoints::Propagate()
151 {
152   //
153   //   Set attributes of all detectors to be the attributes of this point
154   //
155   Int_t ntracks,track;
156   TObjArray *points;
157   AliPoints *pm;
158   //  
159   TIter next(gAlice->Detectors());
160   AliDetector *detector;
161   while((detector = (AliDetector*)next())) {
162     if (!detector->IsActive()) continue;
163     points = detector->Points();
164     if (!points) continue;
165     ntracks = points->GetEntriesFast();
166     for (track=0;track<ntracks;track++) {
167       pm = (AliPoints*)points->UncheckedAt(track);
168       if (!pm) continue;
169       if (fIndex == pm->GetIndex()) {
170         pm->SetMarkerColor(GetMarkerColor());
171         pm->SetMarkerSize(GetMarkerSize());
172         pm->SetMarkerStyle(GetMarkerStyle());
173       }
174     }
175   }
176 }