StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Plot3Dtracks.C
1 // $Id: Plot3Dtracks.C,v 1.4 2009/11/30 18:39:08 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  gSystem->Load("StDetectorDbMaker");
21  bfc(0,"in,StEvent",file);
22  StEvent *event = 0;
23  gEventDisplay->SetBkColor(kWhite);
24  int MyEventId=eventNumber;
25  int MyTrackId=trackId;
26  printf(" Look up the file %s to find the track %d from the event %d \n"
27  , file,MyTrackId,MyEventId);
28 
29  bool trackWasFound = false;
30  bool eventWasFound = false;
31 
32  while (!eventWasFound && !chain->MakeEvent() ) {
33  // Access the StEvent pointer
34  event = (StEvent *)chain->GetDataSet("StEvent");
35  if (chain->GetEventNumber() == MyEventId) { eventWasFound = true; break; }
36  printf(" ----- Current event %d keep moving towards event %d\n"
37  ,chain->GetEventNumber(), MyEventId);
38  }
39  if (eventWasFound) {
40  // printf(" -++++++++++++++++++++++++++++++++ %p total tracks=%d\n",event
41  // ,event->summary()->numberOfTracks());
42  const StSPtrVecTrackNode& theNodes = event->trackNodes();
43  StTrack *track = 0; int sz = theNodes.size();
44  for (unsigned int i=0; i<sz; i++) {
45  track = theNodes[i]->track(global);
46  printf(" - current track - %d ---looking for %d \n", track->key(),MyTrackId);
47  // select tracks
48  if (track && (track->key() == MyTrackId)) { trackWasFound = true; break; }
49  }
50  if (trackWasFound) gEventDisplay->Track(*track);
51  else {
52  printf("ATTENTION: No track %d was found in %d event from file <%s>\n"
53  , MyTrackId, MyEventId, file);
54  }
55 
56  } else {
57  printf("ATTENTION: No event %d was found from file <%s> !!!\n", MyEventId, file);
58  }
59 }
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.