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
 
NtupleManagerntuple_ {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 className equal to the EventProcessor class name.

For an example, look at MyProcessor.

Parameters
parametersParameters for configuration.

Reimplemented from framework::EventProcessor.

Definition at line 11 of file TrigHcalEnergySum.cxx.

11 {
12 in_proc_ = ps.get<std::string>("inputProc");
13 quad_coll_name_ = ps.get<std::string>("quadCollName");
14 combined_quad_coll_name_ = ps.get<std::string>("combinedQuadCollName");
15}

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 16 of file TrigHcalEnergySum.cxx.

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