Belle II Software  release-06-01-15
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 <TH2F.h>
16 #include <framework/logging/Logger.h>
17 #include <iostream>
18 #include <TString.h>
19 #include <TFitResult.h>
20 
21 using namespace std;
22 using namespace Belle2;
23 
24 SVDTimeValidationAlgorithm::SVDTimeValidationAlgorithm() :
25  CalibrationAlgorithm("SVDTimeValidationCollector")
26 {
27  setDescription("SVDTimeValidation calibration algorithm");
28 }
29 
31 {
32 
33  gROOT->SetBatch(true);
34 
35  auto hEventT0 = getObjectPtr<TH1F>("hEventT0");
36  float eventT0_mean = 0;
37  float eventT0_rms = 0;
38  if (hEventT0) {
39  eventT0_mean = hEventT0->GetMean();
40  eventT0_rms = hEventT0->GetRMS();
41  } else
42  B2ERROR("Histogram with Event T0 not found");
43 
44  B2DEBUG(27, "Histogram: " << hEventT0->GetName() <<
45  " Entries (n. clusters): " << hEventT0->GetEntries() <<
46  " Mean: " << eventT0_mean);
47 
49  for (auto layer : geoCache.getLayers(VXD::SensorInfoBase::SVD)) {
50  for (auto ladder : geoCache.getLadders(layer)) {
51  for (Belle2::VxdID sensor : geoCache.getSensors(ladder)) {
52  for (int view = SVDHistograms<TH1F>::VIndex ; view < SVDHistograms<TH1F>::UIndex + 1; view++) {
53  char side = 'U';
54  if (view == 0)
55  side = 'V';
56  auto layer_num = sensor.getLayerNumber();
57  auto ladder_num = sensor.getLadderNumber();
58  auto sensor_num = sensor.getSensorNumber();
59  auto hClsTimeOnTracks = getObjectPtr<TH1F>(Form("clsTimeOnTracks__L%dL%dS%d%c", layer_num, ladder_num, sensor_num, side));
60  float clsTimeOnTracks_mean = 0.;
61  if (hClsTimeOnTracks)
62  clsTimeOnTracks_mean = hClsTimeOnTracks->GetMean();
63  else
64  B2ERROR("Histogram " << Form("clsTimeOnTracks__L%dL%dS%d%c", layer_num, ladder_num, sensor_num, side) << " not found");
65  auto deviation = (clsTimeOnTracks_mean - eventT0_mean) / eventT0_rms;
66 
67  B2DEBUG(27, "Histogram: " << hClsTimeOnTracks->GetName() <<
68  " Entries (n. clusters): " << hClsTimeOnTracks->GetEntries() <<
69  " Mean: " << clsTimeOnTracks_mean <<
70  " Deviation: " << deviation << " EventT0 RMS");
71  if (abs(deviation) > m_allowedDeviationMean)
72  B2ERROR("Histogram: " << hClsTimeOnTracks->GetName() << " deviates from EventT0 by" << deviation << " times the EventT0 RMS");
73 
74  }
75  }
76  }
77  }
78  return c_OK;
79 }
Base class for calibration algorithms.
void setDescription(const std::string &description)
Set algorithm description (in constructor)
EResult
The result of calibration.
@ c_OK
Finished successfuly =0 in Python.
template class for SVd histograms
Definition: SVDHistograms.h:24
float m_allowedDeviationMean
Allowed deviation of clsOnTracks histo wrt EventT0 histo in number of EventT0 RMS.
virtual EResult calibrate() override
Run algo on data.
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
Definition: GeoCache.h:39
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:213
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
Abstract base class for different kinds of events.