11#include <framework/core/FrameworkExceptions.h>
12#include <framework/core/Module.h>
14#include <framework/datastore/StoreArray.h>
15#include <framework/datastore/RelationArray.h>
17#include <tracking/spacePointCreation/SpacePoint.h>
18#include <pxd/dataobjects/PXDTrueHit.h>
19#include <svd/dataobjects/SVDTrueHit.h>
26#include <unordered_map>
71 return (std::tuple<int, double>(b.m_U + b.m_V, b.m_wU + b.m_wV) < std::tuple<int, double>(
m_U +
m_V,
m_wU +
m_wV));
90 os <<
"Id " << thInfo.
m_Id <<
": wU = " << thInfo.
m_wU <<
", setU = " << thInfo.
m_U <<
". wV = " <<
91 thInfo.
m_wV <<
", setV = " << thInfo.
m_V;
125 void event()
override;
130 "Found no related Cluster for a SpacePoint!");
168 typedef std::unordered_map<int, TrueHitInfo>
baseMapT;
184 c_primaryParticle = 16,
186 c_nonUniqueRelation = 64,
187 c_registeredRelation = 128,
188 c_noiseCluster = 256,
314 template <
typename MapType,
typename TrueHitType>
322 template <
typename TrueHitType>
334 template<
typename MapType,
typename ClusterType,
typename TrueHitType>
342 template<
typename MapType>
348 template<
typename MapType>
354 template<
typename TrueHitType>
360 template<
typename ClusterType>
367 template<
typename ClusterType>
368 std::vector<std::pair<ClusterType*, double> >
376 template<
typename TrueHitType>
388 template<
typename MapType>
395 template<
typename TrueHitType>
396 std::pair<ROOT::Math::XYZVector, ROOT::Math::XYZVector>
getTrueHitPositions(TrueHitType* trueHit);
438 const T
hasStatus(T __statusBits)
const {
return (
__bits & __statusBits) == __statusBits; }
Module that tries to register a relation between SpacePoints and TrueHits, hence making some MC Infor...
BELLE2_DEFINE_EXCEPTION(NoClusterToSpacePoint, "Found no related Cluster for a SpacePoint!")
Exception for when no related Cluster can be found for a SpacePoint.
TTree * m_treePtr
pointer to tree in root file
std::vector< std::string > m_PARAMclusterNames
names of containers of Clusters
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 o...
SpacePoint2TrueHitConnectorModule()
Constructor.
std::vector< std::string > m_PARAMtrueHitNames
names of containers of TrueHits
std::vector< unsigned int > m_SpacePointsCtr
Number of SpacePoints presented to the module.
std::vector< std::string > m_PARAMdetectorTypes
detector type names as strings to determine which name belongs to which detector type
void initialize() override
initialize: initialize counters, check StoreArrays, register StoreArrays, ...
unsigned int m_nContainers
number of passed containers -> storing the size of an input vector for not having to obtain it every ...
void reRegisterClusterRelations(Belle2::SpacePoint *origSpacePoint, Belle2::SpacePoint *newSpacePoint, std::string clusterName="ALL")
register all the relations to Clusters that origSpacePoint had for newSpacePoint
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 event() override
event: try to find the appropriate TrueHit to all SpacePoints
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!...
std::pair< double, double > getLocalError(Belle2::SpacePoint *spacePoint)
get the position error of SpacePoints in local coordinates
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< unsigned int > m_noClusterCtr
Number of SpacePoints without relation to a Cluster (i.e.
std::vector< std::pair< Belle2::StoreArray< Belle2::SpacePoint >, e_detTypes > > m_inputSpacePoints
StoreArray of all input SpacePoints.
double m_PARAMmaxGlobalDiff
maximum difference of global position coordinates for each direction between TrueHit and SpacePoint
void initializeRootFile()
initialize the root file that is used for output
std::unordered_map< int, TrueHitInfo > baseMapT
typedef for shorter notation throughout the module
std::vector< unsigned int > m_regRelationsCtr
Number of registered relations.
e_detTypes
enum to distinguish the detectortypes
unsigned int m_weightTooSmallCtr
Count the omitted relations because of a too small weight.
void terminate() override
terminate: print some summary information
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::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 spacePo...
std::vector< std::array< unsigned int, 5 > > m_nRelTrueHitsCtr
counting different numbers of related TrueHits (to a SpacePoint) with one variable
e_relationStatus
enum for better code readability
void closeRootFile()
close root file
void positionAnalysis(Belle2::SpacePoint *spacePoint, const MapType &trueHitMap, const int &index, e_detTypes detType)
Analyze the position of SpacePoints and corresponding TrueHits.
bool m_PARAMstoreSeparate
switch for storing the SpacePoints that can be related to a TrueHit into separate StoreArrays,...
unsigned int m_rejectedNoPrimaryCtr
Count how many times a relation was rejected because TrueHit was not related to primary.
std::vector< Belle2::StoreArray< Belle2::SpacePoint > > m_outputSpacePoints
StoreArray of all output SpacePoints.
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
MapType processSpacePoint(Belle2::SpacePoint *spacePoint, e_detTypes detType)
process a SpacePoint.
std::vector< e_detTypes > m_detectorTypes
storing the detector types for each container in vector, needed in initialize
std::vector< std::string > m_PARAMrootFileName
name and update status of root file
double m_maxGlobalDiff
storing the squared value of m_PARAMmaxGlobalDiff here to not alter the parameter input
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 True...
std::vector< unsigned int > m_noTrueHitCtr
Number of SpacePoints that contained a Cluster to which no TrueHit could be found (i....
std::string m_PARAMoutputSuffix
suffix that will be appended to the StoreArray names of the output StoreArrays
Belle2::StoreArray< Belle2::SVDTrueHit > m_SVDTrueHits
SVDTrueHits StoreArray used throughout the module.
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)
Belle2::StoreArray< Belle2::PXDTrueHit > m_PXDTrueHits
PXDTrueHits StoreArray used throughout the module.
Belle2::StoreArray< Belle2::PXDCluster > m_PXDClusters
PXDTClusters StoreArray used throughout the module.
bool m_PARAMregisterAll
switch for registereing all relations for all TrueHits for all SpacePoints (there can be more than 1 ...
Belle2::StoreArray< Belle2::SVDCluster > m_SVDClusters
PXDClusters 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...
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!...
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)
bool m_PARAMrequireProximity
require the TrueHit to be close to the SpacePoint.
std::vector< std::string > m_PARAMspacePointNames
names of containers of SpacePoints
std::pair< double, double > getLocalPos(Belle2::SpacePoint *spacePoint)
get the local position of a SpacePoint
void initializeCounters()
initialize all counters to 0 WARNING: only call in constructor of module!
TFile * m_rootFilePtr
pointer to root file
bool compatibleCombination(Belle2::SpacePoint *spacePoint, TrueHitType *trueHit)
compares the TrueHit and the SpacePoint positions (global) to decide whether they are compatible NOTE...
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.
std::vector< unsigned int > m_ghostHitCtr
Number of SpacePoints that are considered ghost hits.
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Accessor to arrays stored in the data store.
helper class for setting up a bitfield that can be used to store several flags in one variable TODO: ...
void removeStatus(T __statusBits)
remove a status from the bitfield
void setStatus(T __statusBits)
set the status of the bitfield (CAUTION: overwrites any previously defined status!...
T __bits
member holding the bits that are manipulated
const T hasStatus(T __statusBits) const
check if a certain status has been set to the bitfield
void addStatus(T __statusBits)
add a status to the bitfield (if it has not already been added)
simpleBitfield< T > & operator=(simpleBitfield< T > &)=delete
not needed
const T getStatus() const
get the status of the bitfield
void clear()
reset bitfield
simpleBitfield()
default constructor
simpleBitfield(const simpleBitfield< T > &__otherBitfield)=delete
not needed
std::ostream & operator<<(std::ostream &output, const IntervalOfValidity &iov)
Abstract base class for different kinds of events.
helper struct to access root variables inside the module
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 > TrueHitULocal
TrueHit local U-position.
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 > TrueHitVLocal
TrueHit local V-position.
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.
helper struct that holds information that is needed for the registration of the relation between Spac...
double m_wU
weight of relation between U-Cluster and TrueHit
bool m_U
if true, U-Cluster is used by SpacePoint
void setVWeight(double weight)
set the weight for the V-Cluster
short getNClusters() const
get the number of Clusters that point to this TrueHit
TrueHitInfo()
default ctor, initializing Id to -1, weights to 0, and bools to false
bool operator<(const TrueHitInfo &b) const
comparison operator ensuring strict weak ordering sorts by the number of Clusters first,...
void setUWeight(double weight)
set the weight for the U-Cluster
TrueHitInfo(int Id)
ctor using Id-only
double m_wV
weight of relation between V-Cluster and TrueHit
bool m_V
if true, V-Cluster is used by SpacePoint
double getWeightSum() const
get sum of relation weights
int m_Id
TrueHit ID (StoreArray Index)