Belle II Software development
FrontEndMapper.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 <top/dbobjects/TOPFrontEndMap.h>
12#include <framework/gearbox/GearDir.h>
13#include <framework/database/DBArray.h>
14#include <framework/database/IntervalOfValidity.h>
15
16#include <map>
17#include <unordered_set>
18
19
20namespace Belle2 {
25 namespace TOP {
26
32
33 public:
34
39
44 void initialize(const GearDir& frontEndMapping);
45
49 void initialize();
50
55 bool isValid() const {return m_valid;}
56
61 void importPayload(const IntervalOfValidity& iov) const;
62
69 const TOPFrontEndMap* getMap(int moduleID, int bs) const
70 {
71 moduleID--;
72 if (moduleID >= 0 and moduleID < c_numModules and bs >= 0 and bs < c_numColumns)
73 return m_fromModule[moduleID][bs];
74 return 0;
75 }
76
82 const TOPFrontEndMap* getMap(unsigned short scrodID) const
83 {
84 std::map<unsigned short, const TOPFrontEndMap*>::const_iterator it =
85 m_fromScrod.find(scrodID);
86 if (it == m_fromScrod.end()) return 0;
87 return it->second;
88 }
89
96 const TOPFrontEndMap* getMapFromCopper(unsigned copperID, int finesse) const
97 {
98 std::map<unsigned int, const TOPFrontEndMap*>::const_iterator it =
99 m_fromCopper.find(copperID * 4 + finesse);
100 if (it == m_fromCopper.end()) return 0;
101 return it->second;
102 }
103
108 int getMapSize() const
109 {
110 if (m_fromDB) {
111 return m_mappingDB.getEntries();
112 } else {
113 return m_mapping.size();
114 }
115 }
116
121 const std::unordered_set<unsigned int>& getCopperIDs() const
122 {
123 return m_copperIDs;
124 }
125
131 int getModuleCNumber(int moduleID) const
132 {
133 for (int bs = 0; bs < c_numColumns; bs++) {
134 const auto* map = getMap(moduleID, bs);
135 if (map) return map->getModuleCNumber();
136 }
137 return 0;
138 }
139
143 void print() const;
144
145 private:
146
151 enum {c_numModules = 16, c_numColumns = 4};
152
156 void clear();
157
161 void update();
162
163 std::vector<TOPFrontEndMap> m_mapping;
165 bool m_valid = false;
166 bool m_fromDB = false;
167
168 std::unordered_set<unsigned int> m_copperIDs;
169 const TOPFrontEndMap* m_fromModule[c_numModules][c_numColumns] = {{0}};
170 std::map<unsigned short, const TOPFrontEndMap*> m_fromScrod;
171 std::map<unsigned int, const TOPFrontEndMap*> m_fromCopper;
172
173 };
174
175 } // TOP namespace
177} // Belle2 namespace
178
Class for accessing arrays of objects in the database.
Definition DBArray.h:26
GearDir is the basic class used for accessing the parameter store.
Definition GearDir.h:31
A class that describes the interval of experiments/runs for which an object in the database is valid.
Mapping of a boardstack number within a module to SCROD and COPPER/Finesse.
DBArray< TOPFrontEndMap > m_mappingDB
mappings from database
void initialize()
Initialize from database.
bool m_fromDB
true, if from database
const TOPFrontEndMap * m_fromModule[c_numModules][c_numColumns]
conversion
const TOPFrontEndMap * getMap(int moduleID, int bs) const
Return map from TOP module side.
bool isValid() const
check if the mapping is available
bool m_valid
true, if mapping available
int getMapSize() const
Return size of the map.
std::unordered_set< unsigned int > m_copperIDs
COPPER ID's.
const TOPFrontEndMap * getMapFromCopper(unsigned copperID, int finesse) const
Return map from COPPER/Finesse side.
std::map< unsigned int, const TOPFrontEndMap * > m_fromCopper
conversion
const std::unordered_set< unsigned int > & getCopperIDs() const
Return a set of copper ID's.
const TOPFrontEndMap * getMap(unsigned short scrodID) const
Return map from SCROD side.
std::map< unsigned short, const TOPFrontEndMap * > m_fromScrod
conversion
int getModuleCNumber(int moduleID) const
Returns module construction number.
void update()
re-do conversion maps when DBArray has changed
void importPayload(const IntervalOfValidity &iov) const
import mappings to database
void print() const
Print mappings to terminal screen.
std::vector< TOPFrontEndMap > m_mapping
mappings from gearbox
STL class.
Abstract base class for different kinds of events.