Belle II Software  release-08-01-10
EKLMAlignment.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 /* Own header. */
10 #include <klm/dbobjects/eklm/EKLMAlignment.h>
11 
12 using namespace Belle2;
13 
15 {
16 }
17 
19 {
20 }
21 
23  KLMAlignmentData* dat)
24 {
25  std::map<KLMModuleNumber, KLMAlignmentData>::iterator it;
26  it = m_ModuleAlignment.find(module);
27  if (it == m_ModuleAlignment.end()) {
28  m_ModuleAlignment.insert(
29  std::pair<KLMModuleNumber, KLMAlignmentData>(module, *dat));
30  } else {
31  it->second = *dat;
32  }
33 }
34 
36  KLMModuleNumber module) const
37 {
38  std::map<KLMModuleNumber, KLMAlignmentData>::const_iterator it;
39  it = m_ModuleAlignment.find(module);
40  if (it == m_ModuleAlignment.end())
41  return nullptr;
42  return &(it->second);
43 }
44 
45 double EKLMAlignment::getGlobalParam(unsigned short element,
46  unsigned short param) const
47 {
48  const KLMAlignmentData* alignmentData = getModuleAlignment(element);
49  if (alignmentData == nullptr)
50  return 0;
51  return alignmentData->getParameter(
52  static_cast<enum KLMAlignmentData::ParameterNumbers>(param));
53 }
54 
55 void EKLMAlignment::setGlobalParam(double value, unsigned short element,
56  unsigned short param)
57 {
58  KLMAlignmentData* alignmentData =
59  const_cast<KLMAlignmentData*>(getModuleAlignment(element));
60  /*
61  * Create alignment data if it does not exist.
62  * This is necessary for errors and corrections.
63  */
64  if (alignmentData == nullptr) {
65  KLMAlignmentData newAlignmentData(0, 0, 0, 0, 0, 0);
66  newAlignmentData.setParameter(
67  static_cast<enum KLMAlignmentData::ParameterNumbers>(param), value);
68  m_ModuleAlignment.insert(
69  std::pair<KLMModuleNumber, KLMAlignmentData>(element, newAlignmentData));
70  } else {
71  alignmentData->setParameter(
72  static_cast<enum KLMAlignmentData::ParameterNumbers>(param), value);
73  }
74 }
75 
76 /* TODO: this function is not implemented. */
77 std::vector< std::pair<unsigned short, unsigned short> >
79 {
80  return {};
81 }
std::vector< std::pair< unsigned short, unsigned short > > listGlobalParams()
Get a list of stored global parameters.
double getGlobalParam(unsigned short element, unsigned short param) const
Get global parameter.
EKLMAlignment()
Constructor.
void setModuleAlignment(KLMModuleNumber module, KLMAlignmentData *dat)
Set module alignment data.
std::map< KLMModuleNumber, KLMAlignmentData > m_ModuleAlignment
Module alignment.
Definition: EKLMAlignment.h:93
const KLMAlignmentData * getModuleAlignment(KLMModuleNumber module) const
Get module alignment data.
void setGlobalParam(double value, unsigned short element, unsigned short param)
Set global parameter.
~EKLMAlignment()
Destructor.
KLM Alignment data.
ParameterNumbers
Alignment parameter numbers.
void setParameter(enum ParameterNumbers number, float value)
Set parameter by number.
uint16_t KLMModuleNumber
Module number.
Abstract base class for different kinds of events.