BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
LocalLambdaSelector.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/LocalLambdaSelector.h"
8#include "VertexFit/VertexFit.h"
9#include "VertexFit/SecondVertexFit.h"
10#include "VertexFit/IVertexDbSvc.h"
11#include "ParticleID/ParticleID.h"
12
13
15{
16 IJobOptionsSvc* jobSvc;
17 Gaudi::svcLocator()->service("JobOptionsSvc", jobSvc);
18
19 PropertyMgr m_propMgr;
20
21 m_propMgr.declareProperty("LambdaMinMassCut", m_minMass = 1.10 );
22 m_propMgr.declareProperty("LambdaMaxMassCut", m_maxMass = 1.13 );
23 m_propMgr.declareProperty("LambdaMaxChisq", m_maxChisq = 100 );
24 m_propMgr.declareProperty("UseProtonPID", m_UseProtonPID = true );
25 m_propMgr.declareProperty("ProtonPIDChiCut", m_ChiCut = 8);
26
27 m_propMgr.declareProperty("DoSecondaryVFit", m_doSecondaryVFit = false );
28 m_propMgr.declareProperty("LambdaMaxVFitChisq", m_maxVFitChisq = 100 );
29 m_propMgr.declareProperty("LambdaMinFlightSig", m_minFlightSig = 2.0 );
30
31 jobSvc->setMyProperties("LocalLambdaSelector", &m_propMgr);
32}
33
35
36 aLambda.setUserTag(1);
37 EvtRecVeeVertex* lambda = const_cast<EvtRecVeeVertex*>( aLambda.navLambda() );
38
39 if ( fabs(lambda->vertexId()) != 3122 ) return false;
40
41 double mass = lambda->mass();
42 if ((mass <= m_minMass)||(mass >= m_maxMass)) return false;
43 if ( lambda->chi2() >= m_maxChisq ) return false;
44
45
46 // PID
47 int index[2] = {0, 1};
48 if (lambda->vertexId() < 0){
49 index[0] = 1;
50 index[1] = 0;
51 }
52
53 EvtRecTrack* recTrk_proton = lambda->daughter(index[0]);
54 EvtRecTrack* recTrk_pion = lambda->daughter(index[1]);
55
56 if(m_UseProtonPID){
58 pid->init();
59 pid->setMethod(pid->methodProbability());
60 pid->setChiMinCut(m_ChiCut);
61 pid->setRecTrack(recTrk_proton);
62 //pid->usePidSys(pid->useDedx() | pid->useTof1() | pid->useTof2() | pid->useTof());
63 pid->usePidSys(pid->useDedx() | pid->useTofCorr() );
64 pid->identify(pid->onlyPion() | pid->onlyKaon() | pid->onlyProton());
65 pid->calculate();
66 if(!(pid->probProton() > 0. && pid->probProton() > pid->probPion() && pid->probProton() > pid->probKaon())) return false;
67 }
68
69 if( !m_doSecondaryVFit ) return true;
70 // --------------------------------------------------
71 // Do a secondary vertex fit and check the flight significance
72 // --------------------------------------------------
73
74 RecMdcKalTrack* mdcKalTrk_proton = recTrk_proton->mdcKalTrack();
75 mdcKalTrk_proton->setPidType(RecMdcKalTrack::proton);
76 WTrackParameter WTrk_proton;
77 WTrk_proton = WTrackParameter(0.9314940054, mdcKalTrk_proton->getZHelixP(), mdcKalTrk_proton->getZErrorP());
78
79 RecMdcKalTrack* mdcKalTrk_pion = recTrk_pion->mdcKalTrack();
80 mdcKalTrk_pion->setPidType(RecMdcKalTrack::pion);
81 WTrackParameter WTrk_pion = WTrackParameter(0.13957018, mdcKalTrk_pion->getZHelix(), mdcKalTrk_pion->getZError());
82
83 VertexParameter wideVertex;
84 HepPoint3D vWideVertex(0., 0., 0.);
85 HepSymMatrix evWideVertex(3, 0);
86
87 evWideVertex[0][0] = 1.0e12;
88 evWideVertex[1][1] = 1.0e12;
89 evWideVertex[2][2] = 1.0e12;
90
91 wideVertex.setVx(vWideVertex);
92 wideVertex.setEvx(evWideVertex);
93
94 // First, perform a vertex fit
96 vtxfit->init();
97
98 // add the daughters
99 vtxfit->AddTrack(0,WTrk_proton);
100 vtxfit->AddTrack(1,WTrk_pion);
101 vtxfit->AddVertex(0,wideVertex,0,1);
102
103 // do the fit
104 vtxfit->Fit(0);
105 vtxfit->Swim(0);
106 vtxfit->BuildVirtualParticle(0);
107
108 // Now perform the secondary vertex fit
110 svtxfit->init();
111
112 // add the primary vertex
113 VertexParameter beamSpot;
114 HepPoint3D vBeamSpot(0., 0., 0.);
115 HepSymMatrix evBeamSpot(3, 0);
116
117 IVertexDbSvc* vtxsvc;
118 Gaudi::svcLocator()->service("VertexDbSvc", vtxsvc);
119 if(vtxsvc->isVertexValid()){
120 double* dbv = vtxsvc->PrimaryVertex();
121 double* vv = vtxsvc->SigmaPrimaryVertex();
122 for (unsigned int ivx = 0; ivx < 3; ivx++){
123 vBeamSpot[ivx] = dbv[ivx];
124 evBeamSpot[ivx][ivx] = vv[ivx] * vv[ivx];
125 }
126 }
127 else{
128 cout << "LambdaSELECTOR ERROR: Could not find a vertex from VertexDbSvc" << endl;
129 return false;
130 }
131
132 beamSpot.setVx(vBeamSpot);
133 beamSpot.setEvx(evBeamSpot);
134
135 VertexParameter primaryVertex(beamSpot);
136 svtxfit->setPrimaryVertex(primaryVertex);
137
138 // add the secondary vertex
139 svtxfit->setVpar(vtxfit->vpar(0));
140
141 // add the Ks or lambda
142 svtxfit->AddTrack(0,vtxfit->wVirtualTrack(0));
143
144 // do the second vertex fit
145 // if the fit fails, the default values will not be changed
146 if( !svtxfit->Fit() ) return false;
147
148 // save the new ks parameters
149 double vfitlength = svtxfit->decayLength();
150 double vfiterror = svtxfit->decayLengthError();
151 double vfitchi2 = svtxfit->chisq();
152 double flightsig = 0;
153 if( vfiterror != 0 )
154 flightsig = vfitlength/vfiterror;
155
156 // if the ks does not meet the criteria, the information from
157 // the secondary vertex fit will not be filled (default = -999)
158 if( vfitchi2 > m_maxVFitChisq ) return false;
159 if( flightsig < m_minFlightSig ) return false;
160
161 return true;
162
163}
164
double mass
LocalLambdaSelector lambdaSelector
void setUserTag(int tag)
Definition: CDCandidate.cxx:81
virtual const EvtRecVeeVertex * navLambda() const
Definition: CDLambda.cxx:116
virtual bool isVertexValid()=0
virtual double * SigmaPrimaryVertex()=0
virtual double * PrimaryVertex()=0
bool operator()(CDLambda &aLambda)
static ParticleID * instance()
Definition: ParticleID.cxx:22
void calculate()
Definition: ParticleID.cxx:97
void init()
Definition: ParticleID.cxx:27
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