Belle II Software development
SVDOccupancyCalibrationsAlgorithm.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/SVDOccupancyCalibrationsAlgorithm.h>
9
10#include <svd/calibration/SVDOccupancyCalibrations.h>
11
12#include <framework/logging/Logger.h>
13
14#include <TH1F.h>
15#include <TString.h>
16
17#include <iostream>
18
19using namespace Belle2;
20
22 CalibrationAlgorithm("SVDOccupancyCalibrationsCollector")
23{
24 setDescription("Calibration algorithm for SVDOccupancyCalibrations payloads");
25 m_id = str;
26}
27
29{
30
31 float occCal = 1.;
32 auto payload = new Belle2::SVDOccupancyCalibrations::t_payload(occCal, m_id);
33
34 auto tree = getObjectPtr<TTree>("HTreeOccupancyCalib");
35
36 TH1F* hocc = new TH1F("", "", 768, 0, 768);
37
38 if (!tree) {
39 B2WARNING("No tree object.");
40 } else if (!tree->GetEntries()) {
41 B2WARNING("No data in the tree.");
42 }
43
44 int layer = 0;
45 int ladder = 0;
46 int sensor = 0;
47 int side = 0;
48
49 tree->SetBranchAddress("hist", &hocc);
50 tree->SetBranchAddress("layer", &layer);
51 tree->SetBranchAddress("ladder", &ladder);
52 tree->SetBranchAddress("sensor", &sensor);
53 tree->SetBranchAddress("view", &side);
54
55 for (int i = 0; i < tree->GetEntries(); i++) {
56 tree->GetEntry(i);
57
58 int nstrips = 768;
59 if (!side && layer != 3) nstrips = 512;
60
61 for (int iterStrip = 0; iterStrip < nstrips; iterStrip++) {
62 occCal = hocc->GetBinContent(iterStrip + 1);
63
64 payload->set(layer, ladder, sensor, bool(side), iterStrip, occCal);
65 }
66 }
67
68 saveCalibration(payload, "SVDOccupancyCalibrations");
69
70 // probably not needed - would trigger re-doing the collection
71 //if ( ... too large corrections ... ) return c_Iterate;
72 return c_OK;
73
74}
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 successfuly =0 in Python.
virtual EResult calibrate() override
Run algo on data.
SVDOccupancyCalibrationsAlgorithm(const std::string &str)
Constructor set the prefix to SVDOccupancyCalibrationsCollector.
SVDCalibrationsBase< SVDCalibrationsVector< float > > t_payload
typedef of the Occupancy payload of all SVD strips
Abstract base class for different kinds of events.