Skip to content

Commit

Permalink
Add a m_collName to save the name of the collection
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcarcell committed Oct 3, 2023
1 parent 215e2f5 commit bb8dc34
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
21 changes: 10 additions & 11 deletions k4Reco/DDPlanarDigi/components/DDPlanarDigiProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,22 @@ DDPlanarDigiProcessor::initialize() {
<< det.name() << " in SurfaceManager ";
throw std::runtime_error(err.str());
}

(void)this->getProperty("SimTrackerHitCollectionName", m_collName);

return StatusCode::SUCCESS;
}


std::tuple<TrackerHitPlaneColl, Association>
DDPlanarDigiProcessor::operator()(const SimTrackerHitCollection& simTrackerHits) const {

// TODO: Set seed
// gslrng_set( rng, Global::EVENTSEEDER->getSeed(this) );
// debug() << "seed set to " << Global::EVENTSEEDER->getSeed(this) << endmsg;
auto seed = m_uidSvc->getUniqueID(1, 2, "hello");
// TODO: Set seed correctly
auto seed = m_uidSvc->getUniqueID(1, 2, m_collName);
m_engine.seed(seed);
// For rng calls, use the fact that drawing from a
// Gaussing with mean mu and variance sigma^2 is the same as drawing from
// a normal distribution and then multiplying by sigma and adding mu
auto dist = std::normal_distribution<double>(0, 1);

int nCreatedHits=0;
Expand All @@ -121,9 +125,7 @@ DDPlanarDigiProcessor::operator()(const SimTrackerHitCollection& simTrackerHits)
dd4hep::DDSegmentation::BitFieldCoder bitFieldCoder(cellIDEncodingString);

int nSimHits = simTrackerHits.size();
std::string collName;
(void)this->getProperty("SimTrackerHitCollectionName", collName);
debug() << "Processing collection " << collName << " with " << simTrackerHits.size() << " hits ... " << endmsg;
debug() << "Processing collection " << m_collName << " with " << simTrackerHits.size() << " hits ... " << endmsg;

for(const auto& hit : simTrackerHits) {
m_histograms[hitE]->Fill( hit.getEDep() * (dd4hep::GeV / dd4hep::keV) );
Expand Down Expand Up @@ -181,9 +183,6 @@ DDPlanarDigiProcessor::operator()(const SimTrackerHitCollection& simTrackerHits)
if (m_resTLayer.size() and m_resTLayer[0] > 0) {
float resT = m_resTLayer.size() > 1 ? m_resTLayer[layer] : m_resTLayer[0];

// For this and other rng calls, use the fact that drawing from a
// Gaussing with mean mu and variance sigma^2 is the same as drawing from
// a normal distribution and then multiplying by sigma and adding mu
double tSmear = resT > 0 ? dist(m_engine) * resT : 0;
m_histograms[hT]->Fill(resT > 0 ? tSmear / resT : 0);
m_histograms[diffT]->Fill(tSmear);
Expand Down Expand Up @@ -215,7 +214,7 @@ DDPlanarDigiProcessor::operator()(const SimTrackerHitCollection& simTrackerHits)
dd4hep::rec::Vector3D u = surf->u();
dd4hep::rec::Vector3D v = surf->v();

// get local coordinates on surface
// Get local coordinates on surface
dd4hep::rec::Vector2D lv = surf->globalToLocal(dd4hep::mm * oldPos);
double uL = lv[0] / dd4hep::mm;
double vL = lv[1] / dd4hep::mm;
Expand Down
4 changes: 3 additions & 1 deletion k4Reco/DDPlanarDigi/components/DDPlanarDigiProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,11 @@ struct DDPlanarDigiProcessor final
Gaudi::Property<std::string> m_geoSvcName{this, "GeoSvcName", "GeoSvc", "The name of the GeoSvc instance"};
Gaudi::Property<int> m_maxTries{this, "MaxTries", 10, "Maximum number of tries to find a valid surface for a hit"};

inline static thread_local std::mt19937 m_engine;
const dd4hep::rec::SurfaceMap* surfaceMap;
std::vector<TH1F*> m_histograms;
std::string m_collName;

inline static thread_local std::mt19937 m_engine;
SmartIF<IGeoSvc> m_geoSvc;
SmartIF<IUniqueIDGenSvc> m_uidSvc;

Expand Down

0 comments on commit bb8dc34

Please sign in to comment.