Belle II Software  release-08-01-10
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 /* Own header. */
10 #include <ecl/modules/eclFillCellIdMapping/eclFillCellIdMappingModule.h>
11 
12 /* ECL headers. */
13 #include <ecl/dataobjects/ECLCalDigit.h>
14 #include <ecl/dataobjects/ECLCellIdMapping.h>
15 #include <ecl/dataobjects/ECLElementNumbers.h>
16 #include <ecl/geometry/ECLNeighbours.h>
17 #include <ecl/geometry/ECLGeometryPar.h>
18 
19 /* Basf2 headers. */
20 #include <framework/geometry/B2Vector3.h>
21 
22 using namespace Belle2;
23 using namespace ECL;
24 
25 //-----------------------------------------------------------------
26 // Register the Module
27 //-----------------------------------------------------------------
28 REG_MODULE(ECLFillCellIdMapping);
29 
30 //-----------------------------------------------------------------
31 // Implementation
32 //-----------------------------------------------------------------
33 
35 {
36  // Set module properties
37  setDescription("Fills a dataobject that provides maping between cell id and store arrays and neighbour maps");
38 }
39 
41 {
42  m_eclCalDigits.isRequired();
43  m_eclCellIdMapping.registerInDataStore();
44 
45  // make neighbourmap
46  m_NeighbourMap5 = new ECLNeighbours("N", 2, true); //sort them for ecl variable getters
47  m_NeighbourMap7 = new ECLNeighbours("N", 3, true); //sort them for ecl variable getters
48  m_NeighbourMap9 = new ECLNeighbours("N", 4, true); //sort them for ecl variable getters
49  m_NeighbourMap11 = new ECLNeighbours("N", 5, true); //sort them for ecl variable getters
50 
51  // get phi, theta, phiid, thetaid values
56 
57  // Geometry instance.
59 
60  for (int idx = 1; idx <= ECLElementNumbers::c_NCrystals; idx++) {
61  B2Vector3D vectorPosition = m_geom->GetCrystalPos(idx - 1);
62 
63  m_CellIdToPhi[idx] = vectorPosition.Phi();
64  m_CellIdToTheta[idx] = vectorPosition.Theta();
65 
66  m_geom->Mapping(idx - 1);
69  }
70 }
71 
73 {
74  if (!m_eclCellIdMapping) {
75  m_eclCellIdMapping.create();
76 
77  for (int idx = 1; idx <= ECLElementNumbers::c_NCrystals; idx++) {
78  m_eclCellIdMapping->setCellIdToNeighbour5(idx, m_NeighbourMap5->getNeighbours(idx));
79  m_eclCellIdMapping->setCellIdToNeighbour7(idx, m_NeighbourMap7->getNeighbours(idx));
80  m_eclCellIdMapping->setCellIdToNeighbour9(idx, m_NeighbourMap9->getNeighbours(idx));
81  m_eclCellIdMapping->setCellIdToNeighbour11(idx, m_NeighbourMap11->getNeighbours(idx));
82  m_eclCellIdMapping->setCellIdToPhi(idx, m_CellIdToPhi[idx]);
83  m_eclCellIdMapping->setCellIdToTheta(idx, m_CellIdToTheta[idx]);
84  m_eclCellIdMapping->setCellIdToPhiId(idx, m_CellIdToPhiId[idx]);
85  m_eclCellIdMapping->setCellIdToThetaId(idx, m_CellIdToThetaId[idx]);
86  }
87  }
88 
89  // Fill a vector that can be used to map cellid -> store array position for eclCalDigits.
90  m_eclCellIdMapping->reset();
91 
92  for (int i = 0; i < m_eclCalDigits.getEntries(); i++) {
93  m_eclCellIdMapping->setCellIdToStoreArray(m_eclCalDigits[i]->getCellId(), i);
94  }
95 }
96 
98 {
99  if (m_NeighbourMap5) delete m_NeighbourMap5;
100  if (m_NeighbourMap7) delete m_NeighbourMap7;
101  if (m_NeighbourMap9) delete m_NeighbourMap9;
103 }
DataType Phi() const
The azimuth angle.
Definition: B2Vector3.h:151
DataType Theta() const
The polar angle.
Definition: B2Vector3.h:153
std::vector< double > m_CellIdToTheta
vector (ECLElementNumbers::c_NCrystals + 1 entries) with cell id to theta values
virtual void initialize() override
Initialize.
std::vector< int > m_CellIdToThetaId
vector (ECLElementNumbers::c_NCrystals + 1 entries) with cell id to theta id values
ECL::ECLNeighbours * m_NeighbourMap5
Neighbour maps.
virtual void terminate() override
Terminate.
ECL::ECLGeometryPar * m_geom
Geometry.
std::vector< double > m_CellIdToPhi
vector (ECLElementNumbers::c_NCrystals + 1 entries) with cell id to phi values
std::vector< int > m_CellIdToPhiId
vector (ECLElementNumbers::c_NCrystals + 1 entries) with cell id to phi id values
ECLFillCellIdMappingModule()
Constructor: Sets the description, the properties and the parameters of the module.
StoreObjPtr< ECLCellIdMapping > m_eclCellIdMapping
Store object pointer: ECLCellIdToECLCalDigitMapping.
StoreArray< ECLCalDigit > m_eclCalDigits
Store array: ECLCalDigit.
static ECLGeometryPar * Instance()
Static method to get a reference to the ECLGeometryPar instance.
ROOT::Math::XYZVector GetCrystalPos(int cid)
The Position of crystal.
void Mapping(int cid)
Mapping theta, phi Id.
int GetThetaID()
Get Theta Id.
Class to get the neighbours for a given cell id.
Definition: ECLNeighbours.h:25
const std::vector< short int > & getNeighbours(short int cid) const
Return the neighbours for a given cell ID.
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
REG_MODULE(arichBtest)
Register the Module.
const int c_NCrystals
Number of crystals.
Abstract base class for different kinds of events.