CFEL - ASG Software Suite  2.5.0
CASS
xfel_hdf5_file_input.h
Go to the documentation of this file.
1 // Copyright (C) 2017 Lutz Foucar
2 
3 /**
4  * @file xfel_hdf5_file_input.h contains a xfel hdf5 file reader class
5  *
6  * @author Lutz Foucar
7  */
8 
9 #ifndef _XFELHDF5FILEINPUT_H_
10 #define _XFELHDF5FILEINPUT_H_
11 
12 #include <string>
13 
14 #include "input_base.h"
15 #include "cass.h"
16 #include "ringbuffer.hpp"
17 #include "cass_event.h"
18 #include "file_reader.h"
19 
20 namespace cass
21 {
22 /** XFEL HDF5 File Input for cass
23  *
24  * @cassttng XFELHDF5FileInput/{MaxPulseId}\n
25  * The maximum pulse id that will be used to iterate through. Default is 65.
26  * @cassttng XFELHDF5FileInput/{PreCacheData}\n
27  * Flag that allows precaching the whole files by reading the contents to memory.
28  * Need to ensure that you've got enough memory available first otherwise the
29  * program will crash. Default is true.
30  * @cassttng XFELHDF5FileInput/AGIPD/{DataCASSID}\n
31  * ID that the agipd data will have in the cassevent. Default is 30
32  * @cassttng XFELHDF5FileInput/AGIPD/{MaskCASSID}\n
33  * ID that the agipd mask will have in the cassevent. Default is 31
34  * @cassttng XFELHDF5FileInput/AGIPD/{GainCASSID}\n
35  * ID that the agipd gain information will have in the cassevent. Default is 32
36  * @cassttng XFELHDF5FileInput/AGIPD/Tiles/\%index\%/{Id}\n
37  * ID of the tile. Default is -1 which will skip this entry
38  * @cassttng XFELHDF5FileInput/AGIPD/Tiles/\%index\%/{HDF5FileName}\n
39  * HDF5 file that contains the data of the tile.
40  * Default is Invalid which will skip this entry
41  * @cassttng XFELHDF5FileInput/AGIPD/Tiles/\%index\%/{DataHDF5Key}\n
42  * Key to the data of the tile in the HDF5 file.
43  * Default is Invalid which will skip this entry
44  * @cassttng XFELHDF5FileInput/AGIPD/Tiles/\%index\%/{MaskHDF5Key}\n
45  * Key to the mask of the tile in the HDF5 file.
46  * Default is Invalid which will skip this entry
47  * @cassttng XFELHDF5FileInput/AGIPD/Tiles/\%index\%/{GainHDF5Key}\n
48  * Key to the gain data of the tile in the HDF5 file.
49  * Default is Invalid which will skip this entry
50  * @cassttng XFELHDF5FileInput/AGIPD/Tiles/\%index\%/{TrainIdHDF5Key}\n
51  * Key to the train Id of the tile in the HDF5 file.
52  * Default is Invalid which will skip this entry
53  * @cassttng XFELHDF5FileInput/AGIPD/Tiles/\%index\%/{PulseIdHDF5Key}\n
54  * Key to the pulse Id of the tile in the HDF5 file.
55  * Default is Invalid which will skip this entry
56  * @cassttng XFELHDF5FileInput/AGIPD/Tiles/\%index\%/{CellIdHDF5Key}\n
57  * Key to the cell Id of the tile in the HDF5 file.
58  * Default is Invalid which will skip this entry
59  *
60  * @author Lutz Foucar
61  */
63 {
64 public:
65  /** create instance of this
66  *
67  * @param filelistname name of the file containing all files that should be
68  * processed
69  * @param ringbuffer reference to the ringbuffer containing the CASSEvents
70  * @param ratemeter reference to the ratemeter to measure the rate of the input
71  * @param loadmeter reference to the ratemeter to measure the load of the input
72  * @param quitwhendone flag that tells this class that it should quit the
73  * Program when its done reading all events
74  * @param parent The parent QT Object of this class
75  */
76  static void instance(std::string filelistname,
78  Ratemeter &ratemeter,
79  Ratemeter &loadmeter,
80  bool quitwhendone,
81  QObject *parent=0);
82 
83  /** function with the main loop */
84  void runthis();
85 
86  /** load the parameters used for the multifile input */
87  void load();
88 
89  /** retrieve the averaged progress state of all file processors
90  *
91  * @return the processing progress
92  */
93  double progress() {return static_cast<double>(_counter) /
94  static_cast<double>(_totalevents);}
95 
96  /** retrieve the number of processed events
97  *
98  * @return number of processed events
99  */
100  uint64_t eventcounter() {return _counter;}
101 
102  /** retrieve the number of skipped processed events
103  *
104  * @return number of processed events
105  */
106  uint64_t skippedeventcounter() {return _scounter;}
107 
108 public:
109  /** parameters needed to retrieve the Acqiris data */
111  {
112  /** name of the waveform datafield */
113  std::string DataKey;
114  /** name of the field that contains the horpos value */
115  std::string HorposKey;
116  /** name of the field that contains the vertical offset value */
117  std::string VertOffsetKey;
118  /** name of the field that contains the gain value */
119  std::string GainKey;
120  /** name of the field that contains the sample interval */
121  std::string SampleIntervalKey;
122  /** the instrument within the CASSEvent that should be used */
123  uint32_t Instrument;
124  /** the channel with the instrument within the CASSEvent that the data should
125  * loaded to
126  */
128  };
129 
130  /** parameters needed to retrieve the pixeldetector data */
132  {
133  /** name of the waveform datafield */
134  std::string DataKey;
135 
136  /** the id of the pixeldetector that it should have in the CASSEvent */
137  int CASSID;
138  };
139 
140 private:
141  /** constructor
142  *
143  * @param filelistname name of the file containing all files that should be
144  * processed
145  * @param ringbuffer reference to the ringbuffer containing the CASSEvents
146  * @param ratemeter reference to the ratemeter to measure the rate of the input
147  * @param loadmeter reference to the ratemeter to measure the load of the input
148  * @param quitwhendone flag that tells this class that it should quit the
149  * Program when its done reading all events
150  * @param parent The parent QT Object of this class
151  */
152  XFELHDF5FileInput(std::string filelistname,
154  Ratemeter &ratemeter,
155  Ratemeter &loadmeter,
156  bool quitwhendone,
157  QObject *parent=0);
158 
159  /** flag to tell the thread to quit when its done with all files */
161 
162  /** name of the file containing all files that we need to process */
163  std::string _filelistname;
164 
165  /** the counter for all events */
166  uint64_t _counter;
167 
168  /** the counter for all events */
169  uint64_t _scounter;
170 
171  /** the total # of events to be handled */
172  uint64_t _totalevents;
173 };
174 
175 }//end namespace cass
176 
177 #endif
uint64_t _totalevents
the total # of events to be handled
void load()
load the parameters used for the multifile input
int CASSID
the id of the pixeldetector that it should have in the CASSEvent
double progress()
retrieve the averaged progress state of all file processors
parameters needed to retrieve the Acqiris data
class calculating a rate in Hz.
Definition: ratemeter.h:28
file contains declaration of the CASSEvent
Input base class.
Definition: input_base.h:31
uint64_t _scounter
the counter for all events
uint64_t _counter
the counter for all events
bool _quitWhenDone
flag to tell the thread to quit when its done with all files
uint32_t Instrument
the instrument within the CASSEvent that should be used
std::string SampleIntervalKey
name of the field that contains the sample interval
A Ringbuffer, handles communication between Input and Worker Threads.
Definition: ringbuffer.hpp:52
XFEL HDF5 File Input for cass.
uint64_t eventcounter()
retrieve the number of processed events
contains base class for all file readers
std::string _filelistname
name of the file containing all files that we need to process
file contains the ringbuffer class
std::string GainKey
name of the field that contains the gain value
file contains global definitions for project cass
uint64_t skippedeventcounter()
retrieve the number of skipped processed events
static shared_pointer instance()
get the signelton instance
Definition: input_base.cpp:20
XFELHDF5FileInput(std::string filelistname, RingBuffer< CASSEvent > &, Ratemeter &ratemeter, Ratemeter &loadmeter, bool quitwhendone, QObject *parent=0)
constructor
contains the base class for all input modules
void runthis()
function with the main loop
parameters needed to retrieve the pixeldetector data
std::string VertOffsetKey
name of the field that contains the vertical offset value
std::string DataKey
name of the waveform datafield
size_t ChannelNumber
the channel with the instrument within the CASSEvent that the data should loaded to ...
std::string DataKey
name of the waveform datafield
std::string HorposKey
name of the field that contains the horpos value