Skip to content
Snippets Groups Projects
example_Acts.cxx 3.63 KiB
Newer Older
  • Learn to ignore specific revisions
  • Whitney Armstrong's avatar
    Whitney Armstrong committed
    #include "DDG4/Geant4Data.h"
    #include "DDRec/CellIDPositionConverter.h"
    #include "DDRec/SurfaceManager.h"
    #include "DDRec/Surface.h"
    #include "ROOT/RDataFrame.hxx"
    
    #include "TCanvas.h"
    #include "TChain.h"
    
    #include "Acts/Geometry/TrackingGeometry.hpp"
    #include "Acts/Geometry/TrackingVolume.hpp"
    #include "Acts/Plugins/DD4hep/ConvertDD4hepDetector.hpp"
    
    //convertDD4hepDetector(
    //    dd4hep::DetElement worldDetElement, Logging::Level loggingLevel,
    //    BinningType bTypePhi, BinningType bTypeR, BinningType bTypeZ,
    //    double layerEnvelopeR, double layerEnvelopeZ, double defaultLayerThickness,
    //    const std::function<void(std::vector<dd4hep::DetElement>& detectors)>&
    //        sortSubDetectors,
    //    const Acts::GeometryContext& gctx,
    //    std::shared_ptr<const IMaterialDecorat
    
    //void sortDetElements(std::vector<dd4hep::DetElement>& det) {
    //  std::vector<dd4hep::DetElement> tracker;
    //  for (auto& detElement : det) {
    //    std::string detName = detElement.name();
    //    if (detName.find("Muon") != std::string::npos)
    //      muon.push_back(detElement);
    //    else if (detName.find("ECal") != std::string::npos)
    //      eCal.push_back(detElement);
    //    else if (detName.find("HCal") != std::string::npos)
    //      hCal.push_back(detElement);
    //    else
    //      tracker.push_back(detElement);
    //  }
    //  sort(muon.begin(), muon.end(),
    //       [](const dd4hep::DetElement& a, const dd4hep::DetElement& b) {
    //         return (a.id() < b.id());
    //       });
    //  sort(eCal.begin(), eCal.end(),
    //       [](const dd4hep::DetElement& a, const dd4hep::DetElement& b) {
    //         return (a.id() < b.id());
    //       });
    //  sort(hCal.begin(), hCal.end(),
    //       [](const dd4hep::DetElement& a, const dd4hep::DetElement& b) {
    //         return (a.id() < b.id());
    //       });
    //  sort(tracker.begin(), tracker.end(),
    //       [](const dd4hep::DetElement& a, const dd4hep::DetElement& b) {
    //         return (a.id() < b.id());
    //       });
    //  det.clear();
    //  det = tracker;
    //
    //  det.insert(det.end(), eCal.begin(), eCal.end());
    //  det.insert(det.end(), hCal.begin(), hCal.end());
    //  det.insert(det.end(), muon.begin(), muon.end());
    //}
    
    /** Example loading ACTs.
     *
     * 
     */
    void example_Acts(const char* fname = "upsilon_derp.root"){
    
      using namespace ROOT::Math;
    
      //ROOT::EnableImplicitMT(4);
      //TChain* t = new TChain("EVENT");
      //t->Add(fname);
    
      //ROOT::RDataFrame d0(*t, {"GEMTrackerHits","MCParticles"});
    
      //How to get the type of the initial branch: (vector<dd4hep::sim::Geant4Tracker::Hit*>)
      //std::cout << t->GetBranch("GEMTrackerHits")->GetClassName() << std::endl;
      
      // -------------------------
      // Get the DD4hep instance
      // Load the compact XML file
      // Initialize the position converter tool
      dd4hep::Detector& detector = dd4hep::Detector::getInstance();
      detector.fromCompact("topside/vertex_tracker.xml");
      dd4hep::rec::CellIDPositionConverter cellid_converter(detector);
    
    
      std::cout << " CELL ID : " << 33620481 << ", Position: " << cellid_converter.position(33620481) << "\n\n\n";
    
    
    Whitney Armstrong's avatar
    Whitney Armstrong committed
      // -------------------------
      // Get the surfaces map
      //dd4hep::rec::SurfaceManager& surfMan = *detector.extension<dd4hep::rec::SurfaceManager>() ;
      //auto surfMap = surfMan.map( "world" ) ;
    
      std::cout << " derp\n";
    
      //std::unique_ptr<const Acts::TrackingGeometry> 
      Acts::convertDD4hepDetector (detector.world(),Acts::Logging::Level::VERBOSE);
    
      std::cout << "derp\n";
    
      //if(acts_tracking_geometry) {
      //  if(acts_tracking_geometry->highestTrackingVolume()) {
      //    std::cout << " volume name \n ";
      //    std::cout << acts_tracking_geometry->highestTrackingVolume()->volumeName() << std::endl;
      //  } else {
      //    std::cout << "derp\n";
      //  }
      //}
      
    
    }