LDMX Software
Public Member Functions | Private Attributes | List of all members
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 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 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

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

Constructor & Destructor Documentation

◆ HcalDoubleEndRecProducer()

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

Definition at line 35 of file HcalDoubleEndRecProducer.h.

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

References coll_name_, hcal::HcalReconConditions::CONDITIONS_NAME, ldmx::HcalGeometry::CONDITIONS_OBJECT_NAME, 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 32 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 21 of file HcalDoubleEndRecProducer.h.

21{"HcalRecHits"};

Referenced by configure(), and produce().

◆ mip_energy_

double hcal::HcalDoubleEndRecProducer::mip_energy_
private

energy per MIP [MeV]

Definition at line 30 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 19 of file HcalDoubleEndRecProducer.h.

19{""};

Referenced by configure(), and produce().

◆ pe_per_mip_

double hcal::HcalDoubleEndRecProducer::pe_per_mip_
private

number of PEs per MIP

Definition at line 28 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 25 of file HcalDoubleEndRecProducer.h.

25{"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 23 of file HcalDoubleEndRecProducer.h.

23{""};

Referenced by configure().


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