LDMX Software
Public Member Functions | Private Attributes | List of all members
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::ConditionsIOVgetCondition (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
 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

std::vector< framework::config::Parametersgeometries_
 parameters for the various geometry versions we can support
 
std::string detectorGeometry_
 Geometry as last used.
 
ldmx::EcalGeometryecalGeometry_
 

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

77 ldmx::EcalGeometry::CONDITIONS_OBJECT_NAME, tagname, parameters,
78 process} {
80 parameters.getParameter<std::vector<framework::config::Parameters>>(
81 "geometries");
82 ecalGeometry_ = 0;
83}
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.
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:89

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

◆ ~EcalGeometryProvider()

ecal::EcalGeometryProvider::~EcalGeometryProvider ( )
virtual

Destructor.

Definition at line 85 of file EcalGeometryProvider.cxx.

85 {
86 if (ecalGeometry_) delete ecalGeometry_;
87 ecalGeometry_ = 0;
88}

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

91 {
92 static const std::string KEYNAME("detectors_valid");
93
94 if (!ecalGeometry_) {
95 // search through the subtrees
96 for (auto pver : geometries_) {
97 if (!pver.exists(KEYNAME)) {
98 ldmx_log(warn) << "No parameter " << KEYNAME
99 << " found one of the detector vesrsions.";
100 // log strange situation and continue
101 continue;
102 }
103
104 std::vector<std::string> dets_valid =
105 pver.getParameter<std::vector<std::string>>(KEYNAME);
106 for (auto detregex : dets_valid) {
107 std::string regex(detregex);
108 if (regex.empty()) continue; // no empty regex allowed
109 if (regex[0] != '^') regex.insert(0, 1, '^');
110 if (regex.back() != '$') regex += '$';
111 regex_t reg;
112
113 int rv =
114 regcomp(&reg, regex.c_str(), REG_EXTENDED | REG_ICASE | REG_NOSUB);
115 if (rv) {
116 char err[1024];
117 regerror(rv, &reg, err, 1024);
118 EXCEPTION_RAISE(
119 "GeometryException",
120 "Invalid detector regular expression : '" + regex + "' " + err);
121 }
122 int nmatch = regexec(&reg, detectorGeometry_.c_str(), 0, 0, 0);
123 regfree(&reg);
124 if (!nmatch) {
125 ecalGeometry_ = new ldmx::EcalGeometry(pver);
126 break;
127 }
128 }
129 if (ecalGeometry_) break;
130 }
131 if (!ecalGeometry_) {
132 EXCEPTION_RAISE("GeometryException", "Unable to create EcalGeometry");
133 }
134 }
135
136 return std::make_pair(
137 ecalGeometry_,
138 framework::ConditionsIOV(context.getRun(), context.getRun(), true, true));
139}
std::string detectorGeometry_
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 detectorGeometry_, 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 47 of file EcalGeometryProvider.cxx.

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

References detectorGeometry_, 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 45 of file EcalGeometryProvider.cxx.

45{}

Member Data Documentation

◆ detectorGeometry_

std::string ecal::EcalGeometryProvider::detectorGeometry_
private

Geometry as last used.

Definition at line 68 of file EcalGeometryProvider.cxx.

Referenced by getCondition(), and onNewRun().

◆ ecalGeometry_

ldmx::EcalGeometry* ecal::EcalGeometryProvider::ecalGeometry_
private

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

Referenced by EcalGeometryProvider(), and getCondition().


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