BOSS 7.0.5
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( !m_doSecondaryVFit ) return true;
42
43 // --------------------------------------------------
44 // Do a secondary vertex fit and check the flight significance
45 // --------------------------------------------------
46
47 EvtRecTrack* veeTrack1 = ks->pairDaughters().first;
48 RecMdcKalTrack* veeKalTrack1 = veeTrack1->mdcKalTrack();
49 veeKalTrack1->setPidType(RecMdcKalTrack::pion);
50 WTrackParameter veeInitialWTrack1 = WTrackParameter(0.13957018, veeKalTrack1->getZHelix(), veeKalTrack1->getZError());
51
52 EvtRecTrack* veeTrack2 = ks->pairDaughters().second;
53 RecMdcKalTrack* veeKalTrack2 = veeTrack2->mdcKalTrack();
54 veeKalTrack2->setPidType(RecMdcKalTrack::pion);
55 WTrackParameter veeInitialWTrack2 = WTrackParameter(0.13957018, veeKalTrack2->getZHelix(), veeKalTrack2->getZError());
56
57 VertexParameter wideVertex;
58 HepPoint3D vWideVertex(0., 0., 0.);
59 HepSymMatrix evWideVertex(3, 0);
60
61 evWideVertex[0][0] = 1.0e12;
62 evWideVertex[1][1] = 1.0e12;
63 evWideVertex[2][2] = 1.0e12;
64
65 wideVertex.setVx(vWideVertex);
66 wideVertex.setEvx(evWideVertex);
67
68 // First, perform a vertex fit
70 vtxfit->init();
71
72 // add the daughters
73 vtxfit->AddTrack(0,veeInitialWTrack1);
74 vtxfit->AddTrack(1,veeInitialWTrack2);
75 vtxfit->AddVertex(0,wideVertex,0,1);
76
77 // do the fit
78 vtxfit->Fit(0);
79 vtxfit->Swim(0);
80 vtxfit->BuildVirtualParticle(0);
81
82 // Now perform the secondary vertex fit
84 svtxfit->init();
85
86 // add the primary vertex
87 VertexParameter beamSpot;
88 HepPoint3D vBeamSpot(0., 0., 0.);
89 HepSymMatrix evBeamSpot(3, 0);
90
91 IVertexDbSvc* vtxsvc;
92 Gaudi::svcLocator()->service("VertexDbSvc", vtxsvc);
93 if(vtxsvc->isVertexValid()){
94 double* dbv = vtxsvc->PrimaryVertex();
95 double* vv = vtxsvc->SigmaPrimaryVertex();
96 for (unsigned int ivx = 0; ivx < 3; ivx++){
97 vBeamSpot[ivx] = dbv[ivx];
98 evBeamSpot[ivx][ivx] = vv[ivx] * vv[ivx];
99 }
100 }
101 else{
102 cout << "KSSELECTOR ERROR: Could not find a vertex from VertexDbSvc" << endl;
103 return false;
104 }
105
106 beamSpot.setVx(vBeamSpot);
107 beamSpot.setEvx(evBeamSpot);
108
109 VertexParameter primaryVertex(beamSpot);
110 svtxfit->setPrimaryVertex(primaryVertex);
111
112 // add the secondary vertex
113 svtxfit->setVpar(vtxfit->vpar(0));
114
115 // add the Ks or lambda
116 svtxfit->AddTrack(0,vtxfit->wVirtualTrack(0));
117
118 // do the second vertex fit
119 // if the fit fails, the default values will not be changed
120 if( !svtxfit->Fit() ) return false;
121
122 // save the new ks parameters
123 double vfitlength = svtxfit->decayLength();
124 double vfiterror = svtxfit->decayLengthError();
125 double vfitchi2 = svtxfit->chisq();
126 double flightsig = 0;
127 if( vfiterror != 0 )
128 flightsig = vfitlength/vfiterror;
129
130 // if the ks does not meet the criteria, the information from
131 // the secondary vertex fit will not be filled (default = -999)
132 if( vfitchi2 > m_maxVFitChisq ) return false;
133 if( flightsig < m_minFlightSig ) return false;
134
135 return true;
136}
137
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