Belle II Software development
ECLChannelMap.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/* ECL headers. */
12#include <ecl/dataobjects/ECLElementNumbers.h>
13
14/* Basf2 headers. */
15#include <framework/logging/Logger.h>
16
17/* ROT headers. */
18#include <TObject.h>
19
20namespace Belle2 {
25 namespace ECL {
26 enum {
27 ECL_BARREL_SHAPERS_IN_CRATE = 12,
28 ECL_FWD_SHAPERS_IN_CRATE = 10,
29 ECL_BKW_SHAPERS_IN_CRATE = 8,
30 ECL_TOTAL_SHAPERS = 576,
31 ECL_FINESSES_IN_COPPER = 2,
32 ECL_CHANNELS_IN_SHAPER = 16,
33 ECL_CRATES = 52,
34 ECL_BARREL_CRATES = 36,
35 ECL_FWD_CRATES = 8,
36 ECL_BKW_CRATES = 8,
37 ECL_COPPERS = 26,
38 ECL_BARREL_COPPERS = 18,
39 ECL_ENDCAP_COPPERS = 8,
40 ECL_TOTAL_CHANNELS = ECLElementNumbers::c_NCrystals,
41 ECL_BARREL_CHANNELS = ECLElementNumbers::c_NCrystalsBarrel,
44 };
45 }
46
51 class ECLChannelMap: public TObject {
52
53 public:
54
57
59 const std::vector<int>& getMappingBAR() const {return m_MappingBAR;}
61 const std::vector<int>& getMappingFWD() const {return m_MappingFWD;}
63 const std::vector<int>& getMappingBWD() const {return m_MappingBWD;}
64
66 int get(int crate, int shaper, int channel) const
67 {
68 using namespace ECL;
69
70 int id;
71 if (crate <= ECL_BARREL_CRATES) {
72 id = (crate - 1) * ECL_BARREL_SHAPERS_IN_CRATE * ECL_CHANNELS_IN_SHAPER
73 + (shaper - 1) * ECL_CHANNELS_IN_SHAPER + (channel - 1);
74 return m_MappingBAR[id];
75 }
76 crate -= ECL_BARREL_CRATES;
77
78 if (crate <= ECL_FWD_CRATES) {
79 id = (crate - 1) * ECL_FWD_SHAPERS_IN_CRATE * ECL_CHANNELS_IN_SHAPER
80 + (shaper - 1) * ECL_CHANNELS_IN_SHAPER + (channel - 1);
81 return m_MappingFWD[id];
82 }
83 crate -= ECL_FWD_CRATES;
84
85 if (crate <= ECL_BKW_CRATES) {
86 id = (crate - 1) * ECL_BKW_SHAPERS_IN_CRATE * ECL_CHANNELS_IN_SHAPER
87 + (shaper - 1) * ECL_CHANNELS_IN_SHAPER + (channel - 1);
88 return m_MappingBWD[id];
89 }
90
91 return -1;
92 }
93
100 void setMappingVectors(const std::vector<int>& mappingBAR,
101 const std::vector<int>& mappingFWD,
102 const std::vector<int>& mappingBWD)
103 {
104 using namespace ECL;
105 //== Determine correct vector sizes from ECL-related constants
106 const unsigned int mappingBAR_size = ECL_BARREL_CRATES * ECL_BARREL_SHAPERS_IN_CRATE * ECL_CHANNELS_IN_SHAPER;
107 const unsigned int mappingFWD_size = ECL_FWD_CRATES * ECL_FWD_SHAPERS_IN_CRATE * ECL_CHANNELS_IN_SHAPER;
108 const unsigned int mappingBWD_size = ECL_BKW_CRATES * ECL_BKW_SHAPERS_IN_CRATE * ECL_CHANNELS_IN_SHAPER;
109 //== Compare given vector sizes with the correct ones
110 if (mappingBAR.size() != mappingBAR_size ||
111 mappingFWD.size() != mappingFWD_size ||
112 mappingBWD.size() != mappingBWD_size) {
113 B2FATAL("ECLChannelMap: wrong sizes for mapping vectors. Got ("
114 << mappingBAR.size() << ","
115 << mappingFWD.size() << ","
116 << mappingBWD.size() << "), "
117 << "Expected ("
118 << mappingBAR_size << ","
119 << mappingFWD_size << ","
120 << mappingBWD_size << ")");
121 }
122 //==
123 m_MappingBAR = mappingBAR;
124 m_MappingFWD = mappingFWD;
125 m_MappingBWD = mappingBWD;
126 };
127
128 private:
129 std::vector<int> m_MappingBAR;
130 std::vector<int> m_MappingFWD;
131 std::vector<int> m_MappingBWD;
134 };
136}
137
DB object to store correspondence table of type (Crate id, ShaperDSP id, Channel id) <-> (ECL CellID)
Definition: ECLChannelMap.h:51
std::vector< int > m_MappingBWD
Map entries for ECL backward endcap.
int get(int crate, int shaper, int channel) const
Get value for specific (crate, shaper, channel)
Definition: ECLChannelMap.h:66
const std::vector< int > & getMappingBWD() const
Get vector of map entries for ECL backward endcap.
Definition: ECLChannelMap.h:63
const std::vector< int > & getMappingFWD() const
Get vector of map entries for ECL forward endcap.
Definition: ECLChannelMap.h:61
void setMappingVectors(const std::vector< int > &mappingBAR, const std::vector< int > &mappingFWD, const std::vector< int > &mappingBWD)
Set three vectors of map entries.
ECLChannelMap()
Constructor.
Definition: ECLChannelMap.h:56
ClassDef(ECLChannelMap, 1)
ClassDef.
const std::vector< int > & getMappingBAR() const
Get vector of map entries for ECL barrel.
Definition: ECLChannelMap.h:59
std::vector< int > m_MappingFWD
Map entries for ECL forward endcap.
std::vector< int > m_MappingBAR
Map entries for ECL barrel.
const int c_NCrystals
Number of crystals.
const int c_NCrystalsBackward
Number of crystals in the backward ECL.
const int c_NCrystalsBarrel
Number of crystals in the barrel ECL.
const int c_NCrystalsForward
Number of crystals in the forward ECL.
Abstract base class for different kinds of events.