BOSS 7.1.0
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
12
13
15{
16 IJobOptionsSvc* jobSvc;
17 Gaudi::svcLocator()->service("JobOptionsSvc", jobSvc);
18
19 PropertyMgr m_propMgr;
20
21 m_propMgr.declareProperty("KsMinMassCut", m_minMass = 0.470 );
22 m_propMgr.declareProperty("KsMaxMassCut", m_maxMass = 0.528 );
23 m_propMgr.declareProperty("KsMaxChisq", m_maxChisq = 100 );
24
25 m_propMgr.declareProperty("DoSecondaryVFit", m_doSecondaryVFit = false );
26 m_propMgr.declareProperty("KsMaxVFitChisq", m_maxVFitChisq = 100 );
27 m_propMgr.declareProperty("KsMinFlightSig", m_minFlightSig = 2.0 );
28 m_propMgr.declareProperty("UseVFRefine", m_useVFrefine = true);
29
30 jobSvc->setMyProperties("LocalKsSelector", &m_propMgr);
31}
32
34
35 aKs.setUserTag(1);
36 EvtRecVeeVertex* ks = const_cast<EvtRecVeeVertex*>( aKs.navKshort() );
37
38 if ( ks->vertexId() != 310 ) return false;
39
40 double mass = ks->mass();
41 if ((mass <= m_minMass)||(mass >= m_maxMass)) return false;
42 if ( ks->chi2() >= m_maxChisq ) return false;
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 veeKalTrack1->setPidType(RecMdcKalTrack::pion);
53 WTrackParameter veeInitialWTrack1 = WTrackParameter(0.13957018, veeKalTrack1->getZHelix(), veeKalTrack1->getZError());
54
55 EvtRecTrack* veeTrack2 = ks->pairDaughters().second;
56 RecMdcKalTrack* veeKalTrack2 = veeTrack2->mdcKalTrack();
57 veeKalTrack2->setPidType(RecMdcKalTrack::pion);
58 WTrackParameter veeInitialWTrack2 = WTrackParameter(0.13957018, veeKalTrack2->getZHelix(), veeKalTrack2->getZError());
59
60 //VertexParameter wideVertex;
61 HepPoint3D vWideVertex(0., 0., 0.);
62 HepSymMatrix evWideVertex(3, 0);
63
64 evWideVertex[0][0] = 1.0e12;
65 evWideVertex[1][1] = 1.0e12;
66 evWideVertex[2][2] = 1.0e12;
67
68 // add the primary vertex
69 HepPoint3D vBeamSpot(0., 0., 0.);
70 HepSymMatrix evBeamSpot(3, 0);
71
72 IVertexDbSvc* vtxsvc;
73 Gaudi::svcLocator()->service("VertexDbSvc", vtxsvc);
74 if(vtxsvc->isVertexValid()){
75 double* dbv = vtxsvc->PrimaryVertex();
76 double* vv = vtxsvc->SigmaPrimaryVertex();
77 for (unsigned int ivx = 0; ivx < 3; ivx++){
78 vBeamSpot[ivx] = dbv[ivx];
79 evBeamSpot[ivx][ivx] = vv[ivx] * vv[ivx];
80 }
81 }
82 else{
83 cout << "KSSELECTOR ERROR: Could not find a vertex from VertexDbSvc" << endl;
84 return false;
85 }
86
87 if(m_useVFrefine){
88
89 VertexParameter wideVertex;
90
91 wideVertex.setVx(vWideVertex);
92 wideVertex.setEvx(evWideVertex);
93
94 // First, perform a vertex fit refine
96 vtxfitr->init();
97
98 vtxfitr->AddTrack(0, veeKalTrack1, RecMdcKalTrack::pion);
99 vtxfitr->AddTrack(1, veeKalTrack2, RecMdcKalTrack::pion);
100 vtxfitr->AddVertex(0, wideVertex, 0, 1);
101
102 bool fitok = vtxfitr->Fit();
103
104 // Now perform the secondary vertex fit
106 svtxfit->init();
107
108 // add the primary vertex
109 VertexParameter beamSpot;
110
111 beamSpot.setVx(vBeamSpot);
112 beamSpot.setEvx(evBeamSpot);
113
114 VertexParameter primaryVertex(beamSpot);
115 svtxfit->setPrimaryVertex(primaryVertex);
116
117 // add the secondary vertex
118 svtxfit->setVpar(vtxfitr->vpar(0));
119
120 // add the Ks or lambda
121 svtxfit->AddTrack(0,vtxfitr->wVirtualTrack(0));
122
123 // do the second vertex fit
124 // if the fit fails, the default values will not be changed
125 if( !svtxfit->Fit() ) return false;
126
127 // save the new ks parameters
128 double vfitlength = svtxfit->decayLength();
129 double vfiterror = svtxfit->decayLengthError();
130 double vfitchi2 = svtxfit->chisq();
131 double flightsig = 0;
132 if( vfiterror != 0 )
133 flightsig = vfitlength/vfiterror;
134
135 // if the ks does not meet the criteria, the information from
136 // the secondary vertex fit will not be filled (default = -999)
137 if( vfitchi2 > m_maxVFitChisq ) return false;
138 if( flightsig < m_minFlightSig ) return false;
139
140 return true;
141
142 }else{
143 VertexParameter wideVertex;
144
145 wideVertex.setVx(vWideVertex);
146 wideVertex.setEvx(evWideVertex);
147
148 // First, perform a vertex fit
149 VertexFit* vtxfit = VertexFit::instance();
150 vtxfit->init();
151
152 // add the daughters
153 vtxfit->AddTrack(0,veeInitialWTrack1);
154 vtxfit->AddTrack(1,veeInitialWTrack2);
155 vtxfit->AddVertex(0,wideVertex,0,1);
156
157 // do the fit
158 vtxfit->Fit(0);
159 vtxfit->Swim(0);
160 vtxfit->BuildVirtualParticle(0);
161
162 // Now perform the secondary vertex fit
164 svtxfit->init();
165
166 // add the primary vertex
167 VertexParameter beamSpot;
168
169 beamSpot.setVx(vBeamSpot);
170 beamSpot.setEvx(evBeamSpot);
171
172 VertexParameter primaryVertex(beamSpot);
173 svtxfit->setPrimaryVertex(primaryVertex);
174
175 // add the secondary vertex
176 svtxfit->setVpar(vtxfit->vpar(0));
177
178 // add the Ks or lambda
179 svtxfit->AddTrack(0,vtxfit->wVirtualTrack(0));
180
181 // do the second vertex fit
182 // if the fit fails, the default values will not be changed
183 if( !svtxfit->Fit() ) return false;
184
185 // save the new ks parameters
186 double vfitlength = svtxfit->decayLength();
187 double vfiterror = svtxfit->decayLengthError();
188 double vfitchi2 = svtxfit->chisq();
189 double flightsig = 0;
190 if( vfiterror != 0 )
191 flightsig = vfitlength/vfiterror;
192
193 // if the ks does not meet the criteria, the information from
194 // the secondary vertex fit will not be filled (default = -999)
195 if( vfitchi2 > m_maxVFitChisq ) return false;
196 if( flightsig < m_minFlightSig ) return false;
197
198 return true;
199
200
201 }
202
203
204
205}
206
double mass
LocalKsSelector ksSelector
void setUserTag(int tag)
Definition: CDCandidate.cxx:81
Definition: CDKs.h:60
virtual const EvtRecVeeVertex * navKshort() const
Definition: CDKs.cxx:100
static void setPidType(PidType pidType)
RecMdcKalTrack * mdcKalTrack()
Definition: EvtRecTrack.h:54
std::pair< SmartRef< EvtRecTrack >, SmartRef< EvtRecTrack > > & pairDaughters()
int vertexId() const
double mass() const
double chi2() const
virtual bool isVertexValid()=0
virtual double * SigmaPrimaryVertex()=0
virtual double * PrimaryVertex()=0
bool operator()(CDKs &aKs)
const HepVector & getZHelix() const
const HepSymMatrix & getZError() const
void setPrimaryVertex(const VertexParameter vpar)
double decayLength() const
double decayLengthError() const
static SecondVertexFit * instance()
void setVpar(const VertexParameter vpar)
double chisq() const
void AddTrack(const int number, const double mass, const RecMdcTrack *trk)
Definition: TrackPool.cxx:22
WTrackParameter wVirtualTrack(int n) const
void AddTrack(const int index, RecMdcKalTrack *p, const RecMdcKalTrack::PidType pid)
static VertexFitRefine * instance()
void AddVertex(int number, VertexParameter vpar, std::vector< int > lis)
VertexParameter vpar(int n) const
WTrackParameter wVirtualTrack(int n) const
Definition: VertexFit.h:92
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
VertexParameter vpar(int n) const
Definition: VertexFit.h:89
void BuildVirtualParticle(int number)
Definition: VertexFit.cxx:619
void Swim(int n)
Definition: VertexFit.h:59
bool Fit()
Definition: VertexFit.cxx:301
void setEvx(const HepSymMatrix &eVx)
void setVx(const HepPoint3D &vx)