StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Plot3Dtracks.C
1 // $Id: Plot3Dtracks.C,v 1.1 2009/09/02 18:15:34 fine Exp $
2 // Author: Valeri Fine, 26.03.2009 (fine@bnl.gov)
3 
4 void Plot3Dtracks_usage()
5 {
6  printf("\n The \"Plot3Dtracks.C\" macro creates a simple STAR chain to read the \"StEvent\" object \n");
7  printf(" from ROOT file and draw the track with the \"trackId\" from the \"eventNumber\" event\n");
8  printf("\n");
9  printf(" USAGE: Plot3Dtracks.C(int eventNumber, int trackId, const char *file)\n");
10  printf(" ------\n");
11  printf(" see: <http://www.star.bnl.gov/public/comp/vis/StDraw3D> as well\n\n");
12 }
13 
14 void Plot3Dtracks(int eventNumber=22394, int trackId=425, const char *file="your_root_file"){
15  // This example shows how to use Draw3D class to draw the
16  // track if one knows the track "event number" and "track id".
17  if (!strcmp(file,"your_root_file")) { Plot3Dtracks_usage(); return;}
18  gROOT->Macro("Load.C");
19  gROOT->LoadMacro("bfc.C");
20  bfc(0,"in,StEvent",file);
21  StEvent *event = 0;
22  gEventDisplay->SetBkColor(kWhite);
23  int MyEventId=eventNumber;
24  int MyTrackId=trackId;
25  printf(" Look up the file %s to find the track %d from the event %d \n"
26  , file,MyTrackId,MyEventId);
27 
28  bool trackWasFound = false;
29  bool eventWasFound = false;
30 
31  while (!eventWasFound && !chain->MakeEvent() ) {
32  // Access the StEvent pointer
33  event = (StEvent *)chain->GetDataSet("StEvent");
34  if (chain->GetEventNumber() == MyEventId) { eventWasFound = true; break; }
35  printf(" ----- Current event %d keep moving towards event %d\n"
36  ,chain->GetEventNumber(), MyEventId);
37  }
38  if (eventWasFound) {
39  // printf(" -++++++++++++++++++++++++++++++++ %p total tracks=%d\n",event
40  // ,event->summary()->numberOfTracks());
41  const StSPtrVecTrackNode& theNodes = event->trackNodes();
42  StTrack *track = 0; int sz = theNodes.size();
43  for (unsigned int i=0; i<sz; i++) {
44  track = theNodes[i]->track(global);
45  printf(" - current track - %d ---looking for %d \n", track->key(),MyTrackId);
46  // select tracks
47  if (track && (track->key() == MyTrackId)) { trackWasFound = true; break; }
48  }
49  if (trackWasFound) gEventDisplay->Track(*track);
50  else {
51  printf("ATTENTION: No track %d was found in %d event from file <%s>\n"
52  , MyTrackId, MyEventId, file);
53  }
54 
55  } else {
56  printf("ATTENTION: No event %d was found from file <%s> !!!\n", MyEventId, file);
57  }
58 }
virtual void SetBkColor(Color_t newBkColor)
Set the ROOT color as the widget background.
Definition: StDraw3D.cxx:447
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.