LDMX Software
NtuplizeHgcrocDigiCollection.cxx
1
2#include "Conditions/SimpleTableCondition.h"
3#include "DetDescr/HcalDigiID.h"
4#include "DetDescr/HcalElectronicsID.h"
8
9namespace dqm {
10
12 std::string input_name_, input_pass_, pedestal_table_;
13 int ldmxsw_event_, version_, pf_event_, pf_ticks_, pf_spill_;
14 int raw_id_, adc_, raw_adc_, tot_, toa_, i_sample_;
15 int fpga_, link_, channel_, index_;
16 int section_, layer_, strip_, end_;
17 bool tot_prog_, tot_comp_, aligned_;
18 bool using_eid_, already_aligned_;
19 bool good_link_;
20 TTree* flat_tree_;
21
22 public:
23 NtuplizeHgcrocDigiCollection(std::string const& n, framework::Process& p)
24 : framework::Analyzer(n, p) {}
26
27 void configure(framework::config::Parameters& ps) final override {
28 input_name_ = ps.getParameter<std::string>("input_name");
29 input_pass_ = ps.getParameter<std::string>("input_pass");
30 pedestal_table_ = ps.getParameter<std::string>("pedestal_table");
31 using_eid_ = ps.getParameter<bool>("using_eid");
32 already_aligned_ = ps.getParameter<bool>("already_aligned");
33 }
34
35 void onProcessStart() final override {
37 // cleaned up when histogram file is closed
38 flat_tree_ = new TTree("hgcroc", "Ntuplized HGC ROC Digi Collection");
39
40 flat_tree_->Branch("raw_id", &raw_id_);
41 flat_tree_->Branch("adc", &adc_);
42 flat_tree_->Branch("tot", &tot_);
43 flat_tree_->Branch("toa", &toa_);
44 flat_tree_->Branch("good_link", &good_link_);
45 flat_tree_->Branch("raw_adc", &raw_adc_);
46 flat_tree_->Branch("i_sample", &i_sample_);
47 flat_tree_->Branch("ldmxsw_event", &ldmxsw_event_);
48 if (not already_aligned_) {
49 flat_tree_->Branch("pf_event", &pf_event_);
50 flat_tree_->Branch("pf_spill", &pf_spill_);
51 flat_tree_->Branch("pf_ticks", &pf_ticks_);
52 }
53 flat_tree_->Branch("tot_prog", &tot_prog_);
54 flat_tree_->Branch("tot_comp", &tot_comp_);
55 flat_tree_->Branch("aligned", &aligned_);
56 if (using_eid_) {
57 flat_tree_->Branch("fpga", &fpga_);
58 flat_tree_->Branch("link", &link_);
59 flat_tree_->Branch("channel", &channel_);
60 flat_tree_->Branch("index", &index_);
61 } else {
62 flat_tree_->Branch("section", &section_);
63 flat_tree_->Branch("layer", &layer_);
64 flat_tree_->Branch("strip", &strip_);
65 flat_tree_->Branch("end", &end_);
66 }
67 }
68
69 void analyze(const framework::Event& event) final override;
70};
71
73 // get the reconstruction parameters
74 auto pedestal_table{
75 getCondition<conditions::IntegerTableCondition>(pedestal_table_)};
76 auto detmap{getCondition<hcal::HcalDetectorMap>(
78
79 ldmxsw_event_ = event.getEventNumber();
80 if (already_aligned_) {
81 aligned_ = event.getObject<bool>(input_name_ + "Aligned", input_pass_);
82 } else {
83 aligned_ = false;
84 version_ = event.getObject<int>(input_name_ + "Version", input_pass_);
85 pf_event_ = event.getObject<int>(input_name_ + "Number", input_pass_);
86 pf_ticks_ = event.getObject<int>(input_name_ + "Ticks", input_pass_);
87 pf_spill_ = event.getObject<int>(input_name_ + "Spill", input_pass_);
88 }
89
90 const auto& good_bxheader{
91 event.getCollection<bool>(input_name_ + "GoodLinkHeader", input_pass_)};
92 const auto& good_trailer{
93 event.getCollection<bool>(input_name_ + "GoodLinkTrailer", input_pass_)};
94
95 auto const& digis{
96 event.getObject<ldmx::HgcrocDigiCollection>(input_name_, input_pass_)};
97 for (std::size_t i_digi{0}; i_digi < digis.size(); i_digi++) {
98 auto d{digis.getDigi(i_digi)};
99 raw_id_ = static_cast<int>(d.id());
100 if (using_eid_) {
101 ldmx::HcalElectronicsID eid(d.id());
102 fpga_ = eid.fiber();
103 link_ = eid.elink();
104 good_link_ = (good_bxheader.at(link_) and good_trailer.at(link_));
105 channel_ = eid.channel();
106 index_ = eid.index();
107 } else {
108 ldmx::HcalDigiID detid(d.id());
109 ldmx::HcalElectronicsID eid = detmap.get(detid);
110 int link = eid.elink();
111 good_link_ = (good_bxheader.at(link) and good_trailer.at(link));
112 section_ = detid.section();
113 layer_ = detid.layer();
114 strip_ = detid.strip();
115 end_ = detid.end();
116 }
117
118 for (i_sample_ = 0; i_sample_ < digis.getNumSamplesPerDigi(); i_sample_++) {
119 tot_prog_ = d.at(i_sample_).isTOTinProgress();
120 tot_comp_ = d.at(i_sample_).isTOTComplete();
121 tot_ = d.at(i_sample_).tot();
122 toa_ = d.at(i_sample_).toa();
123 int adc_t = d.at(i_sample_).adc_t();
124 raw_adc_ = adc_t;
125 adc_ = adc_t - pedestal_table.get(d.id(), 0);
126 flat_tree_->Fill();
127 }
128 }
129}
130
131} // namespace dqm
132
133DECLARE_ANALYZER_NS(dqm, NtuplizeHgcrocDigiCollection);
Base classes for all user event processing components to extend.
#define DECLARE_ANALYZER_NS(NS, CLASS)
Macro which allows the framework to construct an analyzer given its name during configuration.
Class which contains logic for how the detector items connect to and relate with the reconstruction c...
Class that represents a digitized hit in a calorimeter cell readout by an HGCROC.
void onProcessStart() final override
Callback for the EventProcessor to take any necessary action when the processing of events starts,...
void configure(framework::config::Parameters &ps) final override
Callback for the EventProcessor to configure itself from the given set of parameters.
void analyze(const framework::Event &event) final override
Process the event and make histograms or summaries.
Base class for a module which does not produce a data product.
TDirectory * getHistoDirectory()
Access/create a directory in the histogram file for this event processor to create histograms and ana...
Implements an event buffer system for storing event data.
Definition Event.h:41
Class which represents the process under execution.
Definition Process.h:36
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:27
static constexpr const char * CONDITIONS_OBJECT_NAME
The name of the EID <-> DetID map for the ECal.
Extension of HcalAbstractID providing access to HCal digi information.
Definition HcalDigiID.h:13
int strip() const
Get the value of the 'strip' field from the ID.
Definition HcalDigiID.h:99
int section() const
Get the value of the 'section' field from the ID.
Definition HcalDigiID.h:75
int layer() const
Get the value of the layer field from the ID.
Definition HcalDigiID.h:81
int end() const
Get the value of the 'end' field from the ID.
Definition HcalDigiID.h:105
Identifies a location in the Hcal readout chain.
unsigned int index() const
Get the compact index value.
int elink() const
Get the value of the elink from the ID.
int fiber() const
Get the value of the fiber from the ID.
int channel() const
Get the value of the channel from the ID.
Represents a collection of the digi hits readout by an HGCROC.
const HgcrocDigi getDigi(unsigned int digiIndex) const
Get samples for the input digi index.