example_Acts.cxx
Go to the documentation of this file.
1 R__LOAD_LIBRARY(libActsDD4hepPlugin.so)
2 R__LOAD_LIBRARY(libDDG4IO.so)
3 R__LOAD_LIBRARY(libGenDetectors.so)
4 #include "DD4hep/Detector.h"
5 #include "DDG4/Geant4Data.h"
6 #include "DDRec/CellIDPositionConverter.h"
7 #include "DDRec/SurfaceManager.h"
8 #include "DDRec/Surface.h"
9 #include "ROOT/RDataFrame.hxx"
10 
11 #include "TCanvas.h"
12 #include "TChain.h"
13 
14 #include "Acts/Geometry/TrackingGeometry.hpp"
15 #include "Acts/Geometry/TrackingVolume.hpp"
16 #include "Acts/Plugins/DD4hep/ConvertDD4hepDetector.hpp"
17 
22 void example_Acts(const char* fname = "test_tracker_disc.root"){
23 
24  using namespace ROOT::Math;
25 
26  ROOT::EnableImplicitMT(4);
27  TChain* t = new TChain("EVENT");
28  t->Add(fname);
29 
30  ROOT::RDataFrame d0(*t, {"GEMTrackerHits","MCParticles"});
31 
32  //How to get the type of the initial branch: (vector<dd4hep::sim::Geant4Tracker::Hit*>)
33  //std::cout << t->GetBranch("GEMTrackerHits")->GetClassName() << std::endl;
34 
35  // -------------------------
36  // Get the DD4hep instance
37  // Load the compact XML file
38  // Initialize the position converter tool
39  dd4hep::Detector& detector = dd4hep::Detector::getInstance();
40  detector.fromCompact("GEM_sidis.xml");
41  dd4hep::rec::CellIDPositionConverter cellid_converter(detector);
42 
43  // -------------------------
44  // Get the surfaces map
45  dd4hep::rec::SurfaceManager& surfMan = *detector.extension<dd4hep::rec::SurfaceManager>() ;
46  auto surfMap = surfMan.map( "world" ) ;
47 
48 
49  //std::unique_ptr<const Acts::TrackingGeometry>
50  auto acts_tracking_geometry =
51  Acts::convertDD4hepDetector(detector.world(), Acts::Logging::Level::VERBOSE);
52 
53  // std::cout << *acts_tracking_geometry << "\n";
54 
55  //if(acts_tracking_geometry->highestTrackingVolume()) {
56  // std::cout << " yooooooo\n";
57  //}
58  if(acts_tracking_geometry.get()) {
59  std::cout << " yooooooo\n";
60  if(acts_tracking_geometry->highestTrackingVolume()) {
61  std::cout << "\n volume name \n ";
62  std::cout << acts_tracking_geometry->highestTrackingVolume()->volumeName() << std::endl;
63  } else {
64  std::cout << "\nderp\n";
65  }
66  }
67 
68  std::cout << " \n\nDONE ! \n";
69 }
Detector
Definition: DDG4.py:69
void example_Acts(const char *fname="test_tracker_disc.root")
Example loading ACTs.