00001
00002
00003
00004 void Plot3Dtracks_usage()
00005 {
00006 printf("\n The \"Plot3Dtracks.C\" macro creates a simple STAR chain to read the \"StEvent\" object \n");
00007 printf(" from ROOT file and draw the track with the \"trackId\" from the \"eventNumber\" event\n");
00008 printf("\n");
00009 printf(" USAGE: Plot3Dtracks.C(int eventNumber, int trackId, const char *file)\n");
00010 printf(" ------\n");
00011 printf(" see: <http://www.star.bnl.gov/public/comp/vis/StDraw3D> as well\n\n");
00012 }
00013
00014 void Plot3Dtracks(int eventNumber=22394, int trackId=425, const char *file="your_root_file"){
00015
00016
00017 if (!strcmp(file,"your_root_file")) { Plot3Dtracks_usage(); return;}
00018 gROOT->Macro("Load.C");
00019 gROOT->LoadMacro("bfc.C");
00020 bfc(0,"in,StEvent",file);
00021 StEvent *event = 0;
00022 gEventDisplay->SetBkColor(kWhite);
00023 int MyEventId=eventNumber;
00024 int MyTrackId=trackId;
00025 printf(" Look up the file %s to find the track %d from the event %d \n"
00026 , file,MyTrackId,MyEventId);
00027
00028 bool trackWasFound = false;
00029 bool eventWasFound = false;
00030
00031 while (!eventWasFound && !chain->MakeEvent() ) {
00032
00033 event = (StEvent *)chain->GetDataSet("StEvent");
00034 if (chain->GetEventNumber() == MyEventId) { eventWasFound = true; break; }
00035 printf(" ----- Current event %d keep moving towards event %d\n"
00036 ,chain->GetEventNumber(), MyEventId);
00037 }
00038 if (eventWasFound) {
00039
00040
00041 const StSPtrVecTrackNode& theNodes = event->trackNodes();
00042 StTrack *track = 0; int sz = theNodes.size();
00043 for (unsigned int i=0; i<sz; i++) {
00044 track = theNodes[i]->track(global);
00045 printf(" - current track - %d ---looking for %d \n", track->key(),MyTrackId);
00046
00047 if (track && (track->key() == MyTrackId)) { trackWasFound = true; break; }
00048 }
00049 if (trackWasFound) gEventDisplay->Track(*track);
00050 else {
00051 printf("ATTENTION: No track %d was found in %d event from file <%s>\n"
00052 , MyTrackId, MyEventId, file);
00053 }
00054
00055 } else {
00056 printf("ATTENTION: No event %d was found from file <%s> !!!\n", MyEventId, file);
00057 }
00058 }