Belle II Software  release-06-02-00
CurlingTrackCandSplitterModule.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 <tracking/spacePointCreation/SpacePointTrackCand.h>
13 #include <tracking/spacePointCreation/SpacePoint.h>
14 
15 #include <array>
16 
17 #include <framework/geometry/B2Vector3.h> // gradually moving to B2Vector3 instead of TVector3
18 
19 #include <TFile.h>
20 #include <TTree.h>
21 
22 namespace Belle2 {
48 
49  public:
50 
54  void initialize() override;
55 
56  void event() override;
58  void terminate() override;
61  enum {
62  c_nSVDPlanes = 4,
63  c_nPXDPlanes = 2,
64 
65  c_nPlanes = c_nSVDPlanes + c_nPXDPlanes,
66  };
67 
69  struct RootVariables {
70  std::array<std::vector<double>, c_nPlanes> SpacePointXGlobal;
71  std::array<std::vector<double>, c_nPlanes> SpacePointYGlobal;
72  std::array<std::vector<double>, c_nPlanes> SpacePointZGlobal;
74  std::array<std::vector<double>, c_nPlanes> SpacePointULocal;
75  std::array<std::vector<double>, c_nPlanes> SpacePointVLocal;
76 // std::array<std::vector<double>, c_nPlanes> SpacePointZLocal; /**< local z-positions of SpacePoints (layerwise)*/
77 
78  std::array<std::vector<double>, c_nPlanes> TrueHitXGlobal;
79  std::array<std::vector<double>, c_nPlanes> TrueHitYGlobal;
80  std::array<std::vector<double>, c_nPlanes> TrueHitZGlobal;
83  std::array<std::vector<double>, c_nPlanes> PosResidueXGlobal;
85  std::array<std::vector<double>, c_nPlanes> PosResidueYGlobal;
87  std::array<std::vector<double>, c_nPlanes> PosResidueZGlobal;
88 
90  std::array<std::vector<double>, c_nPlanes> PosResidueULocal;
92  std::array<std::vector<double>, c_nPlanes> PosResidueVLocal;
93 
94  std::array<std::vector<double>, c_nPlanes> TrueHitULocal;
95  std::array<std::vector<double>, c_nPlanes> TrueHitVLocal;
96 // std::array<std::vector<double>, c_nPlanes> TrueHitZLocal; /**< local z-positions of TrueHits (layerwise) */
97 
98  std::array<std::vector<double>, c_nPlanes> PosResiduesLocal;
99  std::array<std::vector<double>, c_nPlanes> PosResiduesGlobal;
102  std::array<std::vector<double>, c_nPlanes> MisMatchPosResiduals;
104  std::array<std::vector<double>, c_nPlanes> MisMatchPosX;
106  std::array<std::vector<double>, c_nPlanes> MisMatchPosY;
108  std::array<std::vector<double>, c_nPlanes> MisMatchPosZ;
109 
111  std::array<std::vector<double>, c_nPlanes> MisMatchPosU;
113  std::array<std::vector<double>, c_nPlanes> MisMatchPosV;
114 
116  std::array<std::vector<double>, c_nPlanes> MisMatchMomX;
118  std::array<std::vector<double>, c_nPlanes> MisMatchMomY;
120  std::array<std::vector<double>, c_nPlanes> MisMatchMomZ;
121  };
122 
126  struct TaggedUVPos {
127  bool m_setU;
128  bool m_setV;
129  double m_U;
130  double m_V;
133  TaggedUVPos() : m_setU(false), m_setV(false), m_U(0.), m_V(0.) {}
134  };
135 
136  protected:
137 
140  std::string m_PARAMsptcName;
144 
152  std::vector<double> m_PARAMsetOrigin;
153 
174  void initializeCounters();
179  const std::vector<int> checkTrackCandForCurling(const Belle2::SpacePointTrackCand&, RootVariables& rootVariables);
180 
186  template<class TrueHit>
187  std::pair<const B2Vector3<double>, const B2Vector3<double> >
188  getGlobalPositionAndMomentum(TrueHit* aTrueHit);
189 
193  const std::vector<Belle2::SpacePointTrackCand>
194  splitCurlingTrackCand(const Belle2::SpacePointTrackCand& SPTrackCand, int NTracklets, const std::vector<int>& splitIndices);
195 
197  bool getDirectionOfFlight(std::pair<const B2Vector3<double>, const B2Vector3<double> > const& hitPosAndMom,
198  const B2Vector3<double>& origin);
199 
203  BELLE2_DEFINE_EXCEPTION(FoundNoTrueHit, "Found no TrueHit for one (or more) Cluster(s). "
204  "Without a TrueHit a decision if a TrackCand is curling is not possible");
205 
209  BELLE2_DEFINE_EXCEPTION(TrueHitsNotMatching, "The TrueHits related to the two SVDClusters of a SpacePoint are not the same!")
210 
211 
214  BELLE2_DEFINE_EXCEPTION(FoundNoCluster, "No related Cluster to a SpacePoint was found.");
215 
218  std::vector<std::string> m_PARAMrootFileName;
219  TFile* m_rootFilePtr;
220  TTree* m_treePtr;
222  std::array<std::vector<double>, c_nPlanes> m_rootSpacePointXGlobals;
223  std::array<std::vector<double>, c_nPlanes> m_rootSpacePointYGlobals;
224  std::array<std::vector<double>, c_nPlanes> m_rootSpacePointZGlobals;
226  std::array<std::vector<double>, c_nPlanes> m_rootSpacePointULocals;
227  std::array<std::vector<double>, c_nPlanes> m_rootSpacePointVLocals;
228 // std::array<std::vector<double>, c_nPlanes> m_rootSpacePointZLocals; /**< Local Z-Positions of SpacePoints (layerwise) */
229 
230  std::array<std::vector<double>, c_nPlanes> m_rootTrueHitXGlobals;
231  std::array<std::vector<double>, c_nPlanes> m_rootTrueHitYGlobals;
232  std::array<std::vector<double>, c_nPlanes> m_rootTrueHitZGlobals;
234  std::array<std::vector<double>, c_nPlanes> m_rootTrueHitULocals;
235  std::array<std::vector<double>, c_nPlanes> m_rootTrueHitVLocals;
236 // std::vector<double> m_rootTrueHitZLocals; /**< Local Z-Positions of TrueHits (layerwise) */
237 
239  std::array<std::vector<double>, c_nPlanes> m_rootPosResidueXGlobal;
241  std::array<std::vector<double>, c_nPlanes> m_rootPosResidueYGlobal;
243  std::array<std::vector<double>, c_nPlanes> m_rootPosResidueZGlobal;
244 
246  std::array<std::vector<double>, c_nPlanes> m_rootPosResidueULocal;
248  std::array<std::vector<double>, c_nPlanes> m_rootPosResidueVLocal;
249 
251  std::array<std::vector<double>, c_nPlanes> m_rootLocalPosResiduals;
253  std::array<std::vector<double>, c_nPlanes> m_rootGlobalPosResiduals;
254 
256  std::array<std::vector<double>, c_nPlanes> m_rootMisMatchPosDistance;
258  std::array<std::vector<double>, c_nPlanes> m_rootMisMatchPosX;
260  std::array<std::vector<double>, c_nPlanes> m_rootMisMatchPosY;
262  std::array<std::vector<double>, c_nPlanes> m_rootMisMatchPosZ;
263 
265  std::array<std::vector<double>, c_nPlanes> m_rootMisMatchPosU;
267  std::array<std::vector<double>, c_nPlanes> m_rootMisMatchPosV;
268 
270  std::array<std::vector<double>, c_nPlanes> m_rootMisMatchMomX;
272  std::array<std::vector<double>, c_nPlanes> m_rootMisMatchMomY;
274  std::array<std::vector<double>, c_nPlanes> m_rootMisMatchMomZ;
275 
277  TaggedUVPos getUV(const SpacePoint* spacePoint);
278 
280  template <class TrueHit>
281  void getValuesForRoot(const SpacePoint* spacePoint, const TrueHit* trueHit, RootVariables& rootVariables);
282 
283  void writeToRoot(const RootVariables& rootVariables);
284  };
286 }
Class to collect log likelihoods from Clusters from ECL and KLM aimed for output to mdst includes fun...
Definition: Cluster.h:26
Module for checking SpacePointTrackCandidates for curling behaviour and splitting them into Track Can...
std::array< std::vector< double >, c_nPlanes > m_rootMisMatchPosX
Difference of X-positions (global) for mismatched TrueHits (layerwise)
std::array< std::vector< double >, c_nPlanes > m_rootMisMatchPosV
Difference of V-positions (local) for mismatched TrueHits (layerwise)
int m_NoCurlingTCsCtr
Counter for SPTCs that were not curling and hence were added to the StoreArray of first out parts.
std::string m_PARAMcurlingOutRestName
collection name of all but the first outgoing parts of a curling TrackCand
std::array< std::vector< double >, c_nPlanes > m_rootPosResidueYGlobal
Y-position (global) difference between TrueHit and SpacePoint (layerwise)
std::array< std::vector< double >, c_nPlanes > m_rootSpacePointZGlobals
Global Z-Positions of SpacePoints (layerwise)
std::array< std::vector< double >, c_nPlanes > m_rootMisMatchPosU
Difference of U-positions (local) for mismatched TrueHits (layerwise)
std::array< std::vector< double >, c_nPlanes > m_rootMisMatchMomX
Difference of Momentum in X-Direction for TrueHits that do not match but are related from one SpacePo...
bool m_saveCompleteCurler
set to true if all parts of a curling TrackCand should be stored in a separate StoreArray (no paramet...
void initialize() override
initialize: initialize counters, register stuff in DataStore, check if all necessary StoreArrays are ...
std::array< std::vector< double >, c_nPlanes > m_rootSpacePointYGlobals
Global Y-Positions of SpacePoints (layerwise)
std::vector< double > m_PARAMsetOrigin
set the origin to a specific point.
void event() override
event: check SpacePointTrackCand for curling behaviour, split if needed (and wanted by user)
std::array< std::vector< double >, c_nPlanes > m_rootGlobalPosResiduals
Global Position Residuals between TrueHits and SpacePoints (layerwise)
int m_PARAMnTrackStubs
maximum number of TrackCand Stubs to be stored for a curling TrackCand
bool getDirectionOfFlight(std::pair< const B2Vector3< double >, const B2Vector3< double > > const &hitPosAndMom, const B2Vector3< double > &origin)
determine the direction of flight of a particle for a given hit and the origin (assumed interaction p...
std::string m_PARAMcurlingAllInName
collection name of all ingoing parts of a curling TrackCand
std::array< std::vector< double >, c_nPlanes > m_rootTrueHitXGlobals
Global U-Positions of TrueHits (layerwise)
void terminate() override
terminate: print some summary on the modules work
std::array< std::vector< double >, c_nPlanes > m_rootMisMatchPosDistance
Distance of TrueHits that do not match but are related from one SpacePoint (layerwise)
std::string m_PARAMcompleteCurlerName
collection name of all parts of a curling TrackCand
std::string m_PARAMsptcName
collection name of the SpacePointTrackCands to be analyzed
int m_NoSingleTrueHitCtr
Counter for SpacePoints that relate to more than one TrueHit.
int m_createdTrackStubsCtr
Counter for created TrackCand Stubs by splitting a SpacePointTrackCand.
std::array< std::vector< double >, c_nPlanes > m_rootPosResidueXGlobal
X-position (global) difference between TrueHit and SpacePoint (layerwise)
std::array< std::vector< double >, c_nPlanes > m_rootMisMatchMomZ
Difference of Momentum in Z-Direction for TrueHits that do not match but are related from one SpacePo...
std::array< std::vector< double >, c_nPlanes > m_rootSpacePointXGlobals
Global X-Positions of SpacePoints (layerwise)
std::array< std::vector< double >, c_nPlanes > m_rootSpacePointULocals
Local U-Positions of SpacePoints (layerwise)
std::vector< std::string > m_PARAMrootFileName
two entries accepted.
const std::vector< int > checkTrackCandForCurling(const Belle2::SpacePointTrackCand &, RootVariables &rootVariables)
Check if the track candidate is curling.
std::array< std::vector< double >, c_nPlanes > m_rootMisMatchMomY
Difference of Momentum in Y-Direction for TrueHits that do not match but are related from one SpacePo...
void getValuesForRoot(const SpacePoint *spacePoint, const TrueHit *trueHit, RootVariables &rootVariables)
Get The Values that are later written to a ROOT file.
std::array< std::vector< double >, c_nPlanes > m_rootMisMatchPosZ
Difference of Z-positions (global) for mismatched TrueHits (layerwise)
TaggedUVPos getUV(const SpacePoint *spacePoint)
get U&V for a SpacePoint (via its relation to Clusters) (SpacePoint can only return normalized U&V co...
void writeToRoot(const RootVariables &rootVariables)
Write previously collected values to ROOT file.
std::pair< const B2Vector3< double >, const B2Vector3< double > > getGlobalPositionAndMomentum(TrueHit *aTrueHit)
Get the global position and momentum for a given TrueHit (PXD or SVD at the moment).
std::array< std::vector< double >, c_nPlanes > m_rootSpacePointVLocals
Local V-Positions of SpacePoints (layerwise)
std::array< std::vector< double >, c_nPlanes > m_rootPosResidueZGlobal
Z-position (global) difference between TrueHit and SpacePoint (layerwise)
B2Vector3< double > m_origin
origin used internally (set from user set value)
int m_noDecisionPossibleCtr
Counter for TrackCands where a decision if curling or not is not possible.
std::array< std::vector< double >, c_nPlanes > m_rootLocalPosResiduals
Local Position Residuals between TrueHits and SpacePoints (layerwise)
std::array< std::vector< double >, c_nPlanes > m_rootTrueHitYGlobals
Global V-Positions of TrueHits (layerwise)
bool m_PARAMuseNonSingleTHinPA
Switch for using SpacePoints in position Analysis that are related to more than one TrueHit.
std::string m_PARAMcurlingOutFirstName
collection name of the first outgoing (i.e.
const std::vector< Belle2::SpacePointTrackCand > splitCurlingTrackCand(const Belle2::SpacePointTrackCand &SPTrackCand, int NTracklets, const std::vector< int > &splitIndices)
Split a culring track candidate into (up to NTracklets) tracklets.
std::array< std::vector< double >, c_nPlanes > m_rootTrueHitVLocals
Local Y-Positions of TrueHits (layerwise)
int m_curlingTCCtr
Counter for TrackCands that show curling behaviour.
int m_spacePointTCCtr
Counter for presented SpacePointTrackCands.
void initializeCounters()
initialize all counters to 0 for avoiding undeterministic behaviour.
std::array< std::vector< double >, c_nPlanes > m_rootMisMatchPosY
Difference of Y-positions (global) for mismatched TrueHits (layerwise)
std::array< std::vector< double >, c_nPlanes > m_rootTrueHitULocals
Local X-Positions of TrueHits (layerwise)
BELLE2_DEFINE_EXCEPTION(FoundNoTrueHit, "Found no TrueHit for one (or more) Cluster(s). " "Without a TrueHit a decision if a TrackCand is curling is not possible")
Exception for case when no TrueHit can be found for a Cluster.
std::array< std::vector< double >, c_nPlanes > m_rootTrueHitZGlobals
Global Z-Positions of TrueHits (layerwise)
std::array< std::vector< double >, c_nPlanes > m_rootPosResidueVLocal
V-position (local) difference between TrueHit and SpacePoint (layerwise)
bool m_PARAMpositionAnalysis
Set to true if output to ROOT file is desired with the positions and position differences of SpacePoi...
bool m_PARAMsplitCurlers
indicating if the SpacePointTrackCands should only be analyzed for curling behaviour,...
std::array< std::vector< double >, c_nPlanes > m_rootPosResidueULocal
U-position (local) differnece between TrueHit and SpacePoint (layerwise)
Base class for Modules.
Definition: Module.h:72
Storage for (VXD) SpacePoint-based track candidates.
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:42
Abstract base class for different kinds of events.
std::array< std::vector< double >, c_nPlanes > PosResidueVLocal
V-position (local) difference between TrueHit and SpacePoint (layerwise)
std::array< std::vector< double >, c_nPlanes > MisMatchMomZ
Difference of Momentum in Z-Direction for TrueHits that do not match but are related from one SpacePo...
std::array< std::vector< double >, c_nPlanes > MisMatchPosZ
Difference of Z-positions (global) for mismatched TrueHits (layerwise)
std::array< std::vector< double >, c_nPlanes > MisMatchPosU
Difference of U-positions (local) for mismatched TrueHits (layerwise)
std::array< std::vector< double >, c_nPlanes > PosResidueZGlobal
Z-position (global) difference between TrueHit and SpacePoint (layerwise)
std::array< std::vector< double >, c_nPlanes > MisMatchMomX
Difference of Momentum in X-Direction for TrueHits that do not match but are related from one SpacePo...
std::array< std::vector< double >, c_nPlanes > MisMatchPosV
Difference of V-positions (local) for mismatched TrueHits (layerwise)
std::array< std::vector< double >, c_nPlanes > MisMatchPosResiduals
Distance between TrueHits that do not match but are related from one SpacePoint (layerwise)
std::array< std::vector< double >, c_nPlanes > MisMatchPosY
Difference of Y-positions (global) for mismatched TrueHits (layerwise)
std::array< std::vector< double >, c_nPlanes > SpacePointYGlobal
global y-positions of SpacePoints (layerwise)
std::array< std::vector< double >, c_nPlanes > MisMatchPosX
Difference of X-positions (global) for mismatched TrueHits (layerwise)
std::array< std::vector< double >, c_nPlanes > SpacePointVLocal
local v-positions of SpacePoints (layerwise)
std::array< std::vector< double >, c_nPlanes > TrueHitULocal
local u-positions of TrueHits (layerwise)
std::array< std::vector< double >, c_nPlanes > SpacePointZGlobal
global z-positions of SpacePoints (layerwise)
std::array< std::vector< double >, c_nPlanes > PosResidueULocal
U-position (local) differnece between TrueHit and SpacePoint (layerwise)
std::array< std::vector< double >, c_nPlanes > TrueHitXGlobal
global x-positions of TrueHits (layerwise)
std::array< std::vector< double >, c_nPlanes > PosResiduesGlobal
position differences in global coordinates (layerwise)
std::array< std::vector< double >, c_nPlanes > SpacePointULocal
local u-positions of SpacePoints (layerwise)
std::array< std::vector< double >, c_nPlanes > TrueHitVLocal
local v-positions of TrueHits (layerwise)
std::array< std::vector< double >, c_nPlanes > MisMatchMomY
Difference of Momentum in Y-Direction for TrueHits that do not match but are related from one SpacePo...
std::array< std::vector< double >, c_nPlanes > PosResidueYGlobal
Y-position (global) difference between TrueHit and SpacePoint (layerwise)
std::array< std::vector< double >, c_nPlanes > SpacePointXGlobal
global x-positions of SpacePoints (layerwise)
std::array< std::vector< double >, c_nPlanes > PosResiduesLocal
position differences in local coordinates (layerwise)
std::array< std::vector< double >, c_nPlanes > PosResidueXGlobal
X-position (global) difference between TrueHit and SpacePoint (layerwise)
std::array< std::vector< double >, c_nPlanes > TrueHitZGlobal
global z-positions of TrueHits (layerwise)
std::array< std::vector< double >, c_nPlanes > TrueHitYGlobal
global y-positions of TrueHits (layerwise)
struct for easier handling of getting U- & V-position of SpacePoints and some difficulties that arise...
TaggedUVPos()
default constructor initializes both bools to false and both doubles to 0.