Belle II Software development
EKLMSegmentAlignment.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/EKLMSegmentAlignment.h>
11
12using namespace Belle2;
13
15{
16}
17
19{
20}
21
24{
25 std::map<EKLMSegmentNumber, KLMAlignmentData>::iterator it;
26 it = m_SegmentAlignment.find(segment);
27 if (it == m_SegmentAlignment.end()) {
28 m_SegmentAlignment.insert(
29 std::pair<EKLMSegmentNumber, KLMAlignmentData>(segment, *dat));
30 } else
31 it->second = *dat;
32}
33
35 EKLMSegmentNumber segment) const
36{
37 std::map<EKLMSegmentNumber, KLMAlignmentData>::const_iterator it;
38 it = m_SegmentAlignment.find(segment);
39 if (it == m_SegmentAlignment.end())
40 return nullptr;
41 return &(it->second);
42}
43
44double EKLMSegmentAlignment::getGlobalParam(unsigned short element,
45 unsigned short param) const
46{
47 const KLMAlignmentData* alignmentData = getSegmentAlignment(element);
48 if (alignmentData == nullptr)
49 return 0;
50 return alignmentData->getParameter(
51 static_cast<enum KLMAlignmentData::ParameterNumbers>(param));
52}
53
54void EKLMSegmentAlignment::setGlobalParam(double value, unsigned short element,
55 unsigned short param)
56{
57 KLMAlignmentData* alignmentData =
58 const_cast<KLMAlignmentData*>(getSegmentAlignment(element));
59 /*
60 * Create alignment data if it does not exist.
61 * This is necessary for errors and corrections.
62 */
63 if (alignmentData == nullptr) {
64 KLMAlignmentData newAlignmentData(0, 0, 0, 0, 0, 0);
65 newAlignmentData.setParameter(
66 static_cast<enum KLMAlignmentData::ParameterNumbers>(param), value);
67 m_SegmentAlignment.insert(
68 std::pair<EKLMSegmentNumber, KLMAlignmentData>(element, newAlignmentData));
69 } else {
70 alignmentData->setParameter(
71 static_cast<enum KLMAlignmentData::ParameterNumbers>(param), value);
72 }
73}
74
75/* TODO: this function is not implemented. */
76std::vector< std::pair<unsigned short, unsigned short> >
78{
79 return {};
80}
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.
const KLMAlignmentData * getSegmentAlignment(EKLMSegmentNumber segment) const
Get segment alignment data.
void setSegmentAlignment(EKLMSegmentNumber segment, KLMAlignmentData *dat)
Set segment alignment data.
void setGlobalParam(double value, unsigned short element, unsigned short param)
Set global parameter.
std::map< EKLMSegmentNumber, KLMAlignmentData > m_SegmentAlignment
Segment alignment.
KLM Alignment data.
ParameterNumbers
Alignment parameter numbers.
void setParameter(enum ParameterNumbers number, float value)
Set parameter by number.
uint16_t EKLMSegmentNumber
EKLM segment number.
Abstract base class for different kinds of events.