46 B2ERROR(
"TOPCommonT0LLAlgorithm: histogram 'tracks_per_set' not found");
49 unsigned numSets = h1->GetNbinsX();
51 vector<Chi2MinimumFinder1D> finders;
52 for (
unsigned set = 0; set < numSets; set++) {
53 string name =
"chi2_set" + to_string(set);
58 if (finders.size() != numSets) {
59 B2ERROR(
"TOPCommonT0LLAlgorithm: got number of chi2 scans not as expected"
60 <<
LogVar(
"expected", numSets)
61 <<
LogVar(
"found", finders.size()));
69 B2ERROR(
"TOPCommonT0LLAlgorithm: histogram 'offset' not found");
72 double bunchTimeSep = h4->GetXaxis()->GetXmax() - h4->GetXaxis()->GetXmin();
77 string expNo = to_string(expRun[0].first);
78 while (expNo.length() < 4) expNo.insert(0,
"0");
79 string runNo = to_string(expRun[0].second);
80 while (runNo.length() < 5) runNo.insert(0,
"0");
81 string outputFileName =
"commonT0-e" + expNo +
"-r" + runNo +
".root";
82 auto* file = TFile::Open(outputFileName.c_str(),
"recreate");
84 auto* tree =
new TTree(
"tree",
"common T0 calibration results");
85 tree->Branch<
int>(
"expNum", &
m_expNo);
86 tree->Branch<
int>(
"runNum", &
m_runNo);
89 tree->Branch<
float>(
"offset", &
m_offset);
102 auto h_pulls =
new TH1F(
"pulls",
"Pulls of statistically independent results",
104 h_pulls->SetXTitle(
"pulls");
105 std::vector<double> pos, err;
106 for (
auto& finder : finders) {
107 const auto& minimum = finder.getMinimum();
108 if (not minimum.valid)
continue;
109 pos.push_back(minimum.position);
110 err.push_back(minimum.error);
112 for (
unsigned i = 0; i < pos.size(); i++) {
113 for (
unsigned j = i + 1; j < pos.size(); j++) {
114 double pull = (pos[i] - pos[j]) /
sqrt(err[i] * err[i] + err[j] * err[j]);
118 double scaleError = 1;
119 if (h_pulls->GetEntries() > 1) scaleError = h_pulls->GetRMS();
123 auto finder = finders[0];
124 for (
unsigned i = 1; i < numSets; i++) {
125 finder.add(finders[i]);
128 auto h_commonT0 =
new TH1F(
"commonT0",
"Common T0", 1, 0, 1);
129 h_commonT0->SetYTitle(
"common T0 [ns]");
131 const auto& minimum = finder.getMinimum();
137 h_commonT0->SetBinContent(1,
m_offset);
153 auto h = finder.getHistogram(
"chi2",
"chi2 scan; t0 [ns]; -2 logL");
std::shared_ptr< T > getObjectPtr(const std::string &name, const std::vector< Calibration::ExpRun > &requestedRuns)
Get calibration data object by name and list of runs, the Merge function will be called to generate t...