BOSS 7.0.4
BESIII Offline Software System
Loading...
Searching...
No Matches
LocalKsSelector.cxx
Go to the documentation of this file.
1#include "GaudiKernel/Bootstrap.h"
2#include "GaudiKernel/IJobOptionsSvc.h"
3#include "GaudiKernel/ISvcLocator.h"
4#include "GaudiKernel/PropertyMgr.h"
5
6#include "EvtRecEvent/EvtRecVeeVertex.h"
7#include "DTagAlg/LocalKsSelector.h"
8#include "VertexFit/VertexFit.h"
9#include "VertexFit/SecondVertexFit.h"
10#include "VertexFit/IVertexDbSvc.h"
11
13{
14 IJobOptionsSvc* jobSvc;
15 Gaudi::svcLocator()->service("JobOptionsSvc", jobSvc);
16
17 PropertyMgr m_propMgr;
18
19 m_propMgr.declareProperty("KsMinMassCut", m_minMass = 0.470 );
20 m_propMgr.declareProperty("KsMaxMassCut", m_maxMass = 0.528 );
21 m_propMgr.declareProperty("KsMaxChisq", m_maxChisq = 100 );
22
23 m_propMgr.declareProperty("DoSecondaryVFit", m_doSecondaryVFit = false );
24 m_propMgr.declareProperty("KsMaxVFitChisq", m_maxVFitChisq = 100 );
25 m_propMgr.declareProperty("KsMinFlightSig", m_minFlightSig = 2.0 );
26
27 jobSvc->setMyProperties("LocalKsSelector", &m_propMgr);
28}
29
31
32 aKs.setUserTag(1);
33 EvtRecVeeVertex* ks = const_cast<EvtRecVeeVertex*>( aKs.navKshort() );
34
35 if ( ks->vertexId() != 310 ) return false;
36
37 double mass = ks->mass();
38 if ((mass <= m_minMass)||(mass >= m_maxMass)) return false;
39 if ( ks->chi2() >= m_maxChisq ) return false;
40
41 if(mass < 0.487 || mass > 0.511)
42 aKs.setUserTag(2);
43
44 if( !m_doSecondaryVFit ) return true;
45
46 // --------------------------------------------------
47 // Do a secondary vertex fit and check the flight significance
48 // --------------------------------------------------
49
50 EvtRecTrack* veeTrack1 = ks->pairDaughters().first;
51 RecMdcKalTrack* veeKalTrack1 = veeTrack1->mdcKalTrack();
52 WTrackParameter veeInitialWTrack1 = WTrackParameter(0.13957018, veeKalTrack1->getZHelix(), veeKalTrack1->getZError());
53
54 EvtRecTrack* veeTrack2 = ks->pairDaughters().second;
55 RecMdcKalTrack* veeKalTrack2 = veeTrack2->mdcKalTrack();
56 WTrackParameter veeInitialWTrack2 = WTrackParameter(0.13957018, veeKalTrack2->getZHelix(), veeKalTrack2->getZError());
57
58 VertexParameter wideVertex;
59 HepPoint3D vWideVertex(0., 0., 0.);
60 HepSymMatrix evWideVertex(3, 0);
61
62 evWideVertex[0][0] = 1.0e12;
63 evWideVertex[1][1] = 1.0e12;
64 evWideVertex[2][2] = 1.0e12;
65
66 wideVertex.setVx(vWideVertex);
67 wideVertex.setEvx(evWideVertex);
68
69 // First, perform a vertex fit
71 vtxfit->init();
72
73 // add the daughters
74 vtxfit->AddTrack(0,veeInitialWTrack1);
75 vtxfit->AddTrack(1,veeInitialWTrack2);
76 vtxfit->AddVertex(0,wideVertex,0,1);
77
78 // do the fit
79 vtxfit->Fit(0);
80 vtxfit->Swim(0);
81 vtxfit->BuildVirtualParticle(0);
82
83 // Now perform the secondary vertex fit
85 svtxfit->init();
86
87 // add the primary vertex
88 VertexParameter beamSpot;
89 HepPoint3D vBeamSpot(0., 0., 0.);
90 HepSymMatrix evBeamSpot(3, 0);
91
92 IVertexDbSvc* vtxsvc;
93 Gaudi::svcLocator()->service("VertexDbSvc", vtxsvc);
94 if(vtxsvc->isVertexValid()){
95 double* dbv = vtxsvc->PrimaryVertex();
96 double* vv = vtxsvc->SigmaPrimaryVertex();
97 for (unsigned int ivx = 0; ivx < 3; ivx++){
98 vBeamSpot[ivx] = dbv[ivx];
99 evBeamSpot[ivx][ivx] = vv[ivx] * vv[ivx];
100 }
101 }
102 else{
103 cout << "KSSELECTOR ERROR: Could not find a vertex from VertexDbSvc" << endl;
104 return false;
105 }
106
107 beamSpot.setVx(vBeamSpot);
108 beamSpot.setEvx(evBeamSpot);
109
110 VertexParameter primaryVertex(beamSpot);
111 svtxfit->setPrimaryVertex(primaryVertex);
112
113 // add the secondary vertex
114 svtxfit->setVpar(vtxfit->vpar(0));
115
116 // add the Ks or lambda
117 svtxfit->AddTrack(0,vtxfit->wVirtualTrack(0));
118
119 // do the second vertex fit
120 // if the fit fails, the default values will not be changed
121 if( !svtxfit->Fit() ) return false;
122
123 // save the new ks parameters
124 double vfitlength = svtxfit->decayLength();
125 double vfiterror = svtxfit->decayLengthError();
126 double vfitchi2 = svtxfit->chisq();
127 double flightsig = 0;
128 if( vfiterror != 0 )
129 flightsig = vfitlength/vfiterror;
130
131 // if the ks does not meet the criteria, the information from
132 // the secondary vertex fit will not be filled (default = -999)
133 if( vfitchi2 > m_maxVFitChisq ) return false;
134 if( flightsig < m_minFlightSig ) return false;
135
136 return true;
137}
138
double mass
LocalKsSelector ksSelector
void setUserTag(int tag)
Definition: CDCandidate.cxx:81
virtual const EvtRecVeeVertex * navKshort() const
Definition: CDKs.cxx:100
std::pair< SmartRef< EvtRecTrack >, SmartRef< EvtRecTrack > > & pairDaughters()
virtual bool isVertexValid()=0
virtual double * SigmaPrimaryVertex()=0
virtual double * PrimaryVertex()=0
bool operator()(CDKs &aKs)
static SecondVertexFit * instance()
void AddTrack(const int number, const double mass, const RecMdcTrack *trk)
Definition: TrackPool.cxx:22
void init()
Definition: VertexFit.cxx:29
void AddVertex(int number, VertexParameter vpar, std::vector< int > lis)
Definition: VertexFit.cxx:89
static VertexFit * instance()
Definition: VertexFit.cxx:15
void BuildVirtualParticle(int number)
Definition: VertexFit.cxx:619
bool Fit()
Definition: VertexFit.cxx:301