Belle II Software  release-08-01-10
NewV0Fitter.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 #pragma once
9 
10 #include <framework/datastore/StoreArray.h>
11 #include <framework/gearbox/Const.h>
12 #include <mdst/dataobjects/Track.h>
13 #include <mdst/dataobjects/TrackFitResult.h>
14 #include <mdst/dataobjects/V0.h>
15 #include <tracking/dataobjects/V0ValidationVertex.h>
16 #include <tracking/dataobjects/RecoTrack.h>
17 #include <genfit/Track.h>
18 #include <genfit/GFRaveVertex.h>
19 #include <map>
20 
21 namespace Belle2 {
30  class NewV0Fitter {
31 
32  public:
33 
37  struct FittedTrack {
38  const RecoTrack* recoTrack = nullptr;
41  double pValue = 0;
42  int Ndf = 0;
51  void set(const RecoTrack* recoTrk, const Const::ParticleType& hypo, const genfit::MeasuredStateOnPlane& mSoP,
52  const genfit::AbsTrackRep* rep)
53  {
54  recoTrack = recoTrk;
55  ptype = hypo;
56  state = mSoP;
57  const auto* fitStatus = recoTrk->getGenfitTrack().getFitStatus(rep);
58  pValue = fitStatus->getPVal();
59  Ndf = fitStatus->getNdf();
60  }
61  };
62 
63 
73  NewV0Fitter(const std::string& trackFitResultsName = "",
74  const std::string& v0sName = "",
75  const std::string& v0ValidationVerticesName = "",
76  const std::string& recoTracksName = "",
77  const std::string& copiedRecoTracksName = "CopiedRecoTracks",
78  bool enableValidation = false);
79 
88  void initializeCuts(double vertexDistanceCut,
89  double vertexChi2Cut,
90  const std::tuple<double, double>& invMassRangeKshort,
91  const std::tuple<double, double>& invMassRangeLambda,
92  const std::tuple<double, double>& invMassRangePhoton);
93 
101  void setFitterMode(int fitterMode) {m_fitterMode = fitterMode;}
102 
112  bool fitAndStore(const Track* trackPlus, const Track* trackMinus, const Const::ParticleType& v0Hypothesis,
113  bool& isForceStored, bool& isHitRemoved);
114 
120  static std::pair<Const::ParticleType, Const::ParticleType> getTrackHypotheses(const Const::ParticleType& v0Hypothesis);
121 
122 
123  private:
124 
128  enum ErrorStatus {
132  c_NotSelected = -1
133  };
134 
135 
141  c_BitTrackMinus = 0x2
142  };
143 
144 
155  int vertexFit(const RecoTrack* recoTrackPlus, const RecoTrack* recoTrackMinus,
156  int pdgTrackPlus, int pdgTrackMinus, const Const::ParticleType& v0Hypothesis);
157 
164  const genfit::AbsTrackRep* getTrackRepresentation(const RecoTrack* recoTrack, int pdgCode);
165 
172  bool setCardinalRep(genfit::Track& gfTrack, int pdgCode);
173 
181  bool fitGFRaveVertex(genfit::Track& trackPlus, genfit::Track& trackMinus, genfit::GFRaveVertex& vertex);
182 
192  const genfit::GFRaveVertex& vertex);
193 
200  RecoTrack* copyRecoTrack(const RecoTrack* origRecoTrack, const genfit::MeasuredStateOnPlane& state);
201 
210  const RecoTrack* removeHitsAndRefit(const RecoTrack* origRecoTrack, const RecoTrack* lastRecoTrack,
211  const Const::ParticleType& ptype);
212 
220  int isInnermostClusterShared(const RecoTrack* recoTrackPlus, const RecoTrack* recoTrackMinus);
221 
228  const TrackFitResult* saveTrackFitResult(const FittedTrack& trk, int sharedInnermostCluster);
229 
230 
231  std::string m_recoTracksName;
238  double m_vertexDistanceCut = 0;
239  double m_vertexChi2Cut = 0;
240  std::map<int, std::pair<double, double> > m_invMassCuts;
242  int m_fitterMode = 1;
243  bool m_validation = false;
245  // temporary storage
246 
248  double m_momentum = 0;
249  double m_invMass = 0;
253  };
254 
256 }
257 
The ParticleType class for identifying different particle types.
Definition: Const.h:399
static const ParticleType invalidParticle
Invalid particle, used internally.
Definition: Const.h:672
Improved V0 fitter class.
Definition: NewV0Fitter.h:30
void setFitterMode(int fitterMode)
Setter for the fitter mode.
Definition: NewV0Fitter.h:101
StoreArray< V0ValidationVertex > m_validationV0s
V0ValidationVertex collection (optional)
Definition: NewV0Fitter.h:235
StoreArray< RecoTrack > m_copiedRecoTracks
copied RecoTracks collection
Definition: NewV0Fitter.h:236
FittedTrack m_trkPlus
positively charged track data of last successfully fitted vertex
Definition: NewV0Fitter.h:250
bool m_validation
validation flag
Definition: NewV0Fitter.h:243
StoreArray< V0 > m_v0s
V0s collection.
Definition: NewV0Fitter.h:234
double m_vertexDistanceCut
cut on the transverse radius
Definition: NewV0Fitter.h:238
double m_vertexChi2Cut
Chi2 cut.
Definition: NewV0Fitter.h:239
StoreArray< TrackFitResult > m_trackFitResults
TrackFitResults collection.
Definition: NewV0Fitter.h:233
bool fitAndStore(const Track *trackPlus, const Track *trackMinus, const Const::ParticleType &v0Hypothesis, bool &isForceStored, bool &isHitRemoved)
Fit V0 with given hypothesis and store results if fit is successful.
Definition: NewV0Fitter.cc:83
int extrapolateToVertex(genfit::MeasuredStateOnPlane &statePlus, genfit::MeasuredStateOnPlane &stateMinus, const genfit::GFRaveVertex &vertex)
Extrapolation of both tracks to the vertex.
Definition: NewV0Fitter.cc:286
double m_momentum
momentum of last successfully fitted vertex
Definition: NewV0Fitter.h:248
ErrorStatus
Error status codes returned by the vertexFit method.
Definition: NewV0Fitter.h:128
@ c_NoTrackRepresentation
no track representation for given PDG code
Definition: NewV0Fitter.h:129
@ c_NotSelected
fitted vertex not passing the cuts
Definition: NewV0Fitter.h:132
@ c_VertexFitFailed
vertex fit failed
Definition: NewV0Fitter.h:130
@ c_ExtrapolationFailed
track extrapolation failed
Definition: NewV0Fitter.h:131
bool setCardinalRep(genfit::Track &gfTrack, int pdgCode)
Sets cardinal representation of a given genfit track and PDG code.
Definition: NewV0Fitter.cc:239
std::string m_recoTracksName
name of the RecoTracks collection
Definition: NewV0Fitter.h:231
const TrackFitResult * saveTrackFitResult(const FittedTrack &trk, int sharedInnermostCluster)
Append track fit result to the collection.
Definition: NewV0Fitter.cc:463
int isInnermostClusterShared(const RecoTrack *recoTrackPlus, const RecoTrack *recoTrackMinus)
Returns bit flags indicating that the innermost cluster is shared between both tracks.
Definition: NewV0Fitter.cc:409
const genfit::AbsTrackRep * getTrackRepresentation(const RecoTrack *recoTrack, int pdgCode)
Returns track representation for a given PDG code.
Definition: NewV0Fitter.cc:229
std::map< int, std::pair< double, double > > m_invMassCuts
invariant mass cuts, key = abs(PDG)
Definition: NewV0Fitter.h:240
NewV0Fitter(const std::string &trackFitResultsName="", const std::string &v0sName="", const std::string &v0ValidationVerticesName="", const std::string &recoTracksName="", const std::string &copiedRecoTracksName="CopiedRecoTracks", bool enableValidation=false)
Constructor.
Definition: NewV0Fitter.cc:27
StoreArray< RecoTrack > m_recoTracks
RecoTracks collection.
Definition: NewV0Fitter.h:232
genfit::GFRaveVertex m_fittedVertex
last successfully fitted vertex
Definition: NewV0Fitter.h:247
static std::pair< Const::ParticleType, Const::ParticleType > getTrackHypotheses(const Const::ParticleType &v0Hypothesis)
Returns daughter particle types for a given V0 hypothesis.
Definition: NewV0Fitter.cc:67
bool fitGFRaveVertex(genfit::Track &trackPlus, genfit::Track &trackMinus, genfit::GFRaveVertex &vertex)
Genfit Rave vertex fit called by vertexFit method.
Definition: NewV0Fitter.cc:254
void initializeCuts(double vertexDistanceCut, double vertexChi2Cut, const std::tuple< double, double > &invMassRangeKshort, const std::tuple< double, double > &invMassRangeLambda, const std::tuple< double, double > &invMassRangePhoton)
Initialization of cuts applied during the fit and store process.
Definition: NewV0Fitter.cc:53
double m_invMass
invariant mass of last successfully fitted vertex
Definition: NewV0Fitter.h:249
int m_fitterMode
fitter mode
Definition: NewV0Fitter.h:242
FittedTrack m_trkMinus
negatively charged track data of last successfully fitted vertex
Definition: NewV0Fitter.h:251
EInnerHitBits
Bits used to signal that track has hits inside the V0 vertex.
Definition: NewV0Fitter.h:139
@ c_BitTrackMinus
negative track has inner hits
Definition: NewV0Fitter.h:141
@ c_BitTrackPlus
positive track has inner hits
Definition: NewV0Fitter.h:140
int vertexFit(const RecoTrack *recoTrackPlus, const RecoTrack *recoTrackMinus, int pdgTrackPlus, int pdgTrackMinus, const Const::ParticleType &v0Hypothesis)
Performs a vertex fit.
Definition: NewV0Fitter.cc:165
RecoTrack * copyRecoTrack(const RecoTrack *origRecoTrack, const genfit::MeasuredStateOnPlane &state)
Make a copy of reco track.
Definition: NewV0Fitter.cc:396
const RecoTrack * removeHitsAndRefit(const RecoTrack *origRecoTrack, const RecoTrack *lastRecoTrack, const Const::ParticleType &ptype)
Remove track inner hits and refit the track.
Definition: NewV0Fitter.cc:308
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
const genfit::Track & getGenfitTrack() const
Returns genfit track.
Definition: RecoTrack.h:505
Values of the result of a track fit with a given particle hypothesis.
Class that bundles various TrackFitResults.
Definition: Track.h:25
Abstract base class for a track representation.
Definition: AbsTrackRep.h:66
GFRaveVertex class.
Definition: GFRaveVertex.h:48
#StateOnPlane with additional covariance matrix.
Collection of TrackPoint objects, AbsTrackRep objects and FitStatus objects.
Definition: Track.h:71
FitStatus * getFitStatus(const AbsTrackRep *rep=nullptr) const
Get FitStatus for a AbsTrackRep. Per default, return FitStatus for cardinalRep.
Definition: Track.h:154
Abstract base class for different kinds of events.
Structure to save track data of the last successful iteration.
Definition: NewV0Fitter.h:37
void set(const RecoTrack *recoTrk, const Const::ParticleType &hypo, const genfit::MeasuredStateOnPlane &mSoP, const genfit::AbsTrackRep *rep)
Sets the data members.
Definition: NewV0Fitter.h:51
double pValue
p-value of track fit
Definition: NewV0Fitter.h:41
genfit::MeasuredStateOnPlane state
measured state at first hit, extrapolated to fitted vertex
Definition: NewV0Fitter.h:40
Const::ParticleType ptype
particle type of the V0 track
Definition: NewV0Fitter.h:39
const RecoTrack * recoTrack
reco track
Definition: NewV0Fitter.h:38
int Ndf
degrees-of-freedom of track fit
Definition: NewV0Fitter.h:42