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