LDMX Software
WRRawDecoder.cxx
1
2
4#include "Packing/Utility/Reader.h"
5
6// un comment for WRRawDecoder-specific debug printouts to std::cout
7// #define DEBUG
8
9namespace packing {
10
12 int run_number_;
13 int wr_counter_;
14 int channel_;
15 int seq_id_;
16 int sec_;
17 int coarse_;
18 int frac_;
20 return r >> run_number_ >> wr_counter_ >> channel_ >> seq_id_ >> sec_ >>
21 coarse_ >> frac_;
22 }
23 void add(framework::Event& event, const std::string& name) {
24 event.add(name + "RunNumber", run_number_);
25 event.add(name + "Counter", wr_counter_);
26 event.add(name + "Channel", channel_);
27 event.add(name + "SeqId", seq_id_);
28 event.add(name + "Sec", sec_);
29 event.add(name + "Coarse", coarse_);
30 event.add(name + "Frac", frac_);
31 }
32};
33
34std::ostream& operator<<(std::ostream& os, const WRBinaryPacket& p) {
35 return (os << "WR Packet {" << "run: " << p.run_number_
36 << ", counter: " << p.wr_counter_ << ", channel: " << p.channel_
37 << ", seq_id: " << p.seq_id_ << ", sec: " << p.sec_
38 << ", coarse: " << p.coarse_ << ", frac: " << p.frac_ << "}");
39}
40
45 public:
46 WRRawDecoder(const std::string& name, framework::Process& process)
48 virtual ~WRRawDecoder() = default;
49 virtual void configure(framework::config::Parameters&) final override;
50 virtual void onProcessStart() final override;
51 virtual void produce(framework::Event& event) final override;
52
53 private:
55 std::string input_file_;
57 std::string output_name_;
60
61 private:
67 TTree* tree_;
68};
69
71 input_file_ = ps.get<std::string>("input_file");
72 output_name_ = ps.get<std::string>("output_name");
73 ntuplize_ = ps.get<bool>("ntuplize");
74
76}
77
79 if (ntuplize_) {
81 tree_ = new TTree("wrraw", "Flattened and decoded raw WR data");
82 tree_->Branch("run", &p_.run_number_);
83 tree_->Branch("counter", &p_.wr_counter_);
84 tree_->Branch("channel", &p_.channel_);
85 tree_->Branch("seq_id", &p_.seq_id_);
86 tree_->Branch("sec", &p_.sec_);
87 tree_->Branch("coarse", &p_.coarse_);
88 tree_->Branch("frac", &p_.frac_);
89 }
90}
91
93 // only add and fill when file able to readout packet
94 if (file_reader_ >> p_) {
95 p_.add(event, output_name_);
96 tree_->Fill();
97#ifdef DEBUG
98 std::cout << p << std::endl;
99#endif
100 }
101#ifdef DEBUG
102 else {
103 std::cout << "no more events" << std::endl;
104 }
105#endif
106 return;
107} // produce
108
109} // namespace packing
110
Base classes for all user event processing components to extend.
#define DECLARE_PRODUCER(CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
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:40
Class which represents the process under execution.
Definition Process.h:34
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.
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:26
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:75
std::string output_name_
output object to put onto event bus
packing::utility::Reader file_reader_
the file reader (if we are doing that)
TTree * tree_
ntuple tree
bool ntuplize_
should we ntuplize?
virtual void onProcessStart() final override
Callback for the EventProcessor to take any necessary action when the processing of events starts,...
virtual void produce(framework::Event &event) final override
Process the event and put new data products into it.
std::string input_file_
input file
virtual void configure(framework::config::Parameters &) final override
Callback for the EventProcessor to configure itself from the given set of parameters.
WRBinaryPacket p_
packet being used for decoding
Reading a raw data file.
Definition Reader.h:20
void open(const std::string &file_name)
Open a file with this reader.
Definition Reader.h:36