Belle II Software light-2406-ragdoll
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 {
28
29 public:
30
35 {
36 m_pidCalibWeightDB = std::make_unique<DBObjPtr<PIDCalibrationWeight>>();
37
38 if (!(*m_pidCalibWeightDB))
39 B2FATAL("The dbobject PIDCalibrationWeight could not be found! It is necessary for the weighted PID variables.");
40 };
41
45 PIDCalibrationWeightUtil(std::string matrixName)
46 {
47 m_matrixName = matrixName;
48
49 if (m_matrixName.find("PIDDetectorWeights") != std::string::npos) {
50 m_pidDetWeightDB = std::make_unique<DBObjPtr<PIDDetectorWeights>>(m_matrixName);
51 if (!(*m_pidDetWeightDB))
52 B2FATAL("The dbobject PIDDetectorWeights, " << m_matrixName <<
53 " could not be found! It is necessary for the weighted PID variables.");
54 } else {
55 m_pidCalibWeightDB = std::make_unique<DBObjPtr<PIDCalibrationWeight>>(m_matrixName);
56 if (!(*m_pidCalibWeightDB))
57 B2FATAL("The dbobject PIDCalibrationWeight, " << m_matrixName <<
58 " could not be found! It is necessary for the weighted PID variables.");
59 }
60 };
61
65 double getWeight(int pdg, Const::EDetector det, double p, double theta) const
66 {
67 if (m_matrixName.find("PIDDetectorWeights") != std::string::npos) {
68 return (*m_pidDetWeightDB)->getWeight(Const::ParticleType(pdg), det, p, theta);
69 } else {
70 return (*m_pidCalibWeightDB)->getWeight(pdg, det);
71 }
72 }
73
74 private:
75 std::string m_matrixName = "PIDCalibrationWeight";
76 std::unique_ptr<DBObjPtr<PIDCalibrationWeight>> m_pidCalibWeightDB;
77 std::unique_ptr<DBObjPtr<PIDDetectorWeights>>
81 };
82
84} // Belle2 namespace
85
86
87
88
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 to call calibration weight matrix.
PIDCalibrationWeightUtil(std::string matrixName)
Constructor with the name of the calibration weight matrix.
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.
std::string m_matrixName
name of the matrix.
Abstract base class for different kinds of events.
Definition: ClusterUtils.h:24