7#include "Packing/Utility/Mask.h"
8#include "Packing/Utility/Reader.h"
18double toDoubleFt(uint64_t i) {
19 static const unsigned int bits = 32;
20 static const unsigned int expbits = 8;
24 unsigned significandbits = bits - expbits - 1;
26 if (i == 0)
return 0.0;
29 result = (i & ((1LL << significandbits) - 1));
30 result /= (1LL << significandbits);
34 bias = (1 << (expbits - 1)) - 1;
35 shift = ((i >> significandbits) & ((1LL << expbits) - 1)) - bias;
46 result *= (i >> (bits - 1)) & 1 ? -1.0 : 1.0;
55 uint32_t field_header_;
56 std::vector<uint32_t> field_value_;
65 r >> len >> field_header_;
66 r.
read(field_value_, len - 1);
67 if (i_field != field_header_) {
68 EXCEPTION_RAISE(
"BadForm",
"Field " + std::to_string(i_field) +
69 " has a mismatched header " +
70 std::to_string(field_header_));
77 int toInt(
const std::size_t i = 0)
const {
return field_value_.at(i); }
84 str.resize(field_value_.size());
85 for (
int i{0}; i < str.size(); i++) {
86 str[i] = (char)field_value_[i];
96 long int toLong(
const std::size_t i = 0)
const {
97 return ((uint64_t)field_value_.at(i + 1) << 32) |
98 (uint64_t)field_value_.at(i);
105 return toDoubleFt(this->
toLong(i));
111 const std::vector<uint32_t>&
value()
const {
return field_value_; }
136 int trigger_timestamp_lsb_, trigger_timestamp_msb_, event_timestamp_lsb_,
137 event_timestamp_msb_;
138 std::vector<uint32_t> channel_hits_;
143 std::size_t i_word) {
144 trigger_timestamp_lsb_ = spill_data.at(i_word);
145 trigger_timestamp_msb_ = spill_data.at(i_word + 1);
146 event_timestamp_lsb_ = spill_data.at(i_word + 2);
147 event_timestamp_msb_ = spill_data.at(i_word + 3);
148 channel_hits_.clear();
149 channel_hits_.reserve(6);
150 for (std::size_t i{i_word + 4}; i < i_word + 10 and i < spill_data.size();
152 channel_hits_.push_back(spill_data.at(i));
163 int acq_type_allowed_;
164 std::string coincidence_in_use_;
166 long int counts_records_;
167 long int counts_records_with_zero_events_;
168 long int counts_trigs_;
169 std::string cycle_name_;
170 long int cycle_stamp_;
171 std::string equipment_name_;
172 int event_selection_acq_;
181 std::string message_;
182 std::vector<double> profile_;
183 std::vector<double> profile_stand_alone_;
184 std::string time_first_event_;
185 std::string time_first_trigger_;
186 std::string time_last_event_;
187 std::string time_last_trigger_;
189 int trigger_offset_acq_;
190 int trigger_selection_acq_;
208 std::cout << i_field <<
" " <<
"acqMode = " << acqMode << std::endl;
212 std::cout << i_field <<
" " <<
"acqStamp = " << acqStamp << std::endl;
216 std::cout << i_field <<
" " <<
"acqType = " << acqType << std::endl;
220 std::cout << i_field <<
" " <<
"acqTypeAllowed = " << acqTypeAllowed
225 std::cout << i_field <<
" " <<
"coincidenceInUse = " << coincidenceInUse
230 std::cout << i_field <<
" " <<
"counts = " << counts << std::endl;
234 std::cout << i_field <<
" " <<
"countsRecords = " << countsRecords
239 std::cout << i_field <<
" "
240 <<
"countsRecordsWithZeroEvents = " << countsRecordsWithZeroEvents
245 std::cout << i_field <<
" " <<
"countsTrigs = " << countsTrigs << std::endl;
249 std::cout << i_field <<
" " <<
"cycleName = " << cycleName << std::endl;
253 std::cout << i_field <<
" " <<
"cycleStamp = " << cycleStamp << std::endl;
257 std::cout << i_field <<
" " <<
"equipmentName = " << equipmentName
262 std::cout << i_field <<
" " <<
"eventSelectionAcq = " << eventSelectionAcq
269 for (std::size_t i_word{0}; i_word < events_data_field.
value().size();
274 std::cout << i_field <<
" " <<
"eventsData (size = " << eventsData.size()
279 std::cout << i_field <<
" " <<
"meanSNew = " << meanSNew << std::endl;
283 std::cout << i_field <<
" " <<
"message = " << message << std::endl;
287 profile_.reserve(profile_field.
value().size() / 2);
288 for (std::size_t i_word{0}; i_word < profile_field.
value().size();
290 profile_.push_back(profile_field.
toDouble(i_word));
293 std::cout << i_field <<
" " <<
"profile size " << profile.size()
299 profile_stand_alone_.clear();
300 profile_stand_alone_.reserve(profile_stand_alone_field.
value().size() / 2);
301 for (std::size_t i_word{0};
302 i_word < profile_stand_alone_field.
value().size(); i_word += 2) {
303 profile_stand_alone_.push_back(
304 profile_stand_alone_field.
toDouble(i_word));
307 std::cout << i_field <<
" " <<
"profileStandAlone size "
308 << profileStandAlone.size() << std::endl;
312 std::cout << i_field <<
" " <<
"timeFirstEvent = " << timeFirstEvent
317 std::cout << i_field <<
" " <<
"timeFirstTrigger = " << timeFirstTrigger
322 std::cout << i_field <<
" " <<
"timeLastEvent = " << timeLastEvent
327 std::cout << i_field <<
" " <<
"timeLastTrigger = " << timeLastTrigger
332 std::cout << i_field <<
" " <<
"trigger = " << trigger << std::endl;
336 std::cout << i_field <<
" " <<
"triggerOffsetAcq = " << triggerOffsetAcq
341 std::cout << i_field <<
" "
342 <<
"triggerSelectionAcq = " << triggerSelectionAcq << std::endl;
348std::ostream& operator<<(std::ostream& os,
const FiberTrackerBinaryPacket& p) {
349 return (os <<
"FiberTracker Packet {" << p.acq_stamp_ <<
"}");
394 tree_ =
new TTree(
"raw",
"Flattened and decoded raw FiberTracker data");
401 spill_tree_ =
new TTree(
"spill",
"Spill Meta-Data from FiberTrackerDAQ");
405 spill_tree_->Branch(
"acqTypeAllowed", &
spill_packet_.acq_type_allowed_);
407 spill_tree_->Branch(
"countsRecords", &
spill_packet_.counts_records_);
408 spill_tree_->Branch(
"countsRecordsWithZeroEvents",
410 spill_tree_->Branch(
"countsTrigs", &
spill_packet_.counts_trigs_);
411 spill_tree_->Branch(
"cycleStamp", &
spill_packet_.cycle_stamp_);
412 spill_tree_->Branch(
"eventSelectionAcq",
416 spill_tree_->Branch(
"profileStandAlone",
419 spill_tree_->Branch(
"triggerOffsetAcq", &
spill_packet_.trigger_offset_acq_);
420 spill_tree_->Branch(
"triggerSelectionAcq",
435 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.