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