GET library
GETCommon.hh
Go to the documentation of this file.
1 //======================================================================
2 /*! \file GETCommon.hh
3  *
4  * Common include file for library sources.
5  */
6 //======================================================================
7 
8 #ifndef GET_COMMON_HH
9 #define GET_COMMON_HH
10 
11 //----------------------------------------------------------------------
12 
13 // GCpp base include files
14 #include "GGlobal.hh"
15 #include "GBaseFunctions.hh"
16 #include "GLogMessage.hh"
17 #include "GString.hh"
18 
19 // ROOT / GRootTools include files
20 #include "TSystem.h"
21 #include "TRandom3.h"
22 #include "TMath.h"
23 #include "TGraphErrors.h"
24 #include "TGraph2DErrors.h"
25 #include "TFile.h"
26 
27 // GFFT include files
28 #include "RRealSampleFFT.hh"
29 
30 //! Define the data type for samples
31 typedef RRealSampleFFT GETSample;
32 
33 //! Maximum data depth
34 #define GET_MAX_DEPTH 512
35 
36 // Xerces-c include filess (for XML parsing)
37 #include <xercesc/util/PlatformUtils.hpp>
38 #include <xercesc/sax/HandlerBase.hpp>
39 #include <xercesc/parsers/XercesDOMParser.hpp>
40 #include <xercesc/dom/DOM.hpp>
41 #include <xercesc/util/XMLString.hpp>
42 
43 using namespace xercesc;
44 
45 // GET general include files
46 #include "GETMetaFrame.hh"
47 
48 //----------------------------------------------------------------------
49 
50 //! Macro inverting 2 bytes values
51 #define GET_SWAP_BYTES(a,b) { byte __tmp = a; a = b; b = __tmp; }
52 
53 
54 //----------------------------------------------------------------------
55 
56 //! End of file returned value
57 #define GET_EOF -1
58 
59 //! Error code for file problem
60 #define GET_FILE_ERROR 1
61 
62 //! Error code for frame problem
63 #define GET_FRAME_ERROR 3
64 
65 //! Warning code for MFM frames problem
66 #define GET_FRAME_WARN -2
67 
68 
69 //======================================================================
70 // Global variables
71 // (defined in GETObject.cpp file)
72 
73 /*! Unique random generator for GET library.*/
74 extern TRandom3 GETRandom; ///< Random numbers generator
75 
76 
77 //======================================================================
78 /*! \namespace GET
79  *
80  * This namespace defines some values for GET objects and configuration
81  * files.
82  */
83 namespace GET
84 {
85  //----------------------------------------------------------
86  /** @name Experimental / simulation data modes */
87  //@{
88 
89  //! The samples are filled from an experimental data file (in channel output sample)
90  static const u_short modeUndefined = 0;
91 
92  //! The samples are filled from an experimental data file (in channel output sample)
93  static const u_short modeData = 1;
94 
95  //! The samples are filled from an experimental data file (in channel output sample)
96  static const u_short modeSimul = 2;
97  //@}
98 
99  //----------------------------------------------------------
100  /** @name Channel signal sample identifier */
101  //@{
102 
103  //! Undefined signal sample
104  static const u_short signalUndef = 0;
105 
106  //! Test input (simulation) signal sample
107  static const u_short signalTst = 1;
108 
109  //! Output (experimental data) signal sample
110  static const u_short signalOut = 2;
111 
112  //! Reconstructed signal sample
113  static const u_short signalRec = 3;
114  //@}
115 
116  //----------------------------------------------------------
117  /** @name Channel information identifier for analyser (histograms filling) */
118  //@{
119 
120  //! Computed signal amplitude (depends on amplitude mode)
121  static const u_short dataAmplitude = 0x0000;
122 
123  //! Integral of signal data
124  static const u_short dataIntegral = 0x0001;
125 
126  //! Full signal data (for 3D)
127  static const u_short dataFullSignal = 0x0002;
128 
129  //! Time of maximum value of signal data
130  static const u_short dataTime = 0x0004;
131 
132  //! Time bucket of maximum value of signal data
133  static const u_short dataTimeBin = 0x000C;
134 
135  //! Whether the channel is hit (1) or not (0)
136  static const u_short dataHit = 0x0010;
137 
138  //! Whether not to consider saturated data (in summary histo filling)
139  static const u_short dataNoSat = 0x0020;
140 
141  //! Whether not to consider channels with check problems (in summary histo filling)
142  static const u_short dataNoBad = 0x0040;
143 
144  //@}
145 
146  //----------------------------------------------------------
147  /** @name Analysis options */
148  //@{
149 
150  //! Perform input signal reconstruction
151  static const u_short analyseInputRec = 0x0001;
152 
153  //! Perform raw signal analysis
154  static const u_short analyseRaw = 0x0002;
155 
156  //! Perform corrected signal analysis
157  static const u_short analyseCor = 0x0004;
158 
159  //! Perform raw and corrected signal analysis
160  static const u_short analyseAll = 0x0006;
161 
162  //! Perform raw and corrected signal analysis with input signal reconstruction
163  static const u_short analyseRecAll = 0x0007;
164 
165  //@}
166 
167  //----------------------------------------------------------
168  /** @name Channels amplitude and timing analysis modes */
169  //@{
170 
171  //! Channel amplitude calculation mode: maximum signal time bucket
172  static const u_short amplitudeMaxSignal = 0x0000;
173 
174  //! Channel amplitude calculation mode: integrate all signal
175  static const u_short amplitudeIntegAll = 0x0001;
176 
177  //! Channel amplitude calculation mode: integrate signal over threshold around maximum
178  static const u_short amplitudeIntegTOT = 0x0002;
179 
180  //! Channel amplitude calculation mode: integrate all signal over threshold
181  static const u_short amplitudeIntegThr = 0x0003;
182 
183  //! Channel amplitude (and time) from quadratic estimate on 3 points
184  static const u_short amplitudeQuadraticMax = 0x0004;
185 
186  // -- fits analysis modes
187 
188  //! Flag indicating fit function
189  static const u_short amplitudeFitFct = 0x001F;
190  //! Flag indicating fit mode
191  static const u_short amplitudeFit = 0x0010;
192  //! Flag indicating Gauss fit mode
193  static const u_short amplitudeFitG = 0x0011;
194  //! Flag indicating Gauss x SinC fit mode
195  static const u_short amplitudeFitGSC = 0x0012;
196  //! Flag indicating Square convolution with Gauss fit mode
197  static const u_short amplitudeFitSqG = 0x0013;
198  //! Flag indicating Square convolution with Gauss x SinC fit mode
199  static const u_short amplitudeFitSqGSC = 0x0014;
200  //! Flag indicating fit integral result
201  static const u_short amplitudeFitInteg = 0x0100;
202 
203  //! Channel amplitude calculation mode: maximum of a Gauss fit (with constant background)
204  static const u_short amplitudeMaxFitG = 0x0011;
205 
206  //! Channel amplitude calculation mode: integral of a Gauss fit (with constant background)
207  static const u_short amplitudeIntegFitG = 0x0111;
208 
209  //! Channel amplitude calculation mode: maximum of a Gauss x SinC fit (with constant background)
210  static const u_short amplitudeMaxFitGSC = 0x0012;
211 
212  //! Channel amplitude calculation mode: integral of a Gauss x SinC fit (with constant background)
213  static const u_short amplitudeIntegFitGSC = 0x0112;
214 
215  //! Channel amplitude calculation mode: maximum of a Square convolution with Gauss fit (with constant background)
216  static const u_short amplitudeMaxFitSqG = 0x0013;
217 
218  //! Channel amplitude calculation mode: maximum of a Square convolution with Gauss fit (with constant background)
219  static const u_short amplitudeIntegFitSqG = 0x0113;
220 
221  //! Channel amplitude calculation mode: maximum of a Square convolution with Gauss x SinC fit (with constant background)
222  static const u_short amplitudeMaxFitSqGSC = 0x0014;
223 
224  //! Channel amplitude calculation mode: maximum of a Square convolution with Gauss x SinC fit (with constant background)
225  static const u_short amplitudeIntegFitSqGSC = 0x0114;
226 
227  //// Channel amplitude calculation mode: integral of the Gaus part of a Gaus x SinC fit (with constant background)
228  ////static const u_short amplitudeIntGausFitGSC = 0x0112;
229 
230  // -- local analysis modes
231 
232  //! Flag indicating local analysis mode
233  static const u_short amplitudeLocal = 0x0200;
234 
235  //! Channel amplitude calculation mode: average around maximum signal time bucket
236  static const u_short amplitudeLocalAvg = 0x0200;
237 
238  //! Channel amplitude calculation mode: quadratic fit around maximum signal time bucket
239  static const u_short amplitudeLocalFitP2 = 0x0201;
240 
241 
242  //! Channel timing from maximum amplitude
243  static const u_short timingMaxSignal = 0x0000;
244 
245  //! Channel timing from CFD algorithm
246  static const u_short timingCFD = 0x0001;
247 
248  //! Channel timing from quadratic estimate on 3 points
249  static const u_short timingQuadraticMax = 0x0002;
250 
251  //@}
252 
253  //----------------------------------------------------------
254  /** @name Reduced-CoBo options */
255  //@{
256 
257  //! When reading experimental data, correct for sample 0 artefact
258  static const u_int RCoBoData0Correction = 0x00000001;
259 
260  //! When reading experimental data, correct for last sample artefact
261  static const u_int RCoBoDataNCorrection = 0x00000002;
262 
263  //! When reading experimental data, correct for last cell read of AGet number 2
264  static const u_int RCoBoCorrectLC2 = 0x00000010;
265 
266  //! When reading experimental data, correct with closer FPN channel (only for signal channels)
267  static const u_int RCoBoCorrectFPN1 = 0x00000020;
268 
269  //! When reading experimental data, correct with 2 half chip FPN channels average (only for signal channels)
270  static const u_int RCoBoCorrectFPN2 = 0x00000040;
271 
272  //! When reading experimental data, correct with average FPN (only for signal channels)
273  static const u_int RCoBoCorrectFPN4 = 0x00000060;
274  //! When reading experimental data, correct with average FPN (only for signal channels)
275  static const u_int RCoBoCorrectFPN = 0x00000060;
276 
277  //! all option for corrections when reading events
278  static const u_int RCoBoCorrectEvents = 0x000000FF;
279 
280  //@}
281 
282  //----------------------------------------------------------
283  /** @name All GET systems options */
284  //@{
285 
286  //! When reading experimental data, correct for first sample(s) artefact
288 
289  //! When reading experimental data, correct for last sample(s) artefact
291 
292  //! When reading experimental data, correct with closer FPN channel (only for signal channels)
293  static const u_int CoBoCorrectFPN1 = RCoBoCorrectFPN1;
294 
295  //! When reading experimental data, correct with 2 half chip FPN channels average (only for signal channels)
296  static const u_int CoBoCorrectFPN2 = RCoBoCorrectFPN2;
297 
298  //! When reading experimental data, correct with average FPN (only for signal channels)
299  static const u_int CoBoCorrectFPN4 = RCoBoCorrectFPN4;
300  //! When reading experimental data, correct with average FPN (only for signal channels)
301  static const u_int CoBoCorrectFPN = RCoBoCorrectFPN4;
302 
303 
304  /*! When reading experimental data, a (software) zero suppression is
305  * performed on data.
306  * Note that this option cancels the FPN and automatic baseline
307  * corrections.
308  */
309  static const u_int CoBoZeroSuppress = 0x00000400;
310 
311  /*! Option to check and correct for bad data read (this option
312  * works only if hardware zero suppress mode is NOT set).
313  */
314  static const u_int CoBoCorrectBadData = 0x00001000;
315 
316  //! All options for corrections when reading events
317  static const u_int CoBoCorrectEvents = 0x00001FFF;
318 
319  //@}
320 
321  //----------------------------------------------------------
322  /** @name Options for (un)merged events processing */
323  //@{
324 
325  //! Skip events with incomplete merged frames
326  static const u_int MergedIncompleteSkip = 0x00001000;
327 
328  //! Error on events with incomplete merged frames
329  static const u_int MergedIncompleteError = 0x00003000;
330 
331  //! Process single CoBo/AsAd frames as events
332  static const u_int ProcessSingleFrames = 0x00004000;
333 
334  //! Do not unpack CoBo/AsAd frames (fast reading)
335  static const u_int NoCoBoFrameUnpack = 0x00008000;
336 
337  //@}
338 
339 
340  //----------------------------------------------------------
341  /** @name Filters options */
342  //@{
343 
344  //! Normalize filter to conserve signal integral
345  static const u_int filterNormalize = 0x00000001;
346 
347  //@}
348 
349  //----------------------------------------------------------
350  // Configuration files data
351 
352  //! This namespace defines configuration files values.
353  namespace CFG
354  {
355 
356  //----------------------------------------------------------
357  /** @name Channels configuration */
358  //@{
359 
360  //! Defines the trigger inhibit identifiers.
361  enum TriggerInhibit { inhibitChannel,
362  inhibitTriggerData,
363  inhibitTriggerFunction,
364  inhibitNone };
365 
366  //! Defines the CSA gain identifiers.
367  enum CSAGain { csa10pC, csa120fC, csa1pC, csa240fC };
368 
369  //! Defines the reading modes identifiers.
370  enum ReadingMode { readAlways,
371  readNever,
372  readOnlyIfHit };
373  //@}
374 
375  //----------------------------------------------------------
376  /** @name AGet configuration */
377  //@{
378 
379  // AGet / Global / Reg1 configuration */
380 
381  //! Defines the test mode capacitors values identifiers.
382  enum TestModeRange { capa10pF, capa120fF, capa1pF, capa240fF };
383 
384  //! Defines the peaking time values identifiers.
385  enum PeakingTime { peaking70, peaking117, peaking232, peaking280,
386  peaking334, peaking383, peaking502, peaking541,
387  peaking568, peaking632, peaking721, peaking760,
388  peaking831, peaking870, peaking976, peaking1014 };
389 
390  //! Defines the test mode selection identifiers.
391  enum TestModeSelection { testModeCalibration,
392  testModeFunctionality,
393  testModeNothing,
394  testModeTest };
395 
396  //! Defines the SCA pointer identifiers.
397  enum TSCAPointer { anySCAPointer,
398  col0or128or256or384,
399  col0or256,
400  column0 };
401 
402  //! Defines the Vicm values identifiers.
403  enum Vicm { vicm125V, vicm135V, vicm155V, vicm165V };
404  //@}
405 
406  }
407 }
408 
409 //----------------------------------------------------------------------
410 #endif
static const u_short amplitudeFitG
Flag indicating Gauss fit mode.
Definition: GETCommon.hh:193
static const u_short amplitudeIntegFitGSC
Channel amplitude calculation mode: integral of a Gauss x SinC fit (with constant background) ...
Definition: GETCommon.hh:213
static const u_int CoBoCorrectEvents
All options for corrections when reading events.
Definition: GETCommon.hh:317
static const u_int MergedIncompleteSkip
Skip events with incomplete merged frames.
Definition: GETCommon.hh:326
static const u_short signalOut
Output (experimental data) signal sample.
Definition: GETCommon.hh:110
static const u_int RCoBoCorrectFPN
When reading experimental data, correct with average FPN (only for signal channels) ...
Definition: GETCommon.hh:275
static const u_short signalRec
Reconstructed signal sample.
Definition: GETCommon.hh:113
PeakingTime
Defines the peaking time values identifiers.
Definition: GETCommon.hh:385
static const u_short amplitudeIntegFitSqG
Channel amplitude calculation mode: maximum of a Square convolution with Gauss fit (with constant bac...
Definition: GETCommon.hh:219
Vicm
Defines the Vicm values identifiers.
Definition: GETCommon.hh:403
static const u_short dataNoBad
Whether not to consider channels with check problems (in summary histo filling)
Definition: GETCommon.hh:142
static const u_short analyseRecAll
Perform raw and corrected signal analysis with input signal reconstruction.
Definition: GETCommon.hh:163
static const u_short amplitudeFitSqGSC
Flag indicating Square convolution with Gauss x SinC fit mode.
Definition: GETCommon.hh:199
TRandom3 GETRandom
Random numbers generator.
Definition: GETObject.cpp:12
static const u_short analyseRaw
Perform raw signal analysis.
Definition: GETCommon.hh:154
static const u_int RCoBoDataNCorrection
When reading experimental data, correct for last sample artefact.
Definition: GETCommon.hh:261
static const u_short timingCFD
Channel timing from CFD algorithm.
Definition: GETCommon.hh:246
static const u_int CoBoCorrectFPN1
When reading experimental data, correct with closer FPN channel (only for signal channels) ...
Definition: GETCommon.hh:293
static const u_short timingMaxSignal
Channel timing from maximum amplitude.
Definition: GETCommon.hh:243
static const u_short modeData
The samples are filled from an experimental data file (in channel output sample)
Definition: GETCommon.hh:93
TestModeSelection
Defines the test mode selection identifiers.
Definition: GETCommon.hh:391
static const u_int CoBoCorrectFPN4
When reading experimental data, correct with average FPN (only for signal channels) ...
Definition: GETCommon.hh:299
TestModeRange
Defines the test mode capacitors values identifiers.
Definition: GETCommon.hh:382
static const u_short analyseInputRec
Perform input signal reconstruction.
Definition: GETCommon.hh:151
static const u_int CoBoCorrectBadData
Definition: GETCommon.hh:314
static const u_short amplitudeFitInteg
Flag indicating fit integral result.
Definition: GETCommon.hh:201
static const u_short amplitudeFitSqG
Flag indicating Square convolution with Gauss fit mode.
Definition: GETCommon.hh:197
static const u_short timingQuadraticMax
Channel timing from quadratic estimate on 3 points.
Definition: GETCommon.hh:249
static const u_short amplitudeFitFct
Flag indicating fit function.
Definition: GETCommon.hh:189
static const u_short amplitudeFit
Flag indicating fit mode.
Definition: GETCommon.hh:191
ReadingMode
Defines the reading modes identifiers.
Definition: GETCommon.hh:370
static const u_short amplitudeIntegThr
Channel amplitude calculation mode: integrate all signal over threshold.
Definition: GETCommon.hh:181
static const u_short analyseCor
Perform corrected signal analysis.
Definition: GETCommon.hh:157
CSAGain
Defines the CSA gain identifiers.
Definition: GETCommon.hh:367
static const u_short dataIntegral
Integral of signal data.
Definition: GETCommon.hh:124
static const u_int CoBoZeroSuppress
Definition: GETCommon.hh:309
static const u_int RCoBoCorrectFPN4
When reading experimental data, correct with average FPN (only for signal channels) ...
Definition: GETCommon.hh:273
static const u_short amplitudeMaxFitGSC
Channel amplitude calculation mode: maximum of a Gauss x SinC fit (with constant background) ...
Definition: GETCommon.hh:210
static const u_int NoCoBoFrameUnpack
Do not unpack CoBo/AsAd frames (fast reading)
Definition: GETCommon.hh:335
static const u_short amplitudeIntegTOT
Channel amplitude calculation mode: integrate signal over threshold around maximum.
Definition: GETCommon.hh:178
static const u_short amplitudeIntegFitG
Channel amplitude calculation mode: integral of a Gauss fit (with constant background) ...
Definition: GETCommon.hh:207
static const u_short amplitudeMaxFitG
Channel amplitude calculation mode: maximum of a Gauss fit (with constant background) ...
Definition: GETCommon.hh:204
static const u_int RCoBoCorrectLC2
When reading experimental data, correct for last cell read of AGet number 2.
Definition: GETCommon.hh:264
static const u_short amplitudeLocalAvg
Channel amplitude calculation mode: average around maximum signal time bucket.
Definition: GETCommon.hh:236
static const u_short amplitudeIntegFitSqGSC
Channel amplitude calculation mode: maximum of a Square convolution with Gauss x SinC fit (with const...
Definition: GETCommon.hh:225
RRealSampleFFT GETSample
Define the data type for samples.
Definition: GETCommon.hh:31
static const u_short amplitudeMaxFitSqGSC
Channel amplitude calculation mode: maximum of a Square convolution with Gauss x SinC fit (with const...
Definition: GETCommon.hh:222
static const u_short amplitudeLocal
Flag indicating local analysis mode.
Definition: GETCommon.hh:233
static const u_int RCoBoCorrectFPN2
When reading experimental data, correct with 2 half chip FPN channels average (only for signal channe...
Definition: GETCommon.hh:270
static const u_short amplitudeMaxFitSqG
Channel amplitude calculation mode: maximum of a Square convolution with Gauss fit (with constant bac...
Definition: GETCommon.hh:216
static const u_int ProcessSingleFrames
Process single CoBo/AsAd frames as events.
Definition: GETCommon.hh:332
static const u_short signalUndef
Undefined signal sample.
Definition: GETCommon.hh:104
static const u_short amplitudeFitGSC
Flag indicating Gauss x SinC fit mode.
Definition: GETCommon.hh:195
static const u_short modeSimul
The samples are filled from an experimental data file (in channel output sample)
Definition: GETCommon.hh:96
static const u_short dataFullSignal
Full signal data (for 3D)
Definition: GETCommon.hh:127
TriggerInhibit
Defines the trigger inhibit identifiers.
Definition: GETCommon.hh:361
static const u_int filterNormalize
Normalize filter to conserve signal integral.
Definition: GETCommon.hh:345
static const u_int CoBoCorrectFPN2
When reading experimental data, correct with 2 half chip FPN channels average (only for signal channe...
Definition: GETCommon.hh:296
static const u_int CoBoDataNCorrection
When reading experimental data, correct for last sample(s) artefact.
Definition: GETCommon.hh:290
static const u_int RCoBoData0Correction
When reading experimental data, correct for sample 0 artefact.
Definition: GETCommon.hh:258
static const u_short dataNoSat
Whether not to consider saturated data (in summary histo filling)
Definition: GETCommon.hh:139
static const u_short signalTst
Test input (simulation) signal sample.
Definition: GETCommon.hh:107
static const u_short amplitudeQuadraticMax
Channel amplitude (and time) from quadratic estimate on 3 points.
Definition: GETCommon.hh:184
static const u_short amplitudeLocalFitP2
Channel amplitude calculation mode: quadratic fit around maximum signal time bucket.
Definition: GETCommon.hh:239
static const u_short dataAmplitude
Computed signal amplitude (depends on amplitude mode)
Definition: GETCommon.hh:121
static const u_short analyseAll
Perform raw and corrected signal analysis.
Definition: GETCommon.hh:160
static const u_short modeUndefined
The samples are filled from an experimental data file (in channel output sample)
Definition: GETCommon.hh:90
static const u_short dataTime
Time of maximum value of signal data.
Definition: GETCommon.hh:130
static const u_int CoBoCorrectFPN
When reading experimental data, correct with average FPN (only for signal channels) ...
Definition: GETCommon.hh:301
static const u_int MergedIncompleteError
Error on events with incomplete merged frames.
Definition: GETCommon.hh:329
static const u_int CoBoData0Correction
When reading experimental data, correct for first sample(s) artefact.
Definition: GETCommon.hh:287
static const u_short amplitudeMaxSignal
Channel amplitude calculation mode: maximum signal time bucket.
Definition: GETCommon.hh:172
static const u_int RCoBoCorrectFPN1
When reading experimental data, correct with closer FPN channel (only for signal channels) ...
Definition: GETCommon.hh:267
TSCAPointer
Defines the SCA pointer identifiers.
Definition: GETCommon.hh:397
static const u_short dataHit
Whether the channel is hit (1) or not (0)
Definition: GETCommon.hh:136
static const u_short dataTimeBin
Time bucket of maximum value of signal data.
Definition: GETCommon.hh:133
static const u_short amplitudeIntegAll
Channel amplitude calculation mode: integrate all signal.
Definition: GETCommon.hh:175
static const u_int RCoBoCorrectEvents
all option for corrections when reading events
Definition: GETCommon.hh:278