Belle II Software  release-06-01-15
PXDSpacePointCreatorModule.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 <pxd/modules/pxdSpacePointCreator/PXDSpacePointCreatorModule.h>
10 
11 #include <framework/logging/Logger.h>
12 
13 
14 
15 
16 using namespace std;
17 using namespace Belle2;
18 
19 
20 REG_MODULE(PXDSpacePointCreator)
21 
23  Module()
24 {
25  InitializeCounters();
26 
27  setDescription("Imports Clusters of the PXD detector and converts them to spacePoints.");
28  setPropertyFlags(c_ParallelProcessingCertified);
29 
30  // 1. Collections.
31  addParam("PXDClusters", m_pxdClustersName,
32  "PXDCluster collection name", string(""));
33  addParam("SpacePoints", m_spacePointsName,
34  "SpacePoints collection name", string("PXDSpacePoints"));
35 
36  // 2.Modification parameters:
37  addParam("NameOfInstance", m_nameOfInstance,
38  "allows the user to set an identifier for this module. Usefull if one wants to use several instances of that module",
39  string("PXDSpacePoints"));
40 }
41 
42 
43 
44 void PXDSpacePointCreatorModule::initialize()
45 {
46  // prepare all store- and relationArrays:
47  m_spacePoints.registerInDataStore(m_spacePointsName, DataStore::c_DontWriteOut | DataStore::c_ErrorIfAlreadyRegistered);
48  m_pxdClusters.isRequired(m_pxdClustersName);
49  m_eventLevelTrackingInfo.isOptional();
50 
51 
52  //Relations to cluster objects only if the ancestor relations exist:
53  m_spacePoints.registerRelationTo(m_pxdClusters, DataStore::c_Event, DataStore::c_DontWriteOut);
54 
55 
56  B2DEBUG(10, "SpacePointCreatorModule(" << m_nameOfInstance << ")::initialize: names set for containers:\n" <<
57  "pxdClusters: " << m_pxdClusters.getName() <<
58  "\nspacePoints: " << m_spacePoints.getName());
59 
60 
61  // set some counters for output:
62  InitializeCounters();
63 }
64 
65 
66 
67 void PXDSpacePointCreatorModule::event()
68 {
69  // Abort in case SVDSpacePointCreator was aborted (high occupancy events)
70  // as we do not add PXD hits to CDC standalone tracks
71  if (m_eventLevelTrackingInfo.isValid()) {
72  if (m_eventLevelTrackingInfo->hasSVDSpacePointCreatorAbortionFlag()) {
73  return;
74  }
75  }
76 
77  for (unsigned int i = 0; i < uint(m_pxdClusters.getEntries()); ++i) {
78  const PXDCluster* currentCluster = m_pxdClusters[i];
79  SpacePoint* newSP = m_spacePoints.appendNew((currentCluster));
80  newSP->addRelationTo(currentCluster);
81  }
82 
83  B2DEBUG(1, "PXDSpacePointCreatorModule(" << m_nameOfInstance << ")::event: spacePoints created! Size of arrays:\n" <<
84  "pxdClusters: " << m_pxdClusters.getEntries() <<
85  ", spacePoints: " << m_spacePoints.getEntries());
86 
87 
88  if (LogSystem::Instance().isLevelEnabled(LogConfig::c_Debug, 10, PACKAGENAME()) == true) {
89  for (int index = 0; index < m_spacePoints.getEntries(); index++) {
90  const SpacePoint* sp = m_spacePoints[index];
91 
92  PXDCluster* relatedCluster = sp->getRelatedTo<PXDCluster>(m_pxdClusters.getName());
93 
94  B2DEBUG(10, "SpacePointCreatorModule(" << m_nameOfInstance << ")::event: spacePoint " << index <<
95  " with type " << sp->getType() <<
96  " and VxdID " << VxdID(sp->getVxdID()) <<
97  " is stored in Array: " << sp->getArrayName() <<
98  " and the related PXDCluster is in " << relatedCluster->getArrayName() <<
99  " with index " << relatedCluster->getArrayIndex());
100  }
101  }
102 
103  m_TESTERPXDClusterCtr += m_pxdClusters.getEntries();
104  m_TESTERSpacePointCtr += m_spacePoints.getEntries();
105 }
106 
107 
108 
109 void PXDSpacePointCreatorModule::terminate()
110 {
111  B2DEBUG(10, "PXDSpacePointCreatorModule(" << m_nameOfInstance << ")::terminate: total number of occured instances:\n" <<
112  "pxdClusters: " << m_TESTERPXDClusterCtr <<
113  ", spacePoints: " << m_TESTERSpacePointCtr);
114 }
115 
116 
117 void PXDSpacePointCreatorModule::InitializeCounters()
118 {
119  m_TESTERPXDClusterCtr = 0;
120  m_TESTERSpacePointCtr = 0;
121 }
122 
123 
124 
Base class for Modules.
Definition: Module.h:72
The PXD Cluster class This class stores all information about reconstructed PXD clusters The position...
Definition: PXDCluster.h:30
Imports Clusters of the pxd detector and converts them to spacePoints.
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
std::string getArrayName() const
Get name of array this object is stored in, or "" if not found.
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
TO * getRelatedTo(const std::string &name="", const std::string &namedRelation="") const
Get the object to which this object has a relation.
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:42
VxdID getVxdID() const
Return the VxdID of the sensor on which the the cluster of the SpacePoint lives.
Definition: SpacePoint.h:148
Belle2::VXD::SensorInfoBase::SensorType getType() const
Return SensorType (PXD, SVD, ...) on which the SpacePoint lives.
Definition: SpacePoint.h:145
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
#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.