Belle II Software  release-06-01-15
eclFillCellIdMappingModule.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 #include <ecl/modules/eclFillCellIdMapping/eclFillCellIdMappingModule.h>
10 
11 #include <ecl/dataobjects/ECLCellIdMapping.h>
12 #include <ecl/dataobjects/ECLCalDigit.h>
13 
14 #include <ecl/geometry/ECLNeighbours.h>
15 #include <ecl/geometry/ECLGeometryPar.h>
16 
17 #include <framework/geometry/B2Vector3.h>
18 
19 using namespace Belle2;
20 using namespace ECL;
21 
22 //-----------------------------------------------------------------
23 // Register the Module
24 //-----------------------------------------------------------------
25 REG_MODULE(ECLFillCellIdMapping)
26 
27 //-----------------------------------------------------------------
28 // Implementation
29 //-----------------------------------------------------------------
30 
32 {
33  // Set module properties
34  setDescription("Fills a dataobject that provides maping between cell id and store arrays and neighbour maps");
35 }
36 
38 {
39  m_eclCalDigits.isRequired();
40  m_eclCellIdMapping.registerInDataStore();
41 
42  // make neighbourmap
43  m_NeighbourMap5 = new ECLNeighbours("N", 2);
44  m_NeighbourMap7 = new ECLNeighbours("N", 3);
45 
46  // get phi, theta, phiid, thetaid values
47  m_CellIdToPhi.resize(Belle2::ECLCellIdMapping::c_nECLCellIds + 1);
48  m_CellIdToTheta.resize(Belle2::ECLCellIdMapping::c_nECLCellIds + 1);
49  m_CellIdToPhiId.resize(Belle2::ECLCellIdMapping::c_nECLCellIds + 1);
50  m_CellIdToThetaId.resize(Belle2::ECLCellIdMapping::c_nECLCellIds + 1);
51 
52  // Geometry instance.
53  m_geom = ECLGeometryPar::Instance();
54 
55  for (int idx = 1; idx <= Belle2::ECLCellIdMapping::c_nECLCellIds; idx++) {
56  B2Vector3D vectorPosition = m_geom->GetCrystalPos(idx - 1);
57 
58  m_CellIdToPhi[idx] = vectorPosition.Phi();
59  m_CellIdToTheta[idx] = vectorPosition.Theta();
60 
61  m_geom->Mapping(idx - 1);
62  m_CellIdToPhiId[idx] = m_geom->GetPhiID();
63  m_CellIdToThetaId[idx] = m_geom->GetThetaID();
64  }
65 }
66 
68 {
69  if (!m_eclCellIdMapping) {
70  m_eclCellIdMapping.create();
71  }
72 
73  for (int idx = 1; idx <= Belle2::ECLCellIdMapping::c_nECLCellIds; idx++) {
74  m_eclCellIdMapping->setCellIdToNeighbour5(idx, m_NeighbourMap5->getNeighbours(idx));
75  m_eclCellIdMapping->setCellIdToNeighbour7(idx, m_NeighbourMap7->getNeighbours(idx));
76  m_eclCellIdMapping->setCellIdToPhi(idx, m_CellIdToPhi[idx]);
77  m_eclCellIdMapping->setCellIdToTheta(idx, m_CellIdToTheta[idx]);
78  m_eclCellIdMapping->setCellIdToPhiId(idx, m_CellIdToPhiId[idx]);
79  m_eclCellIdMapping->setCellIdToThetaId(idx, m_CellIdToThetaId[idx]);
80  }
81 
82  // Fill a vector that can be used to map cellid -> store array position for eclCalDigits.
83  m_eclCellIdMapping->reset();
84 
85  for (int i = 0; i < m_eclCalDigits.getEntries(); i++) {
86  m_eclCellIdMapping->setCellIdToStoreArray(m_eclCalDigits[i]->getCellId(), i);
87  }
88 }
89 
91 {
92  if (m_NeighbourMap5) delete m_NeighbourMap5;
93  if (m_NeighbourMap7) delete m_NeighbourMap7;
94 }
DataType Phi() const
The azimuth angle.
Definition: B2Vector3.h:136
DataType Theta() const
The polar angle.
Definition: B2Vector3.h:138
static constexpr int c_nECLCellIds
Number of ECL CellId.
Fills a dataobject that provides maping between cell id and ECLCalDigit store array.
virtual void initialize() override
Initialize.
virtual void terminate() override
Terminate.
static ECLGeometryPar * Instance()
Static method to get a reference to the ECLGeometryPar instance.
Class to get the neighbours for a given cell id.
Definition: ECLNeighbours.h:23
Base class for Modules.
Definition: Module.h:72
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.