LDMX Software
ecal::test::EcalCheckEnergyReconstruction Class Reference

Checks. More...

Public Member Functions

 EcalCheckEnergyReconstruction (const std::string &name, framework::Process &p)
 
void configure (framework::config::Parameters &parameters) final 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

std::string ecal_simhits_passname_
 
std::string ecal_digis_passname_
 
std::string ecal_rechits_passname_
 
std::string ecal_trig_digis_passname_
 
bool check_trig_prim_
 

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.

  • Amplitude of EcalRecHit matches SimCalorimeterHit EDep with the same ID
  • Estimated energy at TP level matches sim energy

Assumptions

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

Definition at line 244 of file EcalDigiPipelineTest.cxx.

Constructor & Destructor Documentation

◆ EcalCheckEnergyReconstruction()

ecal::test::EcalCheckEnergyReconstruction::EcalCheckEnergyReconstruction ( const std::string & name,
framework::Process & p )
inline

Definition at line 253 of file EcalDigiPipelineTest.cxx.

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

◆ ~EcalCheckEnergyReconstruction()

ecal::test::EcalCheckEnergyReconstruction::~EcalCheckEnergyReconstruction ( )
inline

Definition at line 255 of file EcalDigiPipelineTest.cxx.

255{}

Member Function Documentation

◆ analyze()

void ecal::test::EcalCheckEnergyReconstruction::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 286 of file EcalDigiPipelineTest.cxx.

286 {
287 const auto sim_hits = event.getCollection<ldmx::SimCalorimeterHit>(
288 "EcalSimHits", ecal_simhits_passname_);
289
290 REQUIRE(sim_hits.size() == 1);
291
292 float truth_energy = sim_hits.at(0).getEdep();
293 ntuple_.setVar<float>("SimEnergy", truth_energy);
294
295 const auto daq_digis{event.getObject<ldmx::HgcrocDigiCollection>(
296 "EcalDigis", ecal_digis_passname_)};
297
298 if (daq_digis.getNumDigis() == 1) {
299 auto daq_digi = daq_digis.getDigi(0);
300 ntuple_.setVar<int>("DaqDigi", daq_digi.soi().raw());
301 bool is_in_adc_mode = daq_digi.isADC();
302 ntuple_.setVar<int>("DaqDigiIsADC", is_in_adc_mode);
303 ntuple_.setVar<int>("DaqDigiADC", daq_digi.soi().adcT());
304 ntuple_.setVar<int>("DaqDigiTOT", daq_digi.tot());
305
306 // arrival time of the hit at the chip, helpful when the failure
307 // depends on where in the readout window the pulse lands
308 INFO("sim hit arrival time = " << sim_hits.at(0).getContrib(0).time_
309 << " ns");
310 INFO("digi is " << (is_in_adc_mode ? "ADC" : "TOT") << " mode");
311
312 const auto rec_hits = event.getCollection<ldmx::EcalHit>(
313 "EcalRecHits", ecal_rechits_passname_);
314 CHECK(rec_hits.size() == 1);
315 // a hit that was read out but not reconstructed has nothing left
316 // for us to check, keep going so that all events are checked
317 if (rec_hits.size() != 1) return;
318
319 auto hit = rec_hits.at(0);
320 ldmx::EcalID id(hit.getID());
321 CHECK_FALSE(hit.isNoise());
322 CHECK(id.raw() == sim_hits.at(0).getID());
323
324 double daq_energy{hit.getAmplitude()};
325 CHECK_THAT(daq_energy, IsCloseEnough(truth_energy, MAX_ENERGY_ERROR_DAQ,
326 MAX_ENERGY_PERCENT_ERROR_DAQ));
327 ntuple_.setVar<float>("RecEnergy", hit.getAmplitude());
328
329 if (not check_trig_prim_) return;
330
331 const auto trig_digis{event.getObject<ldmx::HgcrocTrigDigiCollection>(
332 "ecalTrigDigis", ecal_trig_digis_passname_)};
333 CHECK(trig_digis.size() == 1);
334
335 auto trig_digi = trig_digis.at(0);
336 float tp_energy =
337 8 * trig_digi.linearPrimitive() * 320. / 1024 * MEV_PER_FC;
338
339 CHECK_THAT(tp_energy, IsCloseEnough(truth_energy, MAX_ENERGY_ERROR_TP,
340 MAX_ENERGY_PERCENT_ERROR_TP));
341 ntuple_.setVar<float>("TrigPrimEnergy", tp_energy);
342 ntuple_.setVar<int>("TrigPrimDigiEncoded", trig_digi.getPrimitive());
343 ntuple_.setVar<int>("TrigPrimDigiLinear", trig_digi.linearPrimitive());
344 }
345
346 return;
347 }
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 ECAL.
Definition EcalHit.h:19
Extension of DetectorID providing access to ECal layers and cell numbers in a hex grid.
Definition EcalID.h:20
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 ecal::test::EcalCheckEnergyReconstruction::configure ( framework::config::Parameters & parameters)
inlinefinaloverridevirtual

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 257 of file EcalDigiPipelineTest.cxx.

257 {
258 // the trigger primitives are an in-time, single-sample estimate,
259 // so they are not expected to see out-of-time hits
260 check_trig_prim_ = parameters.get<bool>("check_trig_prim", true);
261 ecal_simhits_passname_ =
262 parameters.get<std::string>("ecal_simhits_passname", "");
263 ecal_digis_passname_ =
264 parameters.get<std::string>("ecal_digis_passname", "");
265 ecal_rechits_passname_ =
266 parameters.get<std::string>("ecal_rechits_passname", "");
267 ecal_trig_digis_passname_ =
268 parameters.get<std::string>("ecal_trig_digis_passname", "");
269 }
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78

◆ onProcessStart()

void ecal::test::EcalCheckEnergyReconstruction::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 271 of file EcalDigiPipelineTest.cxx.

271 {
273 ntuple_.create("EcalDigiTest");
274 ntuple_.addVar<float>("EcalDigiTest", "SimEnergy");
275 ntuple_.addVar<float>("EcalDigiTest", "RecEnergy");
276 ntuple_.addVar<float>("EcalDigiTest", "TrigPrimEnergy");
277
278 ntuple_.addVar<int>("EcalDigiTest", "DaqDigi");
279 ntuple_.addVar<int>("EcalDigiTest", "DaqDigiIsADC");
280 ntuple_.addVar<int>("EcalDigiTest", "DaqDigiADC");
281 ntuple_.addVar<int>("EcalDigiTest", "DaqDigiTOT");
282 ntuple_.addVar<int>("EcalDigiTest", "TrigPrimDigiEncoded");
283 ntuple_.addVar<int>("EcalDigiTest", "TrigPrimDigiLinear");
284 }
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

◆ check_trig_prim_

bool ecal::test::EcalCheckEnergyReconstruction::check_trig_prim_
private

Definition at line 250 of file EcalDigiPipelineTest.cxx.

◆ ecal_digis_passname_

std::string ecal::test::EcalCheckEnergyReconstruction::ecal_digis_passname_
private

Definition at line 247 of file EcalDigiPipelineTest.cxx.

◆ ecal_rechits_passname_

std::string ecal::test::EcalCheckEnergyReconstruction::ecal_rechits_passname_
private

Definition at line 248 of file EcalDigiPipelineTest.cxx.

◆ ecal_simhits_passname_

std::string ecal::test::EcalCheckEnergyReconstruction::ecal_simhits_passname_
private

Definition at line 246 of file EcalDigiPipelineTest.cxx.

◆ ecal_trig_digis_passname_

std::string ecal::test::EcalCheckEnergyReconstruction::ecal_trig_digis_passname_
private

Definition at line 249 of file EcalDigiPipelineTest.cxx.


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