GET library
GETSystem.hh
Go to the documentation of this file.
1 //======================================================================
2 /*! \file GETSystem.hh
3  *
4  * Include file for the GETSystem class.
5  */
6 //======================================================================
7 
8 #ifndef GET_SYSTEM_HH
9 #define GET_SYSTEM_HH
10 
11 //----------------------------------------------------------------------
12 #include "GETCoBo.hh"
13 #include "GETRunFile.hh"
14 #include "GETRunList.hh"
15 #include "GETRunSerie.hh"
16 
17 #include "GETProcessSerie.hh"
18 #include "GETCalibProcess.hh"
19 #include "GETBaselineCorrection.hh"
20 #include "GETAutoBaselineLow.hh"
21 #include "GETAutoBaselineHigh.hh"
22 #include "GETFilterSmooth.hh"
23 
24 #include "GETCfgSetup.hh"
25 
26 #include "MFMCoboFrame.h"
27 #include "MFMCoboTopoFrame.h"
28 #include "MFMEbyedatFrame.h"
29 #include "MFMMutantFrame.h"
30 #include "MFMMergeFrame.h"
31 #include "MFMXmlFileHeaderFrame.h"
32 
33 #include "GETLookupTable.hh"
34 #include "GETHitMask.hh"
35 
36 #include <TH1D.h>
37 #include <TH2D.h>
38 #include <TH3D.h>
39 
40 class GETSystemAnalyser;
41 
42 //======================================================================
43 /*! \class GETSystem
44  *
45  * This class defines a the full GET system, controlling a variable
46  * number of CoBo modules.
47  *
48  * The static options may define general behaviour of the system,
49  * such as samples corrections at readout.
50  *
51  * The class defines some automatic corrections of raw data samples
52  * when reading an event (see options defined in the GET namespace),
53  * independently of the output data correction processes:
54  *
55  * - correction from FPN channels:
56  * - GET::CoBoCorrectFPN for closest FPN channel correction
57  * - GET::CoBoCorrectFPN2 for half-chip FPN channels correction
58  * - GET::CoBoCorrectFPN4 for average (AGET chip) FPN channels correction
59  *
60  * - apply a (software) zero suppresion on raw data:
61  * this option is not compatible with the FPN correction or with the
62  * automatic baseline correction
63  *
64  * Illustration of the event processing with GETSystem class:
65  *
66  * \image html GETEventProcessing.png
67  *
68  *
69  * \par Run files and run series
70  *
71  * When reading events with the GETSystem class (with ReadEvent function),
72  * a file must have been previously opened.
73  *
74  * - A run file is either a single file, either a set of several files
75  * with the same name, but with additional prefix \.1, .2... in
76  * case of automatic change of file during acquisition.
77  * - in this case, use the GETSystem::OpenRunFile function
78  * - the input file name may contain a \b * character to indicate
79  * that there can be more than 1 file (for example "run_0201.dat*")
80  * - A run serie is a list of run files, with different run numbers.
81  * - in this case, use the GETSystem::OpenRunSerie function
82  * - the file name must contain a %R code to indicate where is the
83  * run number
84  * - for example, <B><TT> OpenRunSerie ( "run_%4R.dat*", "201:203,206" ) </TT></B>
85  * will request
86  * to process files "run_0201.dat*", "run_0202.dat*", "run_0203.dat*"
87  * and "run_0206.dat*" (see above for the meaning of *).
88  *
89  *
90  * \par Lookup table
91  *
92  * A lookup table is associated to the GET system object in order to
93  * associate the detector channels positions to the electronics channels.
94  *
95  *
96  * \par Hit mask and hit channels
97  *
98  * A hit mask can be created (the look-up table must be defined) in
99  * order to select the channels for analysis.
100  *
101  * The hit mask defines 2 information for each channel:
102  * - whether it is selected for analysis
103  * - whether its signal is large enough
104  *
105  *
106  * \par Hit channels
107  *
108  * It should be noted that independently of the hit mask, the GET system
109  * class defines an array of logical values that indicates whether
110  * the channels have been filled with experimental data (for example
111  * in partial readout mode).
112  *
113  * This hit channel information is checked when applying automatic
114  * corrections to the raw data: FPN, automatic baseline, ...
115  *
116  *
117  * \par Data analyser
118  *
119  * The GETSystemAnalyser class is a base class for specific data analysis
120  * to be performed on the GETSystem data.
121  * Such an analyser can be defined with the GETSystem::SetAnalyser function.
122  *
123  * If an anlyser is defined, its data analysis functions will be called
124  * before and after output correction when experimental data are read.
125  */
126 class GETSystem : public GETObject
127 {
128  //------------------------------------------------------------
129  /*! \object_doc */
131  //------------------------------------------------------------
132 
133  friend class GETCfgSetup;
134 
135 
136  protected:
137  // GET architecture
138  u_int cobo_number; ///< Number of CoBo modules controlled
139  GETCoBo * cobo; ///< Array of CoBo modules
140 
141  u_int channel_count; ///< Total number of channels
142  GETChannel ** channel_summary; ///< Summary of channels pointers
143  bool * channel_hit; ///< Whether the channel contains data
144 
145  // GET system options
146  static u_int options; ///< Options for GET system
147 
148  // GET configuration
149  GETCfgSetup * config; ///< Configuration data
150 
151  // data file
152  GETRunFile * run_file; ///< Pointer to the input run data
153 
154  u_int mfm_frame_count; ///< Frame number in current file
155  MFMCommonFrame * mfm_frame; ///< Common frame for MFM in/out
156  MFMCoboFrame * mfm_frame_cobo; ///< Specific CoBo frame for MFM in/out
157 
158  char * mfm_buffer; ///< MFM frames data buffer
159  int mfm_buffer_size; ///< Size of allocated buffer
160  char ** mfm_buffer_adr; ///< Pointer of allocated buffer
161 
162  u_int event_count; ///< Number of events read (in file)
163 
164  // look-up table
165  GETLookupTable lookup_table; ///< Lookup table
166  GETHitMask * hit_mask; ///< Pointer to the hit mask
167 
168  // zero suppression
169  double zero_threshold; ///< Threshold for raw data zero suppression
170 
171  u_int saturation_value; ///< Coder value for channel saturation (set to 0 not to perform the analysis)
172  u_int saturation_mult; ///< Number of saturated data to consider a channel as saturated
173  u_int saturation_count; ///< Number of saturated channels (computed at raw event analysis)
174 
175  // data analyser
176  GETSystemAnalyser * analyser; ///< Pointer to a data analyser
177 
178  public:
179  //----------------------------------------------------------
180  /** @name Constructors, affectation, destructor */
181  //@{
182  GETSystem ( u_int n_cobo = 1, u_int dim = 0, double dt = 0.01L );
183  virtual ~GETSystem ( );
184  //@}
185 
186  //----------------------------------------------------------
187  /** @name Options functions */
188  //@{
189  static void SetOptions ( u_int opts ); // inline
190  static void SetOption ( u_int flags, bool b = true ); // inline
191  static u_int GetOptions ( ); // inline
192  static bool GetOption ( u_int flags ); // inline
193 
194  virtual void SetZeroSuppressMode ( double thr = 0. );
195 
196  virtual void SetSaturationValue ( int val ); // inline
197  virtual int GetSaturationValue ( ) const; // inline
198  virtual int GetSaturationCount ( ) const; // inline
199 
200  virtual bool IsChannelSaturated ( u_int ich ); // inline
201  virtual bool IsChannelSaturated ( const GETChannel & ch ); // inline
202  //@}
203 
204  //----------------------------------------------------------
205  /** @name GET configuration */
206  //@{
207  virtual int ResetConfig ( );
208  virtual int InitConfig ( );
209 
210  const GETCfgSetup * GetConfig ( ) const; // inline
211  GETCfgSetup * GetConfig ( ); // inline
212 
213  virtual int ReadXMLConfig ( const string & fname ); // inline
214  //@}
215 
216  //----------------------------------------------------------
217  /** @name Initialization functions */
218  //@{
219  virtual void Reset ( );
220  virtual int Init ( u_int n_cobo, u_int n, double dt );
221  virtual void ClearEvent ( );
222 
223  bool ChannelHasData ( u_int ic ) const; // inline
224  //@}
225 
226  //----------------------------------------------------------
227  /** @name GET system core objects functions */
228  //@{
229  virtual string GetObjectId ( ) const; // inline
230 
231  virtual u_int GetChildrenNumber ( ) const; // inline
232  virtual const GETObject * GetChild ( u_int i ) const; // inline
233  virtual GETObject * GetChild ( u_int i ); // inline
234 
235  const GETCoBo & operator [] ( u_int n ) const; // inline
236  GETCoBo & operator [] ( u_int n ); // inline
237 
238  virtual u_int GetCoBoNumber ( ) const; // inline
239  virtual u_int GetAsAdNumber ( ) const;
240 
241  virtual int GetChannelIndex ( const GETChannel * ch );
242  //@}
243 
244  //----------------------------------------------------------
245  /** @name Look-up table and analysis tools */
246  //@{
247  const GETLookupTable & LookupTable ( ) const; // inline
248  GETLookupTable & LookupTable ( ); // inline
249 
250  virtual u_int GetChannelCount ( ) const; // inline
251  virtual int GetChannelIndex ( int ix, int iy ) const; // inline
252  virtual GETChannel * GetChannel ( int ix, int iy ) const; // inline
253  virtual GETChannel * GetChannel ( u_int n ); // inline
254 
255  virtual GETHitMask * SetHitMask ( GETHitMask * mask );
256  GETHitMask * GetHitMask ( ) const; // inline
257 
258  virtual int SetAnalyser ( GETSystemAnalyser * a );
259  GETSystemAnalyser * GetAnalyser ( ) const; // inline
260  //@}
261 
262 
263  //----------------------------------------------------------
264  /** @name Data (output) correction processes */
265  //@{
266  virtual int SetCalibProcess ( const string & calib_file );
267  virtual int SetBaselineCorrection ( const string & bl_file );
268 
269  virtual int SetOutputSmoothing ( double width );
270 
271  virtual int SetAutoBaseline ( u_short num_lo, u_short num_hi,
272  u_short off_lo = 0, u_short off_hi = 0 );
273  virtual int SetAutoBaselineLow ( u_short num_lo, u_short off_lo = 0 );
274  virtual int SetAutoBaselineHigh ( u_short num_hi, u_short off_hi = 0 );
275  //@}
276 
277 
278  //----------------------------------------------------------
279  /** @name Access to class data */
280  //@{
281  u_int GetEventCount ( ) const; // inline
282  string GetRunFileName ( ) const; // inline
283  //@}
284 
285 
286  //----------------------------------------------------------
287  /** @name Experimental data readout */
288  //@{
289  virtual int OpenRunFile ( const string & fname );
290  virtual int OpenRunSerie ( const string & pattern, const string & serie );
291  virtual int CloseRunFile ( );
292  bool IsRunFileOpen ( ) const; // inline
293  GETRunFile * GetRunFile ( ); // inline
294 
295  virtual int ReadEvent ( bool process = true );
296 
297  virtual int AnalyseRawEvent ( );
298  virtual int AnalyseCorEvent ( );
299 
300  // read the frames
301  virtual int ExtractXMLFileHeaderFrame ( );
302  virtual int ExtractCoboTopoFrame ( );
303  virtual int ExtractCoboFrame ( );
304  virtual int ExtractEbyedatFrame ( );
305  virtual int ExtractMergeFrame ( );
306 
307  // get the data
308  virtual int ProcessFrameData ( MFMCommonFrame * frame );
309  virtual int ProcessMergeFrameData ( MFMMergeFrame * frame );
310  virtual int ProcessCoBoFrameData ( MFMCoboFrame * frame );
311  virtual int ProcessEbyedatFrameData ( MFMEbyedatFrame * frame );
312 
313  //@}
314 
315  //----------------------------------------------------------
316  /** @name Events processing and correction */
317  //@{
318  virtual GETChannel * GetMaximumChannel ( u_short info = GET::signalOut, bool integ = false );
319 
320  // corrections of raw events
321  virtual int OutputCorrectFPN ( u_int opt_fpn = GET::CoBoCorrectFPN4 );
322  virtual int ZeroSuppression ( double thr = 0. );
323  //@}
324 
325  //----------------------------------------------------------
326  /** @name User hook functions */
327  //@{
328 
329  virtual int AnyFrameUser ( MFMCommonFrame & frame );
330  virtual int MergeFrameUser ( MFMMergeFrame & frame );
331  virtual int CoBoFrameUser ( MFMCoboFrame & frame );
332  virtual int EbyedatFrameUser ( MFMEbyedatFrame & frame );
333 
334  //@}
335 
336  //----------------------------------------------------------
337  /** @name ROOT related functions */
338  //@{
339  public:
340 
341  /*! for use within ROOT.*/
342  ClassDef(GETSystem,0);
343  //@}
344 };
345 
346 
347 //----------------------------------------------------------------------
348 // Inline functions
349 #include "icc/GETSystem.icc"
350 
351 
352 //======================================================================
353 #endif
bool ChannelHasData(u_int ic) const
Definition: GETSystem.icc:115
static const u_short signalOut
Output (experimental data) signal sample.
Definition: GETCommon.hh:104
virtual int ExtractMergeFrame()
Definition: GETSystem.cpp:1222
virtual GETHitMask * SetHitMask(GETHitMask *mask)
Definition: GETSystem.cpp:351
const GETCfgSetup * GetConfig() const
Definition: GETSystem.icc:73
virtual int GetSaturationValue() const
Definition: GETSystem.icc:48
virtual u_int GetAsAdNumber() const
Definition: GETSystem.cpp:307
virtual int ProcessFrameData(MFMCommonFrame *frame)
Definition: GETSystem.cpp:1240
virtual int ExtractCoboFrame()
Definition: GETSystem.cpp:1166
virtual int SetAutoBaseline(u_short num_lo, u_short num_hi, u_short off_lo=0, u_short off_hi=0)
Definition: GETSystem.cpp:636
virtual int CloseRunFile()
Definition: GETSystem.cpp:854
const GETLookupTable & LookupTable() const
Definition: GETSystem.icc:141
u_int saturation_value
Coder value for channel saturation (set to 0 not to perform the analysis)
Definition: GETSystem.hh:171
virtual int AnalyseCorEvent()
Definition: GETSystem.cpp:1099
virtual u_int GetCoBoNumber() const
Definition: GETSystem.icc:121
virtual int ExtractCoboTopoFrame()
Definition: GETSystem.cpp:1144
virtual void ClearEvent()
Definition: GETSystem.cpp:290
static u_int options
Options for GET system.
Definition: GETSystem.hh:146
GETCfgSetup * config
Configuration data.
Definition: GETSystem.hh:149
bool IsRunFileOpen() const
Definition: GETSystem.icc:199
Definition: GETChannel.hh:41
virtual int ZeroSuppression(double thr=0.)
Definition: GETSystem.cpp:1689
virtual int ReadEvent(bool process=true)
Definition: GETSystem.cpp:898
virtual int ReadXMLConfig(const string &fname)
Definition: GETSystem.icc:83
static const u_int CoBoCorrectFPN4
When reading experimental data, correct with average FPN (only for signal channels) ...
Definition: GETCommon.hh:195
virtual int ProcessMergeFrameData(MFMMergeFrame *frame)
Definition: GETSystem.cpp:1299
bool * channel_hit
Whether the channel contains data.
Definition: GETSystem.hh:143
virtual int ProcessCoBoFrameData(MFMCoboFrame *frame)
Definition: GETSystem.cpp:1427
u_int cobo_number
Number of CoBo modules controlled.
Definition: GETSystem.hh:138
static void SetOption(u_int flags, bool b=true)
Definition: GETSystem.icc:21
u_int channel_count
Total number of channels.
Definition: GETSystem.hh:141
GETHitMask * GetHitMask() const
Definition: GETSystem.icc:175
virtual int SetBaselineCorrection(const string &bl_file)
Definition: GETSystem.cpp:510
char ** mfm_buffer_adr
Pointer of allocated buffer.
Definition: GETSystem.hh:160
GETSystemAnalyser * GetAnalyser() const
Definition: GETSystem.icc:180
virtual int SetAnalyser(GETSystemAnalyser *a)
Definition: GETSystem.cpp:379
virtual int SetAutoBaselineHigh(u_short num_hi, u_short off_hi=0)
Definition: GETSystem.cpp:721
GETSystemAnalyser * analyser
Pointer to a data analyser.
Definition: GETSystem.hh:176
u_int GetEventCount() const
Definition: GETSystem.icc:188
MFMCommonFrame * mfm_frame
Common frame for MFM in/out.
Definition: GETSystem.hh:155
virtual int MergeFrameUser(MFMMergeFrame &frame)
Definition: GETSystem.icc:226
virtual int OpenRunFile(const string &fname)
Definition: GETSystem.cpp:760
u_int mfm_frame_count
Frame number in current file.
Definition: GETSystem.hh:154
virtual int ExtractXMLFileHeaderFrame()
Definition: GETSystem.cpp:1118
Definition: GETHitMask.hh:29
u_int saturation_mult
Number of saturated data to consider a channel as saturated.
Definition: GETSystem.hh:172
virtual ~GETSystem()
Definition: GETSystem.cpp:73
Definition: GETObject.hh:38
Definition: GETRunFile.hh:29
GETCoBo * cobo
Array of CoBo modules.
Definition: GETSystem.hh:139
virtual int OpenRunSerie(const string &pattern, const string &serie)
Definition: GETSystem.cpp:814
virtual string GetObjectId() const
Definition: GETSystem.icc:91
virtual int OutputCorrectFPN(u_int opt_fpn=GET::CoBoCorrectFPN4)
Definition: GETSystem.cpp:1606
virtual const GETObject * GetChild(u_int i) const
Definition: GETSystem.icc:101
double zero_threshold
Threshold for raw data zero suppression.
Definition: GETSystem.hh:169
virtual int ResetConfig()
Definition: GETSystem.cpp:140
u_int event_count
Number of events read (in file)
Definition: GETSystem.hh:162
virtual u_int GetChannelCount() const
Definition: GETSystem.icc:149
char * mfm_buffer
MFM frames data buffer.
Definition: GETSystem.hh:158
Definition: GETCfgSetup.hh:26
virtual int ExtractEbyedatFrame()
Definition: GETSystem.cpp:1204
static bool GetOption(u_int flags)
Definition: GETSystem.icc:33
virtual int InitConfig()
Definition: GETSystem.cpp:158
GETRunFile * run_file
Pointer to the input run data.
Definition: GETSystem.hh:152
GETLookupTable lookup_table
Lookup table.
Definition: GETSystem.hh:165
virtual int GetChannelIndex(const GETChannel *ch)
Definition: GETSystem.cpp:320
ClassDef(GETSystem, 0)
virtual void Reset()
Definition: GETSystem.cpp:180
GObject(GETSystem)
Definition: GETLookupTable.hh:32
virtual int AnyFrameUser(MFMCommonFrame &frame)
Definition: GETSystem.icc:218
virtual int Init(u_int n_cobo, u_int n, double dt)
Definition: GETSystem.cpp:212
u_int saturation_count
Number of saturated channels (computed at raw event analysis)
Definition: GETSystem.hh:173
virtual int SetCalibProcess(const string &calib_file)
Definition: GETSystem.cpp:421
virtual int SetAutoBaselineLow(u_short num_lo, u_short off_lo=0)
Definition: GETSystem.cpp:679
Definition: GETSystemAnalyser.hh:281
virtual int ProcessEbyedatFrameData(MFMEbyedatFrame *frame)
Definition: GETSystem.cpp:1534
static void SetOptions(u_int opts)
Definition: GETSystem.icc:14
virtual int EbyedatFrameUser(MFMEbyedatFrame &frame)
Definition: GETSystem.icc:242
virtual GETChannel * GetChannel(int ix, int iy) const
Definition: GETSystem.icc:163
virtual int CoBoFrameUser(MFMCoboFrame &frame)
Definition: GETSystem.icc:234
virtual int AnalyseRawEvent()
Definition: GETSystem.cpp:1068
GETSystem(u_int n_cobo=1, u_int dim=0, double dt=0.01L)
Definition: GETSystem.cpp:25
virtual bool IsChannelSaturated(u_int ich)
Definition: GETSystem.icc:59
const GETCoBo & operator[](u_int n) const
Definition: GETSystem.icc:128
MFMCoboFrame * mfm_frame_cobo
Specific CoBo frame for MFM in/out.
Definition: GETSystem.hh:156
virtual u_int GetChildrenNumber() const
Definition: GETSystem.icc:95
GETHitMask * hit_mask
Pointer to the hit mask.
Definition: GETSystem.hh:166
virtual GETChannel * GetMaximumChannel(u_short info=GET::signalOut, bool integ=false)
Definition: GETSystem.cpp:1566
static u_int GetOptions()
Definition: GETSystem.icc:26
Definition: GETCoBo.hh:27
virtual void SetZeroSuppressMode(double thr=0.)
Definition: GETSystem.cpp:122
string GetRunFileName() const
Definition: GETSystem.icc:192
virtual int SetOutputSmoothing(double width)
Definition: GETSystem.cpp:581
virtual int GetSaturationCount() const
Definition: GETSystem.icc:52
int mfm_buffer_size
Size of allocated buffer.
Definition: GETSystem.hh:159
virtual void SetSaturationValue(int val)
Definition: GETSystem.icc:42
GETRunFile * GetRunFile()
Definition: GETSystem.icc:203
Definition: GETSystem.hh:126
GETChannel ** channel_summary
Summary of channels pointers.
Definition: GETSystem.hh:142