LDMX Software
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
hcal::HcalPedestalAnalyzer Class Reference

Classes

struct  Channel
 

Public Member Functions

 HcalPedestalAnalyzer (const std::string &n, framework::Process &p)
 
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 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.
 
- 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.
 
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 Member Functions

void create_and_fill (Channel &chan, ldmx::HcalDigiID detid)
 

Private Attributes

std::string input_name_
 
std::string input_pass_
 
std::string output_file_
 
std::string comments_
 
bool make_histos_
 
bool filter_noTOT
 
bool filter_noTOA
 
int low_cutoff_
 
int high_cutoff_
 
std::map< ldmx::HcalDigiID, Channelpedestal_data_
 

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 9 of file HcalPedestalAnalyzer.h.

Constructor & Destructor Documentation

◆ HcalPedestalAnalyzer()

hcal::HcalPedestalAnalyzer::HcalPedestalAnalyzer ( const std::string &  n,
framework::Process p 
)
inline

Definition at line 39 of file HcalPedestalAnalyzer.h.

40 : framework::Analyzer(n, p) {}
Base class for a module which does not produce a data product.

Member Function Documentation

◆ analyze()

void hcal::HcalPedestalAnalyzer::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 8 of file HcalPedestalAnalyzer.cxx.

8 {
9 auto const& digis{
10 event.getObject<ldmx::HgcrocDigiCollection>(input_name_, input_pass_)};
11
12 for (std::size_t i_digi{0}; i_digi < digis.size(); i_digi++) {
13 auto d{digis.getDigi(i_digi)};
14 ldmx::HcalDigiID detid(d.id());
15
16 Channel& chan = pedestal_data_[detid];
17
18 bool has_tot = false;
19 bool has_toa = false;
20 bool has_under = false;
21 bool has_over = false;
22
23 for (int i = 0; i < digis.getNumSamplesPerDigi(); i++) {
24 if (d.at(i).tot() > 0) has_tot = true;
25 if (d.at(i).toa() > 0) has_toa = true;
26 if (d.at(i).adc_t() < low_cutoff_) has_under = true;
27 if (d.at(i).adc_t() > high_cutoff_) has_over = true;
28 }
29
30 if (has_tot && filter_noTOT) chan.rejects[0]++;
31 if (has_toa && filter_noTOA) chan.rejects[1]++;
32 if (has_under) chan.rejects[2]++;
33 if (has_over) chan.rejects[3]++;
34
35 if (has_tot && filter_noTOT) continue; // ignore this
36 if (has_toa && filter_noTOA) continue; // ignore this
37 if (has_under)
38 continue; // ignore this, set threshold to zero to disable requirement
39 if (has_over)
40 continue; // ignore this, set threshold larger than 1024 to disable
41 // requirement
42
43 for (int i = 0; i < digis.getNumSamplesPerDigi(); i++) {
44 int adc = d.at(i).adc_t();
45
46 chan.sum += adc;
47 chan.sum_sq += adc * adc;
48 chan.entries++;
49 if (chan.hist)
50 chan.hist->Fill(adc);
51 else if (make_histos_)
52 chan.adcs.push_back(adc);
53 }
54
55 // histogram-related business
56 if (make_histos_ && !chan.hist && chan.entries > 250)
57 create_and_fill(chan, detid);
58 }
59}
Extension of HcalAbstractID providing access to HCal digi information.
Definition HcalDigiID.h:13
Represents a collection of the digi hits readout by an HGCROC.
const HgcrocDigi getDigi(unsigned int digiIndex) const
Get samples for the input digi index.

References hcal::HcalPedestalAnalyzer::Channel::adcs, hcal::HcalPedestalAnalyzer::Channel::entries, ldmx::HgcrocDigiCollection::getDigi(), hcal::HcalPedestalAnalyzer::Channel::hist, hcal::HcalPedestalAnalyzer::Channel::rejects, hcal::HcalPedestalAnalyzer::Channel::sum, and hcal::HcalPedestalAnalyzer::Channel::sum_sq.

◆ configure()

void hcal::HcalPedestalAnalyzer::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 43 of file HcalPedestalAnalyzer.h.

43 {
44 input_name_ = ps.getParameter<std::string>("input_name");
45 input_pass_ = ps.getParameter<std::string>("input_pass");
46 output_file_ = ps.getParameter<std::string>("output_file");
47 comments_ = ps.getParameter<std::string>("comments");
48
49 make_histos_ = ps.getParameter<bool>("make_histos", false);
50
51 filter_noTOT = ps.getParameter<bool>("filter_noTOT", true);
52 filter_noTOA = ps.getParameter<bool>("filter_noTOA", true);
53 low_cutoff_ = ps.getParameter<int>("low_cutoff", 10);
54 high_cutoff_ = ps.getParameter<int>("high_cutoff", 512);
55 }

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

◆ create_and_fill()

void hcal::HcalPedestalAnalyzer::create_and_fill ( Channel chan,
ldmx::HcalDigiID  detid 
)
private

Definition at line 61 of file HcalPedestalAnalyzer.cxx.

62 {
63 if (chan.entries == 0) return;
64
65 TDirectory* hdir = getHistoDirectory();
66 hdir->cd();
67 char hname[120];
68 sprintf(hname, "pedestal_%d_%d_%d_%d", detid.section(), detid.layer(),
69 detid.strip(), detid.end());
70 // logic: 100 bins to +/- 5 sigma based on first 250 events.
71 double mean = (chan.sum * 1.0) / chan.entries;
72 double rms = sqrt(chan.sum_sq / chan.entries - mean * mean);
73 if (rms * 5 < 50)
74 chan.hist = new TH1D(hname, hname, 30, int(mean) - 15, int(mean) + 15);
75 else
76 chan.hist = new TH1D(hname, hname, 100, mean - 5 * rms, mean + 5 * rms);
77 for (auto x : chan.adcs) chan.hist->Fill(x);
78 chan.adcs.clear();
79}
TDirectory * getHistoDirectory()
Access/create a directory in the histogram file for this event processor to create histograms and ana...
int strip() const
Get the value of the 'strip' field from the ID.
Definition HcalDigiID.h:99
int section() const
Get the value of the 'section' field from the ID.
Definition HcalDigiID.h:75
int layer() const
Get the value of the layer field from the ID.
Definition HcalDigiID.h:81
int end() const
Get the value of the 'end' field from the ID.
Definition HcalDigiID.h:105

◆ onProcessEnd()

void hcal::HcalPedestalAnalyzer::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 81 of file HcalPedestalAnalyzer.cxx.

81 {
82 FILE* fout = fopen(output_file_.c_str(), "w");
83
84 time_t t = time(NULL);
85 struct tm* gmtm = gmtime(&t);
86 char times[1024];
87 strftime(times, sizeof(times), "%Y-%m-%d %H:%M:%S GMT", gmtm);
88 fprintf(fout, "# %s\n", comments_.c_str());
89 fprintf(fout, "# Produced %s\n", times);
90 fprintf(fout, "DetID,PEDESTAL_ADC,PEDESTAL_RMS_ADC\n");
91
92 for (auto ichan : pedestal_data_) {
93 if (ichan.second.entries == 0) {
94 std::cout << "All entries filtered for " << ichan.first << " for TOT "
95 << ichan.second.rejects[0] << " for TOA "
96 << ichan.second.rejects[1] << " for underthreshold "
97 << ichan.second.rejects[2] << " for overthreshold "
98 << ichan.second.rejects[3] << std::endl;
99 continue; // all entries were filtered out
100 }
101
102 double mean = ichan.second.sum * 1.0 / ichan.second.entries;
103 double rms = sqrt(ichan.second.sum_sq / ichan.second.entries - mean * mean);
104 fprintf(fout, "0x%08x,%9.3f,%9.3f\n", ichan.first.raw(), mean, rms);
105 }
106
107 fclose(fout);
108}

Member Data Documentation

◆ comments_

std::string hcal::HcalPedestalAnalyzer::comments_
private

Definition at line 11 of file HcalPedestalAnalyzer.h.

◆ filter_noTOA

bool hcal::HcalPedestalAnalyzer::filter_noTOA
private

Definition at line 14 of file HcalPedestalAnalyzer.h.

◆ filter_noTOT

bool hcal::HcalPedestalAnalyzer::filter_noTOT
private

Definition at line 13 of file HcalPedestalAnalyzer.h.

◆ high_cutoff_

int hcal::HcalPedestalAnalyzer::high_cutoff_
private

Definition at line 15 of file HcalPedestalAnalyzer.h.

◆ input_name_

std::string hcal::HcalPedestalAnalyzer::input_name_
private

Definition at line 10 of file HcalPedestalAnalyzer.h.

◆ input_pass_

std::string hcal::HcalPedestalAnalyzer::input_pass_
private

Definition at line 10 of file HcalPedestalAnalyzer.h.

◆ low_cutoff_

int hcal::HcalPedestalAnalyzer::low_cutoff_
private

Definition at line 15 of file HcalPedestalAnalyzer.h.

◆ make_histos_

bool hcal::HcalPedestalAnalyzer::make_histos_
private

Definition at line 12 of file HcalPedestalAnalyzer.h.

◆ output_file_

std::string hcal::HcalPedestalAnalyzer::output_file_
private

Definition at line 11 of file HcalPedestalAnalyzer.h.

◆ pedestal_data_

std::map<ldmx::HcalDigiID, Channel> hcal::HcalPedestalAnalyzer::pedestal_data_
private

Definition at line 34 of file HcalPedestalAnalyzer.h.


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