Belle II Software  release-06-01-15
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 #include <TObject.h>
11 #include <framework/logging/Logger.h>
12 
13 namespace Belle2 {
18  namespace ECL {
19  enum {
20  ECL_BARREL_SHAPERS_IN_CRATE = 12,
21  ECL_FWD_SHAPERS_IN_CRATE = 10,
22  ECL_BKW_SHAPERS_IN_CRATE = 8,
23  ECL_TOTAL_SHAPERS = 576,
24  ECL_FINESSES_IN_COPPER = 2,
25  ECL_CHANNELS_IN_SHAPER = 16,
26  ECL_CRATES = 52,
27  ECL_BARREL_CRATES = 36,
28  ECL_FWD_CRATES = 8,
29  ECL_BKW_CRATES = 8,
30  ECL_COPPERS = 26,
31  ECL_BARREL_COPPERS = 18,
32  ECL_ENDCAP_COPPERS = 8,
33  ECL_TOTAL_CHANNELS = 8736,
34  ECL_BARREL_CHANNELS = 6624,
35  ECL_FWD_CHANNELS = 1152,
36  ECL_BKW_CHANNELS = 960
37  };
38  }
39 
44  class ECLChannelMap: public TObject {
45 
46  public:
47 
50 
52  const std::vector<int>& getMappingBAR() const {return m_MappingBAR;}
54  const std::vector<int>& getMappingFWD() const {return m_MappingFWD;}
56  const std::vector<int>& getMappingBWD() const {return m_MappingBWD;}
57 
59  int get(int crate, int shaper, int channel) const
60  {
61  using namespace ECL;
62 
63  int id;
64  if (crate <= ECL_BARREL_CRATES) {
65  id = (crate - 1) * ECL_BARREL_SHAPERS_IN_CRATE * ECL_CHANNELS_IN_SHAPER
66  + (shaper - 1) * ECL_CHANNELS_IN_SHAPER + (channel - 1);
67  return m_MappingBAR[id];
68  }
69  crate -= ECL_BARREL_CRATES;
70 
71  if (crate <= ECL_FWD_CRATES) {
72  id = (crate - 1) * ECL_FWD_SHAPERS_IN_CRATE * ECL_CHANNELS_IN_SHAPER
73  + (shaper - 1) * ECL_CHANNELS_IN_SHAPER + (channel - 1);
74  return m_MappingFWD[id];
75  }
76  crate -= ECL_FWD_CRATES;
77 
78  if (crate <= ECL_BKW_CRATES) {
79  id = (crate - 1) * ECL_BKW_SHAPERS_IN_CRATE * ECL_CHANNELS_IN_SHAPER
80  + (shaper - 1) * ECL_CHANNELS_IN_SHAPER + (channel - 1);
81  return m_MappingBWD[id];
82  }
83 
84  return -1;
85  }
86 
93  void setMappingVectors(const std::vector<int>& mappingBAR,
94  const std::vector<int>& mappingFWD,
95  const std::vector<int>& mappingBWD)
96  {
97  using namespace ECL;
98  //== Determine correct vector sizes from ECL-related constants
99  const unsigned int mappingBAR_size = ECL_BARREL_CRATES * ECL_BARREL_SHAPERS_IN_CRATE * ECL_CHANNELS_IN_SHAPER;
100  const unsigned int mappingFWD_size = ECL_FWD_CRATES * ECL_FWD_SHAPERS_IN_CRATE * ECL_CHANNELS_IN_SHAPER;
101  const unsigned int mappingBWD_size = ECL_BKW_CRATES * ECL_BKW_SHAPERS_IN_CRATE * ECL_CHANNELS_IN_SHAPER;
102  //== Compare given vector sizes with the correct ones
103  if (mappingBAR.size() != mappingBAR_size ||
104  mappingFWD.size() != mappingFWD_size ||
105  mappingBWD.size() != mappingBWD_size) {
106  B2FATAL("ECLChannelMap: wrong sizes for mapping vectors. Got ("
107  << mappingBAR.size() << ","
108  << mappingFWD.size() << ","
109  << mappingBWD.size() << "), "
110  << "Expected ("
111  << mappingBAR_size << ","
112  << mappingFWD_size << ","
113  << mappingBWD_size << ")");
114  }
115  //==
116  m_MappingBAR = mappingBAR;
117  m_MappingFWD = mappingFWD;
118  m_MappingBWD = mappingBWD;
119  };
120 
121  private:
122  std::vector<int> m_MappingBAR;
123  std::vector<int> m_MappingFWD;
124  std::vector<int> m_MappingBWD;
127  };
129 }
130 
DB object to store correspondence table of type (Crate id, ShaperDSP id, Channel id) <-> (ECL CellID)
Definition: ECLChannelMap.h:44
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:59
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:93
ECLChannelMap()
Constructor.
Definition: ECLChannelMap.h:49
ClassDef(ECLChannelMap, 1)
ClassDef.
const std::vector< int > & getMappingBAR() const
Get vector of map entries for ECL barrel.
Definition: ECLChannelMap.h:52
const std::vector< int > & getMappingBWD() const
Get vector of map entries for ECL backward endcap.
Definition: ECLChannelMap.h:56
const std::vector< int > & getMappingFWD() const
Get vector of map entries for ECL forward endcap.
Definition: ECLChannelMap.h:54
std::vector< int > m_MappingFWD
Map entries for ECL forward endcap.
std::vector< int > m_MappingBAR
Map entries for ECL barrel.
Abstract base class for different kinds of events.