LDMX Software
hcal::HcalDoubleEndRecProducer Class Reference

Public Member Functions

 HcalDoubleEndRecProducer (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 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 pass_name_ {""}
 name of pass of rechits to use
 
std::string coll_name_ {"HcalRecHits"}
 name of rechits to use as input
 
std::string rec_pass_name_ {""}
 name of pass of rechits to reconstruct
 
std::string rec_coll_name_ {"HcalRecHitsDoubleEnd"}
 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]
 

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 17 of file HcalDoubleEndRecProducer.h.

Constructor & Destructor Documentation

◆ HcalDoubleEndRecProducer()

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

Definition at line 19 of file HcalDoubleEndRecProducer.h.

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

Member Function Documentation

◆ configure()

void hcal::HcalDoubleEndRecProducer::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 5 of file HcalDoubleEndRecProducer.cxx.

5 {
6 pass_name_ = p.getParameter("pass_name", pass_name_);
7 coll_name_ = p.getParameter("coll_name", coll_name_);
8
9 rec_pass_name_ = p.getParameter("rec_pass_name", pass_name_);
10 rec_coll_name_ = p.getParameter("rec_coll_name", coll_name_);
11
12 pe_per_mip_ = p.get<double>("pe_per_mip");
13 mip_energy_ = p.get<double>("mip_energy");
14 clock_cycle_ = p.get<double>("clock_cycle");
15}
std::string pass_name_
name of pass of rechits to use
std::string rec_coll_name_
name of rechits to reconstruct
std::string rec_pass_name_
name of pass of rechits to reconstruct
double mip_energy_
energy per MIP [MeV]
double pe_per_mip_
number of PEs per MIP
std::string coll_name_
name of rechits to use as input
double clock_cycle_
length of clock cycle [ns]

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

◆ produce()

void hcal::HcalDoubleEndRecProducer::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 17 of file HcalDoubleEndRecProducer.cxx.

17 {
18 const auto& hcal_geometry = getCondition<ldmx::HcalGeometry>(
20
21 const auto& conditions{
23
24 auto hcal_rec_hits =
25 event.getCollection<ldmx::HcalHit>(coll_name_, pass_name_);
26
27 std::vector<ldmx::HcalHit> double_hcal_rec_hits;
28
29 // group hcal rechits by the same HcalID
30 std::map<ldmx::HcalID, std::vector<ldmx::HcalHit>> hits_by_id;
31 for (auto const& hit : hcal_rec_hits) {
32 ldmx::HcalID id(hit.getSection(), hit.getLayer(), hit.getStrip());
33
34 auto idh = hits_by_id.find(id);
35 if (idh == hits_by_id.end()) {
36 hits_by_id[id] = std::vector<ldmx::HcalHit>(1, hit);
37 } else {
38 idh->second.push_back(hit);
39 }
40 }
41
42 // make pairs of hcal rechits indices that belong to the same pulse
43 // @TODO: for now we just take the first two indices that have opposite-ends
44 // we do not cover the case where two hits_ come separated in time
45 std::map<ldmx::HcalID, std::pair<int, int>> indices_by_id;
46 for (auto const& hcal_bar : hits_by_id) {
47 auto id = hcal_bar.first;
48
49 std::pair<int, int> indices(-1, -1);
50 int i_hit = 0;
51 while (i_hit < hcal_bar.second.size()) {
52 auto hit = hcal_bar.second.at(i_hit);
53
54 ldmx::HcalDigiID digi_id(hit.getSection(), hit.getLayer(), hit.getStrip(),
55 hit.getEnd());
56 if (digi_id.isNegativeEnd() && indices.second == -1) {
57 indices.second = i_hit;
58 }
59 if (!digi_id.isNegativeEnd() && indices.first == -1) {
60 indices.first = i_hit;
61 }
62 i_hit++;
63 }
64 indices_by_id[id] = indices;
65 }
66
67 // reconstruct double-ended hits_
68 for (auto const& hcal_bar : hits_by_id) {
69 auto id = hcal_bar.first;
70
71 // get bar position from geometry
72 auto position = hcal_geometry.getStripCenterPosition(id);
73 const auto orientation{hcal_geometry.getScintillatorOrientation(id)};
74 int orientation_int = static_cast<int>(orientation);
75
76 // skip non-double-ended layers
77 if (id.section() != ldmx::HcalID::HcalSection::BACK) continue;
78
79 // get two hits_ to reconstruct
80 auto hit_pos_end = hcal_bar.second.at(indices_by_id[id].first);
81 auto hit_neg_end = hcal_bar.second.at(indices_by_id[id].second);
82
83 // update TOA hit with negative end with mean shift
84 ldmx::HcalDigiID digi_id_pos(hit_pos_end.getSection(),
85 hit_pos_end.getLayer(), hit_pos_end.getStrip(),
86 hit_pos_end.getEnd());
87 ldmx::HcalDigiID digi_id_neg(hit_neg_end.getSection(),
88 hit_neg_end.getLayer(), hit_neg_end.getStrip(),
89 hit_neg_end.getEnd());
90 double mean_shift = conditions.toaCalib(digi_id_neg.raw(), 1);
91
92 double pos_time = hit_pos_end.getTime();
93 double neg_time = hit_neg_end.getTime();
94 if (pos_time != 0 || neg_time != 0) {
95 neg_time = neg_time - mean_shift;
96 }
97
98 // update position in strip according to time measurement
99 // velocity of light in polystyrene, n = 1.6 = c/v
100 double v = 299.792 / 1.6;
101 double hit_time_diff = pos_time - neg_time;
102
103 ldmx_log(trace) << "\n new hit ";
104 ldmx_log(trace) << "strip " << id.strip() << " layer_ " << id.layer()
105 << "center position X = " << position.X()
106 << " Y =" << position.Y() << " Z = " << position.Z();
107 ldmx_log(trace) << "hittime pos_ " << pos_time << "neg " << neg_time
108 << " bar sign " << " diff " << hit_time_diff;
109
110 int position_bar_sign = hit_time_diff > 0 ? 1 : -1;
111 double position_unchanged = 0;
112 double position_bar = position_bar_sign * fabs(hit_time_diff) * v / 2;
113 if (orientation ==
114 ldmx::HcalGeometry::ScintillatorOrientation::horizontal) {
115 position_unchanged = position.X();
116 position.SetX(position_bar);
117 } else {
118 position_unchanged = position.Y();
119 position.SetY(position_bar);
120 }
121 ldmx_log(trace) << "position unchanged " << position_unchanged
122 << " orientation = " << orientation_int;
123 ldmx_log(trace) << "newposition X = " << position.X()
124 << " Y = " << position.Y() << " Z = " << position.Z();
125
126 // TODO: switch unique hit time for this pulse
127 [[maybe_unused]] double hit_time =
128 (hit_pos_end.getTime() + hit_neg_end.getTime());
129
130 // amplitude and PEs
131 double num_mips_equivalent =
132 (hit_pos_end.getAmplitude() + hit_neg_end.getAmplitude());
133 double p_es = (hit_pos_end.getPE() + hit_neg_end.getPE());
134 double reconstructed_energy =
135 num_mips_equivalent * pe_per_mip_ * mip_energy_;
136
137 // reconstructed Hit
138 ldmx::HcalHit rec_hit;
139 rec_hit.setID(id.raw());
140 rec_hit.setXPos(position.X());
141 rec_hit.setYPos(position.Y());
142 rec_hit.setZPos(position.Z());
143 rec_hit.setSection(id.section());
144 rec_hit.setStrip(id.strip());
145 rec_hit.setLayer(id.layer());
146 rec_hit.setPE(p_es);
147 rec_hit.setMinPE(std::min(hit_pos_end.getPE(), hit_neg_end.getPE()));
148 rec_hit.setAmplitude(num_mips_equivalent);
149 rec_hit.setAmplitudePos(hit_pos_end.getAmplitude());
150 rec_hit.setAmplitudeNeg(hit_neg_end.getAmplitude());
151 rec_hit.setToaPos(hit_pos_end.getTime());
152 rec_hit.setToaNeg(hit_neg_end.getTime());
153 rec_hit.setEnergy(reconstructed_energy);
154 rec_hit.setTime(hit_time_diff);
155 rec_hit.setTimeDiff(hit_pos_end.getTime() - hit_neg_end.getTime());
156 rec_hit.setPositionUnchanged(position_unchanged, orientation_int);
157 double_hcal_rec_hits.push_back(rec_hit);
158 }
159
160 // add collection to event bus
161 event.add(rec_coll_name_, double_hcal_rec_hits);
162}
const T & getCondition(const std::string &condition_name)
Access a conditions object for the current event.
static const std::string CONDITIONS_NAME
the name of the HcalReconConditions table (must match python registration name)
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:24
void setSection(int section)
Set the section for this hit.
Definition HcalHit.h:166
void setPositionUnchanged(double position, int orientation)
Set original position.
Definition HcalHit.h:225
void setToaNeg(double toaNeg)
Set toa of the negative end.
Definition HcalHit.h:208
void setTimeDiff(double timeDiff)
Set time difference (uncorrected)
Definition HcalHit.h:196
void setMinPE(float minpe)
Set the minimum number of photoelectrons estimated for this hit.
Definition HcalHit.h:160
void setToaPos(double toaPos)
Set toa of the positive end.
Definition HcalHit.h:202
void setAmplitudeNeg(double amplitudeNeg)
Set amplitude of the negative end.
Definition HcalHit.h:220
void setStrip(int strip)
Set the strip for this hit.
Definition HcalHit.h:178
void setAmplitudePos(double amplitudePos)
Set amplitude of the positive end.
Definition HcalHit.h:214
void setLayer(int layer)
Set the layer for this hit.
Definition HcalHit.h:172
void setPE(float pe)
Set the number of photoelectrons estimated for this hit.
Definition HcalHit.h:153
Implements detector ids for HCal subdetector.
Definition HcalID.h:19

References coll_name_, hcal::HcalReconConditions::CONDITIONS_NAME, ldmx::HcalGeometry::CONDITIONS_OBJECT_NAME, framework::EventProcessor::getCondition(), ldmx::HcalDigiID::isNegativeEnd(), mip_energy_, pass_name_, pe_per_mip_, ldmx::DetectorID::raw(), rec_coll_name_, ldmx::CalorimeterHit::setAmplitude(), ldmx::HcalHit::setAmplitudeNeg(), ldmx::HcalHit::setAmplitudePos(), ldmx::CalorimeterHit::setEnergy(), ldmx::CalorimeterHit::setID(), ldmx::HcalHit::setLayer(), ldmx::HcalHit::setMinPE(), ldmx::HcalHit::setPE(), ldmx::HcalHit::setPositionUnchanged(), ldmx::HcalHit::setSection(), ldmx::HcalHit::setStrip(), ldmx::CalorimeterHit::setTime(), ldmx::HcalHit::setTimeDiff(), ldmx::HcalHit::setToaNeg(), ldmx::HcalHit::setToaPos(), ldmx::CalorimeterHit::setXPos(), ldmx::CalorimeterHit::setYPos(), and ldmx::CalorimeterHit::setZPos().

Member Data Documentation

◆ clock_cycle_

double hcal::HcalDoubleEndRecProducer::clock_cycle_
private

length of clock cycle [ns]

Definition at line 41 of file HcalDoubleEndRecProducer.h.

Referenced by configure().

◆ coll_name_

std::string hcal::HcalDoubleEndRecProducer::coll_name_ {"HcalRecHits"}
private

name of rechits to use as input

Definition at line 30 of file HcalDoubleEndRecProducer.h.

30{"HcalRecHits"};

Referenced by configure(), and produce().

◆ mip_energy_

double hcal::HcalDoubleEndRecProducer::mip_energy_
private

energy per MIP [MeV]

Definition at line 39 of file HcalDoubleEndRecProducer.h.

Referenced by configure(), and produce().

◆ pass_name_

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

name of pass of rechits to use

Definition at line 28 of file HcalDoubleEndRecProducer.h.

28{""};

Referenced by configure(), and produce().

◆ pe_per_mip_

double hcal::HcalDoubleEndRecProducer::pe_per_mip_
private

number of PEs per MIP

Definition at line 37 of file HcalDoubleEndRecProducer.h.

Referenced by configure(), and produce().

◆ rec_coll_name_

std::string hcal::HcalDoubleEndRecProducer::rec_coll_name_ {"HcalRecHitsDoubleEnd"}
private

name of rechits to reconstruct

Definition at line 34 of file HcalDoubleEndRecProducer.h.

34{"HcalRecHitsDoubleEnd"};

Referenced by configure(), and produce().

◆ rec_pass_name_

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

name of pass of rechits to reconstruct

Definition at line 32 of file HcalDoubleEndRecProducer.h.

32{""};

Referenced by configure().


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