Belle II Software  release-05-02-19
ECLChannelMap.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2018 - Belle II Collaboration *
4  * *
5  * DB object with ECL channel mapping *
6  * *
7  * Author: The Belle II Collaboration *
8  * Contributors: Mikhail Remnev *
9  * *
10  * This software is provided "as is" without any warranty. *
11  **************************************************************************/
12 
13 #pragma once
14 #include <TObject.h>
15 #include <framework/logging/Logger.h>
16 
17 namespace Belle2 {
22  namespace ECL {
23  enum {
24  ECL_BARREL_SHAPERS_IN_CRATE = 12,
25  ECL_FWD_SHAPERS_IN_CRATE = 10,
26  ECL_BKW_SHAPERS_IN_CRATE = 8,
27  ECL_TOTAL_SHAPERS = 576,
28  ECL_FINESSES_IN_COPPER = 2,
29  ECL_CHANNELS_IN_SHAPER = 16,
30  ECL_CRATES = 52,
31  ECL_BARREL_CRATES = 36,
32  ECL_FWD_CRATES = 8,
33  ECL_BKW_CRATES = 8,
34  ECL_COPPERS = 26,
35  ECL_BARREL_COPPERS = 18,
36  ECL_ENDCAP_COPPERS = 8,
37  ECL_TOTAL_CHANNELS = 8736,
38  ECL_BARREL_CHANNELS = 6624,
39  ECL_FWD_CHANNELS = 1152,
40  ECL_BKW_CHANNELS = 960
41  };
42  }
43 
48  class ECLChannelMap: public TObject {
49 
50  public:
51 
54 
56  const std::vector<int>& getMappingBAR() const {return m_MappingBAR;}
58  const std::vector<int>& getMappingFWD() const {return m_MappingFWD;}
60  const std::vector<int>& getMappingBWD() const {return m_MappingBWD;}
61 
63  int get(int crate, int shaper, int channel) const
64  {
65  using namespace ECL;
66 
67  int id;
68  if (crate <= ECL_BARREL_CRATES) {
69  id = (crate - 1) * ECL_BARREL_SHAPERS_IN_CRATE * ECL_CHANNELS_IN_SHAPER
70  + (shaper - 1) * ECL_CHANNELS_IN_SHAPER + (channel - 1);
71  return m_MappingBAR[id];
72  }
73  crate -= ECL_BARREL_CRATES;
74 
75  if (crate <= ECL_FWD_CRATES) {
76  id = (crate - 1) * ECL_FWD_SHAPERS_IN_CRATE * ECL_CHANNELS_IN_SHAPER
77  + (shaper - 1) * ECL_CHANNELS_IN_SHAPER + (channel - 1);
78  return m_MappingFWD[id];
79  }
80  crate -= ECL_FWD_CRATES;
81 
82  if (crate <= ECL_BKW_CRATES) {
83  id = (crate - 1) * ECL_BKW_SHAPERS_IN_CRATE * ECL_CHANNELS_IN_SHAPER
84  + (shaper - 1) * ECL_CHANNELS_IN_SHAPER + (channel - 1);
85  return m_MappingBWD[id];
86  }
87 
88  return -1;
89  }
90 
97  void setMappingVectors(const std::vector<int>& mappingBAR,
98  const std::vector<int>& mappingFWD,
99  const std::vector<int>& mappingBWD)
100  {
101  using namespace ECL;
102  //== Determine correct vector sizes from ECL-related constants
103  const unsigned int mappingBAR_size = ECL_BARREL_CRATES * ECL_BARREL_SHAPERS_IN_CRATE * ECL_CHANNELS_IN_SHAPER;
104  const unsigned int mappingFWD_size = ECL_FWD_CRATES * ECL_FWD_SHAPERS_IN_CRATE * ECL_CHANNELS_IN_SHAPER;
105  const unsigned int mappingBWD_size = ECL_BKW_CRATES * ECL_BKW_SHAPERS_IN_CRATE * ECL_CHANNELS_IN_SHAPER;
106  //== Compare given vector sizes with the correct ones
107  if (mappingBAR.size() != mappingBAR_size ||
108  mappingFWD.size() != mappingFWD_size ||
109  mappingBWD.size() != mappingBWD_size) {
110  B2FATAL("ECLChannelMap: wrong sizes for mapping vectors. Got ("
111  << mappingBAR.size() << ","
112  << mappingFWD.size() << ","
113  << mappingBWD.size() << "), "
114  << "Expected ("
115  << mappingBAR_size << ","
116  << mappingFWD_size << ","
117  << mappingBWD_size << ")");
118  }
119  //==
120  m_MappingBAR = mappingBAR;
121  m_MappingFWD = mappingFWD;
122  m_MappingBWD = mappingBWD;
123  };
124 
125  private:
126  std::vector<int> m_MappingBAR;
127  std::vector<int> m_MappingFWD;
128  std::vector<int> m_MappingBWD;
130  ClassDef(ECLChannelMap, 1);
131  };
133 }
134 
Belle2::ECLChannelMap::ECLChannelMap
ECLChannelMap()
Constructor.
Definition: ECLChannelMap.h:63
Belle2::ECLChannelMap::getMappingFWD
const std::vector< int > & getMappingFWD() const
Get vector of map entries for ECL forward endcap.
Definition: ECLChannelMap.h:68
Belle2::ECLChannelMap::setMappingVectors
void setMappingVectors(const std::vector< int > &mappingBAR, const std::vector< int > &mappingFWD, const std::vector< int > &mappingBWD)
Set three vectors of map entries.
Definition: ECLChannelMap.h:107
Belle2::ECLChannelMap::get
int get(int crate, int shaper, int channel) const
Get value for specific (crate, shaper, channel)
Definition: ECLChannelMap.h:73
Belle2::ECLChannelMap::getMappingBWD
const std::vector< int > & getMappingBWD() const
Get vector of map entries for ECL backward endcap.
Definition: ECLChannelMap.h:70
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::ECLChannelMap::m_MappingFWD
std::vector< int > m_MappingFWD
Map entries for ECL forward endcap.
Definition: ECLChannelMap.h:137
Belle2::ECLChannelMap::ClassDef
ClassDef(ECLChannelMap, 1)
ClassDef.
Belle2::ECLChannelMap::m_MappingBWD
std::vector< int > m_MappingBWD
Map entries for ECL backward endcap.
Definition: ECLChannelMap.h:138
Belle2::ECLChannelMap::m_MappingBAR
std::vector< int > m_MappingBAR
Map entries for ECL barrel.
Definition: ECLChannelMap.h:133
Belle2::ECLChannelMap::getMappingBAR
const std::vector< int > & getMappingBAR() const
Get vector of map entries for ECL barrel.
Definition: ECLChannelMap.h:66