Belle II Software development
TagVertexModule.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
13// framework - DataStore
14#include <framework/database/DBObjPtr.h>
15#include <framework/datastore/StoreArray.h>
16#include <framework/datastore/StoreObjPtr.h>
17
18// Rave
19#include <analysis/VertexFitting/RaveInterface/RaveSetup.h>
20#include <analysis/VertexFitting/RaveInterface/RaveVertexFitter.h>
21#include <analysis/VertexFitting/RaveInterface/RaveKinematicVertexFitter.h>
22
23// kFit
24#include <analysis/VertexFitting/KFit/VertexFitKFit.h>
25
26// KFit
27#include <CLHEP/Geometry/Point3D.h>
28#include <CLHEP/Matrix/SymMatrix.h>
29#include <CLHEP/Vector/LorentzVector.h>
30
31// DataObjects
32#include <analysis/dataobjects/Particle.h>
33#include <analysis/dataobjects/ParticleList.h>
34#include <analysis/dataobjects/TagVertex.h>
35#include <mdst/dataobjects/Track.h>
36#include <mdst/dataobjects/TrackFitResult.h>
37#include <mdst/dbobjects/BeamSpot.h>
38#include <mdst/dataobjects/MCParticle.h>
39
40// ROOT
41#include <Math/Vector3D.h>
42
43#include <string>
44#include <vector>
45
46
47namespace Belle2 {
53 class Particle;
54 struct ParticleAndWeight;
55
61 class TagVertexModule : public Module {
62
63 public:
64
69
74 virtual void initialize() override;
75
80 virtual void beginRun() override;
81
85 virtual void event() override;
86
90 const BeamSpot& getBeamSpot() const { return *m_beamSpotDB; }
91
92
93 private:
94
98 //std::string m_EventType; /**< Btag decay type */
99 std::string m_listName;
101 std::string m_useMCassociation;
102 //std::string m_useFitAlgorithm; /**< Choose constraint: from Breco or tube in the boost direction w/wo cut */
103 std::string m_constraintType;
104 std::string m_trackFindingType;
106 std::string m_roeMaskName;
107 double m_Bfield;
108 std::vector<const Particle*> m_tagParticles;
109 std::vector<const Particle*> m_raveParticles;
110 std::vector<double> m_raveWeights;
111 std::vector<const MCParticle*>
123 double m_fitPval;
124 ROOT::Math::XYZVector m_tagV;
125 TMatrixDSym m_tagVErrMatrix;
126 ROOT::Math::XYZVector m_mcTagV;
129 ROOT::Math::XYZVector m_mcVertReco;
131 double m_deltaT;
132 double m_deltaTErr;
134 double m_mcDeltaT;
135 TMatrixDSym m_constraintCov;
136 ROOT::Math::XYZVector m_constraintCenter;
137 ROOT::Math::XYZVector m_BeamSpotCenter;
138 TMatrixDSym m_BeamSpotCov;
139 bool m_mcInfo;
142 double m_tagVl;
144 double m_tagVlErr;
145 double m_tagVol;
147 double m_tagVolErr;
148 double m_tagVNDF;
149 double m_tagVChi2;
151 std::string m_fitAlgo;
154 TMatrixDSym m_pvCov;
155 ROOT::Math::PxPyPzEVector m_tagMomentum;
159 bool doVertexFit(const Particle* Breco);
160
162 Particle* doVertexFitForBTube(const Particle* mother, std::string fitType) const;
163
165 std::pair<ROOT::Math::XYZVector, TMatrixDSym> findConstraint(const Particle* Breco, double cut) const;
166
168 std::pair<ROOT::Math::XYZVector, TMatrixDSym> findConstraintBoost(double cut) const;
169
172 std::pair<ROOT::Math::XYZVector, TMatrixDSym> findConstraintBTube(const Particle* Breco, double cut);
173
175 void BtagMCVertex(const Particle* Breco);
176
178 static bool compBrecoBgen(const Particle* Breco, const MCParticle* Bgen);
179
182 std::vector<const Particle*> getTagTracks_standardAlgorithm(const Particle* Breco, int nPXDHits) const;
183
184
187 analysis::VertexFitKFit doSingleKfit(std::vector<ParticleAndWeight>& particleAndWeights);
188
192 std::vector<ParticleAndWeight> getParticlesAndWeights(const std::vector<const Particle*>& tagParticles) const;
193
195 //bool makeSemileptonicFit(Particle *Breco);
196
197
201 bool makeGeneralFit();
202
209 bool makeGeneralFitRave();
210
214 void fillParticles(std::vector<ParticleAndWeight>& particleAndWeights);
215
216
220 void fillTagVinfo(const ROOT::Math::XYZVector& tagVpos, const TMatrixDSym& tagVposErr);
221
228 bool makeGeneralFitKFit();
229
230
235 void deltaT(const Particle* Breco);
236
241 void resetReturnParams();
242
246 static std::string printVector(const ROOT::Math::XYZVector& vec);
247
251 static std::string printMatrix(const TMatrixD& mat);
252
256 static std::string printMatrix(const TMatrixDSym& mat);
257
265
269 static ROOT::Math::XYZVector getTruePoca(ParticleAndWeight const& paw);
270
278
282 ROOT::Math::XYZVector getRollBackPoca(ParticleAndWeight const& paw);
283 };
284
289 double weight;
292 };
293
295}
This class contains the beam spot position and size modeled as a gaussian distribution in space.
Definition: BeamSpot.h:22
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32
Base class for Modules.
Definition: Module.h:72
Class to store reconstructed particles.
Definition: Particle.h:75
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
Tag side Vertex Fitter module for modular analysis.
int m_fitTruthStatus
Store info about whether the fit was performed with the truth info 0 fit performed with measured para...
TMatrixDSym m_constraintCov
constraint to be used in the tag vertex fit
double m_truthTagVol
MC tagV component in the direction orthogonal to the boost.
std::vector< const Particle * > m_tagParticles
tracks of the rest of the event
double m_tagVl
tagV component in the boost direction
bool doVertexFit(const Particle *Breco)
central method for the tag side vertex fit
std::vector< const Particle * > getTagTracks_standardAlgorithm(const Particle *Breco, int nPXDHits) const
performs the fit using the standard algorithm - using all tracks in RoE The user can specify a reques...
double m_truthTagVl
MC tagV component in the boost direction
std::pair< ROOT::Math::XYZVector, TMatrixDSym > findConstraintBoost(double cut) const
calculate the standard constraint for the vertex fit on the tag side
bool m_useTruthInFit
Set to true if the tag fit is to be made with the TRUE tag track momentum and position.
std::vector< double > m_raveWeights
Store the weights used by Rave in the vtx fit so that they can be accessed later.
TrackFitResult getTrackWithRollBackCoordinates(ParticleAndWeight const &paw)
If the fit has to be done with the rolled back tracks, Rave or KFit is fed with a track where the pos...
virtual void initialize() override
Initialize the Module.
void fillTagVinfo(const ROOT::Math::XYZVector &tagVpos, const TMatrixDSym &tagVposErr)
Fill tagV vertex info.
ROOT::Math::XYZVector m_mcVertReco
generated Breco decay vertex
TMatrixDSym m_pvCov
covariance matrix of the PV (useful with tube and KFit)
double m_mcDeltaT
generated DeltaT with boost-direction approximation
static std::string printVector(const ROOT::Math::XYZVector &vec)
Print a XYZVector (useful for debugging)
ROOT::Math::XYZVector m_tagV
tag side fit result
virtual void event() override
Event processor.
std::pair< ROOT::Math::XYZVector, TMatrixDSym > findConstraintBTube(const Particle *Breco, double cut)
calculate constraint for the vertex fit on the tag side using the B tube (cylinder along the expected...
Particle * doVertexFitForBTube(const Particle *mother, std::string fitType) const
it returns an intersection between B rec and beam spot (= origin of BTube)
std::string m_listName
Breco particle list name.
std::vector< ParticleAndWeight > getParticlesAndWeights(const std::vector< const Particle * > &tagParticles) const
Get a list of particles with attached weight and associated MC particle.
bool m_useRollBack
Set to true if the tag fit is to be made with the tag track position rolled back to mother B.
double m_tagVlErr
Error of the tagV component in the boost direction
std::string m_roeMaskName
ROE particles from this mask will be used for vertex fitting.
double m_tagVChi2
chi^2 value of the tag vertex fit result
static ROOT::Math::XYZVector getTruePoca(ParticleAndWeight const &paw)
This finds the point on the true particle trajectory closest to the measured track position.
void BtagMCVertex(const Particle *Breco)
get the vertex of the MC B particle associated to Btag.
std::pair< ROOT::Math::XYZVector, TMatrixDSym > findConstraint(const Particle *Breco, double cut) const
calculate the constraint for the vertex fit on the tag side using Breco information
bool m_mcInfo
true if user wants to retrieve MC information out from the tracks used in the fit
double m_kFitReqReducedChi2
The required chi2/ndf to accept the kFit result, if it is higher, iteration procedure is applied.
std::string m_useMCassociation
No MC association or standard Breco particle or internal MCparticle association.
ROOT::Math::XYZVector m_constraintCenter
centre position of the constraint for the tag Vertex fit
double m_tagVolErr
Error of the tagV component in the direction orthogonal to the boost.
double m_mcTagLifeTime
generated tag side life time of B-decay
ROOT::Math::XYZVector m_BeamSpotCenter
Beam spot position.
double m_tagVNDF
Number of degrees of freedom in the tag vertex fit.
double m_deltaTErr
reconstructed DeltaT error
std::string m_fitAlgo
Algorithm used for the tag fit (Rave or KFit)
bool makeGeneralFit()
TO DO: tag side vertex fit in the case of semileptonic tag side decay.
ROOT::Math::XYZVector getRollBackPoca(ParticleAndWeight const &paw)
This shifts the position of tracks by the vector difference of mother B and production point of track...
virtual void beginRun() override
Called when entering a new run.
double m_mcDeltaTau
generated DeltaT
double m_fitPval
P value of the tag side fit result.
StoreArray< TagVertex > m_verArray
StoreArray of TagVertexes.
DBObjPtr< BeamSpot > m_beamSpotDB
Beam spot database object.
const BeamSpot & getBeamSpot() const
returns the BeamSpot object
void deltaT(const Particle *Breco)
calculate DeltaT and MC-DeltaT (rec - tag) in ps from Breco and Btag vertices DT = Dl / gamma beta c ...
std::vector< const Particle * > m_raveParticles
tracks given to rave for the track fit (after removing Kshorts
void fillParticles(std::vector< ParticleAndWeight > &particleAndWeights)
Fill sorted list of particles into external variable.
TagVertexModule()
Constructor.
int m_reqPXDHits
N of PXD hits for a track to be used.
double m_confidenceLevel
required fit confidence level
double m_tagVChi2IP
IP component of the chi^2 of the tag vertex fit result.
double m_tagVol
tagV component in the direction orthogonal to the boost
analysis::VertexFitKFit doSingleKfit(std::vector< ParticleAndWeight > &particleAndWeights)
performs single KFit on particles stored in particleAndWeights this function can be iterated several ...
std::string m_constraintType
Choose constraint: noConstraint, IP, tube, boost, (breco)
void resetReturnParams()
Reset all parameters that are computed in each event and then used to compute tuple variables.
ROOT::Math::PxPyPzEVector m_tagMomentum
B tag momentum computed from fully reconstructed B sig.
bool makeGeneralFitRave()
make the vertex fit on the tag side: RAVE AVF tracks coming from Ks removed all other tracks used
TrackFitResult getTrackWithTrueCoordinates(ParticleAndWeight const &paw) const
If the fit has to be done with the truth info, Rave is fed with a track where the momentum is replace...
StoreArray< MCParticle > m_mcParticles
StoreArray of MCParticles.
double m_mcLifeTimeReco
generated Breco life time
static bool compBrecoBgen(const Particle *Breco, const MCParticle *Bgen)
compare Breco with the two MC B particles
double m_Bfield
magnetic field from data base
TMatrixDSym m_tagVErrMatrix
Error matrix of the tag side fit result.
int m_mcPDG
generated tag side B flavor
StoreObjPtr< ParticleList > m_plist
input particle list
static std::string printMatrix(const TMatrixD &mat)
Print a TMatrix (useful for debugging)
ROOT::Math::XYZVector m_mcTagV
generated tag side vertex
int m_rollbackStatus
Store info about whether the fit was performed with the rolled back tracks 0 fit performed with measu...
std::string m_trackFindingType
Choose how to find the tag tracks: standard, standard_PXD.
bool m_verbose
choose if you want to print extra infos
int m_FitType
fit algo used
bool makeGeneralFitKFit()
make the vertex fit on the tag side: KFit tracks coming from Ks removed all other tracks used
std::vector< const MCParticle * > m_raveMCParticles
Store the MC particles corresponding to each track used by Rave in the vtx fit.
TMatrixDSym m_BeamSpotCov
size of the beam spot == covariance matrix on the beam spot position
double m_deltaT
reconstructed DeltaT
Values of the result of a track fit with a given particle hypothesis.
VertexFitKFit is a derived class from KFitBase to perform vertex-constraint kinematical fit.
Definition: VertexFitKFit.h:34
Abstract base class for different kinds of events.
this struct is used to store and sort the tag tracks
const Particle * particle
tag track fit result with pion mass hypo, for sorting purposes
const MCParticle * mcParticle
mc particle matched to the tag track, for sorting purposes
double weight
rave weight associated to the track, for sorting purposes