Belle II Software development
SVDCrossTalkCalibrationsAlgorithm.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
9#include <svd/calibration/SVDCrossTalkCalibrationsAlgorithm.h>
10#include <svd/calibration/SVDCrossTalkStripsCalibrations.h>
11
12#include <TH1F.h>
13
14#include <iostream>
15
16using namespace Belle2;
17
19 CalibrationAlgorithm("SVDCrossTalkCalibrationsCollector")
20{
21 setDescription("Calibration algorithm for SVDCrossTalkCalibrations payload");
22 m_id = str;
23}
24
26{
27 int isCrossTalkCal = 0;
28 auto payload = new Belle2::SVDCrossTalkStripsCalibrations::t_payload(isCrossTalkCal, m_id);
29
30 auto tree = getObjectPtr<TTree>("HTreeCrossTalkCalib");
31
32 TH1F* hist = new TH1F("", "", 768, 0, 768);
33
34 if (!tree) {
35 B2WARNING("No tree");
36 } else if (!tree->GetEntries()) {
37 B2WARNING("Empty tree");
38 }
39
40 int layer = 0;
41 int ladder = 0;
42 int sensor = 0;
43 int side = 0;
44
45 tree->SetBranchAddress("hist", &hist);
46 tree->SetBranchAddress("layer", &layer);
47 tree->SetBranchAddress("ladder", &ladder);
48 tree->SetBranchAddress("sensor", &sensor);
49 tree->SetBranchAddress("side", &side);
50
51
52
53 for (int i = 0; i < tree->GetEntries(); i++) {
54 tree->GetEntry(i);
55
56 int nstrips = 768;
57 if (side == 0 && layer != 3) nstrips = 512;
58
59 for (int strip = 0; strip < nstrips; strip++) {
60
61 isCrossTalkCal = hist->GetBinContent(strip + 1);
62
63 if (layer == 4 && ladder == 1 && sensor == 2 && side == 1
64 && hist->GetEntries() < m_minEntries) { //Check that we have enough events populating the calibration
65 std::cout << "Not enough Data: " << hist->GetEntries() << " entries found" << std::endl;
66 return c_NotEnoughData;
67 }
68
69 payload->set(layer, ladder, sensor, side, strip, isCrossTalkCal);
70 }
71 }
72
73
74 saveCalibration(payload, "SVDCrossTalkStripsCalibrations");
75
76 return c_OK;
77
78}
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)
EResult
The result of calibration.
@ c_OK
Finished successfully =0 in Python.
@ c_NotEnoughData
Needs more data =2 in Python.
int m_minEntries
Minimum number of required entries for collector histogram L4.1.2 u-side.
SVDCrossTalkCalibrationsAlgorithm(const std::string &str)
Constructor
virtual EResult calibrate() override
Run algo on data.
SVDCalibrationsBase< SVDCalibrationsBitmap > t_payload
typedef of the SVDCrossTalkStripsCalibrations payload for all SVD strips
Abstract base class for different kinds of events.