LDMX Software
ecal::EcalGeometryProvider Class Reference

Public Member Functions

 EcalGeometryProvider (const std::string &name, const std::string &tagname, const framework::config::Parameters &parameters, framework::Process &process)
 Class constructor.
 
virtual ~EcalGeometryProvider ()
 Destructor.
 
virtual std::pair< const framework::ConditionsObject *, framework::ConditionsIOV > getCondition (const ldmx::EventHeader &context)
 Provides access to the EcalGeometry or EcalTriggerGeometry.
 
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

std::vector< framework::config::Parameters > geometries_
 parameters for the various geometry versions we can support
 
std::string detector_geometry_
 Geometry as last used.
 
ldmx::EcalGeometry * ecal_geometry_
 

Additional Inherited Members

- Protected Member Functions inherited from framework::ConditionsObjectProvider
std::pair< const ConditionsObject *, ConditionsIOV > requestParentCondition (const std::string &name, const ldmx::EventHeader &context)
 Request another condition needed to construct this condition.
 
const Process & process () 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 16 of file EcalGeometryProvider.cxx.

Constructor & Destructor Documentation

◆ EcalGeometryProvider()

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

Class constructor.

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

Definition at line 71 of file EcalGeometryProvider.cxx.

76 ldmx::EcalGeometry::CONDITIONS_OBJECT_NAME, tagname, parameters,
77 process} {
79 parameters.get<std::vector<framework::config::Parameters>>("geometries");
80 ecal_geometry_ = 0;
81}
std::vector< framework::config::Parameters > geometries_
parameters for the various geometry versions we can support
Base class for all providers of conditions objects.
const Process & process() const
Get the process handle.
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:75

References geometries_, and framework::config::Parameters::get().

◆ ~EcalGeometryProvider()

ecal::EcalGeometryProvider::~EcalGeometryProvider ( )
virtual

Destructor.

Definition at line 83 of file EcalGeometryProvider.cxx.

83 {
84 if (ecal_geometry_) delete ecal_geometry_;
85 ecal_geometry_ = 0;
86}

Member Function Documentation

◆ getCondition()

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

Provides access to the EcalGeometry or EcalTriggerGeometry.

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 89 of file EcalGeometryProvider.cxx.

89 {
90 static const std::string keyname("detectors_valid");
91
92 if (!ecal_geometry_) {
93 // search through the subtrees
94 for (auto pver : geometries_) {
95 if (!pver.exists(keyname)) {
96 ldmx_log(warn) << "No parameter " << keyname
97 << " found one of the detector vesrsions.";
98 // log strange situation and continue
99 continue;
100 }
101
102 std::vector<std::string> dets_valid =
103 pver.get<std::vector<std::string>>(keyname);
104 for (auto detregex : dets_valid) {
105 std::string regex(detregex);
106 if (regex.empty()) continue; // no empty regex allowed
107 if (regex[0] != '^') regex.insert(0, 1, '^');
108 if (regex.back() != '$') regex += '$';
109 regex_t reg;
110
111 int rv =
112 regcomp(&reg, regex.c_str(), REG_EXTENDED | REG_ICASE | REG_NOSUB);
113 if (rv) {
114 char err[1024];
115 regerror(rv, &reg, err, 1024);
116 EXCEPTION_RAISE(
117 "GeometryException",
118 "Invalid detector regular expression : '" + regex + "' " + err);
119 }
120 int nmatch = regexec(&reg, detector_geometry_.c_str(), 0, 0, 0);
121 regfree(&reg);
122 if (!nmatch) {
123 ecal_geometry_ = new ldmx::EcalGeometry(pver);
124 break;
125 }
126 }
127 if (ecal_geometry_) break;
128 }
129 if (!ecal_geometry_) {
130 EXCEPTION_RAISE("GeometryException", "Unable to create EcalGeometry");
131 }
132 }
133
134 return std::make_pair(
135 ecal_geometry_,
136 framework::ConditionsIOV(context.getRun(), context.getRun(), true, true));
137}
std::string detector_geometry_
Geometry as last used.
Class which defines the run/event/type range for which a given condition is valid,...
Translation between real-space positions and cell IDs within the ECal.
int getRun() const
Return the run number.
Definition EventHeader.h:84

References detector_geometry_, geometries_, and ldmx::EventHeader::getRun().

◆ onNewRun()

virtual void ecal::EcalGeometryProvider::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 46 of file EcalGeometryProvider.cxx.

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

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

◆ releaseConditionsObject()

virtual void ecal::EcalGeometryProvider::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 44 of file EcalGeometryProvider.cxx.

44{}

Member Data Documentation

◆ detector_geometry_

std::string ecal::EcalGeometryProvider::detector_geometry_
private

Geometry as last used.

Definition at line 67 of file EcalGeometryProvider.cxx.

Referenced by getCondition(), and onNewRun().

◆ ecal_geometry_

ldmx::EcalGeometry* ecal::EcalGeometryProvider::ecal_geometry_
private

Definition at line 68 of file EcalGeometryProvider.cxx.

◆ geometries_

std::vector<framework::config::Parameters> ecal::EcalGeometryProvider::geometries_
private

parameters for the various geometry versions we can support

Definition at line 65 of file EcalGeometryProvider.cxx.

Referenced by EcalGeometryProvider(), and getCondition().


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