Belle II Software development
PIDCalibrationWeightUtil.h
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#pragma once
10
11#include <analysis/dbobjects/PIDCalibrationWeight.h>
12#include <analysis/dbobjects/PIDDetectorWeights.h>
13#include <framework/database/DBObjPtr.h>
14#include <framework/logging/Logger.h>
15
16#include <framework/gearbox/Const.h>
17
18namespace Belle2 {
23
28
29 public:
30
36 {
37 if (!(*m_pidCalibWeightDB))
38 B2FATAL("The dbobject PIDCalibrationWeight could not be found! It is necessary for the weighted PID variables.");
39 };
40
44 explicit PIDCalibrationWeightUtil(const std::string& matrixName)
45 : m_matrixName(matrixName)
46 {
47 if (m_matrixName.find("PIDDetectorWeights") != std::string::npos) {
48 m_pidDetWeightDB = std::make_unique<DBObjPtr<PIDDetectorWeights>>(m_matrixName);
49 if (!(*m_pidDetWeightDB))
50 B2FATAL("The dbobject PIDDetectorWeights, " << m_matrixName <<
51 " could not be found! It is necessary for the weighted PID variables.");
52 } else {
53 m_pidCalibWeightDB = std::make_unique<DBObjPtr<PIDCalibrationWeight>>(m_matrixName);
54 if (!(*m_pidCalibWeightDB))
55 B2FATAL("The dbobject PIDCalibrationWeight, " << m_matrixName <<
56 " could not be found! It is necessary for the weighted PID variables.");
57 }
58 };
59
63 double getWeight(int pdg, Const::EDetector det, double p, double theta) const
64 {
65 if (m_matrixName.find("PIDDetectorWeights") != std::string::npos) {
66 return (*m_pidDetWeightDB)->getWeight(Const::ParticleType(pdg), det, p, theta);
67 } else {
68 return (*m_pidCalibWeightDB)->getWeight(pdg, det);
69 }
70 }
71
72 private:
73 std::string m_matrixName = "PIDCalibrationWeight";
74 std::unique_ptr<DBObjPtr<PIDCalibrationWeight>> m_pidCalibWeightDB;
75 std::unique_ptr<DBObjPtr<PIDDetectorWeights>>
77
78
79 };
80
82} // Belle2 namespace
83
84
85
86
The ParticleType class for identifying different particle types.
Definition Const.h:408
EDetector
Enum for identifying the detector components (detector and subdetector).
Definition Const.h:42
Class for accessing objects in the database.
Definition DBObjPtr.h:21
std::unique_ptr< DBObjPtr< PIDCalibrationWeight > > m_pidCalibWeightDB
db object for the calibration weight matrix.
double getWeight(int pdg, Const::EDetector det, double p, double theta) const
Get the weight for the given combination of the PDG code and the detector in Const::EDetector.
std::unique_ptr< DBObjPtr< PIDDetectorWeights > > m_pidDetWeightDB
db object for the detector weight matrix for momentum and theta dependent matrix.
PIDCalibrationWeightUtil(const std::string &matrixName)
Constructor with the name of the calibration weight matrix.
std::string m_matrixName
name of the matrix.
Class for handling the PID calibration weight matrix.
Abstract base class for different kinds of events.
STL namespace.