LDMX Software
trigscint::TestBeamHitProducer Class Reference

Organizes digis into TrigScintHits, based on linearized full event readout from test beam/test stand. More...

#include <TestBeamHitProducer.h>

Public Member Functions

 TestBeamHitProducer (const std::string &name, framework::Process &process)
 
void configure (framework::config::Parameters &parameters) override
 Callback for the processor to configure itself from the given set of parameters.
 
void produce (framework::Event &event) override
 Process the event and put new data products into it.
 
- Public Member Functions inherited from framework::Producer
 Producer (const std::string &name, Process &process)
 Class constructor.
 
virtual void process (Event &event) final
 Processing an event for a Producer is calling produce.
 
- 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 beforeNewRun (ldmx::RunHeader &run_header)
 Callback for Producers to add parameters to the run header before conditions are initialized.
 
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 onProcessStart ()
 Callback for the EventProcessor to take any necessary action when the processing of events starts, such as creating histograms.
 
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 input_col_
 Set the local verbosity level.
 
std::string input_pass_name_
 Name of the pass that the input collection is on (empty string means take any pass)
 
std::string output_collection_
 Name of the output collection that will be used to stored the trigger scintillator hits.
 
std::vector< double > gain_
 SiPM gain, per channel (all initialized to 2e6 in default config)
 
std::vector< double > peds_
 channel pedestals [fC]
 
std::vector< double > mip_response_
 channel MIP response for intercalibration
 
int start_sample_ {10}
 start sample for pulse integration (not including any fiber offsets)
 
int pulse_width_ {5}
 Total number of samples used in pulse integration.
 
int pulse_width_lyso_ {8}
 Total number of samples used in pulse integration for LYSO (long decay, might need wider window)
 
int n_instrumented_channels_ {12}
 Number of instrumented channels in module.
 
bool do_clean_hits_ {false}
 boolean indicating whether we want to apply quality criteria in hit reconstruction
 

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
 
NtupleManager & ntuple_ {NtupleManager::getInstance()}
 Manager for any ntuples.
 
logging::logger the_log_
 The logger for this EventProcessor.
 

Detailed Description

Organizes digis into TrigScintHits, based on linearized full event readout from test beam/test stand.

Definition at line 26 of file TestBeamHitProducer.h.

Constructor & Destructor Documentation

◆ TestBeamHitProducer()

trigscint::TestBeamHitProducer::TestBeamHitProducer ( const std::string & name,
framework::Process & process )

Definition at line 17 of file TestBeamHitProducer.cxx.

19 : Producer(name, process) {}
Producer(const std::string &name, Process &process)
Class constructor.
virtual void process(Event &event) final
Processing an event for a Producer is calling produce.

Member Function Documentation

◆ configure()

void trigscint::TestBeamHitProducer::configure ( framework::config::Parameters & parameters)
overridevirtual

Callback for the processor to configure itself from the given set of parameters.

Parameters
parametersParameterSet for configuration.

Reimplemented from framework::EventProcessor.

Definition at line 21 of file TestBeamHitProducer.cxx.

21 {
22 input_col_ = parameters.get<std::string>("input_collection");
23 output_collection_ = parameters.get<std::string>("output_collection");
24 input_pass_name_ = parameters.get<std::string>("input_pass_name");
25 mip_response_ = parameters.get<std::vector<double> >("MIPresponse");
26 peds_ = parameters.get<std::vector<double> >("pedestals");
27 gain_ = parameters.get<std::vector<double> >("gain");
28
29 start_sample_ = parameters.get<int>("start_sample");
30 pulse_width_ = parameters.get<int>("pulse_width");
31 pulse_width_lyso_ = parameters.get<int>("pulse_width_lyso");
32 n_instrumented_channels_ = parameters.get<int>("n_instrumented_channels");
33 do_clean_hits_ = parameters.get<bool>("do_clean_hits");
34
35 std::cout << " [ TestBeamHitProducer ] In configure(), got parameters "
36 << "\n\t inputCollection = " << input_col_
37 << "\n\t inputPassName = " << input_pass_name_
38 << "\n\t outputCollection = " << output_collection_
39 << "\n\t startSample = " << start_sample_
40 << "\n\t pulseWidth = " << pulse_width_
41 << "\n\t pulseWidthLYSO = " << pulse_width_lyso_
42 << "\n\t gain[0] = " << gain_[0]
43 << "\n\t nInstrumentedChannels = " << n_instrumented_channels_
44 << "\n\t doCleanHits = " << do_clean_hits_
45 << "\n\t pedestals[0] = " << peds_[0]
46 << "\n\t MIPresponse[0] = " << mip_response_[0] << "\t."
47 << std::endl;
48
49 return;
50}
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:75
std::string input_pass_name_
Name of the pass that the input collection is on (empty string means take any pass)
std::string output_collection_
Name of the output collection that will be used to stored the trigger scintillator hits.
int pulse_width_
Total number of samples used in pulse integration.
std::vector< double > gain_
SiPM gain, per channel (all initialized to 2e6 in default config)
int start_sample_
start sample for pulse integration (not including any fiber offsets)
bool do_clean_hits_
boolean indicating whether we want to apply quality criteria in hit reconstruction
std::string input_col_
Set the local verbosity level.
int pulse_width_lyso_
Total number of samples used in pulse integration for LYSO (long decay, might need wider window)
int n_instrumented_channels_
Number of instrumented channels in module.
std::vector< double > peds_
channel pedestals [fC]
std::vector< double > mip_response_
channel MIP response for intercalibration

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

◆ produce()

void trigscint::TestBeamHitProducer::produce ( framework::Event & event)
overridevirtual

Process the event and put new data products into it.

Parameters
eventThe Event to process.

Implements framework::Producer.

Definition at line 52 of file TestBeamHitProducer.cxx.

52 {
53 /*
54 hit producer.
55 sum up all charge within a certain time window. could work two ways:
56 - find a time sample above a threshold or where TDC is 0-50 (0-2)
57 * this could allow for finding several pulses per event, just
58 keep sliding along in time
59 -- in that case, record nPulses, startsample, pulsewidth
60 for each hit
61 - use a fixed start sample, and keep summing from there until
62 nSamples is reached or all time samples used
63
64 specifics:
65 - each channel has its own pedestal to subtract. also try using the
66 first 5 samples to establish a threshold in the event. store both
67 - store hit Q and hit PE conversion
68 - for now use the same reconstruction paradigm for LYSO and plastic.
69 two notes though
70 1. LYSO pulse looks wider, and might need wider window. plastic is
71 fine with 5. start by 8 for LYSO (even if for large pulses, sometimes 10
72 seem to be needed). could probe this by correlating plastic and LYSO, and
73 checking if at some amplitude (in plastic), we start cutting off charge in
74 LYSO
75 2. there is a time offset between fibers. need to have a
76 parameter fiber2offset to use for elecID >= 8
77 -- added this as a variable in EventReadout, along with fiber
78 number. so this class doesn't need any detailed knowledge
79
80 variables to write out:
81 - start sample
82 - pulse width
83 - n samples above threshold
84 - nPulses
85 - early pedestal (from first 5)
86 - assumed/average channel pedestal
87 - total Q
88 - ped subtracted total Q
89 - PE value
90 - max amplitude in pulse
91 - store material assumption? isLYSO?
92 */
93
94 float mev_per_mip = 0.3;
95 float pe_per_mip = 100;
96
97 const auto channels{event.getCollection<trigscint::EventReadout>(
99
100 int ev_nb = event.getEventNumber();
101 std::vector<trigscint::TestBeamHit> hits;
102 for (auto chan : channels) {
104 int bar = chan.getChanID();
105 // don't run hit reconstruction on junk signal
106 if (bar >= n_instrumented_channels_) continue;
107 int width = pulse_width_;
108 if (bar % 2 == 0) { // LYSO channel: allow for wider pulses
109 width = pulse_width_lyso_; // avoid hardwiring
110 }
111 hit.setPulseWidth(width);
113 float ped = peds_.at(bar); // chan.getPedestal() ;
114 float early_ped = chan.getEarlyPedestal();
115 hit.setPedestal(ped);
116 hit.setEarlyPedestal(early_ped);
117 int is_clean = 0; // false;
118 float threshold = fabs(ped); // 2*fabs(peds_[ bar ]); // or sth
119 if (do_clean_hits_) threshold = 7 * fabs(ped); // stricter cut
120
121 int start_t = start_sample_ + chan.getTimeOffset();
122 float max_q = -999.;
123 int n_samp_above_ped = 0;
124 int n_samp_above_thr = 0;
125 float tot_subtr_q = 0;
126 std::vector<float> q = chan.getQ();
127 // go to the start sample defined for this channel.
128 for (int i_t = start_t; i_t < q.size(); i_t++) {
129 ldmx_log(debug) << "in event " << ev_nb << "; channel " << bar
130 << ", got charge[" << i_t << "] = " << q.at(i_t);
131 // for the defined number of samples, subtract pedestal. if > 0, increment
132 // sample counter.
133 float sub_q = q.at(i_t) -
134 ped; // this might be addition, if ped is negative. should
135 // see this as channel dependence in nSampAbove
136 // once beyond nSamples, want to see how long positive threshold
137 // subtracted tail is --> increment sample counter in any case.
138 if (sub_q > 0) n_samp_above_ped++;
139 if (sub_q > threshold) n_samp_above_thr++;
140 if (i_t - start_t < width) { // we're in the pulse integration window
141 if (sub_q > max_q) // keep track of max Q. this is the pulse amplitude
142 max_q = sub_q; // q.at(iT);
143 if (sub_q > 0)
144 tot_subtr_q +=
145 sub_q; // add positive subtracted Q to total pulse charge.
146 } else if (sub_q < 0 ||
147 q.at(i_t) < 0) // if after the full pulse width, subQ <
148 // pedestal, break. special case to break at
149 // q=0 for cases where ped < 0
150 break;
151 // done
152 } // over time samples
153
154 // first check that hit passes any quality cuts
155 uint flag = chan.getQualityFlag();
156 if (do_clean_hits_) {
157 // int isLongPulse=(nSampAboveThr < 2 || nSampAboveThr >
158 // width + 2);
159 int is_long_pulse =
160 (n_samp_above_thr >
161 width); // the short ones we'll have to single out otherwise (like
162 // spike flag or low Q) or live with
163 flag += 4 * is_long_pulse;
164 if (max_q > 2e5 && n_samp_above_thr < 3 &&
165 flag % 2 == 0) // this was not flagged as a spike but is eerily
166 // narrow and with high Q; flag it as a spike.
167 flag += 1;
168 if (flag == 0) is_clean = 1;
169 }
170
171 float pe = tot_subtr_q * 6250. / gain_[bar];
172 if (pe > 20) // dont't want to intercalibrate the shot noise
173 pe *= mip_response_[bar];
174
175 // set pulse properties like PE and amplitude
176 hit.setSampAbovePed(n_samp_above_ped);
177 hit.setSampAboveThr(n_samp_above_thr);
178 hit.setQ(tot_subtr_q);
179 hit.setAmplitude(max_q);
180 hit.setPE(pe);
181 hit.setHitQuality(is_clean);
182 hit.setQualityFlag(flag);
183 // set bar id. set moduleNB = 0
184 hit.setBarID(bar);
185 hit.setModuleID(0); // test beam
186 // the rest are a little ill-defined for now (PE-energy conversion not
187 // known/different between LYSO and plastic)
188 hit.setTime(-999); // maybe?
189 hit.setBeamEfrac(-1.);
190 hit.setEnergy(hit.getPE() * mev_per_mip / pe_per_mip);
191
192 // add hit
193 hits.push_back(hit);
194 } // over channels
195
196 // at end of event, write the collection of trigger scintillator hits.
197 event.add(output_collection_, hits);
198
199 return;
200}
void setTime(float time)
Set the time of the hit [ns].
void setAmplitude(float amplitude)
Set the amplitude of the hit, which is proportional to the signal in the calorimeter cell without sam...
void setEnergy(float energy)
Set the calorimetric energy of the hit, corrected for sampling factors [MeV].
void setPE(const float PE)
Set hit pe.
void setBarID(const int barID)
Set hit bar ID.
void setBeamEfrac(const float beamEfrac)
Set beam energy fraction of hit.
float getPE() const
Get the hit pe.
void setModuleID(const int moduleID)
Set hit module ID.
This class represents the linearised QIE output from the trigger scintillator, in charge (fC).
This class represents the linearised QIE output from the trigger scintillator, in charge (fC).
Definition TestBeamHit.h:24
void setQualityFlag(const uint flag)
Set hit data quality flag.
void setHitQuality(const int isClean)
Set whether hit has been checked for and passed quality criteria.
void setSampAbovePed(const int sampAbovePed)
Set number of samples above pedestal in pulse/hit.
void setQ(const float q)
Store total charge.
Definition TestBeamHit.h:73
void setSampAboveThr(const int sampAboveThr)
Set number of samples above threshold in pulse/hit.
void setPulseWidth(const int pulseWidth)
Set width used to integrate pulse/hit (in time samples)
void setPedestal(const float pedestal)
Set channel (linearized.
Definition TestBeamHit.h:51
void setEarlyPedestal(const float earlyPed)
Set channel (linearized.
Definition TestBeamHit.h:63
void setStartSample(const int startSample)
Store total charge.
Definition TestBeamHit.h:96

References ldmx::TrigScintHit::getPE(), ldmx::CalorimeterHit::setAmplitude(), ldmx::TrigScintHit::setBarID(), ldmx::TrigScintHit::setBeamEfrac(), trigscint::TestBeamHit::setEarlyPedestal(), ldmx::CalorimeterHit::setEnergy(), trigscint::TestBeamHit::setHitQuality(), ldmx::TrigScintHit::setModuleID(), ldmx::TrigScintHit::setPE(), trigscint::TestBeamHit::setPedestal(), trigscint::TestBeamHit::setPulseWidth(), trigscint::TestBeamHit::setQ(), trigscint::TestBeamHit::setQualityFlag(), trigscint::TestBeamHit::setSampAbovePed(), trigscint::TestBeamHit::setSampAboveThr(), trigscint::TestBeamHit::setStartSample(), and ldmx::CalorimeterHit::setTime().

Member Data Documentation

◆ do_clean_hits_

bool trigscint::TestBeamHitProducer::do_clean_hits_ {false}
private

boolean indicating whether we want to apply quality criteria in hit reconstruction

Definition at line 80 of file TestBeamHitProducer.h.

80{false};

◆ gain_

std::vector<double> trigscint::TestBeamHitProducer::gain_
private

SiPM gain, per channel (all initialized to 2e6 in default config)

Definition at line 57 of file TestBeamHitProducer.h.

◆ input_col_

std::string trigscint::TestBeamHitProducer::input_col_
private

Set the local verbosity level.

Name of the input collection containing the event readout samples

Definition at line 46 of file TestBeamHitProducer.h.

◆ input_pass_name_

std::string trigscint::TestBeamHitProducer::input_pass_name_
private

Name of the pass that the input collection is on (empty string means take any pass)

Definition at line 50 of file TestBeamHitProducer.h.

◆ mip_response_

std::vector<double> trigscint::TestBeamHitProducer::mip_response_
private

channel MIP response for intercalibration

Definition at line 63 of file TestBeamHitProducer.h.

◆ n_instrumented_channels_

int trigscint::TestBeamHitProducer::n_instrumented_channels_ {12}
private

Number of instrumented channels in module.

Definition at line 76 of file TestBeamHitProducer.h.

76{12};

◆ output_collection_

std::string trigscint::TestBeamHitProducer::output_collection_
private

Name of the output collection that will be used to stored the trigger scintillator hits.

Definition at line 54 of file TestBeamHitProducer.h.

◆ peds_

std::vector<double> trigscint::TestBeamHitProducer::peds_
private

channel pedestals [fC]

Definition at line 60 of file TestBeamHitProducer.h.

◆ pulse_width_

int trigscint::TestBeamHitProducer::pulse_width_ {5}
private

Total number of samples used in pulse integration.

Definition at line 69 of file TestBeamHitProducer.h.

69{5};

◆ pulse_width_lyso_

int trigscint::TestBeamHitProducer::pulse_width_lyso_ {8}
private

Total number of samples used in pulse integration for LYSO (long decay, might need wider window)

Definition at line 73 of file TestBeamHitProducer.h.

73{8};

◆ start_sample_

int trigscint::TestBeamHitProducer::start_sample_ {10}
private

start sample for pulse integration (not including any fiber offsets)

Definition at line 66 of file TestBeamHitProducer.h.

66{10};

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