LDMX Software
tools::ClusterTripletMaker Class Reference

Write trigger scintillator cluster triplets to a text file. More...

#include <ClusterTripletMaker.h>

Public Member Functions

 ClusterTripletMaker (const std::string &name, framework::Process &process)
 
void configure (framework::config::Parameters &ps) 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.
 
void onProcessStart () override
 Callback for the EventProcessor to take any necessary action when the processing of events starts, such as creating histograms.
 
void onProcessEnd () override
 Callback for the EventProcessor to take any necessary action when the processing of events finishes, such as calculating job-summary quantities.
 
- 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.
 
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

int verbose_ {0}
 
std::string pass_name_ {""}
 
std::vector< std::string > cluster_input_collections_
 
std::string output_file_ {"clusters.txt"}
 
std::ofstream output_stream_
 

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

Write trigger scintillator cluster triplets to a text file.

Definition at line 28 of file ClusterTripletMaker.h.

Constructor & Destructor Documentation

◆ ClusterTripletMaker()

tools::ClusterTripletMaker::ClusterTripletMaker ( const std::string & name,
framework::Process & process )

Definition at line 7 of file ClusterTripletMaker.cxx.

9 : Analyzer(name, process) {}
virtual void process(Event &event) final
Processing an event for an Analyzer is calling analyze.
Analyzer(const std::string &name, Process &process)
Class constructor.

Member Function Documentation

◆ analyze()

void tools::ClusterTripletMaker::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 42 of file ClusterTripletMaker.cxx.

42 {
43 const auto clusters_pad1{event.getCollection<ldmx::TrigScintCluster>(
44 cluster_input_collections_.at(0), pass_name_)};
45 const auto clusters_pad2{event.getCollection<ldmx::TrigScintCluster>(
46 cluster_input_collections_.at(1), pass_name_)};
47 const auto clusters_pad3{event.getCollection<ldmx::TrigScintCluster>(
48 cluster_input_collections_.at(2), pass_name_)};
49
50 const size_t num_clusters = std::min( //in the event of multiple clusters in
51 {clusters_pad1.size(), //one pad in one event, select that with the lowest
52 clusters_pad2.size(), //centroid value for simplicity (not always accurate
53 clusters_pad3.size()}); //unfortunately)
54
55 ldmx_log(debug) << "Event " << event.getEventNumber() << " has " << clusters_pad1.size()
56 << ", " << clusters_pad2.size() << ", " << clusters_pad3.size()
57 << " clusters in pads 1, 2, and 3.";
58
59 for (size_t cluster_index = 0; cluster_index < num_clusters; ++cluster_index) {
60 const int event_number = event.getEventNumber();
61 const float pad1_centroid = clusters_pad1.at(cluster_index).getCentroid();
62 const float pad2_centroid = clusters_pad2.at(cluster_index).getCentroid();
63 const float pad3_centroid = clusters_pad3.at(cluster_index).getCentroid();
64
65 //write to output file
66 output_stream_ << event_number << " " << pad1_centroid << " "
67 << pad2_centroid << " " << pad3_centroid << " " << "\n";
68 }
69
70 if (verbose_) {
71 for (size_t cluster_index = 1; cluster_index < clusters_pad1.size();
72 ++cluster_index) {
73 ldmx_log(info) << "Event " << event.getEventNumber()
74 << ", extra cluster in pad 1: "
75 << clusters_pad1.at(cluster_index).getCentroid();
76 }
77
78 for (size_t cluster_index = 1; cluster_index < clusters_pad2.size();
79 ++cluster_index) {
80 ldmx_log(info) << "Event " << event.getEventNumber()
81 << ", extra cluster in pad 2: "
82 << clusters_pad2.at(cluster_index).getCentroid();
83 }
84
85 for (size_t cluster_index = 1; cluster_index < clusters_pad3.size();
86 ++cluster_index) {
87 ldmx_log(info) << "Event " << event.getEventNumber()
88 << ", extra cluster in pad 3: "
89 << clusters_pad3.at(cluster_index).getCentroid();
90 }
91 }
92 return;
93}
Stores cluster information from the trigger scintillator pads.

◆ configure()

void tools::ClusterTripletMaker::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 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 11 of file ClusterTripletMaker.cxx.

11 {
12 pass_name_ = ps.get<std::string>("pass_name");
13 cluster_input_collections_ =
14 ps.get<std::vector<std::string>>("cluster_input_collections");
15 output_file_ = ps.get<std::string>("output_file");
16 verbose_ = ps.get<int>("verbosity");
17
18 if (verbose_) {
19 ldmx_log(info) << "In ClusterTripletMaker: configure done!"
20 << "\nInput collection 1: "
21 << cluster_input_collections_.at(0)
22 << "\nInput collection 2: "
23 << cluster_input_collections_.at(1)
24 << "\nInput collection 3: "
25 << cluster_input_collections_.at(2)
26 << "\nPass name: " << pass_name_
27 << "\nOutput file: " << output_file_
28 << "\nVerbosity: " << verbose_;
29 }
30 return;
31}

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

◆ onProcessEnd()

void tools::ClusterTripletMaker::onProcessEnd ( )
overridevirtual

Callback for the EventProcessor to take any necessary action when the processing of events finishes, such as calculating job-summary quantities.

Reimplemented from framework::EventProcessor.

Definition at line 95 of file ClusterTripletMaker.cxx.

95 {
96 if (output_stream_.is_open()) {
97 output_stream_.close();
98 }
99
100 if (verbose_) {
101 ldmx_log(info) << "Closed output file " << output_file_;
102 }
103 return;
104}

◆ onProcessStart()

void tools::ClusterTripletMaker::onProcessStart ( )
overridevirtual

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 33 of file ClusterTripletMaker.cxx.

33 {
34 output_stream_.open(output_file_);
35
36 if (verbose_) {
37 ldmx_log(info) << "Opened output file " << output_file_;
38 }
39 return;
40}

Member Data Documentation

◆ cluster_input_collections_

std::vector<std::string> tools::ClusterTripletMaker::cluster_input_collections_
private

Definition at line 50 of file ClusterTripletMaker.h.

◆ output_file_

std::string tools::ClusterTripletMaker::output_file_ {"clusters.txt"}
private

Definition at line 53 of file ClusterTripletMaker.h.

53{"clusters.txt"};

◆ output_stream_

std::ofstream tools::ClusterTripletMaker::output_stream_
private

Definition at line 56 of file ClusterTripletMaker.h.

◆ pass_name_

std::string tools::ClusterTripletMaker::pass_name_ {""}
private

Definition at line 47 of file ClusterTripletMaker.h.

47{""};

◆ verbose_

int tools::ClusterTripletMaker::verbose_ {0}
private

Definition at line 44 of file ClusterTripletMaker.h.

44{0};

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