otsdaq-mu2e-stm  5.02.01
pulseheight_config.hh
1 #ifndef PULSEHEIGHT_CONFIG_HH_
2 #define PULSEHEIGHT_CONFIG_HH_
3 
4 // Include config files
5 #include "Mu2e-STMDAQ/config/config.hh"
6 #include "Mu2e-STMDAQ/config/include/fw_config.hh"
7 
8 // Pulse height configurable variables
10 
11  // Baseline
12  const int baselineWindow;
13  const int baselineLookback;
14 
15  // Peak detection / pulse finding
16  const double threshold;
17  const int slopeWindow;
18  const double slopeThreshold;
19  const double noiseTolerance;
20  const int minBaselineCheck;
21  const int Nsharp;
22  const int localWindowMax;
23  const int persistenceWindow;
24  const float persistenceFraction;
25  const int persistenceCount;
26  const float curvature_threshold;
27  const float contaminatedBaselineStd;
28 
29  // Smoothing / Savitzky-Golay
30  const std::array<float,7> sg7_coeffs;
31 
32  // Constructor
34  const std::shared_ptr<AsyncLogger> logger,
35  fw_info fw_config,
36  baseline_info baseline_config) :
37 
38  // Baseline
39  baselineWindow(cfg.getValue<int>("stm.ph.baselineWindow")),
40  baselineLookback(cfg.getValue<int>("stm.ph.baselineLookback")),
41 
42  // Peak detection / pulse finding
43  threshold(cfg.getValue<double>("stm.ph.threshold")),
44  slopeWindow(cfg.getValue<int>("stm.ph.slopeWindow")),
45  slopeThreshold(cfg.getValue<double>("stm.ph.slopeThreshold")),
46  noiseTolerance(cfg.getValue<double>("stm.ph.noiseTolerance")),
47  minBaselineCheck(cfg.getValue<int>("stm.ph.minBaselineCheck")),
48  Nsharp(cfg.getValue<int>("stm.ph.Nsharp")),
49  localWindowMax(cfg.getValue<int>("stm.ph.localWindowMax")),
50  persistenceWindow(cfg.getValue<int>("stm.ph.persistenceWindow")),
51  persistenceFraction(cfg.getValue<float>("stm.ph.persistenceFraction")),
52  persistenceCount(cfg.getValue<int>("stm.ph.persistenceCount")),
53  curvature_threshold(cfg.getValue<float>("stm.ph.curvature_threshold")),
54  contaminatedBaselineStd(cfg.getValue<float>("stm.ph.contaminatedBaselineStd")),
55 
56  // SG coefficients
57  sg7_coeffs({
58  cfg.getValue<float>("stm.ph.sg7.c0"),
59  cfg.getValue<float>("stm.ph.sg7.c1"),
60  cfg.getValue<float>("stm.ph.sg7.c2"),
61  cfg.getValue<float>("stm.ph.sg7.c3"),
62  cfg.getValue<float>("stm.ph.sg7.c4"),
63  cfg.getValue<float>("stm.ph.sg7.c5"),
64  cfg.getValue<float>("stm.ph.sg7.c6")
65  })
66  {
67  if (logger) {
68 
69  logger->log("Config:pulseheight_info: baselineWindow = " +
70  std::to_string(baselineWindow) +
71  "; baselineLookback = " +
72  std::to_string(baselineLookback) + ".", 1);
73 
74  logger->log("Config:pulseheight_info: threshold = " +
75  std::to_string(threshold) +
76  "; slopeWindow = " +
77  std::to_string(slopeWindow) +
78  "; slopeThreshold = " +
79  std::to_string(slopeThreshold) + ".", 1);
80 
81  logger->log("Config:pulseheight_info: noiseTolerance = " +
82  std::to_string(noiseTolerance) +
83  "; minBaselineCheck = " +
84  std::to_string(minBaselineCheck) + ".", 1);
85 
86  logger->log("Config:pulseheight_info: Nsharp = " +
87  std::to_string(Nsharp) +
88  "; localWindowMax = " +
89  std::to_string(localWindowMax) + ".", 1);
90 
91  logger->log("Config:pulseheight_info: persistence window = " +
92  std::to_string(persistenceWindow) +
93  "; persistence fraction = " +
94  std::to_string(persistenceFraction) +
95  "; persistence count = " +
96  std::to_string(persistenceCount) + ".", 1);
97 
98  logger->log("Config:pulseheight_info: curvature_threshold = " +
99  std::to_string(curvature_threshold) + ".", 1);
100 
101  logger->log("Config:pulseheight_info: contaminatedBaselineStd = " +
102  std::to_string(contaminatedBaselineStd) + ".", 1);
103 
104  // Validate sg7_coeffs length
105  if (sg7_coeffs.size() != 7) {
106 
107  logger->log("Config:pulseheight_info: Error! sg7_coeffs must contain 7 values.", 0);
108 
109  } else {
110 
111  std::string coeffs_str;
112 
113  for (size_t i = 0; i < sg7_coeffs.size(); ++i) {
114 
115  coeffs_str += std::to_string(sg7_coeffs[i]);
116 
117  if (i + 1 < sg7_coeffs.size())
118  coeffs_str += ", ";
119  }
120 
121  logger->log("Config:pulseheight_info: sg7_coeffs = [" +
122  coeffs_str + "].", 1);
123  }
124  }
125  }
126 };
127 
128 #endif
Definition: config.hh:19