Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ find_package(Gaudi)
find_package(ROOT COMPONENTS RIO Tree)
find_package(EDM4HEP)
find_package(k4FWCore)
find_package(DD4hep)

include(cmake/Key4hepConfig.cmake)

Expand Down
1 change: 1 addition & 0 deletions GaudiTutorial/MoliereRadiusFunctional/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ gaudi_add_module(MoliereRadiusFunctionalPlugins
LINK Gaudi::GaudiKernel
k4FWCore::k4FWCore
EDM4HEP::edm4hep
DD4hep::DDCore
)

install(TARGETS MoliereRadiusFunctionalPlugins
Expand Down
1 change: 1 addition & 0 deletions GaudiTutorial/RandomNoiseDigitizer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ gaudi_add_module(RandomNoiseDigitizerPlugins
LINK Gaudi::GaudiKernel
k4FWCore::k4FWCore
EDM4HEP::edm4hep
DD4hep::DDCore
)

install(TARGETS RandomNoiseDigitizerPlugins
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
InputCaloSimHitCollection=["simplecaloRO"],
OutputCaloDigiHitCollection=["CaloDigiHits"],
uidSvcName="uidSvc",
NoiseMean=1e-6,
NoiseWidth=1e-7,
NoiseMean=1e-3,
NoiseWidth=1e-4,
OutputLevel=INFO
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
#include "edm4hep/CalorimeterHitCollection.h"
#include "edm4hep/SimCalorimeterHitCollection.h"

// dd4hep
#include <DD4hep/DD4hepUnits.h>

// STL
#include <random>
#include <string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
#include "edm4hep/CalorimeterHitCollection.h"
#include "edm4hep/SimCalorimeterHitCollection.h"

// dd4hep
#include <DD4hep/DD4hepUnits.h>

// STL
#include <random>
#include <string>
Expand Down Expand Up @@ -75,17 +78,21 @@ struct RandomNoiseDigitizerSolution final
random_engine.seed(engine_seed);

// Create the random distributions for smearing the hit energy
std::normal_distribution<double> gaussian_noise{m_noise_mean.value(), m_noise_width.value()};
// By multiplying with dd4hep::MeV, we convert the input to dd4hep default units
std::normal_distribution<double> gaussian_noise{m_noise_mean.value() * dd4hep::MeV,
m_noise_width.value() * dd4hep::MeV};

// Loop over the input hits
for (const auto& hit : InputCaloSimHitCollection) {
auto digihit = CaloDigiHits.create();

// will be in dd4hep default units, since gaussian_noise is in default units
double noise = gaussian_noise(random_engine);

digihit.setCellID(hit.getCellID());
digihit.setEnergy(hit.getEnergy() + noise);
digihit.setEnergyError(m_noise_width);
// hit.getEnergy() is already in GeV (see yaml file), so only cast noise to GeV
digihit.setEnergy(hit.getEnergy() + noise / dd4hep::GeV);
digihit.setEnergyError(m_noise_width / dd4hep::GeV); // set energy error to the width of the noise
digihit.setPosition(hit.getPosition());
}

Expand All @@ -99,8 +106,8 @@ struct RandomNoiseDigitizerSolution final
this, "uidSvcName", "UniqueIDGenSvc",
"The name of the service for generating unique, but reproducable random seeds"};

Gaudi::Property<double> m_noise_mean{this, "NoiseMean", 0.0, "Mean of the Gaussian noise to be added"};
Gaudi::Property<double> m_noise_width{this, "NoiseWidth", 0.1, "Width of the Gaussian noise to be added"};
Gaudi::Property<double> m_noise_mean{this, "NoiseMean", 1e-3, "Mean of the Gaussian noise to be added in MeV"};
Gaudi::Property<double> m_noise_width{this, "NoiseWidth", 1e-4, "Width of the Gaussian noise to be added in MeV"};
};

DECLARE_COMPONENT(RandomNoiseDigitizerSolution)
Loading