Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
raw Namespace Reference

Raw data description. More...

Namespaces

 ctb
 

Classes

class  AuxDetDigit
 
class  BeamInfo
 
class  DAQHeader
 
class  DUNEHDF5FileInfo
 
class  ExternalTrigger
 
class  OpDetPulse
 
class  OpDetWaveform
 
class  RawDigit
 Collection of charge vs time digitized from a single readout channel. More...
 
class  RDStatus
 
class  RDTimeStamp
 
class  Trigger
 
class  VDColdboxTDERawInput
 

Typedefs

using VDColdboxTDERawInputSource = art::Source< VDColdboxTDERawInput >
 
typedef enum raw::_compress Compress_t
 
typedef enum raw::_auxdettype AuxDetType_t
 
typedef int TDCtick_t
 Type representing a TDC tick. More...
 
typedef unsigned int ChannelID_t
 Type representing the ID of a readout channel. More...
 
typedef long long TriggerTimeStamp_t
 type of trigger time stamp More...
 
typedef short ADC_Count_t
 
typedef unsigned int Channel_t
 
typedef double TimeStamp_t
 us since 1970, based on TimeService More...
 

Enumerations

enum  _compress {
  kNone, kHuffman, kZeroSuppression, kZeroHuffman,
  kDynamicDec, kFibonacci
}
 
enum  _auxdettype { kUnknownAuxDet, kScintillator, kTimeOfFlight, kCherenkov }
 

Functions

constexpr bool isValidChannelID (raw::ChannelID_t channel)
 
std::ostream & operator<< (std::ostream &os, const raw::BeamInfo &o)
 
bool operator< (const OpDetWaveform &lhs, const OpDetWaveform &rhs)
 
void Compress (std::vector< short > &adc, raw::Compress_t compress)
 Compresses a raw data buffer. More...
 
void Compress (std::vector< short > &adc, raw::Compress_t compress, int &nearestneighbor)
 
void Compress (std::vector< short > &adc, raw::Compress_t compress, unsigned int &zerothreshold)
 
void Compress (std::vector< short > &adc, raw::Compress_t compress, unsigned int &zerothreshold, int &nearestneighbor)
 
void Compress (const boost::circular_buffer< std::vector< short >> &adcvec_neighbors, std::vector< short > &adc, raw::Compress_t compress, unsigned int &zerothreshold, int &nearestneighbor)
 
void Compress (std::vector< short > &adc, raw::Compress_t compress, unsigned int &zerothreshold, int pedestal, int &nearestneighbor, bool fADCStickyCodeFeature)
 
void Compress (const boost::circular_buffer< std::vector< short >> &adcvec_neighbors, std::vector< short > &adc, raw::Compress_t compress, unsigned int &zerothreshold, int pedestal, int &nearestneighbor, bool fADCStickyCodeFeature)
 
void ZeroSuppression (std::vector< short > &adc, unsigned int &zerothreshold)
 
void ZeroSuppression (std::vector< short > &adc, unsigned int &zerothreshold, int &nearestneighbor)
 
void ZeroSuppression (std::vector< short > &adc, unsigned int &zerothreshold, int pedestal, int &nearestneighbor, bool fADCStickyCodeFeature)
 
void ZeroSuppression (const boost::circular_buffer< std::vector< short >> &adcvec_neighbors, std::vector< short > &adc, unsigned int &zerothreshold, int &nearestneighbor)
 
void ZeroSuppression (const boost::circular_buffer< std::vector< short >> &adcvec_neighbors, std::vector< short > &adc, unsigned int &zerothreshold, int pedestal, int &nearestneighbor, bool fADCStickyCodeFeature)
 
void ZeroUnsuppression (const std::vector< short > &adc, std::vector< short > &uncompressed)
 
void ZeroUnsuppression (const std::vector< short > &adc, std::vector< short > &uncompressed, int pedestal)
 
void Uncompress (const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
 Uncompresses a raw data buffer. More...
 
void Uncompress (const std::vector< short > &adc, std::vector< short > &uncompressed, int pedestal, raw::Compress_t compress)
 
void CompressHuffman (std::vector< short > &adc)
 
void UncompressHuffman (const std::vector< short > &adc, std::vector< short > &uncompressed)
 
int ADCStickyCodeCheck (const short adc_value, const int pedestal, bool fADCStickyCodeFeature)
 
void add_to_sequence_terminate (std::vector< bool > array, std::vector< bool > &cmp)
 
void CompressFibonacci (std::vector< short > &wf, std::function< void(int, std::vector< std::vector< bool >> &)> add_to_table)
 
void UncompressFibonacci (const std::vector< short > &adc, std::vector< short > &uncompressed, std::function< int(std::vector< bool > &)> decode_table_chunk)
 
void fibonacci_encode_table (int end, std::vector< std::vector< bool >> &table)
 
short fibonacci_decode (std::vector< bool > &chunk)
 

Variables

constexpr ChannelID_t InvalidChannelID = std::numeric_limits<ChannelID_t>::max()
 ID of an invalid channel. More...
 
const unsigned int onemask = 0x003f
 

Detailed Description

Raw data description.

Raw data description and utilities.

Typedef Documentation

typedef short raw::ADC_Count_t

Definition at line 21 of file OpDetWaveform.h.

typedef unsigned int raw::Channel_t

Definition at line 22 of file OpDetWaveform.h.

typedef unsigned int raw::ChannelID_t

Type representing the ID of a readout channel.

Definition at line 28 of file RawTypes.h.

typedef int raw::TDCtick_t

Type representing a TDC tick.

Definition at line 25 of file RawTypes.h.

typedef double raw::TimeStamp_t

us since 1970, based on TimeService

Definition at line 23 of file OpDetWaveform.h.

typedef long long raw::TriggerTimeStamp_t

type of trigger time stamp

Definition at line 13 of file ExternalTrigger.h.

Definition at line 763 of file VDColdboxTDERawInput_source.cc.

Enumeration Type Documentation

Enumerator
kUnknownAuxDet 

no idea

kScintillator 

Scintillator paddle.

kTimeOfFlight 

Time of flight.

kCherenkov 

Cherenkov counter.

Definition at line 17 of file RawTypes.h.

17  {
18  kUnknownAuxDet, ///< no idea
19  kScintillator, ///< Scintillator paddle
20  kTimeOfFlight, ///< Time of flight
21  kCherenkov ///< Cherenkov counter
22  } AuxDetType_t;
enum raw::_auxdettype AuxDetType_t
Cherenkov counter.
Definition: RawTypes.h:21
Scintillator paddle.
Definition: RawTypes.h:19
Time of flight.
Definition: RawTypes.h:20
Enumerator
kNone 

no compression

kHuffman 

Huffman Encoding.

kZeroSuppression 

Zero Suppression algorithm.

kZeroHuffman 

Zero Suppression followed by Huffman Encoding.

kDynamicDec 

Dynamic decimation.

kFibonacci 

Fibonacci encoding.

Definition at line 8 of file RawTypes.h.

8  {
9  kNone, ///< no compression
10  kHuffman, ///< Huffman Encoding
11  kZeroSuppression, ///< Zero Suppression algorithm
12  kZeroHuffman, ///< Zero Suppression followed by Huffman Encoding
13  kDynamicDec, ///< Dynamic decimation
14  kFibonacci ///< Fibonacci encoding
15  } Compress_t;
Huffman Encoding.
Definition: RawTypes.h:10
enum raw::_compress Compress_t
Zero Suppression followed by Huffman Encoding.
Definition: RawTypes.h:12
no compression
Definition: RawTypes.h:9
Zero Suppression algorithm.
Definition: RawTypes.h:11
Fibonacci encoding.
Definition: RawTypes.h:14
Dynamic decimation.
Definition: RawTypes.h:13

Function Documentation

int raw::ADCStickyCodeCheck ( const short  adc_value,
const int  pedestal,
bool  fADCStickyCodeFeature 
)

Definition at line 1185 of file raw.cxx.

1187  {
1188 
1189  int adc_return_value = std::abs(adc_value - pedestal);
1190 
1191  if(!fADCStickyCodeFeature){
1192  return adc_return_value;
1193  }
1194  // if DUNE 35t ADC sticky code feature is enabled in simulation, skip over ADC codes with LSBs of 0x00 or 0x3f
1195  unsigned int sixlsbs = adc_value & onemask;
1196 
1197  if((sixlsbs==onemask || sixlsbs==0) && std::abs(adc_value - pedestal) < 64){
1198  adc_return_value = 0; //set current adc value to zero if its LSBs are at sticky values and if it is within one MSB cell (64 ADC counts) of the pedestal value
1199  }
1200  return adc_return_value;
1201  }
const unsigned int onemask
Definition: raw.h:139
T abs(T value)
void raw::add_to_sequence_terminate ( std::vector< bool array,
std::vector< bool > &  cmp 
)
inline

Definition at line 1203 of file raw.cxx.

1203  {
1204  cmp.insert(cmp.end(), array.begin(), array.end());
1205  cmp.push_back(1);
1206  }
void raw::Compress ( std::vector< short > &  adc,
raw::Compress_t  compress 
)

Compresses a raw data buffer.

Parameters
adcbuffer with uncompressed data
compresstype of compression to be applied

This function dispatches the compression to the function appropriate for the specified compression type. The resulting compressed data replaces the input buffer content, which is lost. Compression is expected to reduce the size of the data, so that there is in principle no need for reallocation of the input buffer, adc, to store the result.

Definition at line 19 of file raw.cxx.

21  {
22  if(compress == raw::kHuffman) CompressHuffman(adc);
23  else if(compress == raw::kZeroHuffman){
24  unsigned int zerothreshold = 5;
25  ZeroSuppression(adc,zerothreshold);
26  CompressHuffman(adc);
27  }
28  else if(compress == raw::kZeroSuppression){
29  unsigned int zerothreshold = 5;
30  ZeroSuppression(adc,zerothreshold);
31  }
32  else if (compress == raw::kFibonacci) {
33  CompressFibonacci(adc);
34  }
35 
36 
37  return;
38  }
void CompressHuffman(std::vector< short > &adc)
Definition: raw.cxx:849
Huffman Encoding.
Definition: RawTypes.h:10
void ZeroSuppression(const boost::circular_buffer< std::vector< short >> &adcvec_neighbors, std::vector< short > &adc, unsigned int &zerothreshold, int pedestal, int &nearestneighbor, bool fADCStickyCodeFeature)
Definition: raw.cxx:590
Zero Suppression followed by Huffman Encoding.
Definition: RawTypes.h:12
Zero Suppression algorithm.
Definition: RawTypes.h:11
Fibonacci encoding.
Definition: RawTypes.h:14
void CompressFibonacci(std::vector< short > &wf, std::function< void(int, std::vector< std::vector< bool >> &)> add_to_table)
Definition: raw.cxx:1208
void raw::Compress ( std::vector< short > &  adc,
raw::Compress_t  compress,
int &  nearestneighbor 
)

Definition at line 40 of file raw.cxx.

43  {
44  if(compress == raw::kHuffman) CompressHuffman(adc);
45  else if(compress == raw::kZeroHuffman){
46  unsigned int zerothreshold = 5;
47  ZeroSuppression(adc,zerothreshold, nearestneighbor);
48  CompressHuffman(adc);
49  }
50  else if(compress == raw::kZeroSuppression){
51  unsigned int zerothreshold = 5;
52  ZeroSuppression(adc,zerothreshold, nearestneighbor);
53  }
54  else if (compress == raw::kFibonacci) {
55  CompressFibonacci(adc);
56  }
57 
58 
59  return;
60  }
void CompressHuffman(std::vector< short > &adc)
Definition: raw.cxx:849
Huffman Encoding.
Definition: RawTypes.h:10
void ZeroSuppression(const boost::circular_buffer< std::vector< short >> &adcvec_neighbors, std::vector< short > &adc, unsigned int &zerothreshold, int pedestal, int &nearestneighbor, bool fADCStickyCodeFeature)
Definition: raw.cxx:590
Zero Suppression followed by Huffman Encoding.
Definition: RawTypes.h:12
Zero Suppression algorithm.
Definition: RawTypes.h:11
Fibonacci encoding.
Definition: RawTypes.h:14
void CompressFibonacci(std::vector< short > &wf, std::function< void(int, std::vector< std::vector< bool >> &)> add_to_table)
Definition: raw.cxx:1208
void raw::Compress ( std::vector< short > &  adc,
raw::Compress_t  compress,
unsigned int &  zerothreshold 
)

Definition at line 63 of file raw.cxx.

66  {
67  if(compress == raw::kHuffman) CompressHuffman(adc);
68 
69  else if(compress == raw::kZeroSuppression) ZeroSuppression(adc,zerothreshold);
70  else if(compress == raw::kZeroHuffman){
71  ZeroSuppression(adc,zerothreshold);
72  CompressHuffman(adc);
73  }
74  else if (compress == raw::kFibonacci) {
75  CompressFibonacci(adc);
76  }
77 
78  return;
79  }
void CompressHuffman(std::vector< short > &adc)
Definition: raw.cxx:849
Huffman Encoding.
Definition: RawTypes.h:10
void ZeroSuppression(const boost::circular_buffer< std::vector< short >> &adcvec_neighbors, std::vector< short > &adc, unsigned int &zerothreshold, int pedestal, int &nearestneighbor, bool fADCStickyCodeFeature)
Definition: raw.cxx:590
Zero Suppression followed by Huffman Encoding.
Definition: RawTypes.h:12
Zero Suppression algorithm.
Definition: RawTypes.h:11
Fibonacci encoding.
Definition: RawTypes.h:14
void CompressFibonacci(std::vector< short > &wf, std::function< void(int, std::vector< std::vector< bool >> &)> add_to_table)
Definition: raw.cxx:1208
void raw::Compress ( std::vector< short > &  adc,
raw::Compress_t  compress,
unsigned int &  zerothreshold,
int &  nearestneighbor 
)

Definition at line 81 of file raw.cxx.

85  {
86  if(compress == raw::kHuffman)
87  CompressHuffman(adc);
88  else if(compress == raw::kZeroSuppression)
89  ZeroSuppression(adc,zerothreshold, nearestneighbor);
90  else if(compress == raw::kZeroHuffman){
91  ZeroSuppression(adc,zerothreshold, nearestneighbor);
92  CompressHuffman(adc);
93  }
94  else if (compress == raw::kFibonacci) {
95  CompressFibonacci(adc);
96  }
97 
98  return;
99  }
void CompressHuffman(std::vector< short > &adc)
Definition: raw.cxx:849
Huffman Encoding.
Definition: RawTypes.h:10
void ZeroSuppression(const boost::circular_buffer< std::vector< short >> &adcvec_neighbors, std::vector< short > &adc, unsigned int &zerothreshold, int pedestal, int &nearestneighbor, bool fADCStickyCodeFeature)
Definition: raw.cxx:590
Zero Suppression followed by Huffman Encoding.
Definition: RawTypes.h:12
Zero Suppression algorithm.
Definition: RawTypes.h:11
Fibonacci encoding.
Definition: RawTypes.h:14
void CompressFibonacci(std::vector< short > &wf, std::function< void(int, std::vector< std::vector< bool >> &)> add_to_table)
Definition: raw.cxx:1208
void raw::Compress ( const boost::circular_buffer< std::vector< short >> &  adcvec_neighbors,
std::vector< short > &  adc,
raw::Compress_t  compress,
unsigned int &  zerothreshold,
int &  nearestneighbor 
)

Definition at line 102 of file raw.cxx.

107  {
108  if(compress == raw::kHuffman)
109  CompressHuffman(adc);
110  else if(compress == raw::kZeroSuppression)
111  ZeroSuppression(adcvec_neighbors,adc,zerothreshold, nearestneighbor);
112  else if(compress == raw::kZeroHuffman){
113  ZeroSuppression(adcvec_neighbors,adc,zerothreshold, nearestneighbor);
114  CompressHuffman(adc);
115  }
116  else if (compress == raw::kFibonacci) {
117  CompressFibonacci(adc);
118  }
119 
120  return;
121  }
void CompressHuffman(std::vector< short > &adc)
Definition: raw.cxx:849
Huffman Encoding.
Definition: RawTypes.h:10
void ZeroSuppression(const boost::circular_buffer< std::vector< short >> &adcvec_neighbors, std::vector< short > &adc, unsigned int &zerothreshold, int pedestal, int &nearestneighbor, bool fADCStickyCodeFeature)
Definition: raw.cxx:590
Zero Suppression followed by Huffman Encoding.
Definition: RawTypes.h:12
Zero Suppression algorithm.
Definition: RawTypes.h:11
Fibonacci encoding.
Definition: RawTypes.h:14
void CompressFibonacci(std::vector< short > &wf, std::function< void(int, std::vector< std::vector< bool >> &)> add_to_table)
Definition: raw.cxx:1208
void raw::Compress ( std::vector< short > &  adc,
raw::Compress_t  compress,
unsigned int &  zerothreshold,
int  pedestal,
int &  nearestneighbor,
bool  fADCStickyCodeFeature 
)

Definition at line 124 of file raw.cxx.

130  {
131  if(compress == raw::kHuffman)
132  CompressHuffman(adc);
133  else if(compress == raw::kZeroSuppression)
134  ZeroSuppression(adc,zerothreshold, pedestal, nearestneighbor, fADCStickyCodeFeature);
135  else if(compress == raw::kZeroHuffman){
136  ZeroSuppression(adc,zerothreshold, pedestal, nearestneighbor, fADCStickyCodeFeature);
137  CompressHuffman(adc);
138  }
139  else if (compress == raw::kFibonacci) {
140  CompressFibonacci(adc);
141  }
142 
143  return;
144  }
void CompressHuffman(std::vector< short > &adc)
Definition: raw.cxx:849
Huffman Encoding.
Definition: RawTypes.h:10
void ZeroSuppression(const boost::circular_buffer< std::vector< short >> &adcvec_neighbors, std::vector< short > &adc, unsigned int &zerothreshold, int pedestal, int &nearestneighbor, bool fADCStickyCodeFeature)
Definition: raw.cxx:590
Zero Suppression followed by Huffman Encoding.
Definition: RawTypes.h:12
Zero Suppression algorithm.
Definition: RawTypes.h:11
Fibonacci encoding.
Definition: RawTypes.h:14
void CompressFibonacci(std::vector< short > &wf, std::function< void(int, std::vector< std::vector< bool >> &)> add_to_table)
Definition: raw.cxx:1208
void raw::Compress ( const boost::circular_buffer< std::vector< short >> &  adcvec_neighbors,
std::vector< short > &  adc,
raw::Compress_t  compress,
unsigned int &  zerothreshold,
int  pedestal,
int &  nearestneighbor,
bool  fADCStickyCodeFeature 
)

Definition at line 147 of file raw.cxx.

154  {
155  if(compress == raw::kHuffman)
156  CompressHuffman(adc);
157  else if(compress == raw::kZeroSuppression)
158  ZeroSuppression(adcvec_neighbors,adc,zerothreshold, pedestal, nearestneighbor, fADCStickyCodeFeature);
159  else if(compress == raw::kZeroHuffman){
160  ZeroSuppression(adcvec_neighbors,adc,zerothreshold, pedestal, nearestneighbor, fADCStickyCodeFeature);
161  CompressHuffman(adc);
162  }
163  else if (compress == raw::kFibonacci) {
164  CompressFibonacci(adc);
165  }
166 
167  return;
168  }
void CompressHuffman(std::vector< short > &adc)
Definition: raw.cxx:849
Huffman Encoding.
Definition: RawTypes.h:10
void ZeroSuppression(const boost::circular_buffer< std::vector< short >> &adcvec_neighbors, std::vector< short > &adc, unsigned int &zerothreshold, int pedestal, int &nearestneighbor, bool fADCStickyCodeFeature)
Definition: raw.cxx:590
Zero Suppression followed by Huffman Encoding.
Definition: RawTypes.h:12
Zero Suppression algorithm.
Definition: RawTypes.h:11
Fibonacci encoding.
Definition: RawTypes.h:14
void CompressFibonacci(std::vector< short > &wf, std::function< void(int, std::vector< std::vector< bool >> &)> add_to_table)
Definition: raw.cxx:1208
void raw::CompressFibonacci ( std::vector< short > &  wf)

Definition at line 1208 of file raw.cxx.

1209  {
1210 
1211  std::vector<std::vector<bool>> table;
1212  add_to_table(100, table);
1213 
1214  std::vector<short> comp_short;
1215  // First numbers are not encoded (size and baseline)
1216  assert(not empty(wf));
1217 
1218  unsigned int size_short = sizeof(wf[0])*8-1; // assuming we don't encode over the sign bits
1219  unsigned int max_2_short = (1 << (size_short*2)); //this number is then: 1,073,741,824 (i.e. almost 9min of data at 2MHz)
1220  size_t wf_size = wf.size();
1221 
1222 
1223  if (wf_size > max_2_short) {
1224  throw cet::exception("raw") << "WOW! You are trying to compress a " << wf_size << " long waveform"
1225  << " in a vector of shorts.\nUnfortunately, the encoded waveform needs to store the size"
1226  << " of the wavefom (in its first number) and " << wf_size << " is bigger than the maximum\n"
1227  << " number you can encode with 2 shorts (" << max_2_short << ").\n"
1228  << " Bailing out disgracefully to avoid massive trouble.\n";
1229  }
1230 
1231  short high = (wf_size >> (sizeof(short)*8-1));
1232  short low = wf_size % ((std::numeric_limits<short>::max()+1));
1233  comp_short.push_back(high);
1234  comp_short.push_back(low);
1235  comp_short.push_back(*wf.begin());
1236 
1237  // The format we are working with
1238  std::vector<bool> cmp;
1239  cmp.reserve(wf.size()*sizeof(wf[0])*8);
1240 
1241  // The input is changed to be the difference between ticks
1242  std::vector<short> diff;
1243  diff.reserve(wf.size());
1244  // Fibonacci number are positive, so need a way to get negative number
1245  // We use the ZigZag approach (even numbers are positive, odd are negative)
1246  std::adjacent_difference(wf.begin(), wf.end(),std::back_inserter(diff), [](const short& it1, const short& it2){
1247  short d = it1-it2;
1248  if (d > 0) d = 2 * d;
1249  else d = -2 * d + 1;
1250  return d;
1251  });
1252 
1253  // Start from 1 to avoid the first number
1254  for (size_t iSample=1; iSample<diff.size(); ++iSample) {
1255 
1256  short d = diff[iSample];
1257  if ((unsigned)d < table.size()) {
1258  add_to_sequence_terminate(table[d], cmp);
1259  } else { // catch if the table is too small...
1260  int end = d+1;
1261  // use the user provided function to fill the table
1262  add_to_table(end, table);
1263  // and add again to the sequence
1264  add_to_sequence_terminate(table[d], cmp);
1265  }
1266  }
1267 
1268  // Now convert all this to a vector of short and it's just another day in paradise for larsoft
1269  size_t n_vector = cmp.size();
1270 
1271  // Create a bitset of the size of the short to simplify things
1272  std::bitset<8*sizeof(short)> this_encoded;
1273  // Set the bitset to match the stream
1274  size_t bit_counter=0;
1275 
1276  for (size_t it=0; it<n_vector; ++it) {
1277 
1278  if (bit_counter>=8*sizeof(short)) {
1279  short comp_s = (short)this_encoded.to_ulong();
1280  comp_short.push_back(comp_s);
1281  bit_counter=0;
1282  this_encoded.reset();
1283  }
1284 
1285  if (cmp[it])
1286  this_encoded.set(bit_counter);
1287 
1288  bit_counter++;
1289 
1290  }
1291 
1292  // Deal with the last part
1293  short comp_s = (short)this_encoded.to_ulong();
1294  comp_short.push_back(comp_s);
1295 
1296  wf = comp_short;
1297 
1298  return;
1299  }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
static int max(int a, int b)
void add_to_sequence_terminate(std::vector< bool > array, std::vector< bool > &cmp)
Definition: raw.cxx:1203
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:97
void raw::CompressHuffman ( std::vector< short > &  adc)

Definition at line 849 of file raw.cxx.

850  {
851  std::vector<short> const orig_adc(std::move(adc));
852 
853  // diffs contains the difference between an element of adc and the previous
854  // one; the first entry is never used.
855  std::vector<short> diffs;
856  diffs.reserve(orig_adc.size());
857  std::adjacent_difference
858  (orig_adc.begin(), orig_adc.end(), std::back_inserter(diffs));
859 
860  // prepare adc for the new data; we kind-of-expect the size,
861  // so we pre-allocate it; we might want to shrink-to-fit at the end
862  adc.clear();
863  adc.reserve(orig_adc.size());
864  // now loop over the diffs and do the Huffman encoding
865  adc.push_back(orig_adc.front());
866  unsigned int curb = 15U;
867 
868  std::bitset<16> bset;
869  bset.set(15);
870 
871  for(size_t i = 1U; i < diffs.size(); ++i){
872 
873  switch (diffs[i]) {
874  // if the difference is 0, check to see what the next 3 differences are
875  case 0 : {
876  if(i < diffs.size() - 3){
877  // if next 3 are also 0, set the next bit to be 1
878  if(diffs[i+1] == 0 && diffs[i+2] == 0 && diffs[i+3] == 0){
879  if(curb > 0){
880  --curb;
881  bset.set(curb);
882  i += 3;
883  continue;
884  }
885  else{
886  adc.push_back(bset.to_ulong());
887 
888  // reset the bitset to be ready for the next word
889  bset.reset();
890  bset.set(15);
891  bset.set(14); // account for the fact that this is a zero diff
892  curb = 14;
893  i += 3;
894  continue;
895  } // end if curb is not big enough to put current difference in bset
896  } // end if next 3 are also zero
897  else{
898  // 0 diff is encoded as 01, so move the current bit one to the right
899  if(curb > 1){
900  curb -= 2;
901  bset.set(curb);
902  continue;
903  } // end if the current bit is large enough to set this one
904  else{
905  adc.push_back(bset.to_ulong());
906  // reset the bitset to be ready for the next word
907  bset.reset();
908  bset.set(15);
909  bset.set(13); // account for the fact that this is a zero diff
910  curb = 13;
911  continue;
912  } // end if curb is not big enough to put current difference in bset
913  } // end if next 3 are not also 0
914  }// end if able to check next 3
915  else{
916  // 0 diff is encoded as 01, so move the current bit one to the right
917  if(curb > 1){
918  curb -= 2;
919  bset.set(curb);
920  continue;
921  } // end if the current bit is large enough to set this one
922  else{
923  adc.push_back(bset.to_ulong());
924  // reset the bitset to be ready for the next word
925  bset.reset();
926  bset.set(15);
927  bset.set(13); // account for the fact that this is a zero diff
928  curb = 13;
929  continue;
930  } // end if curb is not big enough to put current difference in bset
931  }// end if not able to check the next 3
932  break;
933  }// end if current difference is zero
934  case 1: {
935  if(curb > 2){
936  curb -= 3;
937  bset.set(curb);
938  }
939  else{
940  adc.push_back(bset.to_ulong());
941  // reset the bitset to be ready for the next word
942  bset.reset();
943  bset.set(15);
944  bset.set(12); // account for the fact that this is a +1 diff
945  curb = 12;
946  } // end if curb is not big enough to put current difference in bset
947  break;
948  } // end if difference = 1
949  case -1: {
950  if(curb > 3){
951  curb -= 4;
952  bset.set(curb);
953  }
954  else{
955  adc.push_back(bset.to_ulong());
956  // reset the bitset to be ready for the next word
957  bset.reset();
958  bset.set(15);
959  bset.set(11); // account for the fact that this is a -1 diff
960  curb = 11;
961  } // end if curb is not big enough to put current difference in bset
962  break;
963  }// end if difference = -1
964  case 2: {
965  if(curb > 4){
966  curb -= 5;
967  bset.set(curb);
968  }
969  else{
970  adc.push_back(bset.to_ulong());
971  // reset the bitset to be ready for the next word
972  bset.reset();
973  bset.set(15);
974  bset.set(10); // account for the fact that this is a +2 diff
975  curb = 10;
976  } // end if curb is not big enough to put current difference in bset
977  break;
978  }// end if difference = 2
979  case -2: {
980  if(curb > 5){
981  curb -= 6;
982  bset.set(curb);
983  }
984  else{
985  adc.push_back(bset.to_ulong());
986  // reset the bitset to be ready for the next word
987  bset.reset();
988  bset.set(15);
989  bset.set(9); // account for the fact that this is a -2 diff
990  curb = 9;
991  } // end if curb is not big enough to put current difference in bset
992  break;
993  }// end if difference = -2
994  case 3: {
995  if(curb > 6){
996  curb -= 7;
997  bset.set(curb);
998  }
999  else{
1000  adc.push_back(bset.to_ulong());
1001  // reset the bitset to be ready for the next word
1002  bset.reset();
1003  bset.set(15);
1004  bset.set(8); // account for the fact that this is a +3 diff
1005  curb = 8;
1006  } // end if curb is not big enough to put current difference in bset
1007  break;
1008  }// end if difference = 3
1009  case -3: {
1010  if(curb > 7){
1011  curb -= 8;
1012  bset.set(curb);
1013  }
1014  else{
1015  adc.push_back(bset.to_ulong());
1016  // reset the bitset to be ready for the next word
1017  bset.reset();
1018  bset.set(15);
1019  bset.set(7); // account for the fact that this is a -3 diff
1020  curb = 7;
1021  } // end if curb is not big enough to put current difference in bset
1022  break;
1023  }// end if difference = -3
1024  default: {
1025  // if the difference is too large that we have to put the entire adc value in:
1026  // put the current value into the adc vec unless the current bit is 15, then there
1027  // were multiple large difference values in a row
1028  if(curb != 15){
1029  adc.push_back(bset.to_ulong());
1030  }
1031 
1032  bset.reset();
1033  bset.set(15);
1034  curb = 15;
1035 
1036  // put the current adcvalue in adc, with its bit 15 set to 0
1037  if(orig_adc[i] > 0) adc.push_back(orig_adc[i]);
1038  else{
1039  std::bitset<16> tbit(-orig_adc[i]);
1040  tbit.set(14);
1041  adc.push_back(tbit.to_ulong());
1042  }
1043  break;
1044  } // if |difference| > 3
1045  }// switch diff[i]
1046  }// end loop over differences
1047 
1048  //write out the last bitset
1049  adc.push_back(bset.to_ulong());
1050 
1051  // this would reduce global memory usage,
1052  // at the cost of a new allocation and copy
1053  // adc.shrink_to_fit();
1054 
1055  } // CompressHuffman()
def move(depos, offset)
Definition: depos.py:107
short raw::fibonacci_decode ( std::vector< bool > &  chunk)

Definition at line 1394 of file raw.cxx.

1394  {
1395  std::vector<int> FibNumbers={1,2,3,5,8,13,21,34,55,89,144,233,377,610,987};
1396 
1397  if (chunk.size() > FibNumbers.size()) {
1398  for (int i=FibNumbers.size(); i<=(int)chunk.size(); ++i){
1399  FibNumbers.push_back(FibNumbers.at(i-1)+FibNumbers.at(i-2));
1400  }
1401  }
1402  short decoded = 0;
1403  for (size_t it=0; it<chunk.size(); ++it) {
1404  if (chunk[it])
1405  decoded += FibNumbers[it];
1406  }
1407  return decoded;
1408  }
void raw::fibonacci_encode_table ( int  end,
std::vector< std::vector< bool >> &  table 
)

Definition at line 1346 of file raw.cxx.

1346  {
1347  if ((int)table.size() > end)
1348  return;
1349 
1350  std::map<int, int> fibn; // no need for this to be static
1351  fibn[0] = 0;
1352  fibn[1] = 1;
1353  fibn[2] = 1;
1354 
1355  // if the table was empty, fill it
1356  if (empty(table)) {
1357  table.push_back(std::vector<bool>()); // we need this one so that the index of the vector is the same as the number we want to encode
1358  table.push_back({true });
1359  table.push_back({false,true});
1360  }
1361 
1362  if ((int)table.size() > end)
1363  return;
1364 
1365  // start at the third fibonacci number
1366  for (int i=2; fibn.rbegin()->second<end; ++i) {
1367  fibn[i] = fibn[i-1] + fibn[i-2];
1368  }
1369 
1370 
1371  for (int i=table.size(); i<=end; ++i) {
1372  int current_number = i;
1373  std::vector<bool> seq; // the final sequence of numbers
1374  while (current_number>0) {
1375  // find the biggest fibonacci number that is smaller than the current number
1376  for (auto fib = fibn.rbegin(); fib != fibn.rend(); ++fib) {
1377  if (fib->second<=current_number) {
1378  // if this is the first number, create the vector
1379  if (!seq.size())
1380  seq=std::vector<bool>(fib->first-1, false);
1381  // fill the sequence
1382  seq[fib->first-2] = true;
1383  // subtract the current number
1384  current_number-=fib->second;
1385  break;
1386  }
1387  }
1388  }
1389 
1390  table.push_back(seq);
1391  }
1392  }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:97
constexpr bool raw::isValidChannelID ( raw::ChannelID_t  channel)
inline

Returns whether the specified channel ID is valid

Note
This does not mean that channel exists in the current geometry.

Definition at line 37 of file RawTypes.h.

38  { return channel != InvalidChannelID; }
uint8_t channel
Definition: CRTFragment.hh:201
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
Definition: RawTypes.h:32
bool raw::operator< ( const OpDetWaveform lhs,
const OpDetWaveform rhs 
)
inline

Definition at line 77 of file OpDetWaveform.h.

78  {
79  // Sort by channel, then time
80  if ( lhs.ChannelNumber() < rhs.ChannelNumber() ) return true;
81  if ( rhs.ChannelNumber() > rhs.ChannelNumber() ) return false;
82 
83  return ( lhs.TimeStamp() < rhs.TimeStamp() );
84  }
std::ostream& raw::operator<< ( std::ostream &  os,
const raw::BeamInfo o 
)

Definition at line 117 of file BeamInfo.cxx.

119  {
120 
121  os << "Record type:" << o.GetRecordType() << std::endl;;
122  os << "Timestamp: " << o.GetSeconds() << "\t"
123  << o.GetMilliSeconds() << std::endl;
124  os << "Number of Devices: " << o.GetNumberOfDevices() << std::endl;
125 
126  const std::map<std::string, std::vector<double> > dm=o.GetDataMap();
127  std::map<std::string, std::vector<double> >::const_iterator it=dm.begin();
128  while (it!=dm.end()) {
129  os << it->first<<": ";
130  for (size_t i=0;i<it->second.size();i++) os <<it->second[i]<<", ";
131  os << std::endl;
132  it++;
133  }
134 
135  return os;
136  }
uint8_t GetRecordType() const
Definition: BeamInfo.h:57
uint16_t GetNumberOfDevices() const
Definition: BeamInfo.h:60
uint16_t GetMilliSeconds() const
Definition: BeamInfo.h:59
std::map< std::string, std::vector< double > > GetDataMap() const
Definition: BeamInfo.h:63
uint32_t GetSeconds() const
Definition: BeamInfo.h:58
QTextStream & endl(QTextStream &s)
void raw::Uncompress ( const std::vector< short > &  adc,
std::vector< short > &  uncompressed,
raw::Compress_t  compress 
)

Uncompresses a raw data buffer.

Parameters
adccompressed buffer
uncompressedbuffer to be filled with uncompressed data
compresstype of compression in the adc buffer

This function dispatches the uncompression to the correct uncompress function according to compression type in compress.

The uncompressed buffer must be already allocated with enough space to store the full inflated adc data. Uncompressing raw::RawDigit can be done as follows:

std::vector<ADC_t> uncompressed(digit.Samples(), 0);
raw::Uncompress(digit.ADC(), uncompressed, digit.ADC());

Definition at line 776 of file raw.cxx.

779  {
780  if(compress == raw::kHuffman) UncompressHuffman(adc, uncompressed);
781  else if(compress == raw::kZeroSuppression){
782  ZeroUnsuppression(adc, uncompressed);
783  }
784  else if(compress == raw::kZeroHuffman){
785  std::vector<short> tmp(2*adc[0]);
786  UncompressHuffman(adc, tmp);
787  ZeroUnsuppression(tmp, uncompressed);
788  }
789  else if(compress == raw::kNone){
790  for(unsigned int i = 0; i < adc.size(); ++i) uncompressed[i] = adc[i];
791  }
792  else if (compress == raw::kFibonacci) {
793  UncompressFibonacci(adc, uncompressed);
794  }
795  else {
796  throw cet::exception("raw")
797  << "raw::Uncompress() does not support compression #"
798  << ((int) compress);
799  }
800  return;
801  }
Huffman Encoding.
Definition: RawTypes.h:10
void ZeroUnsuppression(const std::vector< short > &adc, std::vector< short > &uncompressed, int pedestal)
Definition: raw.cxx:745
void UncompressHuffman(const std::vector< short > &adc, std::vector< short > &uncompressed)
Definition: raw.cxx:1059
Zero Suppression followed by Huffman Encoding.
Definition: RawTypes.h:12
no compression
Definition: RawTypes.h:9
Zero Suppression algorithm.
Definition: RawTypes.h:11
string tmp
Definition: languages.py:63
Fibonacci encoding.
Definition: RawTypes.h:14
void UncompressFibonacci(const std::vector< short > &adc, std::vector< short > &uncompressed, std::function< int(std::vector< bool > &)> decode_table_chunk)
Definition: raw.cxx:1301
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void raw::Uncompress ( const std::vector< short > &  adc,
std::vector< short > &  uncompressed,
int  pedestal,
raw::Compress_t  compress 
)

Definition at line 805 of file raw.cxx.

809  {
810  if(compress == raw::kHuffman) UncompressHuffman(adc, uncompressed);
811  else if(compress == raw::kZeroSuppression){
812  ZeroUnsuppression(adc, uncompressed, pedestal);
813  }
814  else if(compress == raw::kZeroHuffman){
815  std::vector<short> tmp(2*adc[0]);
816  UncompressHuffman(adc, tmp);
817  ZeroUnsuppression(tmp, uncompressed, pedestal);
818  }
819  else if(compress == raw::kNone){
820  for(unsigned int i = 0; i < adc.size(); ++i) uncompressed[i] = adc[i];
821  }
822  else if (compress == raw::kFibonacci) {
823  UncompressFibonacci(adc, uncompressed);
824  }
825  else {
826  throw cet::exception("raw")
827  << "raw::Uncompress() does not support compression #"
828  << ((int) compress);
829  }
830  return;
831  }
Huffman Encoding.
Definition: RawTypes.h:10
void ZeroUnsuppression(const std::vector< short > &adc, std::vector< short > &uncompressed, int pedestal)
Definition: raw.cxx:745
void UncompressHuffman(const std::vector< short > &adc, std::vector< short > &uncompressed)
Definition: raw.cxx:1059
Zero Suppression followed by Huffman Encoding.
Definition: RawTypes.h:12
no compression
Definition: RawTypes.h:9
Zero Suppression algorithm.
Definition: RawTypes.h:11
string tmp
Definition: languages.py:63
Fibonacci encoding.
Definition: RawTypes.h:14
void UncompressFibonacci(const std::vector< short > &adc, std::vector< short > &uncompressed, std::function< int(std::vector< bool > &)> decode_table_chunk)
Definition: raw.cxx:1301
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void raw::UncompressFibonacci ( const std::vector< short > &  adc,
std::vector< short > &  uncompressed,
std::function< int(std::vector< bool > &)>  decode_table_chunk 
)

Definition at line 1301 of file raw.cxx.

1303  {
1304 
1305  // First compressed sample is the size
1306  size_t n_samples = (adc[0]<<(sizeof(short)*8-1))+adc[1];
1307  // The second compressed sample is the first uncompressed sample
1308  uncompressed.push_back(adc[2]);
1309 
1310  // The thing that we want to decode (rather than jumbled short vector)
1311  std::vector<bool> comp;
1312 
1313  for (size_t i=3; i<adc.size(); ++i) {
1314 
1315  std::bitset<8*sizeof(short)> this_encoded(adc[i]);
1316  for (size_t i2=0; i2<this_encoded.size(); ++i2) {
1317  comp.push_back(this_encoded[i2]);
1318  }
1319  }
1320 
1321  // The bit which has to be decoded ("chunk")
1322  std::vector<bool> current_number;
1323  for (size_t it=0; it<comp.size(); ++it) {
1324  current_number.push_back(comp[it]);
1325  // If we have at least 2 numbers in the current chunk
1326  // and if the last 2 number are one
1327  // and if we are not at the end
1328  if ((current_number.size()>=2 && it >= 1 && comp[it-1] == 1 && comp[it] == 1) || it == comp.size()-1) {
1329  current_number.pop_back();
1330  short zigzag_number = decode_table_chunk(current_number);
1331 
1332  short decoded = 0;
1333  if (zigzag_number%2 == 0) decoded = zigzag_number / 2;
1334  else decoded = -(zigzag_number - 1) / 2;
1335  short baseline = uncompressed.back();
1336 
1337  uncompressed.push_back(baseline + decoded);
1338 
1339  current_number.clear();
1340  if (uncompressed.size() == n_samples) break;
1341  }
1342  }
1343  return;
1344  }
void raw::UncompressHuffman ( const std::vector< short > &  adc,
std::vector< short > &  uncompressed 
)

Definition at line 1059 of file raw.cxx.

1061  {
1062 
1063  //the first entry in adc is a data value by construction
1064  uncompressed[0] = adc[0];
1065 
1066  unsigned int curu = 1;
1067  short curADC = uncompressed[0];
1068 
1069  // loop over the entries in adc and uncompress them according to the
1070  // encoding scheme above the CompressHuffman method
1071  for(unsigned int i = 1; i < adc.size() && curu < uncompressed.size(); ++i){
1072 
1073  std::bitset<16> bset(adc[i]);
1074 
1075  int numu = 0;
1076 
1077  //check the 15 bit to see if this entry is a full data value or not
1078  if( !bset.test(15) ){
1079  curADC = adc[i];
1080  if(bset.test(14)){
1081  bset.set(14, false);
1082  curADC = -1*bset.to_ulong();
1083  }
1084  uncompressed[curu] = curADC;
1085 
1086  ++curu;
1087  }
1088  else{
1089 
1090  int b = 14;
1091  int lowestb = 0;
1092 
1093  // ignore any padding with zeros in the lower order bits
1094  while( !bset.test(lowestb) && lowestb < 15) ++lowestb;
1095 
1096  if(lowestb > 14){
1097  mf::LogWarning("raw.cxx") << "encoded entry has no set bits!!! "
1098  << i << " "
1099  << bset.to_string< char,std::char_traits<char>,std::allocator<char> >();
1100  continue;
1101  }
1102 
1103  while( b >= lowestb){
1104 
1105  // count the zeros between the current bit and the next on bit
1106  int zerocnt = 0;
1107  while( !bset.test(b-zerocnt) && b-zerocnt > lowestb) ++zerocnt;
1108 
1109  b -= zerocnt;
1110 
1111  if(zerocnt == 0){
1112  for(int s = 0; s < 4; ++s){
1113  uncompressed[curu] = curADC;
1114  ++curu;
1115  ++numu;
1116  if(curu > uncompressed.size()-1) break;
1117  }
1118  --b;
1119  }
1120  else if(zerocnt == 1){
1121  uncompressed[curu] = curADC;
1122  ++curu;
1123  ++numu;
1124  --b;
1125  }
1126  else if(zerocnt == 2){
1127  curADC += 1;
1128  uncompressed[curu] = curADC;
1129  ++curu;
1130  ++numu;
1131  --b;
1132  }
1133  else if(zerocnt == 3){
1134  curADC -= 1;
1135  uncompressed[curu] = curADC;
1136  ++curu;
1137  ++numu;
1138  --b;
1139  }
1140  else if(zerocnt == 4){
1141  curADC += 2;
1142  uncompressed[curu] = curADC;
1143  ++curu;
1144  ++numu;
1145  --b;
1146  }
1147  else if(zerocnt == 5){
1148  curADC -= 2;
1149  uncompressed[curu] = curADC;
1150  ++curu;
1151  ++numu;
1152  --b;
1153  }
1154  else if(zerocnt == 6){
1155  curADC += 3;
1156  uncompressed[curu] = curADC;
1157  ++curu;
1158  ++numu;
1159  --b;
1160  }
1161  else if(zerocnt == 7){
1162  curADC -= 3;
1163  uncompressed[curu] = curADC;
1164  ++curu;
1165  ++numu;
1166  --b;
1167  }
1168 
1169  if(curu > uncompressed.size() - 1) break;
1170 
1171  }// end loop over bits
1172 
1173  if(curu > uncompressed.size() - 1) break;
1174 
1175  }// end if this entry in the vector is encoded
1176 
1177  }// end loop over entries in adc
1178 
1179  return;
1180  }
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
static bool * b
Definition: config.cpp:1043
static QCString * s
Definition: config.cpp:1042
void raw::ZeroSuppression ( std::vector< short > &  adc,
unsigned int &  zerothreshold 
)

Definition at line 173 of file raw.cxx.

175  {
176  const int adcsize = adc.size();
177  const int zerothresholdsigned = zerothreshold;
178 
179  std::vector<short> zerosuppressed(adc.size());
180  int maxblocks = adcsize/2 + 1;
181  std::vector<short> blockbegin(maxblocks);
182  std::vector<short> blocksize(maxblocks);
183 
184  unsigned int nblocks = 0;
185  unsigned int zerosuppressedsize = 0;
186 
187  int blockcheck = 0;
188 
189  for(int i = 0; i < adcsize; ++i){
190  int adc_current_value = std::abs(adc[i]);
191 
192  if(adc_current_value > zerothresholdsigned){
193 
194  if(blockcheck == 0){
195 
196  blockbegin[nblocks] = i;
197  blocksize[nblocks] = 0;
198  blockcheck=1;
199  }
200 
201  zerosuppressed[zerosuppressedsize] = adc[i];
202  zerosuppressedsize++;
203  blocksize[nblocks]++;
204 
205  if(i == adcsize-1) nblocks++;
206  }
207 
208  if(adc_current_value <= zerothresholdsigned && blockcheck == 1){
209  zerosuppressed[zerosuppressedsize] = adc[i];
210  zerosuppressedsize++;
211  blocksize[nblocks]++;
212  nblocks++;
213  blockcheck = 0;
214  }
215  }
216 
217 
218 
219  adc.resize(2+nblocks+nblocks+zerosuppressedsize);
220 
221  adc[0] = adcsize; //fill first entry in adc with length of uncompressed vector
222  adc[1] = nblocks;
223 
224 
225 
226  for(unsigned int i = 0; i < nblocks; ++i)
227  adc[i+2] = blockbegin[i];
228 
229  for(unsigned int i = 0; i < nblocks; ++i)
230  adc[i+nblocks+2] = blocksize[i];
231 
232  for(unsigned int i = 0; i < zerosuppressedsize; ++i)
233  adc[i+nblocks+nblocks+2] = zerosuppressed[i];
234 
235 
236  }
T abs(T value)
void raw::ZeroSuppression ( std::vector< short > &  adc,
unsigned int &  zerothreshold,
int &  nearestneighbor 
)

Definition at line 243 of file raw.cxx.

246  {
247 
248  const int adcsize = adc.size();
249  const int zerothresholdsigned = zerothreshold;
250 
251  std::vector<short> zerosuppressed(adcsize);
252  int maxblocks = adcsize/2 + 1;
253  std::vector<short> blockbegin(maxblocks);
254  std::vector<short> blocksize(maxblocks);
255 
256  int nblocks = 0;
257  int zerosuppressedsize = 0;
258 
259  int blockstartcheck = 0;
260  int endofblockcheck = 0;
261 
262  for(int i = 0; i < adcsize; ++i){
263  int adc_current_value = std::abs(adc[i]);
264 
265  if(blockstartcheck==0){
266  if(adc_current_value>zerothresholdsigned){
267  if(nblocks>0){
268  if((i-nearestneighbor)<=(blockbegin[nblocks-1]+blocksize[nblocks-1]+1)){
269 
270  nblocks--;
271  blocksize[nblocks] = i - blockbegin[nblocks] + 1;
272  blockstartcheck = 1;
273  }
274  else{
275  blockbegin[nblocks] = (i - nearestneighbor > 0) ? i - nearestneighbor : 0;
276  blocksize[nblocks] = i - blockbegin[nblocks] + 1;
277  blockstartcheck = 1;
278  }
279  }
280  else{
281  blockbegin[nblocks] = (i - nearestneighbor > 0) ? i - nearestneighbor : 0;
282  blocksize[nblocks] = i - blockbegin[nblocks] + 1;
283  blockstartcheck = 1;
284  }
285  }
286  }
287  else if(blockstartcheck==1){
288  if(adc_current_value>zerothresholdsigned){
289  blocksize[nblocks]++;
290  endofblockcheck = 0;
291  }
292  else{
293  if(endofblockcheck<nearestneighbor){
294  endofblockcheck++;
295  blocksize[nblocks]++;
296  }
297  //block has ended
298  else if(i+2<adcsize){ //check if end of adc vector is near
299  if(std::abs(adc[i+1]) <= zerothresholdsigned && std::abs(adc[i+2]) <= zerothresholdsigned){
300  endofblockcheck = 0;
301  blockstartcheck = 0;
302  nblocks++;
303  }
304  }
305 
306 
307  } // end else
308  } // end if blockstartcheck == 1
309  }// end loop over adc size
310 
311  if(blockstartcheck==1){ // we reached the end of the adc vector with the block still going
312  ++nblocks;
313  }
314 
315  for(int i = 0; i < nblocks; ++i)
316  zerosuppressedsize += blocksize[i];
317 
318 
319  adc.resize(2+nblocks+nblocks+zerosuppressedsize);
320  zerosuppressed.resize(2+nblocks+nblocks+zerosuppressedsize);
321 
322 
323  int zerosuppressedcount = 0;
324  for(int i = 0; i < nblocks; ++i){
325  //zerosuppressedsize += blocksize[i];
326  for(int j = 0; j < blocksize[i]; ++j){
327  zerosuppressed[zerosuppressedcount] = adc[blockbegin[i] + j];
328  zerosuppressedcount++;
329  }
330  }
331 
332  adc[0] = adcsize; //fill first entry in adc with length of uncompressed vector
333  adc[1] = nblocks;
334  for(int i = 0; i < nblocks; ++i){
335  adc[i+2] = blockbegin[i];
336  adc[i+nblocks+2] = blocksize[i];
337  }
338 
339 
340 
341  for(int i = 0; i < zerosuppressedsize; ++i)
342  adc[i+nblocks+nblocks+2] = zerosuppressed[i];
343 
344 
345  // for(int i = 0; i < 2 + 2*nblocks + zerosuppressedsize; ++i)
346  // std::cout << adc[i] << std::endl;
347  //adc.resize(2+nblocks+nblocks+zerosuppressedsize);
348  }
T abs(T value)
void raw::ZeroSuppression ( std::vector< short > &  adc,
unsigned int &  zerothreshold,
int  pedestal,
int &  nearestneighbor,
bool  fADCStickyCodeFeature 
)

Definition at line 354 of file raw.cxx.

359  {
360 
361  const int adcsize = adc.size();
362  const int zerothresholdsigned = zerothreshold;
363 
364  std::vector<short> zerosuppressed(adcsize);
365  int maxblocks = adcsize/2 + 1;
366  std::vector<short> blockbegin(maxblocks);
367  std::vector<short> blocksize(maxblocks);
368 
369  int nblocks = 0;
370  int zerosuppressedsize = 0;
371 
372  int blockstartcheck = 0;
373  int endofblockcheck = 0;
374 
375  for(int i = 0; i < adcsize; ++i){
376  int adc_current_value = ADCStickyCodeCheck(adc[i],pedestal,fADCStickyCodeFeature);
377 
378  if(blockstartcheck==0){
379  if(adc_current_value>zerothresholdsigned){
380  if(nblocks>0){
381  if(i-nearestneighbor<=blockbegin[nblocks-1]+blocksize[nblocks-1]+1){
382  nblocks--;
383  blocksize[nblocks] = i - blockbegin[nblocks] + 1;
384  blockstartcheck = 1;
385  }
386  else{
387  blockbegin[nblocks] = (i - nearestneighbor > 0) ? i - nearestneighbor : 0;
388  blocksize[nblocks] = i - blockbegin[nblocks] + 1;
389  blockstartcheck = 1;
390  }
391  }
392  else{
393  blockbegin[nblocks] = (i - nearestneighbor > 0) ? i - nearestneighbor : 0;
394  blocksize[nblocks] = i - blockbegin[nblocks] + 1;
395  blockstartcheck = 1;
396  }
397  }
398  }
399  else if(blockstartcheck==1){
400  if(adc_current_value>zerothresholdsigned){
401  blocksize[nblocks]++;
402  endofblockcheck = 0;
403  }
404  else{
405  if(endofblockcheck<nearestneighbor){
406  endofblockcheck++;
407  blocksize[nblocks]++;
408  }
409  //block has ended
410  else if(i+2<adcsize){ //check if end of adc vector is near
411  if(ADCStickyCodeCheck(adc[i+1],pedestal,fADCStickyCodeFeature) <= zerothresholdsigned && ADCStickyCodeCheck(adc[i+2],pedestal,fADCStickyCodeFeature) <= zerothresholdsigned){
412  endofblockcheck = 0;
413  blockstartcheck = 0;
414  nblocks++;
415  }
416  }
417  } // end else
418  } // end if blockstartcheck == 1
419  }// end loop over adc size
420 
421  if(blockstartcheck==1){ // we reached the end of the adc vector with the block still going
422  ++nblocks;
423  }
424 
425 
426  for(int i = 0; i < nblocks; ++i)
427  zerosuppressedsize += blocksize[i];
428 
429 
430  adc.resize(2+nblocks+nblocks+zerosuppressedsize);
431  zerosuppressed.resize(2+nblocks+nblocks+zerosuppressedsize);
432 
433 
434  int zerosuppressedcount = 0;
435  for(int i = 0; i < nblocks; ++i){
436  //zerosuppressedsize += blocksize[i];
437  for(int j = 0; j < blocksize[i]; ++j){
438  zerosuppressed[zerosuppressedcount] = adc[blockbegin[i] + j];
439  zerosuppressedcount++;
440  }
441  }
442 
443  adc[0] = adcsize; //fill first entry in adc with length of uncompressed vector
444  adc[1] = nblocks;
445  for(int i = 0; i < nblocks; ++i){
446  adc[i+2] = blockbegin[i];
447  adc[i+nblocks+2] = blocksize[i];
448  }
449 
450 
451 
452  for(int i = 0; i < zerosuppressedsize; ++i)
453  adc[i+nblocks+nblocks+2] = zerosuppressed[i];
454 
455 
456  // for(int i = 0; i < 2 + 2*nblocks + zerosuppressedsize; ++i)
457  // std::cout << adc[i] << std::endl;
458  //adc.resize(2+nblocks+nblocks+zerosuppressedsize);
459  }
int ADCStickyCodeCheck(const short adc_value, const int pedestal, bool fADCStickyCodeFeature)
Definition: raw.cxx:1185
void raw::ZeroSuppression ( const boost::circular_buffer< std::vector< short >> &  adcvec_neighbors,
std::vector< short > &  adc,
unsigned int &  zerothreshold,
int &  nearestneighbor 
)

Definition at line 465 of file raw.cxx.

469  {
470 
471  const int adcsize = adc.size();
472  const int zerothresholdsigned = zerothreshold;
473 
474  std::vector<short> zerosuppressed(adcsize);
475  const int maxblocks = adcsize/2 + 1;
476  std::vector<short> blockbegin(maxblocks);
477  std::vector<short> blocksize(maxblocks);
478 
479  int nblocks = 0;
480  int zerosuppressedsize = 0;
481 
482  int blockstartcheck = 0;
483  int endofblockcheck = 0;
484 
485  for(int i = 0; i < adcsize; ++i){
486 
487  //find maximum adc value among all neighboring channels within the nearest neighbor channel distance
488 
489  int adc_current_value = 0;
490 
491  for(boost::circular_buffer<std::vector<short>>::const_iterator adcveciter = adcvec_neighbors.begin(); adcveciter!=adcvec_neighbors.end();++adcveciter){
492  const std::vector<short> &adcvec_current = *adcveciter;
493  const int adcvec_current_single = std::abs(adcvec_current[i]);
494 
495  if(adc_current_value < adcvec_current_single){
496  adc_current_value = adcvec_current_single;
497  }
498 
499  }
500  if(blockstartcheck==0){
501  if(adc_current_value>zerothresholdsigned){
502  if(nblocks>0){
503  if(i-nearestneighbor<=blockbegin[nblocks-1]+blocksize[nblocks-1]+1){
504  nblocks--;
505  blocksize[nblocks] = i - blockbegin[nblocks] + 1;
506  blockstartcheck = 1;
507  }
508  else{
509  blockbegin[nblocks] = (i - nearestneighbor > 0) ? i - nearestneighbor : 0;
510  blocksize[nblocks] = i - blockbegin[nblocks] + 1;
511  blockstartcheck = 1;
512  }
513  }
514  else{
515  blockbegin[nblocks] = (i - nearestneighbor > 0) ? i - nearestneighbor : 0;
516  blocksize[nblocks] = i - blockbegin[nblocks] + 1;
517  blockstartcheck = 1;
518  }
519  }
520  }
521  else if(blockstartcheck==1){
522  if(adc_current_value>zerothresholdsigned){
523  blocksize[nblocks]++;
524  endofblockcheck = 0;
525  }
526  else{
527  if(endofblockcheck<nearestneighbor){
528  endofblockcheck++;
529  blocksize[nblocks]++;
530  }
531  //block has ended
532  else if(i+2<adcsize){ //check if end of adc vector is near
533  if(std::abs(adc[i+1]) <= zerothresholdsigned && std::abs(adc[i+2]) <= zerothresholdsigned){
534  endofblockcheck = 0;
535  blockstartcheck = 0;
536  nblocks++;
537  }
538  }
539 
540  } // end else
541  } // end if blockstartcheck == 1
542  }// end loop over adc size
543 
544  if(blockstartcheck==1){ // we reached the end of the adc vector with the block still going
545  ++nblocks;
546  }
547 
548 
549 
550  for(int i = 0; i < nblocks; ++i)
551  zerosuppressedsize += blocksize[i];
552 
553 
554  adc.resize(2+nblocks+nblocks+zerosuppressedsize);
555  zerosuppressed.resize(2+nblocks+nblocks+zerosuppressedsize);
556 
557 
558  int zerosuppressedcount = 0;
559  for(int i = 0; i < nblocks; ++i){
560  //zerosuppressedsize += blocksize[i];
561  for(int j = 0; j < blocksize[i]; ++j){
562  zerosuppressed[zerosuppressedcount] = adc[blockbegin[i] + j];
563  zerosuppressedcount++;
564  }
565  }
566 
567  adc[0] = adcsize; //fill first entry in adc with length of uncompressed vector
568  adc[1] = nblocks;
569  for(int i = 0; i < nblocks; ++i){
570  adc[i+2] = blockbegin[i];
571  adc[i+nblocks+2] = blocksize[i];
572  }
573 
574 
575 
576  for(int i = 0; i < zerosuppressedsize; ++i)
577  adc[i+nblocks+nblocks+2] = zerosuppressed[i];
578 
579 
580  // for(int i = 0; i < 2 + 2*nblocks + zerosuppressedsize; ++i)
581  // std::cout << adc[i] << std::endl;
582  //adc.resize(2+nblocks+nblocks+zerosuppressedsize);
583  }
T abs(T value)
void raw::ZeroSuppression ( const boost::circular_buffer< std::vector< short >> &  adcvec_neighbors,
std::vector< short > &  adc,
unsigned int &  zerothreshold,
int  pedestal,
int &  nearestneighbor,
bool  fADCStickyCodeFeature 
)

Definition at line 590 of file raw.cxx.

596  {
597 
598  const int adcsize = adc.size();
599  const int zerothresholdsigned = zerothreshold;
600 
601  std::vector<short> zerosuppressed(adcsize);
602  const int maxblocks = adcsize/2 + 1;
603  std::vector<short> blockbegin(maxblocks);
604  std::vector<short> blocksize(maxblocks);
605 
606  int nblocks = 0;
607  int zerosuppressedsize = 0;
608 
609  int blockstartcheck = 0;
610  int endofblockcheck = 0;
611 
612  for(int i = 0; i < adcsize; ++i){
613 
614  //find maximum adc value among all neighboring channels within the nearest neighbor channel distance
615 
616  int adc_current_value = ADCStickyCodeCheck(adc[i],pedestal,fADCStickyCodeFeature);
617 
618  for(boost::circular_buffer<std::vector<short>>::const_iterator adcveciter = adcvec_neighbors.begin(); adcveciter!=adcvec_neighbors.end();++adcveciter){
619  const std::vector<short> &adcvec_current = *adcveciter;
620  const int adcvec_current_single = std::abs(adcvec_current[i] - pedestal);
621 
622  if(adc_current_value < adcvec_current_single){
623  adc_current_value = adcvec_current_single;
624  }
625 
626  }
627  if(blockstartcheck==0){
628  if(adc_current_value>zerothresholdsigned){
629  if(nblocks>0){
630  if(i-nearestneighbor<=blockbegin[nblocks-1]+blocksize[nblocks-1]+1){
631  nblocks--;
632  blocksize[nblocks] = i - blockbegin[nblocks] + 1;
633  blockstartcheck = 1;
634  }
635  else{
636  blockbegin[nblocks] = (i - nearestneighbor > 0) ? i - nearestneighbor : 0;
637  blocksize[nblocks] = i - blockbegin[nblocks] + 1;
638  blockstartcheck = 1;
639  }
640  }
641  else{
642  blockbegin[nblocks] = (i - nearestneighbor > 0) ? i - nearestneighbor : 0;
643  blocksize[nblocks] = i - blockbegin[nblocks] + 1;
644  blockstartcheck = 1;
645  }
646  }
647  }
648  else if(blockstartcheck==1){
649  if(adc_current_value>zerothresholdsigned){
650  blocksize[nblocks]++;
651  endofblockcheck = 0;
652  }
653  else{
654  if(endofblockcheck<nearestneighbor){
655  endofblockcheck++;
656  blocksize[nblocks]++;
657  }
658  //block has ended
659 
660  else if(i+2<adcsize){ //check if end of adc vector is near
661  if(ADCStickyCodeCheck(adc[i+1],pedestal,fADCStickyCodeFeature) <= zerothresholdsigned && ADCStickyCodeCheck(adc[i+2],pedestal,fADCStickyCodeFeature) <= zerothresholdsigned){
662  endofblockcheck = 0;
663  blockstartcheck = 0;
664  nblocks++;
665  }
666  }
667 
668  } // end else
669  } // end if blockstartcheck == 1
670  }// end loop over adc size
671 
672  if(blockstartcheck==1){ // we reached the end of the adc vector with the block still going
673  ++nblocks;
674  }
675 
676 
677 
678  for(int i = 0; i < nblocks; ++i)
679  zerosuppressedsize += blocksize[i];
680 
681 
682  adc.resize(2+nblocks+nblocks+zerosuppressedsize);
683  zerosuppressed.resize(2+nblocks+nblocks+zerosuppressedsize);
684 
685 
686  int zerosuppressedcount = 0;
687  for(int i = 0; i < nblocks; ++i){
688  //zerosuppressedsize += blocksize[i];
689  for(int j = 0; j < blocksize[i]; ++j){
690  zerosuppressed[zerosuppressedcount] = adc[blockbegin[i] + j];
691  zerosuppressedcount++;
692  }
693  }
694 
695  adc[0] = adcsize; //fill first entry in adc with length of uncompressed vector
696  adc[1] = nblocks;
697  for(int i = 0; i < nblocks; ++i){
698  adc[i+2] = blockbegin[i];
699  adc[i+nblocks+2] = blocksize[i];
700  }
701 
702 
703 
704  for(int i = 0; i < zerosuppressedsize; ++i)
705  adc[i+nblocks+nblocks+2] = zerosuppressed[i];
706 
707 
708  // for(int i = 0; i < 2 + 2*nblocks + zerosuppressedsize; ++i)
709  // std::cout << adc[i] << std::endl;
710  //adc.resize(2+nblocks+nblocks+zerosuppressedsize);
711  }
int ADCStickyCodeCheck(const short adc_value, const int pedestal, bool fADCStickyCodeFeature)
Definition: raw.cxx:1185
T abs(T value)
void raw::ZeroUnsuppression ( const std::vector< short > &  adc,
std::vector< short > &  uncompressed 
)

Definition at line 716 of file raw.cxx.

718  {
719  const int lengthofadc = adc[0];
720  const int nblocks = adc[1];
721 
722  uncompressed.resize(lengthofadc);
723  for (int i = 0;i < lengthofadc; ++i){
724  uncompressed[i] = 0;
725  }
726 
727  int zerosuppressedindex = nblocks*2 + 2;
728 
729  for(int i = 0; i < nblocks; ++i){ //loop over each nonzero block of the compressed vector
730 
731  for(int j = 0; j < adc[2+nblocks+i]; ++j){//loop over each block size
732 
733  //set uncompressed value
734  uncompressed[adc[2+i]+j] = adc[zerosuppressedindex];
735  zerosuppressedindex++;
736 
737  }
738  }
739 
740  return;
741  }
void raw::ZeroUnsuppression ( const std::vector< short > &  adc,
std::vector< short > &  uncompressed,
int  pedestal 
)

Definition at line 745 of file raw.cxx.

748  {
749  const int lengthofadc = adc[0];
750  const int nblocks = adc[1];
751 
752  uncompressed.resize(lengthofadc);
753  for (int i = 0;i < lengthofadc; ++i){
754  uncompressed[i] = pedestal;
755  }
756 
757  int zerosuppressedindex = nblocks*2 + 2;
758 
759  for(int i = 0; i < nblocks; ++i){ //loop over each nonzero block of the compressed vector
760 
761  for(int j = 0; j < adc[2+nblocks+i]; ++j){//loop over each block size
762 
763  //set uncompressed value
764  uncompressed[adc[2+i]+j] = adc[zerosuppressedindex];
765  zerosuppressedindex++;
766 
767  }
768  }
769 
770  return;
771  }

Variable Documentation

constexpr ChannelID_t raw::InvalidChannelID = std::numeric_limits<ChannelID_t>::max()

ID of an invalid channel.

Definition at line 32 of file RawTypes.h.

const unsigned int raw::onemask = 0x003f

Definition at line 139 of file raw.h.