19 std::vector<raw::ExternalTrigger> ExternTrigs;
21 std::vector<lbne::PennMicroSlice::Payload_Trigger::trigger_type_t> trigger_types = {lbne::PennMicroSlice::Payload_Trigger::TA,
22 lbne::PennMicroSlice::Payload_Trigger::TB,
23 lbne::PennMicroSlice::Payload_Trigger::TC,
24 lbne::PennMicroSlice::Payload_Trigger::TD};
25 std::vector<lbne::PennMicroSlice::Payload_Trigger::trigger_type_t> calib_types = {lbne::PennMicroSlice::Payload_Trigger::C1,
26 lbne::PennMicroSlice::Payload_Trigger::C2,
27 lbne::PennMicroSlice::Payload_Trigger::C3,
28 lbne::PennMicroSlice::Payload_Trigger::C4};
29 std::vector<lbne::PennMicroSlice::Payload_Timestamp::timestamp_t> fCounterTimes;
30 std::vector<lbne::PennMicroSlice::Payload_Timestamp::timestamp_t> fMuonTriggerTimes;
31 std::vector<lbne::PennMicroSlice::Payload_Timestamp::timestamp_t> fSSPTriggerTimes;
33 std::vector<lbne::PennMicroSlice::Payload_Timestamp::timestamp_t> fCalibrationTriggerTimes;
35 std::vector<lbne::PennMicroSlice::Payload_Counter> fCounterWords;
36 std::vector<lbne::PennMicroSlice::Payload_Trigger> fMuonTriggers;
37 std::vector<lbne::PennMicroSlice::Payload_Trigger> fSSPTriggers;
39 std::vector<lbne::PennMicroSlice::Payload_Trigger> fCalibrationTriggers;
42 for (
size_t idx = 0; idx < Fragments.size(); ++idx ) {
43 const auto& frag(Fragments[idx]);
46 lbne::PennMilliSliceFragment msf(frag);
48 lbne::PennMicroSlice::Payload_Header *word_header =
nullptr;
49 lbne::PennMicroSlice::Payload_Counter *word_p_counter =
nullptr;
50 lbne::PennMicroSlice::Payload_Trigger *word_p_trigger =
nullptr;
51 lbne::PennMicroSlice::Payload_Timestamp *previous_timestamp =
nullptr;
52 lbne::PennMicroSlice::Payload_Header *future_timestamp_header =
nullptr;
53 lbne::PennMicroSlice::Payload_Timestamp *future_timestamp =
nullptr;
54 uint8_t* payload_data =
nullptr;
58 payloadCount = msf.payloadCount(counter, trigger, timestamp);
62 while (payload_index <
uint32_t(payloadCount-1) ) {
63 payload_data = msf.get_next_payload(payload_index,word_header);
65 if (payload_data ==
nullptr)
67 switch(word_header->data_packet_type) {
69 case lbne::PennMicroSlice::DataTypeCounter:
70 word_p_counter =
reinterpret_cast<lbne::PennMicroSlice::Payload_Counter*
>(payload_data);
71 fCounterWords.push_back(*word_p_counter);
72 GetTimestamp( msf, word_header, previous_timestamp, future_timestamp, future_timestamp_header, fCounterTimes );
76 case lbne::PennMicroSlice::DataTypeTrigger:
77 word_p_trigger =
reinterpret_cast<lbne::PennMicroSlice::Payload_Trigger*
>(payload_data);
79 if (word_p_trigger->has_muon_trigger()) {
80 fMuonTriggers.push_back(*word_p_trigger);
81 GetTimestamp( msf, word_header, previous_timestamp, future_timestamp, future_timestamp_header, fMuonTriggerTimes );
84 if (word_p_trigger->has_ssp_trigger()) {
85 fSSPTriggers.push_back(*word_p_trigger);
86 GetTimestamp( msf, word_header, previous_timestamp, future_timestamp, future_timestamp_header, fSSPTriggerTimes );
96 if (word_p_trigger->has_calibration()) {
97 fCalibrationTriggers.push_back(*word_p_trigger);
98 GetTimestamp( msf, word_header, previous_timestamp, future_timestamp, future_timestamp_header, fCalibrationTriggerTimes );
104 case lbne::PennMicroSlice::DataTypeTimestamp:
105 previous_timestamp =
reinterpret_cast<lbne::PennMicroSlice::Payload_Timestamp*
>(payload_data);
106 if (FirstPTBTimestamp ==
nullptr) FirstPTBTimestamp = previous_timestamp;
118 for (
int counter_index=0; counter_index<98; ++counter_index ) {
119 bool counter_previously_on =
true;
121 bool counter_currently_on = fCounterWords.at(
pos).get_counter_status(counter_index);
124 bool MakeNewExtCount =
MakeNewExtTrig(
pos, counter_previously_on, counter_currently_on);
125 if (MakeNewExtCount) {
127 ExternTrigs.push_back(counter);
135 bool trigA_previously_on =
false, trigB_previously_on =
false, trigC_previously_on =
false, trigD_previously_on =
false;
137 bool trigA_currently_on = fMuonTriggers.at(
pos).has_muon_TA();
138 bool trigB_currently_on = fMuonTriggers.at(
pos).has_muon_TB();
139 bool trigC_currently_on = fMuonTriggers.at(
pos).has_muon_TC();
140 bool trigD_currently_on = fMuonTriggers.at(
pos).has_muon_TD();
141 lbne::PennMicroSlice::Payload_Timestamp::timestamp_t current_trigger_time = fMuonTriggerTimes.at(
pos);
142 bool MakeNewExtTrigA, MakeNewExtTrigB, MakeNewExtTrigC, MakeNewExtTrigD;
144 MakeNewExtTrigA = trigA_previously_on = trigA_currently_on;
145 MakeNewExtTrigB = trigA_previously_on = trigB_currently_on;
146 MakeNewExtTrigC = trigA_previously_on = trigC_currently_on;
147 MakeNewExtTrigD = trigA_previously_on = trigD_currently_on;
149 MakeNewExtTrigA =
MakeNewExtTrig(
pos, trigA_previously_on, trigA_currently_on );
150 MakeNewExtTrigB =
MakeNewExtTrig(
pos, trigB_previously_on, trigB_currently_on );
151 MakeNewExtTrigC =
MakeNewExtTrig(
pos, trigC_previously_on, trigC_currently_on );
152 MakeNewExtTrigD =
MakeNewExtTrig(
pos, trigD_previously_on, trigD_currently_on );
158 if (MakeNewExtTrigA) {
161 ExternTrigs.push_back(counter);
163 if (MakeNewExtTrigB) {
166 ExternTrigs.push_back(counter);
168 if (MakeNewExtTrigC) {
171 ExternTrigs.push_back(counter);
173 if (MakeNewExtTrigD) {
176 ExternTrigs.push_back(counter);
183 lbne::PennMicroSlice::Payload_Timestamp::timestamp_t current_trigger_time = fSSPTriggerTimes.at(
pos);
void GetTimestamp(lbne::PennMilliSliceFragment msf, lbne::PennMicroSlice::Payload_Header *&word_header, lbne::PennMicroSlice::Payload_Timestamp *const &previous_timestamp, lbne::PennMicroSlice::Payload_Timestamp *&future_timestamp, lbne::PennMicroSlice::Payload_Header *&future_timestamp_header, std::vector< lbne::PennMicroSlice::Payload_Timestamp::timestamp_t > &TimeVector)
bool MakeNewExtTrig(uint32_t pos, bool &PrevOn, bool NowOn)
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.