Belle II Software development
SpacePoint2TrueHitConnectorModule Class Reference

Module that tries to register a relation between SpacePoints and TrueHits, hence making some MC Information easily accessible for other modules working with SpacePoints (e.g. More...

#include <SpacePoint2TrueHitConnectorModule.h>

Inheritance diagram for SpacePoint2TrueHitConnectorModule:
Module PathElement

Classes

struct  RootVariables
 helper struct to access root variables inside the module More...
 

Public Types

enum  EModulePropFlags {
  c_Input = 1 ,
  c_Output = 2 ,
  c_ParallelProcessingCertified = 4 ,
  c_HistogramManager = 8 ,
  c_InternalSerializer = 16 ,
  c_TerminateInAllProcesses = 32 ,
  c_DontCollectStatistics = 64
}
 Each module can be tagged with property flags, which indicate certain features of the module. More...
 
typedef ModuleCondition::EAfterConditionPath EAfterConditionPath
 Forward the EAfterConditionPath definition from the ModuleCondition.
 

Public Member Functions

 SpacePoint2TrueHitConnectorModule ()
 Constructor.
 
void initialize () override
 initialize: initialize counters, check StoreArrays, register StoreArrays, ...
 
void event () override
 event: try to find the appropriate TrueHit to all SpacePoints
 
void terminate () override
 terminate: print some summary information
 
 BELLE2_DEFINE_EXCEPTION (NoClusterToSpacePoint, "Found no related Cluster for a SpacePoint!")
 Exception for when no related Cluster can be found for a SpacePoint.
 
virtual std::vector< std::string > getFileNames (bool outputFiles)
 Return a list of output filenames for this modules.
 
virtual void beginRun ()
 Called when entering a new run.
 
virtual void endRun ()
 This method is called if the current run ends.
 
const std::string & getName () const
 Returns the name of the module.
 
const std::string & getType () const
 Returns the type of the module (i.e.
 
const std::string & getPackage () const
 Returns the package this module is in.
 
const std::string & getDescription () const
 Returns the description of the module.
 
void setName (const std::string &name)
 Set the name of the module.
 
void setPropertyFlags (unsigned int propertyFlags)
 Sets the flags for the module properties.
 
LogConfiggetLogConfig ()
 Returns the log system configuration.
 
void setLogConfig (const LogConfig &logConfig)
 Set the log system configuration.
 
void setLogLevel (int logLevel)
 Configure the log level.
 
void setDebugLevel (int debugLevel)
 Configure the debug messaging level.
 
void setAbortLevel (int abortLevel)
 Configure the abort log level.
 
void setLogInfo (int logLevel, unsigned int logInfo)
 Configure the printed log information for the given level.
 
void if_value (const std::string &expression, const std::shared_ptr< Path > &path, EAfterConditionPath afterConditionPath=EAfterConditionPath::c_End)
 Add a condition to the module.
 
void if_false (const std::shared_ptr< Path > &path, EAfterConditionPath afterConditionPath=EAfterConditionPath::c_End)
 A simplified version to add a condition to the module.
 
void if_true (const std::shared_ptr< Path > &path, EAfterConditionPath afterConditionPath=EAfterConditionPath::c_End)
 A simplified version to set the condition of the module.
 
bool hasCondition () const
 Returns true if at least one condition was set for the module.
 
const ModuleConditiongetCondition () const
 Return a pointer to the first condition (or nullptr, if none was set)
 
const std::vector< ModuleCondition > & getAllConditions () const
 Return all set conditions for this module.
 
bool evalCondition () const
 If at least one condition was set, it is evaluated and true returned if at least one condition returns true.
 
std::shared_ptr< PathgetConditionPath () const
 Returns the path of the last true condition (if there is at least one, else reaturn a null pointer).
 
Module::EAfterConditionPath getAfterConditionPath () const
 What to do after the conditional path is finished.
 
std::vector< std::shared_ptr< Path > > getAllConditionPaths () const
 Return all condition paths currently set (no matter if the condition is true or not).
 
bool hasProperties (unsigned int propertyFlags) const
 Returns true if all specified property flags are available in this module.
 
bool hasUnsetForcedParams () const
 Returns true and prints error message if the module has unset parameters which the user has to set in the steering file.
 
const ModuleParamListgetParamList () const
 Return module param list.
 
template<typename T >
ModuleParam< T > & getParam (const std::string &name) const
 Returns a reference to a parameter.
 
bool hasReturnValue () const
 Return true if this module has a valid return value set.
 
int getReturnValue () const
 Return the return value set by this module.
 
std::shared_ptr< PathElementclone () const override
 Create an independent copy of this module.
 
std::shared_ptr< boost::python::list > getParamInfoListPython () const
 Returns a python list of all parameters.
 

Static Public Member Functions

static void exposePythonAPI ()
 Exposes methods of the Module class to Python.
 

Protected Types

enum  e_detTypes {
  c_PXD = Belle2::VXD::SensorInfoBase::PXD ,
  c_SVD = Belle2::VXD::SensorInfoBase::SVD
}
 enum to distinguish the detectortypes More...
 
enum  e_relationStatus {
  c_clearHit = 1 ,
  c_ghostHit = 2 ,
  c_SpacePointU = 4 ,
  c_SpacePointV = 8 ,
  c_primaryParticle = 16 ,
  c_bgParticle = 32 ,
  c_nonUniqueRelation = 64 ,
  c_registeredRelation = 128 ,
  c_noiseCluster = 256
}
 enum for better code readability More...
 
typedef std::unordered_map< int, TrueHitInfobaseMapT
 typedef for shorter notation throughout the module
 

Protected Member Functions

void initializeCounters ()
 initialize all counters to 0 WARNING: only call in constructor of module!
 
template<typename MapType , typename TrueHitType >
std::pair< TrueHitType *, double > getTHwithWeight (const MapType &aMap, Belle2::StoreArray< TrueHitType > trueHits, Belle2::SpacePoint *spacePoint, e_detTypes detType)
 get the TrueHit from information that is stored in the map (conditions are checked in the following order):
 
template<typename TrueHitType >
bool compatibleCombination (Belle2::SpacePoint *spacePoint, TrueHitType *trueHit)
 compares the TrueHit and the SpacePoint positions (global) to decide whether they are compatible NOTE: if a SpacePoint and a TrueHit do not 'pass' this test they are most probably not compatible, however just because this test is passed does not guarantee that the 'right' TrueHit has been chosen before calling this function!
 
template<typename MapType , typename ClusterType , typename TrueHitType >
MapType getRelatedTrueHits (Belle2::SpacePoint *spacePoint, std::string clusterName="ALL", std::string trueHitName="ALL")
 get all the related TrueHits to the SpacePoint, including their weights in a map (multimap!) where the StoreArray indices of the TrueHits are the keys and the values are TrueHitInfos to these indices MapType has to have key value pairs of pair<int,TrueHitInfo> throws: + NoTrueHitToCluster
 
template<typename MapType >
MapType processSpacePoint (Belle2::SpacePoint *spacePoint, e_detTypes detType)
 process a SpacePoint.
 
template<typename MapType >
void registerAllRelations (Belle2::SpacePoint *spacePoint, MapType trueHitMap, e_detTypes detType)
 register a Relation to all the TrueHits in the trueHitMap for the passed SpacePoint
 
template<typename TrueHitType >
void registerOneRelation (Belle2::SpacePoint *spacePoint, std::pair< TrueHitType *, double > trueHitwWeight, e_detTypes)
 register Relation between SpacePoint and TrueHit (and if necessary also between SpacePoint and Cluster)
 
template<typename ClusterType >
void reRegisterClusterRelations (Belle2::SpacePoint *origSpacePoint, Belle2::SpacePoint *newSpacePoint, std::string clusterName="ALL")
 register all the relations to Clusters that origSpacePoint had for newSpacePoint
 
template<typename ClusterType >
std::vector< std::pair< ClusterType *, double > > getRelatedClusters (Belle2::SpacePoint *spacePoint, std::string clusterName="ALL")
 get the pointers to the related Clusters and the weight of the original Relations between the spacePoint and these Clusters
 
template<typename TrueHitType >
void registerTrueHitRelation (Belle2::SpacePoint *spacePoint, int index, double weight, Belle2::StoreArray< TrueHitType > trueHits)
 register the relation between a SpacePoint and the TrueHit (passed by index in the corresponding TrueHit Array) with the passed weight NOTE: defining a function here mainly to avoid having duplicate code for every TrueHitType
 
template<typename MapType >
void positionAnalysis (Belle2::SpacePoint *spacePoint, const MapType &trueHitMap, const int &index, e_detTypes detType)
 Analyze the position of SpacePoints and corresponding TrueHits.
 
std::pair< double, double > getLocalPos (Belle2::SpacePoint *spacePoint)
 get the local position of a SpacePoint
 
template<typename TrueHitType >
std::pair< ROOT::Math::XYZVector, ROOT::Math::XYZVector > getTrueHitPositions (TrueHitType *trueHit)
 get the local (.first) and global (.second) position of a TrueHit (passed by index)
 
void initializeRootFile ()
 initialize the root file that is used for output
 
void closeRootFile ()
 close root file
 
std::pair< unsigned short int, unsigned short int > getClusterSizes (Belle2::SpacePoint *spacePoint, e_detTypes detType)
 get the sizes of the related Clusters of a SpacePoint
 
std::pair< double, double > getLocalError (Belle2::SpacePoint *spacePoint)
 get the position error of SpacePoints in local coordinates
 
double calculateRelationWeight (const TrueHitInfo &trueHitInfo, Belle2::SpacePoint *spacePoint)
 calculate the Relation weight to be used (for SVD only, although method works with PXD as well!)
 
virtual void def_initialize ()
 Wrappers to make the methods without "def_" prefix callable from Python.
 
virtual void def_beginRun ()
 Wrapper method for the virtual function beginRun() that has the implementation to be used in a call from Python.
 
virtual void def_event ()
 Wrapper method for the virtual function event() that has the implementation to be used in a call from Python.
 
virtual void def_endRun ()
 This method can receive that the current run ends as a call from the Python side.
 
virtual void def_terminate ()
 Wrapper method for the virtual function terminate() that has the implementation to be used in a call from Python.
 
void setDescription (const std::string &description)
 Sets the description of the module.
 
void setType (const std::string &type)
 Set the module type.
 
template<typename T >
void addParam (const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
 Adds a new parameter to the module.
 
template<typename T >
void addParam (const std::string &name, T &paramVariable, const std::string &description)
 Adds a new enforced parameter to the module.
 
void setReturnValue (int value)
 Sets the return value for this module as integer.
 
void setReturnValue (bool value)
 Sets the return value for this module as bool.
 
void setParamList (const ModuleParamList &params)
 Replace existing parameter list.
 

Protected Attributes

std::string m_PARAMoutputSuffix
 suffix that will be appended to the StoreArray names of the output StoreArrays
 
std::vector< std::string > m_PARAMtrueHitNames
 names of containers of TrueHits
 
std::vector< std::string > m_PARAMspacePointNames
 names of containers of SpacePoints
 
std::vector< std::string > m_PARAMdetectorTypes
 detector type names as strings to determine which name belongs to which detector type
 
std::vector< std::string > m_PARAMclusterNames
 names of containers of Clusters
 
std::vector< std::string > m_PARAMrootFileName
 name and update status of root file
 
bool m_PARAMstoreSeparate
 switch for storing the SpacePoints that can be related to a TrueHit into separate StoreArrays, where only such SpacePoints are stored
 
bool m_PARAMregisterAll
 switch for registereing all relations for all TrueHits for all SpacePoints (there can be more than 1 related TrueHit to each SpacePoint).
 
bool m_PARAMpositionAnalysis
 switch for doing the analysis of positions of SpacePoints and TrueHits
 
bool m_PARAMrequirePrimary
 require the TrueHit to be related to a primary particle in order for the relation to get registered!
 
bool m_PARAMrequireProximity
 require the TrueHit to be close to the SpacePoint.
 
double m_PARAMmaxGlobalDiff
 maximum difference of global position coordinates for each direction between TrueHit and SpacePoint
 
double m_PARAMmaxPosSigma
 defining th maximum difference of local coordinates in units of PitchSize / sqrt(12)
 
double m_PARAMminWeight
 define a minimal weight a relation between Cluster and TrueHit.
 
unsigned int m_nContainers
 number of passed containers -> storing the size of an input vector for not having to obtain it every time
 
std::vector< e_detTypesm_detectorTypes
 storing the detector types for each container in vector, needed in initialize
 
Belle2::StoreArray< Belle2::SVDTrueHitm_SVDTrueHits
 SVDTrueHits StoreArray used throughout the module.
 
Belle2::StoreArray< Belle2::PXDTrueHitm_PXDTrueHits
 PXDTrueHits StoreArray used throughout the module.
 
Belle2::StoreArray< Belle2::PXDClusterm_PXDClusters
 PXDTClusters StoreArray used throughout the module.
 
Belle2::StoreArray< Belle2::SVDClusterm_SVDClusters
 PXDClusters StoreArray used throughout the module.
 
std::vector< std::pair< Belle2::StoreArray< Belle2::SpacePoint >, e_detTypes > > m_inputSpacePoints
 StoreArray of all input SpacePoints.
 
std::vector< Belle2::StoreArray< Belle2::SpacePoint > > m_outputSpacePoints
 StoreArray of all output SpacePoints.
 
double m_maxGlobalDiff
 storing the squared value of m_PARAMmaxGlobalDiff here to not alter the parameter input
 
unsigned int m_iCont
 'helper variable' needed to not have to pass one integer down to processSpacePoint only to have a handle in cases where an exception gets caught
 
RootVariables m_rootVariables
 Root variables used for collecting data eventwise.
 
TFile * m_rootFilePtr
 pointer to root file
 
TTree * m_treePtr
 pointer to tree in root file
 
std::vector< unsigned int > m_SpacePointsCtr
 Number of SpacePoints presented to the module.
 
std::vector< std::array< unsigned int, 5 > > m_nRelTrueHitsCtr
 counting different numbers of related TrueHits (to a SpacePoint) with one variable
 
std::vector< unsigned int > m_noClusterCtr
 Number of SpacePoints without relation to a Cluster (i.e.
 
std::vector< unsigned int > m_regRelationsCtr
 Number of registered relations.
 
std::vector< unsigned int > m_ghostHitCtr
 Number of SpacePoints that are considered ghost hits.
 
std::vector< unsigned int > m_noTrueHitCtr
 Number of SpacePoints that contained a Cluster to which no TrueHit could be found (i.e.
 
std::vector< unsigned int > m_rejectedRelsCtr
 Number of SpacePoints that were not related to a TrueHit (i.e.
 
unsigned int m_weightTooSmallCtr
 Count the omitted relations because of a too small weight.
 
unsigned int m_rejectedNoPrimaryCtr
 Count how many times a relation was rejected because TrueHit was not related to primary.
 

Private Member Functions

std::list< ModulePtrgetModules () const override
 no submodules, return empty list
 
std::string getPathString () const override
 return the module name.
 
void setParamPython (const std::string &name, const boost::python::object &pyObj)
 Implements a method for setting boost::python objects.
 
void setParamPythonDict (const boost::python::dict &dictionary)
 Implements a method for reading the parameter values from a boost::python dictionary.
 

Private Attributes

std::string m_name
 The name of the module, saved as a string (user-modifiable)
 
std::string m_type
 The type of the module, saved as a string.
 
std::string m_package
 Package this module is found in (may be empty).
 
std::string m_description
 The description of the module.
 
unsigned int m_propertyFlags
 The properties of the module as bitwise or (with |) of EModulePropFlags.
 
LogConfig m_logConfig
 The log system configuration of the module.
 
ModuleParamList m_moduleParamList
 List storing and managing all parameter of the module.
 
bool m_hasReturnValue
 True, if the return value is set.
 
int m_returnValue
 The return value.
 
std::vector< ModuleConditionm_conditions
 Module condition, only non-null if set.
 

Detailed Description

Module that tries to register a relation between SpacePoints and TrueHits, hence making some MC Information easily accessible for other modules working with SpacePoints (e.g.

SPTCReferee or GFTC2SPTCConverter).

As there is no direct relation between SpacePoints and TrueHits, the relations between SpacePoints and Clusters and the relations between Clusters and TrueHits are used to relate SpacePoints and TrueHits. In a first step all (unique) TrueHits that are related to all Clusters of a SpacePoint are collected (including the weight of the relation). It is then possible that there is more than one TrueHit after this.

  • If 'storeSeperate' is set to true a new StoreArray of SpacePoints is created for every input StoreArray of SpacePoints with the same name and the 'outputSuffix' appended to it. This can be useful to have a StoreArray of SpacePoints where only 'checked' SpacePoints are (e.g. without ghost hits) that can then be used to feed the GFTC2SPTCConverter for example. If it is set to false, the relations will get registered in the existing StoreArray.
  • If 'registerAll' is set to true, the module simply registers a relation to all of these TrueHits. The weight of this new built relation encodes the information which Clusters of the SpacePoint where related to this TrueHit. ++ for PXD it is always 1, since these SpacePoints have only one underlying Cluster ++ for SVD it is 2 if it is a double Cluster SpacePoint and both Clusters have a relation to the TrueHit. It is 11 if only the U-Cluster has a relation to the TrueHit and it is 21 if only the V-Cluster has a relation to the TrueHit. This is also valid for single Cluster SpacePoints In this way the decision which TrueHit to use is left to the user. NOTE: The exact weight of the relations between Clusters and TrueHits is not stored, however the relations are registered in an order that the TrueHit with the highest sum of weights is the first entry in the RelationVector (i.e. it should be the one that is returned by SpacePoint::getRelatedTo<TrueHit>()).
  • If 'registerAll' is set to false, the module tries to find a relation to only one TrueHit: 1) If there is only one TrueHit -> check if all Clusters of the SpacePoint are related to this TrueHit -> if true -> register relation with weight holding the same information as explained above.
    2) If there is more than one TrueHit but only one TrueHit has a relation to both Clusters of a SpacePoint -> register relation to this TrueHit (again the weight of the relation codes the information which clusters of the SpacePoint are related to the TrueHit)
    3) If there is more than one TrueHit with a relation to all Clusters of a SpacePoint -> register relation to the TrueHit with the largest sum of weights (of relation between Clusters and TrueHits). Again the weight of the newly registered relation codes the above stated information
    4) If the SpacePoint has only one Cluster (e.g. PXD) and there is more than one TrueHit -> register relation to the TrueHit with the largest weight (of relation between Cluster and TrueHit). The weight of the newly registered relation is 1,11 or 21 (depending on what Cluster is underlying the SpacePoint) in this case (as there is only one Cluster of such a SpacePoint related to the TrueHit)

NOTE: It is not guaranteed that every SpacePoint gets related to a TrueHit if 'registerAll' is set to false! E.g. 'ghost hits' should be sorted out. NOTE: Choosing the TrueHit with the biggest weight (or sum of weights) if there is more than one possible TrueHit does not guarantee that the 'right' TrueHit is chosen! It is possible that in such cases no relation will get registered in the future if this proves to be a source of errors! NOTE: in a previous version the weight of the registered relations was the sum of the weights. Now it encodes information on the relation between the SpacePoint and the Clusters as well. The Information on the absolute values of the weights (between Cluster and TrueHit)is lost, however the relative values are preserved and if there are more than one related TrueHits to a SpacePoint (only possible if 'registerAll' is set to true) the entries of the RelationVector of TrueHits are ordered from highest to lowest sum of weights. NOTE: This module should be used to connect SpacePoints and TrueHits if MC information is needed afterwards (e.g. in the SPTCRefereeModule for SpacePointTrackCands) to avoid having to look up the relations to obtain this information separately in every Module. Furthermore some modules are no longer able to determine the related TrueHits themselves (e.g. GFTC2SPTCConverter)

Definition at line 117 of file SpacePoint2TrueHitConnectorModule.h.

Member Typedef Documentation

◆ baseMapT

typedef std::unordered_map<int, TrueHitInfo> baseMapT
protected

typedef for shorter notation throughout the module

Definition at line 168 of file SpacePoint2TrueHitConnectorModule.h.

◆ EAfterConditionPath

Forward the EAfterConditionPath definition from the ModuleCondition.

Definition at line 88 of file Module.h.

Member Enumeration Documentation

◆ e_detTypes

◆ e_relationStatus

enum e_relationStatus
protected

enum for better code readability

Definition at line 179 of file SpacePoint2TrueHitConnectorModule.h.

179 {
180 c_clearHit = 1, //< bit 0: Only one TrueHit to SpacePoint
181 c_ghostHit = 2, //< bit 1: ghost hit as described in this module
182 c_SpacePointU = 4, //< bit 2: SpacePoint U-coordinate is set
183 c_SpacePointV = 8, //< bit 3: SpacePoint V-coordinate is set
184 c_primaryParticle = 16, //< bit 4: Particle related to TrueHit is primary
185 c_bgParticle = 32, //< bit 5: particle related to TrueHit is background
186 c_nonUniqueRelation = 64, //< bit 6: more than one TrueHit related to SpacePoint
187 c_registeredRelation = 128, //< bit 7: this relation got registered
188 c_noiseCluster = 256, //< bit 8: one of the Clusters has no relation to a TrueHit (i.e. is noise) -> only for twoCluster SPs!
189 }; // end e_relationStatus

◆ EModulePropFlags

enum EModulePropFlags
inherited

Each module can be tagged with property flags, which indicate certain features of the module.

Enumerator
c_Input 

This module is an input module (reads data).

c_Output 

This module is an output module (writes data).

c_ParallelProcessingCertified 

This module can be run in parallel processing mode safely (All I/O must be done through the data store, in particular, the module must not write any files.)

c_HistogramManager 

This module is used to manage histograms accumulated by other modules.

c_InternalSerializer 

This module is an internal serializer/deserializer for parallel processing.

c_TerminateInAllProcesses 

When using parallel processing, call this module's terminate() function in all processes().

This will also ensure that there is exactly one process (single-core if no parallel modules found) or at least one input, one main and one output process.

c_DontCollectStatistics 

No statistics is collected for this module.

Definition at line 77 of file Module.h.

77 {
78 c_Input = 1,
79 c_Output = 2,
85 };
@ c_HistogramManager
This module is used to manage histograms accumulated by other modules.
Definition: Module.h:81
@ c_Input
This module is an input module (reads data).
Definition: Module.h:78
@ c_DontCollectStatistics
No statistics is collected for this module.
Definition: Module.h:84
@ 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
@ c_InternalSerializer
This module is an internal serializer/deserializer for parallel processing.
Definition: Module.h:82
@ c_Output
This module is an output module (writes data).
Definition: Module.h:79
@ c_TerminateInAllProcesses
When using parallel processing, call this module's terminate() function in all processes().
Definition: Module.h:83

Constructor & Destructor Documentation

◆ SpacePoint2TrueHitConnectorModule()

Constructor.

Definition at line 35 of file SpacePoint2TrueHitConnectorModule.cc.

35 :
36 Module()
37{
38 setDescription("Module that tries to find the appropriate TrueHit to each SpacePoint and to register a relation between them for making MC information for SpacePoints more easily accessible for Modules that need it. Module can also be used to filter out 'fishy' SpacePoints.");
40
41 addParam("storeSeperate", m_PARAMstoreSeparate,
42 "Set to false if you do not want to create separate StoreArrays for processed SpacePoints. (i.e. a relation from SpacePoint to TrueHit will be set in the passed StoreArray. NOTE: this StoreArray will contain SpacePoints with a relation to TrueHits and such without after this module). The Names of the output StoreArrays will be the names of the input StoreArrays with 'outputSuffix' (module parameter) appended to them",
43 true);
44
45 addParam("registerAll", m_PARAMregisterAll,
46 "If set to true, the module simply registers a relation for all TrueHits that are related to a SpacePoint (resp. its Clusters). In this way the module can be used to find all related TrueHits and then the user can decide what to do with these TrueHits (otherwise this module does some decision making). Setting this to true means that all checks (e.g. 'minWeight', 'maxPosSigma', ...) are omitted! NOTE that some of the information is lost in this way (e.g. how many of the Clusters of a SpacePoint have been related to a TrueHit)!",
47 false);
48
49 addParam("positionAnalysis", m_PARAMpositionAnalysis,
50 "Analyze the positions of SpacePoints and corresponding TrueHits. NOTE: if enabled a root file gets created!", false);
51
52 addParam("requirePrimary", m_PARAMrequirePrimary,
53 "Set to true if only relations to TrueHits that are related to a primary particle should get registered.", false);
54
55 addParam("requireProximity", m_PARAMrequireProximity,
56 "Require that the TrueHit is close to the SpacePoint (in local coordinates). The meaning of 'close' can be defined with the parameters 'maxPosSigma' and 'maxGlobalPosDiff'.",
57 true);
58
59 std::vector<std::string> defaultInList; // default list for input StoreArrays
60 defaultInList.push_back(std::string(""));
61 addParam("TrueHitNames", m_PARAMtrueHitNames,
62 "Container names of TrueHits. NOTE: need one name per 'DetectorType' (i.e. unique entries in 'DetectorType)!", defaultInList);
63 addParam("SpacePointNames", m_PARAMspacePointNames, "Container names of SpacePoints.", {"SVDSpacePoints", "PXDSpacePoints"});
64 addParam("DetectorTypes", m_PARAMdetectorTypes,
65 "detector types to determine which entries in 'TrueHitNames' and 'SpacePointNames' belong to which detector type. Entries have to be 'SVD' or 'PXD'. NOTE: if more 'SpacePointNames' than 'DetectorTypes' get passed, the last entry in 'DetectorTypes' is assumed to be valid for all remaining 'SpacePointNames'!");
66 addParam("ClusterNames", m_PARAMclusterNames,
67 "Container names of Clusters. NOTE: need one name per 'DetectorType' (i.e. unique entries in 'DetectorType')!", defaultInList);
68
69 std::vector<std::string> defaultRootFName = { "PositionAnalysis", "RECREATE" };
70 addParam("rootFileName", m_PARAMrootFileName,
71 "Filename and write-mode ('RECREATE' or 'UPDATE'). If given more than 2 strings this module will cause termination",
72 defaultRootFName);
73
74 addParam("outputSuffix", m_PARAMoutputSuffix,
75 "Suffix that will be appended to the container names if 'storeSeperate' is set to true", std::string("_relTH"));
76
77 addParam("maxGlobalPosDiff", m_PARAMmaxGlobalDiff,
78 "max difference of global position coordinates between TrueHit and SpacePoint (in each direction) in cm.", 0.05);
79// addParam("maxLocalPosDiff", m_PARAMmaxLocalDiff, "max difference of local position coordinates between TrueHit and SpacePoint (in U & V direction) in cm. NOTE: the default value is still subject to tuning and finding the appropriate value!", 0.01);
80
81 addParam("maxPosSigma", m_PARAMmaxPosSigma, "Define the maximum local position difference in units of PitchSize / sqrt(12).", 4.);
82 addParam("minWeight", m_PARAMminWeight,
83 "Define a minimal weight a relation between a Cluster and a TrueHit has to have for the TrueHit to be considered as possible candidate.",
84 0.);
85
86 // initialize all counters
88 m_rootFilePtr = nullptr;
89 m_treePtr = nullptr;
90
91 if (m_PARAMpositionAnalysis == true and Environment::Instance().getNumberProcesses() > 0) {
92 B2WARNING(
93 "SpacePoint2TrueHitConnector::initialize: parameter positionAnalysis (and therefore root-output) is enabled and basf2 is running in multi-threaded mode - this can cause nondeterministic behavior! "
94 << "\n"
95 << " you can suppress multi-threading for this module by writing:"
96 << "\n"
97 << "main.add_module('SpacePoint2TrueHitConnector').set_property_flags(0) "
98 << "\n"
99 << "into the steering file!");
100 }
101}
static Environment & Instance()
Static method to get a reference to the Environment instance.
Definition: Environment.cc:28
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
Module()
Constructor.
Definition: Module.cc:30
std::vector< std::string > m_PARAMclusterNames
names of containers of Clusters
std::vector< std::string > m_PARAMtrueHitNames
names of containers of TrueHits
std::vector< std::string > m_PARAMdetectorTypes
detector type names as strings to determine which name belongs to which detector type
double m_PARAMmaxGlobalDiff
maximum difference of global position coordinates for each direction between TrueHit and SpacePoint
bool m_PARAMstoreSeparate
switch for storing the SpacePoints that can be related to a TrueHit into separate StoreArrays,...
std::vector< std::string > m_PARAMrootFileName
name and update status of root file
std::string m_PARAMoutputSuffix
suffix that will be appended to the StoreArray names of the output StoreArrays
bool m_PARAMrequirePrimary
require the TrueHit to be related to a primary particle in order for the relation to get registered!
double m_PARAMmaxPosSigma
defining th maximum difference of local coordinates in units of PitchSize / sqrt(12)
bool m_PARAMregisterAll
switch for registereing all relations for all TrueHits for all SpacePoints (there can be more than 1 ...
bool m_PARAMrequireProximity
require the TrueHit to be close to the SpacePoint.
std::vector< std::string > m_PARAMspacePointNames
names of containers of SpacePoints
void initializeCounters()
initialize all counters to 0 WARNING: only call in constructor of module!
bool m_PARAMpositionAnalysis
switch for doing the analysis of positions of SpacePoints and TrueHits
double m_PARAMminWeight
define a minimal weight a relation between Cluster and TrueHit.
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

Member Function Documentation

◆ beginRun()

virtual void beginRun ( void  )
inlinevirtualinherited

Called when entering a new run.

Called at the beginning of each run, the method gives you the chance to change run dependent constants like alignment parameters, etc.

This method can be implemented by subclasses.

Reimplemented in ARICHBackgroundModule, BeamabortModule, BgoModule, CaveModule, ClawModule, CLAWSModule, DosiModule, FANGSModule, He3tubeModule, MicrotpcModule, Ph1bpipeModule, Ph1sustrModule, PindiodeModule, PlumeModule, QcsmonitorModule, SrsensorModule, GetEventFromSocketModule, CalibrationCollectorModule, EventsOfDoomBusterModule, CosmicsAlignmentValidationModule, EnergyBiasCorrectionModule, ChargedPidMVAModule, ChargedPidMVAMulticlassModule, CurlTaggerModule, LowEnergyPi0IdentificationExpertModule, LowEnergyPi0VetoExpertModule, ParticleVertexFitterModule, PhotonEfficiencySystematicsModule, TagVertexModule, TreeFitterModule, arichBtestModule, ARICHDigitizerModule, ARICHDQMModule, ARICHRateCalModule, ARICHReconstructorModule, B2BIIMCParticlesMonitorModule, B2BIIConvertBeamParamsModule, B2BIIConvertMdstModule, B2BIIFixMdstModule, B2BIIMdstInputModule, BelleMCOutputModule, BeamBkgGeneratorModule, BeamBkgHitRateMonitorModule, BeamBkgMixerModule, BeamBkgTagSetterModule, BGOverlayInputModule, AnalysisPhase1StudyModule, NtuplePhase1_v6Module, ReprocessorModule, BeamabortStudyModule, BeamDigitizerModule, BgoDigitizerModule, BgoStudyModule, ClawDigitizerModule, ClawStudyModule, ClawsDigitizerModule, ClawsStudyModule, CsiDigitizer_v2Module, CsIDigitizerModule, CsiModule, CsiStudy_v2Module, CsIStudyModule, DosiDigitizerModule, DosiStudyModule, FANGSDigitizerModule, FANGSStudyModule, He3DigitizerModule, He3tubeStudyModule, MicrotpcStudyModule, TpcDigitizerModule, PinDigitizerModule, PindiodeStudyModule, PlumeDigitizerModule, QcsmonitorDigitizerModule, QcsmonitorStudyModule, CDCCosmicAnalysisModule, CDCCRTestModule, cdcDQM7Module, CDCDQMModule, CDCPackerModule, CDCRecoTrackFilterModule, CDCUnpackerModule, DAQPerfModule, RxSocketModule, TxSocketModule, DqmHistoManagerModule, MonitorDataModule, TrackAnaModule, Ds2SampleModule, ReceiveEventModule, HLTDQM2ZMQModule, ElapsedTimeModule, DeSerializerPXDModule, GenRawSendModule, SerializerModule, CertifyParallelModule, Ds2RawModule, Ds2RbufModule, EvReductionModule, FastRbuf2DsModule, Raw2DsModule, RawInputModule, Rbuf2DsModule, Rbuf2RbufModule, Ds2RawFileModule, PartialSeqRootReaderModule, SeqRootMergerModule, StorageDeserializerModule, StorageSerializerModule, IPDQMModule, PhysicsObjectsDQMModule, PhysicsObjectsMiraBelleBhabhaModule, PhysicsObjectsMiraBelleDst2Module, PhysicsObjectsMiraBelleDstModule, PhysicsObjectsMiraBelleHadronModule, PhysicsObjectsMiraBelleModule, ECLBackgroundModule, ECLChargedPIDModule, ECLChargedPIDDataAnalysisModule, ECLChargedPIDDataAnalysisValidationModule, ECLChargedPIDMVAModule, ECLClusterPSDModule, ECLCovarianceMatrixModule, ECLCRFinderModule, ECLDataAnalysisModule, ECLDigitCalibratorModule, ECLDigitizerModule, ECLDigitizerPureCsIModule, EclDisplayModule, ECLDQMModule, ECLDQMConnectedRegionsModule, ECLDQMEXTENDEDModule, ECLDQMOutOfTimeDigitsModule, ECLFinalizerModule, ECLHitDebugModule, ECLLocalMaximumFinderModule, ECLLocalRunCalibratorModule, ECLLOMModule, ECLPackerModule, ECLShowerCorrectorModule, ECLShowerShapeModule, ECLSplitterN1Module, ECLSplitterN2Module, ECLUnpackerModule, ECLWaveformFitModule, HistoModule, SubEventModule, SwitchDataStoreModule, EventInfoPrinterModule, EventLimiterModule, IoVDependentConditionModule, ProgressModule, RandomBarrierModule, GearboxModule, HistoManagerModule, StatisticsSummaryModule, SeqRootInputModule, SeqRootOutputModule, RxModule, TxModule, EvtGenDecayModule, EvtGenInputModule, OverrideGenerationFlagsModule, KKGenInputModule, CreateFieldMapModule, ExportGeometryModule, SoftwareTriggerModule, SoftwareTriggerHLTDQMModule, StatisticsTimingHLTDQMModule, BKLMAnaModule, BKLMDigitAnalyzerModule, BKLMSimHistogrammerModule, BKLMTrackingModule, EKLMDataCheckerModule, KLMClusterAnaModule, KLMClusterEfficiencyModule, KLMClustersReconstructorModule, KLMDigitizerModule, KLMDigitTimeShifterModule, KLMDQMModule, KLMDQM2Module, KLMPackerModule, KLMReconstructorModule, KLMScintillatorSimulatorModule, KLMUnpackerModule, MVAExpertModule, MVAMultipleExpertsModule, MVAPrototypeModule, AWESOMEBasicModule, PXDBackgroundModule, PXDRawDQMChipsModule, PXDClustersFromTracksModule, PXDPerformanceModule, PXDClusterizerModule, Convert2RawDetModule, CDCDedxDQMModule, CDCDedxValidationModule, EventT0DQMModule, EventT0ValidationModule, DataWriterModule, ECLExpertModule, KLMExpertModule, KlongValidationModule, KLMMuonIDDNNExpertModule, FullSimModule, MaterialScanModule, SVDBackgroundModule, SVDClusterCalibrationsMonitorModule, SVDHotStripFinderModule, SVDLatencyCalibrationModule, SVDLocalCalibrationsCheckModule, SVDLocalCalibrationsMonitorModule, SVDPositionErrorScaleFactorImporterModule, SVDTimeCalibrationsMonitorModule, SVDDQMHitTimeModule, svdDumpModule, SVDPackerModule, SVDB4CommissioningPlotsModule, SVDClusterEvaluationModule, SVDClusterEvaluationTrueInfoModule, SVDClusterFilterModule, SVDMaxStripTTreeModule, SVDOccupancyAnalysisModule, SVDPerformanceModule, SVDPerformanceTTreeModule, SVDShaperDigitsFromTracksModule, SVDClusterizerModule, SVDCoGTimeEstimatorModule, SVDDataFormatCheckModule, SVDMissingAPVsClusterCreatorModule, SVDRecoDigitCreatorModule, SVD3SamplesEmulatorModule, SVDDigitizerModule, SVDEventInfoSetterModule, SVDTriggerQualityGeneratorModule, SVDSpacePointCreatorModule, SVDTimeGroupingModule, SVDUnpackerModule, TOPBackgroundModule, TOPBunchFinderModule, TOPChannelMaskerModule, TOPChannelT0MCModule, TOPDigitizerModule, TOPTriggerDigitizerModule, TOPDoublePulseGeneratorModule, TOPDQMModule, TOPGainEfficiencyCalculatorModule, TOPLaserHitSelectorModule, TOPInterimFENtupleModule, TOPLaserCalibratorModule, TOPMCTrackMakerModule, TOPModuleT0CalibratorModule, TOPNtupleModule, TOPPackerModule, TOPRawDigitConverterModule, TOPTBCComparatorModule, TOPTimeBaseCalibratorModule, TOPTimeRecalibratorModule, TOPUnpackerModule, TOPWaveformFeatureExtractorModule, TOPXTalkChargeShareSetterModule, DQMHistoModuleBase, SVDEventT0EstimatorModule, ExtModule, FlipQualityModule, BeamSpotMonitorModule, KinkFinderModule, MCV0MatcherModule, MCTrackCandClassifierModule, MuidModule, PXDROIFinderModule, SVDROIFinderAnalysisModule, SVDROIFinderModule, SPTCmomentumSeedRetrieverModule, SPTCvirtualIPRemoverModule, TrackCreatorModule, TrackFinderMCTruthRecoTracksModule, EffPlotsModule, HitXPModule, TrackingPerformanceEvaluationModule, V0findingPerformanceEvaluationModule, TrackQETrainingDataCollectorModule, TrackQualityEstimatorMVAModule, SecMapTrainerBaseModule, SecMapTrainerVXDTFModule, TrackFinderVXDAnalizerModule, VXDSimpleClusterizerModule, QualityEstimatorVXDModule, VXDQETrainingDataCollectorModule, VXDQualityEstimatorMVAModule, SectorMapBootstrapModule, SegmentNetworkProducerModule, TrackFinderVXDBasicPathFinderModule, TrackFinderVXDCellOMatModule, VXDTFTrainingDataCollectorModule, FindletModule< AFindlet >, FindletModule< HitBasedT0Extractor >, FindletModule< CKFToSVDSeedFindlet >, FindletModule< CKFToSVDFindlet >, FindletModule< CosmicsTrackMergerFindlet >, FindletModule< DATCONFPGAFindlet >, FindletModule< MCVXDCDCTrackMergerFindlet >, FindletModule< vxdHoughTracking::SVDHoughTracking >, FindletModule< CKFToCDCFindlet >, FindletModule< CKFToCDCFromEclFindlet >, FindletModule< CKFToPXDFindlet >, FindletModule< AsicBackgroundLibraryCreator >, FindletModule< CDCTrackingEventLevelMdstInfoFillerFromHitsFindlet >, FindletModule< CDCTrackingEventLevelMdstInfoFillerFromSegmentsFindlet >, FindletModule< AxialSegmentPairCreator >, FindletModule< AxialStraightTrackFinder >, FindletModule< AxialTrackCreatorMCTruth >, FindletModule< AxialTrackCreatorSegmentHough >, FindletModule< AxialTrackFinderHough >, FindletModule< AxialTrackFinderLegendre >, FindletModule< ClusterBackgroundDetector >, FindletModule< ClusterPreparer >, FindletModule< ClusterRefiner< BridgingWireHitRelationFilter > >, FindletModule< FacetCreator >, FindletModule< HitReclaimer >, FindletModule< MonopoleAxialTrackFinderLegendre >, FindletModule< MonopoleStereoHitFinder >, FindletModule< MonopoleStereoHitFinderQuadratic >, FindletModule< SegmentCreatorFacetAutomaton >, FindletModule< SegmentCreatorMCTruth >, FindletModule< SegmentFinderFacetAutomaton >, FindletModule< SegmentFitter >, FindletModule< SegmentLinker >, FindletModule< SegmentOrienter >, FindletModule< SegmentPairCreator >, FindletModule< SegmentRejecter >, FindletModule< SegmentTrackCombiner >, FindletModule< SegmentTripleCreator >, FindletModule< StereoHitFinder >, FindletModule< SuperClusterCreator >, FindletModule< TrackCombiner >, FindletModule< TrackCreatorSegmentPairAutomaton >, FindletModule< TrackCreatorSegmentTripleAutomaton >, FindletModule< TrackCreatorSingleSegments >, FindletModule< TrackExporter >, FindletModule< TrackFinderAutomaton >, FindletModule< TrackFinderCosmics >, FindletModule< TrackFinder >, FindletModule< TrackFinderSegmentPairAutomaton >, FindletModule< TrackFinderSegmentTripleAutomaton >, FindletModule< TrackFlightTimeAdjuster >, FindletModule< TrackLinker >, FindletModule< TrackOrienter >, FindletModule< TrackQualityAsserter >, FindletModule< TrackQualityEstimator >, FindletModule< TrackRejecter >, FindletModule< WireHitBackgroundDetector >, FindletModule< WireHitCreator >, FindletModule< WireHitPreparer >, CDCTriggerNeuroDQMModule, CDCTriggerNeuroDQMOnlineModule, CDCTriggerNDFinderModule, CDCTriggerTSFModule, TRGCDCModule, TRGCDCETFUnpackerModule, TRGCDCT2DDQMModule, TRGCDCT3DConverterModule, TRGCDCT3DDQMModule, TRGCDCT3DUnpackerModule, TRGCDCTSFDQMModule, TRGCDCTSFUnpackerModule, TRGCDCTSStreamModule, CDCTriggerUnpackerModule, MCMatcherTRGECLModule, TRGECLFAMModule, TRGECLModule, TRGECLBGTCHitModule, TRGECLDQMModule, TRGECLEventTimingDQMModule, TRGECLQAMModule, TRGECLRawdataAnalysisModule, TRGECLTimingCalModule, TRGECLUnpackerModule, TRGGDLModule, TRGEFFDQMModule, TRGGDLDQMModule, TRGGDLDSTModule, TRGGDLSummaryModule, TRGGDLUnpackerModule, TRGGRLMatchModule, TRGGRLModule, TRGGRLProjectsModule, TRGGRLDQMModule, TRGGRLUnpackerModule, KLMTriggerModule, TRGTOPDQMModule, TRGTOPTRD2TTSConverterModule, TRGTOPUnpackerModule, TRGTOPUnpackerWaveformModule, TRGTOPWaveformPlotterModule, TRGRAWDATAModule, VXDMisalignmentModule, DQMHistAnalysisARICHModule, DQMHistAnalysisCDCDedxModule, DQMHistAnalysisCDCEpicsModule, DQMHistAnalysisCDCMonObjModule, DQMHistAnalysisDAQMonObjModule, DQMHistAnalysisECLModule, DQMHistAnalysisECLConnectedRegionsModule, DQMHistAnalysisECLShapersModule, DQMHistAnalysisECLSummaryModule, DQMHistAnalysisEpicsExampleModule, DQMHistAnalysisEventT0EfficiencyModule, DQMHistAnalysisEventT0TriggerJitterModule, DQMHistAnalysisExampleModule, DQMHistAnalysisExampleFlagsModule, DQMHistAnalysisHLTModule, DQMHistAnalysisInput2Module, DQMHistAnalysisInputPVSrvModule, DQMHistAnalysisInputRootFileModule, DQMHistAnalysisInputTestModule, DQMHistAnalysisKLMModule, DQMHistAnalysisKLM2Module, DQMHistAnalysisMiraBelleModule, DQMHistAnalysisOutputMonObjModule, DQMHistAnalysisOutputRelayMsgModule, DQMHistAnalysisPeakModule, DQMHistAnalysisPXDERModule, DQMHistAnalysisPXDFitsModule, DQMHistAnalysisSVDClustersOnTrackModule, DQMHistAnalysisSVDDoseModule, DQMHistAnalysisSVDEfficiencyModule, DQMHistAnalysisSVDGeneralModule, DQMHistAnalysisSVDOccupancyModule, DQMHistAnalysisSVDOnMiraBelleModule, DQMHistAnalysisSVDUnpackerModule, DQMHistAnalysisTOPModule, DQMHistAnalysisTrackingAbortModule, DQMHistAnalysisTrackingHLTModule, DQMHistAnalysisTRGECLModule, DQMHistAutoCanvasModule, DQMHistComparitorModule, DQMHistDeltaHistoModule, DQMHistReferenceModule, DQMHistSnapshotsModule, DAQMonitorModule, DelayDQMModule, V0ObjectsDQMModule, ECLDQMInjectionModule, PyModule, PXDBgTupleProducerModule, PXDMCBgTupleProducerModule, PXDDAQDQMModule, PXDDQMClustersModule, PXDDQMCorrModule, PXDDQMEfficiencyModule, PXDDQMEfficiencySelftrackModule, PXDDQMExpressRecoModule, PXDGatedDHCDQMModule, PXDGatedModeDQMModule, PXDInjectionDQMModule, PXDRawDQMCorrModule, PXDRawDQMModule, PXDROIDQMModule, PXDTrackClusterDQMModule, PXDDigitizerModule, PXDPackerModule, PXDUnpackerModule, TTDDQMModule, DetectorOccupanciesDQMModule, SVDDQMClustersOnTrackModule, SVDDQMDoseModule, SVDDQMExpressRecoModule, SVDDQMInjectionModule, SVDUnpackerDQMModule, PXDclusterFilterModule, PXDdigiFilterModule, PXDROIFinderAnalysisModule, TrackingAbortDQMModule, VXDDQMExpressRecoModule, vxdDigitMaskingModule, DQMHistAnalysisDeltaEpicsMonObjExampleModule, DQMHistAnalysisDeltaTestModule, DQMHistAnalysisEpicsOutputModule, DQMHistAnalysisPhysicsModule, DQMHistAnalysisPXDChargeModule, DQMHistAnalysisPXDCMModule, DQMHistAnalysisPXDDAQModule, DQMHistAnalysisPXDEffModule, DQMHistAnalysisPXDInjectionModule, DQMHistAnalysisPXDReductionModule, DQMHistAnalysisPXDTrackChargeModule, DQMHistAnalysisRooFitExampleModule, DQMHistAnalysisRunNrModule, DQMHistAnalysisTRGModule, DQMHistInjectionModule, and DQMHistOutputToEPICSModule.

Definition at line 147 of file Module.h.

147{};

◆ calculateRelationWeight()

double calculateRelationWeight ( const TrueHitInfo trueHitInfo,
Belle2::SpacePoint spacePoint 
)
protected

calculate the Relation weight to be used (for SVD only, although method works with PXD as well!)

  • if a TrueHit is related to both Clusters -> relation weight = 2
  • if a TrueHit is only related to the U-Cluster -> relation weight = 11 (this is what happens with if a PXD is passed!)
  • if a TrueHit is only related to the V-Cluster -> relation weight = 21

Definition at line 903 of file SpacePoint2TrueHitConnectorModule.cc.

904{
905 bool isUAssigned = spacePoint->getIfClustersAssigned().first; // get if the Cluster in the SpacePoint is a U-Cluster
906 // get if two Clusters are related to the Truehit (always false for single Cluster SPs
907 bool bothClusters = trueHitInfo.m_U && trueHitInfo.m_V;
908 // calculate the additional weight that identifies which Clusters are related to this TrueHit
909 // 0 -> both Clusters have Relation to TrueHit, 10 -> only U-Cluster, 20 -> only V-Cluster has Relation to TrueHit
910 short addWeight = 20 - (bothClusters ? 20 : isUAssigned ? 10 : 0);
911
912 return addWeight + (bothClusters ? 2 : 1);
913}
std::pair< bool, bool > getIfClustersAssigned() const
Returns, if u(v)-coordinate is based on cluster information.
Definition: SpacePoint.h:162
bool m_U
if true, U-Cluster is used by SpacePoint
bool m_V
if true, V-Cluster is used by SpacePoint

◆ clone()

std::shared_ptr< PathElement > clone ( ) const
overridevirtualinherited

Create an independent copy of this module.

Note that parameters are shared, so changing them on a cloned module will also affect the original module.

Implements PathElement.

Definition at line 179 of file Module.cc.

180{
182 newModule->m_moduleParamList.setParameters(getParamList());
183 newModule->setName(getName());
184 newModule->m_package = m_package;
185 newModule->m_propertyFlags = m_propertyFlags;
186 newModule->m_logConfig = m_logConfig;
187 newModule->m_conditions = m_conditions;
188
189 return newModule;
190}
std::shared_ptr< Module > registerModule(const std::string &moduleName, std::string sharedLibPath="") noexcept(false)
Creates an instance of a module and registers it to the ModuleManager.
static ModuleManager & Instance()
Exception is thrown if the requested module could not be created by the ModuleManager.
const ModuleParamList & getParamList() const
Return module param list.
Definition: Module.h:363
const std::string & getName() const
Returns the name of the module.
Definition: Module.h:187
const std::string & getType() const
Returns the type of the module (i.e.
Definition: Module.cc:41
unsigned int m_propertyFlags
The properties of the module as bitwise or (with |) of EModulePropFlags.
Definition: Module.h:512
LogConfig m_logConfig
The log system configuration of the module.
Definition: Module.h:514
std::vector< ModuleCondition > m_conditions
Module condition, only non-null if set.
Definition: Module.h:521
std::string m_package
Package this module is found in (may be empty).
Definition: Module.h:510
std::shared_ptr< Module > ModulePtr
Defines a pointer to a module object as a boost shared pointer.
Definition: Module.h:43

◆ closeRootFile()

void closeRootFile ( )
protected

close root file

Definition at line 852 of file SpacePoint2TrueHitConnectorModule.cc.

853{
854 if (m_treePtr != nullptr && m_rootFilePtr != nullptr) {
855 m_rootFilePtr->cd(); //important! without this the famework root I/O (SimpleOutput etc) could mix with the root I/O of this module
856// m_treePtr->Write(); // using TTree::Write() instead, which calls this any way
857 m_rootFilePtr->Write();
858 m_rootFilePtr->Close();
859 }
860}

◆ compatibleCombination()

bool compatibleCombination ( Belle2::SpacePoint spacePoint,
TrueHitType *  trueHit 
)
protected

compares the TrueHit and the SpacePoint positions (global) to decide whether they are compatible NOTE: if a SpacePoint and a TrueHit do not 'pass' this test they are most probably not compatible, however just because this test is passed does not guarantee that the 'right' TrueHit has been chosen before calling this function!

Definition at line 701 of file SpacePoint2TrueHitConnectorModule.cc.

702{
703 B2DEBUG(25, "Checking TrueHit " << trueHit->getArrayIndex() << " from Array " << trueHit->getArrayName() << " and SpacePoint " <<
704 spacePoint->getArrayIndex() << " from Array " << spacePoint->getArrayName() << " for compatibility");
705
706 // check primary first
707 MCParticle* mcPart = trueHit->template getRelatedFrom<MCParticle>("ALL");
708 bool primaryPart = false; // assume secondary or background for safety
709 if (mcPart != nullptr) primaryPart = mcPart->hasStatus(MCParticle::c_PrimaryParticle);
710 if (m_PARAMrequirePrimary && !primaryPart) {
711 B2DEBUG(25, "TrueHit is not related to a primary particle but 'requirePrimary' is set to true!");
713 return false;
714 }
715
716 // CAUTION: if further tests are added, make sure that they do not get 'over-ruled' by this one (i.e. put before this if)
718 B2DEBUG(29, "Not checking positions because 'requireProximity' is set to false");
719 return true;
720 }
721 const VxdID spacePointVxdId = spacePoint->getVxdID();
722 const VxdID trueHitVxdId = trueHit->getSensorID();
723
724 B2DEBUG(29, "Comparing the VxdIDs, SpacePoint: " << spacePointVxdId << ", TrueHit: " << trueHitVxdId);
725 if (spacePointVxdId != trueHitVxdId) {
726 B2DEBUG(25, "SpacePoint and TrueHit do not have the same VxdID. spacePoint: " << spacePointVxdId << ", trueHit: " << trueHitVxdId);
727 return false;
728 }
729
731 trueHitVxdId); // only have to get one, since VxdIds are already the same at this point!
732 double maxUres = SensorInfoBase.getUPitch(trueHit->getV()) / sqrt(12.) * m_PARAMmaxPosSigma;
733 double maxVres = SensorInfoBase.getVPitch(trueHit->getV()) / sqrt(12.) * m_PARAMmaxPosSigma;
734
735 B2DEBUG(29, "maximum residual in U: " << maxUres << ", in V: " << maxVres);
736
737 const ROOT::Math::XYZVector trueHitLocalPos = ROOT::Math::XYZVector(trueHit->getU(), trueHit->getV(), 0);
738 const ROOT::Math::XYZVector trueHitGlobalPos = SensorInfoBase.pointToGlobal(trueHitLocalPos, true); // uses alignment
739
740 std::pair<double, double> spacePointLocal = getLocalPos(spacePoint);
741 // compare only those values of the local coordinates that have been set
742 std::pair<bool, bool> setCoordinates = spacePoint->getIfClustersAssigned();
743
744 if (setCoordinates.first) {
745 B2DEBUG(29, "Comparing the U-coordinates, SpacePoint: " << spacePointLocal.first << ", TrueHit: " << trueHitLocalPos.X() <<
746 " -> diff: " << spacePointLocal.first - trueHitLocalPos.X());
747 if (pow(spacePointLocal.first - trueHitLocalPos.X(), 2) > maxUres * maxUres) {
748 B2DEBUG(25, "The local position difference in U direction is " << spacePointLocal.first - trueHitLocalPos.X() <<
749 " but maximum local position difference is set to: " << maxUres);
750 return false;
751 }
752 }
753 if (setCoordinates.second) {
754 B2DEBUG(29, "Comparing the V-coordinates, SpacePoint: " << spacePointLocal.second << ", TrueHit: " << trueHitLocalPos.Y() <<
755 " -> diff: " << spacePointLocal.second - trueHitLocalPos.Y());
756 if (pow(spacePointLocal.second - trueHitLocalPos.Y(), 2) > maxVres * maxVres) {
757 B2DEBUG(25, "The local position difference in V direction is " << spacePointLocal.second - trueHitLocalPos.Y() <<
758 " but maximum local position difference is set to: " << maxVres);
759 return false;
760 }
761 }
762
763 // only if both local coordinates of a SpacePoint are set, compare also the global positions!
764 if (setCoordinates.first && setCoordinates.second) {
765 B2DEBUG(29, "Comparing the global positions, SpacePoint: (" << spacePoint->X() << "," << spacePoint->Y() << "," << spacePoint->Z()
766 << "), TrueHit: (" << trueHitGlobalPos.X() << "," << trueHitGlobalPos.Y() << "," << trueHitGlobalPos.Z() << ")");
767 if (pow(spacePoint->X() - trueHitGlobalPos.X(), 2) > m_maxGlobalDiff
768 || pow(spacePoint->Y() - trueHitGlobalPos.Y(), 2) > m_maxGlobalDiff ||
769 pow(spacePoint->Z() - trueHitGlobalPos.Z(), 2) > m_maxGlobalDiff) {
770 B2DEBUG(25, "The position differences are for X: " << spacePoint->X() - trueHitGlobalPos.X() << ", Y: " << spacePoint->Y() -
771 trueHitGlobalPos.Y() << " Z: " << spacePoint->Z() - trueHitGlobalPos.Z() << " but the maximum position difference is set to: " <<
773 return false;
774 }
775 } else {
776 B2DEBUG(20, "For SpacePoint " << spacePoint->getArrayIndex() <<
777 " one of the local coordinates was not assigned. The global positions and the un-assigned local coordinate were not compared!");
778 }
779
780 return true;
781}
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32
@ c_PrimaryParticle
bit 0: Particle is primary particle.
Definition: MCParticle.h:47
bool hasStatus(unsigned short int bitmask) const
Return if specific status bit is set.
Definition: MCParticle.h:129
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.
unsigned int m_rejectedNoPrimaryCtr
Count how many times a relation was rejected because TrueHit was not related to primary.
double m_maxGlobalDiff
storing the squared value of m_PARAMmaxGlobalDiff here to not alter the parameter input
std::pair< double, double > getLocalPos(Belle2::SpacePoint *spacePoint)
get the local position of a SpacePoint
VxdID getVxdID() const
Return the VxdID of the sensor on which the the cluster of the SpacePoint lives.
Definition: SpacePoint.h:148
double Z() const
return the z-value of the global position of the SpacePoint
Definition: SpacePoint.h:129
double X() const
return the x-value of the global position of the SpacePoint
Definition: SpacePoint.h:123
double Y() const
return the y-value of the global position of the SpacePoint
Definition: SpacePoint.h:126
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne to the SensorInfo of a given SensorID.
Definition: GeoCache.cc:67
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214
Base class to provide Sensor Information for PXD and SVD.
double getUPitch(double v=0) const
Return the pitch of the sensor.
ROOT::Math::XYZVector pointToGlobal(const ROOT::Math::XYZVector &local, bool reco=false) const
Convert a point from local to global coordinates.
double getVPitch(double v=0) const
Return the pitch of the sensor.
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28

◆ def_beginRun()

virtual void def_beginRun ( )
inlineprotectedvirtualinherited

Wrapper method for the virtual function beginRun() that has the implementation to be used in a call from Python.

Reimplemented in PyModule.

Definition at line 426 of file Module.h.

426{ beginRun(); }
virtual void beginRun()
Called when entering a new run.
Definition: Module.h:147

◆ def_endRun()

virtual void def_endRun ( )
inlineprotectedvirtualinherited

This method can receive that the current run ends as a call from the Python side.

For regular C++-Modules that forwards the call to the regular endRun() method.

Reimplemented in PyModule.

Definition at line 439 of file Module.h.

439{ endRun(); }
virtual void endRun()
This method is called if the current run ends.
Definition: Module.h:166

◆ def_event()

virtual void def_event ( )
inlineprotectedvirtualinherited

Wrapper method for the virtual function event() that has the implementation to be used in a call from Python.

Reimplemented in PyModule.

Definition at line 432 of file Module.h.

432{ event(); }
virtual void event()
This method is the core of the module.
Definition: Module.h:157

◆ def_initialize()

virtual void def_initialize ( )
inlineprotectedvirtualinherited

Wrappers to make the methods without "def_" prefix callable from Python.

Overridden in PyModule. Wrapper method for the virtual function initialize() that has the implementation to be used in a call from Python.

Reimplemented in PyModule.

Definition at line 420 of file Module.h.

420{ initialize(); }
virtual void initialize()
Initialize the Module.
Definition: Module.h:109

◆ def_terminate()

virtual void def_terminate ( )
inlineprotectedvirtualinherited

Wrapper method for the virtual function terminate() that has the implementation to be used in a call from Python.

Reimplemented in PyModule.

Definition at line 445 of file Module.h.

445{ terminate(); }
virtual void terminate()
This method is called at the end of the event processing.
Definition: Module.h:176

◆ endRun()

virtual void endRun ( void  )
inlinevirtualinherited

This method is called if the current run ends.

Use this method to store information, which should be aggregated over one run.

This method can be implemented by subclasses.

Reimplemented in BeamabortModule, BgoModule, CaveModule, ClawModule, CLAWSModule, DosiModule, FANGSModule, He3tubeModule, MicrotpcModule, Ph1bpipeModule, Ph1sustrModule, PindiodeModule, PlumeModule, QcsmonitorModule, SrsensorModule, GetEventFromSocketModule, CalibrationCollectorModule, AlignDQMModule, CosmicsAlignmentValidationModule, CurlTaggerModule, LowEnergyPi0IdentificationExpertModule, LowEnergyPi0VetoExpertModule, arichBtestModule, ARICHDQMModule, B2BIIMCParticlesMonitorModule, B2BIIConvertMdstModule, B2BIIMdstInputModule, BelleMCOutputModule, BeamBkgGeneratorModule, BeamBkgHitRateMonitorModule, BeamBkgMixerModule, BeamBkgTagSetterModule, BGOverlayInputModule, AnalysisPhase1StudyModule, NtuplePhase1_v6Module, ReprocessorModule, BeamabortStudyModule, BeamDigitizerModule, BgoDigitizerModule, BgoStudyModule, ClawDigitizerModule, ClawStudyModule, ClawsDigitizerModule, ClawsStudyModule, CsiDigitizer_v2Module, CsIDigitizerModule, CsiModule, CsiStudy_v2Module, CsIStudyModule, DosiDigitizerModule, DosiStudyModule, FANGSDigitizerModule, FANGSStudyModule, He3DigitizerModule, He3tubeStudyModule, MicrotpcStudyModule, TpcDigitizerModule, TPCStudyModule, PinDigitizerModule, PindiodeStudyModule, PlumeDigitizerModule, QcsmonitorDigitizerModule, QcsmonitorStudyModule, CDCCosmicAnalysisModule, CDCCRTestModule, cdcDQM7Module, CDCDQMModule, CDCPackerModule, CDCRecoTrackFilterModule, CDCUnpackerModule, DAQPerfModule, RxSocketModule, TxSocketModule, DqmHistoManagerModule, MonitorDataModule, TrackAnaModule, Ds2SampleModule, ReceiveEventModule, HLTDQM2ZMQModule, HLTDs2ZMQModule, ElapsedTimeModule, DeSerializerPXDModule, GenRawSendModule, Root2RawModule, SerializerModule, CertifyParallelModule, Ds2RawModule, Ds2RbufModule, EvReductionModule, FastRbuf2DsModule, Raw2DsModule, RawInputModule, Rbuf2DsModule, Rbuf2RbufModule, Ds2RawFileModule, PartialSeqRootReaderModule, SeqRootMergerModule, StorageDeserializerModule, StorageRootOutputModule, StorageSerializerModule, PhysicsObjectsDQMModule, PhysicsObjectsMiraBelleBhabhaModule, PhysicsObjectsMiraBelleDst2Module, PhysicsObjectsMiraBelleDstModule, PhysicsObjectsMiraBelleHadronModule, PhysicsObjectsMiraBelleModule, ECLBackgroundModule, ECLChargedPIDModule, ECLChargedPIDDataAnalysisModule, ECLChargedPIDDataAnalysisValidationModule, ECLClusterPSDModule, ECLCovarianceMatrixModule, ECLCRFinderModule, ECLDataAnalysisModule, ECLDigitCalibratorModule, ECLDigitizerModule, ECLDigitizerPureCsIModule, EclDisplayModule, ECLDQMModule, ECLDQMEXTENDEDModule, ECLFinalizerModule, ECLHitDebugModule, ECLLocalMaximumFinderModule, ECLLocalRunCalibratorModule, ECLLOMModule, ECLPackerModule, ECLShowerCorrectorModule, ECLShowerShapeModule, ECLSplitterN1Module, ECLSplitterN2Module, ECLUnpackerModule, ECLWaveformFitModule, HistoModule, SubEventModule, SwitchDataStoreModule, EventInfoPrinterModule, RandomBarrierModule, HistoManagerModule, StatisticsSummaryModule, SeqRootInputModule, SeqRootOutputModule, RxModule, TxModule, ZMQTxInputModule, ZMQTxWorkerModule, EvtGenDecayModule, OverrideGenerationFlagsModule, BKLMAnaModule, BKLMDigitAnalyzerModule, BKLMSimHistogrammerModule, BKLMTrackingModule, EKLMDataCheckerModule, KLMClusterEfficiencyModule, KLMClustersReconstructorModule, KLMDigitizerModule, KLMDQMModule, KLMDQM2Module, KLMPackerModule, KLMReconstructorModule, KLMScintillatorSimulatorModule, KLMUnpackerModule, AWESOMEBasicModule, PXDBackgroundModule, PXDClustersFromTracksModule, PXDPerformanceModule, Convert2RawDetModule, PrintDataModule, PrintEventRateModule, Root2BinaryModule, CDCDedxDQMModule, CDCDedxValidationModule, EventT0ValidationModule, DataWriterModule, KlongValidationModule, KLMMuonIDDNNExpertModule, FullSimModule, SVDBackgroundModule, SVDClusterCalibrationsMonitorModule, SVDHotStripFinderModule, SVDLatencyCalibrationModule, SVDLocalCalibrationsMonitorModule, SVDPositionErrorScaleFactorImporterModule, SVDTimeCalibrationsMonitorModule, svdDumpModule, SVDPackerModule, SVDB4CommissioningPlotsModule, SVDClusterEvaluationModule, SVDClusterEvaluationTrueInfoModule, SVDClusterFilterModule, SVDOccupancyAnalysisModule, SVDPerformanceModule, SVDShaperDigitsFromTracksModule, SVDClusterizerModule, SVDCoGTimeEstimatorModule, SVDDataFormatCheckModule, SVDRecoDigitCreatorModule, SVD3SamplesEmulatorModule, SVDTriggerQualityGeneratorModule, SVDUnpackerModule, TOPBackgroundModule, TOPChannelT0MCModule, TOPTriggerDigitizerModule, TOPDoublePulseGeneratorModule, TOPGainEfficiencyCalculatorModule, TOPLaserHitSelectorModule, TOPInterimFENtupleModule, TOPLaserCalibratorModule, TOPMCTrackMakerModule, TOPNtupleModule, TOPPackerModule, TOPRawDigitConverterModule, TOPTBCComparatorModule, TOPTimeBaseCalibratorModule, TOPUnpackerModule, TOPWaveformFeatureExtractorModule, TOPWaveformQualityPlotterModule, TOPXTalkChargeShareSetterModule, ExtModule, GenfitVisModule, MCV0MatcherModule, MCTrackCandClassifierModule, MuidModule, MCSlowPionPXDROICreatorModule, PXDROIFinderModule, SVDROIDQMModule, SVDROIFinderAnalysisModule, SVDROIFinderModule, RT2SPTCConverterModule, SPTCmomentumSeedRetrieverModule, SPTCvirtualIPRemoverModule, TrackFinderMCTruthRecoTracksModule, EffPlotsModule, HitXPModule, TrackingPerformanceEvaluationModule, V0findingPerformanceEvaluationModule, SecMapTrainerBaseModule, SecMapTrainerVXDTFModule, TrackFinderVXDAnalizerModule, VXDSimpleClusterizerModule, NoKickCutsEvalModule, SectorMapBootstrapModule, VXDTFTrainingDataCollectorModule, FindletModule< AFindlet >, FindletModule< HitBasedT0Extractor >, FindletModule< CKFToSVDSeedFindlet >, FindletModule< CKFToSVDFindlet >, FindletModule< CosmicsTrackMergerFindlet >, FindletModule< DATCONFPGAFindlet >, FindletModule< MCVXDCDCTrackMergerFindlet >, FindletModule< vxdHoughTracking::SVDHoughTracking >, FindletModule< CKFToCDCFindlet >, FindletModule< CKFToCDCFromEclFindlet >, FindletModule< CKFToPXDFindlet >, FindletModule< AsicBackgroundLibraryCreator >, FindletModule< CDCTrackingEventLevelMdstInfoFillerFromHitsFindlet >, FindletModule< CDCTrackingEventLevelMdstInfoFillerFromSegmentsFindlet >, FindletModule< AxialSegmentPairCreator >, FindletModule< AxialStraightTrackFinder >, FindletModule< AxialTrackCreatorMCTruth >, FindletModule< AxialTrackCreatorSegmentHough >, FindletModule< AxialTrackFinderHough >, FindletModule< AxialTrackFinderLegendre >, FindletModule< ClusterBackgroundDetector >, FindletModule< ClusterPreparer >, FindletModule< ClusterRefiner< BridgingWireHitRelationFilter > >, FindletModule< FacetCreator >, FindletModule< HitReclaimer >, FindletModule< MonopoleAxialTrackFinderLegendre >, FindletModule< MonopoleStereoHitFinder >, FindletModule< MonopoleStereoHitFinderQuadratic >, FindletModule< SegmentCreatorFacetAutomaton >, FindletModule< SegmentCreatorMCTruth >, FindletModule< SegmentFinderFacetAutomaton >, FindletModule< SegmentFitter >, FindletModule< SegmentLinker >, FindletModule< SegmentOrienter >, FindletModule< SegmentPairCreator >, FindletModule< SegmentRejecter >, FindletModule< SegmentTrackCombiner >, FindletModule< SegmentTripleCreator >, FindletModule< StereoHitFinder >, FindletModule< SuperClusterCreator >, FindletModule< TrackCombiner >, FindletModule< TrackCreatorSegmentPairAutomaton >, FindletModule< TrackCreatorSegmentTripleAutomaton >, FindletModule< TrackCreatorSingleSegments >, FindletModule< TrackExporter >, FindletModule< TrackFinderAutomaton >, FindletModule< TrackFinderCosmics >, FindletModule< TrackFinder >, FindletModule< TrackFinderSegmentPairAutomaton >, FindletModule< TrackFinderSegmentTripleAutomaton >, FindletModule< TrackFlightTimeAdjuster >, FindletModule< TrackLinker >, FindletModule< TrackOrienter >, FindletModule< TrackQualityAsserter >, FindletModule< TrackQualityEstimator >, FindletModule< TrackRejecter >, FindletModule< WireHitBackgroundDetector >, FindletModule< WireHitCreator >, FindletModule< WireHitPreparer >, CDCTriggerNeuroDQMModule, CDCTriggerNeuroDQMOnlineModule, CDCTriggerNDFinderModule, TRGCDCModule, TRGCDCETFUnpackerModule, TRGCDCT2DDQMModule, TRGCDCT3DConverterModule, TRGCDCT3DDQMModule, TRGCDCT3DUnpackerModule, TRGCDCTSFDQMModule, TRGCDCTSFUnpackerModule, TRGCDCTSStreamModule, MCMatcherTRGECLModule, TRGECLFAMModule, TRGECLModule, TRGECLBGTCHitModule, TRGECLDQMModule, TRGECLQAMModule, TRGECLRawdataAnalysisModule, TRGECLTimingCalModule, TRGECLUnpackerModule, TRGGDLModule, TRGEFFDQMModule, TRGGDLDQMModule, TRGGDLDSTModule, TRGGDLSummaryModule, TRGGDLUnpackerModule, TRGGRLMatchModule, TRGGRLModule, TRGGRLProjectsModule, TRGGRLDQMModule, TRGGRLUnpackerModule, KLMTriggerModule, TRGTOPDQMModule, TRGTOPTRD2TTSConverterModule, TRGTOPUnpackerModule, TRGTOPUnpackerWaveformModule, TRGTOPWaveformPlotterModule, TRGRAWDATAModule, DQMHistAnalysisARICHModule, DQMHistAnalysisARICHMonObjModule, DQMHistAnalysisCDCDedxModule, DQMHistAnalysisCDCEpicsModule, DQMHistAnalysisCDCMonObjModule, DQMHistAnalysisDAQMonObjModule, DQMHistAnalysisECLModule, DQMHistAnalysisECLConnectedRegionsModule, DQMHistAnalysisECLOutOfTimeDigitsModule, DQMHistAnalysisECLShapersModule, DQMHistAnalysisECLSummaryModule, DQMHistAnalysisEpicsExampleModule, DQMHistAnalysisExampleModule, DQMHistAnalysisExampleFlagsModule, DQMHistAnalysisHLTMonObjModule, DQMHistAnalysisInput2Module, DQMHistAnalysisInputPVSrvModule, DQMHistAnalysisInputTestModule, DQMHistAnalysisKLMModule, DQMHistAnalysisKLM2Module, DQMHistAnalysisMiraBelleModule, DQMHistAnalysisMonObjModule, DQMHistAnalysisOutputFileModule, DQMHistAnalysisOutputMonObjModule, DQMHistAnalysisOutputRelayMsgModule, DQMHistAnalysisPXDFitsModule, DQMHistAnalysisSVDClustersOnTrackModule, DQMHistAnalysisSVDDoseModule, DQMHistAnalysisSVDEfficiencyModule, DQMHistAnalysisSVDGeneralModule, DQMHistAnalysisSVDOccupancyModule, DQMHistAnalysisSVDOnMiraBelleModule, DQMHistAnalysisSVDUnpackerModule, DQMHistAnalysisTOPModule, DQMHistAnalysisTRGECLModule, DQMHistAnalysisTRGEFFModule, DQMHistAnalysisTRGGDLModule, DQMHistComparitorModule, DQMHistDeltaHistoModule, DQMHistReferenceModule, DQMHistSnapshotsModule, PyModule, SVDUnpackerDQMModule, TrackSetEvaluatorHopfieldNNDEVModule, vxdDigitMaskingModule, DQMHistAnalysisDeltaEpicsMonObjExampleModule, DQMHistAnalysisDeltaTestModule, DQMHistAnalysisEpicsOutputModule, DQMHistAnalysisPhysicsModule, DQMHistAnalysisPXDChargeModule, DQMHistAnalysisPXDTrackChargeModule, DQMHistAnalysisRooFitExampleModule, DQMHistAnalysisTRGModule, and DQMHistOutputToEPICSModule.

Definition at line 166 of file Module.h.

166{};

◆ evalCondition()

bool evalCondition ( ) const
inherited

If at least one condition was set, it is evaluated and true returned if at least one condition returns true.

If no condition or result value was defined, the method returns false. Otherwise, the condition is evaluated and true returned, if at least one condition returns true. To speed up the evaluation, the condition strings were already parsed in the method if_value().

Returns
True if at least one condition and return value exists and at least one condition expression was evaluated to true.

Definition at line 96 of file Module.cc.

97{
98 if (m_conditions.empty()) return false;
99
100 //okay, a condition was set for this Module...
101 if (!m_hasReturnValue) {
102 B2FATAL("A condition was set for '" << getName() << "', but the module did not set a return value!");
103 }
104
105 for (const auto& condition : m_conditions) {
106 if (condition.evaluate(m_returnValue)) {
107 return true;
108 }
109 }
110 return false;
111}
int m_returnValue
The return value.
Definition: Module.h:519
bool m_hasReturnValue
True, if the return value is set.
Definition: Module.h:518

◆ event()

void event ( void  )
overridevirtual

event: try to find the appropriate TrueHit to all SpacePoints

Reimplemented from Module.

Definition at line 196 of file SpacePoint2TrueHitConnectorModule.cc.

197{
198 StoreObjPtr<EventMetaData> eventMetaDataPtr("EventMetaData", DataStore::c_Event);
199 const int eventCtr = eventMetaDataPtr->getEvent();
200 B2DEBUG(20, "SpacePoint2TrueHitConnector::event(). Processing event " << eventCtr << " -----------------------");
201
202 if (m_PARAMpositionAnalysis) m_rootVariables = RootVariables(); // clear the rootVariables for every event
203
204 // loop over all containers
205 for (m_iCont = 0; m_iCont < m_nContainers; ++m_iCont) {
206 StoreArray<SpacePoint> spacePoints = m_inputSpacePoints.at(m_iCont).first;
207 const int nSpacePoints = spacePoints.getEntries();
208 e_detTypes detType = m_inputSpacePoints.at(m_iCont).second;
209 std::string detTypeStr = detType == c_SVD ? "SVD" : "PXD";
210 B2DEBUG(20, "Found " << nSpacePoints << " SpacePoints in Array " << m_inputSpacePoints.at(m_iCont).first.getName() <<
211 " for this event. detType: " << detTypeStr);
212
213 m_SpacePointsCtr.at(m_iCont) += nSpacePoints;
214
215 for (int iSP = 0; iSP < nSpacePoints; ++iSP) {
216 SpacePoint* spacePoint = spacePoints[iSP];
217 B2DEBUG(21, "Processing SpacePoint " << iSP << " from " << nSpacePoints);
218
219 baseMapT trueHitMap = processSpacePoint<baseMapT>(spacePoint, detType);
220 if (trueHitMap.empty()) continue; // next SpacePoint if something went wrong
221
222 unsigned int nUniqueTHs = getUniqueSize(trueHitMap);
223 B2DEBUG(23, "Found " << nUniqueTHs << " TrueHits (unique) related to SpacePoint " << spacePoint->getArrayIndex() << " from Array "
224 << spacePoint->getArrayName());
225 unsigned int iRels = nUniqueTHs > 4 ? 4 : nUniqueTHs - 1;
226 m_nRelTrueHitsCtr.at(m_iCont).at(iRels)++;
227
228 // print the complete map if the debug level is set high enough
229 if (LogSystem::Instance().isLevelEnabled(LogConfig::c_Debug, 350, PACKAGENAME())) {
230 std::string mapCont = printMap(trueHitMap);
231 B2DEBUG(24, "The TrueHits and their weights for spacePoint " << spacePoint->getArrayIndex() << ": " + mapCont);
232 }
233
234 int thIndex = -1; // declare negative and only assign a value if ONE relation gets registered! (see doc of positionAnalysis)
235 if (m_PARAMregisterAll) {
236 registerAllRelations(spacePoint, trueHitMap, detType);
237 } else { // find THE ONE TrueHit (to rule them all, one TrueHit to find them all ...)
238 // COULDDO: wrap this up in a function
239 std::pair<VXDTrueHit*, double> trueHitwWeight;
240
241 if (detType == c_PXD) trueHitwWeight = getTHwithWeight<baseMapT, PXDTrueHit>(trueHitMap, m_PXDTrueHits, spacePoint, c_PXD);
242 else trueHitwWeight = getTHwithWeight<baseMapT, SVDTrueHit>(trueHitMap, m_SVDTrueHits, spacePoint, c_SVD);
243
244 if (trueHitwWeight.first != nullptr) {
245 registerOneRelation(spacePoint, trueHitwWeight, detType);
246 thIndex = trueHitwWeight.first->getArrayIndex();
247 } else {
248 B2DEBUG(20, "Could not relate one TrueHit to SpacePoint " << spacePoint->getArrayIndex() << ".");
250 }
251 }
252
253 if (m_PARAMpositionAnalysis) { positionAnalysis(spacePoint, trueHitMap, thIndex, detType); }
254 } // end loop SpacePoints
255 } // end loop containers
256 if (m_PARAMpositionAnalysis) { m_treePtr->Fill(); }
257}
@ 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
std::vector< unsigned int > m_SpacePointsCtr
Number of SpacePoints presented to the module.
unsigned int m_nContainers
number of passed containers -> storing the size of an input vector for not having to obtain it every ...
RootVariables m_rootVariables
Root variables used for collecting data eventwise.
std::vector< unsigned int > m_rejectedRelsCtr
Number of SpacePoints that were not related to a TrueHit (i.e.
void registerAllRelations(Belle2::SpacePoint *spacePoint, MapType trueHitMap, e_detTypes detType)
register a Relation to all the TrueHits in the trueHitMap for the passed SpacePoint
std::vector< std::pair< Belle2::StoreArray< Belle2::SpacePoint >, e_detTypes > > m_inputSpacePoints
StoreArray of all input SpacePoints.
std::unordered_map< int, TrueHitInfo > baseMapT
typedef for shorter notation throughout the module
unsigned int m_iCont
'helper variable' needed to not have to pass one integer down to processSpacePoint only to have a han...
std::vector< std::array< unsigned int, 5 > > m_nRelTrueHitsCtr
counting different numbers of related TrueHits (to a SpacePoint) with one variable
void positionAnalysis(Belle2::SpacePoint *spacePoint, const MapType &trueHitMap, const int &index, e_detTypes detType)
Analyze the position of SpacePoints and corresponding TrueHits.
Belle2::StoreArray< Belle2::SVDTrueHit > m_SVDTrueHits
SVDTrueHits StoreArray used throughout the module.
Belle2::StoreArray< Belle2::PXDTrueHit > m_PXDTrueHits
PXDTrueHits StoreArray used throughout the module.
void registerOneRelation(Belle2::SpacePoint *spacePoint, std::pair< TrueHitType *, double > trueHitwWeight, e_detTypes)
register Relation between SpacePoint and TrueHit (and if necessary also between SpacePoint and Cluste...
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:42
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
unsigned int getUniqueSize(const MapType &aMap)
get the number of unique keys inside the map NOTE: for non-multimap this is the same as ....
std::string printMap(const MapType &aMap)
get the contents of the map as string.

◆ exposePythonAPI()

void exposePythonAPI ( )
staticinherited

Exposes methods of the Module class to Python.

Definition at line 325 of file Module.cc.

326{
327 // to avoid confusion between std::arg and boost::python::arg we want a shorthand namespace as well
328 namespace bp = boost::python;
329
330 docstring_options options(true, true, false); //userdef, py sigs, c++ sigs
331
332 void (Module::*setReturnValueInt)(int) = &Module::setReturnValue;
333
334 enum_<Module::EAfterConditionPath>("AfterConditionPath",
335 R"(Determines execution behaviour after a conditional path has been executed:
336
337.. attribute:: END
338
339 End processing of this path after the conditional path. (this is the default for if_value() etc.)
340
341.. attribute:: CONTINUE
342
343 After the conditional path, resume execution after this module.)")
344 .value("END", Module::EAfterConditionPath::c_End)
345 .value("CONTINUE", Module::EAfterConditionPath::c_Continue)
346 ;
347
348 /* Do not change the names of >, <, ... we use them to serialize conditional pathes */
349 enum_<Belle2::ModuleCondition::EConditionOperators>("ConditionOperator")
356 ;
357
358 enum_<Module::EModulePropFlags>("ModulePropFlags",
359 R"(Flags to indicate certain low-level features of modules, see :func:`Module.set_property_flags()`, :func:`Module.has_properties()`. Most useful flags are:
360
361.. attribute:: PARALLELPROCESSINGCERTIFIED
362
363 This module can be run in parallel processing mode safely (All I/O must be done through the data store, in particular, the module must not write any files.)
364
365.. attribute:: HISTOGRAMMANAGER
366
367 This module is used to manage histograms accumulated by other modules
368
369.. attribute:: TERMINATEINALLPROCESSES
370
371 When using parallel processing, call this module's terminate() function in all processes. This will also ensure that there is exactly one process (single-core if no parallel modules found) or at least one input, one main and one output process.
372)")
373 .value("INPUT", Module::EModulePropFlags::c_Input)
374 .value("OUTPUT", Module::EModulePropFlags::c_Output)
375 .value("PARALLELPROCESSINGCERTIFIED", Module::EModulePropFlags::c_ParallelProcessingCertified)
376 .value("HISTOGRAMMANAGER", Module::EModulePropFlags::c_HistogramManager)
377 .value("INTERNALSERIALIZER", Module::EModulePropFlags::c_InternalSerializer)
378 .value("TERMINATEINALLPROCESSES", Module::EModulePropFlags::c_TerminateInAllProcesses)
379 ;
380
381 //Python class definition
382 class_<Module, PyModule> module("Module", R"(
383Base class for Modules.
384
385A module is the smallest building block of the framework.
386A typical event processing chain consists of a Path containing
387modules. By inheriting from this base class, various types of
388modules can be created. To use a module, please refer to
389:func:`Path.add_module()`. A list of modules is available by running
390``basf2 -m`` or ``basf2 -m package``, detailed information on parameters is
391given by e.g. ``basf2 -m RootInput``.
392
393The 'Module Development' section in the manual provides detailed information
394on how to create modules, setting parameters, or using return values/conditions:
395https://xwiki.desy.de/xwiki/rest/p/f4fa4/#HModuleDevelopment
396
397)");
398 module
399 .def("__str__", &Module::getPathString)
400 .def("name", &Module::getName, return_value_policy<copy_const_reference>(),
401 "Returns the name of the module. Can be changed via :func:`set_name() <Module.set_name()>`, use :func:`type() <Module.type()>` for identifying a particular module class.")
402 .def("type", &Module::getType, return_value_policy<copy_const_reference>(),
403 "Returns the type of the module (i.e. class name minus 'Module')")
404 .def("set_name", &Module::setName, args("name"), R"(
405Set custom name, e.g. to distinguish multiple modules of the same type.
406
407>>> path.add_module('EventInfoSetter')
408>>> ro = path.add_module('RootOutput', branchNames=['EventMetaData'])
409>>> ro.set_name('RootOutput_metadata_only')
410>>> print(path)
411[EventInfoSetter -> RootOutput_metadata_only]
412
413)")
414 .def("description", &Module::getDescription, return_value_policy<copy_const_reference>(),
415 "Returns the description of this module.")
416 .def("package", &Module::getPackage, return_value_policy<copy_const_reference>(),
417 "Returns the package this module belongs to.")
418 .def("available_params", &_getParamInfoListPython,
419 "Return list of all module parameters as `ModuleParamInfo` instances")
420 .def("has_properties", &Module::hasProperties, (bp::arg("properties")),
421 R"DOCSTRING(Allows to check if the module has the given properties out of `ModulePropFlags` set.
422
423>>> if module.has_properties(ModulePropFlags.PARALLELPROCESSINGCERTIFIED):
424>>> ...
425
426Parameters:
427 properties (int): bitmask of `ModulePropFlags` to check for.
428)DOCSTRING")
429 .def("set_property_flags", &Module::setPropertyFlags, args("property_mask"),
430 "Set module properties in the form of an OR combination of `ModulePropFlags`.");
431 {
432 // python signature is too crowded, make ourselves
433 docstring_options subOptions(true, false, false); //userdef, py sigs, c++ sigs
434 module
435 .def("if_value", &Module::if_value,
436 (bp::arg("expression"), bp::arg("condition_path"), bp::arg("after_condition_path")= Module::EAfterConditionPath::c_End),
437 R"DOCSTRING(if_value(expression, condition_path, after_condition_path=AfterConditionPath.END)
438
439Sets a conditional sub path which will be executed after this
440module if the return value set in the module passes the given ``expression``.
441
442Modules can define a return value (int or bool) using ``setReturnValue()``,
443which can be used in the steering file to split the Path based on this value, for example
444
445>>> module_with_condition.if_value("<1", another_path)
446
447In case the return value of the ``module_with_condition`` for a given event is
448less than 1, the execution will be diverted into ``another_path`` for this event.
449
450You could for example set a special return value if an error occurs, and divert
451the execution into a path containing :b2:mod:`RootOutput` if it is found;
452saving only the data producing/produced by the error.
453
454After a conditional path has executed, basf2 will by default stop processing
455the path for this event. This behaviour can be changed by setting the
456``after_condition_path`` argument.
457
458Parameters:
459 expression (str): Expression to determine if the conditional path should be executed.
460 This should be one of the comparison operators ``<``, ``>``, ``<=``,
461 ``>=``, ``==``, or ``!=`` followed by a numerical value for the return value
462 condition_path (Path): path to execute in case the expression is fulfilled
463 after_condition_path (AfterConditionPath): What to do once the ``condition_path`` has been executed.
464)DOCSTRING")
465 .def("if_false", &Module::if_false,
466 (bp::arg("condition_path"), bp::arg("after_condition_path")= Module::EAfterConditionPath::c_End),
467 R"DOC(if_false(condition_path, after_condition_path=AfterConditionPath.END)
468
469Sets a conditional sub path which will be executed after this module if
470the return value of the module evaluates to False. This is equivalent to
471calling `if_value` with ``expression=\"<1\"``)DOC")
472 .def("if_true", &Module::if_true,
473 (bp::arg("condition_path"), bp::arg("after_condition_path")= Module::EAfterConditionPath::c_End),
474 R"DOC(if_true(condition_path, after_condition_path=AfterConditionPath.END)
475
476Sets a conditional sub path which will be executed after this module if
477the return value of the module evaluates to True. It is equivalent to
478calling `if_value` with ``expression=\">=1\"``)DOC");
479 }
480 module
481 .def("has_condition", &Module::hasCondition,
482 "Return true if a conditional path has been set for this module "
483 "using `if_value`, `if_true` or `if_false`")
484 .def("get_all_condition_paths", &_getAllConditionPathsPython,
485 "Return a list of all conditional paths set for this module using "
486 "`if_value`, `if_true` or `if_false`")
487 .def("get_all_conditions", &_getAllConditionsPython,
488 "Return a list of all conditional path expressions set for this module using "
489 "`if_value`, `if_true` or `if_false`")
490 .add_property("logging", make_function(&Module::getLogConfig, return_value_policy<reference_existing_object>()),
@ c_GE
Greater or equal than: ">=".
@ c_SE
Smaller or equal than: "<=".
@ c_GT
Greater than: ">"
@ c_NE
Not equal: "!=".
@ c_EQ
Equal: "=" or "=="
@ c_ST
Smaller than: "<"
Base class for Modules.
Definition: Module.h:72
LogConfig & getLogConfig()
Returns the log system configuration.
Definition: Module.h:225
void if_value(const std::string &expression, const std::shared_ptr< Path > &path, EAfterConditionPath afterConditionPath=EAfterConditionPath::c_End)
Add a condition to the module.
Definition: Module.cc:79
void if_true(const std::shared_ptr< Path > &path, EAfterConditionPath afterConditionPath=EAfterConditionPath::c_End)
A simplified version to set the condition of the module.
Definition: Module.cc:90
void setReturnValue(int value)
Sets the return value for this module as integer.
Definition: Module.cc:220
void setLogConfig(const LogConfig &logConfig)
Set the log system configuration.
Definition: Module.h:230
const std::string & getDescription() const
Returns the description of the module.
Definition: Module.h:202
void if_false(const std::shared_ptr< Path > &path, EAfterConditionPath afterConditionPath=EAfterConditionPath::c_End)
A simplified version to add a condition to the module.
Definition: Module.cc:85
bool hasCondition() const
Returns true if at least one condition was set for the module.
Definition: Module.h:311
const std::string & getPackage() const
Returns the package this module is in.
Definition: Module.h:197
void setName(const std::string &name)
Set the name of the module.
Definition: Module.h:214
bool hasProperties(unsigned int propertyFlags) const
Returns true if all specified property flags are available in this module.
Definition: Module.cc:160
std::string getPathString() const override
return the module name.
Definition: Module.cc:192

◆ getAfterConditionPath()

Module::EAfterConditionPath getAfterConditionPath ( ) const
inherited

What to do after the conditional path is finished.

(defaults to c_End if no condition is set)

Definition at line 133 of file Module.cc.

134{
135 if (m_conditions.empty()) return EAfterConditionPath::c_End;
136
137 //okay, a condition was set for this Module...
138 if (!m_hasReturnValue) {
139 B2FATAL("A condition was set for '" << getName() << "', but the module did not set a return value!");
140 }
141
142 for (const auto& condition : m_conditions) {
143 if (condition.evaluate(m_returnValue)) {
144 return condition.getAfterConditionPath();
145 }
146 }
147
148 return EAfterConditionPath::c_End;
149}

◆ getAllConditionPaths()

std::vector< std::shared_ptr< Path > > getAllConditionPaths ( ) const
inherited

Return all condition paths currently set (no matter if the condition is true or not).

Definition at line 150 of file Module.cc.

151{
152 std::vector<std::shared_ptr<Path>> allConditionPaths;
153 for (const auto& condition : m_conditions) {
154 allConditionPaths.push_back(condition.getPath());
155 }
156
157 return allConditionPaths;
158}

◆ getAllConditions()

const std::vector< ModuleCondition > & getAllConditions ( ) const
inlineinherited

Return all set conditions for this module.

Definition at line 324 of file Module.h.

325 {
326 return m_conditions;
327 }

◆ getClusterSizes()

std::pair< unsigned short int, unsigned short int > getClusterSizes ( Belle2::SpacePoint spacePoint,
e_detTypes  detType 
)
protected

get the sizes of the related Clusters of a SpacePoint

Returns
.first is U cluster size, .second is V cluster size

Definition at line 863 of file SpacePoint2TrueHitConnectorModule.cc.

865{
866 std::pair<unsigned short int, unsigned short int> clusterSizes = { 0, 0 };
867 if (detType == c_PXD) {
868 std::vector<std::pair<PXDCluster*, double> > relClusters = getRelatedClusters<PXDCluster>(spacePoint, m_PXDClusters.getName());
869 return std::make_pair(relClusters[0].first->getUSize(), relClusters[0].first->getVSize());
870 } else {
871 std::vector<std::pair<SVDCluster*, double> > relClusters = getRelatedClusters<SVDCluster>(spacePoint, m_SVDClusters.getName());
872 for (auto cluster : relClusters) {
873 if (cluster.first->isUCluster()) clusterSizes.first = cluster.first->getSize();
874 else clusterSizes.second = cluster.first->getSize();
875 }
876 }
877 return clusterSizes;
878}
Belle2::StoreArray< Belle2::PXDCluster > m_PXDClusters
PXDTClusters StoreArray used throughout the module.
Belle2::StoreArray< Belle2::SVDCluster > m_SVDClusters
PXDClusters StoreArray used throughout the module.
const std::string & getName() const
Return name under which the object is saved in the DataStore.

◆ getCondition()

const ModuleCondition * getCondition ( ) const
inlineinherited

Return a pointer to the first condition (or nullptr, if none was set)

Definition at line 314 of file Module.h.

315 {
316 if (m_conditions.empty()) {
317 return nullptr;
318 } else {
319 return &m_conditions.front();
320 }
321 }

◆ getConditionPath()

std::shared_ptr< Path > getConditionPath ( ) const
inherited

Returns the path of the last true condition (if there is at least one, else reaturn a null pointer).


Definition at line 113 of file Module.cc.

114{
115 PathPtr p;
116 if (m_conditions.empty()) return p;
117
118 //okay, a condition was set for this Module...
119 if (!m_hasReturnValue) {
120 B2FATAL("A condition was set for '" << getName() << "', but the module did not set a return value!");
121 }
122
123 for (const auto& condition : m_conditions) {
124 if (condition.evaluate(m_returnValue)) {
125 return condition.getPath();
126 }
127 }
128
129 // if none of the conditions were true, return a null pointer.
130 return p;
131}
std::shared_ptr< Path > PathPtr
Defines a pointer to a path object as a boost shared pointer.
Definition: Path.h:35

◆ getDescription()

const std::string & getDescription ( ) const
inlineinherited

Returns the description of the module.

Definition at line 202 of file Module.h.

202{return m_description;}
std::string m_description
The description of the module.
Definition: Module.h:511

◆ getFileNames()

virtual std::vector< std::string > getFileNames ( bool  outputFiles)
inlinevirtualinherited

Return a list of output filenames for this modules.

This will be called when basf2 is run with "--dry-run" if the module has set either the c_Input or c_Output properties.

If the parameter outputFiles is false (for modules with c_Input) the list of input filenames should be returned (if any). If outputFiles is true (for modules with c_Output) the list of output files should be returned (if any).

If a module has sat both properties this member is called twice, once for each property.

The module should return the actual list of requested input or produced output filenames (including handling of input/output overrides) so that the grid system can handle input/output files correctly.

This function should return the same value when called multiple times. This is especially important when taking the input/output overrides from Environment as they get consumed when obtained so the finalized list of output files should be stored for subsequent calls.

Reimplemented in RootInputModule, StorageRootOutputModule, and RootOutputModule.

Definition at line 134 of file Module.h.

135 {
136 return std::vector<std::string>();
137 }

◆ getLocalError()

std::pair< double, double > getLocalError ( Belle2::SpacePoint spacePoint)
protected

get the position error of SpacePoints in local coordinates

Returns
A pair of doubles. .first is U position error, .second is V position error

Definition at line 880 of file SpacePoint2TrueHitConnectorModule.cc.

881{
882 auto detType = spacePoint->getType();
883 std::pair<double, double> errors = { -1., -1. };
884 if (detType == VXD::SensorInfoBase::PXD) {
885 std::vector<std::pair<PXDCluster*, double> > relClusters = getRelatedClusters<PXDCluster>(spacePoint, m_PXDClusters.getName());
886 errors.first = relClusters[0].first->getUSigma();
887 errors.second = relClusters[0].first->getVSigma();
888 } else if (detType == VXD::SensorInfoBase::SVD) {
889 std::vector<std::pair<SVDCluster*, double> > relClusters = getRelatedClusters<SVDCluster>(spacePoint, m_SVDClusters.getName());
890 for (auto cluster : relClusters) {
891 if (cluster.first->isUCluster()) { errors.first = cluster.first->getPositionSigma(); }
892 else { errors.second = cluster.first->getPositionSigma(); }
893 }
894 } else {
895 B2ERROR("Detector type not known in SpacePoint2TrueHitConnector::getLocalError() !");
896 }
897
898 return errors;
899}
Belle2::VXD::SensorInfoBase::SensorType getType() const
Return SensorType (PXD, SVD, ...) on which the SpacePoint lives.
Definition: SpacePoint.h:145

◆ getLocalPos()

std::pair< double, double > getLocalPos ( Belle2::SpacePoint spacePoint)
protected

get the local position of a SpacePoint

Definition at line 784 of file SpacePoint2TrueHitConnectorModule.cc.

785{
786 // get the normalized local coordinates from SpacePoint and convert them to local coordinates (have to do so because at the slanted parts the local U-position is dependent on the local V-position)
787 // NOTE: second way is to convert the global position of the SpacePoint to local position via the sensorInfoBase (yields same results)
788 double normU = spacePoint->getNormalizedLocalU();
789 double normV = spacePoint->getNormalizedLocalV();
790 return spacePoint->convertNormalizedToLocalCoordinates(std::make_pair(normU, normV), spacePoint->getVxdID());
791}
double getNormalizedLocalV() const
Return normalized local coordinates of the cluster in v (0 <= posV <= 1).
Definition: SpacePoint.h:154
static std::pair< double, double > convertNormalizedToLocalCoordinates(const std::pair< double, double > &hitNormalized, Belle2::VxdID vxdID, const Belle2::VXD::SensorInfoBase *aSensorInfo=nullptr)
converts a hit in sensor-independent relative coordinates into local coordinate of given sensor.
Definition: SpacePoint.cc:178
double getNormalizedLocalU() const
Return normalized local coordinates of the cluster in u (0 <= posU <= 1).
Definition: SpacePoint.h:151

◆ getLogConfig()

LogConfig & getLogConfig ( )
inlineinherited

Returns the log system configuration.

Definition at line 225 of file Module.h.

225{return m_logConfig;}

◆ getModules()

std::list< ModulePtr > getModules ( ) const
inlineoverrideprivatevirtualinherited

no submodules, return empty list

Implements PathElement.

Definition at line 506 of file Module.h.

506{ return std::list<ModulePtr>(); }

◆ getName()

const std::string & getName ( ) const
inlineinherited

Returns the name of the module.

This can be changed via e.g. set_name() in the steering file to give more useful names if there is more than one module of the same type.

For identifying the type of a module, using getType() (or type() in Python) is recommended.

Definition at line 187 of file Module.h.

187{return m_name;}
std::string m_name
The name of the module, saved as a string (user-modifiable)
Definition: Module.h:508

◆ getPackage()

const std::string & getPackage ( ) const
inlineinherited

Returns the package this module is in.

Definition at line 197 of file Module.h.

197{return m_package;}

◆ getParamInfoListPython()

std::shared_ptr< boost::python::list > getParamInfoListPython ( ) const
inherited

Returns a python list of all parameters.

Each item in the list consists of the name of the parameter, a string describing its type, a python list of all default values and the description of the parameter.

Returns
A python list containing the parameters of this parameter list.

Definition at line 279 of file Module.cc.

280{
282}
std::shared_ptr< boost::python::list > getParamInfoListPython() const
Returns a python list of all parameters.
ModuleParamList m_moduleParamList
List storing and managing all parameter of the module.
Definition: Module.h:516

◆ getParamList()

const ModuleParamList & getParamList ( ) const
inlineinherited

Return module param list.

Definition at line 363 of file Module.h.

363{ return m_moduleParamList; }

◆ getPathString()

std::string getPathString ( ) const
overrideprivatevirtualinherited

return the module name.

Implements PathElement.

Definition at line 192 of file Module.cc.

193{
194
195 std::string output = getName();
196
197 for (const auto& condition : m_conditions) {
198 output += condition.getString();
199 }
200
201 return output;
202}

◆ getRelatedClusters()

std::vector< std::pair< ClusterType *, double > > getRelatedClusters ( Belle2::SpacePoint spacePoint,
std::string  clusterName = "ALL" 
)
protected

get the pointers to the related Clusters and the weight of the original Relations between the spacePoint and these Clusters

Definition at line 492 of file SpacePoint2TrueHitConnectorModule.cc.

494{
495 std::vector<std::pair<ClusterType*, double> > indsAndWeights;
496 RelationVector<ClusterType> relClusters = spacePoint->getRelationsTo<ClusterType>(clusterName);
497
498 for (unsigned int iCl = 0; iCl < relClusters.size(); ++iCl) {
499 indsAndWeights.push_back(std::make_pair(relClusters[iCl], relClusters.weight(iCl)));
500 }
501
502 // safety measure, should not / cannot happen (checked before)
503 if (indsAndWeights.empty()) { B2ERROR("No Clusters related to SpacePoint " << spacePoint->getArrayIndex() << "!"); }
504
505 return indsAndWeights;
506}
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
float weight(int index) const
Get weight with index.
RelationVector< TO > getRelationsTo(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from this object to another store array.

◆ getRelatedTrueHits()

MapType getRelatedTrueHits ( Belle2::SpacePoint spacePoint,
std::string  clusterName = "ALL",
std::string  trueHitName = "ALL" 
)
protected

get all the related TrueHits to the SpacePoint, including their weights in a map (multimap!) where the StoreArray indices of the TrueHits are the keys and the values are TrueHitInfos to these indices MapType has to have key value pairs of pair<int,TrueHitInfo> throws: + NoTrueHitToCluster

  • NoSpacePointToCluster
    Parameters
    spacePointpointer to the SpacePoint of interest
    clusterNameName of the StoreArray of Clusters to be searched (defaults to "ALL")
    trueHitNameName of the StoreArray of TrueHits to be searched (defaults to "ALL")
    Returns
    multimap containing the related TrueHitInfos

Definition at line 330 of file SpacePoint2TrueHitConnectorModule.cc.

332{
333 MapType trueHitsMap; // map to be filled with indices (keys) and weights (values)
334
335 RelationVector<ClusterType> spacePointClusters = spacePoint->getRelationsTo<ClusterType>(clusterName);
336 if (spacePointClusters.size() == 0) {
337 B2DEBUG(20, "Found no related Cluster for SpacePoint " << spacePoint->getArrayIndex() << " from Array " <<
338 spacePoint->getArrayIndex());
339 throw NoClusterToSpacePoint();
340 }
341 B2DEBUG(24, "Found " << spacePointClusters.size() << " related Clusters to SpacePoint " << spacePoint->getArrayIndex() <<
342 " from Array " << spacePoint->getArrayName());
343
344 // loop over all Clusters, get all TrueHits from them and add the information to the map
345 short noTrueHits = 0;
346 for (size_t iCl = 0; iCl < spacePointClusters.size(); ++iCl) {
347
348 const ClusterType* cluster = spacePointClusters[iCl];
349 RelationVector<TrueHitType> clusterTrueHits = cluster->template getRelationsTo<TrueHitType>(trueHitName);
350 if (clusterTrueHits.size() == 0) {
351 B2DEBUG(20, "Found no related TrueHit for Cluster " << cluster->getArrayIndex() << " contained by SpacePoint " <<
352 spacePoint->getArrayIndex() << " from Array " << spacePoint->getArrayName());
353 noTrueHits++;
354 } else {
355 B2DEBUG(26, "Found " << clusterTrueHits.size() << " related TrueHits to Cluster " << cluster->getArrayIndex() << " from Array " <<
356 cluster->getArrayName());
357
358 for (unsigned int i = 0; i < clusterTrueHits.size(); ++i) { // 'TrueHit' loop
359 if ((clusterTrueHits.weight(i) < m_PARAMminWeight) && !m_PARAMregisterAll) {
361 continue; // not take into account relations with too little weight
362 }
363 int index = clusterTrueHits[i]->getArrayIndex();
364 if (trueHitsMap.find(index) == trueHitsMap.end()) { // create entry only if it is not already in the map
365 trueHitsMap[index] = TrueHitInfo(index);
366 B2DEBUG(29, "Added new TrueHitInfo to map. Index " << index);
367 }
368 if (spacePointClusters.weight(iCl) > 0) {
369 trueHitsMap[index].setUWeight(clusterTrueHits.weight(i));
370 B2DEBUG(29, "Added UCluster to TrueHitInfo with index " << index);
371 } else {
372 trueHitsMap[index].setVWeight(clusterTrueHits.weight(i));
373 B2DEBUG(29, "Added VCluster to TrueHitInfo with index " << index);
374 }
375 }
376 }
377 }
378 // check if there was no Cluster with a related TrueHit -> then throw
379 if (noTrueHits == spacePoint->getNClustersAssigned()) {
380 m_noTrueHitCtr[m_iCont]++; // increase counter for current container
381 }
382 return trueHitsMap;
383}
unsigned int m_weightTooSmallCtr
Count the omitted relations because of a too small weight.
std::vector< unsigned int > m_noTrueHitCtr
Number of SpacePoints that contained a Cluster to which no TrueHit could be found (i....
unsigned short getNClustersAssigned() const
Returns the number of Clusters assigned to this SpacePoint.
Definition: SpacePoint.h:165
helper struct that holds information that is needed for the registration of the relation between Spac...

◆ getReturnValue()

int getReturnValue ( ) const
inlineinherited

Return the return value set by this module.

This value is only meaningful if hasReturnValue() is true

Definition at line 381 of file Module.h.

381{ return m_returnValue; }

◆ getTHwithWeight()

std::pair< TrueHitType *, double > getTHwithWeight ( const MapType &  aMap,
Belle2::StoreArray< TrueHitType >  trueHits,
Belle2::SpacePoint spacePoint,
e_detTypes  detType 
)
protected

get the TrueHit from information that is stored in the map (conditions are checked in the following order):

  • if there is only one TrueHit in the map, return a pointer to it and as weight the information which Clusters of the SpacePoint are related to this TrueHit (1 -> PXD, 2 -> both Clusters, 11 -> only U-, 21 -> only V-Cluster)
  • if there is only one TrueHit in the map with two weights associated (and all other TrueHits have only one weight or there is no other TrueHit), return a pointer to it and the weight is 2
  • if there are more than one TrueHits with two weights associated, return the one with the biggest sum of weights (.second = 2)
  • if there are only TrueHits with one weight associated, return the one with the biggest weight ONLY if the SpacePoint is related to only one Cluster (e.g. PXD). .second is either 1 (PXD), 11 or 21 (U-/V-cluster SP) NOTE: as this method is rather specific, it is not very much templated! NOTE: the possible return of a nullptr pointer has to be handled!

Definition at line 627 of file SpacePoint2TrueHitConnectorModule.cc.

629{
630 std::vector<TrueHitInfo> trueHitInfos = getAllValues(aMap);
631 std::pair<TrueHitType*, double> THwithWeight(nullptr, 0.0); // default return value
632 // return nullptr pointer and zero weight if there is no TrueHit (safety measure that should not actually be needed!)
633 if (trueHitInfos.empty()) return THwithWeight;
634 std::sort(trueHitInfos.begin(), trueHitInfos.end()); // sort to have best candidates at beginning
635
636 short nClusters = spacePoint->getNClustersAssigned();
637 size_t nRelations = trueHitInfos.size(); // get the number of possible relations
638
639 B2DEBUG(23, "Trying to select one TrueHit for SpacePoint " << spacePoint->getArrayIndex() << " from Array " <<
640 spacePoint->getArrayName() << ". SpacePoint has " << nClusters << " Clusters.");
641 B2DEBUG(25, "There are " << nRelations << " possible candidates.");
642
643 // very verbose output only to have a look on why these TrueHits could be in the same SpacePoint, COULDDO: wrap up in function
644 if (LogSystem::Instance().isLevelEnabled(LogConfig::c_Debug, 999, PACKAGENAME())) {
645 std::stringstream output;
646 output << "The candidates are: ";
647 for (auto& info : trueHitInfos) { output << info; }
648 B2DEBUG(29, output.str());
649
650 std::pair<double, double> spacePointLocal = getLocalPos(spacePoint);
651 std::pair<bool, bool> assignedLocal = spacePoint->getIfClustersAssigned();
652
653 B2DEBUG(29, "SpacePoint " << spacePoint->getArrayIndex() << " U: " << spacePointLocal.first << " V: " << spacePointLocal.second <<
654 " assigned: " << assignedLocal.first << ", " << assignedLocal.second);
655
656 std::vector<int> uniqueKeys = getUniqueKeys(aMap);
657 for (int key : uniqueKeys) {
658 TrueHitType* trueHit = trueHits[key];
659 // NOTE: assuming here that there is only one MCParticle to each TrueHit
660 MCParticle* mcParticle = trueHit->template getRelatedFrom<MCParticle>("ALL");
661
662 int mcPartId = -1, pdgCode = 0;
663 bool primary = false;
664
665 if (mcParticle != nullptr) {
666 mcPartId = mcParticle->getArrayIndex();
667 primary = mcParticle->hasStatus(MCParticle::c_PrimaryParticle);
668 pdgCode = mcParticle->getPDG();
669 }
670
671 B2DEBUG(29, "TrueHit " << key << " U: " << trueHit->getU() << ", V: " << trueHit->getV() << " mc Particle Id: " << mcPartId <<
672 ", primary " << primary << ", pdg: " << pdgCode);
673 }
674 }
675
676 // loop over all TrueHitInfos and check if the number of related Clusters is equal to the number of the number of the assigned
677 // Clusters in the SpacePoint -> if so, check for compatibility and return (the first that is compatible)
678 bool ghostHit = false;
679 for (const TrueHitInfo& info : trueHitInfos) {
680 B2DEBUG(28, "Now checking trueHit: " << info);
681 if (nClusters == info.getNClusters()) {
682 TrueHitType* trueHit = trueHits[info.m_Id];
683 if (compatibleCombination(spacePoint, trueHit)) {
684 double weight = (detType == c_PXD ? 1 : calculateRelationWeight(info, spacePoint)); // if PXD weight is always 1!
685 return std::make_pair(trueHit, weight);
686 }
687 } else {
688 B2DEBUG(28, "The number of related Clusters ( = " << nClusters << ") and the number of associated weights ( = " <<
689 info.getNClusters() << ") do not match! This indicates a ghost hit");
690 ghostHit = true;
691 }
692 }
693 if (ghostHit) m_ghostHitCtr[m_iCont]++;
694
695 // B2DEBUG(28, "just before return in getTHwithWeight")
696 return THwithWeight;
697}
int getArrayIndex() const
Get 0-based index of the particle in the corresponding MCParticle list.
Definition: MCParticle.h:244
int getPDG() const
Return PDG code of particle.
Definition: MCParticle.h:112
double calculateRelationWeight(const TrueHitInfo &trueHitInfo, Belle2::SpacePoint *spacePoint)
calculate the Relation weight to be used (for SVD only, although method works with PXD as well!...
bool compatibleCombination(Belle2::SpacePoint *spacePoint, TrueHitType *trueHit)
compares the TrueHit and the SpacePoint positions (global) to decide whether they are compatible NOTE...
std::vector< unsigned int > m_ghostHitCtr
Number of SpacePoints that are considered ghost hits.
std::vector< typename MapType::key_type > getUniqueKeys(const MapType &aMap)
get the unique keys of a map (i.e.
std::vector< typename MapType::mapped_type > getAllValues(const MapType &aMap)
get all values in the map (i.e.

◆ getTrueHitPositions()

std::pair< ROOT::Math::XYZVector, ROOT::Math::XYZVector > getTrueHitPositions ( TrueHitType *  trueHit)
protected

get the local (.first) and global (.second) position of a TrueHit (passed by index)

Definition at line 795 of file SpacePoint2TrueHitConnectorModule.cc.

796{
797// TrueHitType* trueHit = trueHits[index];
798 const ROOT::Math::XYZVector localPos = ROOT::Math::XYZVector(trueHit->getU(), trueHit->getV(), 0);
799
800 const VxdID trueHitVxdId = trueHit->getSensorID();
801 VXD::SensorInfoBase SensorInfoBase = VXD::GeoCache::getInstance().getSensorInfo(trueHitVxdId);
802 const ROOT::Math::XYZVector globalPos = SensorInfoBase.pointToGlobal(localPos, true); // uses alignment
803
804 return std::make_pair(localPos, globalPos);
805}

◆ getType()

const std::string & getType ( ) const
inherited

Returns the type of the module (i.e.

class name minus 'Module')

Definition at line 41 of file Module.cc.

42{
43 if (m_type.empty())
44 B2FATAL("Module type not set for " << getName());
45 return m_type;
46}
std::string m_type
The type of the module, saved as a string.
Definition: Module.h:509

◆ hasCondition()

bool hasCondition ( ) const
inlineinherited

Returns true if at least one condition was set for the module.

Definition at line 311 of file Module.h.

311{ return not m_conditions.empty(); };

◆ hasProperties()

bool hasProperties ( unsigned int  propertyFlags) const
inherited

Returns true if all specified property flags are available in this module.

Parameters
propertyFlagsOred EModulePropFlags which should be compared with the module flags.

Definition at line 160 of file Module.cc.

161{
162 return (propertyFlags & m_propertyFlags) == propertyFlags;
163}

◆ hasReturnValue()

bool hasReturnValue ( ) const
inlineinherited

Return true if this module has a valid return value set.

Definition at line 378 of file Module.h.

378{ return m_hasReturnValue; }

◆ hasUnsetForcedParams()

bool hasUnsetForcedParams ( ) const
inherited

Returns true and prints error message if the module has unset parameters which the user has to set in the steering file.

Definition at line 166 of file Module.cc.

167{
169 std::string allMissing = "";
170 for (const auto& s : missing)
171 allMissing += s + " ";
172 if (!missing.empty())
173 B2ERROR("The following required parameters of Module '" << getName() << "' were not specified: " << allMissing <<
174 "\nPlease add them to your steering file.");
175 return !missing.empty();
176}
std::vector< std::string > getUnsetForcedParams() const
Returns list of unset parameters (if they are required to have a value.

◆ if_false()

void if_false ( const std::shared_ptr< Path > &  path,
EAfterConditionPath  afterConditionPath = EAfterConditionPath::c_End 
)
inherited

A simplified version to add a condition to the module.

Please note that successive calls of this function will add more than one condition to the module. If more than one condition results in true, only the last of them will be used.

Please be careful: Avoid creating cyclic paths, e.g. by linking a condition to a path which is processed before the path where this module is located in.

It is equivalent to the if_value() method, using the expression "<1". This method is meant to be used together with the setReturnValue(bool value) method.

Parameters
pathShared pointer to the Path which will be executed if the return value is false.
afterConditionPathWhat to do after executing 'path'.

Definition at line 85 of file Module.cc.

86{
87 if_value("<1", path, afterConditionPath);
88}

◆ if_true()

void if_true ( const std::shared_ptr< Path > &  path,
EAfterConditionPath  afterConditionPath = EAfterConditionPath::c_End 
)
inherited

A simplified version to set the condition of the module.

Please note that successive calls of this function will add more than one condition to the module. If more than one condition results in true, only the last of them will be used.

Please be careful: Avoid creating cyclic paths, e.g. by linking a condition to a path which is processed before the path where this module is located in.

It is equivalent to the if_value() method, using the expression ">=1". This method is meant to be used together with the setReturnValue(bool value) method.

Parameters
pathShared pointer to the Path which will be executed if the return value is true.
afterConditionPathWhat to do after executing 'path'.

Definition at line 90 of file Module.cc.

91{
92 if_value(">=1", path, afterConditionPath);
93}

◆ if_value()

void if_value ( const std::string &  expression,
const std::shared_ptr< Path > &  path,
EAfterConditionPath  afterConditionPath = EAfterConditionPath::c_End 
)
inherited

Add a condition to the module.

Please note that successive calls of this function will add more than one condition to the module. If more than one condition results in true, only the last of them will be used.

See https://xwiki.desy.de/xwiki/rest/p/a94f2 or ModuleCondition for a description of the syntax.

Please be careful: Avoid creating cyclic paths, e.g. by linking a condition to a path which is processed before the path where this module is located in.

Parameters
expressionThe expression of the condition.
pathShared pointer to the Path which will be executed if the condition is evaluated to true.
afterConditionPathWhat to do after executing 'path'.

Definition at line 79 of file Module.cc.

80{
81 m_conditions.emplace_back(expression, path, afterConditionPath);
82}

◆ initialize()

void initialize ( void  )
overridevirtual

initialize: initialize counters, check StoreArrays, register StoreArrays, ...

Reimplemented from Module.

Definition at line 104 of file SpacePoint2TrueHitConnectorModule.cc.

105{
106 B2INFO("SpacePoint2TrueHitConnector -------------------------- initialize --------------------------------");
107
108 m_nContainers = m_PARAMspacePointNames.size(); // get number of passed arrays
109 unsigned int nTHNames = m_PARAMtrueHitNames.size();
110 unsigned int nDetTypes = m_PARAMdetectorTypes.size();
111 unsigned int nClNames = m_PARAMclusterNames.size();
112 if (m_nContainers < nTHNames || m_nContainers < nDetTypes || m_nContainers < nClNames) {
113 B2FATAL("Passed " << nTHNames << " TrueHitNames and " << nDetTypes << " DetectorTypes but number of passed SpacePointArrays is " <<
115 }
116 if ((nTHNames != nDetTypes) || (nClNames != nTHNames)) {
117 B2FATAL("Passed " << nTHNames << " TrueHitNames and " << nClNames << "ClusterNames but " << nDetTypes << " DetectorTypes!");
118 }
119
120 for (unsigned int i = 0; i < m_nContainers; ++i) {
121 if (i < nDetTypes) { // handle the detector types
122 std::string detType = m_PARAMdetectorTypes.at(i);
123 if (detType.compare(std::string("SVD")) != 0 && detType.compare(std::string("PXD")) != 0) {
124 B2FATAL("Found entry " << detType << " in DetectorTypes, but only 'PXD' and 'SVD' are allowed!");
125 }
126 if (detType.compare(std::string("SVD")) == 0) {
127 m_detectorTypes.push_back(c_SVD);
132 } else {
133 m_detectorTypes.push_back(c_PXD);
138 }
139 } else { m_detectorTypes.push_back(m_detectorTypes.at(i - 1)); } // add the last entry again
140
142 m_inputSpacePoints.at(i).first.isRequired();
143
144 // add counters
145 m_SpacePointsCtr.push_back(0);
146 m_nRelTrueHitsCtr.push_back(std::array<unsigned int, 5>());
147 m_noClusterCtr.push_back(0);
148 m_noTrueHitCtr.push_back(0);
149 m_regRelationsCtr.push_back(0);
150 m_ghostHitCtr.push_back(0);
151 m_rejectedRelsCtr.push_back(0);
152 }
153
155 if (m_PARAMoutputSuffix.empty()) {
156 B2WARNING("'outputSuffix' is empty and 'storeSeperate' is set to true. This would lead to StoreArrays with the same name. Resetting to 'outputSuffix' to '_relTH'!");
157 m_PARAMoutputSuffix = "_relTH";
158 }
159
160 for (unsigned int i = 0; i < m_nContainers; ++i) {
161 std::string name = m_inputSpacePoints.at(i).first.getName() + m_PARAMoutputSuffix;
164
165 // register relations (detector dependent)
166 if (m_inputSpacePoints.at(i).second == c_SVD) {
169 } else {
172 }
173 }
174 } else {
175 for (unsigned int i = 0; i < m_nContainers; ++i) {
176 if (m_inputSpacePoints.at(i).second == c_SVD) {
178 } else {
180 }
181 }
182 }
183
184 m_maxGlobalDiff = m_PARAMmaxGlobalDiff * m_PARAMmaxGlobalDiff; // only comparing squared values in module!
185// m_PARAMmaxLocalDiff *= m_PARAMmaxLocalDiff;
186
187 if (m_PARAMmaxPosSigma < 0) {
188 B2WARNING("'maxPosSigma' is set to a value below 0: " << m_PARAMmaxPosSigma << "! Resetting to default (4)!");
190 }
191
193}
@ 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
std::vector< unsigned int > m_noClusterCtr
Number of SpacePoints without relation to a Cluster (i.e.
void initializeRootFile()
initialize the root file that is used for output
std::vector< unsigned int > m_regRelationsCtr
Number of registered relations.
std::vector< Belle2::StoreArray< Belle2::SpacePoint > > m_outputSpacePoints
StoreArray of all output SpacePoints.
std::vector< e_detTypes > m_detectorTypes
storing the detector types for each container in vector, needed in initialize
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.

◆ initializeCounters()

void initializeCounters ( )
protected

initialize all counters to 0 WARNING: only call in constructor of module!

Definition at line 386 of file SpacePoint2TrueHitConnectorModule.cc.

387{
388 // NEW
389 for (unsigned int i = 0; i < m_SpacePointsCtr.size(); ++i) {
390 m_SpacePointsCtr.at(i) = 0;
391 m_regRelationsCtr.at(i) = 0;
392 m_noClusterCtr.at(i) = 0;
393 m_ghostHitCtr.at(i) = 0;
394 m_noTrueHitCtr.at(i) = 0;
395 m_rejectedRelsCtr.at(i) = 0;
396
397 for (unsigned int j = 0; j < m_nRelTrueHitsCtr.at(i).size(); ++j) { m_nRelTrueHitsCtr.at(i).at(j) = 0; }
398 }
399
402
403 // initialize the following here because of cppcheck complaining (not initialized in constructor)
404 m_nContainers = 0;
405 m_maxGlobalDiff = 0.;
406 m_iCont = 0;
407
408// m_negWeightCtr = 0;
409// m_totWeightsCtr = 0;
410// m_moreThan2Weights = 0;
411//
412// m_single2WTHCtr = 0;
413// m_nonSingle2WTHCtr = 0;
414// m_all2WTHCtr = 0;
415// m_accSingle2WTHCtr = 0;
416// m_accNonSingle2WTHCtr = 0;
417// m_accAll2WTHCtr = 0;
418//
419// m_oneCluster2THCtr = 0;
420//
421
422}

◆ initializeRootFile()

void initializeRootFile ( )
protected

initialize the root file that is used for output

Definition at line 808 of file SpacePoint2TrueHitConnectorModule.cc.

809{
810 if (m_PARAMrootFileName.size() != 2 || (m_PARAMrootFileName[1] != "UPDATE" && m_PARAMrootFileName[1] != "RECREATE")) {
811 std::string output;
812 for (std::string entry : m_PARAMrootFileName) {
813 output += "'" + entry + "' ";
814 }
815 B2FATAL("CurlingTrackCandSplitter::initialize() : rootFileName is set wrong: entries are: " << output);
816 }
817
818 std::string fileName = m_PARAMrootFileName[0] + ".root";
819 m_rootFilePtr = new TFile(fileName.c_str(), m_PARAMrootFileName[1].c_str());
820 m_treePtr = new TTree("PosAnaTree", "Position Analysis");
821
822 // link the variables
823 m_treePtr->Branch("SPLocalU", &m_rootVariables.SpacePointULocal);
824 m_treePtr->Branch("SPLocalV", &m_rootVariables.SpacePointVLocal);
825 m_treePtr->Branch("SPGlobalX", &m_rootVariables.SpacePointXGlobal);
826 m_treePtr->Branch("SPGlobalY", &m_rootVariables.SpacePointYGlobal);
827 m_treePtr->Branch("SPGlobalZ", &m_rootVariables.SpacePointZGlobal);
828
829 m_treePtr->Branch("THLocalU", &m_rootVariables.TrueHitULocal);
830 m_treePtr->Branch("THLocalV", &m_rootVariables.TrueHitVLocal);
831 m_treePtr->Branch("THGlobalX", &m_rootVariables.TrueHitXGlobal);
832 m_treePtr->Branch("THGlobalY", &m_rootVariables.TrueHitYGlobal);
833 m_treePtr->Branch("THGlobalZ", &m_rootVariables.TrueHitZGlobal);
834
835 m_treePtr->Branch("WeightU", &m_rootVariables.WeightU);
836 m_treePtr->Branch("WeightV", &m_rootVariables.WeightV);
837
838 m_treePtr->Branch("relStatus", &m_rootVariables.RelationStatus);
839 m_treePtr->Branch("VxdID", &m_rootVariables.HitVxdID);
840 m_treePtr->Branch("nRelations", &m_rootVariables.NRelations);
841
842 m_treePtr->Branch("clusterSizeU", &m_rootVariables.ClusterSizeU);
843 m_treePtr->Branch("clusterSizeV", &m_rootVariables.ClusterSizeV);
844 m_treePtr->Branch("SPErrorU", &m_rootVariables.SpacePointErrorU);
845 m_treePtr->Branch("SPErrorV", &m_rootVariables.SpacePointErrorV);
846 m_treePtr->Branch("SPErrorX", &m_rootVariables.SpacePointErrorX);
847 m_treePtr->Branch("SPErrorY", &m_rootVariables.SpacePointErrorY);
848 m_treePtr->Branch("SPErrorZ", &m_rootVariables.SpacePointErrorZ);
849}
std::vector< unsigned int > ClusterSizeV
size of the v-cluster (resp.
std::vector< double > WeightV
weight of the relation between the V-Cluster of the SpacePoint and the TrueHit
std::vector< double > SpacePointErrorZ
positiion error of SpacePoint in Z direction (global)
std::vector< double > TrueHitXGlobal
TrueHit global X-position.
std::vector< double > SpacePointErrorX
positiion error of SpacePoint in X direction (global)
std::vector< double > SpacePointVLocal
SpacePoint local V-position.
std::vector< unsigned int > ClusterSizeU
size of the u-cluster (resp.
std::vector< double > SpacePointErrorY
positiion error of SpacePoint in Y direction (global)
std::vector< unsigned int > NRelations
Number of related TrueHits to a SpacePoint.
std::vector< double > SpacePointXGlobal
SpacePoint global X-position.
std::vector< unsigned short int > HitVxdID
VxdID of the SpacePoint/TrueHit.
std::vector< double > SpacePointErrorU
position error of SpacePoint in U direction
std::vector< unsigned short int > RelationStatus
different flags of the relation stored in here (see c_relationStatus)
std::vector< double > SpacePointYGlobal
SpacePoint global Y-position.
std::vector< double > SpacePointULocal
SpacePoint local U-position.
std::vector< double > SpacePointZGlobal
SpacePoint global Z-position.
std::vector< double > TrueHitYGlobal
TrueHit global Y-position.
std::vector< double > SpacePointErrorV
position error of SpacePoint in V direction
std::vector< double > WeightU
weight of the relation between the U-Cluster of the SpacePoint and the TrueHit
std::vector< double > TrueHitZGlobal
TrueHit global Z-position.

◆ positionAnalysis()

void positionAnalysis ( Belle2::SpacePoint spacePoint,
const MapType &  trueHitMap,
const int &  index,
e_detTypes  detType 
)
protected

Analyze the position of SpacePoints and corresponding TrueHits.

Parameters
spacePointpointer to the SpacePoint
trueHitMapmap with the information to the (possibly) related TrueHits
index(StoreArray) index of the TrueHit to which the relation actually got registered (if < 0 it is assumed that all possible relations were registered)
detTypethe detector type NOTE: if a relation is not registered because the combination TrueHit - SpacePoint is considered not compatible (can happen if 'requirePrimary' or 'requireProximity' is set to true this method does not now about this! This can lead to unexpected values for the relation status in the output file!) If there is time in the future this can be fixed such that the information on why the relation was declined is preserved until the output

Definition at line 523 of file SpacePoint2TrueHitConnectorModule.cc.

525{
526 B2DEBUG(28, "Doing position analysis for SpacePoint " << spacePoint->getArrayIndex() << " from Array " <<
527 spacePoint->getArrayName());
529
530 // TODO TODO TODO TODO TODO TODO TODO: remove if not needed, only for tessting at the moment (i.e. do not commit)
531 std::pair<unsigned short int, unsigned short int> clusterSizes = getClusterSizes(spacePoint, detType);
532 std::pair<double, double> positionError = getLocalError(spacePoint);
533 // TODO TODO TODO TODO TODO TODO TODO: remove if not needed, only for tessting at the moment (i.e. do not commit)
534
535 // do some checks and set the relationStatus
536 std::pair<bool, bool> setUV = spacePoint->getIfClustersAssigned();
537 if (setUV.first) relationStatus.addStatus(c_SpacePointU);
538 if (setUV.second) relationStatus.addStatus(c_SpacePointV);
539
540 const std::vector<TrueHitInfo> trueHitInfos = getAllValues(trueHitMap);
541 unsigned int nRelations = trueHitInfos.size();
542 if (nRelations != 1) relationStatus.addStatus(c_nonUniqueRelation);
543 else relationStatus.addStatus(c_clearHit); // TODO: check if this is according to the definition of cleanHit
544
545 B2DEBUG(29, "SpacePoint has assigned U: " << setUV.first << ", V: " << setUV.second << ". Possible TrueHits: " << nRelations);
546
547 std::pair<double, double> spLocalPos = getLocalPos(spacePoint);
548 unsigned short int vxdId = spacePoint->getVxdID();
549 short nClusters = spacePoint->getNClustersAssigned();
550
551 // loop over all TrueHitInfos and check if it is a ghostHit, and if a noise hit is contained in the SpacePoint
552 bool onceU = false, onceV = false; // check if both Clusters are at least used once
553 bool twoClusters = false;
554 for (const TrueHitInfo& info : trueHitInfos) {
555 onceU = onceU || info.m_U; // if U is set for one of the possible TrueHits, onceU is true after this loop
556 onceV = onceV || info.m_V;
557 twoClusters = twoClusters || (info.getNClusters() == 2); // if one of the TrueHits has two Clusters in the SpacePoint -> true
558 }
559 bool allSet = onceU && onceV;
560
561 if (nClusters > 1) { // at this stage noise Clusters and ghostHits can only appear if there are two Clusters in the SpacePoint
562 if (!allSet) relationStatus.addStatus(c_noiseCluster);
563 if (allSet && !twoClusters) relationStatus.addStatus(c_ghostHit);
564 }
565
566 // get the status that has been set until now as from now on it can differ for every relation
567 unsigned short int overAllStatus = relationStatus.getStatus();
568
569 for (const TrueHitInfo& info : trueHitInfos) {
570 relationStatus.setStatus(overAllStatus); // reset status
571 VXDTrueHit* trueHit;
572 if (detType == c_SVD) { trueHit = m_SVDTrueHits[info.m_Id]; }
573 else { trueHit = m_PXDTrueHits[info.m_Id]; }
574 std::pair<ROOT::Math::XYZVector, ROOT::Math::XYZVector> trueHitPos = getTrueHitPositions(trueHit);
575
576 double weightU = info.m_wU;
577 double weightV = info.m_wV;
578
579 MCParticle* mcParticle = trueHit->getRelatedFrom<MCParticle>("ALL");
580 if (mcParticle != nullptr) {
581 if (mcParticle->hasStatus(MCParticle::c_PrimaryParticle)) relationStatus.addStatus(c_primaryParticle);
582 }
583
584 if (info.m_Id == index) relationStatus.addStatus(c_registeredRelation);
585
586 m_rootVariables.SpacePointULocal.push_back(spLocalPos.first);
587 m_rootVariables.SpacePointVLocal.push_back(spLocalPos.second);
588 m_rootVariables.SpacePointXGlobal.push_back(spacePoint->X());
589 m_rootVariables.SpacePointYGlobal.push_back(spacePoint->Y());
590 m_rootVariables.SpacePointZGlobal.push_back(spacePoint->Z());
591
592 m_rootVariables.TrueHitULocal.push_back(trueHitPos.first.X());
593 m_rootVariables.TrueHitVLocal.push_back(trueHitPos.first.Y());
594 m_rootVariables.TrueHitXGlobal.push_back(trueHitPos.second.X());
595 m_rootVariables.TrueHitYGlobal.push_back(trueHitPos.second.Y());
596 m_rootVariables.TrueHitZGlobal.push_back(trueHitPos.second.Z());
597
598 m_rootVariables.NRelations.push_back(nRelations);
599 m_rootVariables.RelationStatus.push_back(relationStatus.getStatus());
600 m_rootVariables.WeightU.push_back(weightU);
601 m_rootVariables.WeightV.push_back(weightV);
602 m_rootVariables.HitVxdID.push_back(vxdId);
603
604 // TODO TODO TODO TODO TODO TODO TODO: remove if not needed, only for tessting at the moment (i.e. do not commit)
605 m_rootVariables.ClusterSizeU.push_back(clusterSizes.first);
606 m_rootVariables.ClusterSizeV.push_back(clusterSizes.second);
607 m_rootVariables.SpacePointErrorU.push_back(positionError.first);
608 m_rootVariables.SpacePointErrorV.push_back(positionError.second);
609 m_rootVariables.SpacePointErrorX.push_back(spacePoint->getPositionError().X());
610 m_rootVariables.SpacePointErrorY.push_back(spacePoint->getPositionError().Y());
611 m_rootVariables.SpacePointErrorZ.push_back(spacePoint->getPositionError().Z());
612 // TODO TODO TODO TODO TODO TODO TODO: remove if not needed, only for tessting at the moment (i.e. do not commit)
613
614 B2DEBUG(29, "Branch contents of this entry:\nSPLocalU: " << spLocalPos.first << ". SPLocalV: " << spLocalPos.second << "\n" << \
615 "SPGlobalX: " << spacePoint->X() << ", SPGlobalY: " << spacePoint->Y() << ", SPGlobalZ " << spacePoint->Z() << "\n" << \
616 "THLocalU: " << trueHitPos.first.X() << ", THLocalV: " << trueHitPos.first.Y() << "\n" << \
617 "THGlobalX: " << trueHitPos.second.X() << ", THGlobalY: " << trueHitPos.second.Y() << ", THGlobalZ: " << trueHitPos.second.Z() <<
618 "\n" << \
619 "weight1: " << weightU << ", weight2: " << weightV << ", VxdID: " << vxdId << ", nRelations: " << nRelations << ", relStatus: " <<
620 relationStatus.getStatus());
621 }
622}
DataType Z() const
access variable Z (= .at(2) without boundary check)
Definition: B2Vector3.h:435
DataType X() const
access variable X (= .at(0) without boundary check)
Definition: B2Vector3.h:431
DataType Y() const
access variable Y (= .at(1) without boundary check)
Definition: B2Vector3.h:433
FROM * getRelatedFrom(const std::string &name="", const std::string &namedRelation="") const
Get the object from which this object has a relation.
std::pair< double, double > getLocalError(Belle2::SpacePoint *spacePoint)
get the position error of SpacePoints in local coordinates
std::pair< unsigned short int, unsigned short int > getClusterSizes(Belle2::SpacePoint *spacePoint, e_detTypes detType)
get the sizes of the related Clusters of a SpacePoint
std::pair< ROOT::Math::XYZVector, ROOT::Math::XYZVector > getTrueHitPositions(TrueHitType *trueHit)
get the local (.first) and global (.second) position of a TrueHit (passed by index)
const B2Vector3D & getPositionError() const
return the hitErrors in sigma of the global position
Definition: SpacePoint.h:141
Class VXDTrueHit - Records of tracks that either enter or leave the sensitive volume.
Definition: VXDTrueHit.h:36
helper class for setting up a bitfield that can be used to store several flags in one variable TODO: ...
void setStatus(T __statusBits)
set the status of the bitfield (CAUTION: overwrites any previously defined status!...
void addStatus(T __statusBits)
add a status to the bitfield (if it has not already been added)
const T getStatus() const
get the status of the bitfield

◆ processSpacePoint()

MapType processSpacePoint ( Belle2::SpacePoint spacePoint,
e_detTypes  detType 
)
protected

process a SpacePoint.

This is essentially a wrapper that handles the different types of Clusters and TrueHits and then calls getRelatedTrueHits(args) appropriately and returns the map that is created by that NOTE: could declare as const (after development)

Returns
: empty map if something went wrong (i.e. exception), or map of TrueHit indices to weights if all was good

Definition at line 306 of file SpacePoint2TrueHitConnectorModule.cc.

307{
308 B2DEBUG(23, "Processing SpacePoint " << spacePoint->getArrayIndex() << " from Array " << spacePoint->getArrayName());
309 MapType trueHitMap;
310 try {
311 if (detType == c_PXD) {
312 trueHitMap = getRelatedTrueHits<MapType, PXDCluster, PXDTrueHit>(spacePoint, m_PXDClusters.getName(), m_PXDTrueHits.getName());
313 } else {
314 trueHitMap = getRelatedTrueHits<MapType, SVDCluster, SVDTrueHit>(spacePoint, m_SVDClusters.getName(), m_SVDTrueHits.getName());
315 }
316 } catch (NoClusterToSpacePoint& anE) {
317 B2WARNING("Caught an exception while trying to relate SpacePoints and TrueHits: " << anE.what());
319 } catch (...) { // catch the rest
320 B2ERROR("Caught undefined exception while trying to relate SpacePoints and TrueHits");
321 throw; // throw further (maybe it is caught somewhere else)
322 }
323
324 B2DEBUG(25, "trueHitMap.size() before return in processSpacePoint: " << trueHitMap.size());
325 return trueHitMap;
326}

◆ registerAllRelations()

void registerAllRelations ( Belle2::SpacePoint spacePoint,
MapType  trueHitMap,
e_detTypes  detType 
)
protected

register a Relation to all the TrueHits in the trueHitMap for the passed SpacePoint

Definition at line 426 of file SpacePoint2TrueHitConnectorModule.cc.

427{
428 B2DEBUG(23, "Registering all possible relations for SpacePoint " << spacePoint->getArrayIndex() << " from Array " <<
429 spacePoint->getArrayName() << ". storeSeparate is set to " << m_PARAMstoreSeparate);
430 SpacePoint* newSP = spacePoint; // declaring pointer here, getting new pointer if storeSeparate is true
431
432 if (m_PARAMstoreSeparate) { // if storing in separate Array, re-register the relations to the Clusters first
433 newSP = m_outputSpacePoints.at(m_iCont).appendNew(*spacePoint);
434 B2DEBUG(23, "Added new SpacePoint to Array " << m_outputSpacePoints[m_iCont].getName() << ".");
435 if (detType == c_PXD) reRegisterClusterRelations<PXDCluster>(spacePoint, newSP, m_PXDClusters.getName());
436 else reRegisterClusterRelations<SVDCluster>(spacePoint, newSP, m_SVDClusters.getName());
437 }
438
439 std::vector<TrueHitInfo> trueHitInfos = getAllValues(trueHitMap);
440 // sort by the number of related Clusters first and than by weight (descending order)
441 std::sort(trueHitInfos.begin(), trueHitInfos.end());
442
443 for (const TrueHitInfo& info : trueHitInfos) {
444 if (detType == c_PXD) registerTrueHitRelation<PXDTrueHit>(newSP, info.m_Id, 1, m_PXDTrueHits); // only one Cluster for PXDs!
445 else { // for SVD relation weight is depending on which Cluster is related to TrueHit!
446 double weight = calculateRelationWeight(info, spacePoint);
447 registerTrueHitRelation<SVDTrueHit>(newSP, info.m_Id, weight, m_SVDTrueHits);
448 }
449 }
450}

◆ registerOneRelation()

void registerOneRelation ( Belle2::SpacePoint spacePoint,
std::pair< TrueHitType *, double >  trueHitwWeight,
e_detTypes  detType 
)
protected

register Relation between SpacePoint and TrueHit (and if necessary also between SpacePoint and Cluster)

Definition at line 454 of file SpacePoint2TrueHitConnectorModule.cc.

456{
457 TrueHitType* trueHit = trueHitwWeight.first;
458 B2DEBUG(23, "Registering relation to TrueHit " << trueHit->getArrayIndex() << " from Array " << trueHit->getArrayName());
459 SpacePoint* newSP = spacePoint; // declaring pointer here, getting new pointer if storeSeparate is true
460
461 if (m_PARAMstoreSeparate) { // if storing in separate Array, re-register the relations to the Clusters first
462 newSP = m_outputSpacePoints.at(m_iCont).appendNew(*spacePoint);
463 B2DEBUG(23, "Added new SpacePoint to Array " << m_outputSpacePoints[m_iCont].getName() << ".");
464 if (detType == c_PXD) reRegisterClusterRelations<PXDCluster>(spacePoint, newSP, m_PXDClusters.getName());
465 else reRegisterClusterRelations<SVDCluster>(spacePoint, newSP, m_SVDClusters.getName());
466 }
467
468 newSP->addRelationTo(trueHit, trueHitwWeight.second);
470 B2DEBUG(23, "Added Relation to TrueHit " << trueHit->getArrayIndex() << " from Array " << trueHit->getArrayName() <<
471 " for SpacePoint " << spacePoint->getArrayIndex() << " (weight = " << trueHitwWeight.second << ")");
472}
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).

◆ registerTrueHitRelation()

void registerTrueHitRelation ( Belle2::SpacePoint spacePoint,
int  index,
double  weight,
Belle2::StoreArray< TrueHitType >  trueHits 
)
protected

register the relation between a SpacePoint and the TrueHit (passed by index in the corresponding TrueHit Array) with the passed weight NOTE: defining a function here mainly to avoid having duplicate code for every TrueHitType

Definition at line 510 of file SpacePoint2TrueHitConnectorModule.cc.

512{
513 TrueHitType* trueHit = trueHits[index];
514 spacePoint->addRelationTo(trueHit, weight);
515 m_regRelationsCtr.at(m_iCont)++; // increase counter of registered relations for this container
516 B2DEBUG(23, "Added Relation to TrueHit " << index << " from Array " << trueHits.getName() << " for SpacePoint " <<
517 spacePoint->getArrayIndex() << " (weight = " << weight << ")");
518}

◆ reRegisterClusterRelations()

void reRegisterClusterRelations ( Belle2::SpacePoint origSpacePoint,
Belle2::SpacePoint newSpacePoint,
std::string  clusterName = "ALL" 
)
protected

register all the relations to Clusters that origSpacePoint had for newSpacePoint

Definition at line 476 of file SpacePoint2TrueHitConnectorModule.cc.

478{
479 B2DEBUG(27, "Registering the Relations to Clusters of SpacePoint " << origSpacePoint->getArrayIndex() << " in Array " <<
480 origSpacePoint->getArrayName() << " for SpacePoint " << newSpacePoint->getArrayIndex() << " in Array " <<
481 newSpacePoint->getArrayName());
482
483 std::vector<std::pair<ClusterType*, double> > clustersAndWeights = getRelatedClusters<ClusterType>(origSpacePoint, clusterName);
484 for (auto aCluster : clustersAndWeights) {
485 newSpacePoint->addRelationTo(aCluster.first, aCluster.second);
486 B2DEBUG(27, "Registered Relation to Cluster " << aCluster.first->getArrayIndex() << " with weight " << aCluster.second);
487 }
488}

◆ setAbortLevel()

void setAbortLevel ( int  abortLevel)
inherited

Configure the abort log level.

Definition at line 67 of file Module.cc.

68{
69 m_logConfig.setAbortLevel(static_cast<LogConfig::ELogLevel>(abortLevel));
70}
ELogLevel
Definition of the supported log levels.
Definition: LogConfig.h:26
void setAbortLevel(ELogLevel abortLevel)
Configure the abort level.
Definition: LogConfig.h:112

◆ setDebugLevel()

void setDebugLevel ( int  debugLevel)
inherited

Configure the debug messaging level.

Definition at line 61 of file Module.cc.

62{
63 m_logConfig.setDebugLevel(debugLevel);
64}
void setDebugLevel(int debugLevel)
Configure the debug messaging level.
Definition: LogConfig.h:98

◆ setDescription()

void setDescription ( const std::string &  description)
protectedinherited

Sets the description of the module.

Parameters
descriptionA description of the module.

Definition at line 214 of file Module.cc.

215{
216 m_description = description;
217}

◆ setLogConfig()

void setLogConfig ( const LogConfig logConfig)
inlineinherited

Set the log system configuration.

Definition at line 230 of file Module.h.

230{m_logConfig = logConfig;}

◆ setLogInfo()

void setLogInfo ( int  logLevel,
unsigned int  logInfo 
)
inherited

Configure the printed log information for the given level.

Parameters
logLevelThe log level (one of LogConfig::ELogLevel)
logInfoWhat kind of info should be printed? ORed combination of LogConfig::ELogInfo flags.

Definition at line 73 of file Module.cc.

74{
75 m_logConfig.setLogInfo(static_cast<LogConfig::ELogLevel>(logLevel), logInfo);
76}
void setLogInfo(ELogLevel logLevel, unsigned int logInfo)
Configure the printed log information for the given level.
Definition: LogConfig.h:127

◆ setLogLevel()

void setLogLevel ( int  logLevel)
inherited

Configure the log level.

Definition at line 55 of file Module.cc.

56{
57 m_logConfig.setLogLevel(static_cast<LogConfig::ELogLevel>(logLevel));
58}
void setLogLevel(ELogLevel logLevel)
Configure the log level.
Definition: LogConfig.cc:25

◆ setName()

void setName ( const std::string &  name)
inlineinherited

Set the name of the module.

Note
The module name is set when using the REG_MODULE macro, but the module can be renamed before calling process() using the set_name() function in your steering file.
Parameters
nameThe name of the module

Definition at line 214 of file Module.h.

214{ m_name = name; };

◆ setParamList()

void setParamList ( const ModuleParamList params)
inlineprotectedinherited

Replace existing parameter list.

Definition at line 501 of file Module.h.

501{ m_moduleParamList = params; }

◆ setParamPython()

void setParamPython ( const std::string &  name,
const boost::python::object &  pyObj 
)
privateinherited

Implements a method for setting boost::python objects.

The method supports the following types: list, dict, int, double, string, bool The conversion of the python object to the C++ type and the final storage of the parameter value is done in the ModuleParam class.

Parameters
nameThe unique name of the parameter.
pyObjThe object which should be converted and stored as the parameter value.

Definition at line 234 of file Module.cc.

235{
236 LogSystem& logSystem = LogSystem::Instance();
237 logSystem.updateModule(&(getLogConfig()), getName());
238 try {
240 } catch (std::runtime_error& e) {
241 throw std::runtime_error("Cannot set parameter '" + name + "' for module '"
242 + m_name + "': " + e.what());
243 }
244
245 logSystem.updateModule(nullptr);
246}
Class for logging debug, info and error messages.
Definition: LogSystem.h:46
void updateModule(const LogConfig *moduleLogConfig=nullptr, const std::string &moduleName="")
Sets the log configuration to the given module log configuration and sets the module name This method...
Definition: LogSystem.h:191
void setParamPython(const std::string &name, const PythonObject &pyObj)
Implements a method for setting boost::python objects.

◆ setParamPythonDict()

void setParamPythonDict ( const boost::python::dict &  dictionary)
privateinherited

Implements a method for reading the parameter values from a boost::python dictionary.

The key of the dictionary has to be the name of the parameter and the value has to be of one of the supported parameter types.

Parameters
dictionaryThe python dictionary from which the parameter values are read.

Definition at line 249 of file Module.cc.

250{
251
252 LogSystem& logSystem = LogSystem::Instance();
253 logSystem.updateModule(&(getLogConfig()), getName());
254
255 boost::python::list dictKeys = dictionary.keys();
256 int nKey = boost::python::len(dictKeys);
257
258 //Loop over all keys in the dictionary
259 for (int iKey = 0; iKey < nKey; ++iKey) {
260 boost::python::object currKey = dictKeys[iKey];
261 boost::python::extract<std::string> keyProxy(currKey);
262
263 if (keyProxy.check()) {
264 const boost::python::object& currValue = dictionary[currKey];
265 setParamPython(keyProxy, currValue);
266 } else {
267 B2ERROR("Setting the module parameters from a python dictionary: invalid key in dictionary!");
268 }
269 }
270
271 logSystem.updateModule(nullptr);
272}
void setParamPython(const std::string &name, const boost::python::object &pyObj)
Implements a method for setting boost::python objects.
Definition: Module.cc:234

◆ setPropertyFlags()

void setPropertyFlags ( unsigned int  propertyFlags)
inherited

Sets the flags for the module properties.

Parameters
propertyFlagsbitwise OR of EModulePropFlags

Definition at line 208 of file Module.cc.

209{
210 m_propertyFlags = propertyFlags;
211}

◆ setReturnValue() [1/2]

void setReturnValue ( bool  value)
protectedinherited

Sets the return value for this module as bool.

The bool value is saved as an integer with the convention 1 meaning true and 0 meaning false. The value can be used in the steering file to divide the analysis chain into several paths.

Parameters
valueThe value of the return value.

Definition at line 227 of file Module.cc.

228{
229 m_hasReturnValue = true;
230 m_returnValue = value;
231}

◆ setReturnValue() [2/2]

void setReturnValue ( int  value)
protectedinherited

Sets the return value for this module as integer.

The value can be used in the steering file to divide the analysis chain into several paths.

Parameters
valueThe value of the return value.

Definition at line 220 of file Module.cc.

221{
222 m_hasReturnValue = true;
223 m_returnValue = value;
224}

◆ setType()

void setType ( const std::string &  type)
protectedinherited

Set the module type.

Only for use by internal modules (which don't use the normal REG_MODULE mechanism).

Definition at line 48 of file Module.cc.

49{
50 if (!m_type.empty())
51 B2FATAL("Trying to change module type from " << m_type << " is not allowed, the value is assumed to be fixed.");
52 m_type = type;
53}

◆ terminate()

void terminate ( void  )
overridevirtual

terminate: print some summary information

Reimplemented from Module.

Definition at line 260 of file SpacePoint2TrueHitConnectorModule.cc.

261{
262 unsigned int sumSpacePoints = accumulate(m_SpacePointsCtr.begin(), m_SpacePointsCtr.end(), 0);
263 unsigned int sumRelations = accumulate(m_regRelationsCtr.begin(), m_regRelationsCtr.end(), 0);
264
265 B2RESULT("SpacePoint2TrueHitConnector: Got " << sumSpacePoints << " SpacePoints in " << m_nContainers <<
266 " containers and registered " << sumRelations << " relations to TrueHits");
267 if (LogSystem::Instance().isLevelEnabled(LogConfig::c_Debug, 1, PACKAGENAME())) {
268 std::stringstream contSumm;
269 contSumm << "Container-wise summary: \n";
270
271 for (unsigned int iCont = 0; iCont < m_nContainers; ++iCont) {
272 contSumm << "In Container " << iCont << " (container name: " << m_inputSpacePoints[iCont].first.getName() << ") " <<
273 m_SpacePointsCtr[iCont] << " SpacePoints were contained. " << m_regRelationsCtr[iCont] <<
274 " relations were registered.\nNumber of related TrueHits to a SpacePoint are:\n";
275 for (unsigned int i = 0; i < m_nRelTrueHitsCtr[iCont].size() - 1; ++i) { contSumm << i + 1 << " related TrueHits to a SpacePoint : " << m_nRelTrueHitsCtr[iCont].at(i) << "\n"; }
276 contSumm << " more than 4 related TrueHits to a SpacePoint: " << m_nRelTrueHitsCtr[iCont].at(4) << "\n"; // WARNING: hardcoded
277 contSumm << m_rejectedRelsCtr.at(iCont) << " SpacePoints did not get a relation, " << m_ghostHitCtr.at(
278 iCont) << " were probably ghost hits in this container!\n";
279 contSumm << m_noTrueHitCtr[iCont] << " SpacePoints had no relation to a TrueHit at all.\n";
280 }
281 B2DEBUG(20, contSumm.str());
282
283 if (!m_PARAMregisterAll) {
284 // TODO: do this containerwise
285 std::stringstream furtherSummary;
286 furtherSummary << "Omitted Relations because of weight < " << m_PARAMminWeight << ": " << m_weightTooSmallCtr << "\n";
287 furtherSummary << "Rejected Relations because of non primary particle: " << m_rejectedNoPrimaryCtr;
288// furtherSummary << "Summary for all containers:\n";
289// furtherSummary << "possible/accepted relations for cases:\n";
290// furtherSummary << m_all2WTHCtr << "/" << m_accAll2WTHCtr << " SP with THs (more than one) with all THs having two weights\n";
291// furtherSummary << m_single2WTHCtr << "/" << m_accSingle2WTHCtr << " SP with THs (more than one) with only one TH having two weights\n";
292// furtherSummary << m_nonSingle2WTHCtr << "/" << m_accNonSingle2WTHCtr << " SP with THs (more than one) with more than one but not all THs having two weights\n";
293// furtherSummary << "In " << m_oneCluster2THCtr << " cases there was a SP with only one Cluster but more than one related TrueHits";
294 B2DEBUG(20, furtherSummary.str());
295 }
296 }
297
299
300// B2INFO("total number of weights: " << m_totWeightsCtr << " of which " << m_negWeightCtr << " were negative")
301// B2INFO("m_moreThan2Weights = " << m_moreThan2Weights);
302}

Member Data Documentation

◆ m_conditions

std::vector<ModuleCondition> m_conditions
privateinherited

Module condition, only non-null if set.

Definition at line 521 of file Module.h.

◆ m_description

std::string m_description
privateinherited

The description of the module.

Definition at line 511 of file Module.h.

◆ m_detectorTypes

std::vector<e_detTypes> m_detectorTypes
protected

storing the detector types for each container in vector, needed in initialize

Definition at line 229 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_ghostHitCtr

std::vector<unsigned int> m_ghostHitCtr
protected

Number of SpacePoints that are considered ghost hits.

Definition at line 266 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_hasReturnValue

bool m_hasReturnValue
privateinherited

True, if the return value is set.

Definition at line 518 of file Module.h.

◆ m_iCont

unsigned int m_iCont
protected

'helper variable' needed to not have to pass one integer down to processSpacePoint only to have a handle in cases where an exception gets caught

Definition at line 247 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_inputSpacePoints

std::vector<std::pair<Belle2::StoreArray<Belle2::SpacePoint>, e_detTypes> > m_inputSpacePoints
protected

StoreArray of all input SpacePoints.

Definition at line 240 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_logConfig

LogConfig m_logConfig
privateinherited

The log system configuration of the module.

Definition at line 514 of file Module.h.

◆ m_maxGlobalDiff

double m_maxGlobalDiff
protected

storing the squared value of m_PARAMmaxGlobalDiff here to not alter the parameter input

Definition at line 244 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_moduleParamList

ModuleParamList m_moduleParamList
privateinherited

List storing and managing all parameter of the module.

Definition at line 516 of file Module.h.

◆ m_name

std::string m_name
privateinherited

The name of the module, saved as a string (user-modifiable)

Definition at line 508 of file Module.h.

◆ m_nContainers

unsigned int m_nContainers
protected

number of passed containers -> storing the size of an input vector for not having to obtain it every time

Definition at line 227 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_noClusterCtr

std::vector<unsigned int> m_noClusterCtr
protected

Number of SpacePoints without relation to a Cluster (i.e.

counts how many times the NoClusterTrueHit exception gets thrown)

Definition at line 262 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_noTrueHitCtr

std::vector<unsigned int> m_noTrueHitCtr
protected

Number of SpacePoints that contained a Cluster to which no TrueHit could be found (i.e.

counts how many times the NoTrueHitToCluster exception gets thrown)

Definition at line 269 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_nRelTrueHitsCtr

std::vector<std::array<unsigned int, 5> > m_nRelTrueHitsCtr
protected

counting different numbers of related TrueHits (to a SpacePoint) with one variable

Definition at line 259 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_outputSpacePoints

std::vector<Belle2::StoreArray<Belle2::SpacePoint> > m_outputSpacePoints
protected

StoreArray of all output SpacePoints.

Definition at line 242 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_package

std::string m_package
privateinherited

Package this module is found in (may be empty).

Definition at line 510 of file Module.h.

◆ m_PARAMclusterNames

std::vector<std::string> m_PARAMclusterNames
protected

names of containers of Clusters

Definition at line 201 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_PARAMdetectorTypes

std::vector<std::string> m_PARAMdetectorTypes
protected

detector type names as strings to determine which name belongs to which detector type

Definition at line 199 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_PARAMmaxGlobalDiff

double m_PARAMmaxGlobalDiff
protected

maximum difference of global position coordinates for each direction between TrueHit and SpacePoint

Definition at line 217 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_PARAMmaxPosSigma

double m_PARAMmaxPosSigma
protected

defining th maximum difference of local coordinates in units of PitchSize / sqrt(12)

Definition at line 221 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_PARAMminWeight

double m_PARAMminWeight
protected

define a minimal weight a relation between Cluster and TrueHit.

Below this limit the relation will not be registered

Definition at line 223 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_PARAMoutputSuffix

std::string m_PARAMoutputSuffix
protected

suffix that will be appended to the StoreArray names of the output StoreArrays

Definition at line 192 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_PARAMpositionAnalysis

bool m_PARAMpositionAnalysis
protected

switch for doing the analysis of positions of SpacePoints and TrueHits

Definition at line 211 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_PARAMregisterAll

bool m_PARAMregisterAll
protected

switch for registereing all relations for all TrueHits for all SpacePoints (there can be more than 1 related TrueHit to each SpacePoint).

The module can be used to get all TrueHits for a SpacePoint and then the user can decide what to do with it.

Definition at line 209 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_PARAMrequirePrimary

bool m_PARAMrequirePrimary
protected

require the TrueHit to be related to a primary particle in order for the relation to get registered!

Definition at line 213 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_PARAMrequireProximity

bool m_PARAMrequireProximity
protected

require the TrueHit to be close to the SpacePoint.

What close means can be controlled by other module parameters

Definition at line 215 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_PARAMrootFileName

std::vector<std::string> m_PARAMrootFileName
protected

name and update status of root file

Definition at line 203 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_PARAMspacePointNames

std::vector<std::string> m_PARAMspacePointNames
protected

names of containers of SpacePoints

Definition at line 196 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_PARAMstoreSeparate

bool m_PARAMstoreSeparate
protected

switch for storing the SpacePoints that can be related to a TrueHit into separate StoreArrays, where only such SpacePoints are stored

Definition at line 206 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_PARAMtrueHitNames

std::vector<std::string> m_PARAMtrueHitNames
protected

names of containers of TrueHits

Definition at line 194 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_propertyFlags

unsigned int m_propertyFlags
privateinherited

The properties of the module as bitwise or (with |) of EModulePropFlags.

Definition at line 512 of file Module.h.

◆ m_PXDClusters

Belle2::StoreArray<Belle2::PXDCluster> m_PXDClusters
protected

PXDTClusters StoreArray used throughout the module.

Definition at line 235 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_PXDTrueHits

Belle2::StoreArray<Belle2::PXDTrueHit> m_PXDTrueHits
protected

PXDTrueHits StoreArray used throughout the module.

Definition at line 233 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_regRelationsCtr

std::vector<unsigned int> m_regRelationsCtr
protected

Number of registered relations.

Definition at line 264 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_rejectedNoPrimaryCtr

unsigned int m_rejectedNoPrimaryCtr
protected

Count how many times a relation was rejected because TrueHit was not related to primary.

Definition at line 276 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_rejectedRelsCtr

std::vector<unsigned int> m_rejectedRelsCtr
protected

Number of SpacePoints that were not related to a TrueHit (i.e.

getTHwithWeight returned nullptr)

Definition at line 272 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_returnValue

int m_returnValue
privateinherited

The return value.

Definition at line 519 of file Module.h.

◆ m_rootFilePtr

TFile* m_rootFilePtr
protected

pointer to root file

Definition at line 251 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_rootVariables

RootVariables m_rootVariables
protected

Root variables used for collecting data eventwise.

Definition at line 249 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_SpacePointsCtr

std::vector<unsigned int> m_SpacePointsCtr
protected

Number of SpacePoints presented to the module.

Definition at line 256 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_SVDClusters

Belle2::StoreArray<Belle2::SVDCluster> m_SVDClusters
protected

PXDClusters StoreArray used throughout the module.

Definition at line 237 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_SVDTrueHits

Belle2::StoreArray<Belle2::SVDTrueHit> m_SVDTrueHits
protected

SVDTrueHits StoreArray used throughout the module.

Definition at line 231 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_treePtr

TTree* m_treePtr
protected

pointer to tree in root file

Definition at line 253 of file SpacePoint2TrueHitConnectorModule.h.

◆ m_type

std::string m_type
privateinherited

The type of the module, saved as a string.

Definition at line 509 of file Module.h.

◆ m_weightTooSmallCtr

unsigned int m_weightTooSmallCtr
protected

Count the omitted relations because of a too small weight.

Definition at line 274 of file SpacePoint2TrueHitConnectorModule.h.


The documentation for this class was generated from the following files: