LDMX Software
Public Member Functions | Private Attributes | List of all members
hcal::test::HcalCheckReconstruction Class Reference

Checks. More...

Public Member Functions

 HcalCheckReconstruction (const std::string &name, framework::Process &p)
 
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.
 
- Public Member Functions inherited from framework::EventProcessor
 EventProcessor (const std::string &name, Process &process)
 Class constructor.
 
virtual ~EventProcessor ()
 Class destructor.
 
virtual void configure (framework::config::Parameters &parameters)
 Callback for the EventProcessor to configure itself from the given set of parameters.
 
virtual void onNewRun (const ldmx::RunHeader &runHeader)
 Callback for the EventProcessor to take any necessary action when the run being processed changes.
 
virtual void onFileOpen (EventFile &eventFile)
 Callback for the EventProcessor to take any necessary action when a new event input ROOT file is opened.
 
virtual void onFileClose (EventFile &eventFile)
 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
 

Additional Inherited Members

- Static Public Member Functions inherited from framework::EventProcessor
static void declare (const std::string &classname, int classtype, EventProcessorMaker *)
 Internal function which is part of the PluginFactory machinery.
 
- Static Public Attributes inherited from framework::Analyzer
static const int CLASSTYPE {2}
 Constant used to track EventProcessor types by the PluginFactory.
 
- Protected Member Functions inherited from framework::EventProcessor
void abortEvent ()
 Abort the event immediately.
 
- Protected Attributes inherited from framework::EventProcessor
HistogramHelper histograms_
 Interface class for making and filling histograms.
 
NtupleManagerntuple_ {NtupleManager::getInstance()}
 Manager for any ntuples.
 
logging::logger theLog_
 The logger for this EventProcessor.
 

Detailed Description

Checks.

Assumptions

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 198 of file HcalDigiPipelineTest.cxx.

199 : 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 200 of file HcalDigiPipelineTest.cxx.

200{}

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 223 of file HcalDigiPipelineTest.cxx.

223 {
224 const auto simHits =
225 event.getCollection<ldmx::SimCalorimeterHit>("HcalFakeSimHits");
226
227 REQUIRE(simHits.size() == 1);
228
229 float truth_energy = simHits.at(0).getEdep();
230
231 if (save_) {
232 ntuple_.setVar<float>("SimEnergy", truth_energy);
233 ntuple_.setVar<float>("SimX", simHits.at(0).getPosition()[0]);
234 ntuple_.setVar<float>("SimY", simHits.at(0).getPosition()[1]);
235 ntuple_.setVar<float>("SimZ", simHits.at(0).getPosition()[2]);
236 ntuple_.setVar<float>("SimTime", simHits.at(0).getContrib(0).time);
237 }
238
239 const auto daqDigis{
240 event.getObject<ldmx::HgcrocDigiCollection>("HcalDigis")};
241 auto daqDigi = daqDigis.getDigi(0);
242 bool is_in_adc_mode = daqDigi.isADC();
243
244 if (save_) {
245 ntuple_.setVar<int>("DaqDigi", daqDigi.soi().raw());
246 ntuple_.setVar<int>("DaqDigiIsADC", is_in_adc_mode);
247 ntuple_.setVar<int>("DaqDigiADC", daqDigi.soi().adc_t());
248 ntuple_.setVar<int>("DaqDigiTOT", daqDigi.tot());
249 }
250
251 const auto recHits = event.getCollection<ldmx::HcalHit>("HcalRecHits");
252 CHECK(recHits.size() == 1);
253
254 auto hit = recHits.at(0);
255 ldmx::HcalID id(hit.getID());
256 CHECK_FALSE(hit.isNoise());
257 CHECK(id.raw() == simHits.at(0).getID());
258
259 if (save_) {
260 ntuple_.setVar<float>("RecX", hit.getXPos());
261 ntuple_.setVar<float>("RecY", hit.getYPos());
262 ntuple_.setVar<float>("RecZ", hit.getZPos());
263 ntuple_.setVar<float>("RecTime", hit.getTime());
264 ntuple_.setVar<float>("RecPE", hit.getPE());
265 ntuple_.setVar<float>("RecEnergy", hit.getEnergy());
266 }
267
268 // define target pe by using the settings at the top
269 double daq_pe{hit.getPE()};
270 CHECK_THAT(daq_pe, isCloseEnough(truth_energy / PE_ENERGY, MAX_PE_ERROR_DAQ,
271 MAX_PE_PERCENT_ERROR_DAQ));
272
273 // std::cout << "rec energy " << hit.getEnergy() << " * approx sampl
274 // fraction " << hit.getEnergy()*sampling_fraction << " truth " <<
275 // truth_energy
276 // << std::endl;
277 // std::cout << "npes " << hit.getPE() << " approx PE " << int(truth_energy
278 // / PE_ENERGY) << std::endl;
279 /*
280 if (id.section() == 0) {
281 double truth_pos, rec_pos;
282 if ((id.layer() % 2) == 1) {
283 truth_pos = simHits.at(0).getPosition()[0];
284 rec_pos = hit.getXPos();
285 } else {
286 truth_pos = simHits.at(0).getPosition()[1];
287 rec_pos = hit.getYPos();
288 }
289 // std::cout << "rec pos " << rec_pos << " truth " << truth_pos <<
290 // std::endl;
291 // comment position check for now
292 // CHECK_THAT(rec_pos, isCloseEnough(truth_pos,
293 MAX_POSITION_ERROR_DAQ,
294 // MAX_POSITION_PERCENT_ERROR_DAQ));
295 }
296 */
297 return;
298 }
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:23
Implements detector ids for HCal subdetector.
Definition HcalID.h:19
bool isADC() const
Check if this DIGI is an ADC measurement.
Represents a collection of the digi hits readout by an HGCROC.
const HgcrocDigi getDigi(unsigned int digiIndex) const
Get samples for the input digi index.
Stores simulated calorimeter hit information.

References ldmx::HgcrocDigiCollection::getDigi(), ldmx::HgcrocDigiCollection::HgcrocDigi::isADC(), framework::EventProcessor::ntuple_, and framework::NtupleManager::setVar().

◆ 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 202 of file HcalDigiPipelineTest.cxx.

202 {
203 if (save_) {
205 ntuple_.create("HcalDigiTest");
206 ntuple_.addVar<float>("HcalDigiTest", "SimEnergy");
207 ntuple_.addVar<float>("HcalDigiTest", "RecEnergy");
208 ntuple_.addVar<float>("HcalDigiTest", "SimX");
209 ntuple_.addVar<float>("HcalDigiTest", "SimY");
210 ntuple_.addVar<float>("HcalDigiTest", "SimZ");
211 ntuple_.addVar<float>("HcalDigiTest", "SimTime");
212 ntuple_.addVar<float>("HcalDigiTest", "RecX");
213 ntuple_.addVar<float>("HcalDigiTest", "RecY");
214 ntuple_.addVar<float>("HcalDigiTest", "RecZ");
215 ntuple_.addVar<float>("HcalDigiTest", "RecTime");
216 ntuple_.addVar<int>("HcalDigiTest", "DaqDigi");
217 ntuple_.addVar<int>("HcalDigiTest", "DaqDigiIsADC");
218 ntuple_.addVar<int>("HcalDigiTest", "DaqDigiADC");
219 ntuple_.addVar<int>("HcalDigiTest", "DaqDigiTOT");
220 }
221 }
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

◆ 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: