1 #include <det/Detector.h>
3 #include <sdet/SDetector.h>
4 #include <sdet/PMTConstants.h>
8 #include <fwk/CentralConfig.h>
10 #include <sevt/SEvent.h>
11 #include <sevt/Station.h>
12 #include <sevt/StationSimData.h>
13 #include <sevt/StationCalibData.h>
14 #include <sevt/PMTCalibData.h>
15 #include <sevt/PMTSimData.h>
20 #include <utl/Reader.h>
30 using namespace SdSimulationCalibrationFillerOG;
36 auto topB = CentralConfig::GetInstance()->GetTopBranch(
"SdSimulationCalibrationFiller");
38 const auto calibratorBranch = topB.GetChild(
"calibratorBranch").Get<
string>();
41 auto calibTopB = CentralConfig::GetInstance()->GetTopBranch(calibratorBranch);
43 calibTopB.GetChild(
"peakOnlineToVEMFactor").GetData(fPeakOnlineToVEMFactor);
44 calibTopB.GetChild(
"chargeOnlineToVEMFactor").GetData(fChargeOnlineToVEMFactor);
47 info <<
"from top branch <" << calibratorBranch <<
"> of the calibrator module got "
48 "the peak online-to-vem factor " << fPeakOnlineToVEMFactor <<
" and "
49 "the charge online-to-vem " << fChargeOnlineToVEMFactor;
53 topB.GetChild(
"calibrationVersion").GetData(fCalibVersion);
58 auto spmtCalibB = topB.GetChild(
"SmallPMTCalibration");
60 spmtCalibB.GetChild(
"version").GetData(fSPMTVersion);
61 spmtCalibB.GetChild(
"beta").GetData(fBeta);
62 spmtCalibB.GetChild(
"betaErr").GetData(fBetaError);
63 spmtCalibB.GetChild(
"chi2").GetData(fChi2);
65 info <<
"Got calibration constants for SmallPMT -- version " << fSPMTVersion <<
"\n"
66 "\tbeta = " << fBeta <<
" +- " << fBetaError <<
" (chi2 = " << fChi2 <<
")";
69 const auto betas = spmtCalibB.GetChild(
"betasLPMT").Get<vector<double>>();
70 const auto betaErrs = spmtCalibB.GetChild(
"betaErrsLPMT").Get<vector<double>>();
71 const auto chi2s = spmtCalibB.GetChild(
"chi2sLPMT").Get<vector<double>>();
74 if (betas.size() != 3 || betaErrs.size() != 3 || chi2s.size() != 3) {
75 ERROR(
"Wrong SmallPMT calibration values for single LPMTs");
78 info <<
"\tsingle LPMTs betas:";
79 for (
int i = 0; i < 3; ++i) {
80 fBetaLPMT[i] = betas.at(i);
81 fBetaErrorLPMT[i] = betaErrs[i];
82 fChi2LPMT[i] = chi2s[i];
85 <<
" beta = " << fBetaLPMT[i] <<
" +- " << fBetaErrorLPMT[i]
86 <<
" (chi2 = " << fChi2LPMT[i] <<
")";
98 SdSimulationCalibrationFiller::Run(
Event& event)
103 auto& sEvent =
event.GetSEvent();
105 for (
auto& station : sEvent.CandidateStationsRange()) {
107 const bool isUUB = station.IsUUB();
110 if (station.HasSimData())
111 signature = station.GetSimData().GetSimulatorSignature();
113 ERROR(
"No SimData found, though it should exist at this point");
115 if (!station.HasCalibData())
116 station.MakeCalibData();
118 auto& stationCalib = station.GetCalibData();
120 stationCalib.SetVersion(fCalibVersion);
121 stationCalib.SetStartSecond(1);
122 stationCalib.SetEndSecond(3);
123 stationCalib.SetNT1(100);
124 stationCalib.SetNT2(20);
125 stationCalib.SetNTot(1);
129 if (!pmt.HasCalibData())
131 auto& pmtCalib = pmt.GetCalibData();
133 if (!pmt.HasSimData())
135 auto& pmtSim = pmt.GetSimData();
137 const auto& dStation = det::Detector::GetInstance().GetSDetector().GetStation(station);
138 const auto pmtId = pmt.GetId();
139 const auto& dPMT = dStation.GetPMT(pmtId);
144 const double onlinePeak = dPMT.GetVEMPeak(signature) / fPeakOnlineToVEMFactor;
145 pmtSim.SetTriggerVEMPeak(onlinePeak);
147 pmtCalib.SetOnlinePeak(onlinePeak);
150 const double compatPeak = dPMT.GetCompatibilityVEMPeak(signature) / fPeakOnlineToVEMFactor;
151 pmtCalib.SetOnlinePeak(compatPeak);
152 pmtSim.SetCompatibilityTriggerVEMPeak(compatPeak);
154 const double onlineCharge = dPMT.GetVEMCharge(signature) / fChargeOnlineToVEMFactor;
155 pmtCalib.SetOnlineCharge(onlineCharge);
158 pmtCalib.SetBaseline(dPMT.GetBaseline(
gain), dPMT.GetBaselineRMS(
gain),
gain);
160 pmtCalib.SetIsTubeOk(
true);
161 pmtCalib.SetIsLowGainOk(
true);
162 pmtCalib.SetRate(7e3);
163 pmtCalib.SetGainRatio(dPMT.GetGainRatio(), dPMT.GetGainRatioRMS());
165 pmtCalib.SetEvolution(0);
166 pmtCalib.SetNumberTDA(0);
167 pmtCalib.SetHighGainDelay(0, 0);
168 pmtCalib.SetHighGainDelayChi2(0);
171 auto& spmtData = station.GetSmallPMTData();
172 if (!spmtData.HasCalibData())
173 spmtData.MakeCalibData();
174 auto& spmtCalib = spmtData.GetCalibData();
175 spmtCalib.SetIsTubeOk(
true);
176 spmtCalib.SetVersion(fSPMTVersion);
177 spmtCalib.SetBeta(fBeta);
178 spmtCalib.SetBetaError(fBetaError);
179 spmtCalib.SetChi2(fChi2);
180 spmtCalib.SetCorrectionFactor(1);
182 const auto lpmtId = lpmt.GetId();
183 const auto i = lpmtId - dStation.GetFirstPMTId();
184 spmtCalib.SetBeta(fBetaLPMT[i], lpmtId);
185 spmtCalib.SetBetaError(fBetaErrorLPMT[i], lpmtId);
186 spmtCalib.SetChi2(fChi2LPMT[i], lpmtId);
187 spmtCalib.SetCorrectionFactor(1, lpmtId);
#define INFO(message)
Macro for logging informational messages.
void Init()
Initialise the registry.
ResultFlag
Flag returned by module methods to the RunController.
#define ERROR(message)
Macro for logging error messages.