LDMX Software
Public Member Functions | Private Attributes | List of all members
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
 ConditionsObjectProvider (const std::string &objname, const std::string &tagname, const framework::config::Parameters &parameters, Process &process)
 Class constructor.
 
virtual ~ConditionsObjectProvider ()
 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 detectorGeometry_
 Geometry as last used.
 
ldmx::HcalGeometryhcalGeometry_
 

Additional Inherited Members

- Static Public Member Functions inherited from framework::ConditionsObjectProvider
static void declare (const std::string &classname, ConditionsObjectProviderMaker *)
 Internal function which is part of the PluginFactory machinery.
 
- Static Public Attributes inherited from framework::ConditionsObjectProvider
static const int CLASSTYPE {10}
 Constant used to types by the PluginFactory.
 
- 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 theLog_
 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 hcalGeometry_ = 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 (hcalGeometry_) delete hcalGeometry_;
86 hcalGeometry_ = 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 (!hcalGeometry_) {
95 (params_.exists("HcalGeometry"))
97 "HcalGeometry"))
98 : (params_);
99
100 // search through the subtrees
101 for (auto key : phex.keys()) {
104
105 if (!pver.exists(KEYNAME)) {
106 ldmx_log(warn) << "No parameter " << KEYNAME << " found in " << key;
107 // log strange situation and continue
108 continue;
109 }
110
111 std::vector<std::string> dets_valid =
112 pver.getParameter<std::vector<std::string> >(KEYNAME);
113 for (auto detregex : dets_valid) {
114 std::string regex(detregex);
115 if (regex.empty()) continue; // no empty regex allowed
116 if (regex[0] != '^') regex.insert(0, 1, '^');
117 if (regex.back() != '$') regex += '$';
118 regex_t reg;
119
120 int rv =
121 regcomp(&reg, regex.c_str(), REG_EXTENDED | REG_ICASE | REG_NOSUB);
122 if (rv) {
123 char err[1024];
124 regerror(rv, &reg, err, 1024);
125 EXCEPTION_RAISE(
126 "GeometryException",
127 "Invalid detector regular expression : '" + regex + "' " + err);
128 }
129 int nmatch = regexec(&reg, detectorGeometry_.c_str(), 0, 0, 0);
130 regfree(&reg);
131 if (!nmatch) {
132 hcalGeometry_ = new ldmx::HcalGeometry(pver);
133 break;
134 }
135 }
136 if (hcalGeometry_) break;
137 }
138 if (!hcalGeometry_) {
139 EXCEPTION_RAISE("GeometryException", "Unable to create HcalGeometry");
140 }
141 }
142
143 return std::make_pair(
144 hcalGeometry_,
145 framework::ConditionsIOV(context.getRun(), context.getRun(), true, true));
146}
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:27
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:89
bool exists(const std::string &name) const
Check to see if a parameter exists.
Definition Parameters.h:71
std::string detectorGeometry_
Geometry as last used.
int getRun() const
Return the run number.
Definition EventHeader.h:84
Implementation of HCal strip readout.

References detectorGeometry_, framework::config::Parameters::exists(), framework::config::Parameters::getParameter(), 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 (detectorGeometry_.empty())
50 detectorGeometry_ = rh.getDetectorName();
51 else if (hcalGeometry_ != nullptr &&
52 detectorGeometry_ != rh.getDetectorName()) {
53 EXCEPTION_RAISE(
54 "GeometryException",
55 "Attempting to run a single job with multiple geometries " +
56 detectorGeometry_ + " and '" + rh.getDetectorName() + "'");
57 }
58 // make sure detector name has been set
59 if (detectorGeometry_.empty())
60 EXCEPTION_RAISE("GeometryException",
61 "HcalGeometryProvider unable to get the name of the "
62 "detector from the RunHeader.");
63 }

References detectorGeometry_, 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

◆ detectorGeometry_

std::string hcal::HcalGeometryProvider::detectorGeometry_
private

Geometry as last used.

Definition at line 69 of file HcalGeometryProvider.cxx.

Referenced by getCondition(), and onNewRun().

◆ hcalGeometry_

ldmx::HcalGeometry* hcal::HcalGeometryProvider::hcalGeometry_
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: