STAR offline framework provides two C++ classes:
  1. StuDraw3DEvent (from StEventUtilities package)
    to visualize the components of the StEvent.
    Set QtRoot environment: Try macro:
  2. StuDraw3DMuEvent (from StMuDSTMaker package)
    to visualize the components of the StMuEvent.
    Set QtRoot environment: Try macros:
The classes StuDraw3DEvent / StuDraw3DMuEvent provide the simple way to visualize the StEvent / StMuEvent primitives in 3D quickly against of the STAR detector geometry.

The classes are "self-sufficient" and ready-to-use "on demand".

Compare its usage with the other components of STAR offline. For example,

The StuDraw3DEvent / StuDraw3DMuEvent classes can be used directly from any C++ application, from the ROOT Cint interpreter and even from the gdb UNIX debugger break point as needed. It can be used to customize the STAR applications mentioned above also. On the other hands it is backed by the same well-known poweful 3D engine; and it shares with the full-fledged STAR 3D applications the powerfull and flexible GUI interface. The GUI interface is described "STAR visualization and plotting" by "Offline Event Display" and "Star Geometry Browser" links.


The base StDraw3D class is a controller connecting the arbitrary "model" object to the arbitrary ROOT 3D class "view" object to implement the so-called "Model / View" paradigm. In our case, the "Model" is an arbitrary object and the "View" is an instance of some ROOT 3D class. To render views the StDraw3D instantiates the TCanvas and TVirtualViewer3D to allow the user select interactively the "view" instance and invoke the model methods like:

For example, StuDraw3DEvent class applies:


To see how it works, you need two things to do

  1. Create the custom ".rootrc" file to turn the Qt-layer on
        stardev	
        ln -s  $STAR/QtRoot/qtExamples/QtGBrowser/.rootrc
    
  2. Execute the ROOT macros
    	
      > root.exe Draw3D.C
    
    You should get the picture
    .
    One is advised to switch from the "perspective" view to the "parallel" one
    The Draw3D.C macro is 3 lines long:
    	
    void Draw3D()
    {
       gROOT->Macro("Load.C");
       gEventDisplay->Draw3DTest();
    }
    
    Another ROOT session:
    	
    root[0] gROOT->Macro("Load.C");
    root[1] gEventDisplay->ShowTest();
    
    is to produce two separate windows;
    Event over detector geometry Event with no detector geometry

    The StDraw3D::Draw3DTest should give you a clue how the class can be used


     
     void StDraw3D::Draw3DTest(){
    
       float xyz[] = { 189.195,       27.951,       123.966
                     ,187.195,       28.6187,       122.89
                     ,181.195       ,30.6788       ,119.556
                     ,179.195       ,31.3387       ,118.454
                     ,177.195       ,32.0065       ,117.328
                     ,175.195       ,32.6132       ,116.26
                     ,173.195       ,33.2385       ,115.146
                     ,171.195       ,33.8552       ,114.016
                     ,169.195       ,34.3924       ,112.964
             };
    
       int sizeXYZ = sizeof(xyz)/sizeof(float)/3;
       fprintf(stderr," %d %p\n", sizeXYZ,xyz);
       // Draw the 3D polymarkers
       Draw3D(sizeXYZ,xyz);
       SetComment("The hits from the TPC sector");
    
       // Draw the 3D polyline
       Line(sizeXYZ,xyz,kPrimaryTrack);
       SetComment("The recontstructed track");
    }
    

    To draw the components (tracks, hits etc) of the StEvent,


    use the ROOT session like

     
     root.exe   # or "root4star", do  NOT use just "root". "root" is a shell script that  can screw the environment
       root[0] .x Load.C
       root[1] .x bfc.C(0,"doevents","st_physics_6048025_raw_1020002.event.root"); 
       root[2]  // One can use any other chain parameters instead of "doevents" above
       root[3] chain->MakeEvent();                 // to read the next event
       root[4] StEvent *event = (StEvent *)chain->GetDataSet("StEvent");   // Access the StEvent pointer
       root[5] gEventDisplay->SetBkColor(kWhite);  // Change the backgorund color
       root[6] gEventDisplay->Tracks(event);       // Draw the tracks
    
    Replacing the last statement with
     
       root[5] gEventDisplay->Tracks(event,primary);  // to draw the tracks
    
    should produce another picture:


    Invocation of the

     
    root.exe [6]  gEventDisplay->Clear();                    // Clear the previous picture
    root.exe [7]  gEventDisplay->Hits(event,kUsedHitsTracks);// Draw tracks and its his
    
    will show the image:


    To hide the detector geometry components and improve the "display" response time one can change the Coin widget attributes from "As Is" to "Points" to do that

    1. Click with the "right mouse button" over the OpenGL widget working area;
    2. Select from the Coint "Context menu"
      "Draw Styles> -> "Still darwstyle" -> "Points"
      or
      "Draw Styles> -> "Animating drawstyle" -> "Points"
      to get the low resolution picture (see below)
    3. To restore the original view you can always use the same menu and select "As Is" position there.

    How to change the widget view to hide the detector geometry
    Original "as is" view Coin3D "Context menu" "Points" view

    The macro below shows how one can navigate the StEvent structure read from the root files to find and draw the track providing the eventNumber and trackId. You can pick this macro from $STAR/StRoot/macros/graphics/Plot3Dtracks.C. Try:

    root.exe Plot3Dtracks.C
    

    void Plot3Dtracks(int eventNumber=22394, int trackId=425, const char *file="st_physics_8112087_raw_1020015.event.root"){
     // This example shows how to use Draw3D class to draw  the 
     // track if one knows the track "event number" and "track id".
     
      gROOT->Macro("Load.C");
      gROOT->LoadMacro("bfc.C");
      bfc(0,"in,StEvent",file); 
      StEvent *event = 0;
      gEventDisplay->SetBkColor(kWhite);
      printf(" Look up the file %s to find the track %d from the event %d \n"
           , file,trackId,eventNumber);
      bool trackWasFound = false;
      bool eventWasFound = false;
    
      while (!eventWasFound && !chain->MakeEvent() ) {
         // Access the StEvent pointer
         event  =  (StEvent *)chain->GetDataSet("StEvent");
         // ------------------ select event  -----------------------
         if (chain->GetEventNumber() == eventNumber) { eventWasFound = true; break; }
         // --------------------------------------------------------
      }
      if (eventWasFound) {
         const StSPtrVecTrackNode& theNodes = event->trackNodes();
         StTrack *track = 0; int sz = theNodes.size();
         for (unsigned int i=0; i<sz; i++) {
            // --------------------- select tracks  -------------------------//
            track = theNodes[i]->track(global);                              //
            if  (track->key() == trackId) { trackWasFound  = true;  break; } //
            // --------------------------------------------------------------//
          }
          //-----------------Draw the track ---------------//
          if (trackWasFound) gEventDisplay->Track(*track); //
          //-----------------------------------------------//
      }
    }
    

    Here you are the StuDraw3DEvent (see STAR CVS also) class API including the methods from the base StDraw3D (see STAR CVS also) class.
    The definitions of the ROOT color and marker style attributes are provided by the TAttMarker C++ class documentation.


    StuDraw3DEvent C++ class API


    enum EDraw3DStyle {kVtx,kPrimaryTrack,kGlobalTrack,kUsedHit,kUnusedHit,kTrackBegin,kTrackEnd,kUser};
    
    class StuDraw3DEvent : public StDraw3D {
    
         StuDraw3DEvent(TVirtualPad *pad = 0); // "by default" (pad=0) the new viewer is to be created automatically
    
                   // Draw StEvent "StTrack" object with the ROOT color, style, size attributes
         virtual TObject *Track(const StTrack &track
                      ,  Color_t col
                      ,  Style_t sty= Style_t(-1)
                      ,  Size_t siz = Size_t (-1));
                   // Draw StEvent "StTrack" object with the predefined attrbutes
    
         virtual TObject *Track(const StTrack &track, EDraw3DStyle sty=kPrimaryTrack);
    
                   // Draw StEvent "StMeasuredPoint" object  (like StHit, StVertex) with the ROOT color, style, size attributes
         virtual TObject *Hit(const StMeasuredPoint &hit
                      ,  Color_t col
                      ,  Style_t sty= Style_t(-1)
                      ,  Size_t siz = Size_t (-1));
    
                   // Draw StEvent "StMeasuredPoint" object  (like StHit, StVertex) with the predefined attrbutes
                   // This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
    
         virtual TObject *Hit(const StMeasuredPoint &hit, EDraw3DStyle sty=kUsedHit);
    
                   // Draw StEvent "StMeasuredPoint" object  (like StHit, StVertex) with the ROOT color, style, size attributes
                   // This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
    
         virtual TObject *Vertex(const StMeasuredPoint &hit
                      ,  Color_t col
                      ,  Style_t sty= Style_t(-1)
                      ,  Size_t siz = Size_t (-1));
    
                   // Draw StEvent "StMeasuredPoint" object  (like StHit, StVertex) with the predefined attributes
                   // This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
    
         virtual TObject *Vertex(const StMeasuredPoint &hit, EDraw3DStyle sty=kVtx);
         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));
         virtual TObject *TrackInOut(const StTrack &track, EDraw3DStyle sty=kUsedHit, Bool_t in=kTRUE);
    
                   // Draw the array of the float coordinates with ROOT TPolyMarker3D class and the predefined attributes
    
         virtual TObject *Points(int n, const float *xyz,  EDraw3DStyle sty);
    
                   // Draw the array of the float coordinates with ROOT TPolyMarker3D class and the ROOT color, style, size attributes
    
         virtual TObject *Points(int n, const float *xyz
             ,  Color_t col= Color_t(-1)
             ,  Style_t sty= Style_t(-1)
             ,  Size_t siz = Size_t (-1));
    
                   // Draw ONE 3D marker with ROOT TPolyMarker3D class and the ROOT color, style, size attributes
         virtual TObject *Point(float x, float y, float z
             ,  Color_t col= Color_t(-1)
             ,  Style_t sty= Style_t(-1)
             ,  Size_t siz = Size_t (-1));
    
                   // Draw ONE 3D marker with ROOT TPolyMarker3D class and the predefined attrbutes
    
         virtual TObject *Point(float x, float y, float z,  EDraw3DStyle sty);
    
                   // Draw the array of the float coordinates with ROOT TPolyLine3D class and the ROOT color, style, size attributes
    
         virtual TObject *Line(int n,  const float *xyz
             ,  Color_t col= Color_t(-1)
             ,  Style_t sty= Style_t(-1)
             ,  Size_t siz = Size_t (-1));
    
                   // Draw the array of the float coordinates with ROOT TPolyLine3D class and the predefined attributes
    
         virtual TObject *Line(int n,  const float *xyz,  EDraw3DStyle sty);
       
                   // Draw the test example
         void Draw3DTest();
    };
    

    To report the bug use STAR Bug report facility

    Valeri Fine
    (fine at bnl dot gov )