225{
226 MsgStream log(
msgSvc(), name());
227 log << MSG::INFO << "in execute()" << endmsg;
228
229 cout.precision(20);
230
231
232
233 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
236 log << MSG::DEBUG << "run and event = " << eventHeader->runNumber()
237 << " " << eventHeader->eventNumber() << endreq;
238 log << MSG::DEBUG <<"ncharg, nneu, tottks = "
239 << recEvent->totalCharged() << " , " << recEvent->totalNeutral() << " , "
240 << recEvent->totalTracks() <<endreq;
241 m_sel_number[0]++;
242
243
244
245
246
248
249 StatusCode sc = RegisterEvtRecPrimaryVertex(aNewEvtRecPrimaryVertex, log);
250 if (sc != StatusCode::SUCCESS) {
251 return sc;
252 }
253
254
255 if (recEvent->totalCharged() < m_trackNumberCut) {
256 return StatusCode::SUCCESS;
257 }
258 m_sel_number[1]++;
259
260 Vint icp, icm, iGood;
261 SelectGoodChargedTracks(recEvent, recTrackCol, icp, icm, iGood);
262
263
264 if (iGood.size() < m_trackNumberCut) {
265 return StatusCode::SUCCESS;
266 }
267 m_sel_number[2]++;
268
269
270 VertexParameter vxpar;
272
273
274 if (m_fitMethod == 0) {
278 for (int i = 0; i < iGood.size(); i++) {
279 int trk_id = iGood[i];
281 RecMdcKalTrack *kalTrk = (*itTrk)->mdcKalTrack();
283 WTrackParameter wtrk(
xmass[2], kalTrk->
helix(), kalTrk->
err());
285 tlis.push_back(i);
286 trkidlis.push_back(trk_id);
287 }
289 if(!vtxfit->
Fit(0))
return StatusCode::SUCCESS;
290 if(vtxfit->
chisq(0) > m_globalChisqCut)
return StatusCode::SUCCESS;
291 if (m_output == 1) {
292 m_chig = vtxfit->
chisq(0);
293 m_ndofg = 2 * iGood.size() - 3;
294 m_probg = TMath::Prob(m_chig, m_ndofg);
295 HepVector glvtx = vtxfit->
Vx(0);
296 m_gvx = glvtx[0];
297 m_gvy = glvtx[1];
298 m_gvz = glvtx[2];
299 m_tuple1->write();
300 }
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316 aNewEvtRecPrimaryVertex->
setNTracks(iGood.size());
319 aNewEvtRecPrimaryVertex->
setNdof(2 * iGood.size() - 3);
324
325 } else if (m_fitMethod == 1) {
326
334 for(int i = 0; i < iGood.size(); i++) {
335 int trk_id = iGood[i];
337 RecMdcKalTrack *kalTrk = (*itTrk)->mdcKalTrack();
339 HTrackParameter htrk(kalTrk->
helix(), kalTrk->
err(), trk_id, 2);
341 }
343
344
345 if(kalvtx->
ndof() >= m_freedomCut) {
346
347 for(int i = 0; i < iGood.size(); i++) {
348 if (m_output == 1) {
349 m_chif = kalvtx->
chiF(i);
350 m_chis = kalvtx->
chiS(i);
351 m_probs = TMath::Prob(m_chis, 2);
352 m_probf = TMath::Prob(m_chif, 2);
353 m_tuple2->write();
354 }
355 if(kalvtx->
chiS(i) > m_chi2CutforSmooth) kalvtx->
remove(i);
356 }
357 }
358 if(kalvtx->
ndof() >= m_freedomCut) {
359 for(int i = 0; i < iGood.size(); i++) {
361
362 HepVector Pull(5, 0);
363 Pull = kalvtx->
pull(i);
364 if (m_output == 1) {
365 m_pull_drho = Pull[0];
366 m_pull_phi = Pull[1];
367 m_pull_kapha = Pull[2];
368 m_pull_dz = Pull[3];
369 m_pull_lamb = Pull[4];
371 m_tuple3->write();
372 }
373 }
374 if (m_output == 1) {
375 m_chik = kalvtx->
chisq();
376 m_ndofk = kalvtx->
ndof();
377 m_probk = TMath::Prob(m_chik, m_ndofk);
378 HepVector xp(3, 0);
380 m_kvx = xp[0];
381 m_kvy = xp[1];
382 m_kvz = xp[2];
383 m_tuple4->write();
384 }
385
386 m_sel_number[3]++;
387
388
389
390
391
392
393
394
395
396
397
398
399
405 aNewEvtRecPrimaryVertex->
setVertex(kalvtx->
x());
408
409 }
410 }
411 return StatusCode::SUCCESS;
412}
EvtRecTrackCol::iterator EvtRecTrackIterator
void InitVertexParameter(VertexParameter &vxpar)
const HepVector & helix() const
static void setPidType(PidType pidType)
const HepSymMatrix & err() const
void setTrackIdList(const std::vector< int > &trackIdList)
void setVertex(const HepVector &vtx)
void setFitMethod(int fitMethod)
void setErrorVertex(const HepSymMatrix &Evtx)
void setChi2(double chi2)
void setNTracks(int nTracks)
void setIsValid(bool isValid)
double pullmomentum(const int k)
void setChisqCut(const double chicut)
void addTrack(const HTrackParameter)
double chiF(const int k) const
std::vector< int > trackIDList() const
double chiS(const int k) const
void initVertex(const VertexParameter vtx)
HepVector pull(const int k)
void setTrackIterationCut(const double chicut)
void setTrackIteration(const int num)
static KalmanVertexFit * instance()
void setVertexIteration(const int num)
void AddTrack(const int number, const double mass, const RecMdcTrack *trk)
HepVector Vx(int n) const
void AddVertex(int number, VertexParameter vpar, std::vector< int > lis)
HepSymMatrix Evx(int n) const
static VertexFit * instance()
_EXTERN_ std::string EvtRecPrimaryVertex
_EXTERN_ std::string EvtRecEvent
_EXTERN_ std::string EvtRecTrackCol