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 108 of file FunctionalCoreTest.cxx.

Constructor & Destructor Documentation

◆ TestAnalyzer()

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

Definition at line 117 of file FunctionalCoreTest.cxx.

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

◆ ~TestAnalyzer()

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

Definition at line 118 of file FunctionalCoreTest.cxx.

118{}

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 136 of file FunctionalCoreTest.cxx.

136 {
137 int i_event = event.getEventNumber();
138
139 REQUIRE(i_event > 0);
140
141 const std::vector<ldmx::CalorimeterHit>& calo_hits =
142 event.getCollection<ldmx::CalorimeterHit>("TestCollection",
143 test_collection_passname_);
144
145 CHECK(calo_hits.size() == i_event);
146 for (unsigned int i = 0; i < calo_hits.size(); i++) {
147 CHECK(calo_hits.at(i).getID() == i_event * 10 + i);
148 test_hist_->Fill(calo_hits.at(i).getID());
149 }
150
151 const ldmx::HcalVetoResult& veto_res =
152 event.getObject<ldmx::HcalVetoResult>("TestObject",
153 veto_test_object_passname_);
154
155 auto max_pe_hit{veto_res.getMaxPEHit()};
156
157 CHECK(max_pe_hit.getID() == i_event);
158 CHECK(veto_res.passesVeto() == (i_event % 2 == 0));
159
160 const float& tenth_event =
161 event.getObject<float>("EventTenth", tenth_event_passname_);
162 CHECK(tenth_event == Approx(i_event * 0.1));
163
164 const std::vector<int>& i_event_from_bus =
165 event.getCollection<int>("EventIndex", event_index_passname_);
166
167 CHECK(i_event_from_bus.size() == 2);
168 CHECK(i_event_from_bus.at(0) == i_event);
169 CHECK(i_event_from_bus.at(1) == i_event);
170
171 return;
172 }
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 className equal to the EventProcessor class name.

For an example, look at MyProcessor.

Parameters
parametersParameters for configuration.

Reimplemented from framework::EventProcessor.

Definition at line 120 of file FunctionalCoreTest.cxx.

120 {
121 test_collection_passname_ =
122 ps.get<std::string>("test_collection_passname", "");
123 test_object_passname_ = ps.get<std::string>("test_object_passname", "");
124 veto_test_object_passname_ =
125 ps.get<std::string>("veto_test_object_passname", "");
126 tenth_event_passname_ = ps.get<std::string>("tenth_event_passname", "");
127 event_index_passname_ = ps.get<std::string>("event_index_passname", "");
128 }

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 130 of file FunctionalCoreTest.cxx.

130 {
131 REQUIRE_NOTHROW(getHistoDirectory());
132 test_hist_ = new TH1F("test_hist_", "Test Histogram", 101, -50, 50);
133 test_hist_->SetCanExtend(TH1::kAllAxes);
134 }
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 114 of file FunctionalCoreTest.cxx.

◆ tenth_event_passname_

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

Definition at line 113 of file FunctionalCoreTest.cxx.

◆ test_collection_passname_

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

Definition at line 110 of file FunctionalCoreTest.cxx.

◆ test_hist_

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

test histogram filled with event indices

Definition at line 176 of file FunctionalCoreTest.cxx.

Referenced by analyze(), and onProcessStart().

◆ test_object_passname_

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

Definition at line 111 of file FunctionalCoreTest.cxx.

◆ veto_test_object_passname_

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

Definition at line 112 of file FunctionalCoreTest.cxx.


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