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

Public Member Functions

 HcalSingleEndRecProducer (const std::string &n, framework::Process &p)
 
void configure (framework::config::Parameters &p) override
 Callback for the EventProcessor 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 beforeNewRun (ldmx::RunHeader &header)
 Handle allowing producers to modify run headers before the run begins.
 
- 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.
 
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 Member Functions

std::tuple< double, double, int > extract_measurements (const ldmx::HgcrocDigiCollection::HgcrocDigi &digi, double pedestal, double bx_shift)
 extract toa, sum adc, and sum tot from the input raw digi
 

Private Attributes

std::string pass_name_ {""}
 name of pass of digis to use
 
std::string coll_name_ {"HcalDigis"}
 name of digis to reconstruct
 
std::string rec_pass_name_ {""}
 name of pass of rechits to use
 
std::string rec_coll_name_ {"HcalRecHits"}
 name of rechits to reconstruct
 
double pe_per_mip_
 number of PEs per MIP
 
double mip_energy_
 energy per MIP [MeV]
 
double clock_cycle_
 length of clock cycle [ns]
 
unsigned int isoi_
 sample of interest index
 

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::Producer
static const int CLASSTYPE {1}
 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 15 of file HcalSingleEndRecProducer.h.

Constructor & Destructor Documentation

◆ HcalSingleEndRecProducer()

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

Definition at line 64 of file HcalSingleEndRecProducer.h.

65 : Producer(n, p) {}
Producer(const std::string &name, Process &process)
Class constructor.

Member Function Documentation

◆ configure()

void hcal::HcalSingleEndRecProducer::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 className equal to the EventProcessor class name.

For an example, look at MyProcessor.

Parameters
parametersParameters for configuration.

Reimplemented from framework::EventProcessor.

Definition at line 57 of file HcalSingleEndRecProducer.cxx.

57 {
58 pass_name_ = p.getParameter("pass_name", pass_name_);
59 coll_name_ = p.getParameter("coll_name", coll_name_);
60
61 rec_pass_name_ = p.getParameter("rec_pass_name", rec_pass_name_);
62 rec_coll_name_ = p.getParameter("rec_coll_name", rec_coll_name_);
63
64 pe_per_mip_ = p.getParameter<double>("pe_per_mip");
65 mip_energy_ = p.getParameter<double>("mip_energy");
66 clock_cycle_ = p.getParameter<double>("clock_cycle");
67}
double mip_energy_
energy per MIP [MeV]
double pe_per_mip_
number of PEs per MIP
std::string pass_name_
name of pass of digis to use
std::string rec_coll_name_
name of rechits to reconstruct
std::string coll_name_
name of digis to reconstruct
double clock_cycle_
length of clock cycle [ns]
std::string rec_pass_name_
name of pass of rechits to use

References clock_cycle_, coll_name_, framework::config::Parameters::getParameter(), mip_energy_, pass_name_, pe_per_mip_, rec_coll_name_, and rec_pass_name_.

◆ extract_measurements()

std::tuple< double, double, int > hcal::HcalSingleEndRecProducer::extract_measurements ( const ldmx::HgcrocDigiCollection::HgcrocDigi digi,
double  pedestal,
double  bx_shift 
)
private

extract toa, sum adc, and sum tot from the input raw digi

in the far future, we can make these member functions ofthe HgcrocDigi class; however, right now as we develop our reconstruction method it is helpful to have more flexible control on how we extract these measurements

with C++17 structured bindings, this tuple return can be bound to separate variables:

auto [ toa, sum_adc, sum_tot ] =
extract_measurements(digi,pedestal,bx_shift);
std::tuple< double, double, int > extract_measurements(const ldmx::HgcrocDigiCollection::HgcrocDigi &digi, double pedestal, double bx_shift)
extract toa, sum adc, and sum tot from the input raw digi

giving us the dual benefit of separate variable names while only having to loop over the samples within a single digi once

Uses isoi_ and clock_cycle_ member variables to convert TOA into ns since beginning of Sample Of Interest (SOI)

Parameters
[in]digihandle to HgcrocDigi to extract from
[in]pedestalpedestal for this channel
[in]shiftin BX associated to TOA for this channel
Returns
tuple of (toa [ns since SOI], sum_adc, sum_tot)

Definition at line 4 of file HcalSingleEndRecProducer.cxx.

6 {
7 // sum_adc = total of all but first in-time adc measurements
8 double sum_adc{0};
9 // sum_tot = total of all tot measurements
10 int sum_tot{0};
11 // first, get time of arrival w.r.t to start BX
12 int toa_sample{0}, toa_startbx{0};
13 // get the correction for the wrong BX assignment
14 // TODO: Currently not used anywhere
15 [[maybe_unused]] int bx_to_time{0};
16 // and figure out sample of maximum amplitude
17 // TODO: Currently not used anywhere
18 [[maybe_unused]] int max_sample{0};
19 double max_meas{0};
20 for (std::size_t i_sample{0}; i_sample < digi.size(); i_sample++) {
21 // adc logic
22 if (i_sample > 0) sum_adc += (digi.at(i_sample).adc_t() - pedestal);
23
24 // tot logic
25 sum_tot += digi.at(i_sample).tot();
26
27 // toa logic
28 if (digi.at(i_sample).toa() > 0) {
29 if (digi.at(i_sample).toa() >= bx_shift) {
30 toa_sample = i_sample;
31 } else {
32 toa_sample = i_sample + 1;
33 }
34
35 // sum toa in given bx - given that multiple bx may be associated with the
36 // TOA measurement
37 toa_startbx += digi.at(i_sample).toa() * (clock_cycle_ / 1024) +
38 (clock_cycle_ * toa_sample);
39 }
40
41 if (digi.at(i_sample).adc_t() - pedestal > max_meas) {
42 max_meas = digi.at(i_sample).adc_t() - pedestal;
43 max_sample = i_sample;
44 }
45 }
46 // get toa
47 double toa = toa_startbx;
48
49 // get toa w.r.t the peak
50 // double toa = (max_sample - toa_sample) * clock_cycle_ - toa_startbx;
51 // get toa w.r.t the SOI
52 // toa += ((int)isoi_ - max_sample) * clock_cycle_;
53
54 return std::make_tuple(toa, sum_adc, sum_tot);
55}
HgcrocDigiCollection::Sample at(unsigned int i_sample) const
get the sample at a specific index in the digi
int adc_t() const
Get the ADC measurement from this sample.
int tot() const
Get the TOT measurement from this sample.
int toa() const
Get the Time Of Arrival of this sample which is always the third position in all readout modes.

References ldmx::HgcrocDigiCollection::Sample::adc_t(), ldmx::HgcrocDigiCollection::HgcrocDigi::at(), clock_cycle_, ldmx::HgcrocDigiCollection::Sample::toa(), and ldmx::HgcrocDigiCollection::Sample::tot().

Referenced by produce().

◆ produce()

void hcal::HcalSingleEndRecProducer::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 69 of file HcalSingleEndRecProducer.cxx.

69 {
70 const auto& hcalGeometry = getCondition<ldmx::HcalGeometry>(
72
73 const auto& conditions{
74 getCondition<HcalReconConditions>(HcalReconConditions::CONDITIONS_NAME)};
75
76 auto hcalDigis =
78
79 std::vector<ldmx::HcalHit> hcalRecHits;
80
81 isoi_ = hcalDigis.getSampleOfInterestIndex();
82
83 for (auto const& digi : hcalDigis) {
84 ldmx::HcalDigiID id_digi(digi.id());
85 ldmx::HcalID id(id_digi.section(), id_digi.layer(), id_digi.strip());
86
87 // amplitude/TOT reconstruction
88 double num_mips_equivalent{0};
89 auto [toa, sum_adc, sum_tot] =
90 extract_measurements(digi, conditions.adcPedestal(digi.id()),
91 conditions.toaCalib(digi.id(), 0));
92 auto is_adc = conditions.is_adc(digi.id(), sum_tot);
93 if (is_adc) {
94 double adc_calib = sum_adc / conditions.adcGain(digi.id(), 0);
95 num_mips_equivalent = adc_calib;
96 } else {
97 double tot_calib = conditions.linearize(digi.id(), sum_tot);
98 num_mips_equivalent = tot_calib / conditions.adcGain(digi.id(), 0);
99 }
100 int PEs = num_mips_equivalent * pe_per_mip_;
101 double reconstructed_energy =
102 num_mips_equivalent * pe_per_mip_ * mip_energy_;
103
104 // time reconstruction
105 double hitTime = toa;
106
107 // position single ended (taken directly from geometry)
108 auto position = hcalGeometry.getStripCenterPosition(id);
109
110 // reconstructed Hit
111 ldmx::HcalHit recHit;
112 recHit.setID(id.raw());
113 recHit.setXPos(position.X());
114 recHit.setYPos(position.Y());
115 recHit.setZPos(position.Z());
116 recHit.setSection(id.section());
117 recHit.setStrip(id.strip());
118 recHit.setLayer(id.layer());
119 recHit.setEnd(id_digi.end());
120 recHit.setPE(PEs);
121 recHit.setMinPE(PEs);
122 recHit.setAmplitude(num_mips_equivalent);
123 recHit.setEnergy(reconstructed_energy);
124 recHit.setTime(hitTime);
125 recHit.setIsADC(is_adc);
126 hcalRecHits.push_back(recHit);
127 }
128
129 // add collection to event bus
130 event.add(rec_coll_name_, hcalRecHits);
131}
static const std::string CONDITIONS_NAME
the name of the HcalReconConditions table (must match python registration name)
unsigned int isoi_
sample of interest index
void setYPos(float ypos)
Set the Y position of the hit [mm].
void setID(int id)
Set the detector ID.
void setZPos(float zpos)
Set the Z position of the hit [mm].
void setXPos(float xpos)
Set the X position of the hit [mm].
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].
Extension of HcalAbstractID providing access to HCal digi information.
Definition HcalDigiID.h:13
static constexpr const char * CONDITIONS_OBJECT_NAME
Conditions object: The name of the python configuration calling this class (Hcal/python/HcalGeometry....
Stores reconstructed hit information from the HCAL.
Definition HcalHit.h:23
void setSection(int section)
Set the section for this hit.
Definition HcalHit.h:132
void setEnd(int end)
Set the end (0 neg, 1 pos side).
Definition HcalHit.h:150
void setIsADC(int isADC)
Set if the hit is reconstructed using ADC.
Definition HcalHit.h:156
void setMinPE(float minpe)
Set the minimum number of photoelectrons estimated for this hit.
Definition HcalHit.h:126
void setStrip(int strip)
Set the strip for this hit.
Definition HcalHit.h:144
void setLayer(int layer)
Set the layer for this hit.
Definition HcalHit.h:138
void setPE(float pe)
Set the number of photoelectrons estimated for this hit.
Definition HcalHit.h:119
Implements detector ids for HCal subdetector.
Definition HcalID.h:19
Represents a collection of the digi hits readout by an HGCROC.
unsigned int getSampleOfInterestIndex() const
Get index of sample of interest.

References coll_name_, hcal::HcalReconConditions::CONDITIONS_NAME, ldmx::HcalGeometry::CONDITIONS_OBJECT_NAME, ldmx::HcalDigiID::end(), extract_measurements(), ldmx::HgcrocDigiCollection::getSampleOfInterestIndex(), isoi_, ldmx::HcalDigiID::layer(), mip_energy_, pass_name_, pe_per_mip_, rec_coll_name_, ldmx::HcalDigiID::section(), ldmx::CalorimeterHit::setAmplitude(), ldmx::HcalHit::setEnd(), ldmx::CalorimeterHit::setEnergy(), ldmx::CalorimeterHit::setID(), ldmx::HcalHit::setIsADC(), ldmx::HcalHit::setLayer(), ldmx::HcalHit::setMinPE(), ldmx::HcalHit::setPE(), ldmx::HcalHit::setSection(), ldmx::HcalHit::setStrip(), ldmx::CalorimeterHit::setTime(), ldmx::CalorimeterHit::setXPos(), ldmx::CalorimeterHit::setYPos(), ldmx::CalorimeterHit::setZPos(), and ldmx::HcalDigiID::strip().

Member Data Documentation

◆ clock_cycle_

double hcal::HcalSingleEndRecProducer::clock_cycle_
private

length of clock cycle [ns]

Definition at line 30 of file HcalSingleEndRecProducer.h.

Referenced by configure(), and extract_measurements().

◆ coll_name_

std::string hcal::HcalSingleEndRecProducer::coll_name_ {"HcalDigis"}
private

name of digis to reconstruct

Definition at line 19 of file HcalSingleEndRecProducer.h.

19{"HcalDigis"};

Referenced by configure(), and produce().

◆ isoi_

unsigned int hcal::HcalSingleEndRecProducer::isoi_
private

sample of interest index

Definition at line 32 of file HcalSingleEndRecProducer.h.

Referenced by produce().

◆ mip_energy_

double hcal::HcalSingleEndRecProducer::mip_energy_
private

energy per MIP [MeV]

Definition at line 28 of file HcalSingleEndRecProducer.h.

Referenced by configure(), and produce().

◆ pass_name_

std::string hcal::HcalSingleEndRecProducer::pass_name_ {""}
private

name of pass of digis to use

Definition at line 17 of file HcalSingleEndRecProducer.h.

17{""};

Referenced by configure(), and produce().

◆ pe_per_mip_

double hcal::HcalSingleEndRecProducer::pe_per_mip_
private

number of PEs per MIP

Definition at line 26 of file HcalSingleEndRecProducer.h.

Referenced by configure(), and produce().

◆ rec_coll_name_

std::string hcal::HcalSingleEndRecProducer::rec_coll_name_ {"HcalRecHits"}
private

name of rechits to reconstruct

Definition at line 23 of file HcalSingleEndRecProducer.h.

23{"HcalRecHits"};

Referenced by configure(), and produce().

◆ rec_pass_name_

std::string hcal::HcalSingleEndRecProducer::rec_pass_name_ {""}
private

name of pass of rechits to use

Definition at line 21 of file HcalSingleEndRecProducer.h.

21{""};

Referenced by configure().


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