LDMX Software
trigger::TrigHcalEnergySum Class Reference

Public Types

typedef ap_ufixed< 16, 14 > e_t
 

Public Member Functions

 TrigHcalEnergySum (const std::string &name, framework::Process &process)
 
virtual void configure (framework::config::Parameters &ps)
 Callback for the EventProcessor to configure itself from the given set of parameters.
 
virtual void produce (framework::Event &event)
 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 in_proc_
 
std::string quad_coll_name_
 
std::string combined_quad_coll_name_
 

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

Definition at line 24 of file TrigHcalEnergySum.h.

Member Typedef Documentation

◆ e_t

Definition at line 33 of file TrigHcalEnergySum.h.

Constructor & Destructor Documentation

◆ TrigHcalEnergySum()

trigger::TrigHcalEnergySum::TrigHcalEnergySum ( const std::string & name,
framework::Process & process )
inline

Definition at line 26 of file TrigHcalEnergySum.h.

Base class for a module which produces a data product.
virtual void process(Event &event) final
Processing an event for a Producer is calling produce.

Member Function Documentation

◆ configure()

void trigger::TrigHcalEnergySum::configure ( framework::config::Parameters & parameters)
virtual

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 class_name equal to the EventProcessor class name.

For an example, look at MyProcessor.

Parameters
parametersParameters for configuration.

Reimplemented from framework::EventProcessor.

Definition at line 9 of file TrigHcalEnergySum.cxx.

9 {
10 in_proc_ = ps.get<std::string>("input_proc");
11 quad_coll_name_ = ps.get<std::string>("quad_coll_name");
12 combined_quad_coll_name_ = ps.get<std::string>("combined_quad_coll_name");
13}

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

◆ produce()

void trigger::TrigHcalEnergySum::produce ( framework::Event & event)
virtual

Process the event and put new data products into it.

Parameters
eventThe Event to process.

Implements framework::Producer.

Definition at line 14 of file TrigHcalEnergySum.cxx.

14 {
15 // mV/ADC: 1.2
16 // MeV/MIP: 4.66
17 // PE/MIP: 68 (summed over BOTH ends, based on 1808.05219, p38)
18 // mV/PE: 5
19 // mV/MeV: 72.961 (= 5*68/4.66)
20 // const float mV_per_adc = 1.2;
21 // adc gain
22 // these are unused, should they be? FIXME
23 // const float pe_per_adc = mV_per_adc / 5;
24 // const float MeV_per_adc = mV_per_adc / 72.961;
25 // const float samp_frac = 371/4e3; // ad-hoc, from a 4 GeV neutron sample
26
27 // interaction length in Fe ('steel') = 16.77 cm (132.1 g/cm2)
28 // polystyrene = 77.07 cm (81.7 g/cm2)
29 // back hcal is 20mm bar, 25mm absorber
30 // these are unused, should they be? FIXME
31 // const float had_samp_frac =
32 // (20 / 77.07) / (20 / 77.07 + 25 / 16.77); // 0.148266
33 // const float em_samp_frac =
34 // (20 / 41.31) / (20 / 41.31 + 25 / 1.757); // 0.032906
35 // const float samp_frac = (em_samp_frac + 2 * had_samp_frac) / 3; //
36 // 0.109813 const float attenuation = exp(-1 / 5.); // 5m attenuation length,
37 // 1m half-bar
38
39 // for(auto t : event.searchProducts("","","")) std::cout << t.name() << " "
40 // << t.passname() << " " << t.type() << std::endl;
41
42 if (!event.exists(quad_coll_name_, in_proc_)) {
43 // std::cout << "missing collection! : " << quad_coll_name_ << " " <<
44 // in_proc_
45 // << std::endl;
46 return;
47 }
48
49 // auto
50 // oneEndedQuads{event.getObject<ldmx::CaloTrigPrimCollection>(quad_coll_name_)};
51 const std::vector<ldmx::CaloTrigPrim> one_ended_quads =
52 event.getCollection<ldmx::CaloTrigPrim>(quad_coll_name_, in_proc_);
53
54 //
55 // sum bar ends to produce the combined quads
56 std::map<int, ldmx::CaloTrigPrim> two_ended_quad_map;
57 for (const auto& one_ended_quad : one_ended_quads) {
58 const ldmx::HcalTriggerID end_id(one_ended_quad.getId());
59 ldmx::HcalTriggerID combo_id(end_id.section(), end_id.layer(),
60 end_id.superstrip(), 2);
61 auto ptr = two_ended_quad_map.find(combo_id.raw());
62 if (ptr == two_ended_quad_map.end()) {
63 two_ended_quad_map[combo_id.raw()] = one_ended_quad;
64 } else {
65 ptr->second.setPrimitive(ptr->second.getPrimitive() +
66 one_ended_quad.getPrimitive());
67 }
68 }
69 ldmx::CaloTrigPrimCollection two_ended_quads;
70 for (auto p : two_ended_quad_map) two_ended_quads.push_back(p.second);
71 event.add(combined_quad_coll_name_, two_ended_quads);
72
73 //
74 // Produce the layer-by-layer energy sums
75 const unsigned int layer_max = 50;
76 const unsigned int side_layer_max = 16;
77 trigger::TrigEnergySumCollection back_layer_sums;
78 trigger::TrigEnergySumCollection side_layer_sums;
79 back_layer_sums.resize(layer_max);
80 for (int i = 0; i < layer_max; i++) back_layer_sums[i].setLayer(i);
81 side_layer_sums.resize(side_layer_max);
82 for (int i = 0; i < side_layer_max; i++) side_layer_sums[i].setLayer(i);
83
84 int total_adc = 0;
85 std::map<int, int> section_sum;
86 for (auto p : two_ended_quad_map) {
87 auto tp = p.second;
88 int adc = tp.getPrimitive();
89 total_adc += adc;
90 ldmx::HcalTriggerID combo_id(tp.getId());
91 int ilayer = combo_id.layer();
92 if (ilayer >= back_layer_sums.size()) {
93 std::cout << "[TrigHcalEnergySum.cxx] Warning(!), layer " << ilayer
94 << " is out-of-bounds.\n";
95 continue;
96 }
97 int isec = combo_id.section();
98
99 if (isec == 0)
100 back_layer_sums[ilayer].setHwEnergy(adc +
101 back_layer_sums[ilayer].hwEnergy());
102 else
103 side_layer_sums[ilayer].setHwEnergy(adc +
104 side_layer_sums[ilayer].hwEnergy());
105
106 auto ptr = section_sum.find(isec);
107 if (ptr == section_sum.end()) {
108 section_sum[isec] = adc;
109 } else {
110 section_sum[isec] += adc;
111 }
112 }
113 event.add(combined_quad_coll_name_ + "BackLayerSums", back_layer_sums);
114 event.add(combined_quad_coll_name_ + "SideLayerSums", side_layer_sums);
115
116 trigger::TrigEnergySumCollection section_sums;
117 for (auto p : section_sum) {
118 section_sums.emplace_back(-1, p.first, p.second);
119 }
120 event.add(combined_quad_coll_name_ + "SectionSums", section_sums);
121
122 // Also store total energy for now
123 trigger::TrigEnergySum total_sum;
124 total_sum.setLayer(-1);
125 total_sum.setHwEnergy(total_adc);
126 event.add(combined_quad_coll_name_ + "Sum", total_sum);
127}
bool exists(const std::string &name, const std::string &passName, bool unique=true) const
Check for the existence of an object or collection with the given name and pass name in the event.
Definition Event.cxx:107
Contains the trigger output for generic calo objects.
Extension of DetectorID providing access to HCal trigger cell.
Contains the trigger output for generic calo objects.

References framework::Event::exists(), ldmx::HcalTriggerID::layer(), ldmx::DetectorID::raw(), and ldmx::HcalTriggerID::superstrip().

Member Data Documentation

◆ combined_quad_coll_name_

std::string trigger::TrigHcalEnergySum::combined_quad_coll_name_
private

Definition at line 39 of file TrigHcalEnergySum.h.

◆ in_proc_

std::string trigger::TrigHcalEnergySum::in_proc_
private

Definition at line 37 of file TrigHcalEnergySum.h.

◆ quad_coll_name_

std::string trigger::TrigHcalEnergySum::quad_coll_name_
private

Definition at line 38 of file TrigHcalEnergySum.h.


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