Belle II Software development
SVDTimeValidationAlgorithm.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#include <svd/calibration/SVDTimeValidationAlgorithm.h>
9
10#include <svd/dbobjects/SVDCoGCalibrationFunction.h>
11#include <svd/calibration/SVDCoGTimeCalibrations.h>
12
13#include <TF1.h>
14#include <TProfile.h>
15#include "TH1F.h"
16#include "TH2F.h"
17#include "TH3F.h"
18#include <framework/logging/Logger.h>
19#include <iostream>
20#include <TString.h>
21#include <TFitResult.h>
22
23using namespace Belle2;
24
26 CalibrationAlgorithm("SVDTimeValidationCollector")
27{
28 setDescription("SVDTimeValidation calibration algorithm");
29}
30
32{
33
34 gROOT->SetBatch(true);
35
36 auto hEventT0 = getObjectPtr<TH1F>("hEventT0");
37 float eventT0_mean = 0;
38 float eventT0_rms = 0;
39 if (hEventT0) {
40 eventT0_mean = hEventT0->GetMean();
41 eventT0_rms = hEventT0->GetRMS();
42 } else
43 B2ERROR("Histogram with Event T0 not found");
44
45 B2DEBUG(27, "Histogram: " << hEventT0->GetName() <<
46 " Entries (n. clusters): " << hEventT0->GetEntries() <<
47 " Mean: " << eventT0_mean);
48
49 auto __hClsTimeOnTracks__ = getObjectPtr<TH2F>("__hClsTimeOnTracks__");
50 // auto __hClsTimeAll__ = getObjectPtr<TH2F>("__hClsTimeAll__");
51 // auto __hClsDiffTimeOnTracks__ = getObjectPtr<TH2F>("__hClsDiffTimeOnTracks__");
52 auto __hBinToSensorMap__ = getObjectPtr<TH1F>("__hBinToSensorMap__");
53
54 for (int ij = 0; ij < (__hBinToSensorMap__->GetNbinsX()); ij++) {
55 {
56 {
57 {
58
59 auto binLabel = __hBinToSensorMap__->GetXaxis()->GetBinLabel(ij + 1);
60 char side;
61 int layer_num, ladder_num, sensor_num;
62 std::sscanf(binLabel, "L%dL%dS%d%c", &layer_num, &ladder_num, &sensor_num, &side);
63
64 B2INFO("Projecting for Sensor: " << binLabel << " with Bin Number: " << ij + 1);
65
66 auto hClsTimeOnTracks = (TH1D*)__hClsTimeOnTracks__->ProjectionX("hClsTimeOnTracks_tmp", ij + 1, ij + 1);
67 if (!hClsTimeOnTracks)
68 B2ERROR("Histogram " << Form("clsTimeOnTracks__L%dL%dS%d%c", layer_num, ladder_num, sensor_num, side) << " not found");
69
70 hClsTimeOnTracks->SetName(Form("clsTimeOnTracks__L%dL%dS%d%c", layer_num, ladder_num, sensor_num, side));
71 char sidePN = (side == 'U' ? 'P' : 'N');
72 hClsTimeOnTracks->SetTitle(Form("clsTimeOnTracks in %d.%d.%d %c/%c", layer_num, ladder_num, sensor_num, side, sidePN));
73 hClsTimeOnTracks->SetDirectory(0);
74
75 float clsTimeOnTracks_mean = hClsTimeOnTracks->GetMean();
76 auto deviation = (clsTimeOnTracks_mean - eventT0_mean) / eventT0_rms;
77
78 B2DEBUG(27, "Histogram: " << hClsTimeOnTracks->GetName() <<
79 " Entries (n. clusters): " << hClsTimeOnTracks->GetEntries() <<
80 " Mean: " << clsTimeOnTracks_mean <<
81 " Deviation: " << deviation << " EventT0 RMS");
82 if (std::fabs(deviation) > m_allowedDeviationMean)
83 B2ERROR("Histogram: " << hClsTimeOnTracks->GetName() << " deviates from EventT0 by" << deviation << " times the EventT0 RMS");
84
85 delete hClsTimeOnTracks;
86 }
87 }
88 }
89 }
90 return c_OK;
91}
void setDescription(const std::string &description)
Set algorithm description (in constructor)
EResult
The result of calibration.
@ c_OK
Finished successfully =0 in Python.
CalibrationAlgorithm(const std::string &collectorModuleName)
Constructor - sets the prefix for collected objects (won't be accesses until execute(....
float m_allowedDeviationMean
Allowed deviation of clsOnTracks histo wrt EventT0 histo in number of EventT0 RMS.
SVDTimeValidationAlgorithm()
Constructor set the prefix to SVDTimeCalibrationCollector.
virtual EResult calibrate() override
Run algo on data.
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...
Abstract base class for different kinds of events.