Belle II Software  release-08-01-10
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 
22 PXDSpacePointCreatorModule::PXDSpacePointCreatorModule() :
23  Module()
24 {
26 
27  setDescription("Imports Clusters of the PXD detector and converts them to spacePoints.");
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 
45 {
46  // prepare all store- and relationArrays:
49  m_eventLevelTrackingInfo.isOptional();
50 
51 
52  //Relations to cluster objects only if the ancestor relations exist:
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:
63 }
64 
65 
66 
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 
105 }
106 
107 
108 
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 
118 {
121 }
122 
123 
124 
@ c_DontWriteOut
Object/array should be NOT saved by output modules.
Definition: DataStore.h:71
@ c_ErrorIfAlreadyRegistered
If the object/array was already registered, produce an error (aborting initialisation).
Definition: DataStore.h:72
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
Definition: DataStore.h:59
@ c_Debug
Debug: for code development.
Definition: LogConfig.h:26
static LogSystem & Instance()
Static method to get a reference to the LogSystem instance.
Definition: LogSystem.cc:31
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
The PXD Cluster class This class stores all information about reconstructed PXD clusters The position...
Definition: PXDCluster.h:30
unsigned int m_TESTERPXDClusterCtr
counts total number of PXDClusters occured
std::string m_nameOfInstance
allows the user to set an identifier for this module.
virtual void initialize() override
Init the module.
StoreObjPtr< EventLevelTrackingInfo > m_eventLevelTrackingInfo
StoreObject to access the event level tracking information.
virtual void event() override
eventWise jobs (e.g.
void InitializeCounters()
initialize variables in constructor to avoid nondeterministic behavior
unsigned int m_TESTERSpacePointCtr
counts total number of SpacePoints occured
virtual void terminate() override
final output with mini-feedback
StoreArray< SpacePoint > m_spacePoints
the storeArray for spacePoints as member, is faster than recreating link for each event
std::string m_pxdClustersName
PXDCluster collection name.
StoreArray< PXDCluster > m_pxdClusters
the storeArray for pxdClusters as member, is faster than recreating link for each event
std::string m_spacePointsName
SpacePoints collection name.
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
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
const std::string & getName() const
Return name under which the object is saved in the DataStore.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:246
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
bool registerRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut, const std::string &namedRelation="") const
Register a relation to the given StoreArray.
Definition: StoreArray.h:140
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#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.