SdHistogramFitterKG.cc
Go to the documentation of this file.
1 #include "SdHistogramFitterKG.h"
2 
3 #include <fwk/CentralConfig.h>
4 #include <evt/Event.h>
5 #include <sdet/SDetector.h>
6 #include <sevt/SEvent.h>
7 #include <sevt/EventTrigger.h>
8 #include <sevt/StationCalibData.h>
9 #include <utl/QuadraticFitter.h>
10 #include <utl/ExponentialFitter.h>
11 #include <utl/String.h>
12 
13 using namespace fwk;
14 using namespace sevt;
15 using namespace utl;
16 using namespace std;
17 
18 
20 
21  // pair<> output helper
22  template<typename T1, typename T2>
23  inline
24  ostream&
25  operator<<(ostream& os, pair<T1, T2>& p)
26  {
27  return os << '[' << p.first << ", " << p.second << ']';
28  }
29 
30 
31  inline
32  bool
33  IsInRange(const double x, const pair<double, double>& r)
34  {
35  return r.first < x && x < r.second;
36  }
37 
38 
41  {
42  auto topB = CentralConfig::GetInstance()->GetTopBranch("SdHistogramFitterKG");
43 
44  topB.GetChild("peakFitRange").GetData(fPeakFitRange);
45  topB.GetChild("peakFitChi2Accept").GetData(fPeakFitChi2Accept);
46  topB.GetChild("peakOnlineToVEMFactor").GetData(fPeakOnlineToVEMFactor);
47  topB.GetChild("peakHistogramToVEMFactor").GetData(fPeakHistogramToVEMFactor);
48  topB.GetChild("peakOnlineToMIPFactor").GetData(fPeakOnlineToMIPFactor);
49  topB.GetChild("peakHistogramToMIPFactor").GetData(fPeakHistogramToMIPFactor);
50  topB.GetChild("chargeSigmaThresholdFactors").GetData(fChargeSigmaThresholdFactors);
51  topB.GetChild("chargeFitChi2Accept").GetData(fChargeFitChi2Accept);
52  topB.GetChild("chargeOnlineToVEMFactor").GetData(fChargeOnlineToVEMFactor);
53  topB.GetChild("chargeHistogramToVEMFactor").GetData(fChargeHistogramToVEMFactor);
54  topB.GetChild("chargeOnlineToMIPFactor").GetData(fChargeOnlineToMIPFactor);
55  topB.GetChild("chargeHistogramToMIPFactor").GetData(fChargeHistogramToMIPFactor);
56  topB.GetChild("chargeVEMRangeUub").GetData(fChargeVEMRangeUub);
57 
58  auto shapeFitB = topB.GetChild("shapeFitRange");
59  shapeFitB.GetChild("beforeCalibrationVersion12").GetData(fShapeFitRangeBefore12);
60  shapeFitB.GetChild("sinceCalibrationVersion12").GetData(fShapeFitRangeSince12);
61 
62  ostringstream info;
63  info << "Parameters:\n"
64  "peakFitRange: " << fPeakFitRange << "\n"
65  "peakFitChi2Accept: " << fPeakFitChi2Accept << "\n"
66  "peakOnlineToVEMFactor: " << fPeakOnlineToVEMFactor << "\n"
67  "peakHistogramToVEMFactor: " << fPeakHistogramToVEMFactor << "\n"
68  "peakOnlineToMIPFactor: " << fPeakOnlineToMIPFactor << "\n"
69  "peakHistogramToMIPFactor: " << fPeakHistogramToMIPFactor << "\n"
70  "chargeSigmaThresholdFactors: " << Join(" ", fChargeSigmaThresholdFactors) << "\n"
71  "chargeFitChi2Accept: " << fChargeFitChi2Accept << "\n"
72  "chargeOnlineToVEMFactor: " << fChargeOnlineToVEMFactor << "\n"
73  "chargeHistogramToVEMFactor: " << fChargeHistogramToVEMFactor << "\n"
74  "chargeOnlineToMIPFactor: " << fChargeOnlineToMIPFactor << "\n"
75  "chargeHistogramToMIPFactor: " << fChargeHistogramToMIPFactor << "\n"
76  "chargeVEMRangeUub: " << fChargeVEMRangeUub;
77  INFO(info);
78 
79  return eSuccess;
80  }
81 
82 
84  SdHistogramFitter::Run(evt::Event& event)
85  {
86  if (!event.HasSEvent())
87  return eSuccess;
88  auto& sEvent = event.GetSEvent();
89 
90  fToldYaPeak = false;
91  fToldYaCharge = false;
92  fToldYaShape = false;
93 
94  // loop on stations
95  for (auto& station : sEvent.StationsRange()) {
96  if (!station.HasTriggerData() ||
97  !station.HasCalibData() ||
98  !station.HasGPSData())
99  continue;
100 
101  const auto& trig = station.GetTriggerData();
102  if (trig.IsRandom() ||
103  (trig.GetErrorCode() & 0xff) || // for UUBs errorcodes are above 256.
104  station.GetCalibData().GetVersion() > 32000)
105  continue;
106 
107  // skip "bad compressed data"
108  if (sEvent.HasTrigger()) {
109  const int trigSecond = sEvent.GetTrigger().GetTime().GetGPSSecond();
110  const int timeDiff = int(station.GetGPSData().GetSecond()) - trigSecond;
111  if (abs(timeDiff) > 1)
112  continue;
113  }
114 
115  const auto& dStation = det::Detector::GetInstance().GetSDetector().GetStation(station);
116  fIsUUB = dStation.IsUUB();
117 
118  CalculatePeakAndCharge(station);
119 
120  // calibration for small pmt
121  if (fIsUUB && station.HasSmallPMTData()) {
122  if (CopySmallPMTCalibData(station))
123  station.GetSmallPMTData().SetIsTubeOk();
124  else {
125  station.GetSmallPMTData().SetIsTubeOk(false);
126  if (station.GetSmallPMT().HasCalibData())
127  station.GetSmallPMT().GetCalibData().SetIsTubeOk(false);
128  ostringstream warn;
129  warn << "Station " << station.GetId() << ": No valid SmallPMT calibration. "
130  "Setting IsTubeOk as false for SmallPMT.";
131  WARNING(warn);
132  }
133  }
134  }
135 
136  return eSuccess;
137  }
138 
139 
140  void
141  SdHistogramFitter::CalculatePeakAndCharge(Station& station)
142  {
143  const auto& stationCalibData = station.GetCalibData();
144 
145  const auto calibVersion = stationCalibData.GetVersion();
146  const auto& dStation = det::Detector::GetInstance().GetSDetector().GetStation(station);
147 
148  typedef VariableBinHistogramWrap<short, int> CalibHistogram;
149  typedef VariableBinHistogramWrap<double, int> CalibHistogramD;
150 
151  for (auto& pmt : station.PMTsRange(sdet::PMTConstants::eAnyType)) {
152  const auto type = pmt.GetType();
153 
154  // No muon histograms for SmallPMT.
155  // It has its own dedicated function "CopySmallPMTCalibData"
156  // to fill VEM values in RecData from SmallPMTCalibData class.
158  continue;
159 
160  if (!pmt.HasCalibData())
161  continue;
162  auto& pmtCalibData = pmt.GetCalibData();
163 
164  if (!pmtCalibData.IsTubeOk())
165  continue;
166 
167  if (!pmt.HasRecData())
168  pmt.MakeRecData();
169  auto& pmtRec = pmt.GetRecData();
170 
171  if (!pmtRec.GetVEMPeak()) {
172  // first approximation is corrected online value
173  const double onlineFactor =
174  (type == sdet::PMTConstants::eScintillator) ? fPeakOnlineToMIPFactor : fPeakOnlineToVEMFactor;
175  double vemPeak = pmtCalibData.GetOnlinePeak() * onlineFactor;
176  double vemPeakErr = 0;
177  pmtRec.SetOnlineVEMPeak(vemPeak, vemPeakErr);
178  bool vemPeakFromHisto = false;
179 
180  // try to improve values above with histogram fitting
181  if (calibVersion > 8) {
182  const auto& peakHistoBinning = dStation.GetMuonPeakHistogramBinning<short>(type, calibVersion);
183  const int muonPeakHistoSize = pmtCalibData.GetMuonPeakHisto().size();
184  if (!muonPeakHistoSize || int(peakHistoBinning.size())-1 != muonPeakHistoSize) {
185  if (!(fToldYaPeak || pmt.HasSimData())) {
186  WARNING("According to the LS calibration version there should be a muon peak histogram... Will not tell you again!");
187  fToldYaPeak = true;
188  }
189  } else {
190  const CalibHistogram peakHisto(peakHistoBinning, pmtCalibData.GetMuonPeakHisto());
191  const double histoFactor =
192  (type == sdet::PMTConstants::eScintillator) ? fPeakHistogramToMIPFactor : fPeakHistogramToVEMFactor;
193  const double predictedHistoPeak = vemPeak / histoFactor;
194  if (predictedHistoPeak > 0 && peakHisto.GetMaximum() > 200) {
195  const double baseEstimate =
196  pmtCalibData.GetBaseline() - pmtCalibData.GetMuonPeakHistoOffset();
197  const double base = (fabs(baseEstimate) < 20) ? baseEstimate : 0;
198  const double peakLow = fPeakFitRange.first * predictedHistoPeak;
199  const double peakHigh = fPeakFitRange.second * predictedHistoPeak;
200 
201  if (peakHigh - peakLow >= 5) {
202  try {
203  // note: x axis is offset by base, in order to be the same
204  // for all histograms
205  QuadraticFitData qf;
206  MakeQuadraticFitter(peakHisto,
207  peakLow + base, peakHigh + base).GetFitData(qf);
208  pmtRec.GetMuonPeakFitData() = qf;
209  const double fittedPeak = qf.GetExtremePosition() - base;
210  // reasonable limits for the result
211  if (peakLow <= fittedPeak && fittedPeak <= peakHigh &&
212  qf.GetChi2() <= fPeakFitChi2Accept*qf.GetNdof()) {
213  vemPeak = fittedPeak * histoFactor;
214  vemPeakErr = qf.GetExtremePositionError() * histoFactor;
215  pmtRec.SetHistogramVEMPeak(vemPeak, vemPeakErr);
216  vemPeakFromHisto = true;
217  }
218  } catch (OutOfBoundException& ex) {
219  WARNING(ex.GetMessage());
220  }
221  }
222  }
223  }
224  }
225  pmtRec.SetVEMPeak(vemPeak, vemPeakErr);
226  pmtRec.SetIsVEMPeakFromHistogram(vemPeakFromHisto);
227  }
228 
229  if (!pmtRec.GetVEMCharge()) {
230  // The charge conversion factor is the correction for the difference between the mode
231  // of charge histograms for the VEM (vertical-centered muons) or MIP (vertical muons)
232  // and the mode of charge histogram for omni-directional background particles.
233  // charge conversion factor depends on PMT type, so far eScintillator, and eWaterCherenkovLarge;
234  const double onlineFactor =
235  (type == sdet::PMTConstants::eScintillator) ? fChargeOnlineToMIPFactor : fChargeOnlineToVEMFactor;
236  double vemCharge = pmtCalibData.GetOnlineCharge() * onlineFactor;
237  double vemChargeErr = 20 * onlineFactor;
238  pmtRec.SetOnlineVEMCharge(vemCharge, vemChargeErr);
239  bool vemChargeFromHisto = false;
240  double muChargeSlope = 0;
241 
242  // try to improve values above with histogram fitting
243  if (calibVersion > 8) {
244  const auto& chargeHistoBinning = dStation.GetMuonChargeHistogramBinning<double>(type, calibVersion);
245  const auto& calibChargeHisto = pmtCalibData.GetMuonChargeHisto();
246  const int chargeHistoSize = calibChargeHisto.size();
247 
248  if (!chargeHistoSize || int(chargeHistoBinning.size()) - 1 != chargeHistoSize) {
249  if (!fToldYaCharge) {
250  WARNING("According to the LS calibration version there should be a muon charge histogram... Will not tell you again!");
251  fToldYaCharge = true;
252  }
253  } else {
254  const CalibHistogramD chargeHisto(chargeHistoBinning, calibChargeHisto);
255 
256  const int chargeHistoEntries = fIsUUB ?
257  chargeHisto.GetSumEntries() :
258  chargeHisto.GetSumEntries() - calibChargeHisto.back();
259 
260  if (chargeHistoEntries > 1e4) {
261  const double chargeEntropyMinimum =
262  (chargeHistoEntries > 5e4) ? 0 : ((type == sdet::PMTConstants::eWaterCherenkovLarge) ? 5 : 3);
263  const double chargeEntropy = chargeHisto.GetEntropy();
264  if (chargeEntropy > chargeEntropyMinimum) {
265  // UUB: baseline correction not yet available
266  double base = 0;
267  if (!fIsUUB) {
268  // apparently there were 19 bins in calibration version 13
269  const double baseEstimate = pmtCalibData.GetBaseline() *
270  (calibVersion == 13 ? 19 : 20) - pmtCalibData.GetMuonChargeHistoOffset();
271  base = (fabs(baseEstimate) < 20) ? baseEstimate : 0;
272  }
273 
274  const auto chargeDensity = chargeHisto.GetDensityVector();
275  const auto chargeDensityError = chargeHisto.GetDensityErrorVector();
276 
277  for (const auto& thresholdFactor: fChargeSigmaThresholdFactors) {
278  double chargeHumpPos = 0;
279  double chargeHumpPosError = 0;
280  double chargeDipPos = 0;
281 
282  // skip 5 last bins and any small values at the high end
283  const unsigned int binStart = chargeHisto.GetNBins() - 5;
284  unsigned int humpBin = binStart;
285  double humpDensity = chargeDensity[humpBin];
286  double humpDensityError = chargeDensityError[humpBin];
287 
288  unsigned int humpLimitLow = 0;
289  for (unsigned int bin = humpBin - 1; bin > 1; --bin) {
290  const double dens1 = chargeDensity[bin];
291  const double dens2 = chargeDensity[bin - 1];
292  const double dens3 = chargeDensity[bin - 2];
293  const double thresh = humpDensity - thresholdFactor * humpDensityError;
294  if (dens1 < thresh && dens2 < thresh && dens3 < thresh) {
295  humpLimitLow = bin;
296  break;
297  }
298  if (dens1 > humpDensity) {
299  humpBin = bin;
300  humpDensity = dens1;
301  humpDensityError = chargeDensityError.at(bin);
302  }
303  }
304 
305  const double histoFactor =
306  (type == sdet::PMTConstants::eScintillator) ? fChargeHistogramToMIPFactor : fChargeHistogramToVEMFactor;
307 
308  if (humpLimitLow) {
309  unsigned int humpLimitHigh = 0;
310  for (unsigned int bin = humpBin + 1; bin < binStart; ++bin) {
311  double dens1 = chargeDensity[bin];
312  double dens2 = chargeDensity[bin + 1];
313  double dens3 = chargeDensity[bin + 2];
314  double thresh = humpDensity - thresholdFactor * humpDensityError;
315  if (dens1 < thresh && dens2 < thresh && dens3 < thresh) {
316  humpLimitHigh = bin;
317  break;
318  }
319  }
320 
321  if (humpLimitHigh) {
322  const double chargeHumpLow = chargeHisto.GetBinCenter(humpLimitLow);
323  const double chargeHumpHigh = chargeHisto.GetBinCenter(humpLimitHigh);
324 
325  try {
326  QuadraticFitData qfHump;
327  MakeQuadraticFitter(chargeHisto, chargeHumpLow, chargeHumpHigh).GetFitData(qfHump);
328  pmtRec.GetMuonChargeFitData() = qfHump;
329  const double humpFit = qfHump.GetExtremePosition();
330  if (chargeHumpLow <= humpFit && humpFit <= chargeHumpHigh &&
331  qfHump.GetChi2() <= fChargeFitChi2Accept * qfHump.GetNdof() &&
332  qfHump.GetCoefficient(2) < 0) {
333  chargeHumpPos = humpFit;
334  chargeHumpPosError = qfHump.GetExtremePositionError();
335  }
336  } catch (OutOfBoundException& ex) {
337  ostringstream warn;
338  warn << ex.GetMessage()
339  << "\nQuadratic fit of hump between limits "
340  << chargeHumpLow
341  << " and "
342  << chargeHumpHigh
343  << " failed on this charge histogram:\n";
344  WARNING(warn);
345  }
346 
347  // ToDo: correct for UUB bin spacing (small: 1->8, big: 3->32)
348  try {
349  // slope of muon charge
351  const double start = chargeHumpHigh + 10;
352  const double stop = min(2 * start, 950.);
353  if (start + 10 < stop) {
354  MakeExponentialFitter(chargeHisto, start, stop).GetFit(ef);
355  pmtRec.GetMuonChargeSlopeFitData() = ef;
356  const double slope = (chargeHumpPos - base) * histoFactor * ef.GetSlope();
357  if (slope < -0.5)
358  muChargeSlope = slope;
359  }
360  } catch (OutOfBoundException& ex) {
361  WARNING(ex.GetMessage());
362  }
363  }
364  }
365 
366  // get dip when hump exists (dip pos < hump limit low, dip limit high < hump pos)
367  if (chargeHumpPos && humpLimitLow > 0) {
368  unsigned int dipBin = humpLimitLow - 1;
369  double dipDensity = chargeDensity.at(dipBin);
370  double dipDensityError = chargeDensityError.at(dipBin);
371 
372  unsigned int dipLimitLow = 0;
373  for (unsigned int bin = dipBin - 1; bin > 1; --bin) {
374  double dens1 = chargeDensity[bin];
375  double dens2 = chargeDensity[bin - 1];
376  double dens3 = chargeDensity[bin - 2];
377  double thresh = dipDensity + thresholdFactor * dipDensityError;
378  if (dens1 > thresh && dens2 > thresh && dens3 > thresh) {
379  dipLimitLow = bin;
380  break;
381  }
382  if (dens1 < dipDensity) {
383  dipBin = bin;
384  dipDensity = dens1;
385  dipDensityError = chargeDensityError[bin];
386  }
387  }
388 
389  if (dipLimitLow) {
390  unsigned int dipLimitHigh = 0;
391  for (unsigned int bin = dipBin + 1; bin < humpBin; ++bin) {
392  double dens1 = chargeDensity[bin];
393  double dens2 = chargeDensity[bin + 1];
394  double dens3 = chargeDensity[bin + 2];
395  double thresh = dipDensity + thresholdFactor * dipDensityError;
396  if (dens1 > thresh && dens2 > thresh && dens3 > thresh) {
397  dipLimitHigh = bin;
398  // first estimate of dip position, following fit is optional
399  chargeDipPos = chargeHisto.GetBinCenter(dipBin);
400  break;
401  }
402  }
403 
404  if (dipLimitHigh) {
405  const double chargeDipLow = chargeHisto.GetBinCenter(dipLimitLow);
406  const double chargeDipHigh = chargeHisto.GetBinCenter(dipLimitHigh);
407 
408  if ((dipLimitHigh - dipLimitLow) > 10) {
409  try {
410  QuadraticFitData qfDip;
411  MakeQuadraticFitter(chargeHisto, chargeDipLow, chargeDipHigh).GetFitData(qfDip);
412  const double dipFit = qfDip.GetExtremePosition();
413  if (chargeDipLow <= dipFit && dipFit <= chargeDipHigh &&
414  qfDip.GetChi2() <= fChargeFitChi2Accept * qfDip.GetNdof() &&
415  qfDip.GetCoefficient(2) > 0)
416  chargeDipPos = dipFit;
417  } catch (OutOfBoundException& ex) {
418  ostringstream warn;
419  warn << ex.GetMessage() << "\n"
420  "\nQuadratic fit of dip between limits "
421  << chargeDipLow << " and " << chargeDipHigh
422  << " failed on this charge histogram:\n";
423  WARNING(warn);
424  }
425  }
426  }
427  }
428  }
429 
430  if (chargeHumpPos && chargeDipPos) {
431  if (chargeHumpPos / chargeDipPos > 1.3) {
432  vemCharge = (chargeHumpPos - base) * histoFactor;
433  vemChargeErr = chargeHumpPosError * histoFactor;
434  pmtRec.SetHistogramVEMCharge(vemCharge, vemChargeErr);
435  vemChargeFromHisto = true;
436  }
437 
438  // break loop over thresholdFactors
439  break;
440  }
441  }
442  }
443  } // if total number entries > 1e4
444  }
445  }
446  if (!vemChargeFromHisto &&
447  fIsUUB &&
448  !IsInRange(vemCharge, (type == sdet::PMTConstants::eWaterCherenkovLarge) ? fChargeVEMRangeUub : fChargeMIPRange)) {
449  vemCharge = 0;
450  vemChargeErr = 0;
451  muChargeSlope = 0;
452  pmtCalibData.SetIsTubeOk(false);
453  }
454  pmtRec.SetVEMCharge(vemCharge, vemChargeErr);
455  pmtRec.SetIsVEMChargeFromHistogram(vemChargeFromHisto);
456  pmtRec.SetMuonChargeSlope(muChargeSlope);
457  }
458 
459  // shape histogram
460  double muDecayTime = 0;
461  double muDecayTimeErr = 0;
462  if (calibVersion > 8) {
463  // muon decay time from muon shape histogram
464  const auto& muShapeHisto = pmtCalibData.GetMuonShapeHisto();
465  if (muShapeHisto.empty()) {
466  if (!fToldYaShape) {
467  WARNING("According to the LS calibration version there should be a muon shape histogram... "
468  "Will not tell you again!");
469  fToldYaShape = true;
470  }
471  } else {
472  if (!muShapeHisto.empty()) {
473  try {
475 
476  typedef VariableBinHistogramWrap<double, int> ShapeHistogram;
477  const auto& shapeHistoBinning = dStation.GetMuonShapeHistogramBinning(calibVersion);
478  const double subtract = muShapeHisto[0];
479  MakeExponentialFitter(ShapeHistogram(shapeHistoBinning, muShapeHisto),
480  (calibVersion < 12 ?
481  fShapeFitRangeBefore12 :
482  fShapeFitRangeSince12)).GetFit(ef, subtract);
483  pmtRec.GetMuonShapeFitData() = ef;
484 
485  const double slope = ef.GetSlope();
486  const double slopeErr = ef.GetSlopeError();
487 
488  if (slope) {
489  const double decayTime = -1 / slope;
490  if (0 <= decayTime && decayTime < 1000*nanosecond) {
491  muDecayTime = decayTime;
492  muDecayTimeErr = slopeErr / Sqr(slope);
493  }
494  }
495  } catch (OutOfBoundException& ex) {
496  WARNING(ex.GetMessage());
497  }
498  }
499  }
500  }
501  pmtRec.SetMuonPulseDecayTime(muDecayTime, muDecayTimeErr);
502 
503  }
504  }
505 
506 
507  bool
508  SdHistogramFitter::CopySmallPMTCalibData(Station& station)
509  {
510  // Check specific SmallPMT quantities
511  const auto& spmtData = station.GetSmallPMTData();
512  if (!spmtData.HasCalibData())
513  return false;
514 
515  const auto& spmtCalib = spmtData.GetCalibData();
516 
517  if (!spmtCalib.IsTubeOk())
518  return false;
519 
520  // Check standard PMT quantities
521  auto& pmt = station.GetSmallPMT();
522  if (!pmt.HasCalibData())
523  return false;
524 
525  const auto& pmtCalib = pmt.GetCalibData();
526 
527  if (!pmtCalib.IsTubeOk())
528  return false;
529 
530  if (!pmt.HasRecData())
531  pmt.MakeRecData();
532  auto& pmtRec = pmt.GetRecData();
533 
534  const double spmtVemCharge = 1 / (spmtCalib.GetBeta() * spmtCalib.GetCorrectionFactor());
535  const double spmtVemChargeErr =
536  (spmtCalib.GetBetaError() * spmtCalib.GetCorrectionFactor()) * Sqr(spmtVemCharge);
537 
538  if (std::isnan(spmtVemCharge) || std::isinf(spmtVemCharge) ||
539  spmtVemCharge <= 0 || spmtVemChargeErr <= 0)
540  return false;
541 
542  pmtRec.SetVEMCharge(spmtVemCharge, spmtVemChargeErr);
543 
544  // SmallPMT "VEMpeak" estimation
545  double muonAreaOverPeak = 0;
546  for (const auto& lpmt : station.PMTsRange()) {
547  if (lpmt.HasCalibData() &&
548  lpmt.GetCalibData().IsTubeOk() &&
549  lpmt.HasRecData() &&
550  lpmt.GetRecData().GetVEMPeak() > 0) {
551  const auto& lpmtRec = lpmt.GetRecData();
552  muonAreaOverPeak += lpmtRec.GetVEMCharge() / lpmtRec.GetVEMPeak();
553  }
554  }
555  if (muonAreaOverPeak > 0)
556  pmtRec.SetVEMPeak(spmtVemCharge / muonAreaOverPeak, 0);
557  else {
558  ostringstream warn;
559  warn << "Station " << station.GetId()
560  << ": Cannot calculate properly SmallPMT VEMpeak. Using default value = 1/3";
561  WARNING(warn);
562  pmtRec.SetVEMPeak(1./3, 0);
563  }
564 
565  ostringstream info;
566  info << "SmallPMT calibration for station " << station.GetId() << "\n"
567  << " beta = " << spmtCalib.GetBeta() << " +- " << spmtCalib.GetBetaError()
568  << " ---> VEMcharge = " << pmtRec.GetVEMCharge() << " +- " << pmtRec.GetVEMChargeError()
569  << " (VEMpeak = " << pmtRec.GetVEMPeak() << ")";
570  INFO(info);
571 
572  pmtRec.SetIsVEMChargeFromHistogram(false);
573  pmtRec.SetIsVEMPeakFromHistogram(false);
574 
575  pmtRec.SetMuonChargeSlope(0);
576  pmtRec.SetMuonPulseDecayTime(0, 0);
577  pmtRec.SetGainRatio(1);
578 
579  return true;
580  }
581 
582 }
int GetId() const
Get the station Id.
constexpr T Sqr(const T &x)
Holds result of the quadratic fit.
PMTCalibData & GetCalibData()
Get object containing PMT calibration data.
Definition: SEvent/PMT.h:56
double GetExtremePositionError() const
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
Exception for reporting variable out of valid range.
SmallPMTCalibData & GetCalibData()
Definition: SmallPMTData.h:21
oss<< "0b";oss<< ((x >> i)&1);return oss.str();}template< class S, class V > std::string Join(const S &sep, const V &v)
Definition: String.h:60
class to hold data at Station level
ExponentialFitter< Histogram > MakeExponentialFitter(const Histogram &histogram, const T &start, const T &stop)
constexpr double nanosecond
Definition: AugerUnits.h:143
double abs(const SVector< n, T > &v)
SmallPMTData & GetSmallPMTData()
#define WARNING(message)
Macro for logging warning messages.
Definition: ErrorLogger.h:163
QuadraticFitter< Histogram, ErrorPolicy > MakeQuadraticFitter(const Histogram &h, const ErrorPolicy)
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
sevt::StationCalibData & GetCalibData()
Get calibration data for the station.
double GetCoefficient(unsigned int i) const
double GetChi2() const
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
double GetExtremePosition() const
int GetVersion() const
version of the onboard calibration
bool IsInRange(const double x, const vector< double > &r)
PMT & GetSmallPMT()
double GetSlopeError() const
bool HasSEvent() const
const std::string & GetMessage() const
Retrieve the message from the exception.
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)

, generated on Tue Sep 26 2023.