112 bool discard_data =
false;
114 uint32_t framebuf[117];
115 uint16_t databuf[128];
116 uint64_t timestampstart=0;
117 uint64_t timestamp=0;
127 for (
size_t ifile=0; ifile < nfiles; ++ ifile)
136 "Attempt to read off the end of file " <<
fInputFiles.at(ifile);
138 timestamp= framebuf[3];
140 timestamp += framebuf[2];
150 std::vector<std::vector<uint32_t>> fbcache(nfiles);
151 std::vector<uint64_t> tscache;
152 uint64_t latest_timestamp=0;
156 for (
size_t ifile=0; ifile<nfiles; ++ifile)
158 fbcache.at(ifile).resize(117);
164 "Attempt to read off the end of file " <<
fInputFiles.at(ifile);
166 timestamp= fbcache.at(ifile)[3];
168 timestamp += fbcache.at(ifile)[2];
169 tscache.push_back(timestamp);
170 if (timestamp > latest_timestamp)
172 latest_timestamp = timestamp;
178 for (
size_t ifile=0; ifile<nfiles; ++ifile)
180 while (tscache.at(ifile) + 16 < latest_timestamp)
187 "Attempt to read off the end of file " <<
fInputFiles.at(ifile);
189 timestamp= fbcache.at(ifile)[3];
191 timestamp += fbcache.at(ifile)[2];
192 tscache.at(ifile) = timestamp;
196 for (
size_t ifile=0; ifile < nfiles; ++ ifile)
201 std::vector<raw::RawDigit::ADCvector_t> adcvv(256);
202 for (
size_t itick=0; itick<
fNSamples; ++itick)
206 for (
size_t i=0; i<117; ++i)
208 framebuf[i] = fbcache.at(ifile).at(i);
218 "Attempt to read off the end of file " <<
fInputFiles.at(ifile);
221 int curslot = (framebuf[0] & 0x7000) >> 12;
222 int curfiber = (framebuf[0] & 0x8000) >> 15;
228 "Slot mismatch in file: " << curslot <<
" " << slot;
230 if (curfiber != fiber)
233 "Fiber mismatch in file: " << curfiber <<
" " << fiber;
242 uint64_t timestamp= framebuf[3];
244 timestamp += framebuf[2];
249 timestampstart = timestamp;
255 for (
size_t ichan=0; ichan<128; ++ichan)
257 adcvv.at(ichan).push_back(databuf[ichan]);
259 unpack14(&(framebuf[4+56]),databuf);
260 for (
size_t ichan=0; ichan<128; ++ichan)
262 adcvv.at(ichan+128).push_back(databuf[ichan]);
266 for (
size_t ichan=0; ichan<256; ++ichan)
274 unsigned int fiberloc = 0;
284 unsigned int chloc = ichan;
296 auto slotloc2 = slot;
297 auto fiberloc2 = fiberloc;
299 if (slot == 0 && fiberloc == 4)
304 if (slot == 1 && fiberloc == 4)
309 if (slot == 1 && fiberloc == 3)
314 if (slot == 0 && fiberloc == 3)
322 if ( slotloc2 == 1 && fiberloc2 == 1 )
327 if ( slotloc2 == 2 && fiberloc2 == 1 )
343 raw::RawDigit raw_digit(offlineChannel, uncompressed_nticks, adcvv.at(ichan), cflag);
345 raw_digits.push_back(raw_digit);
348 rd_timestamps.push_back(rdtimestamp);
351 auto const rawdigitptr = rdpm(raw_digits.size()-1);
352 auto const rdtimestampptr = tspm(rd_timestamps.size()-1);
353 rd_ts_assocs.addSingle(rawdigitptr,rdtimestampptr);
364 statuses.emplace_back(
true,
false,1);
373 unsigned int statword=0;
374 statuses.emplace_back(
false,
false,statword);
std::vector< raw::RDStatus > RDStatuses
std::vector< raw::RDTimeStamp > RDTimeStamps
std::vector< raw::RawDigit > RawDigits
enum raw::_compress Compress_t
Collection of charge vs time digitized from a single readout channel.
art::PtrMaker< raw::RawDigit > RDPmkr
void unpack14(const uint32_t *packed, uint16_t *unpacked)
art::PtrMaker< raw::RDTimeStamp > TSPmkr
unsigned int GetOfflineNumberFromDetectorElements(unsigned int crate, unsigned int slot, unsigned int fiber, unsigned int fembchannel, FelixOrRCE frswitch)
art::Assns< raw::RawDigit, raw::RDTimeStamp > RDTsAssocs
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
void computeMedianSigma(raw::RawDigit::ADCvector_t &v_adc, float &median, float &sigma)
std::vector< FILE * > fInputFilePointers
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.
std::vector< std::string > fInputFiles
ULong64_t fDesiredStartTimestamp
cet::coded_exception< error, detail::translate > exception
double median(sqlite3 *db, std::string const &table_name, std::string const &column_name)