Skip to content
Snippets Groups Projects
Commit 40bec3a4 authored by Whitney Armstrong's avatar Whitney Armstrong
Browse files

modified: scripts/example_digi.cxx

	modified:   scripts/example_hit_position.cxx
	modified:   scripts/example_hit_recon.cxx
parent e5ca5d6d
No related branches found
No related tags found
No related merge requests found
......@@ -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");
......
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"
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment