9#include <top/calibration/TOPEventT0OffsetAlgorithm.h>
10#include <top/dbobjects/TOPCalEventT0Offset.h>
11#include <framework/gearbox/Const.h>
30 setDescription(
"Calibration algorithm for event T0 offset calibration");
40 string expNo = to_string(expRun[0].first);
41 while (expNo.length() < 4) expNo.insert(0,
"0");
42 string runNo = to_string(expRun[0].second);
43 while (runNo.length() < 5) runNo.insert(0,
"0");
44 string outputFileName =
"evenT0Offset-e" + expNo +
"-r" + runNo +
".root";
45 auto* file = TFile::Open(outputFileName.c_str(),
"recreate");
53 std::map<Const::EDetector, std::string> names;
54 names[Const::SVD] =
"svdOffset";
55 names[Const::CDC] =
"cdcOffset";
56 for (
const auto& x : names) {
57 auto h = getObjectPtr<TH1F>(x.second);
59 double sum = h->Integral();
61 auto* func =
new TF1(
"func1g",
62 "[0] + [1]/sqrt(2*pi)/[3]*exp(-0.5*((x-[2])/[3])**2)",
63 h->GetXaxis()->GetXmin(), h->GetXaxis()->GetXmax());
64 func->SetParameter(0, 0);
65 func->SetParameter(1, sum * h->GetBinWidth(1));
66 func->SetParameter(2, h->GetBinCenter(h->GetMaximumBin()));
68 int status = h->Fit(func,
"LRSQ");
69 if (status == 0) eventT0Offset->set(x.first, func->GetParameter(2), std::abs(func->GetParameter(3)));
76 if (eventT0Offset->isEmpty()) {
Base class for calibration algorithms.
void saveCalibration(TClonesArray *data, const std::string &name)
Store DBArray payload with given name with default IOV.
void setDescription(const std::string &description)
Set algorithm description (in constructor)
const std::vector< Calibration::ExpRun > & getRunList() const
Get the list of runs for which calibration is called.
EResult
The result of calibration.
@ c_OK
Finished successfully =0 in Python.
@ c_NotEnoughData
Needs more data =2 in Python.
Class to store the calibrated EventT0 offsets of other detector components The offsets are measured r...
int m_minEntries
minimal number of entries to perform fit
virtual EResult calibrate() final
algorithm implementation
double m_sigma
initial value for Gaussian width [ns]
TOPEventT0OffsetAlgorithm()
Constructor.
Abstract base class for different kinds of events.