LDMX Software
Public Member Functions | Private Attributes | List of all members
dqm::ReSimVerifier Class Reference

Public Member Functions

 ReSimVerifier (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.
 
void analyze (const framework::Event &event) override
 Process the event and make histograms or summaries.
 
bool verifySimCalorimeterHits (const std::vector< ldmx::SimCalorimeterHit > &simHits, const std::vector< ldmx::SimCalorimeterHit > &reSimHits)
 
bool verifySimParticles (const framework::Event &event)
 
- 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 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 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::vector< std::string > collections
 
std::string simPassName_ {""}
 
std::string reSimPassName_ {""}
 
bool stop_on_error {}
 

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

Definition at line 14 of file ReSimVerifier.h.

Constructor & Destructor Documentation

◆ ReSimVerifier()

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

Definition at line 16 of file ReSimVerifier.h.

17 : framework::Analyzer{name, process} {}
Base class for a module which does not produce a data product.

Member Function Documentation

◆ analyze()

void dqm::ReSimVerifier::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 61 of file ReSimVerifier.cxx.

61 {
62 std::stringstream ss;
63 bool passing{true};
64 bool skipped{false};
65 auto eventNumber{event.getEventNumber()};
66 for (auto collection : collections) {
67 const auto SimHits =
68 event.getCollection<ldmx::SimCalorimeterHit>(collection, simPassName_);
69 const auto ReSimHits = event.getCollection<ldmx::SimCalorimeterHit>(
70 collection, reSimPassName_);
71 if (ReSimHits.size() == 0) {
72 skipped = true;
73 continue;
74 } else {
75 skipped = false;
76 }
77
78 if (!verifySimCalorimeterHits(SimHits, ReSimHits)) {
79 passing = false;
80 ss << "Event " << eventNumber << " has different simhits for "
81 << collection << std::endl;
82 }
83 }
84 if (skipped) {
85 std::cout << "Skipping event " << eventNumber
86 << "since it was not resimulated" << std::endl;
87 }
88 if (!verifySimParticles(event)) {
89 passing = false;
90 ss << "Event " << eventNumber
91 << " has different SimParticles between the two passes" << std::endl;
92 }
93 if (!passing) {
94 if (stop_on_error) {
95 EXCEPTION_RAISE("ReSimVerify", ss.str());
96 } else {
97 std::cout << ss.str();
98 }
99 }
100
101} // Analyze
Stores simulated calorimeter hit information.

◆ configure()

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

For an example, look at MyProcessor.

Parameters
parametersParameters for configuration.

Reimplemented from framework::EventProcessor.

Definition at line 4 of file ReSimVerifier.cxx.

4 {
5 simPassName_ = parameters.getParameter<std::string>("sim_pass_name");
6 reSimPassName_ = parameters.getParameter<std::string>("resim_pass_name");
7 stop_on_error = parameters.getParameter<bool>("stop_on_error");
8 collections =
9 parameters.getParameter<std::vector<std::string>>("collections");
10}
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:89

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

◆ verifySimCalorimeterHits()

bool dqm::ReSimVerifier::verifySimCalorimeterHits ( const std::vector< ldmx::SimCalorimeterHit > &  simHits,
const std::vector< ldmx::SimCalorimeterHit > &  reSimHits 
)

Definition at line 11 of file ReSimVerifier.cxx.

13 {
14 for (auto i{0}; i < simHits.size(); ++i) {
15 auto hit{simHits[i]};
16 auto rehit{reSimHits[i]};
17
18 if (hit.getEdep() != rehit.getEdep()) {
19 return false;
20 }
21 if (hit.getID() != rehit.getID()) {
22 return false;
23 }
24 if (hit.getTime() != rehit.getTime()) {
25 return false;
26 }
27 if (hit.getNumberOfContribs() != rehit.getNumberOfContribs()) {
28 return false;
29 }
30 auto pos{hit.getPosition()};
31 auto repos{rehit.getPosition()};
32 if (pos[0] != repos[0] || pos[1] != repos[1] || pos[2] != repos[2]) {
33 return false;
34 }
35 }
36 return true;
37}

◆ verifySimParticles()

bool dqm::ReSimVerifier::verifySimParticles ( const framework::Event event)

Definition at line 39 of file ReSimVerifier.cxx.

39 {
40 const auto& simParticles{
41 event.getMap<int, ldmx::SimParticle>("SimParticles", simPassName_)};
42 const auto& reSimParticles{
43 event.getMap<int, ldmx::SimParticle>("SimParticles", reSimPassName_)};
44 for (auto [id, simParticle] : simParticles) {
45 if (!reSimParticles.count(id)) {
46 return false;
47 }
48 auto reSimParticle{reSimParticles.at(id)};
49 if (simParticle.getEnergy() != reSimParticle.getEnergy()) {
50 return false;
51 }
52 if (simParticle.getPdgID() != reSimParticle.getPdgID()) {
53 return false;
54 }
55 if (simParticle.getTime() != reSimParticle.getTime()) {
56 return false;
57 }
58 }
59 return true;
60}
Class representing a simulated particle.
Definition SimParticle.h:23

Member Data Documentation

◆ collections

std::vector<std::string> dqm::ReSimVerifier::collections
private

Definition at line 41 of file ReSimVerifier.h.

◆ reSimPassName_

std::string dqm::ReSimVerifier::reSimPassName_ {""}
private

Definition at line 43 of file ReSimVerifier.h.

43{""};

◆ simPassName_

std::string dqm::ReSimVerifier::simPassName_ {""}
private

Definition at line 42 of file ReSimVerifier.h.

42{""};

◆ stop_on_error

bool dqm::ReSimVerifier::stop_on_error {}
private

Definition at line 48 of file ReSimVerifier.h.

48{};

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