VDColdboxTDERawInput.h
Go to the documentation of this file.
1 /*
2  Input source driver for TDE coldbox data
3 
4 
5  */
6 #ifndef VDColdboxTDERawInput_h
7 #define VDColdboxTDERawInput_h
8 
16 
18 
19 #include <fstream>
20 #include <string>
21 
22 namespace raw {
23  //Forward declare the class
24  //The Class name is too long
25  class VDColdboxTDERawInput;
26 }
27 
28 
29 // anonymous namespace
30 namespace
31 {
32  typedef struct timespec trigstamp_t; // time_t tv_sec, long tv_nsec
33  //typedef std::vector<uint16_t> adcdata_t;
34  typedef std::vector< raw::RawDigit::ADCvector_t > adcbuf_t;
35  typedef std::vector<uint8_t> eflags_t;
36  typedef char BYTE;
37 
38  //
39  struct DaqEvent
40  {
41  // event has been correctly loaded
42  //bool valid;
43 
44  // global event quality flag
45  bool good;
46 
47  // run info
48  uint32_t runnum; // run number
49  uint8_t runflags;
50 
51  // event info
52  uint32_t evnum;
53  eflags_t evflags;
54 
55  // trigger info
56  uint8_t trigtype;
57  uint32_t trignum;
58  trigstamp_t trigstamp;
59 
60  // unpacked CRO ADC buffer
61  adcbuf_t crodata;
62 
63  // unpacked CRO ADC data
64  //adcdata_t lrodata;
65 
66  // number of decoded channels
67  unsigned chcro() const { return crodata.size(); }
68 
69  // CRO data compression
70  raw::Compress_t compression;
71  };
72 }
73 
74 //
75 //
77 {
78  public:
79  // Required constructor
82  art::SourceHelper const &pm );
83 
84  // Required by FileReaderSource
85  void closeCurrentFile();
86  void readFile( std::string const &name,
87  art::FileBlock* &fb);
88  bool readNext( art::RunPrincipal* const &inR,
89  art::SubRunPrincipal* const &inSR,
90  art::RunPrincipal* &outR,
91  art::SubRunPrincipal* &outSR,
92  art::EventPrincipal* &outE );
93 
94  private:
97 
105 
106  uint32_t __eventCtr;
107  uint32_t __eventNum;
108 
110 
111  // number of uncompressed samples per channel
112  size_t __nsacro;
114 
115  // close binary file
116  void __close();
117 
118  // read a chunk of binary data
119  void __readChunk( std::vector<BYTE> &bytes, size_t sz );
120 
121  // unpack binary data written by each L1 evb builder
122  bool __unpackEvent( std::vector<BYTE> &buf, DaqEvent &event );
123 
124  //
126 
127  // crp to daq mapping
128  std::vector<unsigned> __daqch;
129  std::vector<bool> __keepch;
130  // ped inversion to deal with the inverted signal polarity
131  std::vector<unsigned> __invped;
132 
133  // file locations
134  std::vector<std::streampos> __events;
135  std::vector<uint32_t> __evsz;
136 
137  // input file
138  size_t __filesz;
139  std::ifstream __file;
140  unsigned __file_seqno;
141 
142  // header sizes
143  enum { evinfoSz = 44 };
144 
145  // trigger structure from WR trigserver
146  typedef struct triginfo_t
147  {
148  uint8_t type;
149  uint32_t num;
150  struct timespec ts; //{ time_t ts.tv_sec, long tv_nsec }
151  } triginfo_t;
152 
153  // strucutre to hold decoded event header
154  typedef struct eveinfo_t
155  {
156  uint32_t runnum;
157  uint8_t runflags;
158  triginfo_t ti; // trigger info
159  uint8_t evflag; // data quality flag
160  uint32_t evnum; // event number
161  uint32_t evszlro; // size of event in bytes
162  uint32_t evszcro; // size of event in bytes
163  } eveinfo_t;
164 
165  // fragment from each L1 event builder
166  typedef struct fragment_t
167  {
169  const BYTE* bytes;
170  adcbuf_t crodata;
171  //adcbuf_t lrodata;
172  } fragment_t;
173 
174  //
175  unsigned __unpack_evtable();
176  unsigned __unpack_eve_info( const char *buf, eveinfo_t &ei );
177  unsigned __get_file_seqno( std::string s);
178 };
179 
180 #endif
static QCString name
Definition: declinfo.cpp:673
unsigned __get_file_seqno(std::string s)
enum raw::_compress Compress_t
struct raw::VDColdboxTDERawInput::triginfo_t triginfo_t
std::string string
Definition: nybbler.cc:12
struct raw::VDColdboxTDERawInput::fragment_t fragment_t
unsigned __unpack_eve_info(const char *buf, eveinfo_t &ei)
std::vector< unsigned > __invped
Raw data description.
std::vector< uint32_t > __evsz
VDColdboxTDERawInput(fhicl::ParameterSet const &pset, art::ProductRegistryHelper &helper, art::SourceHelper const &pm)
char BYTE
Definition: dlardaq.h:39
bool readNext(art::RunPrincipal *const &inR, art::SubRunPrincipal *const &inSR, art::RunPrincipal *&outR, art::SubRunPrincipal *&outSR, art::EventPrincipal *&outE)
art::SourceHelper const & __sourceHelper
bool __unpackEvent(std::vector< BYTE > &buf, DaqEvent &event)
void __readChunk(std::vector< BYTE > &bytes, size_t sz)
struct raw::VDColdboxTDERawInput::eveinfo_t eveinfo_t
std::vector< std::streampos > __events
std::vector< unsigned > __daqch
byte bytes
Alias for common language habits.
Definition: datasize.h:101
static QCString * s
Definition: config.cpp:1042
Event finding and building.
void readFile(std::string const &name, art::FileBlock *&fb)
std::string __getProducerLabel(std::string &lbl)