WaveformProcessor.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file WaveformProcessor.h
3 /// \brief Service for extracting timing and pulse height information
4 /// from traces with multipoint readout.
5 ///
6 /// \author ram2aq@virginia.edu
7 ////////////////////////////////////////////////////////////////////////
8 #ifndef NOVADDT_WAVEFORMPROCESSOR_H
9 #define NOVADDT_WAVEFORMPROCESSOR_H
10 
14 
15 #include "DAQDataFormats/RawMilliSlice.h"
16 #include "DAQDataFormats/RawNanoSlice.h"
18 #include "NovaDAQConventions/DAQConventions.h"
19 
20 #include <array>
21 #include <bitset>
22 #include <string>
23 #include <cmath>
24 #include <cassert>
25 #include "TFile.h"
26 #include "TTree.h"
27 
28 namespace novaddt
29 {
30 
31  unsigned int nTableLoads = 0;
32 
33  // Bounds within which adc values must lie in order for them to be in our
34  // table. adc1 must be less than adc3. adc2 is measured relative to
35  // adc3. See genADCShapeFitLookupTable for more detail about the looping
36  // order.
37 
38  const static int kADC3Max = 512;
39  const static int kADC3Min = 256;
40  const static int kADC1Min = 180;
41  const static int kADC1RelMax = 50;
42  const static int kADC2Min = 180;
43  const static int kADC2Max = 512;
44 
45 
46  // To understand this you need to understand the constraints the looping in
47  // genADCShapeFitLookupTable and be ready to think about the 3D shape this
48  // produces in ADC space.
49 
50  const static unsigned int kNumTableEntries = 21545472;
51  /* ((kADC3Min-kADC1Min)*(kADC3Min) + // Rectangular part, where adc1 < 0 */
52  /* ((kADC3Max-kADC3Min)*(kADC3Max-kADC3Min-1))/2)* // Triangular part, where 0 <= adc1 < adc0 */
53  /* (kADC2Max-kADC2Min); // Thickness of the wedge due to adc2 */
54 
55 
56  uint8_t ADCShapeFit(int16_t adc1, int16_t adc2, int16_t adc3,
57  double riseTime, double fallTime,
58  bool& goodTime);
59 
60  TDC OffsetToTDC(uint32_t const& t0, uint64_t const& high_time,
61  uint8_t const& offset);
62 
63  inline double GetExpectations(double t0,
64  double riseTime, double fallTime,
65  const int16_t* obs,
66  double* exps);
67 
69  {
70  public:
74 
75  void postBeginRun(art::Run const& run);
76  void reconfigure(const fhicl::ParameterSet& pset);
77 
80  {
81  fMicro = theMicro; fNano = theNano;
82  if (fUseMulti) initmulti();
83  else initdcs();
84  }
85 
86  void setup(uint32_t const& t0, uint64_t const& high_time,
87  int16_t const& adc1, int16_t const& adc2, int16_t const& adc3,
88  int16_t const& dcs);
89 
90  TDC getTDC() { return fTDC; }
91  ADC getADC() { return fADC; }
92 
93  private:
94 
95  void process(uint32_t const& t0, uint64_t const& high_time,
96  int16_t const& adc1, int16_t const& adc2, int16_t const& adc3,
97  ADC& adcpeak, bool& goodTime, TDC& retval);
98  void initmulti();
99  void initdcs();
100 
101  bool fTableLoaded = false;
102  std::array<uint8_t, kNumTableEntries> fTable;
103 
104  //the adc part of the lookup table is not currently used,
105  //but it is still part of the lookup table file
106  std::array<uint16_t, kNumTableEntries> fADCTable;
107 
108  std::bitset<kNumTableEntries> fGood;
110  const double fSampleTime;
111  const double fRiseTime;
112  const double fFallTime;
115  const bool fUseMulti;
116  const bool fUseMulti4ADC;
117  const bool fDoHighADCFits;
120  };
121 }
123 #endif // NOVADDT_WAVEFORMPROCESSOR_H
124 ////////////////////////////////////////////////////////////////////////
WaveformProcessor(fhicl::ParameterSet const &pset, art::ActivityRegistry &reg)
static const int kADC1Min
static const int kADC2Min
static const int kADC3Min
void process(uint32_t const &t0, uint64_t const &high_time, int16_t const &adc1, int16_t const &adc2, int16_t const &adc3, ADC &adcpeak, bool &goodTime, TDC &retval)
daqdataformats::RawNanoSlice * fNano
std::bitset< kNumTableEntries > fGood
#define DECLARE_ART_SERVICE(svc, scope)
Definition: ServiceMacros.h:86
void reconfigure(const fhicl::ParameterSet &pset)
static const int kADC1RelMax
Definition: Run.h:21
double GetExpectations(double t0, double riseTime, double fallTime, const int16_t *obs, double *exps)
Helper function for ADCShapeFit inner loop.
TDC OffsetToTDC(uint32_t const &t0, uint64_t const &high_time, uint8_t const &offset)
static const unsigned int kNumTableEntries
std::array< uint16_t, kNumTableEntries > fADCTable
static const int kADC2Max
std::array< uint8_t, kNumTableEntries > fTable
Definition: run.py:1
void setup(daqdataformats::RawMicroSlice *theMicro, daqdataformats::RawNanoSlice *theNano)
daqdataformats::RawMicroSlice * fMicro
unsigned int nTableLoads
Class to hold the MicroSlice data.
Definition: RawMicroSlice.h:48
void postBeginRun(art::Run const &run)
static const int kADC3Max
uint8_t ADCShapeFit(int16_t adc1, int16_t adc2, int16_t adc3, double riseTime, double fallTime, bool &goodTime)
enum BeamMode string