Belle II Software  release-05-02-19
SPTCRefereeModule.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2014 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Thomas Madlener *
7  * *
8  **************************************************************************/
9 #pragma once
10 
11 #include <framework/core/Module.h>
12 #include <framework/datastore/StoreArray.h>
13 
14 #include <tracking/spacePointCreation/SpacePointTrackCand.h>
15 
16 #include <string>
17 #include <vector>
18 
19 namespace Belle2 {
41  class SPTCRefereeModule : public Module {
42 
43  public:
46  void initialize() override;
48  void event() override;
50  void terminate() override;
52  protected:
53 
56  typedef std::tuple<std::vector<int>, std::vector<int>> CheckInfo;
57 
58  // ==================================================== PARAMETERS ============================================================
59 
61  std::string m_PARAMsptcName = "";
62 
64  std::string m_PARAMnewArrayName = "";
65 
68  std::string m_PARAMcurlingSuffix = "_curlParts";
69 
72 
74  bool m_PARAMcheckIfFitted = true;
75 
77  bool m_PARAMcheckMinDistance = true;
78 
80  bool m_PARAMcheckCurling = true;
81 
83  bool m_PARAMsplitCurlers = false;
84 
86  bool m_PARAMkeepOnlyFirstPart = false;
87 
89  bool m_PARAMuseMCInfo = true;
90 
92  bool m_PARAMkickSpacePoint = false;
93 
96 
99  bool m_PARAMstoreNewArray = true;
100 
102  double m_PARAMminDistance = 0.;
103 
105  std::vector<double> m_PARAMsetOrigin = { 0., 0., 0. };
106 
107  // ======================================================= INTERNALY USED MEMBERS =============================================
108 
111 
113  std::string m_curlingArrayName;
114 
115  // ========================================== COUNTER VARIABLES ===============================================================
116 
118  unsigned int m_SameSensorCtr;
119 
121  unsigned int m_minDistanceCtr;
122 
124  unsigned int m_totalTrackCandCtr;
125 
127  unsigned int m_kickedSpacePointsCtr;
128 
130  unsigned int m_curlingTracksCtr;
131 
133  unsigned int m_regTrackStubsCtr;
134 
136  unsigned int m_allInwardsCtr;
137 
141  void initializeCounters()
142  {
144  m_minDistanceCtr = 0;
147  m_curlingTracksCtr = 0;
149  m_allInwardsCtr = 0;
150  }
151 
152 
153  // ========================================================== MODULE METHODS ==================================================
154 
159  const std::vector<int> checkSameSensor(Belle2::SpacePointTrackCand* trackCand);
160 
164  const std::vector<int> checkMinDistance(Belle2::SpacePointTrackCand* trackCand, double minDistance);
165 
171  const std::vector<int> checkCurling(Belle2::SpacePointTrackCand* trackCand, bool useMCInfo);
172 
176  const std::vector<bool> getDirectionsOfFlight(const std::vector<const Belle2::SpacePoint*>& spacePoints, bool useMCInfo);
177 
181  std::vector<Belle2::SpacePointTrackCand>
182  splitTrackCand(const Belle2::SpacePointTrackCand* trackCand, const std::vector<int>& splitIndices, bool onlyFirstPart,
183  const CheckInfo& prevChecksInfo, bool removedHits);
184 
190  template <typename TrueHitType>
191  bool getDirOfFlightTrueHit(const Belle2::SpacePoint* spacePoint, B2Vector3F origin);
192 
197  std::vector<bool> getDirsOfFlightSpacePoints(const std::vector<const Belle2::SpacePoint*>& spacePoints, B2Vector3F origin);
198 
202  bool getDirOfFlightPosMom(B2Vector3F position, B2Vector3F momentum, B2Vector3F origin);
203 
208  void
210 
217  const Belle2::SpacePointTrackCand* origTrackCand);
218 
222  unsigned short int getCheckStatus(const Belle2::SpacePointTrackCand* trackCand);
223 
228  const std::vector<int> removeSpacePoints(Belle2::SpacePointTrackCand* trackCand, const std::vector<int>& indsToRemove);
229 
232  template<typename T>
233  bool vectorHasValueBetween(std::vector<T> V, std::pair<T, T> P)
234  {
235  return std::find_if(V.begin(), V.end(), [&P](const T & aValue) { return (aValue < P.second && aValue >= P.first);}) != V.end();
236  }
237  };
239 }
Belle2::SPTCRefereeModule::splitTrackCand
std::vector< Belle2::SpacePointTrackCand > splitTrackCand(const Belle2::SpacePointTrackCand *trackCand, const std::vector< int > &splitIndices, bool onlyFirstPart, const CheckInfo &prevChecksInfo, bool removedHits)
split a curling SpacePointTrackCand into TrackStubs.
Definition: SPTCRefereeModule.cc:478
Belle2::SPTCRefereeModule::m_PARAMcheckIfFitted
bool m_PARAMcheckIfFitted
if true it is looked for any related RecoTrack and if that RecoTrack has a valid fit.
Definition: SPTCRefereeModule.h:81
Belle2::SPTCRefereeModule::m_kickedSpacePointsCtr
unsigned int m_kickedSpacePointsCtr
counter of kicked SpacePoints
Definition: SPTCRefereeModule.h:134
Belle2::SPTCRefereeModule::m_PARAMkeepOnlyFirstPart
bool m_PARAMkeepOnlyFirstPart
parameter for keeping only the first part of a curling SpacePointTrackCand
Definition: SPTCRefereeModule.h:93
Belle2::SPTCRefereeModule::initialize
void initialize() override
initialize: check StoreArrays, initialize counters, ...
Definition: SPTCRefereeModule.cc:104
Belle2::SPTCRefereeModule::m_origin
B2Vector3F m_origin
origin used internally.
Definition: SPTCRefereeModule.h:117
Belle2::SPTCRefereeModule::initializeCounters
void initializeCounters()
initialize all counters to 0
Definition: SPTCRefereeModule.h:148
Belle2::SPTCRefereeModule::getDirOfFlightTrueHit
bool getDirOfFlightTrueHit(const Belle2::SpacePoint *spacePoint, B2Vector3F origin)
get the direction of flight for a SpacePoint by using information from the underlying TrueHit NOTE: t...
Definition: SPTCRefereeModule.cc:597
Belle2::SPTCRefereeModule::checkMinDistance
const std::vector< int > checkMinDistance(Belle2::SpacePointTrackCand *trackCand, double minDistance)
Check if two subsequent SpacePoints are seperated by at least the provided minDistance.
Definition: SPTCRefereeModule.cc:371
Belle2::SPTCRefereeModule::m_allInwardsCtr
unsigned int m_allInwardsCtr
counter for the number of SPTCs which have direction of flight inward for all SpacePoints in them
Definition: SPTCRefereeModule.h:143
Belle2::SPTCRefereeModule::event
void event() override
event: check SpacePointTrackCands
Definition: SPTCRefereeModule.cc:150
Belle2::SPTCRefereeModule::m_PARAMcurlingSuffix
std::string m_PARAMcurlingSuffix
Suffix that will be used to get a name for the StoreArray that holds the trackStubs that were obtaine...
Definition: SPTCRefereeModule.h:75
Belle2::SpacePoint
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:52
Belle2::SPTCRefereeModule::removeSpacePoints
const std::vector< int > removeSpacePoints(Belle2::SpacePointTrackCand *trackCand, const std::vector< int > &indsToRemove)
remove the SpacePoint passed to this function from the SpacePointTrackCand
Definition: SPTCRefereeModule.cc:406
Belle2::B2Vector3< float >
Belle2::SPTCRefereeModule::getDirectionsOfFlight
const std::vector< bool > getDirectionsOfFlight(const std::vector< const Belle2::SpacePoint * > &spacePoints, bool useMCInfo)
get the directions of Flight for every SpacePoint in the passed vector.
Definition: SPTCRefereeModule.cc:570
Belle2::SPTCRefereeModule::m_PARAMstoreNewArray
bool m_PARAMstoreNewArray
parameter for indicating if all checked SpacePointTrackCands should be stored in a new StoreArray NOT...
Definition: SPTCRefereeModule.h:106
Belle2::SPTCRefereeModule::terminate
void terminate() override
terminate: print some summary information
Definition: SPTCRefereeModule.cc:310
Belle2::SPTCRefereeModule::m_curlingTracksCtr
unsigned int m_curlingTracksCtr
counter for tracks that curl
Definition: SPTCRefereeModule.h:137
Belle2::SPTCRefereeModule::m_PARAMsetOrigin
std::vector< double > m_PARAMsetOrigin
assumed interaction point from which the SpacePointTrackCands emerge.
Definition: SPTCRefereeModule.h:112
Belle2::SPTCRefereeModule::getDirOfFlightPosMom
bool getDirOfFlightPosMom(B2Vector3F position, B2Vector3F momentum, B2Vector3F origin)
get the direction of flight provided the global position and momentum of a SpacePoint/TrueHit for the...
Definition: SPTCRefereeModule.cc:639
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SPTCRefereeModule::copyToNewStoreArray
void copyToNewStoreArray(const Belle2::SpacePointTrackCand *trackCand, Belle2::StoreArray< Belle2::SpacePointTrackCand > newStoreArray)
copy the SpacePointTrackCand to a new StoreArray and register a relation to the original trackCand
Definition: SPTCRefereeModule.cc:663
Belle2::SPTCRefereeModule::m_SameSensorCtr
unsigned int m_SameSensorCtr
counter for TrackCands with SpacePoints on the same sensor
Definition: SPTCRefereeModule.h:125
Belle2::SPTCRefereeModule::m_PARAMcheckMinDistance
bool m_PARAMcheckMinDistance
parameter for indicating if the check for the minimal distance between two subsequent SpacePoints sho...
Definition: SPTCRefereeModule.h:84
Belle2::SPTCRefereeModule::m_PARAMuseMCInfo
bool m_PARAMuseMCInfo
parameter for indicating if MC information should be used or not
Definition: SPTCRefereeModule.h:96
Belle2::SPTCRefereeModule::m_PARAMnewArrayName
std::string m_PARAMnewArrayName
Name of the output container of SpacePointTrackCands if 'storeNewArray' is set to true.
Definition: SPTCRefereeModule.h:71
Belle2::SPTCRefereeModule::m_curlingArrayName
std::string m_curlingArrayName
name of the StoreArray in which the trackStubs from a curling SPTC are stored
Definition: SPTCRefereeModule.h:120
Belle2::SPTCRefereeModule::m_PARAMkickSpacePoint
bool m_PARAMkickSpacePoint
parameter for indicating if only the 'problematic' SpacePoint shall be removed from the SPTC or if th...
Definition: SPTCRefereeModule.h:99
Belle2::SPTCRefereeModule::CheckInfo
std::tuple< std::vector< int >, std::vector< int > > CheckInfo
typedef for storing the outcome of previously done checks to have them available later.
Definition: SPTCRefereeModule.h:63
Belle2::SPTCRefereeModule::addToStoreArray
void addToStoreArray(const Belle2::SpacePointTrackCand &trackCand, Belle2::StoreArray< Belle2::SpacePointTrackCand > storeArray, const Belle2::SpacePointTrackCand *origTrackCand)
register the SpacePointTrackCand (i.e.
Definition: SPTCRefereeModule.cc:673
Belle2::SPTCRefereeModule::m_PARAMminDistance
double m_PARAMminDistance
minimal distance two subsequent SpacePoints have to be seperated
Definition: SPTCRefereeModule.h:109
Belle2::SPTCRefereeModule::SPTCRefereeModule
SPTCRefereeModule()
Constructor.
Belle2::SPTCRefereeModule::checkSameSensor
const std::vector< int > checkSameSensor(Belle2::SpacePointTrackCand *trackCand)
Check if two subsequent SpacePoints are on the same sensor.
Definition: SPTCRefereeModule.cc:342
Belle2::SPTCRefereeModule::m_regTrackStubsCtr
unsigned int m_regTrackStubsCtr
counter for the number of track stubs that were registered by this module
Definition: SPTCRefereeModule.h:140
Belle2::SPTCRefereeModule::vectorHasValueBetween
bool vectorHasValueBetween(std::vector< T > V, std::pair< T, T > P)
function to determine if any of the values in vector V are between the values of P (i....
Definition: SPTCRefereeModule.h:240
Belle2::SPTCRefereeModule::m_PARAMsplitCurlers
bool m_PARAMsplitCurlers
parameter for switching on/off the splitting of curling SpacePointTrackCands
Definition: SPTCRefereeModule.h:90
Belle2::SPTCRefereeModule::m_PARAMsptcName
std::string m_PARAMsptcName
Name of input container of SpacePointTrackCands.
Definition: SPTCRefereeModule.h:68
Belle2::SPTCRefereeModule::checkCurling
const std::vector< int > checkCurling(Belle2::SpacePointTrackCand *trackCand, bool useMCInfo)
Check if the SpacePointTrackCand shows curling behavior.
Definition: SPTCRefereeModule.cc:431
Belle2::SPTCRefereeModule::m_totalTrackCandCtr
unsigned int m_totalTrackCandCtr
counter for the total number of TrackCands
Definition: SPTCRefereeModule.h:131
Belle2::StoreArray< Belle2::SpacePointTrackCand >
Belle2::SPTCRefereeModule::m_PARAMcheckSameSensor
bool m_PARAMcheckSameSensor
parameter for indicating if the check for subsequent SpacePoints being on the same sensor should be d...
Definition: SPTCRefereeModule.h:78
Belle2::SPTCRefereeModule::m_PARAMminNumSpacePoints
int m_PARAMminNumSpacePoints
only keep track candidates which have at least m_PARAMminNumSpacePoints space points
Definition: SPTCRefereeModule.h:102
Belle2::SpacePointTrackCand
Storage for (VXD) SpacePoint-based track candidates.
Definition: SpacePointTrackCand.h:51
Belle2::SPTCRefereeModule::m_minDistanceCtr
unsigned int m_minDistanceCtr
counter for TrackCands with SpacePoints not far enough apart
Definition: SPTCRefereeModule.h:128
Belle2::SPTCRefereeModule::getCheckStatus
unsigned short int getCheckStatus(const Belle2::SpacePointTrackCand *trackCand)
get the checked referee status of a SPTC (i.e.
Definition: SPTCRefereeModule.cc:685
Belle2::SPTCRefereeModule::getDirsOfFlightSpacePoints
std::vector< bool > getDirsOfFlightSpacePoints(const std::vector< const Belle2::SpacePoint * > &spacePoints, B2Vector3F origin)
get the directions of flight for a vector of SpacePoints using only information from SpacePoints (i....
Definition: SPTCRefereeModule.cc:619
Belle2::SPTCRefereeModule::m_PARAMcheckCurling
bool m_PARAMcheckCurling
parameter for indicating if the SpacePointTrackCand should be checked for curling
Definition: SPTCRefereeModule.h:87