LDMX Software
hcal::HcalGeometryProvider Class Reference

Public Member Functions

 HcalGeometryProvider (const std::string &name, const std::string &tagname, const framework::config::Parameters &parameters, framework::Process &process)
 Class constructor.
 
virtual ~HcalGeometryProvider ()
 Destructor.
 
virtual std::pair< const framework::ConditionsObject *, framework::ConditionsIOVgetCondition (const ldmx::EventHeader &context)
 Provides access to the HcalGeometry.
 
virtual void releaseConditionsObject (const framework::ConditionsObject *co)
 Take no action on release, as the object is permanently owned by the Provider.
 
virtual void onNewRun (ldmx::RunHeader &rh)
 Callback for the ConditionsObjectProvider to take any necessary action when the processing of events starts for a given run.
 
- Public Member Functions inherited from framework::ConditionsObjectProvider
 DECLARE_FACTORY (ConditionsObjectProvider, std::shared_ptr< ConditionsObjectProvider >, const std::string &, const std::string &, const framework::config::Parameters &, Process &)
 declare that we have a factory for these types of classes
 
 ConditionsObjectProvider (const std::string &objname, const std::string &tagname, const framework::config::Parameters &parameters, Process &process)
 Class constructor.
 
virtual ~ConditionsObjectProvider ()=default
 Class destructor.
 
virtual void onProcessStart ()
 Callback for the ConditionsObjectProvider to take any necessary action when the processing of events starts.
 
virtual void onProcessEnd ()
 Callback for the ConditionsObjectProvider to take any necessary action when the processing of events finishes, such as closing database connections.
 
const std::string & getConditionObjectName () const
 Get the list of conditions objects available from this provider.
 
const std::string & getTagName () const
 Access the tag name.
 

Private Attributes

framework::config::Parameters params_
 Handle to the parameters, needed for future use during get condition.
 
std::string detector_geometry_
 Geometry as last used.
 
ldmx::HcalGeometryhcal_geometry_
 

Additional Inherited Members

- Protected Member Functions inherited from framework::ConditionsObjectProvider
std::pair< const ConditionsObject *, ConditionsIOVrequestParentCondition (const std::string &name, const ldmx::EventHeader &context)
 Request another condition needed to construct this condition.
 
const Processprocess () const
 Get the process handle.
 
- Protected Attributes inherited from framework::ConditionsObjectProvider
logging::logger the_log_
 The logger for this ConditionsObjectProvider.
 

Detailed Description

Definition at line 18 of file HcalGeometryProvider.cxx.

Constructor & Destructor Documentation

◆ HcalGeometryProvider()

hcal::HcalGeometryProvider::HcalGeometryProvider ( const std::string & name,
const std::string & tagname,
const framework::config::Parameters & parameters,
framework::Process & process )

Class constructor.

Parameters
parameters– uses the "HcalGeometry" section to configure the HcalGeometry

Definition at line 73 of file HcalGeometryProvider.cxx.

77 : framework::
78 ConditionsObjectProvider{ldmx::HcalGeometry::CONDITIONS_OBJECT_NAME,
79 tagname, parameters, process},
80 params_{parameters} {
81 hcal_geometry_ = 0;
82}
const Process & process() const
Get the process handle.
framework::config::Parameters params_
Handle to the parameters, needed for future use during get condition.
static constexpr const char * CONDITIONS_OBJECT_NAME
Conditions object: The name of the python configuration calling this class (Hcal/python/HcalGeometry....

◆ ~HcalGeometryProvider()

hcal::HcalGeometryProvider::~HcalGeometryProvider ( )
virtual

Destructor.

Definition at line 84 of file HcalGeometryProvider.cxx.

84 {
85 if (hcal_geometry_) delete hcal_geometry_;
86 hcal_geometry_ = 0;
87}

Member Function Documentation

◆ getCondition()

std::pair< const framework::ConditionsObject *, framework::ConditionsIOV > hcal::HcalGeometryProvider::getCondition ( const ldmx::EventHeader & context)
virtual

Provides access to the HcalGeometry.

Note
Currently, these are assumed to be valid for all time, but this behavior could be changed. Users should not cache the pointer between events

Implements framework::ConditionsObjectProvider.

Definition at line 90 of file HcalGeometryProvider.cxx.

90 {
91 static const std::string keyname("detectors_valid");
92
93 if (!hcal_geometry_) {
95 (params_.exists("HcalGeometry"))
96 ? (params_.get<framework::config::Parameters>("HcalGeometry"))
97 : (params_);
98
99 // search through the subtrees
100 for (auto key : phex.keys()) {
101 framework::config::Parameters pver =
102 phex.get<framework::config::Parameters>(key);
103
104 if (!pver.exists(keyname)) {
105 ldmx_log(warn) << "No parameter " << keyname << " found in " << key;
106 // log strange situation and continue
107 continue;
108 }
109
110 std::vector<std::string> dets_valid =
111 pver.get<std::vector<std::string> >(keyname);
112 for (auto detregex : dets_valid) {
113 std::string regex(detregex);
114 if (regex.empty()) continue; // no empty regex allowed
115 if (regex[0] != '^') regex.insert(0, 1, '^');
116 if (regex.back() != '$') regex += '$';
117 regex_t reg;
118
119 int rv =
120 regcomp(&reg, regex.c_str(), REG_EXTENDED | REG_ICASE | REG_NOSUB);
121 if (rv) {
122 char err[1024];
123 regerror(rv, &reg, err, 1024);
124 EXCEPTION_RAISE(
125 "GeometryException",
126 "Invalid detector regular expression : '" + regex + "' " + err);
127 }
128 int nmatch = regexec(&reg, detector_geometry_.c_str(), 0, 0, 0);
129 regfree(&reg);
130 if (!nmatch) {
131 hcal_geometry_ = new ldmx::HcalGeometry(pver);
132 break;
133 }
134 }
135 if (hcal_geometry_) break;
136 }
137 if (!hcal_geometry_) {
138 EXCEPTION_RAISE("GeometryException", "Unable to create HcalGeometry");
139 }
140 }
141
142 return std::make_pair(
143 hcal_geometry_,
144 framework::ConditionsIOV(context.getRun(), context.getRun(), true, true));
145}
Class which defines the run/event/type range for which a given condition is valid,...
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
std::vector< std::string > keys() const
Get a list of the keys available.
Definition Parameters.h:134
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78
bool exists(const std::string &name) const
Check to see if a parameter exists.
Definition Parameters.h:63
std::string detector_geometry_
Geometry as last used.
int getRun() const
Return the run number.
Definition EventHeader.h:84
Implementation of HCal strip readout.

References detector_geometry_, framework::config::Parameters::exists(), framework::config::Parameters::get(), ldmx::EventHeader::getRun(), framework::config::Parameters::keys(), and params_.

◆ onNewRun()

virtual void hcal::HcalGeometryProvider::onNewRun ( ldmx::RunHeader & )
inlinevirtual

Callback for the ConditionsObjectProvider to take any necessary action when the processing of events starts for a given run.

Reimplemented from framework::ConditionsObjectProvider.

Definition at line 48 of file HcalGeometryProvider.cxx.

48 {
49 if (detector_geometry_.empty())
50 detector_geometry_ = rh.getDetectorName();
51 else if (hcal_geometry_ != nullptr &&
52 detector_geometry_ != rh.getDetectorName()) {
53 EXCEPTION_RAISE(
54 "GeometryException",
55 "Attempting to run a single job with multiple geometries " +
56 detector_geometry_ + " and '" + rh.getDetectorName() + "'");
57 }
58 // make sure detector name has been set
59 if (detector_geometry_.empty())
60 EXCEPTION_RAISE("GeometryException",
61 "HcalGeometryProvider unable to get the name of the "
62 "detector from the RunHeader.");
63 }

References detector_geometry_, and ldmx::RunHeader::getDetectorName().

◆ releaseConditionsObject()

virtual void hcal::HcalGeometryProvider::releaseConditionsObject ( const framework::ConditionsObject * co)
inlinevirtual

Take no action on release, as the object is permanently owned by the Provider.

Reimplemented from framework::ConditionsObjectProvider.

Definition at line 46 of file HcalGeometryProvider.cxx.

46{}

Member Data Documentation

◆ detector_geometry_

std::string hcal::HcalGeometryProvider::detector_geometry_
private

Geometry as last used.

Definition at line 69 of file HcalGeometryProvider.cxx.

Referenced by getCondition(), and onNewRun().

◆ hcal_geometry_

ldmx::HcalGeometry* hcal::HcalGeometryProvider::hcal_geometry_
private

Definition at line 70 of file HcalGeometryProvider.cxx.

◆ params_

framework::config::Parameters hcal::HcalGeometryProvider::params_
private

Handle to the parameters, needed for future use during get condition.

Definition at line 67 of file HcalGeometryProvider.cxx.

Referenced by getCondition().


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