Belle II Software development
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
22using namespace Belle2;
23using namespace ECL;
24
25//-----------------------------------------------------------------
26// Register the Module
27//-----------------------------------------------------------------
28REG_MODULE(ECLFillCellIdMapping);
29
30//-----------------------------------------------------------------
31// Implementation
32//-----------------------------------------------------------------
33
35{
36 // Set module properties
37 setDescription("Fills a dataobject that provides mapping between cell id and store arrays and neighbour maps");
39}
40
42{
43 m_eclCalDigits.isRequired();
44 m_eclCellIdMapping.registerInDataStore();
45
46 // make neighbourmap
47 m_NeighbourMap5 = new ECLNeighbours("N", 2, true); //sort them for ecl variable getters
48 m_NeighbourMap7 = new ECLNeighbours("N", 3, true); //sort them for ecl variable getters
49 m_NeighbourMap9 = new ECLNeighbours("N", 4, true); //sort them for ecl variable getters
50 m_NeighbourMap11 = new ECLNeighbours("N", 5, true); //sort them for ecl variable getters
51
52 // get phi, theta, phiid, thetaid values
57
58 // Geometry instance.
60
61 for (int idx = 1; idx <= ECLElementNumbers::c_NCrystals; idx++) {
62 B2Vector3D vectorPosition = m_geom->GetCrystalPos(idx - 1);
63
64 m_CellIdToPhi[idx] = vectorPosition.Phi();
65 m_CellIdToTheta[idx] = vectorPosition.Theta();
66
67 m_geom->Mapping(idx - 1);
70 }
71}
72
74{
75 if (!m_eclCellIdMapping) {
76 m_eclCellIdMapping.create();
77
78 for (int idx = 1; idx <= ECLElementNumbers::c_NCrystals; idx++) {
79 m_eclCellIdMapping->setCellIdToNeighbour5(idx, m_NeighbourMap5->getNeighbours(idx));
80 m_eclCellIdMapping->setCellIdToNeighbour7(idx, m_NeighbourMap7->getNeighbours(idx));
81 m_eclCellIdMapping->setCellIdToNeighbour9(idx, m_NeighbourMap9->getNeighbours(idx));
82 m_eclCellIdMapping->setCellIdToNeighbour11(idx, m_NeighbourMap11->getNeighbours(idx));
83 m_eclCellIdMapping->setCellIdToPhi(idx, m_CellIdToPhi[idx]);
84 m_eclCellIdMapping->setCellIdToTheta(idx, m_CellIdToTheta[idx]);
85 m_eclCellIdMapping->setCellIdToPhiId(idx, m_CellIdToPhiId[idx]);
86 m_eclCellIdMapping->setCellIdToThetaId(idx, m_CellIdToThetaId[idx]);
87 }
88 }
89
90 // Fill a vector that can be used to map cellid -> store array position for eclCalDigits.
91 m_eclCellIdMapping->reset();
92
93 for (int i = 0; i < m_eclCalDigits.getEntries(); i++) {
94 m_eclCellIdMapping->setCellIdToStoreArray(m_eclCalDigits[i]->getCellId(), i);
95 }
96}
97
99{
104}
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
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
const int c_NCrystals
Number of crystals.
Abstract base class for different kinds of events.