Belle II Software release-09-00-00
GFTC2SPTCConverterModule.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9# pragma once
10
11#include <framework/core/Module.h>
12#include <framework/datastore/StoreArray.h>
13#include <tracking/spacePointCreation/SpacePoint.h>
14
15#include <tracking/spacePointCreation/SpacePointTrackCand.h>
16
17#include <pxd/dataobjects/PXDTrueHit.h>
18#include <svd/dataobjects/SVDTrueHit.h>
19
20#include <genfit/TrackCand.h>
21#include <genfit/TrackCandHit.h>
22
23#include <string>
24#include <utility>
25#include <boost/tuple/tuple.hpp>
26
27namespace Belle2 {
69
70 public:
71
74 void initialize()
75 override;
77 void event() override;
79 void terminate() override;
81 protected:
82
96 c_lowNDF = -7,
97 };
98
101 {
102 switch (intToConvert) {
103 case 1: return c_singleClusterSP;
104 case 0: return c_noFail;
105 case -1: return c_foundNoSpacePoint;
106 case -2: return c_foundNoTrueHit;
107 case -3: return c_unsuitableGFTC;
108 case -4: return c_unusedHits;
109 case -5: return c_nonSingleSP;
110 case -6: return c_noValidSP;
111 case -7: return c_lowNDF;
112 default: return c_foundNoSpacePoint;
113 }
114 }
115
116 // ========================================================== PARAMETERS ============================================================================
117 std::string m_PXDClusterName;
119 std::string m_SVDClusterName;
125 std::string m_PXDClusterSPName;
127 std::string m_genfitTCName;
129 std::string m_SPTCName;
141 // ============================================================= COUNTER VARIABLES ====================================================================
142 unsigned int
145 unsigned int m_genfitTCCtr;
147 unsigned int m_abortedTrueHitCtr;
151 unsigned int m_abortedNoSPCtr;
153 unsigned int
156 unsigned int
159 unsigned int m_skippedPXDnoSPCtr;
161 unsigned int m_skippedPXDnoTHCtr;
163 unsigned int m_skippedSVDnoSPCtr;
165 unsigned int m_skippedSVDnoTHCtr;
167 unsigned int m_singleClusterSPCtr;
169 unsigned int
172 unsigned int m_skippedCluster;
174 unsigned int
179 unsigned int
184 unsigned int m_nonSingleSPCtr;
186 unsigned int
191 {
193 m_genfitTCCtr = 0;
200
203
209
213
216
217 m_NDF = 0; // (cppcheck complaining about not being initialized in constructor)
218 }
219
222 {
223 switch (status) {
227 case c_lowNDF: m_abortedLowNDFCtr++; break;
228 case c_noValidSP: m_abortedNoValidSPCtr++; break;
229 default: m_abortedMiscCtr++; break;
230 }
231 return;
232 }
233
238 template<typename ClusterType>
239 void increaseSkippedCounter(conversionStatus status, ClusterType* cluster)
240 {
241 short unsigned int layerNumber = cluster->getSensorID().getLayerNumber();
242 if (layerNumber > 6) throw SpacePointTrackCand::UnsupportedDetType();
243 switch (status) {
244 case c_noFail:
245 break;
247 break;
249 if (layerNumber < 3) m_skippedPXDnoSPCtr++;
250 else m_skippedSVDnoSPCtr++;
251 break;
252 case c_foundNoTrueHit:
253 if (layerNumber < 3) m_skippedPXDnoTHCtr++;
254 else m_skippedSVDnoTHCtr++;
255 break;
256 case c_unsuitableGFTC:
257 if (layerNumber < 3) m_skippedPXDunsuitableCtr++;
259 break;
260 case c_noValidSP:
261 if (layerNumber < 3) m_skippedPXDnoValidSPCtr++;
263 break;
264 default:
265 m_skippedCluster++; break;
266 }
267 return;
268 }
269 // ================================================================ INTERNALLY USED VARIABLES ===========================================================
270 std::string svdMainArrayName;
272 int m_NDF;
274 // ================================================= TYPEDEFS ============================================================================================================
275
276// #ifndef __CINT__ // was once needed, when it was defined in SpacePointTrackCand.h
277 template<typename HitType> using HitInfo =
278 std::pair<double, const HitType*>;
279// #endif
280
281 template<typename T> using flaggedPair =
282 boost::tuple<bool, T, T>;
284 // ============================================================================ MODULE METHODS ==============================================================================
285
286
287 void markHitAsUsed(std::vector<flaggedPair<int> >& flaggedHitIDs,
288 int hitToMark);
294 std::pair<const Belle2::SpacePointTrackCand, conversionStatus>
295 createSpacePointTC(const genfit::TrackCand* genfitTC);
296
300 std::pair<Belle2::SpacePoint*, conversionStatus>
301 processTrackCandHit(genfit::TrackCandHit* hit, std::vector<flaggedPair<int> >& flaggedHitIDs, int iHit);
302
313 template<typename ClusterType, typename TrueHitType>
314 std::pair<Belle2::SpacePoint*, conversionStatus>
315 getSpacePoint(const ClusterType* cluster, std::vector<flaggedPair<int> >& flaggedHitIDs, int iHit, bool singleCluster,
316 std::string arrayName = "");
325 template<typename ClusterType>
326 std::pair<Belle2::SpacePoint*, conversionStatus>
328 std::vector<flaggedPair<int> >& flaggedHitIDs);
329
337 std::pair<int, int> checkExistAndValid(int clusterInd, int detID, std::vector<flaggedPair<int> >& flaggedHitIDs);
338
343 int getAppropriateSpacePointIndex(const std::vector<std::pair<bool, bool> >& existAndValidSPs,
344 const std::vector<std::pair<int, int> >& clusterPositions);
345
350 template<typename ClusterType>
351 std::vector<int> getClusterIndices(const Belle2::SpacePoint* spacePoint, std::string storeArrayName);
352
356 int getNDF(Belle2::SpacePoint* spacePoint);
357
361 bool checkUsedAllHits(std::vector<flaggedPair<int> >& flaggedHitIDs);
362
364 template <typename TrueHitType>
365 bool foundRelatedTrueHit(const Belle2::SpacePoint* spacePoint, unsigned int allowedRelations = 1);
366
371 "Not all hits of the genfit::TrackCand have been marked as used. This indicates that not all hits have been used to create a SpacePointTrackCand.");
372 private:
382 };
384}
Module for converting genfit::TrackCands to SpacePointTrackCands.
unsigned int m_abortedNoSPCtr
Counter for aborted conversions because no SpacePoint has been found.
StoreArray< SpacePoint > m_SingleClusterSpacePoints
SVD SpacePoints StoreArray only consisting of one SVDCluster.
int getNDF(Belle2::SpacePoint *spacePoint)
get the NDF of a SpacePoint
int m_PARAMminNDF
parameter for specifying a minimal number of degrees of freedom a SpacePointTrackCand has to have in ...
unsigned int m_skippedPXDunsuitableCtr
Counter for skipped PXD Clusters due to unsuitable GFTC.
bool m_PARAMskipCluster
Switch for controlling the behavior of the converter, when for one or more Clusters no appropriate Sp...
conversionStatus
enum for differentiating different reasons why a conversion failed negative values mean fail!
@ c_nonSingleSP
conversion failed because there were more than one single Cluster SpacePoints related to a Cluster
@ c_foundNoSpacePoint
conversion failed because no related SpacePoint was found to a Cluster/Hit of the GFTC
@ c_singleClusterSP
had to use a singleCluster SpacePoint (also returned if PXD is passed!
@ c_lowNDF
conversion failed because the created SpacePointTrackCand had not enough degrees of freedom
@ c_unusedHits
conversion failed because there were unused Hits
@ c_noValidSP
conversion failed because there was no valid SpacePoint (only possible for double Cluster SpacePoints...
@ c_foundNoTrueHit
conversion failed because there was no related SpacePoint to a TrueHit
@ c_unsuitableGFTC
conversion failed because the GFTC is considered not suitable for conversion
@ c_noFail
conversion without any problems
unsigned int m_skippedSVDnoValidSPCtr
Counter for skipped SVD Clusters due to no found valid SpacePoint.
std::string m_SingleClusterSVDSPName
Single Cluster SVD SpacePoints collection name.
unsigned int m_abortedUnsuitableTCCtr
Counter for aborted conversions due to unsuitable genfit::TrackCand.
std::pair< double, const HitType * > HitInfo
container used for storing information, that is then put into the SpacePointTrackCand
StoreArray< SVDCluster > m_SVDClusters
SVDClusters StoreArray.
std::string m_NoSingleClusterSVDSPName
Non SingleCluster SVD SpacePoints collection name.
void initialize() override
initialize module (e.g.
StoreArray< SpacePointTrackCand > m_SpacePointTrackCands
SpacePointTrackCands StoreArray.
void event() override
event: convert genfit::TrackCands to SpacePointTrackCands
std::string m_PXDClusterName
PXDCluster collection name.
unsigned int m_skippedSVDunsuitableCtr
Counter for skipped SVD Clusters due to unsuitable GFTC.
StoreArray< PXDTrueHit > m_PXDTrueHits
PXDTrueHits StoreArray.
void terminate() override
terminate: print some summary information on the processed events
bool foundRelatedTrueHit(const Belle2::SpacePoint *spacePoint, unsigned int allowedRelations=1)
check if there is a related TrueHit for a given SpacePoint.
unsigned int m_skippedSVDnoSPCtr
Counter for skipped SVD Clusters, due to no found SpacePoint.
unsigned int m_genfitTCCtr
Counter for genfit::TrackCands which were presented to the module.
std::string m_genfitTCName
Name of collection of genfit::TrackCand StoreArray.
void increaseSkippedCounter(conversionStatus status, ClusterType *cluster)
increase the appropriate counter variable if a Cluster is skipped (i.e.
bool m_PARAMcheckTrueHits
Parameter Indicating if the TrueHits related from the Clusters forming a SpacePoint should be checked...
unsigned int m_skippedSVDnoTHCtr
Counter for skipped SVD Clusters, due to no related TrueHit to a SpacePoint.
StoreArray< genfit::TrackCand > m_GenfitTrackCands
Genfit::TrackCand StoreArray.
bool m_PARAMuseSingleClusterSP
Parameter Indicating if SingleCluster SVD SpacePoints should be used if no double Cluster SVD SpacePo...
std::pair< Belle2::SpacePoint *, conversionStatus > processTrackCandHit(genfit::TrackCandHit *hit, std::vector< flaggedPair< int > > &flaggedHitIDs, int iHit)
process a TrackCandHit (i.e.
unsigned int m_nonSingleSPCtr
Counter for cases where there is more than one single Cluster SpacePoint related to a Cluster.
unsigned int m_noTwoClusterSPCtr
Counter for cases where no related two Cluster could be found for a Cluster.
StoreArray< PXDCluster > m_PXDClusters
PXDClusters StoreArray.
unsigned int m_abortedNoValidSPCtr
Counter for aborted conversions due to no found valid SpacePoint to any Cluster of the GFTC.
boost::tuple< bool, T, T > flaggedPair
typdef, for avoiding having a vector<bool> and a vector<pair<T,T>>
std::string m_SPTCName
Name of collection under which SpacePointTrackCands will be stored in the StoreArray.
conversionStatus getFailEnum(int intToConvert)
get the enum representation of an integer
void increaseFailCounter(conversionStatus status)
increase the counter that 'belongs' to the conversionStatus
void markHitAsUsed(std::vector< flaggedPair< int > > &flaggedHitIDs, int hitToMark)
mark a hit as used, i.e.
unsigned int m_skippedPXDnoSPCtr
Counter for skipped PXD Clusters, due to no found SpacePoint.
std::pair< Belle2::SpacePoint *, conversionStatus > findAppropriateSpacePoint(const Belle2::RelationVector< Belle2::SpacePoint > &spacePoints, std::vector< flaggedPair< int > > &flaggedHitIDs)
given a RelationVector with SpacePoints in it, it tries to get the appropriate one (see main document...
unsigned int m_skippedPXDnoValidSPCtr
Counter for skipped PXD Clusters due to no found valid SpacePoint.
std::string m_SVDClusterName
SVDCluster collection name.
std::string m_PXDClusterSPName
PXDCluster SpacePoints collection name.
unsigned int m_skippedPXDnoTHCtr
Counter for skipped PXD Clusters, due to no related TrueHit to a SpacePoint.
std::pair< int, int > checkExistAndValid(int clusterInd, int detID, std::vector< flaggedPair< int > > &flaggedHitIDs)
check if the Cluster (of a SpacePoint) is valid and/or exists in a genfit::TrackCand
unsigned int m_skippedCluster
Counter for skipped Cluster.
std::pair< Belle2::SpacePoint *, conversionStatus > getSpacePoint(const ClusterType *cluster, std::vector< flaggedPair< int > > &flaggedHitIDs, int iHit, bool singleCluster, std::string arrayName="")
templated version to get a SpacePoint from a Cluster
bool m_PARAMcheckNoSingleSVDSP
Switch for checking the StoreArray of non-single cluster SVD SpacePoints in initialize.
unsigned int m_SpacePointTCCtr
Counter for SpacePointTrackCands which were converted (if a curling track is split up,...
unsigned int m_abortedLowNDFCtr
Counter for SpacePointTrackCands that were not stored due to a too small number of degrees of freedom...
bool checkUsedAllHits(std::vector< flaggedPair< int > > &flaggedHitIDs)
check if all hits have been used (i.e.
std::vector< int > getClusterIndices(const Belle2::SpacePoint *spacePoint, std::string storeArrayName)
get the indices of the Clusters related to the SpacePoint.
void initializeCounters()
reset counters to 0 to avoid indeterministic behaviour
unsigned int m_abortedMiscCtr
temporary counter used for counting all failed conversions for which the reason cannot be deduced at ...
int m_NDF
number of degrees of freedom.
unsigned int m_singleClusterSPCtr
Counter for single cluster SVD SpacePoints.
std::pair< const Belle2::SpacePointTrackCand, conversionStatus > createSpacePointTC(const genfit::TrackCand *genfitTC)
create a SpacePointTrackCand from the genfit::TrackCand
int getAppropriateSpacePointIndex(const std::vector< std::pair< bool, bool > > &existAndValidSPs, const std::vector< std::pair< int, int > > &clusterPositions)
get the position of the appropriate SpacePoint inside the RelationVector NOTE: returns negative index...
StoreArray< SpacePoint > m_PXDSpacePoints
PXDSpacePoints StoreArray.
StoreArray< SpacePoint > m_NoSingleClusterSpacePoints
SVD SpacePoints StoreArray consisting of two SVDClusters.
StoreArray< SVDTrueHit > m_SVDTrueHits
SVDTrueHits StoreArray.
std::string svdMainArrayName
Name of the Array of SVD SpacePoints that shall be searched first.
unsigned int m_abortedTrueHitCtr
Counting discarded conversions due to check for TrueHits not good.
BELLE2_DEFINE_EXCEPTION(UnusedHits, "Not all hits of the genfit::TrackCand have been marked as used. This indicates that not all hits have been used to create a SpacePointTrackCand.")
Exception thrown, when not all hits of a genfit::TrackCand have been used for conversion.
Base class for Modules.
Definition: Module.h:72
Class for type safe access to objects that are referred to in relations.
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
Abstract base class for different kinds of events.