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

79 ldmx::EcalGeometry::CONDITIONS_OBJECT_NAME, tagname, parameters,
80 process} {
82 parameters.get<std::vector<framework::config::Parameters>>("geometries");
83 // optional explicit detector name (real data), empty: use the RunHeader
84 detector_geometry_ = parameters.get<std::string>("detector", "");
85 ecal_geometry_ = 0;
86}
std::string detector_geometry_
Geometry as last used.
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 detector_geometry_, geometries_, and framework::config::Parameters::get().

◆ ~EcalGeometryProvider()

ecal::EcalGeometryProvider::~EcalGeometryProvider ( )
virtual

Destructor.

Definition at line 88 of file EcalGeometryProvider.cxx.

88 {
89 if (ecal_geometry_) delete ecal_geometry_;
90 ecal_geometry_ = 0;
91}

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

94 {
95 static const std::string keyname("detectors_valid");
96
97 if (!ecal_geometry_) {
98 // search through the subtrees
99 for (auto pver : geometries_) {
100 if (!pver.exists(keyname)) {
101 ldmx_log(warn) << "No parameter " << keyname
102 << " found one of the detector vesrsions.";
103 // log strange situation and continue
104 continue;
105 }
106
107 std::vector<std::string> dets_valid =
108 pver.get<std::vector<std::string>>(keyname);
109 for (auto detregex : dets_valid) {
110 std::string regex(detregex);
111 if (regex.empty()) continue; // no empty regex allowed
112 if (regex[0] != '^') regex.insert(0, 1, '^');
113 if (regex.back() != '$') regex += '$';
114 regex_t reg;
115
116 int rv =
117 regcomp(&reg, regex.c_str(), REG_EXTENDED | REG_ICASE | REG_NOSUB);
118 if (rv) {
119 char err[1024];
120 regerror(rv, &reg, err, 1024);
121 EXCEPTION_RAISE(
122 "GeometryException",
123 "Invalid detector regular expression : '" + regex + "' " + err);
124 }
125 int nmatch = regexec(&reg, detector_geometry_.c_str(), 0, 0, 0);
126 regfree(&reg);
127 if (!nmatch) {
128 ecal_geometry_ = new ldmx::EcalGeometry(pver);
129 break;
130 }
131 }
132 if (ecal_geometry_) break;
133 }
134 if (!ecal_geometry_) {
135 EXCEPTION_RAISE("GeometryException", "Unable to create EcalGeometry");
136 }
137 }
138
139 return std::make_pair(
140 ecal_geometry_,
141 framework::ConditionsIOV(context.getRun(), context.getRun(), true, true));
142}
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 // the configured detector wins (real data RunHeaders carry no detector)
48 const std::string rh_det = rh.getDetectorName();
49 if (detector_geometry_.empty())
50 detector_geometry_ = rh_det;
51 else if (ecal_geometry_ != nullptr && !rh_det.empty() &&
52 detector_geometry_ != rh_det) {
53 EXCEPTION_RAISE(
54 "GeometryException",
55 "Attempting to run a single job with multiple geometries " +
56 detector_geometry_ + " and '" + rh_det + "'");
57 }
58 // make sure detector name has been set
59 if (detector_geometry_.empty())
60 EXCEPTION_RAISE("GeometryException",
61 "EcalGeometryProvider unable to get the name of the "
62 "detector from the RunHeader; set the 'detector' "
63 "parameter.");
64 }

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

Referenced by EcalGeometryProvider(), getCondition(), and onNewRun().

◆ ecal_geometry_

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

Definition at line 71 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 68 of file EcalGeometryProvider.cxx.

Referenced by EcalGeometryProvider(), and getCondition().


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