LDMX Software
hcal::test::HcalCheckReconstruction Class Reference

Checks. More...

Public Member Functions

 HcalCheckReconstruction (const std::string &name, framework::Process &p)
 
void configure (framework::config::Parameters &ps) override
 Callback for the EventProcessor to configure itself from the given set of parameters.
 
void onProcessStart () final override
 Callback for the EventProcessor to take any necessary action when the processing of events starts, such as creating histograms.
 
void analyze (const framework::Event &event) final 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 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

const bool SAVE = false
 
std::string hcal_fake_sim_hits_passname_
 
std::string hcal_rec_hits_passname_
 
std::string hcal_digis_passname_
 

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
 
NtupleManagerntuple_ {NtupleManager::getInstance()}
 Manager for any ntuples.
 
logging::logger the_log_
 The logger for this EventProcessor.
 

Detailed Description

Checks.

  • Energy of HcalRecHit matches SimCalorimeterHit EDep with the same ID
  • Position of HcalRecHit for back Hcal matches SimCalorimeterHit position along the bar with the same ID

Assumptions

  • Only one sim hit per event
  • Noise generation has been turned off

Definition at line 192 of file HcalDigiPipelineTest.cxx.

Constructor & Destructor Documentation

◆ HcalCheckReconstruction()

hcal::test::HcalCheckReconstruction::HcalCheckReconstruction ( const std::string & name,
framework::Process & p )
inline

Definition at line 203 of file HcalDigiPipelineTest.cxx.

204 : framework::Analyzer(name, p) {}
Base class for a module which does not produce a data product.

◆ ~HcalCheckReconstruction()

hcal::test::HcalCheckReconstruction::~HcalCheckReconstruction ( )
inline

Definition at line 205 of file HcalDigiPipelineTest.cxx.

205{}

Member Function Documentation

◆ analyze()

void hcal::test::HcalCheckReconstruction::analyze ( const framework::Event & event)
inlinefinaloverridevirtual

Process the event and make histograms or summaries.

Parameters
eventThe Event to analyze

Implements framework::Analyzer.

Definition at line 235 of file HcalDigiPipelineTest.cxx.

235 {
236 const auto sim_hits = event.getCollection<ldmx::SimCalorimeterHit>(
237 "HcalFakeSimHits", hcal_fake_sim_hits_passname_);
238
239 REQUIRE(sim_hits.size() == 1);
240
241 float truth_energy = sim_hits.at(0).getEdep();
242
243 if (SAVE) {
244 ntuple_.setVar<float>("SimEnergy", truth_energy);
245 ntuple_.setVar<float>("SimX", sim_hits.at(0).getPosition()[0]);
246 ntuple_.setVar<float>("SimY", sim_hits.at(0).getPosition()[1]);
247 ntuple_.setVar<float>("SimZ", sim_hits.at(0).getPosition()[2]);
248 ntuple_.setVar<float>("SimTime", sim_hits.at(0).getContrib(0).time_);
249 }
250
251 const auto daq_digis{event.getObject<ldmx::HgcrocDigiCollection>(
252 "HcalDigis", hcal_digis_passname_)};
253 auto daq_digi = daq_digis.getDigi(0);
254 bool is_in_adc_mode = daq_digi.isADC();
255
256 if (SAVE) {
257 ntuple_.setVar<int>("DaqDigi", daq_digi.soi().raw());
258 ntuple_.setVar<int>("DaqDigiIsADC", is_in_adc_mode);
259 ntuple_.setVar<int>("DaqDigiADC", daq_digi.soi().adcT());
260 ntuple_.setVar<int>("DaqDigiTOT", daq_digi.tot());
261 }
262
263 const auto rec_hits = event.getCollection<ldmx::HcalHit>(
264 "HcalRecHits", hcal_rec_hits_passname_);
265 CHECK(rec_hits.size() == 1);
266
267 auto hit = rec_hits.at(0);
268 ldmx::HcalID id(hit.getID());
269 CHECK_FALSE(hit.isNoise());
270 CHECK(id.raw() == sim_hits.at(0).getID());
271
272 if (SAVE) {
273 ntuple_.setVar<float>("RecX", hit.getXPos());
274 ntuple_.setVar<float>("RecY", hit.getYPos());
275 ntuple_.setVar<float>("RecZ", hit.getZPos());
276 ntuple_.setVar<float>("RecTime", hit.getTime());
277 ntuple_.setVar<float>("RecPE", hit.getPE());
278 ntuple_.setVar<float>("RecEnergy", hit.getEnergy());
279 }
280
281 // define target pe by using the settings at the top
282 double daq_pe{hit.getPE()};
283 CHECK_THAT(daq_pe, IsCloseEnough(truth_energy / PE_ENERGY, MAX_PE_ERROR_DAQ,
284 MAX_PE_PERCENT_ERROR_DAQ));
285
286 // std::cout << "rec energy " << hit.getEnergy() << " * approx sampl
287 // fraction " << hit.getEnergy()*sampling_fraction << " truth " <<
288 // truth_energy
289 // << std::endl;
290 // std::cout << "npes " << hit.getPE() << " approx PE " << int(truth_energy
291 // / PE_ENERGY) << std::endl;
292 /*
293 if (id.section() == 0) {
294 double truth_pos, rec_pos;
295 if ((id.layer() % 2) == 1) {
296 truth_pos = simHits.at(0).getPosition()[0];
297 rec_pos = hit.getXPos();
298 } else {
299 truth_pos = simHits.at(0).getPosition()[1];
300 rec_pos = hit.getYPos();
301 }
302 // std::cout << "rec pos_ " << rec_pos << " truth " << truth_pos <<
303 // std::endl;
304 // comment position check for now
305 // CHECK_THAT(rec_pos, isCloseEnough(truth_pos,
306 MAX_POSITION_ERROR_DAQ,
307 // MAX_POSITION_PERCENT_ERROR_DAQ));
308 }
309 */
310 return;
311 }
NtupleManager & ntuple_
Manager for any ntuples.
void setVar(const std::string &vname, const T &value)
Set the value of the variable named 'vname'.
Stores reconstructed hit information from the HCAL.
Definition HcalHit.h:24
Implements detector ids for HCal subdetector.
Definition HcalID.h:19
Represents a collection of the digi hits readout by an HGCROC.
Stores simulated calorimeter hit information.

References framework::EventProcessor::ntuple_, and framework::NtupleManager::setVar().

◆ configure()

void hcal::test::HcalCheckReconstruction::configure ( framework::config::Parameters & parameters)
inlineoverridevirtual

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 className equal to the EventProcessor class name.

For an example, look at MyProcessor.

Parameters
parametersParameters for configuration.

Reimplemented from framework::EventProcessor.

Definition at line 207 of file HcalDigiPipelineTest.cxx.

207 {
208 hcal_fake_sim_hits_passname_ =
209 ps.getParameter("hcal_fake_sim_hits_passname", "");
210 hcal_digis_passname_ = ps.getParameter("hcal_digis_passname", "");
211 hcal_rec_hits_passname_ = ps.getParameter("hcal_rec_hits_passname", "");
212 }

◆ onProcessStart()

void hcal::test::HcalCheckReconstruction::onProcessStart ( )
inlinefinaloverridevirtual

Callback for the EventProcessor to take any necessary action when the processing of events starts, such as creating histograms.

Reimplemented from framework::EventProcessor.

Definition at line 214 of file HcalDigiPipelineTest.cxx.

214 {
215 if (SAVE) {
217 ntuple_.create("HcalDigiTest");
218 ntuple_.addVar<float>("HcalDigiTest", "SimEnergy");
219 ntuple_.addVar<float>("HcalDigiTest", "RecEnergy");
220 ntuple_.addVar<float>("HcalDigiTest", "SimX");
221 ntuple_.addVar<float>("HcalDigiTest", "SimY");
222 ntuple_.addVar<float>("HcalDigiTest", "SimZ");
223 ntuple_.addVar<float>("HcalDigiTest", "SimTime");
224 ntuple_.addVar<float>("HcalDigiTest", "RecX");
225 ntuple_.addVar<float>("HcalDigiTest", "RecY");
226 ntuple_.addVar<float>("HcalDigiTest", "RecZ");
227 ntuple_.addVar<float>("HcalDigiTest", "RecTime");
228 ntuple_.addVar<int>("HcalDigiTest", "DaqDigi");
229 ntuple_.addVar<int>("HcalDigiTest", "DaqDigiIsADC");
230 ntuple_.addVar<int>("HcalDigiTest", "DaqDigiADC");
231 ntuple_.addVar<int>("HcalDigiTest", "DaqDigiTOT");
232 }
233 }
TDirectory * getHistoDirectory()
Access/create a directory in the histogram file for this event processor to create histograms and ana...
void addVar(const std::string &tname, const std::string &vname)
Add a variable of type VarType to the ROOT tree with name 'tname'.
void create(const std::string &tname)
Create a ROOT tree to hold the ntuple variables (ROOT leaves).

References framework::NtupleManager::addVar(), framework::NtupleManager::create(), framework::EventProcessor::getHistoDirectory(), and framework::EventProcessor::ntuple_.

Member Data Documentation

◆ hcal_digis_passname_

std::string hcal::test::HcalCheckReconstruction::hcal_digis_passname_
private

Definition at line 200 of file HcalDigiPipelineTest.cxx.

◆ hcal_fake_sim_hits_passname_

std::string hcal::test::HcalCheckReconstruction::hcal_fake_sim_hits_passname_
private

Definition at line 198 of file HcalDigiPipelineTest.cxx.

◆ hcal_rec_hits_passname_

std::string hcal::test::HcalCheckReconstruction::hcal_rec_hits_passname_
private

Definition at line 199 of file HcalDigiPipelineTest.cxx.

◆ SAVE

const bool hcal::test::HcalCheckReconstruction::SAVE = false
private

Definition at line 195 of file HcalDigiPipelineTest.cxx.


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