Belle II Software release-09-00-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 <framework/datastore/StoreArray.h>
13#include <tracking/spacePointCreation/SpacePointTrackCand.h>
14#include <tracking/spacePointCreation/SpacePoint.h>
15
16#include <array>
17
18#include <framework/geometry/B2Vector3.h>
19
20#include <TFile.h>
21#include <TTree.h>
22
23namespace Belle2 {
49
50 public:
51
55 void initialize() override;
56
57 void event() override;
59 void terminate() override;
62 enum {
63 c_nSVDPlanes = 4,
64 c_nPXDPlanes = 2,
65
66 c_nPlanes = c_nSVDPlanes + c_nPXDPlanes,
67 };
68
71 std::array<std::vector<double>, c_nPlanes> SpacePointXGlobal;
72 std::array<std::vector<double>, c_nPlanes> SpacePointYGlobal;
73 std::array<std::vector<double>, c_nPlanes> SpacePointZGlobal;
75 std::array<std::vector<double>, c_nPlanes> SpacePointULocal;
76 std::array<std::vector<double>, c_nPlanes> SpacePointVLocal;
77// std::array<std::vector<double>, c_nPlanes> SpacePointZLocal; /**< local z-positions of SpacePoints (layerwise)*/
78
79 std::array<std::vector<double>, c_nPlanes> TrueHitXGlobal;
80 std::array<std::vector<double>, c_nPlanes> TrueHitYGlobal;
81 std::array<std::vector<double>, c_nPlanes> TrueHitZGlobal;
84 std::array<std::vector<double>, c_nPlanes> PosResidueXGlobal;
86 std::array<std::vector<double>, c_nPlanes> PosResidueYGlobal;
88 std::array<std::vector<double>, c_nPlanes> PosResidueZGlobal;
89
91 std::array<std::vector<double>, c_nPlanes> PosResidueULocal;
93 std::array<std::vector<double>, c_nPlanes> PosResidueVLocal;
94
95 std::array<std::vector<double>, c_nPlanes> TrueHitULocal;
96 std::array<std::vector<double>, c_nPlanes> TrueHitVLocal;
97// std::array<std::vector<double>, c_nPlanes> TrueHitZLocal; /**< local z-positions of TrueHits (layerwise) */
98
99 std::array<std::vector<double>, c_nPlanes> PosResiduesLocal;
100 std::array<std::vector<double>, c_nPlanes> PosResiduesGlobal;
103 std::array<std::vector<double>, c_nPlanes> MisMatchPosResiduals;
105 std::array<std::vector<double>, c_nPlanes> MisMatchPosX;
107 std::array<std::vector<double>, c_nPlanes> MisMatchPosY;
109 std::array<std::vector<double>, c_nPlanes> MisMatchPosZ;
110
112 std::array<std::vector<double>, c_nPlanes> MisMatchPosU;
114 std::array<std::vector<double>, c_nPlanes> MisMatchPosV;
115
117 std::array<std::vector<double>, c_nPlanes> MisMatchMomX;
119 std::array<std::vector<double>, c_nPlanes> MisMatchMomY;
121 std::array<std::vector<double>, c_nPlanes> MisMatchMomZ;
122 };
123
127 struct TaggedUVPos {
128 bool m_setU;
129 bool m_setV;
130 double m_U;
131 double m_V;
134 TaggedUVPos() : m_setU(false), m_setV(false), m_U(0.), m_V(0.) {}
135 };
136
137 protected:
138
141 std::string m_PARAMsptcName;
145
153 std::vector<double> m_PARAMsetOrigin;
154
181 void initializeCounters();
186 const std::vector<int> checkTrackCandForCurling(const Belle2::SpacePointTrackCand&, RootVariables& rootVariables);
187
193 template<class TrueHit>
194 std::pair<const B2Vector3D, const B2Vector3D >
196
200 const std::vector<Belle2::SpacePointTrackCand>
201 splitCurlingTrackCand(const Belle2::SpacePointTrackCand& SPTrackCand, int NTracklets, const std::vector<int>& splitIndices);
202
204 bool getDirectionOfFlight(std::pair<const B2Vector3D, const B2Vector3D > const& hitPosAndMom,
205 const B2Vector3D& origin);
206
210 BELLE2_DEFINE_EXCEPTION(FoundNoTrueHit, "Found no TrueHit for one (or more) Cluster(s). "
211 "Without a TrueHit a decision if a TrackCand is curling is not possible");
212
216 BELLE2_DEFINE_EXCEPTION(TrueHitsNotMatching, "The TrueHits related to the two SVDClusters of a SpacePoint are not the same!")
217
218
221 BELLE2_DEFINE_EXCEPTION(FoundNoCluster, "No related Cluster to a SpacePoint was found.");
222
225 std::vector<std::string> m_PARAMrootFileName;
227 TTree* m_treePtr;
229 std::array<std::vector<double>, c_nPlanes> m_rootSpacePointXGlobals;
230 std::array<std::vector<double>, c_nPlanes> m_rootSpacePointYGlobals;
231 std::array<std::vector<double>, c_nPlanes> m_rootSpacePointZGlobals;
233 std::array<std::vector<double>, c_nPlanes> m_rootSpacePointULocals;
234 std::array<std::vector<double>, c_nPlanes> m_rootSpacePointVLocals;
235// std::array<std::vector<double>, c_nPlanes> m_rootSpacePointZLocals; /**< Local Z-Positions of SpacePoints (layerwise) */
236
237 std::array<std::vector<double>, c_nPlanes> m_rootTrueHitXGlobals;
238 std::array<std::vector<double>, c_nPlanes> m_rootTrueHitYGlobals;
239 std::array<std::vector<double>, c_nPlanes> m_rootTrueHitZGlobals;
241 std::array<std::vector<double>, c_nPlanes> m_rootTrueHitULocals;
242 std::array<std::vector<double>, c_nPlanes> m_rootTrueHitVLocals;
243// std::vector<double> m_rootTrueHitZLocals; /**< Local Z-Positions of TrueHits (layerwise) */
244
246 std::array<std::vector<double>, c_nPlanes> m_rootPosResidueXGlobal;
248 std::array<std::vector<double>, c_nPlanes> m_rootPosResidueYGlobal;
250 std::array<std::vector<double>, c_nPlanes> m_rootPosResidueZGlobal;
251
253 std::array<std::vector<double>, c_nPlanes> m_rootPosResidueULocal;
255 std::array<std::vector<double>, c_nPlanes> m_rootPosResidueVLocal;
256
258 std::array<std::vector<double>, c_nPlanes> m_rootLocalPosResiduals;
260 std::array<std::vector<double>, c_nPlanes> m_rootGlobalPosResiduals;
261
263 std::array<std::vector<double>, c_nPlanes> m_rootMisMatchPosDistance;
265 std::array<std::vector<double>, c_nPlanes> m_rootMisMatchPosX;
267 std::array<std::vector<double>, c_nPlanes> m_rootMisMatchPosY;
269 std::array<std::vector<double>, c_nPlanes> m_rootMisMatchPosZ;
270
272 std::array<std::vector<double>, c_nPlanes> m_rootMisMatchPosU;
274 std::array<std::vector<double>, c_nPlanes> m_rootMisMatchPosV;
275
277 std::array<std::vector<double>, c_nPlanes> m_rootMisMatchMomX;
279 std::array<std::vector<double>, c_nPlanes> m_rootMisMatchMomY;
281 std::array<std::vector<double>, c_nPlanes> m_rootMisMatchMomZ;
282
284 TaggedUVPos getUV(const SpacePoint* spacePoint);
285
287 template <class TrueHit>
288 void getValuesForRoot(const SpacePoint* spacePoint, const TrueHit* trueHit, RootVariables& rootVariables);
289
290 void writeToRoot(const RootVariables& rootVariables);
291 };
293}
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.
StoreArray< SpacePointTrackCand > m_spacePointTCs
SpacePointTrackCand StoreArray.
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...
StoreArray< SpacePointTrackCand > m_curlingAllIns
Curling SpacePointTrackCand StoreArray.
StoreArray< SpacePointTrackCand > m_curlingFirstOuts
Curling SpacePointTrackCand StoreArray.
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.
B2Vector3D m_origin
origin used internally (set from user set value)
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
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::pair< const B2Vector3D, const B2Vector3D > getGlobalPositionAndMomentum(TrueHit *aTrueHit)
Get the global position and momentum for a given TrueHit (PXD or SVD at the moment).
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)
bool getDirectionOfFlight(std::pair< const B2Vector3D, const B2Vector3D > const &hitPosAndMom, const B2Vector3D &origin)
determine the direction of flight of a particle for a given hit and the origin (assumed interaction p...
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...
StoreArray< SpacePointTrackCand > m_curlingCompletes
Curling SpacePointTrackCand StoreArray.
void writeToRoot(const RootVariables &rootVariables)
Write previously collected values to ROOT file.
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)
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...
StoreArray< SpacePointTrackCand > m_curlingRestOuts
Curling SpacePointTrackCand StoreArray.
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
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
#define BELLE2_DEFINE_EXCEPTION(ClassName, Message)
Macro that defines an exception with the given message template.
Abstract base class for different kinds of events.
STL namespace.
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.