42 uint32_t framebuf[117];
43 uint16_t databuf[128];
44 uint64_t timestampstart=0;
48 rd_timestamps.clear();
59 for (
size_t ifile=0; ifile < nfiles; ++ ifile)
68 for (
size_t jfile = 0; jfile < nfiles; ++jfile)
75 timestamp= framebuf[3];
77 timestamp += framebuf[2];
86 std::vector<std::vector<uint32_t>> fbcache(nfiles);
87 std::vector<uint64_t> tscache;
88 uint64_t latest_timestamp=0;
92 for (
size_t ifile=0; ifile<nfiles; ++ifile)
94 fbcache.at(ifile).resize(117);
100 for (
size_t jfile = 0; jfile < nfiles; ++jfile)
107 timestamp= fbcache.at(ifile)[3];
109 timestamp += fbcache.at(ifile)[2];
110 tscache.push_back(timestamp);
111 if (timestamp > latest_timestamp)
113 latest_timestamp = timestamp;
119 for (
size_t ifile=0; ifile<nfiles; ++ifile)
121 while (tscache.at(ifile) + 16 < latest_timestamp)
128 for (
size_t jfile = 0; jfile < nfiles; ++jfile)
135 timestamp= fbcache.at(ifile)[3];
137 timestamp += fbcache.at(ifile)[2];
138 tscache.at(ifile) = timestamp;
144 for (
size_t ifile=0; ifile < nfiles; ++ ifile)
150 std::vector<raw::RawDigit::ADCvector_t> adcvv(256);
151 for (
size_t itick=0; itick<
fNSamples; ++itick)
155 for (
size_t i=0; i<117; ++i)
157 framebuf[i] = fbcache.at(ifile).at(i);
166 for (
size_t jfile = 0; jfile < nfiles; ++jfile)
175 int curslot = (framebuf[0] & 0x7000) >> 12;
176 int curfiber = (framebuf[0] & 0x8000) >> 15;
182 "Slot mismatch in file: " << curslot <<
" " << slot;
184 if (curfiber != fiber)
187 "Fiber mismatch in file: " << curfiber <<
" " << fiber;
196 timestamp= framebuf[3];
198 timestamp += framebuf[2];
203 timestampstart = timestamp;
209 for (
size_t ichan=0; ichan<128; ++ichan)
211 adcvv.at(ichan).push_back(databuf[ichan]);
213 unpack14(&(framebuf[4+56]),databuf);
214 for (
size_t ichan=0; ichan<128; ++ichan)
216 adcvv.at(ichan+128).push_back(databuf[ichan]);
220 for (
size_t ichan=0; ichan<256; ++ichan)
228 unsigned int fiberloc = 0;
238 unsigned int chloc = ichan;
250 auto slotloc2 = slot;
251 auto fiberloc2 = fiberloc;
253 if (slot == 0 && fiberloc == 4)
258 if (slot == 1 && fiberloc == 4)
263 if (slot == 1 && fiberloc == 3)
268 if (slot == 0 && fiberloc == 3)
276 if ( slotloc2 == 1 && fiberloc2 == 1 )
281 if ( slotloc2 == 2 && fiberloc2 == 1 )
289 size_t uncompressed_nticks = adcvv.at(0).size();
297 raw::RawDigit raw_digit(offlineChannel, uncompressed_nticks, adcvv.at(ichan), cflag);
299 raw_digits.push_back(raw_digit);
302 rd_timestamps.push_back(rdtimestamp);
307 unsigned int statword = 0;
308 rdstatuses.emplace_back(
false,
false,statword);
enum raw::_compress Compress_t
Collection of charge vs time digitized from a single readout channel.
ULong64_t fDesiredStartTimestamp
std::vector< std::string > fInputFiles
unsigned int GetOfflineNumberFromDetectorElements(unsigned int crate, unsigned int slot, unsigned int fiber, unsigned int fembchannel, FelixOrRCE frswitch)
std::vector< FILE * > fInputFilePointers
void unpack14(const uint32_t *packed, uint16_t *unpacked)
void SetPedestal(float ped, float sigma=1.)
Set pedestal and its RMS (the latter is 0 by default)
void Compress(std::vector< short > &adc, raw::Compress_t compress)
Compresses a raw data buffer.
void computeMedianSigma(raw::RawDigit::ADCvector_t &v_adc, float &median, float &sigma)
cet::coded_exception< error, detail::translate > exception
double median(sqlite3 *db, std::string const &table_name, std::string const &column_name)