4#include "Hcal/HcalPedestalAnalyzer.h"
12 for (std::size_t i_digi{0}; i_digi < digis.size(); i_digi++) {
16 Channel& chan = pedestal_data_[detid];
20 bool has_under =
false;
21 bool has_over =
false;
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;
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]++;
35 if (has_tot && filter_noTOT)
continue;
36 if (has_toa && filter_noTOA)
continue;
43 for (
int i = 0; i < digis.getNumSamplesPerDigi(); i++) {
44 int adc = d.at(i).adc_t();
51 else if (make_histos_)
52 chan.
adcs.push_back(adc);
56 if (make_histos_ && !chan.
hist && chan.
entries > 250)
57 create_and_fill(chan, detid);
61void HcalPedestalAnalyzer::create_and_fill(Channel& chan,
63 if (chan.entries == 0)
return;
68 sprintf(hname,
"pedestal_%d_%d_%d_%d", detid.
section(), detid.
layer(),
71 double mean = (chan.sum * 1.0) / chan.entries;
72 double rms = sqrt(chan.sum_sq / chan.entries - mean * mean);
74 chan.hist =
new TH1D(hname, hname, 30,
int(mean) - 15,
int(mean) + 15);
76 chan.hist =
new TH1D(hname, hname, 100, mean - 5 * rms, mean + 5 * rms);
77 for (
auto x : chan.adcs) chan.hist->Fill(x);
82 FILE* fout = fopen(output_file_.c_str(),
"w");
84 time_t t = time(NULL);
85 struct tm* gmtm = gmtime(&t);
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");
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;
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);
#define DECLARE_ANALYZER_NS(NS, CLASS)
Macro which allows the framework to construct an analyzer given its name during configuration.
TDirectory * getHistoDirectory()
Access/create a directory in the histogram file for this event processor to create histograms and ana...
Implements an event buffer system for storing event data.
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,...
Extension of HcalAbstractID providing access to HCal digi information.
int strip() const
Get the value of the 'strip' field from the ID.
int section() const
Get the value of the 'section' field from the ID.
int layer() const
Get the value of the layer field from the ID.
int end() const
Get the value of the 'end' field from the ID.
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.
uint64_t sum
Sum of values.
int entries
Number of entries.
double sum_sq
Sum of values squared.
std::vector< int > rejects
counts of various rejections
std::vector< int > adcs
collection of hits accumulated to produce appropriately-binned histograms
TH1 * hist
Histogram, if used.