StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
EveDis.C
1 // $Id: EveDis.C,v 1.6 2018/06/29 17:21:24 perev Exp $
2 // *-- Author : Valery Fine(fine@bnl.gov) 27/04/2008
3 #include "StuDraw3DEvent.h"
4 #if !defined(__CINT__) && !defined(__CLING__)
5 # include "TVirtualPad.h"
6 # include "TColor.h"
7 # include "StEventHelper.h"
8 # include "StEvent.h"
9 # include "StTrack.h"
10 # include "StHit.h"
11 # include "StTpcHit.h"
12 # include "StTrackNode.h"
13 # include "StTrackGeometry.h"
14 # include "StTpcHitCollection.h"
15 # include "StMeasuredPoint.h"
16 # include "StTrackDetectorInfo.h"
17 #endif
18 
19 class EveDis : public StuDraw3DEvent {
20 
21 
23  //
24  // Class EveDis - is template to allow the end user to create his/her
25  // own version of the display to apply the various cuts.
26  //
27  // You have to apply ACliC to use the custom class this macro defines as follows:
28  //
29  // root.exe
30  // root.exe [0].x lMuDst.C
31  // root.exe [1].L EveDis.C++
32  // root.exe [2] EveDis display;
33  // root.exe [3] display.Draw3DTest()
34  // root.exe [3] display.Print("Draw3DTest.wrl");
35  //
36  // See: http://www.star.bnl.gov/public/comp/vis/StDraw3D\n");
37  //
39 public:
40 //___________________________________________________
41 EveDis(const char *detectorName="TPC",TVirtualPad *pad=0)
42 : StuDraw3DEvent(detectorName,pad)
43 {
44  // The detectorName is a comma separated list of the OpenInventor files with no extension
45  // For all names on the list one should provide the iv file with the "iv extension:
46  // <detectorName>.iv
47 }
48 
49 //___________________________________________________
50 ~EveDis(){ }
51 
52 //___________________________________________________
53 void AddHits(const StEvent *event,EStuDraw3DEvent trackHitsOnly, StTrackType type)
54 {
55  if (!event) return; // no event
56  const StTpcHitCollection* hits = event->tpcHitCollection();
57  if (!hits) return; // there is no hits
58  unsigned int m, n, h;
59  if (trackHitsOnly != kUnusedHitsOnly) {
60  StHit *hit=0;
61  Style_t sty = Style(kUsedHit).Sty();
62  Size_t siz = Style(kUsedHit).Siz();
63  Style_t styPnt = Style(kTrackBegin).Sty();
64  Size_t sizPnt = Style(kTrackBegin).Siz();
65 
66  const StSPtrVecTrackNode& theNodes = event->trackNodes();
67  for (unsigned int i=0; i<theNodes.size(); i++) {
68  StTrack *track = theNodes[i]->track(type);
69 //--
70 //-- PAY YOUR ATTENTION:
71 //--
72 //-- Add YOUR OWN CUTS to select the tracks of your choice below
73 //
74  if (track && track->flag() > 0
75  && track->detectorInfo()
76  // && track->fitTraits().numberOfFitPoints(kTpcId) >= minFitPoints)
77  )
78  {
79 //--
80 //-- Create the coloring code
81 //
82  double pt = track->geometry()->momentum().perp();
83  Color_t trackColor = StDraw3DStyle::Pt2Color (pt);
84  if ( trackHitsOnly != kUsedHits) {
85 //--
86 //-- PAY YOUR ATTENTION: you MUST call the "Track" method to get your tracks rendered
87 //
88  Track(*track,trackColor); // render the track
89  TrackInOut(*track, true, trackColor, styPnt, sizPnt); // draw the track start point
90  TrackInOut(*track, false, trackColor, styPnt, sizPnt); // draw the track end point
91  }
92  if ( trackHitsOnly != kTracksOnly) {
93  // look for the hits:
94 //--
95 //-- Create a container to accumulate the hit positions:
96 //
97  std::vector<float> hitPoints;
98  const StPtrVecHit& trackHits = track->detectorInfo()->hits(kTpcId);
99  for (m=0; m<trackHits.size(); m++) {
100 //--
101 //-- Select the hit object
102 //
103  hit = trackHits[m];
104 //--
105 //-- Add the selected hit position to the container
106 //
107  hitPoints.push_back( hit->position().x());
108  hitPoints.push_back( hit->position().y());
109  hitPoints.push_back( hit->position().z());
110  }
111 //--
112 //-- PAY YOUR ATTENTION: you MUST call the "Points" to get your hits position rendred
113 //
114  std::vector<float>::iterator xyz = hitPoints.begin();
115  Points(hitPoints.size()/3,&*xyz,trackColor,sty,siz);
116  if (trackHitsOnly == kUsedHits) SetModel(track);
117  }
118  }
119  }
120  } else {
121  const StTpcHit *hit;
122 //--
123 //-- Create a container to accumulate the hit positions:
124 //
125  std::vector<float> hitPoints;
126  for (n=0; n<hits->numberOfSectors(); n++) {
127  for (m=0; m<hits->sector(n)->numberOfPadrows(); m++) {
128  for (h=0; h<hits->sector(n)->padrow(m)->hits().size(); h++) {
129 //--
130 //-- Select the hit object
131 //
132  hit = hits->sector(n)->padrow(m)->hits()[h];
133 //--
134 //-- Add the selected hit position to the container
135 //
136  hitPoints.push_back( hit->position().x());
137  hitPoints.push_back( hit->position().y());
138  hitPoints.push_back( hit->position().z());
139  }
140  }
141  }
142  std::vector<float>::iterator xyz = hitPoints.begin();
143 //--
144 //-- PAY YOUR ATTENTION: you MUST call the "Points" to get your hit positions rendered
145 //
146  Points(hitPoints.size()/3,&*xyz,kUnusedHit);
147  SetComment("Unused TPC hits");
148  }
149 }
150 ClassDef(EveDis,0);
151 };
152 
Definition: StHit.h:125
virtual const StDraw3DStyle & Style(EDraw3DStyle type) const
Return the reference to the predefined StDraw3DStyle object.
Definition: StDraw3D.cxx:482
static Color_t Pt2Color(double pt)
Maps the track pt to the STAR StTrack track color code.
Definition: StDraw3D.cxx:78
virtual TObject * Track(const StTrack &track, Color_t col, Style_t sty=Style_t(-1), Size_t siz=Size_t(-1))
Add track to the display list with the col color sty and size if provided.
virtual TObject * TrackInOut(const StTrack &track, Bool_t in, Color_t col=Color_t(-1), Style_t sty=Style_t(-1), Size_t siz=Size_t(-1))
Add the in point of the given track to the display list with the col color sty and siz size if provid...
virtual TObject * Points(int n, const float *xyz, EDraw3DStyle sty)
This is an overloaded member function, provided for convenience.
Definition: StDraw3D.cxx:596
Class StuDraw3DEvent - to draw the 3D StEvent primitives like StTrack, StHit, StVertex decorated with...
Definition: EveDis.C:19