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
00018 gROOT->Macro("Load.C");
00019 gROOT->LoadMacro("bfc.C");
00020 gSystem->Load("StDetectorDbMaker");
00021 bfc(0,"in,StEvent",file);
00022 StEvent *event = 0;
00023 gEventDisplay->SetBkColor(kWhite);
00024 int MyEventId=eventNumber;
00025 int MyTrackId=trackId;
00026 printf(" Look up the file %s to find the track %d from the event %d \n"
00027 , file,MyTrackId,MyEventId);
00028
00029 bool trackWasFound = false;
00030 bool eventWasFound = false;
00031
00032 while (!eventWasFound && !chain->MakeEvent() ) {
00033
00034 event = (StEvent *)chain->GetDataSet("StEvent");
00035 if (chain->GetEventNumber() == MyEventId) { eventWasFound = true; break; }
00036 printf(" ----- Current event %d keep moving towards event %d\n"
00037 ,chain->GetEventNumber(), MyEventId);
00038 }
00039 if (eventWasFound) {
00040
00041
00042 const StSPtrVecTrackNode& theNodes = event->trackNodes();
00043 StTrack *track = 0; int sz = theNodes.size();
00044 for (unsigned int i=0; i<sz; i++) {
00045 track = theNodes[i]->track(global);
00046 printf(" - current track - %d ---looking for %d \n", track->key(),MyTrackId);
00047
00048 if (track && (track->key() == MyTrackId)) { trackWasFound = true; break; }
00049 }
00050 if (trackWasFound) gEventDisplay->Track(*track);
00051 else {
00052 printf("ATTENTION: No track %d was found in %d event from file <%s>\n"
00053 , MyTrackId, MyEventId, file);
00054 }
00055
00056 } else {
00057 printf("ATTENTION: No event %d was found from file <%s> !!!\n", MyEventId, file);
00058 }
00059 }