LDMX Software
framework::test::TestAnalyzer Class Reference

Bare analyzer that looks for objects matching what the TestProducer put in. More...

Public Member Functions

 TestAnalyzer (const std::string &name, 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

std::string test_collection_passname_
 
std::string test_object_passname_
 
std::string veto_test_object_passname_
 
std::string tenth_event_passname_
 
std::string event_index_passname_
 
TH1F * test_hist_
 test histogram filled with event indices
 

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

Bare analyzer that looks for objects matching what the TestProducer put in.

Checks

Definition at line 117 of file FunctionalCoreTest.cxx.

Constructor & Destructor Documentation

◆ TestAnalyzer()

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

Definition at line 126 of file FunctionalCoreTest.cxx.

126: Analyzer(name, p) {}
Analyzer(const std::string &name, Process &process)
Class constructor.

◆ ~TestAnalyzer()

framework::test::TestAnalyzer::~TestAnalyzer ( )
inline

Definition at line 127 of file FunctionalCoreTest.cxx.

127{}

Member Function Documentation

◆ analyze()

void framework::test::TestAnalyzer::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 145 of file FunctionalCoreTest.cxx.

145 {
146 int i_event = event.getEventNumber();
147
148 REQUIRE(i_event > 0);
149
150 const std::vector<ldmx::CalorimeterHit>& calo_hits =
151 event.getCollection<ldmx::CalorimeterHit>("TestCollection",
152 test_collection_passname_);
153
154 CHECK(calo_hits.size() == i_event);
155 for (unsigned int i = 0; i < calo_hits.size(); i++) {
156 CHECK(calo_hits.at(i).getID() == i_event * 10 + i);
157 test_hist_->Fill(calo_hits.at(i).getID());
158 }
159
160 const ldmx::HcalVetoResult& veto_res =
161 event.getObject<ldmx::HcalVetoResult>("TestObject",
162 veto_test_object_passname_);
163
164 auto max_pe_hit{veto_res.getMaxPEHit()};
165
166 CHECK(max_pe_hit.getID() == i_event);
167 CHECK(veto_res.passesVeto() == (i_event % 2 == 0));
168
169 const float& tenth_event =
170 event.getObject<float>("EventTenth", tenth_event_passname_);
171 CHECK(tenth_event == Approx(i_event * 0.1));
172
173 const std::vector<int>& i_event_from_bus =
174 event.getCollection<int>("EventIndex", event_index_passname_);
175
176 CHECK(i_event_from_bus.size() == 2);
177 CHECK(i_event_from_bus.at(0) == i_event);
178 CHECK(i_event_from_bus.at(1) == i_event);
179
180 return;
181 }
TH1F * test_hist_
test histogram filled with event indices
Represents a reconstructed hit in a calorimeter cell within the detector.
bool passesVeto() const
Checks if the event passes the Hcal veto.
ldmx::HcalHit getMaxPEHit() const

References ldmx::HcalVetoResult::getMaxPEHit(), ldmx::HcalVetoResult::passesVeto(), and test_hist_.

◆ configure()

void framework::test::TestAnalyzer::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 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 129 of file FunctionalCoreTest.cxx.

129 {
130 test_collection_passname_ =
131 ps.get<std::string>("test_collection_passname", "");
132 test_object_passname_ = ps.get<std::string>("test_object_passname", "");
133 veto_test_object_passname_ =
134 ps.get<std::string>("veto_test_object_passname", "");
135 tenth_event_passname_ = ps.get<std::string>("tenth_event_passname", "");
136 event_index_passname_ = ps.get<std::string>("event_index_passname", "");
137 }

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

◆ onProcessStart()

void framework::test::TestAnalyzer::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 139 of file FunctionalCoreTest.cxx.

139 {
140 REQUIRE_NOTHROW(getHistoDirectory());
141 test_hist_ = new TH1F("test_hist_", "Test Histogram", 101, -50, 50);
142 test_hist_->SetCanExtend(TH1::kAllAxes);
143 }
TDirectory * getHistoDirectory()
Access/create a directory in the histogram file for this event processor to create histograms and ana...

References framework::EventProcessor::getHistoDirectory(), and test_hist_.

Member Data Documentation

◆ event_index_passname_

std::string framework::test::TestAnalyzer::event_index_passname_
private

Definition at line 123 of file FunctionalCoreTest.cxx.

◆ tenth_event_passname_

std::string framework::test::TestAnalyzer::tenth_event_passname_
private

Definition at line 122 of file FunctionalCoreTest.cxx.

◆ test_collection_passname_

std::string framework::test::TestAnalyzer::test_collection_passname_
private

Definition at line 119 of file FunctionalCoreTest.cxx.

◆ test_hist_

TH1F* framework::test::TestAnalyzer::test_hist_
private

test histogram filled with event indices

Definition at line 185 of file FunctionalCoreTest.cxx.

Referenced by analyze(), and onProcessStart().

◆ test_object_passname_

std::string framework::test::TestAnalyzer::test_object_passname_
private

Definition at line 120 of file FunctionalCoreTest.cxx.

◆ veto_test_object_passname_

std::string framework::test::TestAnalyzer::veto_test_object_passname_
private

Definition at line 121 of file FunctionalCoreTest.cxx.


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