LDMX Software
Public Types | Public Member Functions | Private Attributes | List of all members
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 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 inProc_
 
std::string quadCollName_
 
std::string combinedQuadCollName_
 

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 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.

27 : framework::Producer(name, process) {}
Base class for a module which produces a data product.

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 inProc_ = ps.getParameter<std::string>("inputProc");
13 quadCollName_ = ps.getParameter<std::string>("quadCollName");
14 combinedQuadCollName_ = ps.getParameter<std::string>("combinedQuadCollName");
15}

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

◆ 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(quadCollName_, inProc_)) {
45 // std::cout << "missing collection! : " << quadCollName_ << " " << inProc_
46 // << std::endl;
47 return;
48 }
49
50 // auto
51 // oneEndedQuads{event.getObject<ldmx::CaloTrigPrimCollection>(quadCollName_)};
52 const std::vector<ldmx::CaloTrigPrim> oneEndedQuads =
53 event.getCollection<ldmx::CaloTrigPrim>(quadCollName_, inProc_);
54
55 //
56 // sum bar ends to produce the combined quads
57 std::map<int, ldmx::CaloTrigPrim> twoEndedQuadMap;
58 for (const auto& oneEndedQuad : oneEndedQuads) {
59 const ldmx::HcalTriggerID end_id(oneEndedQuad.getId());
60 ldmx::HcalTriggerID combo_id(end_id.section(), end_id.layer(),
61 end_id.superstrip(), 2);
62 auto ptr = twoEndedQuadMap.find(combo_id.raw());
63 if (ptr == twoEndedQuadMap.end()) {
64 twoEndedQuadMap[combo_id.raw()] = oneEndedQuad;
65 } else {
66 ptr->second.setPrimitive(ptr->second.getPrimitive() +
67 oneEndedQuad.getPrimitive());
68 }
69 }
70 ldmx::CaloTrigPrimCollection twoEndedQuads;
71 for (auto p : twoEndedQuadMap) twoEndedQuads.push_back(p.second);
72 event.add(combinedQuadCollName_, twoEndedQuads);
73
74 //
75 // Produce the layer-by-layer energy sums
76 const unsigned int LayerMax = 50;
77 const unsigned int SideLayerMax = 16;
78 trigger::TrigEnergySumCollection backLayerSums;
79 trigger::TrigEnergySumCollection sideLayerSums;
80 backLayerSums.resize(LayerMax);
81 for (int i = 0; i < LayerMax; i++) backLayerSums[i].setLayer(i);
82 sideLayerSums.resize(SideLayerMax);
83 for (int i = 0; i < SideLayerMax; i++) sideLayerSums[i].setLayer(i);
84
85 int total_adc = 0;
86 std::map<int, int> section_sum;
87 for (auto p : twoEndedQuadMap) {
88 auto tp = p.second;
89 int adc = tp.getPrimitive();
90 total_adc += adc;
91 ldmx::HcalTriggerID combo_id(tp.getId());
92 int ilayer = combo_id.layer();
93 if (ilayer >= backLayerSums.size()) {
94 std::cout << "[TrigHcalEnergySum.cxx] Warning(!), layer " << ilayer
95 << " is out-of-bounds.\n";
96 continue;
97 }
98 int isec = combo_id.section();
99
100 if (isec == 0)
101 backLayerSums[ilayer].setHwEnergy(adc + backLayerSums[ilayer].hwEnergy());
102 else
103 sideLayerSums[ilayer].setHwEnergy(adc + sideLayerSums[ilayer].hwEnergy());
104
105 auto ptr = section_sum.find(isec);
106 if (ptr == section_sum.end()) {
107 section_sum[isec] = adc;
108 } else {
109 section_sum[isec] += adc;
110 }
111 }
112 event.add(combinedQuadCollName_ + "BackLayerSums", backLayerSums);
113 event.add(combinedQuadCollName_ + "SideLayerSums", sideLayerSums);
114
115 trigger::TrigEnergySumCollection sectionSums;
116 for (auto p : section_sum) {
117 sectionSums.emplace_back(-1, p.first, p.second);
118 }
119 event.add(combinedQuadCollName_ + "SectionSums", sectionSums);
120
121 // Also store total energy for now
122 trigger::TrigEnergySum totalSum;
123 totalSum.setLayer(-1);
124 totalSum.setHwEnergy(total_adc);
125 event.add(combinedQuadCollName_ + "Sum", totalSum);
126}
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

◆ combinedQuadCollName_

std::string trigger::TrigHcalEnergySum::combinedQuadCollName_
private

Definition at line 39 of file TrigHcalEnergySum.h.

◆ inProc_

std::string trigger::TrigHcalEnergySum::inProc_
private

Definition at line 37 of file TrigHcalEnergySum.h.

◆ quadCollName_

std::string trigger::TrigHcalEnergySum::quadCollName_
private

Definition at line 38 of file TrigHcalEnergySum.h.


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