Pixie16 Analysis Software Suite
Analysis code for processing of .ldf files
Trace.hpp
Go to the documentation of this file.
1 
7 #ifndef __TRACE_HPP__
8 #define __TRACE_HPP__
9 
10 #include <cmath>
11 #include <map>
12 #include <string>
13 #include <vector>
14 
15 #include "DammPlotIds.hpp"
16 #include "Globals.hpp"
17 #include "Plots.hpp"
18 #include "PlotsRegister.hpp"
19 
21 #ifndef NAN
22 #include <limits>
23 #define NAN (numeric_limits<float>::quiet_NaN())
24 #endif
25 
27 
29 namespace {
30  typedef class TrapezoidalFilterParameters TFP;
31 }
32 
34 class Trace : public std::vector<int> {
35 public:
37  Trace() : std::vector<int>() {
39  }
40 
43  Trace(const std::vector<int> &x) : std::vector<int>(x) {
45  }
46 
51  void TrapezoidalFilter(Trace &filter, const TFP &parms,
52  unsigned int lo = 0) const {
53  TrapezoidalFilter(filter, parms, lo, size());
54  }
55 
56 
65  void TrapezoidalFilter(Trace &filter, const TFP &parms,
66  unsigned int lo, unsigned int hi) const;
67 
71  void InsertValue(std::string name, double value) {
72  doubleTraceData.insert(make_pair(name,value));
73  }
74 
78  void InsertValue(std::string name, int value) {
79  intTraceData.insert(make_pair(name,value));
80  }
81 
85  void SetValue(std::string name, double value) {
86  if(doubleTraceData.count(name) > 0)
87  doubleTraceData[name] = value;
88  else
89  InsertValue(name,value);
90  }
91 
95  void SetValue(std::string name, int value) {
96  if(intTraceData.count(name) > 0)
97  intTraceData[name] = value;
98  else
99  InsertValue(name,value);
100  }
101 
105  bool HasValue(std::string name) const {
106  return (doubleTraceData.count(name) > 0 ||
107  intTraceData.count(name) > 0);
108  }
109 
113  double GetValue(std::string name) const {
114  if(doubleTraceData.count(name) > 0)
115  return (*doubleTraceData.find(name)).second;
116  if(intTraceData.count(name) > 0)
117  return (*intTraceData.find(name)).second;
118  return NAN;
119  }
120 
122  std::vector<double> GetWaveform() {
123  return waveform;
124  };
125 
130  double DoBaseline(unsigned int lo = 0, unsigned int numBins = numBinsBaseline);
131 
136  double DoDiscrimination(unsigned int lo, unsigned int numBins);
137 
142  double DoQDC(unsigned int lo, unsigned int numBins);
143 
149  unsigned int FindMaxInfo(unsigned int lo = 5, unsigned int hi = 10, unsigned int numBins = 15);
150 
155  virtual void DeclareHistogram1D(int dammId, int xSize, const char* title) {
156  histo.DeclareHistogram1D(dammId, xSize, title);
157  }
158 
164  virtual void DeclareHistogram2D(int dammId, int xSize, int ySize,
165  const char* title) {
166  histo.DeclareHistogram2D(dammId, xSize, ySize, title);
167  }
168 
178  virtual void plot(int dammId, double val1, double val2 = -1,
179  double val3 = -1, const char* name="h") const {
180  histo.Plot(dammId, val1, val2, val3, name);
181  }
182 
185  void Plot(int id);
189  void Plot(int id, int row);
193  void ScalePlot(int id, double scale);
198  void ScalePlot(int id, int row, double scale);
202  void OffsetPlot(int id, double offset);
207  void OffsetPlot(int id, int row, double offset);
208 
209 private:
210  static const unsigned int numBinsBaseline = 15;
211  unsigned int baselineLow;
212  unsigned int baselineHigh;
213 
214  std::vector<double> waveform;
215 
216  std::map<std::string, double> doubleTraceData;
217  std::map<std::string, int> intTraceData;
218 
221  static Plots histo;
222 };
223 
226 public:
229 
234  TrapezoidalFilterParameters(int gap, int rise, double t = NAN) :
235  gapSamples(gap), riseSamples(rise), tau(t) {};
236 
241  tau(x.tau) {};
242 
246  const TFP& operator=(const TFP &right) {
247  gapSamples = right.gapSamples;
248  riseSamples = right.riseSamples;
249  tau = right.tau;
250 
251  return (*this);
252  }
253 
255  Trace::size_type GetGapSamples(void) const {return gapSamples;};
256 
258  Trace::size_type GetRiseSamples(void) const {return riseSamples;};
259 
261  Trace::size_type GetSize(void) const {return 2*riseSamples + gapSamples;};
262 
264  double GetTau(void) const {return tau;};
265 private:
266  Trace::size_type gapSamples;
267  Trace::size_type riseSamples;
268 
269  double tau;
270 };
271 
272 extern const Trace emptyTrace;
273 #endif // __TRACE_H_
bool DeclareHistogram2D(int dammId, int xSize, int ySize, const char *title, int halfWordsPerChan, int xHistLength, int xLow, int xHigh, int yHistLength, int yLow, int yHigh, const std::string &mne="")
Declares a 2D histogram calls the C++ wrapper for DAMM.
unsigned int baselineHigh
high range for the baseline
Definition: Trace.hpp:212
Parameters for your typical trapezoidal filter.
Definition: Trace.hpp:225
Trace()
Definition: Trace.hpp:37
Trace::size_type GetSize(void) const
Definition: Trace.hpp:261
void TrapezoidalFilter(Trace &filter, const TFP &parms, unsigned int lo=0) const
Definition: Trace.hpp:51
double GetTau(void) const
Definition: Trace.hpp:264
Lists Offsets and Ranges for various Processors.
TrapezoidalFilterParameters(int gap, int rise, double t=NAN)
Definition: Trace.hpp:234
unsigned int baselineLow
low range for the baseline
Definition: Trace.hpp:211
void Plot(int id)
virtual void DeclareHistogram1D(int dammId, int xSize, const char *title)
Declares a 1D histogram calls the C++ wrapper for DAMM.
Definition: Trace.hpp:155
std::map< std::string, int > intTraceData
Trace data stored as ints.
Definition: Trace.hpp:217
double DoBaseline(unsigned int lo=0, unsigned int numBins=numBinsBaseline)
double DoQDC(unsigned int lo, unsigned int numBins)
A container to request a block of plots and plot respective spectra through the plots register...
bool Plot(int dammId, double val1, double val2=-1, double val3=-1, const char *name="h")
Plots into histogram defined by dammId.
static Plots histo
Definition: Trace.hpp:221
void InsertValue(std::string name, double value)
Definition: Trace.hpp:71
Trace::size_type gapSamples
number of samples in the gap
Definition: Trace.hpp:264
TrapezoidalFilterParameters()
Definition: Trace.hpp:228
constant parameters used in pixie16 analysis
double DoDiscrimination(unsigned int lo, unsigned int numBins)
Store the information for a trace.
Definition: Trace.hpp:34
#define NAN
Definition: Trace.hpp:23
std::vector< double > GetWaveform()
Definition: Trace.hpp:122
double tau
Tau of the energy filter.
Definition: Trace.hpp:269
bool HasValue(std::string name) const
Definition: Trace.hpp:105
void InsertValue(std::string name, int value)
Definition: Trace.hpp:78
const TFP & operator=(const TFP &right)
Definition: Trace.hpp:246
virtual void plot(int dammId, double val1, double val2=-1, double val3=-1, const char *name="h") const
Implementation of the plot command to interface with the DAMM routines.
Definition: Trace.hpp:178
TrapezoidalFilterParameters(const TFP &x)
Definition: Trace.hpp:239
Trace::size_type GetRiseSamples(void) const
Definition: Trace.hpp:258
const Trace emptyTrace
Instance of an empty trace for people to grab.
void OffsetPlot(int id, double offset)
double GetValue(std::string name) const
Definition: Trace.hpp:113
const pixie::word_t U_DELIMITER
Definition: Globals.hpp:39
std::vector< double > waveform
The waveform inside the trace.
Definition: Trace.hpp:214
unsigned int FindMaxInfo(unsigned int lo=5, unsigned int hi=10, unsigned int numBins=15)
Trace::size_type GetGapSamples(void) const
Definition: Trace.hpp:255
virtual void DeclareHistogram2D(int dammId, int xSize, int ySize, const char *title)
Declares a 2D histogram calls the C++ wrapper for DAMM.
Definition: Trace.hpp:164
Trace::size_type riseSamples
number of samples in the rise time
Definition: Trace.hpp:267
Trace(const std::vector< int > &x)
Definition: Trace.hpp:43
void SetValue(std::string name, int value)
Definition: Trace.hpp:95
void SetValue(std::string name, double value)
Definition: Trace.hpp:85
std::map< std::string, double > doubleTraceData
Trace data stored as doubles.
Definition: Trace.hpp:216
bool DeclareHistogram1D(int dammId, int xSize, const char *title, int halfWordsPerChan, int xHistLength, int xLow, int xHigh, const std::string &mne="")
Declares a 1D histogram calls the C++ wrapper for DAMM.
Holds pointers to all Histograms.
Definition: Plots.hpp:27
void ScalePlot(int id, double scale)
static const unsigned int numBinsBaseline
Number of bins in the baseline.
Definition: Trace.hpp:210