StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
EdFtpc.C
1 // $Id: EdFtpc.C,v 1.5 2010/04/29 23:57:51 fine Exp $
2 // *-- Author : Valery Fine(fine@bnl.gov) 25/02/2009
3 #ifndef __CINT__
4 # include "StuDraw3DEvent.h"
5 # include "TColor.h"
6 # include "StEvent.h"
7 # include "StTrack.h"
8 # include "StHit.h"
9 # include "StFtpcHit.h"
10 # include "StTrackNode.h"
11 # include "StTrackGeometry.h"
12 # include "StFtpcHitCollection.h"
13 # include "StFtpcSectorHitCollection.h"
14 # include "StFtpcPlaneHitCollection.h"
15 # include "StMeasuredPoint.h"
16 # include "StTrackDetectorInfo.h"
17 # include "StChain.h"
18 # include "TSystem.h"
19 # include "TROOT.h"
20 #endif
21 
22 class StEvent;
23 StEvent* event = 0;
24 class StChain;
25 StChain* ftpChain = 0;
26 class StuDraw3DEvent;
27 StuDraw3DEvent *gEdFtp = 0;
28 //__________________________________________
29 void DrawUnusedHits()
30 {
31  const StHit *hit= 0;
32  std::vector<float> hitPoints;
33  const StFtpcHitCollection* ftpHits = event->ftpcHitCollection();
34  if (ftpHits->numberOfHits()>0) {
35  unsigned int n,m,h;
36  for (n=0;n<ftpHits-> numberOfPlanes();++n ) {
37  for (m=0; m<ftpHits->plane(n)->numberOfSectors(); m++) {
38  for (h=0; h<ftpHits->plane(n)->sector(m)->hits().size(); h++) {
39  hit = ftpHits->plane(n)->sector(m)->hits()[h];
40  hitPoints.push_back( hit->position().x());
41  hitPoints.push_back( hit->position().y());
42  hitPoints.push_back( hit->position().z());
43  } } }
44  std::vector<float>::iterator xyz = hitPoints.begin();
45 
46  gEdFtp->Points(hitPoints.size()/3,&*xyz,kUnusedHit);
47  gEdFtp->SetComment("Unused FTPC hits");
48 
49  printf(" FTPC hits counter total : %d\n", hitPoints.size()/3);
50  }
51  }
52 
53 //__________________________________________
54 void DrawTrackHits()
55 {
56  // tracks and its "used hits"
57  Style_t sty = gEdFtp->Style(kUsedHit).Sty();
58  Size_t siz = gEdFtp->Style(kUsedHit).Siz();
59 
60  Style_t styPnt = gEdFtp->Style(kTrackBegin).Sty();
61  Size_t sizPnt = gEdFtp->Style(kTrackBegin).Siz();
62 
63  StTrackType type = global;
64 
65  int trackCounter = 0;
66  const StSPtrVecTrackNode& theNodes = event->trackNodes();
67  for (unsigned int i=0; i<theNodes.size(); i++) {
68  StTrack *track = theNodes[i]->track(type);
69  if (track && track->flag() > 0
70  && track->detectorInfo()
71  && ( track->detectorInfo()->numberOfPoints(kFtpcWestId) || track->detectorInfo()->numberOfPoints(kFtpcEastId) )
72  && !track->bad()
73  )
74  {
75  ++trackCounter;
76  double pt = track->geometry()->momentum().perp();
77  Color_t trackColor = StDraw3DStyle::Pt2Color(pt);
78 // if ( trackHitsOnly != kUsedHits)
79  {
80  gEdFtp->Track(*track,trackColor);
81  gEdFtp->SetComment(Form("Pt=%f /Gev",pt));
82  gEdFtp->TrackInOut(*track, true, trackColor, styPnt, sizPnt);
83  gEdFtp->TrackInOut(*track, false, trackColor, styPnt, sizPnt);
84  }
85 // if ( trackHitsOnly != kTracksOnly)
86  {
87  gEdFtp->Hits(*track,trackColor,sty,siz);
88  // if (trackHitsOnly == kUsedHits) gEdFtp->SetModel(track);
89  }
90  }
91  }
92 }
93 
94 //__________________________________________
95 void rd()
96 {
97  // redraw the event
98  bool clear = true;
99  if (event) {
100  if (clear) gEdFtp->Clear();
101  DrawTrackHits();
102  DrawUnusedHits();
103  }
104 }
105 //__________________________________________
106 void skip(int nEvents=1) {
107  if(ftpChain) ftpChain->Skip(nEvents);
108 }
109 
110 //__________________________________________
111 void ae()
112 {
113  gEdFtp->Clear();
114  newevent:
115  ftpChain->MakeEvent();
116  event = (StEvent*)ftpChain->GetDataSet("StEvent");
117  if (event && !event->trackNodes().empty()) {
118  rd(); // Draw the tracks
119  } else {
120  printf(" event is empty %p\n", event);
121  goto newevent;
122  }
123  }
124 
125 //__________________________________________
126  void EdFtpc(const char* file =
127  "/star/institutions/bnl/fine/testfiles/st_physics_10169042_raw_4030001.event.root"
128  , unsigned int nEvent=44, const char * detectorNames="FTPC,StarFloor,StarCompass,StarBeam")
129  {
130  // Start application open the file provided.
131  if ( gSystem->AccessPathName(file)) {
132  cout << endl << endl
133  << "** Error ** : The input file: <"<< file << "> does not exist !!!"
134  << endl << endl;
135  return;
136  }
137 
138  gROOT->Macro("Load.C");
139  gSystem->Load("StDetectorDbMaker");
140  TString bfcchain = Form("bfc.C(0,\"doevents\",\"%s\")",file);
141  if (nEvent > 1)
142  bfcchain = Form("bfc.C(%d,%d-1,\"doevents\",\"%s\")",nEvent,nEvent,file);
143  cout << bfcchain.Data() << endl;
144  gROOT->Macro(bfcchain.Data());
145 
146  delete gEventDisplay; // destroy the built-in display
147  ftpChain = (StChain *)StMaker::GetChain();
148 // -- Start new display
149  gEdFtp = new StuDraw3DEvent(detectorNames); // create our own one (with no detector geometry)
150  gEdFtp->SetBkColor(kBlack);
151 
152  ae(); // Advance one event
153  }
Definition: StHit.h:125
virtual const StDraw3DStyle & Style(EDraw3DStyle type) const
Return the reference to the predefined StDraw3DStyle object.
Definition: StDraw3D.cxx:482
virtual void SetBkColor(Color_t newBkColor)
Set the ROOT color as the widget background.
Definition: StDraw3D.cxx:447
static Color_t Pt2Color(double pt)
Maps the track pt to the STAR StTrack track color code.
Definition: StDraw3D.cxx:78
void rd(int hits=0, bool clear=false)
This function redraws all hits and/or tracks from the current event.
Definition: Ed.C:69
void ae(int tracks=-1, int hits=-1)
This function is to search for the next non-empty event and draw it by looping over StBFChain (readin...
Definition: Ed.C:102
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...
virtual void Clear(Option_t *opt="update")
Remove all objects from the list and update the screen if opt is &quot;update&quot;.
Definition: StDraw3D.cxx:398