BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
LocalKsSelector Class Reference

#include <LocalKsSelector.h>

Inheritance diagram for LocalKsSelector:

Public Member Functions

 LocalKsSelector (const std::string &type, const std::string &name, const IInterface *parent)
bool operator() (CDKs &aKs) override

Detailed Description

Definition at line 11 of file LocalKsSelector.h.

Constructor & Destructor Documentation

◆ LocalKsSelector()

LocalKsSelector::LocalKsSelector ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 13 of file LocalKsSelector.cxx.

15 : base_class( type, name, parent ) {
16 declareProperty( "KsMinMassCut", m_minMass = 0.470 );
17 declareProperty( "KsMaxMassCut", m_maxMass = 0.528 );
18 declareProperty( "KsMaxChisq", m_maxChisq = 100 );
19
20 declareProperty( "DoSecondaryVFit", m_doSecondaryVFit = false );
21 declareProperty( "KsMaxVFitChisq", m_maxVFitChisq = 100 );
22 declareProperty( "KsMinFlightSig", m_minFlightSig = 2.0 );
23 declareProperty( "UseVFRefine", m_useVFrefine = true );
24
25 declareProperty( "UseBFieldCorr", m_useBFC = true );
26}

Referenced by LocalKsSelector().

Member Function Documentation

◆ operator()()

bool LocalKsSelector::operator() ( CDKs & aKs)
override

Definition at line 28 of file LocalKsSelector.cxx.

28 {
29
30 aKs.setUserTag( 1 );
31 EvtRecVeeVertex* ks = const_cast<EvtRecVeeVertex*>( aKs.navKshort() );
32
33 if ( ks->vertexId() != 310 ) return false;
34
35 if ( !m_useBFC )
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 ( !m_doSecondaryVFit ) return true;
42 }
43
44 // --------------------------------------------------
45 // Do a secondary vertex fit and check the flight significance
46 // --------------------------------------------------
47
48 EvtRecTrack* veeTrack1 = ks->pairDaughters().first;
49 RecMdcKalTrack* veeKalTrack1 = veeTrack1->mdcKalTrack();
50 veeKalTrack1->setPidType( RecMdcKalTrack::pion );
51 WTrackParameter veeInitialWTrack1 =
52 WTrackParameter( 0.13957018, veeKalTrack1->getZHelix(), veeKalTrack1->getZError() );
53
54 EvtRecTrack* veeTrack2 = ks->pairDaughters().second;
55 RecMdcKalTrack* veeKalTrack2 = veeTrack2->mdcKalTrack();
56 veeKalTrack2->setPidType( RecMdcKalTrack::pion );
57 WTrackParameter veeInitialWTrack2 =
58 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 StatusCode sc = serviceLocator()->service( "VertexDbSvc", vtxsvc );
74 if ( vtxsvc->isVertexValid() )
75 {
76 double* dbv = vtxsvc->PrimaryVertex();
77 double* vv = vtxsvc->SigmaPrimaryVertex();
78 for ( unsigned int ivx = 0; ivx < 3; ivx++ )
79 {
80 vBeamSpot[ivx] = dbv[ivx];
81 evBeamSpot[ivx][ivx] = vv[ivx] * vv[ivx];
82 }
83 }
84 else
85 {
86 cout << "KSSELECTOR ERROR: Could not find a vertex from VertexDbSvc" << endl;
87 return false;
88 }
89
90 if ( m_useVFrefine )
91 {
92
93 VertexParameter wideVertex;
94
95 wideVertex.setVx( vWideVertex );
96 wideVertex.setEvx( evWideVertex );
97
98 // First, perform a vertex fit refine
99 VertexFitRefine* vtxfitr = VertexFitRefine::instance();
100 vtxfitr->init();
101
102 vtxfitr->AddTrack( 0, veeKalTrack1, RecMdcKalTrack::pion );
103 vtxfitr->AddTrack( 1, veeKalTrack2, RecMdcKalTrack::pion );
104 vtxfitr->AddVertex( 0, wideVertex, 0, 1 );
105
106 bool fitok = vtxfitr->Fit();
107
108 HepLorentzVector ppi1 = vtxfitr->pfit( 0 );
109 HepLorentzVector ppi2 = vtxfitr->pfit( 1 );
110 HepLorentzVector pks = ppi1 + ppi2;
111
112 double mass = pks.m();
113 double chisqvtx = vtxfitr->chisq( 0 );
114
115 if ( m_useBFC )
116 {
117 if ( ( mass <= m_minMass ) || ( mass >= m_maxMass ) ) return false;
118 // if ( ks->chi2() >= m_maxChisq ) return false;
119 if ( chisqvtx >= m_maxChisq ) return false;
120
121 if ( !m_doSecondaryVFit ) return true;
122 }
123
124 // Now perform the secondary vertex fit
125 SecondVertexFit* svtxfit = SecondVertexFit::instance();
126 svtxfit->init();
127
128 // add the primary vertex
129 VertexParameter beamSpot;
130
131 beamSpot.setVx( vBeamSpot );
132 beamSpot.setEvx( evBeamSpot );
133
134 VertexParameter primaryVertex( beamSpot );
135 svtxfit->setPrimaryVertex( primaryVertex );
136
137 // add the secondary vertex
138 svtxfit->setVpar( vtxfitr->vpar( 0 ) );
139
140 // add the Ks or lambda
141 svtxfit->AddTrack( 0, vtxfitr->wVirtualTrack( 0 ) );
142
143 // do the second vertex fit
144 // if the fit fails, the default values will not be changed
145 if ( !svtxfit->Fit() ) return false;
146
147 // save the new ks parameters
148 double vfitlength = svtxfit->decayLength();
149 double vfiterror = svtxfit->decayLengthError();
150 double vfitchi2 = svtxfit->chisq();
151 double flightsig = 0;
152 if ( vfiterror != 0 ) flightsig = vfitlength / vfiterror;
153
154 // if the ks does not meet the criteria, the information from
155 // the secondary vertex fit will not be filled (default = -999)
156 if ( vfitchi2 > m_maxVFitChisq ) return false;
157 if ( flightsig < m_minFlightSig ) return false;
158
159 return true;
160 }
161 else
162 {
163 VertexParameter wideVertex;
164
165 wideVertex.setVx( vWideVertex );
166 wideVertex.setEvx( evWideVertex );
167
168 // First, perform a vertex fit
169 VertexFit* vtxfit = VertexFit::instance();
170 vtxfit->init();
171
172 // add the daughters
173 vtxfit->AddTrack( 0, veeInitialWTrack1 );
174 vtxfit->AddTrack( 1, veeInitialWTrack2 );
175 vtxfit->AddVertex( 0, wideVertex, 0, 1 );
176
177 // do the fit
178 vtxfit->Fit( 0 );
179 vtxfit->Swim( 0 );
180 vtxfit->BuildVirtualParticle( 0 );
181
182 WTrackParameter wks = vtxfit->wVirtualTrack( 0 );
183 WTrackParameter wkspi1 = vtxfit->wtrk( 0 );
184 WTrackParameter wkspi2 = vtxfit->wtrk( 1 );
185
186 HepLorentzVector pks = wks.p();
187
188 double mass = pks.m();
189 double chisqvtx = vtxfit->chisq( 0 );
190
191 if ( m_useBFC )
192 {
193 if ( ( mass <= m_minMass ) || ( mass >= m_maxMass ) ) return false;
194 // if ( ks->chi2() >= m_maxChisq ) return false;
195 if ( chisqvtx >= m_maxChisq ) return false;
196
197 if ( !m_doSecondaryVFit ) return true;
198 }
199
200 // Now perform the secondary vertex fit
201 SecondVertexFit* svtxfit = SecondVertexFit::instance();
202 svtxfit->init();
203
204 // add the primary vertex
205 VertexParameter beamSpot;
206
207 beamSpot.setVx( vBeamSpot );
208 beamSpot.setEvx( evBeamSpot );
209
210 VertexParameter primaryVertex( beamSpot );
211 svtxfit->setPrimaryVertex( primaryVertex );
212
213 // add the secondary vertex
214 svtxfit->setVpar( vtxfit->vpar( 0 ) );
215
216 // add the Ks or lambda
217 svtxfit->AddTrack( 0, vtxfit->wVirtualTrack( 0 ) );
218
219 // do the second vertex fit
220 // if the fit fails, the default values will not be changed
221 if ( !svtxfit->Fit() ) return false;
222
223 // save the new ks parameters
224 double vfitlength = svtxfit->decayLength();
225 double vfiterror = svtxfit->decayLengthError();
226 double vfitchi2 = svtxfit->chisq();
227 double flightsig = 0;
228 if ( vfiterror != 0 ) flightsig = vfitlength / vfiterror;
229
230 // if the ks does not meet the criteria, the information from
231 // the secondary vertex fit will not be filled (default = -999)
232 if ( vfitchi2 > m_maxVFitChisq ) return false;
233 if ( flightsig < m_minFlightSig ) return false;
234
235 return true;
236 }
237}
double mass
HepGeom::Point3D< double > HepPoint3D
void setUserTag(int tag)
virtual const EvtRecVeeVertex * navKshort() const
Definition CDKs.cxx:90
std::pair< SmartRef< EvtRecTrack >, SmartRef< EvtRecTrack > > & pairDaughters()
virtual bool isVertexValid()=0
virtual double * SigmaPrimaryVertex()=0
virtual double * PrimaryVertex()=0
void setPrimaryVertex(const VertexParameter vpar)
static SecondVertexFit * instance()
void AddTrack(const int number, const double mass, const RecMdcTrack *trk)
Definition TrackPool.cxx:21
void AddTrack(const int index, RecMdcKalTrack *p, const RecMdcKalTrack::PidType pid)
static VertexFitRefine * instance()
void AddVertex(int number, VertexParameter vpar, std::vector< int > lis)
WTrackParameter wtrk(int n) const
WTrackParameter wVirtualTrack(int n) const
void init()
Definition VertexFit.cxx:27
void AddVertex(int number, VertexParameter vpar, std::vector< int > lis)
Definition VertexFit.cxx:85
static VertexFit * instance()
Definition VertexFit.cxx:15
void BuildVirtualParticle(int number)
bool Fit()

The documentation for this class was generated from the following files: