Belle II Software  release-05-02-19
TagVertexModule.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2014 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Luigi Li Gioi, Thibaud Humair *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <framework/core/Module.h>
14 
15 // DataStore
16 #include <framework/database/DBObjPtr.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 <CLHEP/Geometry/Point3D.h>
25 #include <CLHEP/Matrix/SymMatrix.h>
26 #include <CLHEP/Vector/LorentzVector.h>
27 
28 // DataObjects
29 #include <mdst/dataobjects/Track.h>
30 #include <mdst/dataobjects/TrackFitResult.h>
31 #include <analysis/dataobjects/FlavorTaggerInfo.h>
32 #include <mdst/dbobjects/BeamSpot.h>
33 #include <mdst/dataobjects/MCParticle.h>
34 
35 #include <string>
36 #include <vector>
37 
38 
39 namespace Belle2 {
45  class Particle;
46  struct ParticleAndWeight;
47 
53  class TagVertexModule : public Module {
54 
55  public:
56 
61 
66  virtual void initialize() override;
67 
72  virtual void beginRun() override;
73 
77  virtual void event() override;
78 
82  const BeamSpot& getBeamSpot() const { return *m_beamSpotDB; }
83 
84 
85  private:
86 
87  //std::string m_EventType; /**< Btag decay type */
88  std::string m_listName;
89  double m_confidenceLevel;
90  std::string m_useMCassociation;
91  //std::string m_useFitAlgorithm; /**< Choose constraint: from Breco or tube in the boost direction w/wo cut */
92  std::string m_constraintType;
93  std::string m_trackFindingType;
94  int m_reqPXDHits;
95  std::string m_roeMaskName;
96  double m_Bfield;
97  std::vector<const Particle*> m_tagParticles;
98  std::vector<const Particle*> m_raveParticles;
99  std::vector<double> m_raveWeights;
100  std::vector<const MCParticle*>
108  int m_rollbackStatus;
112  double m_fitPval;
113  TVector3 m_tagV;
114  TMatrixDSym m_tagVErrMatrix;
115  TVector3 m_mcTagV;
117  int m_mcPDG;
118  TVector3 m_mcVertReco;
119  double m_mcLifeTimeReco;
120  double m_deltaT;
121  double m_deltaTErr;
122  double m_mcDeltaTau;
123  double m_mcDeltaT;
124  TMatrixDSym m_constraintCov;
126  TVector3 m_BeamSpotCenter;
127  TMatrixDSym m_BeamSpotCov;
128  bool m_mcInfo;
129  double m_shiftZ;
131  int m_FitType;
132  double m_tagVl;
133  double m_truthTagVl;
134  double m_tagVlErr;
135  double m_tagVol;
136  double m_truthTagVol;
137  double m_tagVolErr;
138  double m_tagVNDF;
139  double m_tagVChi2;
140  double m_tagVChi2IP;
141  std::string m_fitAlgo;
142  bool m_verbose;
143  TMatrixDSym m_pvCov;
144  TLorentzVector m_tagMomentum;
148  bool doVertexFit(const Particle* Breco);
149 
151  Particle* doVertexFitForBTube(const Particle* mother, std::string fitType) const;
152 
154  std::pair<TVector3, TMatrixDSym> findConstraint(const Particle* Breco, double cut) const;
155 
157  std::pair<TVector3, TMatrixDSym> findConstraintBoost(double cut, double shiftAlongBoost = -2000.) const;
158 
161  std::pair<TVector3, TMatrixDSym> findConstraintBTube(const Particle* Breco, double cut);
162 
164  void BtagMCVertex(const Particle* Breco);
165 
167  static bool compBrecoBgen(const Particle* Breco, const MCParticle* Bgen);
168 
171  std::vector<const Particle*> getTagTracks_standardAlgorithm(const Particle* Breco, int nPXDHits) const;
172 
178  std::vector<ParticleAndWeight> getParticlesWithoutKS(const std::vector<const Particle*>& tagParticles,
179  double massWindowWidth = 0.01) const;
180 
182  //bool makeSemileptonicFit(Particle *Breco);
183 
184 
188  bool makeGeneralFit();
189 
196  bool makeGeneralFitRave();
197 
201  void fillParticles(std::vector<ParticleAndWeight>& particleAndWeights);
202 
203 
207  void fillTagVinfo(const TVector3& tagVpos, const TMatrixDSym& tagVposErr);
208 
215  bool makeGeneralFitKFit();
216 
217 
222  void deltaT(const Particle* Breco);
223 
228  void resetReturnParams();
229 
233  static std::string printVector(const TVector3& vec);
234 
238  static std::string printMatrix(const TMatrixD& mat);
239 
243  static std::string printMatrix(const TMatrixDSym& mat);
244 
252 
256  static TVector3 getTruePoca(ParticleAndWeight const& paw);
257 
265 
269  TVector3 getRollBackPoca(ParticleAndWeight const& paw);
270  };
271 
275  struct ParticleAndWeight {
276  double weight;
277  const Particle* particle;
278  const MCParticle* mcParticle;
279  };
280 
282 }
Belle2::TagVertexModule::doVertexFitForBTube
Particle * doVertexFitForBTube(const Particle *mother, std::string fitType) const
it returns an intersection between B rec and beam spot (= origin of BTube)
Definition: TagVertexModule.cc:920
Belle2::TagVertexModule::m_constraintCenter
TVector3 m_constraintCenter
centre position of the constraint for the tag Vertex fit
Definition: TagVertexModule.h:133
Belle2::TagVertexModule::m_tagVChi2
double m_tagVChi2
chi^2 value of the tag vertex fit result
Definition: TagVertexModule.h:147
Belle2::TagVertexModule::m_raveWeights
std::vector< double > m_raveWeights
Store the weights used by Rave in the vtx fit so that they can be accessed later.
Definition: TagVertexModule.h:107
Belle2::TagVertexModule::m_tagVNDF
double m_tagVNDF
Number of degrees of freedom in the tag vertex fit.
Definition: TagVertexModule.h:146
Belle2::TagVertexModule::m_tagVol
double m_tagVol
tagV component in the direction orthogonal to the boost
Definition: TagVertexModule.h:143
Belle2::TagVertexModule::m_truthTagVl
double m_truthTagVl
MC tagV component in the boost direction
Definition: TagVertexModule.h:141
Belle2::TagVertexModule::printMatrix
static std::string printMatrix(const TMatrixD &mat)
Print a TMatrix (useful for debugging)
Definition: TagVertexModule.cc:1042
Belle2::TagVertexModule::m_fitAlgo
std::string m_fitAlgo
Algorithm used for the tag fit (Rave or KFit)
Definition: TagVertexModule.h:149
Belle2::TagVertexModule::fillTagVinfo
void fillTagVinfo(const TVector3 &tagVpos, const TMatrixDSym &tagVposErr)
Fill tagV vertex info.
Definition: TagVertexModule.cc:707
Belle2::TagVertexModule::m_mcTagLifeTime
double m_mcTagLifeTime
generated tag side life time of B-decay
Definition: TagVertexModule.h:124
Belle2::TagVertexModule::getParticlesWithoutKS
std::vector< ParticleAndWeight > getParticlesWithoutKS(const std::vector< const Particle * > &tagParticles, double massWindowWidth=0.01) const
Get a list of pions from a list of pions removing the Kshorts Warning: this assumes all the particles...
Definition: TagVertexModule.cc:638
Belle2::TagVertexModule::m_BeamSpotCov
TMatrixDSym m_BeamSpotCov
size of the beam spot == covariance matrix on the beam spot position
Definition: TagVertexModule.h:135
Belle2::TagVertexModule::m_shiftZ
double m_shiftZ
parameter for testing the systematic error from the IP measurement
Definition: TagVertexModule.h:137
Belle2::ParticleAndWeight::weight
double weight
rave weight associated to the track, for sorting purposes
Definition: TagVertexModule.h:284
Belle2::ParticleAndWeight::mcParticle
const MCParticle * mcParticle
mc particle matched to the tag track, for sorting purposes
Definition: TagVertexModule.h:286
Belle2::TagVertexModule::m_truthTagVol
double m_truthTagVol
MC tagV component in the direction orthogonal to the boost.
Definition: TagVertexModule.h:144
Belle2::TagVertexModule::m_trackFindingType
std::string m_trackFindingType
Choose how to find the tag tracks: standard, standard_PXD.
Definition: TagVertexModule.h:101
Belle2::TagVertexModule::m_useRollBack
bool m_useRollBack
Set to true if the tag fit is to be made with the tag track position rolled back to mother B.
Definition: TagVertexModule.h:115
Belle2::TagVertexModule::compBrecoBgen
static bool compBrecoBgen(const Particle *Breco, const MCParticle *Bgen)
compare Breco with the two MC B particles
Definition: TagVertexModule.cc:589
Belle2::TagVertexModule::findConstraint
std::pair< TVector3, TMatrixDSym > findConstraint(const Particle *Breco, double cut) const
calculate the constraint for the vertex fit on the tag side using Breco information
Definition: TagVertexModule.cc:371
Belle2::TagVertexModule::getRollBackPoca
TVector3 getRollBackPoca(ParticleAndWeight const &paw)
This shifts the position of tracks by the vector difference of mother B and production point of track...
Definition: TagVertexModule.cc:987
Belle2::TagVertexModule::m_deltaT
double m_deltaT
reconstructed DeltaT
Definition: TagVertexModule.h:128
Belle2::TagVertexModule::TagVertexModule
TagVertexModule()
Constructor.
Definition: TagVertexModule.cc:91
Belle2::TagVertexModule::event
virtual void event() override
Event processor.
Definition: TagVertexModule.cc:164
Belle2::TagVertexModule::BtagMCVertex
void BtagMCVertex(const Particle *Breco)
get the vertex of the MC B particle associated to Btag.
Definition: TagVertexModule.cc:543
Belle2::TagVertexModule::m_fitPval
double m_fitPval
P value of the tag side fit result.
Definition: TagVertexModule.h:120
Belle2::TagVertexModule::findConstraintBoost
std::pair< TVector3, TMatrixDSym > findConstraintBoost(double cut, double shiftAlongBoost=-2000.) const
calculate the standard constraint for the vertex fit on the tag side
Definition: TagVertexModule.cc:514
Belle2::TagVertexModule::m_tagVolErr
double m_tagVolErr
Error of the tagV component in the direction orthogonal to the boost.
Definition: TagVertexModule.h:145
Belle2::TagVertexModule::m_tagParticles
std::vector< const Particle * > m_tagParticles
tracks of the rest of the event
Definition: TagVertexModule.h:105
Belle2::TagVertexModule::m_tagV
TVector3 m_tagV
tag side fit result
Definition: TagVertexModule.h:121
Belle2::TagVertexModule::m_pvCov
TMatrixDSym m_pvCov
covariance matrix of the PV (useful with tube and KFit)
Definition: TagVertexModule.h:151
Belle2::TagVertexModule::m_verbose
bool m_verbose
choose if you want to print extra infos
Definition: TagVertexModule.h:150
Belle2::TagVertexModule::m_mcVertReco
TVector3 m_mcVertReco
generated Breco decay vertex
Definition: TagVertexModule.h:126
Belle2::TrackFitResult
Values of the result of a track fit with a given particle hypothesis.
Definition: TrackFitResult.h:59
Belle2::BeamSpot
This class contains the beam spot position and size modeled as a gaussian distribution in space.
Definition: BeamSpot.h:32
Belle2::TagVertexModule::m_tagVlErr
double m_tagVlErr
Error of the tagV component in the boost direction
Definition: TagVertexModule.h:142
Belle2::TagVertexModule::m_tagVl
double m_tagVl
tagV component in the boost direction
Definition: TagVertexModule.h:140
Belle2::TagVertexModule::m_listName
std::string m_listName
Breco particle list name.
Definition: TagVertexModule.h:96
Belle2::TagVertexModule::initialize
virtual void initialize() override
Initialize the Module.
Definition: TagVertexModule.cc:128
Belle2::TagVertexModule::getTrackWithTrueCoordinates
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...
Definition: TagVertexModule.cc:943
Belle2::DBObjPtr
Class for accessing objects in the database.
Definition: DBObjPtr.h:31
Belle2::TagVertexModule::m_roeMaskName
std::string m_roeMaskName
ROE particles from this mask will be used for vertex fitting.
Definition: TagVertexModule.h:103
Belle2::TagVertexModule::m_deltaTErr
double m_deltaTErr
reconstructed DeltaT error
Definition: TagVertexModule.h:129
Belle2::TagVertexModule::m_tagMomentum
TLorentzVector m_tagMomentum
B tag momentum computed from fully reconstructed B sig.
Definition: TagVertexModule.h:152
Belle2::TagVertexModule::m_Bfield
double m_Bfield
magnetic field from data base
Definition: TagVertexModule.h:104
Belle2::TagVertexModule::makeGeneralFit
bool makeGeneralFit()
TO DO: tag side vertex fit in the case of semileptonic tag side decay.
Definition: TagVertexModule.cc:683
Belle2::TagVertexModule::m_constraintType
std::string m_constraintType
Choose constraint: noConstraint, IP, tube, boost, (breco)
Definition: TagVertexModule.h:100
Belle2::TagVertexModule::m_FitType
int m_FitType
fit algo used
Definition: TagVertexModule.h:139
Belle2::TagVertexModule::m_tagVChi2IP
double m_tagVChi2IP
IP component of the chi^2 of the tag vertex fit result.
Definition: TagVertexModule.h:148
Belle2::TagVertexModule::makeGeneralFitKFit
bool makeGeneralFitKFit()
make the vertex fit on the tag side: KFit tracks coming from Ks removed all other tracks used
Definition: TagVertexModule.cc:788
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TagVertexModule::printVector
static std::string printVector(const TVector3 &vec)
Print a TVector3 (useful for debugging)
Definition: TagVertexModule.cc:1033
Belle2::TagVertexModule::resetReturnParams
void resetReturnParams()
Reset all parameters that are computed in each event and then used to compute tuple variables.
Definition: TagVertexModule.cc:997
Belle2::TagVertexModule::m_mcDeltaT
double m_mcDeltaT
generated DeltaT with boost-direction approximation
Definition: TagVertexModule.h:131
Belle2::TagVertexModule::deltaT
void deltaT(const Particle *Breco)
calculate DeltaT and MC-DeltaT (rec - tag) in ps from Breco and Btag vertices DT = Dl / gamma beta c ...
Definition: TagVertexModule.cc:872
Belle2::TagVertexModule::doVertexFit
bool doVertexFit(const Particle *Breco)
central method for the tag side vertex fit
Definition: TagVertexModule.cc:262
Belle2::TagVertexModule::m_mcInfo
bool m_mcInfo
true if user wants to retrieve MC information out from the tracks used in the fit
Definition: TagVertexModule.h:136
Belle2::TagVertexModule::m_useMCassociation
std::string m_useMCassociation
No MC association or standard Breco particle or internal MCparticle association.
Definition: TagVertexModule.h:98
Belle2::TagVertexModule::m_mcLifeTimeReco
double m_mcLifeTimeReco
generated Breco life time
Definition: TagVertexModule.h:127
Belle2::TagVertexModule::getBeamSpot
const BeamSpot & getBeamSpot() const
returns the BeamSpot object
Definition: TagVertexModule.h:90
Belle2::TagVertexModule::getTrackWithRollBackCoordinates
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...
Definition: TagVertexModule.cc:974
Belle2::TagVertexModule::getTagTracks_standardAlgorithm
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...
Definition: TagVertexModule.cc:619
Belle2::TagVertexModule::m_beamSpotDB
DBObjPtr< BeamSpot > m_beamSpotDB
Beam spot database object.
Definition: TagVertexModule.h:138
Belle2::TagVertexModule::m_mcPDG
int m_mcPDG
generated tag side B flavor
Definition: TagVertexModule.h:125
Belle2::TagVertexModule::findConstraintBTube
std::pair< TVector3, 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...
Definition: TagVertexModule.cc:433
Belle2::ParticleAndWeight
this struct is used to store and sort the tag tracks
Definition: TagVertexModule.h:283
Belle2::TagVertexModule::m_confidenceLevel
double m_confidenceLevel
required fit confidence level
Definition: TagVertexModule.h:97
Belle2::TagVertexModule::getTruePoca
static TVector3 getTruePoca(ParticleAndWeight const &paw)
This finds the point on the true particle trajectory closest to the measured track position.
Definition: TagVertexModule.cc:962
Belle2::TagVertexModule::m_useTruthInFit
bool m_useTruthInFit
Set to true if the tag fit is to be made with the TRUE tag track momentum and position.
Definition: TagVertexModule.h:110
Belle2::Particle
Class to store reconstructed particles.
Definition: Particle.h:77
Belle2::TagVertexModule::m_BeamSpotCenter
TVector3 m_BeamSpotCenter
Beam spot position.
Definition: TagVertexModule.h:134
Belle2::TagVertexModule::fillParticles
void fillParticles(std::vector< ParticleAndWeight > &particleAndWeights)
Fill sorted list of particles into external variable.
Definition: TagVertexModule.cc:690
Belle2::TagVertexModule::m_reqPXDHits
int m_reqPXDHits
N of PXD hits for a track to be used.
Definition: TagVertexModule.h:102
Belle2::TagVertexModule::m_mcDeltaTau
double m_mcDeltaTau
generated DeltaT
Definition: TagVertexModule.h:130
Belle2::TagVertexModule::m_fitTruthStatus
int m_fitTruthStatus
Store info about whether the fit was performed with the truth info 0 fit performed with measured para...
Definition: TagVertexModule.h:111
Belle2::TagVertexModule::m_constraintCov
TMatrixDSym m_constraintCov
constraint to be used in the tag vertex fit
Definition: TagVertexModule.h:132
Belle2::MCParticle
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:43
Belle2::TagVertexModule::m_mcTagV
TVector3 m_mcTagV
generated tag side vertex
Definition: TagVertexModule.h:123
Belle2::TagVertexModule::m_tagVErrMatrix
TMatrixDSym m_tagVErrMatrix
Error matrix of the tag side fit result.
Definition: TagVertexModule.h:122
Belle2::TagVertexModule::m_raveParticles
std::vector< const Particle * > m_raveParticles
tracks given to rave for the track fit (after removing Kshorts
Definition: TagVertexModule.h:106
Belle2::TagVertexModule::m_rollbackStatus
int m_rollbackStatus
Store info about whether the fit was performed with the rolled back tracks 0 fit performed with measu...
Definition: TagVertexModule.h:116
Belle2::TagVertexModule::makeGeneralFitRave
bool makeGeneralFitRave()
make the vertex fit on the tag side: RAVE AVF tracks coming from Ks removed all other tracks used
Definition: TagVertexModule.cc:722
Belle2::TagVertexModule::m_raveMCParticles
std::vector< const MCParticle * > m_raveMCParticles
Store the MC particles corresponding to each track used by Rave in the vtx fit.
Definition: TagVertexModule.h:109
Belle2::ParticleAndWeight::particle
const Particle * particle
tag track fit result with pion mass hypo, for sorting purposes
Definition: TagVertexModule.h:285
Belle2::TagVertexModule::beginRun
virtual void beginRun() override
Called when entering a new run.
Definition: TagVertexModule.cc:158