Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:20:28

0001 // $Id: $
0002 
0003 /*!
0004  * \file PHGeom_DSTInspection.C
0005  * \brief Quick inspection of PHGeoTGeo object in RUN/GEOMETRY node inside a DST file
0006  * \author Jin Huang <jhuang@bnl.gov>
0007  * \version $Revision:   $
0008  * \date $Date: $
0009  */
0010 
0011 #include <phgeom/PHGeomUtility.h>
0012 
0013 #include <fun4all/Fun4AllDstInputManager.h>
0014 #include <fun4all/Fun4AllDstOutputManager.h>
0015 #include <fun4all/Fun4AllDummyInputManager.h>
0016 #include <fun4all/Fun4AllInputManager.h>
0017 #include <fun4all/Fun4AllNoSyncDstInputManager.h>
0018 #include <fun4all/Fun4AllOutputManager.h>
0019 #include <fun4all/Fun4AllServer.h>
0020 #include <fun4all/SubsysReco.h>
0021 
0022 #include <phool/recoConsts.h>
0023 
0024 #include <TEveGeoNode.h>
0025 #include <TEveManager.h>
0026 #include <TGLClip.h>
0027 #include <TGLUtil.h>
0028 #include <TGLViewer.h>
0029 #include <TGeoManager.h>
0030 #include <TROOT.h>
0031 
0032 #include <cassert>
0033 #include <string>
0034 
0035 R__LOAD_LIBRARY(libphgeom.so)
0036 R__LOAD_LIBRARY(libg4dst.so)
0037 R__LOAD_LIBRARY(libfun4all.so)
0038 
0039 //! Quick inspection of PHGeoTGeo object in RUN/GEOMETRY node inside a DST file
0040 //! Based on abhisek's display macro
0041 void PHGeom_DSTInspection(const std::string &DST_file_name = "G4sPHENIX.root",
0042                           bool do_clip = true)
0043 {
0044   TEveManager::Create();
0045 
0046   Fun4AllServer *se = Fun4AllServer::instance();
0047   se->Verbosity(1);
0048   recoConsts *rc = recoConsts::instance();
0049   rc->set_IntFlag("RUNNUMBER", 12345);
0050 
0051   Fun4AllInputManager *hitsin = new Fun4AllDstInputManager("DSTin");
0052   hitsin->fileopen(DST_file_name);
0053   se->registerInputManager(hitsin);
0054 
0055   // run one event as example
0056   se->run(1);
0057 
0058   PHGeomUtility::GetTGeoManager(se->topNode());
0059 
0060   assert(gGeoManager);
0061 
0062   if (!gROOT->GetListOfGeometries()->FindObject(gGeoManager))
0063   {
0064     gROOT->GetListOfGeometries()->Add(gGeoManager);
0065   }
0066   if (!gROOT->GetListOfBrowsables()->FindObject(gGeoManager))
0067   {
0068     gROOT->GetListOfBrowsables()->Add(gGeoManager);
0069   }
0070   //  gGeoManager->UpdateElements();
0071 
0072   TGeoNode *current = gGeoManager->GetCurrentNode();
0073   // Alternate drawing
0074   // current->GetVolume()->Draw("ogl");
0075   // Print the list of daughters
0076   // current->PrintCandidates();
0077   for (int igeom = 0; igeom < current->GetNdaughters(); igeom++)
0078   {
0079     TGeoNode *geo_node = (TGeoNode *) current->GetNodes()->UncheckedAt(igeom);
0080     geo_node->GetVolume()->VisibleDaughters(kFALSE);
0081     geo_node->GetVolume()->SetTransparency(2);
0082     // Keep the pipe visible all the time
0083     if (std::string(geo_node->GetName()).find("PIPE") != std::string::npos)
0084     {
0085       geo_node->GetVolume()->SetTransparency(0);
0086     }
0087   }
0088   TEveGeoTopNode *eve_node = new TEveGeoTopNode(gGeoManager, current);
0089   eve_node->SetVisLevel(6);
0090   gEve->AddGlobalElement(eve_node);
0091   gEve->FullRedraw3D(kTRUE);
0092 
0093   // EClipType not exported to CINT (see TGLUtil.h):
0094   // 0 - no clip, 1 - clip plane, 2 - clip box
0095   TGLViewer *v = gEve->GetDefaultGLViewer();
0096   if (do_clip)
0097   {
0098     v->GetClipSet()->SetClipType(TGLClip::kClipPlane);
0099   }
0100   //  v->ColorSet().Background().SetColor(kMagenta + 4);
0101   v->SetGuideState(TGLUtil::kAxesEdge, kTRUE, kFALSE, nullptr);
0102   v->RefreshPadEditor(v);
0103 
0104   v->CurrentCamera().RotateRad(-1.6, 0.);
0105   v->DoDraw();
0106 }