BOSS 7.1.2
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
13
14
16{
17 IJobOptionsSvc* jobSvc;
18 Gaudi::svcLocator()->service("JobOptionsSvc", jobSvc);
19
20 PropertyMgr m_propMgr;
21
22 m_propMgr.declareProperty("LambdaMinMassCut", m_minMass = 1.10 );
23 m_propMgr.declareProperty("LambdaMaxMassCut", m_maxMass = 1.13 );
24 m_propMgr.declareProperty("LambdaMaxChisq", m_maxChisq = 100 );
25 m_propMgr.declareProperty("UseProtonPID", m_UseProtonPID = true );
26 m_propMgr.declareProperty("ProtonPIDChiCut", m_ChiCut = 8);
27
28 m_propMgr.declareProperty("DoSecondaryVFit", m_doSecondaryVFit = false );
29 m_propMgr.declareProperty("LambdaMaxVFitChisq", m_maxVFitChisq = 100 );
30 m_propMgr.declareProperty("LambdaMinFlightSig", m_minFlightSig = 2.0 );
31 m_propMgr.declareProperty("UseVFRefine", m_useVFrefine = true);
32
33 m_propMgr.declareProperty("UseBFieldCorr", m_useBFC = true);
34
35 jobSvc->setMyProperties("LocalLambdaSelector", &m_propMgr);
36}
37
39
40 aLambda.setUserTag(1);
41 EvtRecVeeVertex* lambda = const_cast<EvtRecVeeVertex*>( aLambda.navLambda() );
42
43 if ( fabs(lambda->vertexId()) != 3122 ) return false;
44
45 if( !m_useBFC ){
46 double mass = lambda->mass();
47 if ((mass <= m_minMass)||(mass >= m_maxMass)) return false;
48 if ( lambda->chi2() >= m_maxChisq ) return false;
49 }
50
51 // PID
52 int index[2] = {0, 1};
53 if (lambda->vertexId() < 0){
54 index[0] = 1;
55 index[1] = 0;
56 }
57
58 EvtRecTrack* recTrk_proton = lambda->daughter(index[0]);
59 EvtRecTrack* recTrk_pion = lambda->daughter(index[1]);
60
61 if(m_UseProtonPID){
63 pid->init();
64 pid->setMethod(pid->methodProbability());
65 pid->setChiMinCut(m_ChiCut);
66 pid->setRecTrack(recTrk_proton);
67 //pid->usePidSys(pid->useDedx() | pid->useTof1() | pid->useTof2() | pid->useTof());
68 pid->usePidSys(pid->useDedx() | pid->useTofCorr() );
69 pid->identify(pid->onlyPion() | pid->onlyKaon() | pid->onlyProton());
70 pid->calculate();
71 if(!(pid->probProton() > 0. && pid->probProton() > pid->probPion() && pid->probProton() > pid->probKaon())) return false;
72 }
73
74 if( !m_useBFC ){
75 if( !m_doSecondaryVFit ) return true;
76 }
77 // --------------------------------------------------
78 // Do a secondary vertex fit and check the flight significance
79 // --------------------------------------------------
80
81 RecMdcKalTrack* mdcKalTrk_proton = recTrk_proton->mdcKalTrack();
82 mdcKalTrk_proton->setPidType(RecMdcKalTrack::proton);
83 WTrackParameter WTrk_proton;
84 WTrk_proton = WTrackParameter(0.9314940054, mdcKalTrk_proton->getZHelixP(), mdcKalTrk_proton->getZErrorP());
85
86 RecMdcKalTrack* mdcKalTrk_pion = recTrk_pion->mdcKalTrack();
87 mdcKalTrk_pion->setPidType(RecMdcKalTrack::pion);
88 WTrackParameter WTrk_pion = WTrackParameter(0.13957018, mdcKalTrk_pion->getZHelix(), mdcKalTrk_pion->getZError());
89
90 //VertexParameter wideVertex;
91 HepPoint3D vWideVertex(0., 0., 0.);
92 HepSymMatrix evWideVertex(3, 0);
93
94 evWideVertex[0][0] = 1.0e12;
95 evWideVertex[1][1] = 1.0e12;
96 evWideVertex[2][2] = 1.0e12;
97
98 // add the primary vertex
99 HepPoint3D vBeamSpot(0., 0., 0.);
100 HepSymMatrix evBeamSpot(3, 0);
101
102 IVertexDbSvc* vtxsvc;
103 Gaudi::svcLocator()->service("VertexDbSvc", vtxsvc);
104 if(vtxsvc->isVertexValid()){
105 double* dbv = vtxsvc->PrimaryVertex();
106 double* vv = vtxsvc->SigmaPrimaryVertex();
107 for (unsigned int ivx = 0; ivx < 3; ivx++){
108 vBeamSpot[ivx] = dbv[ivx];
109 evBeamSpot[ivx][ivx] = vv[ivx] * vv[ivx];
110 }
111 }
112 else{
113 cout << "LambdaSELECTOR ERROR: Could not find a vertex from VertexDbSvc" << endl;
114 return false;
115 }
116
117 if(m_useVFrefine){
118
119 VertexParameter wideVertex;
120
121 wideVertex.setVx(vWideVertex);
122 wideVertex.setEvx(evWideVertex);
123
124 // First, perform a vertex fit refine
126 vtxfitr->init();
127
128 vtxfitr->AddTrack(0, mdcKalTrk_proton, RecMdcKalTrack::proton);
129 vtxfitr->AddTrack(1, mdcKalTrk_pion, RecMdcKalTrack::pion);
130 vtxfitr->AddVertex(0, wideVertex, 0, 1);
131
132 bool fitok = vtxfitr->Fit();
133
134 HepLorentzVector ppr = vtxfitr->pfit(0);
135 HepLorentzVector ppi = vtxfitr->pfit(1);
136 HepLorentzVector plambda = ppr + ppi;
137
138 double mass = plambda.m();
139 double chisqvtx = vtxfitr->chisq(0);
140
141 if( m_useBFC ){
142 if ((mass <= m_minMass)||(mass >= m_maxMass)) return false;
143 //if ( lambda->chi2() >= m_maxChisq ) return false;
144 if ( chisqvtx >= m_maxChisq ) return false;
145
146 if( !m_doSecondaryVFit ) return true;
147 }
148
149 // Now perform the secondary vertex fit
151 svtxfit->init();
152
153 // add the primary vertex
154 VertexParameter beamSpot;
155
156 beamSpot.setVx(vBeamSpot);
157 beamSpot.setEvx(evBeamSpot);
158
159 VertexParameter primaryVertex(beamSpot);
160 svtxfit->setPrimaryVertex(primaryVertex);
161
162 // add the secondary vertex
163 svtxfit->setVpar(vtxfitr->vpar(0));
164
165 // add the Ks or lambda
166 svtxfit->AddTrack(0,vtxfitr->wVirtualTrack(0));
167
168 // do the second vertex fit
169 // if the fit fails, the default values will not be changed
170 if( !svtxfit->Fit() ) return false;
171
172 // save the new ks parameters
173 double vfitlength = svtxfit->decayLength();
174 double vfiterror = svtxfit->decayLengthError();
175 double vfitchi2 = svtxfit->chisq();
176 double flightsig = 0;
177 if( vfiterror != 0 )
178 flightsig = vfitlength/vfiterror;
179
180 // if the ks does not meet the criteria, the information from
181 // the secondary vertex fit will not be filled (default = -999)
182 if( vfitchi2 > m_maxVFitChisq ) return false;
183 if( flightsig < m_minFlightSig ) return false;
184
185 return true;
186
187 }else{
188 VertexParameter wideVertex;
189
190 wideVertex.setVx(vWideVertex);
191 wideVertex.setEvx(evWideVertex);
192
193 // First, perform a vertex fit
194 VertexFit* vtxfit = VertexFit::instance();
195 vtxfit->init();
196
197 // add the daughters
198 vtxfit->AddTrack(0,WTrk_proton);
199 vtxfit->AddTrack(1,WTrk_pion);
200 vtxfit->AddVertex(0,wideVertex,0,1);
201
202 // do the fit
203 vtxfit->Fit(0);
204 vtxfit->Swim(0);
205 vtxfit->BuildVirtualParticle(0);
206
207 WTrackParameter wlambda = vtxfit->wVirtualTrack(0);
208
209 HepLorentzVector plambda = wlambda.p();
210
211 double mass = plambda.m();
212 double chisqvtx = vtxfit->chisq(0);
213
214 if( m_useBFC ){
215 if ((mass <= m_minMass)||(mass >= m_maxMass)) return false;
216 //if ( lambda->chi2() >= m_maxChisq ) return false;
217 if ( chisqvtx >= m_maxChisq ) return false;
218
219 if( !m_doSecondaryVFit ) return true;
220 }
221
222 // Now perform the secondary vertex fit
224 svtxfit->init();
225
226 // add the primary vertex
227 VertexParameter beamSpot;
228 beamSpot.setVx(vBeamSpot);
229 beamSpot.setEvx(evBeamSpot);
230
231 VertexParameter primaryVertex(beamSpot);
232 svtxfit->setPrimaryVertex(primaryVertex);
233
234 // add the secondary vertex
235 svtxfit->setVpar(vtxfit->vpar(0));
236
237 // add the Ks or lambda
238 svtxfit->AddTrack(0,vtxfit->wVirtualTrack(0));
239
240 // do the second vertex fit
241 // if the fit fails, the default values will not be changed
242 if( !svtxfit->Fit() ) return false;
243
244 // save the new ks parameters
245 double vfitlength = svtxfit->decayLength();
246 double vfiterror = svtxfit->decayLengthError();
247 double vfitchi2 = svtxfit->chisq();
248 double flightsig = 0;
249 if( vfiterror != 0 )
250 flightsig = vfitlength/vfiterror;
251
252 // if the ks does not meet the criteria, the information from
253 // the secondary vertex fit will not be filled (default = -999)
254 if( vfitchi2 > m_maxVFitChisq ) return false;
255 if( flightsig < m_minFlightSig ) return false;
256
257 return true;
258
259
260 }
261
262
263
264
265
266
267}
268
double mass
LocalLambdaSelector lambdaSelector
void setUserTag(int tag)
virtual const EvtRecVeeVertex * navLambda() const
Definition CDLambda.cxx:116
static void setPidType(PidType pidType)
RecMdcKalTrack * mdcKalTrack()
Definition EvtRecTrack.h:54
SmartRef< EvtRecTrack > & daughter(int i)
int vertexId() const
double mass() const
double chi2() const
virtual bool isVertexValid()=0
virtual double * SigmaPrimaryVertex()=0
virtual double * PrimaryVertex()=0
bool operator()(CDLambda &aLambda)
int useTofCorr() const
int onlyProton() const
int methodProbability() const
int useDedx() const
int onlyKaon() const
int onlyPion() const
void setChiMinCut(const double chi=4)
void setRecTrack(EvtRecTrack *trk)
double probKaon() const
Definition ParticleID.h:124
void setMethod(const int method)
Definition ParticleID.h:94
void identify(const int pidcase)
Definition ParticleID.h:103
void usePidSys(const int pidsys)
Definition ParticleID.h:97
static ParticleID * instance()
double probPion() const
Definition ParticleID.h:123
void calculate()
void init()
double probProton() const
Definition ParticleID.h:125
const HepVector & getZHelix() const
HepVector & getZHelixP()
const HepSymMatrix & getZError() const
HepSymMatrix & getZErrorP()
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
HepLorentzVector pfit(int n) const
double chisq() 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
double chisq() const
Definition VertexFit.h:66
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)
void Swim(int n)
Definition VertexFit.h:59
bool Fit()
void setEvx(const HepSymMatrix &eVx)
void setVx(const HepPoint3D &vx)
HepLorentzVector p() const