4#include "Packing/Utility/Reader.h"
14double toDoubleFt(uint64_t i) {
15 static const unsigned int bits = 32;
16 static const unsigned int expbits = 8;
20 unsigned significandbits = bits - expbits - 1;
22 if (i == 0)
return 0.0;
25 result = (i & ((1LL << significandbits) - 1));
26 result /= (1LL << significandbits);
30 bias = (1 << (expbits - 1)) - 1;
31 shift = ((i >> significandbits) & ((1LL << expbits) - 1)) - bias;
42 result *= (i >> (bits - 1)) & 1 ? -1.0 : 1.0;
51 uint32_t field_header_;
52 std::vector<uint32_t> field_value_;
61 r >> len >> field_header_;
62 r.
read(field_value_, len - 1);
63 if (i_field != field_header_) {
64 EXCEPTION_RAISE(
"BadForm",
"Field " + std::to_string(i_field) +
65 " has a mismatched header " +
66 std::to_string(field_header_));
73 int toInt(
const std::size_t i = 0)
const {
return field_value_.at(i); }
80 str.resize(field_value_.size());
81 for (
int i{0}; i < str.size(); i++) {
82 str[i] = (char)field_value_[i];
92 long int toLong(
const std::size_t i = 0)
const {
93 return ((uint64_t)field_value_.at(i + 1) << 32) |
94 (uint64_t)field_value_.at(i);
101 return toDoubleFt(this->
toLong(i));
107 const std::vector<uint32_t>&
value()
const {
return field_value_; }
132 int trigger_timestamp_lsb_, trigger_timestamp_msb_, event_timestamp_lsb_,
133 event_timestamp_msb_;
134 std::vector<uint32_t> channel_hits_;
139 std::size_t i_word) {
140 trigger_timestamp_lsb_ = spill_data.at(i_word);
141 trigger_timestamp_msb_ = spill_data.at(i_word + 1);
142 event_timestamp_lsb_ = spill_data.at(i_word + 2);
143 event_timestamp_msb_ = spill_data.at(i_word + 3);
144 channel_hits_.clear();
145 channel_hits_.reserve(6);
146 for (std::size_t i{i_word + 4}; i < i_word + 10 and i < spill_data.size();
148 channel_hits_.push_back(spill_data.at(i));
159 int acq_type_allowed_;
160 std::string coincidence_in_use_;
162 long int counts_records_;
163 long int counts_records_with_zero_events_;
164 long int counts_trigs_;
165 std::string cycle_name_;
166 long int cycle_stamp_;
167 std::string equipment_name_;
168 int event_selection_acq_;
177 std::string message_;
178 std::vector<double> profile_;
179 std::vector<double> profile_stand_alone_;
180 std::string time_first_event_;
181 std::string time_first_trigger_;
182 std::string time_last_event_;
183 std::string time_last_trigger_;
185 int trigger_offset_acq_;
186 int trigger_selection_acq_;
204 std::cout << i_field <<
" " <<
"acqMode = " << acqMode << std::endl;
208 std::cout << i_field <<
" " <<
"acqStamp = " << acqStamp << std::endl;
212 std::cout << i_field <<
" " <<
"acqType = " << acqType << std::endl;
216 std::cout << i_field <<
" " <<
"acqTypeAllowed = " << acqTypeAllowed
221 std::cout << i_field <<
" " <<
"coincidenceInUse = " << coincidenceInUse
226 std::cout << i_field <<
" " <<
"counts = " << counts << std::endl;
230 std::cout << i_field <<
" " <<
"countsRecords = " << countsRecords
235 std::cout << i_field <<
" "
236 <<
"countsRecordsWithZeroEvents = " << countsRecordsWithZeroEvents
241 std::cout << i_field <<
" " <<
"countsTrigs = " << countsTrigs << std::endl;
245 std::cout << i_field <<
" " <<
"cycleName = " << cycleName << std::endl;
249 std::cout << i_field <<
" " <<
"cycleStamp = " << cycleStamp << std::endl;
253 std::cout << i_field <<
" " <<
"equipmentName = " << equipmentName
258 std::cout << i_field <<
" " <<
"eventSelectionAcq = " << eventSelectionAcq
265 for (std::size_t i_word{0}; i_word < events_data_field.
value().size();
270 std::cout << i_field <<
" " <<
"eventsData (size = " << eventsData.size()
275 std::cout << i_field <<
" " <<
"meanSNew = " << meanSNew << std::endl;
279 std::cout << i_field <<
" " <<
"message = " << message << std::endl;
283 profile_.reserve(profile_field.
value().size() / 2);
284 for (std::size_t i_word{0}; i_word < profile_field.
value().size();
286 profile_.push_back(profile_field.
toDouble(i_word));
289 std::cout << i_field <<
" " <<
"profile size " << profile.size()
295 profile_stand_alone_.clear();
296 profile_stand_alone_.reserve(profile_stand_alone_field.
value().size() / 2);
297 for (std::size_t i_word{0};
298 i_word < profile_stand_alone_field.
value().size(); i_word += 2) {
299 profile_stand_alone_.push_back(
300 profile_stand_alone_field.
toDouble(i_word));
303 std::cout << i_field <<
" " <<
"profileStandAlone size "
304 << profileStandAlone.size() << std::endl;
308 std::cout << i_field <<
" " <<
"timeFirstEvent = " << timeFirstEvent
313 std::cout << i_field <<
" " <<
"timeFirstTrigger = " << timeFirstTrigger
318 std::cout << i_field <<
" " <<
"timeLastEvent = " << timeLastEvent
323 std::cout << i_field <<
" " <<
"timeLastTrigger = " << timeLastTrigger
328 std::cout << i_field <<
" " <<
"trigger = " << trigger << std::endl;
332 std::cout << i_field <<
" " <<
"triggerOffsetAcq = " << triggerOffsetAcq
337 std::cout << i_field <<
" "
338 <<
"triggerSelectionAcq = " << triggerSelectionAcq << std::endl;
344std::ostream& operator<<(std::ostream& os,
const FiberTrackerBinaryPacket& p) {
345 return (os <<
"FiberTracker Packet {" << p.acq_stamp_ <<
"}");
390 tree_ =
new TTree(
"raw",
"Flattened and decoded raw FiberTracker data");
397 spill_tree_ =
new TTree(
"spill",
"Spill Meta-Data from FiberTrackerDAQ");
401 spill_tree_->Branch(
"acqTypeAllowed", &
spill_packet_.acq_type_allowed_);
403 spill_tree_->Branch(
"countsRecords", &
spill_packet_.counts_records_);
404 spill_tree_->Branch(
"countsRecordsWithZeroEvents",
406 spill_tree_->Branch(
"countsTrigs", &
spill_packet_.counts_trigs_);
407 spill_tree_->Branch(
"cycleStamp", &
spill_packet_.cycle_stamp_);
408 spill_tree_->Branch(
"eventSelectionAcq",
412 spill_tree_->Branch(
"profileStandAlone",
415 spill_tree_->Branch(
"triggerOffsetAcq", &
spill_packet_.trigger_offset_acq_);
416 spill_tree_->Branch(
"triggerSelectionAcq",
431 std::cout <<
"no more events" << std::endl;
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.
Class which represents the process under execution.
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.
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Each "field" of data in a FiberTracker packet.
const std::vector< uint32_t > & value() const
Get the field value.
long int toLong(const std::size_t i=0) const
long split across two ints
int toInt(const std::size_t i=0) const
conversion to a single int
double toDouble(const std::size_t i=0) const
convert two ints into a double
std::string toString() const
conversion from series of ints to string specific to FiberTrackerDAQ
FiberTrackerField(utility::Reader &r, int i_field)
r - reader i_field - field we are supposed to be reading from
std::string output_name_
output object to put onto event bus
virtual void produce(framework::Event &event) final override
Process the event and put new data products into it.
virtual void configure(framework::config::Parameters &) final override
Callback for the EventProcessor to configure itself from the given set of parameters.
FiberTrackerEvent ft_event_
Current Event.
FiberTrackerBinaryPacket spill_packet_
packet being used for decoding
virtual void onProcessStart() final override
Callback for the EventProcessor to take any necessary action when the processing of events starts,...
packing::utility::Reader file_reader_
the file reader (if we are doing that)
bool ntuplize_
should we ntuplize?
std::string input_file_
input file
void open(const std::string &file_name)
Open a file with this reader.
Reader & read(WordType *w, std::size_t count)
Read the next 'count' words into the input handle.
Each one of these packets represents an entire spill of data.
std::vector< FiberTrackerEvent > events_data_
This is the actual event data in which we are interested.
int i_event_
index_ of event we are on (for next)
utility::Reader & read(utility::Reader &r)
27 fields in order, all are present
A spill of events from a FiberTracker station.