IsLightning.cc
Go to the documentation of this file.
1 #include <sevt/Station.h>
2 #include <det/Detector.h>
3 #include <sdet/SDetector.h>
4 #include <sdet/Station.h>
5 #include <sevt/IsLightning.h>
6 
7 #include <sstream>
8 
9 using namespace std;
10 using namespace utl;
11 
12 
13 namespace sevt {
14 
15  namespace {
16  const int kLightningThreshold = 1000;
17  const int kLightningHysteresis = 4;
18  }
19 
20 
21  bool
22  IsLightning(const Station& station)
23  {
24  if (!station.HasCalibData())
25  return false;
26 
27  const auto& dStation = det::Detector::GetInstance().GetSDetector().GetStation(station);
28 
29  struct PMTInfo {
30  const TraceI* trace;
31  const TraceD* baseline;
32  };
33 
34  PMTInfo activePMTs[dStation.GetNPMTs()];
35 
36  // find active PMTs and their baseline's
37  int nActivePMTs = 0;
38 
39  for (const auto& pmt : station.PMTsRange()) {
40  if (pmt.HasFADCTrace() && pmt.HasRecData()) {
41  const auto& pmtRec = pmt.GetRecData();
42  if (pmtRec.HasFADCBaseline(sdet::PMTConstants::eHighGain)) {
43  activePMTs[nActivePMTs].trace = &(pmt.GetFADCTrace(sdet::PMTConstants::eHighGain));
44  activePMTs[nActivePMTs].baseline = &(pmtRec.GetFADCBaseline(sdet::PMTConstants::eHighGain));
45  ++nActivePMTs;
46  }
47  }
48  }
49 
50  if (nActivePMTs == 3) {
51 
52  int count[3] = { 0 };
53  bool cross[3] = { true, true, true };
54 
55  const int tracesize = dStation.GetFADCTraceLength();
56 
57  for (int pmt = 0; pmt < 3; ++pmt) {
58 
59  const PMTInfo& pmti = activePMTs[pmt];
60  const TraceI& trace = *pmti.trace;
61  const TraceD& baseline = *pmti.baseline;
62 
63  for (int i = 0; i < tracesize; ++i) {
64  if (trace[i] > kLightningThreshold)
65  return false;
66  const double signal = trace[i] - baseline[i];
67  if (cross[pmt] && signal < -kLightningHysteresis) {
68  ++count[pmt];
69  cross[pmt] = false;
70  }
71  if (!cross[pmt] && signal > kLightningHysteresis)
72  cross[pmt] = true;
73  }
74  }
75 
76  // PMT 1 has smaller signal
77  if (count[0] > 2 && count[1] > 3 && count[2] > 3) {
78  ostringstream info;
79  info << '(' << count[0] << ", " << count[1] << ", " << count[2]
80  << ") oscillations in station " << station.GetId();
81  INFO(info);
82  return true;
83  }
84  }
85 
86  return false;
87  }
88 
89 }
AxialVector cross(const Vector &l, const Vector &r)
vector cross product
Definition: OperationsAV.h:32
int GetId() const
Get the station Id.
bool HasCalibData() const
Check whether calibration data object exists.
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
class to hold data at Station level
bool IsLightning(const Station &station)
Definition: IsLightning.cc:22

, generated on Tue Sep 26 2023.