LDMX Software
Public Member Functions | Private Attributes | List of all members
framework::config::Parameters Class Reference

Class encapsulating parameters for configuring a processor. More...

#include <Parameters.h>

Public Member Functions

 Parameters ()
 Constructor.
 
 ~Parameters ()
 Destructor.
 
void setParameters (std::map< std::string, std::any > parameters)
 Set the mapping of parameter names to value.
 
template<typename T >
void addParameter (const std::string &name, const T &value)
 Add a parameter to the parameter list.
 
bool exists (const std::string &name) const
 Check to see if a parameter exists.
 
template<typename T >
getParameter (const std::string &name) const
 Retrieve the parameter of the given name.
 
template<typename T >
getParameter (const std::string &name, const T &def) const
 Retrieve a parameter with a default specified.
 
std::vector< std::string > keys () const
 Get a list of the keys available.
 

Private Attributes

std::map< std::string, std::any > parameters_
 Parameters.
 

Detailed Description

Class encapsulating parameters for configuring a processor.

Definition at line 27 of file Parameters.h.

Constructor & Destructor Documentation

◆ Parameters()

framework::config::Parameters::Parameters ( )
inline

Constructor.

Definition at line 30 of file Parameters.h.

30{};

◆ ~Parameters()

framework::config::Parameters::~Parameters ( )
inline

Destructor.

Definition at line 33 of file Parameters.h.

33{};

Member Function Documentation

◆ addParameter()

template<typename T >
void framework::config::Parameters::addParameter ( const std::string &  name,
const T &  value 
)
inline

Add a parameter to the parameter list.

If the parameter already exists in the list, throw an exception.

Parameters
[in]nameName of the parameter.
[in]valueThe value of the parameter.
Exceptions
Exceptionif a parameter by that name already exist in the list.

Definition at line 55 of file Parameters.h.

55 {
56 if (exists(name)) {
57 EXCEPTION_RAISE("ParameterExist",
58 "The parameter " + name +
59 " already exists in the list of parameters.");
60 }
61
62 parameters_[name] = value;
63 }
bool exists(const std::string &name) const
Check to see if a parameter exists.
Definition Parameters.h:71
std::map< std::string, std::any > parameters_
Parameters.
Definition Parameters.h:138

References exists(), and parameters_.

Referenced by eventdisplay::Display::SetFile().

◆ exists()

bool framework::config::Parameters::exists ( const std::string &  name) const
inline

Check to see if a parameter exists.

Parameters
[in]namename of parameter to check
Returns
true if parameter exists in configuration set

Definition at line 71 of file Parameters.h.

71 {
72 return parameters_.find(name) != parameters_.end();
73 }

References parameters_.

Referenced by addParameter(), hcal::HcalGeometryProvider::getCondition(), getParameter(), and getParameter().

◆ getParameter() [1/2]

template<typename T >
T framework::config::Parameters::getParameter ( const std::string &  name) const
inline

Retrieve the parameter of the given name.

Exceptions
Exceptionif parameter of the given name isn't found
Exceptionif parameter is found but not of the input type
Parameters
Tthe data type to cast the parameter to.
[in]namethe name of the parameter value to retrieve.
Returns
The user specified parameter of type T.

Definition at line 89 of file Parameters.h.

89 {
90 // Check if the variable exists in the map. If it doesn't,
91 // raise an exception.
92 if (not exists(name)) {
93 EXCEPTION_RAISE(
94 "NonExistParam",
95 "Parameter '" + name + "' does not exist in list of parameters.");
96 }
97
98 try {
99 auto parameter = std::any_cast<T>(parameters_.at(name));
100 return parameter;
101 } catch (const std::bad_any_cast& e) {
102 EXCEPTION_RAISE("BadTypeParam",
103 "Parameter '" + name + "' of type '" +
104 parameters_.at(name).type().name() +
105 "' is being cast to incorrect type '" +
106 typeid(T).name() + "'.");
107 }
108 }

References exists(), and parameters_.

Referenced by simcore::APrimePhysics::APrimePhysics(), simcore::Simulator::beforeNewRun(), ecal::EcalDigiProducer::configure(), ecal::EcalRawDecoder::configure(), ecal::EcalRawEncoder::configure(), ecal::EcalRecProducer::configure(), ecal::EcalTrigPrimDigiProducer::configure(), trigger::NtupleWriter::configure(), trigger::PropagationMapWriter::configure(), recon::EcalPreselectionSkimmer::configure(), packing::FiberTrackerRawDecoder::configure(), packing::WRRawDecoder::configure(), hcal::HcalDigiProducer::configure(), hcal::HcalRawDecoder::configure(), hcal::HcalRecProducer::configure(), hcal::HcalTrigPrimDigiProducer::configure(), hcal::HcalDoubleEndRecProducer::configure(), hcal::HcalSingleEndRecProducer::configure(), dqm::HCalDQM::configure(), dqm::HcalGeometryVerifier::configure(), dqm::HcalInefficiencyAnalyzer::configure(), dqm::HCalRawDigi::configure(), dqm::PhotoNuclearDQM::configure(), dqm::ReSimVerifier::configure(), ecal::DNNEcalVetoProcessor::configure(), ecal::EcalClusterProducer::configure(), ecal::EcalVetoProcessor::configure(), hcal::HcalClusterProducer::configure(), hcal::HcalVetoProcessor::configure(), hcal::HcalWABVetoProcessor::configure(), recon::BeamElectronLocator::configure(), recon::ElectronCounter::configure(), recon::MyProcessor::configure(), recon::OverlayProducer::configure(), recon::SequentialTrigger::configure(), recon::TriggerProcessor::configure(), simcore::ReSimulator::configure(), simcore::SimulatorBase::configure(), tracking::dqm::TrackingRecoDQM::configure(), tracking::reco::CKFProcessor::configure(), tracking::reco::DigitizationProcessor::configure(), tracking::reco::GSFProcessor::configure(), tracking::reco::SeedFinderProcessor::configure(), tracking::reco::TruthSeedProcessor::configure(), tracking::reco::Vertexer::configure(), tracking::reco::VertexProcessor::configure(), trigscint::EventReadoutProducer::configure(), trigscint::QIEAnalyzer::configure(), trigscint::QualityFlagAnalyzer::configure(), trigscint::TestBeamClusterAnalyzer::configure(), trigscint::TestBeamHitAnalyzer::configure(), trigscint::TestBeamHitProducer::configure(), trigscint::TrigScintDigiProducer::configure(), trigscint::TrigScintQIEDigiProducer::configure(), trigscint::TrigScintRecHitProducer::configure(), trigscint::TruthHitProducer::configure(), dqm::EcalDigiVerifier::configure(), dqm::EcalMipTrackingFeatures::configure(), dqm::EcalShowerFeatures::configure(), dqm::EcalVetoResults::configure(), dqm::SimObjects::configure(), dqm::Trigger::configure(), recon::ParticleFlow::configure(), recon::PFEcalClusterProducer::configure(), recon::PFHcalClusterProducer::configure(), recon::PFTrackProducer::configure(), recon::PFTruthProducer::configure(), trigger::EcalTPSelector::configure(), trigger::TrigEcalClusterProducer::configure(), trigger::TrigEcalEnergySum::configure(), trigger::TrigElectronProducer::configure(), trigger::TrigHcalEnergySum::configure(), trigscint::TestBeamClusterProducer::configure(), hcal::HcalAlignPolarfires::configure(), hcal::HcalPedestalAnalyzer::configure(), packing::RawIO::configure(), packing::SingleSubsystemPacker::configure(), packing::SingleSubsystemUnpacker::configure(), trigscint::QIEDecoder::configure(), trigscint::QIEEncoder::configure(), trigscint::TrigScintClusterProducer::configure(), trigscint::TrigScintFirmwareHitProducer::configure(), trigscint::TrigScintFirmwareTracker::configure(), trigscint::TrigScintTrackProducer::configure(), dqm::TrigScintClusterDQM::configure(), dqm::TrigScintDQM::configure(), dqm::TrigScintHitDQM::configure(), dqm::TrigScintTrackDQM::configure(), simcore::APrimePhysics::ConstructParticle(), simcore::APrimePhysics::ConstructProcess(), simcore::GammaPhysics::ConstructProcess(), simcore::biasoperators::DarkBrem::DarkBrem(), biasing::utility::DecayChildrenKeeper::DecayChildrenKeeper(), biasing::DeepEcalProcessFilter::DeepEcalProcessFilter(), biasing::EcalDarkBremFilter::EcalDarkBremFilter(), ldmx::EcalGeometry::EcalGeometry(), ecal::EcalGeometryProvider::EcalGeometryProvider(), simcore::EcalSD::EcalSD(), simcore::biasoperators::ElectroNuclear::ElectroNuclear(), framework::EventFile::EventFile(), packing::rawdatafile::File::File(), simcore::biasoperators::GammaToMuPair::GammaToMuPair(), simcore::geo::GDMLParser::GDMLParser(), simcore::generators::GeneralParticleSource::GeneralParticleSource(), hcal::HcalGeometryProvider::getCondition(), ldmx::HcalGeometry::HcalGeometry(), hcal::HcalReconConditionsProvider::HcalReconConditionsProvider(), simcore::HcalSD::HcalSD(), ldmx::HgcrocEmulator::HgcrocEmulator(), simcore::RunManager::Initialize(), simcore::biasoperators::K0LongInelastic::K0LongInelastic(), simcore::generators::LHEPrimaryGenerator::LHEPrimaryGenerator(), biasing::MidShowerDiMuonBkgdFilter::MidShowerDiMuonBkgdFilter(), biasing::MidShowerNuclearBkgdFilter::MidShowerNuclearBkgdFilter(), simcore::generators::MultiParticleGunPrimaryGenerator::MultiParticleGunPrimaryGenerator(), simcore::biasoperators::NeutronInelastic::NeutronInelastic(), biasing::NonFiducialFilter::NonFiducialFilter(), biasing::utility::PartialEnergySorter::PartialEnergySorter(), simcore::generators::ParticleGun::ParticleGun(), simcore::biasoperators::PhotoNuclear::PhotoNuclear(), biasing::PhotoNuclearProductsFilter::PhotoNuclearProductsFilter(), biasing::PrimaryToEcalFilter::PrimaryToEcalFilter(), framework::Process::Process(), framework::RandomNumberSeedService::RandomNumberSeedService(), simcore::RunManager::RunManager(), simcore::ScoringPlaneSD::ScoringPlaneSD(), simcore::RunManager::setupPhysics(), biasing::utility::StepPrinter::StepPrinter(), biasing::TaggerHitFilter::TaggerHitFilter(), biasing::TaggerVetoFilter::TaggerVetoFilter(), biasing::TargetBremFilter::TargetBremFilter(), biasing::TargetDarkBremFilter::TargetDarkBremFilter(), biasing::TargetENProcessFilter::TargetENProcessFilter(), biasing::TargetProcessFilter::TargetProcessFilter(), simcore::TrackerSD::TrackerSD(), biasing::utility::TrackProcessFilter::TrackProcessFilter(), and simcore::TrigScintSD::TrigScintSD().

◆ getParameter() [2/2]

template<typename T >
T framework::config::Parameters::getParameter ( const std::string &  name,
const T &  def 
) const
inline

Retrieve a parameter with a default specified.

Return the input default if a parameter is not found in map.

Returns
the user parameter of type T

Definition at line 118 of file Parameters.h.

118 {
119 if (not exists(name)) return def;
120
121 // get here knowing that name exists in parameters_
122 return getParameter<T>(name);
123 }

References exists().

◆ keys()

std::vector< std::string > framework::config::Parameters::keys ( ) const
inline

Get a list of the keys available.

This may be helpful in debugging to make sure the parameters are spelled correctly.

Definition at line 130 of file Parameters.h.

130 {
131 std::vector<std::string> key;
132 for (auto i : parameters_) key.push_back(i.first);
133 return key;
134 }

References parameters_.

Referenced by hcal::HcalGeometryProvider::getCondition().

◆ setParameters()

void framework::config::Parameters::setParameters ( std::map< std::string, std::any >  parameters)
inline

Set the mapping of parameter names to value.

Parameters
[in,out]parametersmapping between parameter names and the corresponding value.

Definition at line 41 of file Parameters.h.

41 {
42 parameters_ = parameters;
43 }

References parameters_.

Referenced by framework::ConfigurePython::ConfigurePython(), eventdisplay::DetectorGeometry::DetectorGeometry(), and framework::getMembers().

Member Data Documentation

◆ parameters_

std::map<std::string, std::any> framework::config::Parameters::parameters_
private

Parameters.

Definition at line 138 of file Parameters.h.

Referenced by addParameter(), exists(), getParameter(), keys(), and setParameters().


The documentation for this class was generated from the following file: