LDMX Software
dqm::HcalGeometryVerifier Class Reference

Public Member Functions

 HcalGeometryVerifier (const std::string &name, framework::Process &process)
 
void configure (framework::config::Parameters &parameters) override
 Callback for the EventProcessor to configure itself from the given set of parameters.
 
std::array< int, 3 > determineIndices (const ldmx::HcalID id)
 
bool hitOk (const ldmx::HcalID id, const std::array< double, 3 > &position)
 
void analyze (const framework::Event &event) override
 Process the event and make histograms or summaries.
 
- Public Member Functions inherited from framework::Analyzer
 Analyzer (const std::string &name, Process &process)
 Class constructor.
 
virtual void process (Event &event) final
 Processing an event for an Analyzer is calling analyze.
 
virtual void beforeNewRun (ldmx::RunHeader &run_header) final
 Don't allow Analyzers to add parameters to the run header.
 
- Public Member Functions inherited from framework::EventProcessor
 DECLARE_FACTORY (EventProcessor, EventProcessor *, const std::string &, Process &)
 declare that we have a factory for this class
 
 EventProcessor (const std::string &name, Process &process)
 Class constructor.
 
virtual ~EventProcessor ()=default
 Class destructor.
 
virtual void onNewRun (const ldmx::RunHeader &run_header)
 Callback for the EventProcessor to take any necessary action when the run being processed changes.
 
virtual void onFileOpen (EventFile &event_file)
 Callback for the EventProcessor to take any necessary action when a new event input ROOT file is opened.
 
virtual void onFileClose (EventFile &event_file)
 Callback for the EventProcessor to take any necessary action when a event input ROOT file is closed.
 
virtual void onProcessStart ()
 Callback for the EventProcessor to take any necessary action when the processing of events starts, such as creating histograms.
 
virtual void onProcessEnd ()
 Callback for the EventProcessor to take any necessary action when the processing of events finishes, such as calculating job-summary quantities.
 
template<class T >
const T & getCondition (const std::string &condition_name)
 Access a conditions object for the current event.
 
TDirectory * getHistoDirectory ()
 Access/create a directory in the histogram file for this event processor to create histograms and analysis tuples.
 
void setStorageHint (framework::StorageControl::Hint hint)
 Mark the current event as having the given storage control hint from this module_.
 
void setStorageHint (framework::StorageControl::Hint hint, const std::string &purposeString)
 Mark the current event as having the given storage control hint from this module and the given purpose string.
 
int getLogFrequency () const
 Get the current logging frequency from the process.
 
int getRunNumber () const
 Get the run number from the process.
 
std::string getName () const
 Get the processor name.
 
void createHistograms (const std::vector< framework::config::Parameters > &histos)
 Internal function which is used to create histograms passed from the python configuration @parma histos vector of Parameters that configure histograms to create.
 

Private Attributes

std::string hcal_sim_hits_collection_ {"HcalSimHits"}
 
std::string hcal_rec_hits_collection_ {"HcalRecHits"}
 
std::string hcal_sim_hits_pass_name_ {""}
 
std::string hcal_rec_hits_pass_name_ {""}
 
double tolerance_ {}
 
bool stop_on_error_ {}
 

Additional Inherited Members

- Protected Member Functions inherited from framework::EventProcessor
void abortEvent ()
 Abort the event immediately.
 
- Protected Attributes inherited from framework::EventProcessor
HistogramPool histograms_
 helper object for making and filling histograms
 
NtupleManager & ntuple_ {NtupleManager::getInstance()}
 Manager for any ntuples.
 
logging::logger the_log_
 The logger for this EventProcessor.
 

Detailed Description

Definition at line 10 of file HcalGeometryVerifier.h.

Constructor & Destructor Documentation

◆ HcalGeometryVerifier()

dqm::HcalGeometryVerifier::HcalGeometryVerifier ( const std::string & name,
framework::Process & process )
inline

Definition at line 12 of file HcalGeometryVerifier.h.

Base class for a module which does not produce a data product.
virtual void process(Event &event) final
Processing an event for an Analyzer is calling analyze.

Member Function Documentation

◆ analyze()

void dqm::HcalGeometryVerifier::analyze ( const framework::Event & event)
overridevirtual

Process the event and make histograms or summaries.

Parameters
eventThe Event to analyze

Implements framework::Analyzer.

Definition at line 19 of file HcalGeometryVerfifier.cxx.

19 {
20 const auto hcal_sim_hits = event.getCollection<ldmx::SimCalorimeterHit>(
21 hcal_sim_hits_collection_, hcal_sim_hits_pass_name_);
22 const auto hcal_rec_hits = event.getCollection<ldmx::HcalHit>(
23 hcal_rec_hits_collection_, hcal_rec_hits_pass_name_);
24
25 for (const auto& hit : hcal_sim_hits) {
26 const ldmx::HcalID id{static_cast<unsigned int>(hit.getID())};
27 const auto position{hit.getPosition()};
28 auto ok{hitOk(id, {position[0], position[1], position[2]})};
29 histograms_.fill("passes_sim", ok);
30 switch (id.section()) {
31 case ldmx::HcalID::HcalSection::BACK:
32 histograms_.fill("passes_sim_back", ok);
33 break;
34 case ldmx::HcalID::HcalSection::TOP:
35 histograms_.fill("passes_sim_top", ok);
36 break;
37 case ldmx::HcalID::HcalSection::BOTTOM:
38 histograms_.fill("passes_sim_bottom", ok);
39 break;
40 case ldmx::HcalID::HcalSection::LEFT:
41 histograms_.fill("passes_sim_left", ok);
42 break;
43 case ldmx::HcalID::HcalSection::RIGHT:
44 histograms_.fill("passes_sim_right", ok);
45 break;
46 }
47 }
48 for (const auto& hit : hcal_rec_hits) {
49 const ldmx::HcalID id{static_cast<unsigned int>(hit.getID())};
50 auto ok{hitOk(id, {hit.getXPos(), hit.getYPos(), hit.getZPos()})};
51 histograms_.fill("passes_rec", ok);
52 switch (id.section()) {
53 case ldmx::HcalID::HcalSection::BACK:
54 histograms_.fill("passes_rec_back", ok);
55 break;
56 case ldmx::HcalID::HcalSection::TOP:
57 histograms_.fill("passes_rec_top", ok);
58 break;
59 case ldmx::HcalID::HcalSection::BOTTOM:
60 histograms_.fill("passes_rec_bottom", ok);
61 break;
62 case ldmx::HcalID::HcalSection::LEFT:
63 histograms_.fill("passes_rec_left", ok);
64 break;
65 case ldmx::HcalID::HcalSection::RIGHT:
66 histograms_.fill("passes_rec_right", ok);
67 break;
68 }
69 }
70
71} // Analyze
HistogramPool histograms_
helper object for making and filling histograms
void fill(const std::string &name, const T &val)
Fill a 1D histogram.
Stores reconstructed hit information from the HCAL.
Definition HcalHit.h:24
Implements detector ids for HCal subdetector.
Definition HcalID.h:19
Stores simulated calorimeter hit information.

References framework::HistogramPool::fill(), and framework::EventProcessor::histograms_.

◆ configure()

void dqm::HcalGeometryVerifier::configure ( framework::config::Parameters & parameters)
overridevirtual

Callback for the EventProcessor to configure itself from the given set of parameters.

The parameters a processor has access to are the member variables of the python class in the sequence that has class_name equal to the EventProcessor class name.

For an example, look at MyProcessor.

Parameters
parametersParameters for configuration.

Reimplemented from framework::EventProcessor.

Definition at line 10 of file HcalGeometryVerfifier.cxx.

11 {
12 hcal_sim_hits_collection_ = parameters.get<std::string>("sim_coll_name");
13 hcal_rec_hits_collection_ = parameters.get<std::string>("rec_coll_name");
14 hcal_sim_hits_pass_name_ = parameters.get<std::string>("sim_pass_name");
15 hcal_rec_hits_pass_name_ = parameters.get<std::string>("rec_pass_name");
16 stop_on_error_ = parameters.get<bool>("stop_on_error");
17 tolerance_ = parameters.get<double>("tolerance_");
18}
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:75

References framework::config::Parameters::get().

◆ determineIndices()

std::array< int, 3 > dqm::HcalGeometryVerifier::determineIndices ( const ldmx::HcalID id)

Definition at line 131 of file HcalGeometryVerfifier.cxx.

132 {
133 const auto& geometry = getCondition<ldmx::HcalGeometry>(
135 const auto orientation{geometry.getScintillatorOrientation(id)};
136 const auto is_lr{id.section() == ldmx::HcalID::HcalSection::LEFT ||
137 id.section() == ldmx::HcalID::HcalSection::RIGHT};
138
139 int index_along{};
140 int index_across{};
141 int index_through{};
142 if (id.section() == ldmx::HcalID::HcalSection::BACK) {
143 index_through = 2; // z
144 if (orientation ==
145 ldmx::HcalGeometry::ScintillatorOrientation::horizontal) {
146 index_along = 0; // x
147 index_across = 1; // y
148 } else {
149 index_across = 0; // x
150 index_along = 1; // y
151 }
152 } else if (geometry.hasSide3DReadout()) {
153 switch (orientation) {
154 case ldmx::HcalGeometry::ScintillatorOrientation::horizontal:
155 index_across = 2; // z
156 index_along = 0; // x
157 index_through = 1; // y
158 // Horizontal bar in side hcal -> x length, z width, y thick
159 break;
160 case ldmx::HcalGeometry::ScintillatorOrientation::vertical:
161 // Vertical bar in side hcal -> y length, z width, x thick
162 index_across = 2; // z
163 index_along = 1; // y
164 index_through = 0; // x
165 break;
166 case ldmx::HcalGeometry::ScintillatorOrientation::depth:
167 index_along = 2; // z
168 if (is_lr) {
169 // Depth bar in side hcal (LR) -> z length, x thick, y width
170 index_through = 0; // x
171 index_across = 1; // y
172 } else {
173 // Depth bar in side hcal (TB) -> z length, y thick, x width
174 index_through = 1; // y
175 index_across = 0; // x
176 }
177 break;
178 }
179 } else {
180 // v12 Side hcal
181 index_across = 2; // z
182 if (orientation ==
183 ldmx::HcalGeometry::ScintillatorOrientation::horizontal) {
184 index_along = 0; // x
185 index_through = 1; // y
186 } else {
187 index_along = 1; // y
188 index_through = 0; // x
189 }
190 }
191 return {index_along, index_across, index_through};
192}
const T & getCondition(const std::string &condition_name)
Access a conditions object for the current event.
static constexpr const char * CONDITIONS_OBJECT_NAME
Conditions object: The name of the python configuration calling this class (Hcal/python/HcalGeometry....

◆ hitOk()

bool dqm::HcalGeometryVerifier::hitOk ( const ldmx::HcalID id,
const std::array< double, 3 > & position )

Definition at line 72 of file HcalGeometryVerfifier.cxx.

73 {
74 const auto& geometry = getCondition<ldmx::HcalGeometry>(
76 auto [index_along, index_across, index_through]{determineIndices(id)};
77 const auto center_vec = geometry.getStripCenterPosition(id);
78 const std::array<double, 3> center{center_vec.X(), center_vec.Y(),
79 center_vec.Z()};
80 const auto length{geometry.getScintillatorLength(id)};
81 bool outside_bounds_along{
82 std::abs(position[index_along] - center[index_along]) >
83 length / 2 + tolerance_};
84
85 const auto width{geometry.getScintillatorWidth()};
86 bool outside_bounds_across{
87 std::abs(position[index_across] - center[index_across]) >
88 width / 2 + tolerance_};
89
90 const auto thickness{geometry.getScintillatorThickness()};
91 bool outside_bounds_through{
92 std::abs(position[index_through] - center[index_through]) >
93 thickness / 2 + tolerance_};
94
95 if (outside_bounds_along || outside_bounds_across || outside_bounds_through) {
96 std::stringstream ss;
97 if (tolerance_ < 1) {
98 // Assume tolerance_ is of form 1e-N
99 //
100 // Set precision so it will be clear if it is a floating point precision
101 // issue or a problem
102 ss.precision(-std::log10(tolerance_) + 1);
103 }
104 ss << std::boolalpha;
105 double x{position[0]};
106 double y{position[1]};
107 double z{position[2]};
108 ss << id << " has hit position at (" << x << ", " << y << ", " << z
109 << ")\nwhich is not within the bounds of the Hcal strip center ("
110 << center[0] << ", " << center[1] << ", " << center[2]
111 << ") with tolerance_ " << tolerance_ << std::endl;
112 ss << "Position along the bar: " << position[index_along] << " outside "
113 << center[index_along] << " +- " << length / 2 << "? "
114 << outside_bounds_along << std::endl;
115 ss << "Position across the bar: " << position[index_across] << " outside "
116 << center[index_across] << " +- " << width / 2 << "? "
117 << outside_bounds_across << std::endl;
118 ss << "Position through the bar: " << position[index_through] << " outside "
119 << center[index_through] << " +- " << thickness / 2 << "? "
120 << outside_bounds_through << std::endl;
121
122 if (stop_on_error_) {
123 EXCEPTION_RAISE("InvalidPosition", ss.str());
124 } else {
125 ldmx_log(warn) << ss.str();
126 }
127 return false;
128 }
129 return true;
130}

Member Data Documentation

◆ hcal_rec_hits_collection_

std::string dqm::HcalGeometryVerifier::hcal_rec_hits_collection_ {"HcalRecHits"}
private

Definition at line 40 of file HcalGeometryVerifier.h.

40{"HcalRecHits"};

◆ hcal_rec_hits_pass_name_

std::string dqm::HcalGeometryVerifier::hcal_rec_hits_pass_name_ {""}
private

Definition at line 42 of file HcalGeometryVerifier.h.

42{""};

◆ hcal_sim_hits_collection_

std::string dqm::HcalGeometryVerifier::hcal_sim_hits_collection_ {"HcalSimHits"}
private

Definition at line 39 of file HcalGeometryVerifier.h.

39{"HcalSimHits"};

◆ hcal_sim_hits_pass_name_

std::string dqm::HcalGeometryVerifier::hcal_sim_hits_pass_name_ {""}
private

Definition at line 41 of file HcalGeometryVerifier.h.

41{""};

◆ stop_on_error_

bool dqm::HcalGeometryVerifier::stop_on_error_ {}
private

Definition at line 47 of file HcalGeometryVerifier.h.

47{};

◆ tolerance_

double dqm::HcalGeometryVerifier::tolerance_ {}
private

Definition at line 46 of file HcalGeometryVerifier.h.

46{};

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