LDMX Software
trigscint::TrigScintGeometryProvider Class Reference

Public Member Functions

 TrigScintGeometryProvider (const std::string &name, const std::string &tagname, const framework::config::Parameters &parameters, framework::Process &process)
 
virtual std::pair< const framework::ConditionsObject *, framework::ConditionsIOV > getCondition (const ldmx::EventHeader &context)
 Pure virtual getCondition function.
 
virtual void releaseConditionsObject (const framework::ConditionsObject *co)
 Called by conditions system when done with a conditions object, appropriate point for cleanup.
 
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_
 
std::string detector_geometry_
 
ldmx::TrigScintGeometry * ts_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 TrigScintGeometryProvider.cxx.

Constructor & Destructor Documentation

◆ TrigScintGeometryProvider()

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

Definition at line 56 of file TrigScintGeometryProvider.cxx.

62 tagname, parameters, process},
63 params_{parameters} {
64 ts_geometry_ = 0;
65 // optional explicit detector name (real data); empty => use RunHeader
66 detector_geometry_ = parameters.get<std::string>("detector", "");
67}
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
static constexpr const char * CONDITIONS_OBJECT_NAME
Name this conditions object is registered under (must match the python provider field name).

◆ ~TrigScintGeometryProvider()

trigscint::TrigScintGeometryProvider::~TrigScintGeometryProvider ( )
virtual

Definition at line 69 of file TrigScintGeometryProvider.cxx.

69 {
70 if (ts_geometry_) delete ts_geometry_;
71 ts_geometry_ = 0;
72}

Member Function Documentation

◆ getCondition()

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

Pure virtual getCondition function.

Must be implemented by any Conditions providers.

Implements framework::ConditionsObjectProvider.

Definition at line 75 of file TrigScintGeometryProvider.cxx.

75 {
76 static const std::string keyname("detectors_valid");
77
78 if (!ts_geometry_) {
80 (params_.exists("trig_scint_geometry"))
82 "trig_scint_geometry"))
83 : (params_);
84
85 for (auto key : pts.keys()) {
86 framework::config::Parameters pver =
87 pts.get<framework::config::Parameters>(key);
88
89 if (!pver.exists(keyname)) {
90 ldmx_log(warn) << "No parameter " << keyname << " found in " << key;
91 continue;
92 }
93
94 std::vector<std::string> dets_valid =
95 pver.get<std::vector<std::string> >(keyname);
96 for (auto detregex : dets_valid) {
97 std::string regex(detregex);
98 if (regex.empty()) continue;
99 if (regex[0] != '^') regex.insert(0, 1, '^');
100 if (regex.back() != '$') regex += '$';
101 regex_t reg;
102
103 int rv =
104 regcomp(&reg, regex.c_str(), REG_EXTENDED | REG_ICASE | REG_NOSUB);
105 if (rv) {
106 char err[1024];
107 regerror(rv, &reg, err, 1024);
108 EXCEPTION_RAISE(
109 "GeometryException",
110 "Invalid detector regular expression : '" + regex + "' " + err);
111 }
112 int nmatch = regexec(&reg, detector_geometry_.c_str(), 0, 0, 0);
113 regfree(&reg);
114 if (!nmatch) {
115 ts_geometry_ = new ldmx::TrigScintGeometry(pver);
116 break;
117 }
118 }
119 if (ts_geometry_) break;
120 }
121 if (!ts_geometry_) {
122 EXCEPTION_RAISE("GeometryException",
123 "Unable to create TrigScintGeometry");
124 }
125 }
126
127 return std::make_pair(
128 ts_geometry_,
129 framework::ConditionsIOV(context.getRun(), context.getRun(), true, true));
130}
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:26
std::vector< std::string > keys() const
Get a list of the keys available.
Definition Parameters.h:131
bool exists(const std::string &name) const
Check to see if a parameter exists.
Definition Parameters.h:60
int getRun() const
Return the run number.
Definition EventHeader.h:84
Bar-center positions of the trigger-scintillator modules.

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

◆ onNewRun()

virtual void trigscint::TrigScintGeometryProvider::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 30 of file TrigScintGeometryProvider.cxx.

30 {
31 // Prefer the explicitly-configured detector (set via the python
32 // 'detector' parameter, robust for real data whose RunHeader may carry no
33 // detector name); otherwise fall back to the RunHeader (sim).
34 const std::string rh_det = rh.getDetectorName();
35 if (detector_geometry_.empty())
36 detector_geometry_ = rh_det;
37 else if (ts_geometry_ != nullptr && !rh_det.empty() &&
38 detector_geometry_ != rh_det) {
39 EXCEPTION_RAISE(
40 "GeometryException",
41 "Attempting to run a single job with multiple geometries " +
42 detector_geometry_ + " and '" + rh_det + "'");
43 }
44 if (detector_geometry_.empty())
45 EXCEPTION_RAISE("GeometryException",
46 "TrigScintGeometryProvider unable to get the detector "
47 "name from the RunHeader; set the 'detector' parameter.");
48 }

References ldmx::RunHeader::getDetectorName().

◆ releaseConditionsObject()

virtual void trigscint::TrigScintGeometryProvider::releaseConditionsObject ( const framework::ConditionsObject * co)
inlinevirtual

Called by conditions system when done with a conditions object, appropriate point for cleanup.

Note
Default behavior is to delete the object!

Reimplemented from framework::ConditionsObjectProvider.

Definition at line 28 of file TrigScintGeometryProvider.cxx.

28{}

Member Data Documentation

◆ detector_geometry_

std::string trigscint::TrigScintGeometryProvider::detector_geometry_
private

Definition at line 52 of file TrigScintGeometryProvider.cxx.

◆ params_

framework::config::Parameters trigscint::TrigScintGeometryProvider::params_
private

Definition at line 51 of file TrigScintGeometryProvider.cxx.

◆ ts_geometry_

ldmx::TrigScintGeometry* trigscint::TrigScintGeometryProvider::ts_geometry_
private

Definition at line 53 of file TrigScintGeometryProvider.cxx.


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