~mbogomilov/maus/devel3

« back to all changes in this revision

Viewing changes to src/input/InputCppDAQData/fADCDataProcessor.hh

  • Committer: Durga Rajaram
  • Date: 2014-01-14 07:07:02 UTC
  • mfrom: (659.1.80 relcand)
  • Revision ID: durga@fnal.gov-20140114070702-2l1fuj1w6rraw7xe
Tags: MAUS-v0.7.6
MAUS-v0.7.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of MAUS: http://micewww.pp.rl.ac.uk:8080/projects/maus
 
2
 *
 
3
 * MAUS is free software: you can redistribute it and/or modify
 
4
 * it under the terms of the GNU General Public License as published by
 
5
 * the Free Software Foundation, either version 3 of the License, or
 
6
 * (at your option) any later version.
 
7
 *
 
8
 * MAUS is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with MAUS.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 */
 
17
 
 
18
#ifndef _MAUS_INPUTCPPDATA_FADCDATAPROCESSOR_HH_
 
19
#define _MAUS_INPUTCPPDATA_FADCDATAPROCESSOR_HH_
 
20
 
 
21
#include <string>
 
22
#include <vector>
 
23
#include <algorithm>
 
24
 
 
25
#include "json/json.h"
 
26
 
 
27
#include "unpacking/MDprocessor.h"
 
28
 
 
29
#include "Utils/DAQChannelMap.hh"
 
30
#include "DataStructure/DAQData.hh"
 
31
 
 
32
////////////////////////////////////////////////////////////////////////////////
 
33
 
 
34
/** MDarranger
 
35
 * Simple class to hold and arrange the Json document
 
36
 * containing all the daq spill information.
 
37
 */
 
38
 
 
39
namespace MAUS {
 
40
 
 
41
class MDarranger : public MDprocessor {
 
42
 public:
 
43
  MDarranger() {}
 
44
  virtual ~MDarranger() {}
 
45
 
 
46
  /** Sets the json document to which the MDarranger will write
 
47
   */
 
48
  void set_JSON_doc(Json::Value *doc) {_docSpill = doc;}
 
49
 
 
50
  /** Gets the json document where DAQ data is written
 
51
   */
 
52
  Json::Value* get_JSON_doc() {return _docSpill;}
 
53
 
 
54
 /** This function sets the pointer to the DAQData object.
 
55
  * \param[in] dd The pointer to the DAQData objevt.
 
56
  */
 
57
  static void set_daq_data(MAUS::DAQData *dd) {_daq_data = dd;}
 
58
 
 
59
  /** Gets the json document where DAQ data is written
 
60
   */
 
61
  static MAUS::DAQData* get_daq_data() {return _daq_data;}
 
62
 
 
63
  /**
 
64
  * This function sets the DAQ map.
 
65
  * \param[in] map The DAQ channel map.
 
66
  */
 
67
  static void set_DAQ_map(DAQChannelMap* map) {_chMap = map;}
 
68
 
 
69
  string get_equipment_name() {return _equipment;}
 
70
 
 
71
 protected:
 
72
  /** The JSON node to put the data under.
 
73
  * It is created at the beginning of the spill.
 
74
  **/
 
75
  Json::Value* _docSpill;
 
76
 
 
77
 
 
78
  /**The DAQData object to put the data under.
 
79
  * It is created at the beginning of the spill.
 
80
  *
 
81
  **/
 
82
  static MAUS::DAQData  *_daq_data;
 
83
 
 
84
  /** The DAQ channel map.
 
85
  * It is used to group all channels belonging to a given detector.
 
86
  **/
 
87
  static DAQChannelMap* _chMap;
 
88
 
 
89
  /** The name of the DAQ equipment. **/
 
90
  string _equipment;
 
91
};
 
92
 
 
93
class ZeroSupressionFilter : public MDarranger {
 
94
 
 
95
 public:
 
96
 
 
97
  ZeroSupressionFilter() :_zero_suppression(0), _zs_threshold(0) {}
 
98
  virtual ~ZeroSupressionFilter() {}
 
99
 
 
100
  void set_zero_supression(bool zs) { _zero_suppression = zs; }
 
101
  void set_zs_threshold(int zst)    { _zs_threshold = zst; }
 
102
 
 
103
 protected:
 
104
 
 
105
  /// If true - do zero suppression
 
106
  bool _zero_suppression;
 
107
 
 
108
  /// Value of the threshold used for zero suppression */
 
109
  int _zs_threshold;
 
110
};
 
111
 
 
112
////////////////////////////////////////////////////////////////////////////////
 
113
 
 
114
 
 
115
// do not increment inside following macro! (e.g.: MAX( ++a, ++b );
 
116
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
 
117
 
 
118
#define SIGNAL_INTEGRATION_WINDOW 30
 
119
 
 
120
class fADCDataProcessor : public ZeroSupressionFilter {
 
121
 public:
 
122
 
 
123
  fADCDataProcessor() {}
 
124
  ~fADCDataProcessor() {}
 
125
 
 
126
  /** Return the position of the maximum.
 
127
  * This function returns the number of the sample having maximum amplitude.
 
128
  */
 
129
  int get_max_position();
 
130
 
 
131
  /** Return the position of the minimum.
 
132
   * This function returns the number of the sample having minimum amplitude.
 
133
   */
 
134
  int get_min_position();
 
135
 
 
136
  int get_arrival_time();
 
137
 
 
138
  int print_data();
 
139
 
 
140
  /** Return the area of the signal.
 
141
  * This function returns the area of the signal. The pedestal is subtracted.
 
142
  * The integration is done in window starting 10 samples before the maximum
 
143
  * and ending 20 samples after the maximum.
 
144
  * \param[out] pos The number of the sample having maximum amplitude.
 
145
  */
 
146
  int get_pos_signal_area(int &pos);
 
147
 
 
148
  int get_neg_signal_area(int &pos);
 
149
 
 
150
  int get_pedestal_area(int &pos);
 
151
 
 
152
  /** Return the measured value for the given sample
 
153
  * \param[in] i The number of the sample.
 
154
  */
 
155
  int get_point(int i) const { return _data[i]; }
 
156
 
 
157
  /// Return the vector of samples
 
158
  vector<int> get_data() const { return _data; }
 
159
 
 
160
  /** Return the area of the signal.
 
161
  * This function returns the area of the signal. The pedestal is subtracted.
 
162
  * The integration is done using the whole acquisition window.
 
163
  */
 
164
 
 
165
  int get_area();
 
166
 
 
167
  /// Return the data member _pedestal
 
168
  double get_pedestal() const { return _pedestal; }
 
169
 
 
170
  /** Return the charge of the signal.
 
171
  * This function returns the charge of the signal calculated by the specified
 
172
  * algorithm.
 
173
  * \param[in] Algorithm identifier of the algorithm.
 
174
  */
 
175
  int get_charge(int Algorithm = ceaPedMax);
 
176
 
 
177
  enum chargeEstimationAlgorithm {
 
178
    ceaMinMax, /// Simplest algorithm
 
179
    ceaFractionDescriminatorThreshold, /// not implemented
 
180
    ceaPedMax,
 
181
    ceaPedMin,
 
182
  };
 
183
 
 
184
  /**Return the charge of the Cherenkov Singal (negative pulse)
 
185
  Uses same Algorithm.
 
186
  */
 
187
  int get_charge_ckov(int Algorithm = ceaPedMin);
 
188
 
 
189
  Json::Value get_samples();
 
190
 
 
191
 protected:
 
192
 
 
193
  void set_pedestal();
 
194
  int chargeMinMax();
 
195
  int chargePedMax();
 
196
  int chargePedMin();
 
197
  /// vector of samples (measurements) */
 
198
  vector<int> _data;
 
199
 
 
200
  /// Pedestal level of the signal */
 
201
  double _pedestal;
 
202
};
 
203
}
 
204
#endif