LDMX Software
tools::PatternLUTMaker Class Reference

Classes

struct  Line
 

Public Member Functions

 PatternLUTMaker (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.
 
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 input_file_
 
std::string output_file_
 
double lut_threshold_ {0.0008}
 
std::ifstream infile_
 
std::ofstream outfile_
 
std::map< std::pair< float, float >, std::vector< Line > > groups_
 
int total_lines_ {0}
 

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

Definition at line 21 of file PatternLUTMaker.h.

Constructor & Destructor Documentation

◆ PatternLUTMaker()

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

Definition at line 9 of file PatternLUTMaker.cxx.

11 : 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::PatternLUTMaker::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 55 of file PatternLUTMaker.cxx.

55 {
56}

◆ configure()

void tools::PatternLUTMaker::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 13 of file PatternLUTMaker.cxx.

13 {
14 input_file_ = ps.get<std::string>("input_file");
15 output_file_ = ps.get<std::string>("output_file");
16 lut_threshold_ = ps.get<double>("lut_threshold");
17 verbose_ = ps.get<int>("verbosity");
18
19 // The LUT threshold is the minimum percentage of times that a track
20 // must appear in a pool of events to be written to the LUT.
21 // Example --- horizontal tracks whose pad 1-2 and pad 2-3 delta values
22 // are both 0 make up ~80% of tracks out of 10.000 events,
23 // while a track with deltas (+22,-22), meaning pad 1 cluster in
24 // e.g. bar 4, pad 2 cluster in bar 26, and pad 3 cluster in bar 4
25 // only appears once in 10.000 events (0.01%). The straight
26 // tracks are written to the LUT and the single "anomaly" is not.
27 // Primary motivation here is for use in the case of an unknown TS
28 // misalignment.
29
30 ldmx_log(info) << "In PatternLUTMaker: configure done!" << std::endl;
31 ldmx_log(info) << "Got parameters: \nInput file: " << input_file_
32 << "\nOutput file: " << output_file_
33 << "\nLUT threshold: " << lut_threshold_
34 << "\nVerbosity: " << verbose_;
35
36 return;
37}

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

◆ onProcessEnd()

void tools::PatternLUTMaker::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 58 of file PatternLUTMaker.cxx.

58 {
59 ldmx_log(info) << "total_lines = " << total_lines_;
60 ldmx_log(info) << "groups = " << groups_.size();
61 int combs = 0; //combs will be the total number of patterns written to the LUT
62 int tracks = 0; //and tracks the number of tracks contained within those pattern groups
63
64 if (verbose_) {
65 ldmx_log(info) << "Total number of cluster combinations: " << total_lines_ << "\n"
66 << "Number of different propagation patterns: " << groups_.size()
67 << "\n" << "LUT Threshold: " << lut_threshold_ * 100 << "%\n";
68 }
69
70 for (auto& g : groups_) {
71 int count = g.second.size();
72 double frac = static_cast<double>(count) / total_lines_;
73
74 if (verbose_) {
75 ldmx_log(debug) << "(" << g.first.first << "," << g.first.second << ") appears "
76 << count << " times, (" << frac * 100 << " %)" << "\n";
77 }
78
79 if (frac > lut_threshold_) { // write to outfile_ (LUT file) if over threshold
80 combs++;
81 for (auto& line : g.second) {
82 tracks++;
83 outfile_ << line.p1_ << " " << line.p2_ << " " << line.p3_ << "\n";
84 }
85 }
86
87 }
88
89 if (verbose_) {
90 ldmx_log(info) << "\nLUT textfile written." << "\n" << combs
91 << " combinations (" << tracks << " tracks) written to LUT.\n";
92 }
93 return;
94}

◆ onProcessStart()

void tools::PatternLUTMaker::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 39 of file PatternLUTMaker.cxx.

39 {
40 infile_.open(input_file_);
41 outfile_.open(output_file_);
42
43 if (total_lines_ > 0) return;
44 int ev;
45 float p1, p2, p3;
46 while (infile_ >> ev >> p1 >> p2 >> p3) {
47 float p12 = p2 - p1; //for each cluster combination, calculate vertical propagation
48 float p23 = p3 - p2; //between pads 1 and 2 (p12) and between pads 2 and 3 (p23);
49 groups_[{p12, p23}].push_back({ev, p1, p2, p3}); //and group by these values
50 total_lines_++; //(the "propagation patterns").
51 }
52 return;
53}

Member Data Documentation

◆ groups_

std::map<std::pair<float, float>, std::vector<Line> > tools::PatternLUTMaker::groups_
private

Definition at line 57 of file PatternLUTMaker.h.

◆ infile_

std::ifstream tools::PatternLUTMaker::infile_
private

Definition at line 53 of file PatternLUTMaker.h.

◆ input_file_

std::string tools::PatternLUTMaker::input_file_
private

Definition at line 45 of file PatternLUTMaker.h.

◆ lut_threshold_

double tools::PatternLUTMaker::lut_threshold_ {0.0008}
private

Definition at line 51 of file PatternLUTMaker.h.

51{0.0008};

◆ outfile_

std::ofstream tools::PatternLUTMaker::outfile_
private

Definition at line 54 of file PatternLUTMaker.h.

◆ output_file_

std::string tools::PatternLUTMaker::output_file_
private

Definition at line 48 of file PatternLUTMaker.h.

◆ total_lines_

int tools::PatternLUTMaker::total_lines_ {0}
private

Definition at line 60 of file PatternLUTMaker.h.

60{0};

◆ verbose_

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

Definition at line 42 of file PatternLUTMaker.h.

42{0};

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