From 40bec3a4eb166050704652f8cd2a9b3267cb3d41 Mon Sep 17 00:00:00 2001
From: Whitney Armstrong <warmstrong@anl.gov>
Date: Mon, 23 Mar 2020 20:56:17 -0500
Subject: [PATCH] 	modified:   scripts/example_digi.cxx 	modified:  
 scripts/example_hit_position.cxx 	modified:  
 scripts/example_hit_recon.cxx

---
 scripts/example_digi.cxx         | 26 +++++---------------------
 scripts/example_hit_position.cxx | 11 +++++------
 scripts/example_hit_recon.cxx    |  3 +--
 3 files changed, 11 insertions(+), 29 deletions(-)

diff --git a/scripts/example_digi.cxx b/scripts/example_digi.cxx
index 4307be3..b2800fa 100644
--- a/scripts/example_digi.cxx
+++ b/scripts/example_digi.cxx
@@ -43,28 +43,15 @@ void example_digi(const char* fname = "gem_tracker_sim.root"){
 
   //// -------------------------
   //// Get the surfaces map
-  dd4hep::rec::SurfaceManager& surfMan = *detector.extension<dd4hep::rec::SurfaceManager>() ;
-  auto surfMap = surfMan.map( "world" ) ;
+  //dd4hep::rec::SurfaceManager& surfMan = *detector.extension<dd4hep::rec::SurfaceManager>() ;
+  //auto surfMap = surfMan.map( "world" ) ;
   
   auto nhits = [] (std::vector<dd4hep::sim::Geant4Tracker::Hit*>& hits){ return (int) hits.size(); };
-  //auto hit_position = [&](const std::vector<dd4hep::sim::Geant4Tracker::Hit*>& hits){
-  //for(const auto& h: hits){
-  //  //std::cout << (h->position/10.0) << std::endl;
-  //  //std::cout << cellid_converter.position(h->cellID) << std::endl;
-  //  //dd4hep::rec::SurfaceMap::const_iterator
-  //  const auto si = _surfMap.find( cellid_converter.findContext(h->cellID)->identifier ); //identifier=volumeID
-  //  dd4hep::rec::ISurface* surf = (si != _surfMap.end() ?  si->second  : 0);
-  //  dd4hep::rec::Vector3D pos =  surf->origin();//fit_global(pivot[0],pivot[1],pivot[2]);
-  //  //std::cout << pos.x() << ", " << pos.y() << ", " << pos.z()<< std::endl;
-  //  // transform lcio units to dd4hep units, see documentation for other functions              
-  //  //DDSurfaces::Vector2D fit_local = surf->globalToLocal( dd4hep::mm * fit_global );
-  //}
-  //  return hits.size(); };
 
   auto digitize_gem_hits = 
     [&](const std::vector<dd4hep::sim::Geant4Tracker::Hit*>& hits) {
       std::vector<lcio2::TrackerRawDataData> digi_hits;
-      std::normal_distribution<> time_dist(0,2.0);
+      std::normal_distribution<> smear_dist(0,2.0);
       std::normal_distribution<> adc_dist(5.0,3.0);
 
       std::map<int64_t,lcio2::TrackerRawDataData> hits_by_id;
@@ -79,7 +66,7 @@ void example_digi(const char* fname = "gem_tracker_sim.root"){
         //fmt::print("{} vs {} vs {}\n", id1, id2,id3);
         fmt::print("{} vs {}\n", h->cellID, ahit.cellID0);
         // time is not kept from dd4hep hit, instead using z position as crude substitute
-        ahit.time = pos.z() + time_dist(gen);
+        ahit.time = pos.z() + smear_dist(gen);
         ahit.adc  = adc_dist(gen);
         //digi_hits.push_back(ahit);
       }
@@ -91,10 +78,7 @@ void example_digi(const char* fname = "gem_tracker_sim.root"){
     };
 
   auto d1 = d0.Define("nhits", nhits, {"GEMTrackerHits"})
-              //.Filter([](int n){ return (n>4); },{"nhits"})
-              //.Define("delta",hit_position, {"GEMTrackerHits"})
-              .Define("RawTrackerHits", digitize_gem_hits, {"GEMTrackerHits"})
-              ;
+              .Define("RawTrackerHits", digitize_gem_hits, {"GEMTrackerHits"});
 
   auto h0 = d1.Histo1D(TH1D("h0", "Number of Hits in GEM Tracker; N hits ", 20, 0,20), "nhits");
 
diff --git a/scripts/example_hit_position.cxx b/scripts/example_hit_position.cxx
index b12b904..e4e1e57 100644
--- a/scripts/example_hit_position.cxx
+++ b/scripts/example_hit_position.cxx
@@ -1,6 +1,11 @@
+R__LOAD_LIBRARY(libfmt.so)
+#include "fmt/core.h"
+R__LOAD_LIBRARY(libDDG4IO.so)
+
 #include "Math/Vector3D.h"
 #include "Math/Vector4D.h"
 #include "Math/VectorUtil.h"
+
 #include "TCanvas.h"
 #include "TLegend.h"
 #include "TMath.h"
@@ -18,12 +23,6 @@
 #include <algorithm>
 #include <iterator>
 
-// DD4hep
-// -----
-// In .rootlogon.C
-//  gSystem->Load("libDDDetectors");
-//  gSystem->Load("libDDG4IO");
-//  gInterpreter->AddIncludePath("/opt/software/local/include");
 #include "DD4hep/Detector.h"
 #include "DDG4/Geant4Data.h"
 #include "DDRec/CellIDPositionConverter.h"
diff --git a/scripts/example_hit_recon.cxx b/scripts/example_hit_recon.cxx
index 1fe1338..9798a15 100644
--- a/scripts/example_hit_recon.cxx
+++ b/scripts/example_hit_recon.cxx
@@ -42,7 +42,7 @@ void example_hit_recon(const char* fname = "gem_tracker_digi.root"){
 
   ROOT::RDataFrame d0(*t);
 
-  std::cout << t->GetBranch("GEMTrackerHits")->GetClassName() << std::endl;
+  //std::cout << t->GetBranch("GEMTrackerHits")->GetClassName() << std::endl;
   
   auto nhits = [] (const std::vector<dd4hep::sim::Geant4Tracker::Hit*>& hits){ return hits.size(); };
 
@@ -56,7 +56,6 @@ void example_hit_recon(const char* fname = "gem_tracker_digi.root"){
 
   auto recon_gem_hits = 
     [&](const std::vector<lcio2::TrackerRawDataData>&        digi_hits)
-    //, const std::vector<dd4hep::sim::Geant4Tracker::Hit*>& hits)
     {
       std::vector<lcio2::TrackerHitData> recon_hits;
       int i_hit = 0;
-- 
GitLab