Belle II Software release-09-00-00
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 std;
20using namespace Belle2;
21
23 CalibrationAlgorithm("SVDOccupancyCalibrationsCollector")
24{
25 setDescription("Calibration algorithm for SVDOccupancyCalibrations payloads");
26 m_id = str;
27}
28
30{
31
32 float occCal = 1.;
33 auto payload = new Belle2::SVDOccupancyCalibrations::t_payload(occCal, m_id);
34
35 auto tree = getObjectPtr<TTree>("HTreeOccupancyCalib");
36
37 TH1F* hocc = new TH1F("", "", 768, 0, 768);
38
39 if (!tree) {
40 B2WARNING("No tree object.");
41 } else if (!tree->GetEntries()) {
42 B2WARNING("No data in the tree.");
43 }
44
45 int layer = 0;
46 int ladder = 0;
47 int sensor = 0;
48 int side = 0;
49
50 tree->SetBranchAddress("hist", &hocc);
51 tree->SetBranchAddress("layer", &layer);
52 tree->SetBranchAddress("ladder", &ladder);
53 tree->SetBranchAddress("sensor", &sensor);
54 tree->SetBranchAddress("view", &side);
55
56 for (int i = 0; i < tree->GetEntries(); i++) {
57 tree->GetEntry(i);
58
59 int nstrips = 768;
60 if (!side && layer != 3) nstrips = 512;
61
62 for (int iterStrip = 0; iterStrip < nstrips; iterStrip++) {
63 occCal = hocc->GetBinContent(iterStrip + 1);
64
65 payload->set(layer, ladder, sensor, bool(side), iterStrip, occCal);
66 }
67 }
68
69 saveCalibration(payload, "SVDOccupancyCalibrations");
70
71 // probably not needed - would trigger re-doing the collection
72 //if ( ... too large corrections ... ) return c_Iterate;
73 return c_OK;
74
75}
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.
STL namespace.