CFEL - ASG Software Suite  2.5.0
CASS
multifile_input.h
Go to the documentation of this file.
1 // Copyright (C) 2011 Lutz Foucar
2 
3 /**
4  * @file multifile_input.h file contains declaration of file input reading
5  * multiple files in parallel.
6  *
7  * @author Lutz Foucar
8  */
9 
10 #ifndef _MULTIFILEINPUT_H_
11 #define _MULTIFILEINPUT_H_
12 
13 #include <string>
14 
15 #include "input_base.h"
16 
17 #include "cass.h"
18 #include "ringbuffer.hpp"
19 #include "cass_event.h"
20 #include "file_reader.h"
21 
22 namespace cass
23 {
24 /** Multi File Input for cass
25  *
26  * This class will be used in offline modus. It will take an string that
27  * points to a file containing a list with filenames.
28  * The filename name must be passed to the program with the -i parameter.
29  *
30  * Purpose of this class is that one can read multiple files and associate
31  * the data of the different files using the event id. Therefore this class
32  * contains a map that allows to map an event id to a set of filestreams
33  * where the data associated with this event id can be found in the different
34  * files.
35  *
36  * Depending on the file extension of the file name it will call an instance
37  * to the right file parser. Once all files have been parsed an the event map
38  * has been build up it will iterate through the event map and read the data
39  * in the different files. The data is then converted to a CASSEvent and put
40  * into the RingBuffer
41  *
42  * @cassttng MultiFileInput/{NbrDifferentSources}\n
43  * Tells the program how many different sources it should expect. If
44  * for one eventId there are less sources recognized than this number
45  * a warning will be issued and the event is skipped. Default is 2.
46  * @cassttng MultiFileInput/{UseNewContainer}\n
47  * set to true if you want to use the new container for pixeldetector
48  * data that can make use of the new analysis chain. Default is false.
49  * @cassttng MultiFileInput/{Rewind}\n
50  * Tells the program to start over running over all files when true.
51  * Default is false.
52  *
53  * @author Lutz Foucar
54  */
55 class MultiFileInput : public InputBase
56 {
57 public:
58  /** create an instance of this
59  *
60  * @param filelistname name of the file containing all files that should be
61  * processed
62  * @param ringbuffer reference to the ringbuffer containing the CASSEvents
63  * @param ratemeter reference to the ratemeter to measure the rate of the input
64  * @param loadmeter reference to the ratemeter to measure the load of the input
65  * @param quitwhendone flag that tells this class that it should quit the
66  * Program when its done reading all events
67  * @param parent The parent QT Object of this class
68  */
69  static void instance(const std::string& filelistname,
71  Ratemeter &ratemeter,
72  Ratemeter &loadmeter,
73  bool quitwhendone,
74  QObject *parent=0);
75 
76  /** destructor */
78 
79  /** function with the main loop */
80  void runthis();
81 
82  /** load the parameters used for the multifile input */
83  void load();
84 
85 private:
86  /** constructor
87  *
88  * @param filelistname name of the file containing all files that should be
89  * processed
90  * @param ringbuffer reference to the ringbuffer containing the CASSEvents
91  * @param ratemeter reference to the ratemeter to measure the rate of the input
92  * @param loadmeter reference to the ratemeter to measure the load of the input
93  * @param quitwhendone flag that tells this class that it should quit the
94  * Program when its done reading all events
95  * @param parent The parent QT Object of this class
96  */
97  MultiFileInput(const std::string& filelistname,
98  RingBuffer<CASSEvent>& ringbuffer,
99  Ratemeter &ratemeter,
100  Ratemeter &loadmeter,
101  bool quitwhendone,
102  QObject *parent=0);
103 
104  /** read the information from the different files into the cassevent
105  *
106  * @param eventIt iterator to the map containing all events
107  */
108  void readEventData(event2positionreaders_t::iterator &eventIt);
109 
110  /** flag to tell the thread to quit when its done with all files */
112 
113  /** the name of the file that contains the list of file to process */
114  std::string _filelistname;
115 
116  /** flag that tells the input to rewind to the beginning of the eventlist */
117  bool _rewind;
118 
119  /** string to identify whether one want to use the new container */
120  std::string _new;
121 
122  /** the number of different sources */
124 };
125 
126 }//end namespace cass
127 
128 #endif
129 
130 
131 
132 // Local Variables:
133 // coding: utf-8
134 // mode: C++
135 // c-file-offsets: ((c . 0) (innamespace . 0))
136 // c-file-style: "Stroustrup"
137 // fill-column: 100
138 // End:
class calculating a rate in Hz.
Definition: ratemeter.h:28
file contains declaration of the CASSEvent
Input base class.
Definition: input_base.h:31
MultiFileInput(const std::string &filelistname, RingBuffer< CASSEvent > &ringbuffer, Ratemeter &ratemeter, Ratemeter &loadmeter, bool quitwhendone, QObject *parent=0)
constructor
RingBuffer< CASSEvent > & ringbuffer()
retrieve a reference to the the ringbuffer
Definition: input_base.cpp:43
A Ringbuffer, handles communication between Input and Worker Threads.
Definition: ringbuffer.hpp:52
~MultiFileInput()
destructor
void runthis()
function with the main loop
contains base class for all file readers
Multi File Input for cass.
file contains the ringbuffer class
file contains global definitions for project cass
bool _rewind
flag that tells the input to rewind to the beginning of the eventlist
size_t _nbrDifferentSources
the number of different sources
void load()
load the parameters used for the multifile input
static shared_pointer instance()
get the signelton instance
Definition: input_base.cpp:20
std::string _new
string to identify whether one want to use the new container
contains the base class for all input modules
bool _quitWhenDone
flag to tell the thread to quit when its done with all files
std::string _filelistname
the name of the file that contains the list of file to process
void readEventData(event2positionreaders_t::iterator &eventIt)
read the information from the different files into the cassevent