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

#include <DQAKsKpiDEDX.h>

Inheritance diagram for DQAKsKpiDEDX:

Public Member Functions

 DQAKsKpiDEDX (const std::string &name, ISvcLocator *pSvcLocator)
StatusCode initialize ()
StatusCode execute ()
StatusCode finalize ()

Detailed Description

Definition at line 21 of file DQAKsKpiDEDX.h.

Constructor & Destructor Documentation

◆ DQAKsKpiDEDX()

DQAKsKpiDEDX::DQAKsKpiDEDX ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 57 of file DQAKsKpiDEDX.cxx.

58 : Algorithm( name, pSvcLocator ) {
59
60 // Declare the properties
61 declareProperty( "Vr0cut", m_vr0cut = 5.0 );
62 declareProperty( "Vz0cut", m_vz0cut = 20.0 );
63 declareProperty( "Vr1cut", m_vr1cut = 1.0 );
64 declareProperty( "Vz1cut", m_vz1cut = 5.0 );
65 declareProperty( "Vctcut", m_cthcut = 0.93 );
66 declareProperty( "EnergyThreshold", m_energyThreshold = 0.04 );
67 declareProperty( "GammaAngCut", m_gammaAngCut = 20.0 );
68}

Referenced by DQAKsKpiDEDX().

Member Function Documentation

◆ execute()

StatusCode DQAKsKpiDEDX::execute ( )

Definition at line 233 of file DQAKsKpiDEDX.cxx.

233 {
234
235 MsgStream log( msgSvc(), name() );
236 log << MSG::INFO << "in execute()" << endmsg;
237
238 // DQA
239 // Add the line below at the beginning of execute()
240 // setFilterPassed(false);
241
242 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(), "/Event/EventHeader" );
243 m_runNo = eventHeader->runNumber();
244 m_event = eventHeader->eventNumber();
245 log << MSG::DEBUG << "run, evtnum = " << m_runNo << " , " << m_event << endmsg;
246
247 SmartDataPtr<EvtRecEvent> evtRecEvent( eventSvc(), EventModel::EvtRec::EvtRecEvent );
248 // m_nchrg = evtRecEvent->totalCharged();
249 // m_nneu = evtRecEvent->totalNeutral();
250 log << MSG::DEBUG << "ncharg, nneu, tottks = " << evtRecEvent->totalCharged() << " , "
251 << evtRecEvent->totalNeutral() << " , " << evtRecEvent->totalTracks() << endmsg;
252
253 SmartDataPtr<EvtRecTrackCol> evtRecTrkCol( eventSvc(), EventModel::EvtRec::EvtRecTrackCol );
254
255 if ( evtRecEvent->totalNeutral() > 100 ) { return StatusCode::SUCCESS; }
256
257 Vint iGood;
258 iGood.clear();
259
260 Hep3Vector xorigin( 0, 0, 0 );
261
262 IVertexDbSvc* vtxsvc;
263 Gaudi::svcLocator()->service( "VertexDbSvc", vtxsvc ).ignore();
264 if ( vtxsvc->isVertexValid() )
265 {
266 double* dbv = vtxsvc->PrimaryVertex();
267 double* vv = vtxsvc->SigmaPrimaryVertex();
268 xorigin.setX( dbv[0] );
269 xorigin.setY( dbv[1] );
270 xorigin.setZ( dbv[2] );
271 log << MSG::INFO << "xorigin.x=" << xorigin.x() << ", "
272 << "xorigin.y=" << xorigin.y() << ", "
273 << "xorigin.z=" << xorigin.z() << ", " << endmsg;
274 }
275
276 int nCharge = 0;
277 for ( int i = 0; i < evtRecEvent->totalCharged(); i++ )
278 {
279 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + i;
280 if ( !( *itTrk )->isMdcTrackValid() ) continue;
281 if ( !( *itTrk )->isMdcKalTrackValid() ) continue;
282 RecMdcTrack* mdcTrk = ( *itTrk )->mdcTrack();
283
284 double pch = mdcTrk->p();
285 double x0 = mdcTrk->x();
286 double y0 = mdcTrk->y();
287 double z0 = mdcTrk->z();
288 double phi0 = mdcTrk->helix( 1 );
289 double xv = xorigin.x();
290 double yv = xorigin.y();
291 double Rxy = fabs( ( x0 - xv ) * cos( phi0 ) + ( y0 - yv ) * sin( phi0 ) );
292 double vx0 = x0;
293 double vy0 = y0;
294 double vz0 = z0 - xorigin.z();
295 double vr0 = Rxy;
296 double Vct = cos( mdcTrk->theta() );
297
298 HepVector a = mdcTrk->helix();
299 HepSymMatrix Ea = mdcTrk->err();
300 HepPoint3D point0( 0., 0., 0. ); // the initial point for MDC recosntruction
301 HepPoint3D IP( xorigin[0], xorigin[1], xorigin[2] );
302 VFHelix helixip( point0, a, Ea );
303 helixip.pivot( IP );
304 HepVector vecipa = helixip.a();
305 double Rvxy0 = fabs( vecipa[0] ); // the nearest distance to IP in xy plane
306 double Rvz0 = vecipa[3]; // the nearest distance to IP in z direction
307 double Rvphi0 = vecipa[1];
308 // m_rvxy0=Rvxy0;
309 // m_rvz0=Rvz0;
310 // m_rvphi0=Rvphi0;
311
312 if ( fabs( Rvz0 ) >= m_vz0cut ) continue;
313 if ( fabs( Rvxy0 ) >= m_vr0cut ) continue;
314
315 // if(fabs(Vct)>=m_cthcut) continue;
316 // iGood.push_back((*itTrk)->trackId());
317 iGood.push_back( i );
318 nCharge += mdcTrk->charge();
319 }
320
321 //
322 // Finish Good Charged Track Selection
323 //
324 int m_ngch = iGood.size();
325 log << MSG::DEBUG << "ngood, totcharge = " << m_ngch << " , " << nCharge << endmsg;
326 if ( ( m_ngch != 4 ) || ( nCharge != 0 ) ) { return StatusCode::SUCCESS; }
327
328 // Particle ID
329 //
330 Vint ipip, ipim, ikp, ikm, ipp, ipm;
331 ipip.clear();
332 ipim.clear();
333 ikp.clear();
334 ikm.clear();
335 ipp.clear();
336 ipm.clear();
337
338 Vp4 p_pip, p_pim, p_kp, p_km, p_pp, p_pm;
339 p_pip.clear();
340 p_pim.clear();
341 p_kp.clear();
342 p_km.clear();
343 p_pp.clear();
344 p_pm.clear();
345
346 ParticleID* pid = ParticleID::instance();
347 for ( int i = 0; i < m_ngch; i++ )
348 {
349 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + iGood[i];
350 // if(pid) delete pid;
351 pid->init();
352 pid->setMethod( pid->methodProbability() );
353 pid->setChiMinCut( 4 );
354 pid->setRecTrack( *itTrk );
355 // pid->usePidSys(pid->useDedx()); // just use dedx PID
356 pid->usePidSys( pid->useTof1() | pid->useTof2() | pid->useTofE() | pid->useTofQ() );
357 pid->identify( pid->onlyPionKaonProton() ); // seperater Pion/Kaon/Proton
358 // pid->identify(pid->onlyPion() | pid->onlyKaon()); // seperater Pion/Kaon
359 // pid->identify(pid->onlyPion());
360 // pid->identify(pid->onlyKaon());
361 pid->calculate();
362 if ( !( pid->IsPidInfoValid() ) ) continue;
363
364 RecMdcTrack* mdcTrk = ( *itTrk )->mdcTrack();
365 RecMdcKalTrack* mdcKalTrk = 0;
366 if ( ( *itTrk )->isMdcKalTrackValid() ) mdcKalTrk = ( *itTrk )->mdcKalTrack();
367
368 double prob_pi = pid->probPion();
369 double prob_K = pid->probKaon();
370 double prob_p = pid->probProton();
371 // std::cout << "prob "<< prob_pi << ", "<< prob_K << ", "<< prob_p << std::endl;
372 HepLorentzVector ptrk;
373 ptrk.setPx( mdcTrk->px() );
374 ptrk.setPy( mdcTrk->py() );
375 ptrk.setPz( mdcTrk->pz() );
376 double p3 = ptrk.mag();
377
378 if ( prob_pi > prob_K && prob_pi > prob_p )
379 {
380 m_pidcode[i] = 2;
381 m_pidprob[i] = pid->prob( 2 );
382 m_pidchiDedx[i] = pid->chiDedx( 2 );
383 m_pidchiTof1[i] = pid->chiTof1( 2 );
384 m_pidchiTof2[i] = pid->chiTof2( 2 );
385 ptrk.setE( sqrt( p3 * p3 + xmass[2] * xmass[2] ) );
386 if ( mdcTrk->charge() > 0 )
387 {
388 ipip.push_back( iGood[i] );
389 p_pip.push_back( ptrk );
390 }
391 if ( mdcTrk->charge() < 0 )
392 {
393 ipim.push_back( iGood[i] );
394 p_pim.push_back( ptrk );
395 }
396 }
397
398 if ( prob_K > prob_pi && prob_K > prob_p )
399 {
400 m_pidcode[i] = 3;
401 m_pidprob[i] = pid->prob( 3 );
402 m_pidchiDedx[i] = pid->chiDedx( 3 );
403 m_pidchiTof1[i] = pid->chiTof1( 3 );
404 m_pidchiTof2[i] = pid->chiTof2( 3 );
405 ptrk.setE( sqrt( p3 * p3 + xmass[3] * xmass[3] ) );
406 if ( mdcTrk->charge() > 0 )
407 {
408 ikp.push_back( iGood[i] );
409 p_kp.push_back( ptrk );
410 }
411 if ( mdcTrk->charge() < 0 )
412 {
413 ikm.push_back( iGood[i] );
414 p_km.push_back( ptrk );
415 }
416 }
417
418 if ( prob_p > prob_pi && prob_p > prob_K )
419 {
420 m_pidcode[i] = 4;
421 m_pidprob[i] = pid->prob( 4 );
422 m_pidchiDedx[i] = pid->chiDedx( 4 );
423 m_pidchiTof1[i] = pid->chiTof1( 4 );
424 m_pidchiTof2[i] = pid->chiTof2( 4 );
425 ptrk.setE( sqrt( p3 * p3 + xmass[4] * xmass[4] ) );
426 if ( mdcTrk->charge() > 0 )
427 {
428 ipp.push_back( iGood[i] );
429 p_pp.push_back( ptrk );
430 }
431 if ( mdcTrk->charge() < 0 )
432 {
433 ipm.push_back( iGood[i] );
434 p_pm.push_back( ptrk );
435 }
436 }
437 }
438
439 m_npip = ipip.size();
440 m_npim = ipim.size();
441 m_nkp = ikp.size();
442 m_nkm = ikm.size();
443 m_np = ipp.size();
444 m_npb = ipm.size();
445
446 // cout<<"m_npip*m_npim: "<<m_npip*m_npim<<endl;
447 if ( m_npip * m_npim != 2 ) { return StatusCode::SUCCESS; }
448 // cout<<"m_nkp+m_nkm: "<<m_nkp+m_nkm<<endl;
449 if ( m_nkp + m_nkm != 1 ) { return StatusCode::SUCCESS; }
450 // cout<<"haha"<<endl;
451
452 // Vertex Fit
453 HepPoint3D vx( 0., 0., 0. );
454 HepSymMatrix Evx( 3, 0 );
455 double bx = 1E+6;
456 double by = 1E+6;
457 double bz = 1E+6;
458 Evx[0][0] = bx * bx;
459 Evx[1][1] = by * by;
460 Evx[2][2] = bz * bz;
461
462 VertexParameter vxpar;
463 vxpar.setVx( vx );
464 vxpar.setEvx( Evx );
465
466 VertexFit* vtxfit_s = VertexFit::instance(); // S second vertex
467 VertexFit* vtxfit_p = VertexFit::instance(); // P primary vertex
468 SecondVertexFit* vtxfit2 = SecondVertexFit::instance();
469
470 RecMdcKalTrack *pi1KalTrk{ nullptr }, *pi2KalTrk{ nullptr }, *pi3KalTrk{ nullptr },
471 *k1KalTrk{ nullptr };
472 RecMdcKalTrack *pipKalTrk{ nullptr }, *pimKalTrk{ nullptr }, *piKalTrk{ nullptr },
473 *kKalTrk{ nullptr };
474 WTrackParameter wks, vwks;
475
476 double chi_temp = 999.0;
477 double mks_temp = 10.0;
478 bool okloop = false;
479 for ( unsigned int i1 = 0; i1 < m_npip; i1++ )
480 { // pion plus
481 RecMdcKalTrack* pi1KalTrk = ( *( evtRecTrkCol->begin() + ipip[i1] ) )->mdcKalTrack();
482 pi1KalTrk->setPidType( RecMdcKalTrack::pion );
483 WTrackParameter wpi1trk( xmass[2], pi1KalTrk->getZHelix(), pi1KalTrk->getZError() );
484
485 for ( unsigned int i2 = 0; i2 < m_npim; i2++ )
486 { // pion minus
487 RecMdcKalTrack* pi2KalTrk = ( *( evtRecTrkCol->begin() + ipim[i2] ) )->mdcKalTrack();
488 pi2KalTrk->setPidType( RecMdcKalTrack::pion );
489 WTrackParameter wpi2trk( xmass[2], pi2KalTrk->getZHelix(), pi2KalTrk->getZError() );
490
491 vtxfit_s->init();
492 vtxfit_s->AddTrack( 0, wpi1trk );
493 vtxfit_s->AddTrack( 1, wpi2trk );
494 vtxfit_s->AddVertex( 0, vxpar, 0, 1 );
495
496 if ( !( vtxfit_s->Fit( 0 ) ) ) continue;
497 vtxfit_s->BuildVirtualParticle( 0 );
498 m_vfits_chi = vtxfit_s->chisq( 0 );
499 WTrackParameter wkshort = vtxfit_s->wVirtualTrack( 0 );
500 VertexParameter vparks = vtxfit_s->vpar( 0 );
501
502 m_vfits_vx = ( vparks.Vx() )[0];
503 m_vfits_vy = ( vparks.Vx() )[1];
504 m_vfits_vz = ( vparks.Vx() )[2];
505 m_vfits_vr = sqrt( m_vfits_vx * m_vfits_vx + m_vfits_vy * m_vfits_vy );
506
507 if ( m_npip == 2 )
508 {
509 int j = i1;
510 int jj = ( i1 == 1 ) ? 0 : 1;
511 pi3KalTrk = ( *( evtRecTrkCol->begin() + ipip[jj] ) )->mdcKalTrack();
512 k1KalTrk = ( *( evtRecTrkCol->begin() + ikm[0] ) )->mdcKalTrack();
513 }
514 if ( m_npim == 2 )
515 {
516 int j = i2;
517 int jj = ( i2 == 1 ) ? 0 : 1;
518 pi3KalTrk = ( *( evtRecTrkCol->begin() + ipim[jj] ) )->mdcKalTrack();
519 k1KalTrk = ( *( evtRecTrkCol->begin() + ikp[0] ) )->mdcKalTrack();
520 }
521
522 pi3KalTrk->setPidType( RecMdcKalTrack::pion );
523 WTrackParameter wpi3trk( xmass[2], pi3KalTrk->getZHelix(), pi3KalTrk->getZError() );
524 k1KalTrk->setPidType( RecMdcKalTrack::kaon );
525 WTrackParameter wk1trk( xmass[3], k1KalTrk->getZHelixK(), k1KalTrk->getZErrorK() );
526
527 vtxfit_p->init();
528 // vtxfit_p->AddTrack(0, wkshort);
529 vtxfit_p->AddTrack( 0, wpi3trk );
530 vtxfit_p->AddTrack( 1, wk1trk );
531 vtxfit_p->AddVertex( 0, vxpar, 0, 1 );
532 if ( !( vtxfit_p->Fit( 0 ) ) ) continue;
533
534 m_vfitp_chi = vtxfit_p->chisq( 0 );
535
536 VertexParameter primaryVpar = vtxfit_p->vpar( 0 );
537 m_vfitp_vx = ( primaryVpar.Vx() )[0];
538 m_vfitp_vy = ( primaryVpar.Vx() )[1];
539 m_vfitp_vz = ( primaryVpar.Vx() )[2];
540 m_vfitp_vr = sqrt( m_vfitp_vx * m_vfitp_vx + m_vfitp_vy * m_vfitp_vy );
541
542 vtxfit2->init();
543 vtxfit2->setPrimaryVertex( vtxfit_p->vpar( 0 ) );
544 vtxfit2->AddTrack( 0, wkshort );
545 vtxfit2->setVpar( vtxfit_s->vpar( 0 ) );
546 if ( !vtxfit2->Fit() ) continue;
547
548 if ( fabs( ( ( vtxfit2->wpar() ).p() ).m() - mks0 ) < mks_temp )
549 {
550 mks_temp = fabs( ( ( vtxfit2->wpar() ).p() ).m() - mks0 );
551
552 okloop = true;
553
554 wks = vtxfit2->wpar();
555 m_vfit2_mks = ( wks.p() ).m();
556 m_vfit2_chi = vtxfit2->chisq();
557 m_vfit2_ct = vtxfit2->ctau();
558 m_vfit2_dl = vtxfit2->decayLength();
559 m_vfit2_dle = vtxfit2->decayLengthError();
560
561 pipKalTrk = pi1KalTrk;
562 pimKalTrk = pi2KalTrk;
563 piKalTrk = pi3KalTrk;
564 kKalTrk = k1KalTrk;
565 }
566 }
567 }
568
569 if ( !okloop ) { return StatusCode::SUCCESS; }
570
571 pipKalTrk->setPidType( RecMdcKalTrack::pion );
572 pimKalTrk->setPidType( RecMdcKalTrack::pion );
573 piKalTrk->setPidType( RecMdcKalTrack::pion );
574 kKalTrk->setPidType( RecMdcKalTrack::kaon );
575
576 WTrackParameter wpip( xmass[2], pipKalTrk->getZHelix(),
577 pipKalTrk->getZError() ); // pi+ from Ks
578 WTrackParameter wpim( xmass[2], pimKalTrk->getZHelix(),
579 pimKalTrk->getZError() ); // pi- from Ks
580
581 WTrackParameter wpi( xmass[2], piKalTrk->getZHelix(), piKalTrk->getZError() );
582 WTrackParameter wk( xmass[3], kKalTrk->getZHelixK(), kKalTrk->getZErrorK() );
583
584 //
585 // check good charged track's infomation
586 int ii{ 0 };
587 for ( int j = 0; j < m_ngch; j++ )
588 {
589 m_charge[j] = 9999.0;
590 m_vx0[j] = 9999.0;
591 m_vy0[j] = 9999.0;
592 m_vz0[j] = 9999.0;
593 m_vr0[j] = 9999.0;
594
595 m_vx[j] = 9999.0;
596 m_vy[j] = 9999.0;
597 m_vz[j] = 9999.0;
598 m_vr[j] = 9999.0;
599
600 m_px[j] = 9999.0;
601 m_py[j] = 9999.0;
602 m_pz[j] = 9999.0;
603 m_p[j] = 9999.0;
604 m_cost[j] = 9999.0;
605
606 m_probPH[j] = 9999.0;
607 m_normPH[j] = 9999.0;
608 m_chie[j] = 9999.0;
609 m_chimu[j] = 9999.0;
610 m_chipi[j] = 9999.0;
611 m_chik[j] = 9999.0;
612 m_chip[j] = 9999.0;
613 m_ghit[j] = 9999.0;
614 m_thit[j] = 9999.0;
615
616 m_e_emc[j] = 9999.0;
617
618 m_qual_etof[j] = 9999.0;
619 m_tof_etof[j] = 9999.0;
620 m_te_etof[j] = 9999.0;
621 m_tmu_etof[j] = 9999.0;
622 m_tpi_etof[j] = 9999.0;
623 m_tk_etof[j] = 9999.0;
624 m_tp_etof[j] = 9999.0;
625
626 m_qual_btof1[j] = 9999.0;
627 m_tof_btof1[j] = 9999.0;
628 m_te_btof1[j] = 9999.0;
629 m_tmu_btof1[j] = 9999.0;
630 m_tpi_btof1[j] = 9999.0;
631 m_tk_btof1[j] = 9999.0;
632 m_tp_btof1[j] = 9999.0;
633
634 m_qual_btof2[j] = 9999.0;
635 m_tof_btof2[j] = 9999.0;
636 m_te_btof2[j] = 9999.0;
637 m_tmu_btof2[j] = 9999.0;
638 m_tpi_btof2[j] = 9999.0;
639 m_tk_btof2[j] = 9999.0;
640 m_tp_btof2[j] = 9999.0;
641
642 m_pidcode[j] = 9999.0;
643 m_pidprob[j] = 9999.0;
644 m_pidchiDedx[j] = 9999.0;
645 m_pidchiTof1[j] = 9999.0;
646 m_pidchiTof2[j] = 99999.0;
647 }
648
649 for ( int i = 0; i < m_ngch; i++ )
650 {
651
652 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + iGood[i];
653 if ( !( *itTrk )->isMdcTrackValid() ) continue; // MDC information
654 RecMdcTrack* mdcTrk = ( *itTrk )->mdcTrack();
655 RecMdcKalTrack* mdcKalTrk = ( *itTrk )->mdcKalTrack();
656
657 if ( mdcKalTrk == pipKalTrk )
658 {
659 ii = 0;
660 mdcKalTrk->setPidType( RecMdcKalTrack::pion );
661 }
662 if ( mdcKalTrk == pimKalTrk )
663 {
664 ii = 1;
665 mdcKalTrk->setPidType( RecMdcKalTrack::pion );
666 }
667 if ( mdcKalTrk == piKalTrk )
668 {
669 ii = 2;
670 mdcKalTrk->setPidType( RecMdcKalTrack::pion );
671 }
672 if ( mdcKalTrk == kKalTrk )
673 {
674 ii = 3;
675 mdcKalTrk->setPidType( RecMdcKalTrack::kaon );
676 }
677
678 m_charge[ii] = mdcTrk->charge();
679 double x0 = mdcTrk->x();
680 double y0 = mdcTrk->y();
681 double z0 = mdcTrk->z();
682 double phi0 = mdcTrk->helix( 1 );
683 double xv = xorigin.x();
684 double yv = xorigin.y();
685 double zv = xorigin.z();
686 double rv = ( x0 - xv ) * cos( phi0 ) + ( y0 - yv ) * sin( phi0 );
687
688 m_vx0[ii] = x0 - xv;
689 m_vy0[ii] = y0 - yv;
690 m_vz0[ii] = z0 - zv;
691 m_vr0[ii] = rv;
692
693 x0 = mdcKalTrk->x();
694 y0 = mdcKalTrk->y();
695 z0 = mdcKalTrk->z();
696 rv = ( x0 - xv ) * cos( phi0 ) + ( y0 - yv ) * sin( phi0 );
697
698 m_vx[ii] = x0 - xv;
699 m_vy[ii] = y0 - yv;
700 m_vz[ii] = z0 - zv;
701 m_vr[ii] = rv;
702
703 m_px[ii] = mdcKalTrk->px();
704 m_py[ii] = mdcKalTrk->py();
705 m_pz[ii] = mdcKalTrk->pz();
706 m_p[ii] = mdcKalTrk->p();
707 m_cost[ii] = mdcKalTrk->pz() / mdcKalTrk->p();
708
709 double ptrk = mdcKalTrk->p();
710 if ( ( *itTrk )->isMdcDedxValid() )
711 { // DEDX information
712 RecMdcDedx* dedxTrk = ( *itTrk )->mdcDedx();
713 m_probPH[ii] = dedxTrk->probPH();
714 m_normPH[ii] = dedxTrk->normPH();
715
716 m_chie[ii] = dedxTrk->chiE();
717 m_chimu[ii] = dedxTrk->chiMu();
718 m_chipi[ii] = dedxTrk->chiPi();
719 m_chik[ii] = dedxTrk->chiK();
720 m_chip[ii] = dedxTrk->chiP();
721 m_ghit[ii] = dedxTrk->numGoodHits();
722 m_thit[ii] = dedxTrk->numTotalHits();
723 }
724
725 if ( ( *itTrk )->isEmcShowerValid() )
726 {
727 RecEmcShower* emcTrk = ( *itTrk )->emcShower();
728 m_e_emc[ii] = emcTrk->energy();
729 }
730
731 if ( ( *itTrk )->isTofTrackValid() )
732 { // TOF information
733 SmartRefVector<RecTofTrack> tofTrkCol = ( *itTrk )->tofTrack();
734
735 SmartRefVector<RecTofTrack>::iterator iter_tof = tofTrkCol.begin();
736
737 for ( ; iter_tof != tofTrkCol.end(); iter_tof++ )
738 {
739 TofHitStatus* status = new TofHitStatus;
740 status->setStatus( ( *iter_tof )->status() );
741
742 if ( !( status->is_barrel() ) )
743 { // endcap
744 if ( !( status->is_counter() ) ) continue; // ?
745 if ( status->layer() != 0 ) continue; // layer1
746 double path = ( *iter_tof )->path(); // ?
747 double tof = ( *iter_tof )->tof();
748 double ph = ( *iter_tof )->ph();
749 double rhit = ( *iter_tof )->zrhit();
750 double qual = 0.0 + ( *iter_tof )->quality();
751 double cntr = 0.0 + ( *iter_tof )->tofID();
752 double texp[5];
753 for ( int j = 0; j < 5; j++ )
754 {
755 double gb = ptrk / xmass[j];
756 double beta = gb / sqrt( 1 + gb * gb );
757 texp[j] = path / beta / velc;
758 }
759
760 m_qual_etof[ii] = qual;
761 m_tof_etof[ii] = tof;
762 }
763 else
764 { // barrel
765 if ( !( status->is_counter() ) ) continue; // ?
766 if ( status->layer() == 1 )
767 { // layer1
768 double path = ( *iter_tof )->path(); // ?
769 double tof = ( *iter_tof )->tof();
770 double ph = ( *iter_tof )->ph();
771 double rhit = ( *iter_tof )->zrhit();
772 double qual = 0.0 + ( *iter_tof )->quality();
773 double cntr = 0.0 + ( *iter_tof )->tofID();
774 double texp[5];
775 for ( int j = 0; j < 5; j++ )
776 {
777 double gb = ptrk / xmass[j];
778 double beta = gb / sqrt( 1 + gb * gb );
779 texp[j] = path / beta / velc;
780 }
781
782 m_qual_btof1[ii] = qual;
783 m_tof_btof1[ii] = tof;
784 }
785
786 if ( status->layer() == 2 )
787 { // layer2
788 double path = ( *iter_tof )->path(); // ?
789 double tof = ( *iter_tof )->tof();
790 double ph = ( *iter_tof )->ph();
791 double rhit = ( *iter_tof )->zrhit();
792 double qual = 0.0 + ( *iter_tof )->quality();
793 double cntr = 0.0 + ( *iter_tof )->tofID();
794 double texp[5];
795 for ( int j = 0; j < 5; j++ )
796 {
797 double gb = ptrk / xmass[j];
798 double beta = gb / sqrt( 1 + gb * gb );
799 texp[j] = path / beta / velc;
800 }
801
802 m_qual_btof2[ii] = qual;
803 m_tof_btof2[ii] = tof;
804 }
805 }
806 }
807 }
808 }
809
810 // Kinamatic Fit
811 KinematicFit* kmfit = KinematicFit::instance();
812
813 double ecms = 3.097;
814 double chisq = 9999.;
815 m_4c_chi2 = 9999.;
816 m_4c_mks = 10.0;
817 m_4c_mkspi = 10.0;
818 m_4c_mksk = 10.0;
819 m_4c_mkpi = 10.0;
820 m_4c_ks_px = 10.0;
821 m_4c_ks_py = 10.0;
822 m_4c_ks_pz = 10.0;
823 m_4c_ks_p = 10.0;
824 m_4c_ks_cos = 10.0;
825
826 kmfit->init();
827 kmfit->AddTrack( 0, wpi );
828 kmfit->AddTrack( 1, wk );
829 kmfit->AddTrack( 2, wks );
830 kmfit->AddFourMomentum( 0, p_cms );
831 bool oksq = kmfit->Fit();
832 if ( oksq )
833 {
834 chisq = kmfit->chisq();
835
836 HepLorentzVector pk = kmfit->pfit( 1 );
837 HepLorentzVector pks = kmfit->pfit( 2 );
838 HepLorentzVector pkspi = kmfit->pfit( 0 ) + kmfit->pfit( 2 );
839 HepLorentzVector pksk = kmfit->pfit( 1 ) + kmfit->pfit( 2 );
840 HepLorentzVector pkpi = kmfit->pfit( 0 ) + kmfit->pfit( 1 );
841
842 pks.boost( u_cms );
843 pkspi.boost( u_cms );
844 pksk.boost( u_cms );
845 pkpi.boost( u_cms );
846
847 m_4c_chi2 = chisq;
848 m_4c_mks = pks.m();
849 m_4c_mkspi = pkspi.m();
850 m_4c_mksk = pksk.m();
851 m_4c_mkpi = pkpi.m();
852
853 m_4c_ks_px = pks.px();
854 m_4c_ks_py = pks.py();
855 m_4c_ks_pz = pks.pz();
856 m_4c_ks_p = ( pks.vect() ).mag();
857 m_4c_ks_cos = m_4c_ks_pz / m_4c_ks_p;
858 }
859
860 chisq = 9999.;
861 m_chi2_fs4c = 9999.;
862 m_mks_fs4c = 10.0;
863 m_mkspi_fs4c = 10.0;
864 m_mksk_fs4c = 10.0;
865 m_mkpi_fs4c = 10.0;
866
867 kmfit->init();
868 kmfit->AddTrack( 0, wpip );
869 kmfit->AddTrack( 1, wpim );
870 kmfit->AddTrack( 2, wpi );
871 kmfit->AddTrack( 3, wk );
872 kmfit->AddFourMomentum( 0, p_cms );
873 oksq = kmfit->Fit();
874 if ( oksq )
875 {
876 chisq = kmfit->chisq();
877
878 HepLorentzVector pks = kmfit->pfit( 0 ) + kmfit->pfit( 1 );
879 HepLorentzVector pkspi = pks + kmfit->pfit( 2 );
880 HepLorentzVector pksk = pks + kmfit->pfit( 3 );
881 HepLorentzVector pkpi = kmfit->pfit( 2 ) + kmfit->pfit( 3 );
882
883 pks.boost( u_cms );
884 pkspi.boost( u_cms );
885 pksk.boost( u_cms );
886 pkpi.boost( u_cms );
887
888 m_chi2_fs4c = chisq;
889 m_mks_fs4c = pks.m();
890 m_mkspi_fs4c = pkspi.m();
891 m_mksk_fs4c = pksk.m();
892 m_mkpi_fs4c = pkpi.m();
893 }
894
895 // finale selection
896 if ( chisq > 20 ) { return StatusCode::SUCCESS; } // 4C chi2
897 if ( m_vfit2_dl < 0.5 ) { return StatusCode::SUCCESS; } // Ks decay length
898 if ( fabs( m_4c_mks - mks0 ) > 0.01 ) { return StatusCode::SUCCESS; } // Ks mass
899 if ( m_4c_mkspi < 1.25 ) { return StatusCode::SUCCESS; } // Kspi mass
900
901 // DQA
902 TH1* h( 0 );
903 if ( m_thsvc->getHist( "/DQAHist/DQAKsKpiDEDX/hks_dl", h ).isSuccess() )
904 { h->Fill( m_vfit2_dl ); }
905 else { log << MSG::ERROR << "Couldn't retrieve hks_dl" << endmsg; }
906
907 if ( m_thsvc->getHist( "/DQAHist/DQAKsKpiDEDX/hks_m", h ).isSuccess() )
908 { h->Fill( m_4c_mks ); }
909 else { log << MSG::ERROR << "Couldn't retrieve hks_m" << endmsg; }
910
911 if ( m_thsvc->getHist( "/DQAHist/DQAKsKpiDEDX/hkspi_m", h ).isSuccess() )
912 { h->Fill( m_4c_mkspi ); }
913 else { log << MSG::ERROR << "Couldn't retrieve hkspi_m" << endmsg; }
914
915 if ( m_thsvc->getHist( "/DQAHist/DQAKsKpiDEDX/hks_p", h ).isSuccess() )
916 { h->Fill( m_4c_ks_p ); }
917 else { log << MSG::ERROR << "Couldn't retrieve hks_p" << endmsg; }
918
919 if ( m_thsvc->getHist( "/DQAHist/DQAKsKpiDEDX/hkpi_m", h ).isSuccess() )
920 { h->Fill( m_4c_mkpi ); }
921 else { log << MSG::ERROR << "Couldn't retrieve hkpi_m" << endmsg; }
922
923 ////////////////////////////////////////////////////////////
924 // DQA
925 // set tag and quality
926
927 // Pid: 1 - electron, 2 - muon, 3 - pion, 4 - kaon, 5 - proton
928 if ( m_npip == 2 && m_npim == 1 )
929 {
930 ( *( evtRecTrkCol->begin() + ipip[0] ) )->setPartId( 2 );
931 ( *( evtRecTrkCol->begin() + ipip[1] ) )->setPartId( 2 );
932 ( *( evtRecTrkCol->begin() + ipim[0] ) )->setPartId( 2 );
933 ( *( evtRecTrkCol->begin() + ikm[0] ) )->setPartId( 4 );
934 }
935 if ( m_npip == 1 && m_npim == 2 )
936 {
937 ( *( evtRecTrkCol->begin() + ipip[0] ) )->setPartId( 2 );
938 ( *( evtRecTrkCol->begin() + ipim[0] ) )->setPartId( 2 );
939 ( *( evtRecTrkCol->begin() + ipim[1] ) )->setPartId( 2 );
940 ( *( evtRecTrkCol->begin() + ikp[0] ) )->setPartId( 4 );
941 }
942 // Quality: defined by whether dE/dx or TOF is used to identify particle
943 // 0 - no dE/dx, no TOF (can be used for dE/dx and TOF calibration)
944 // 1 - only dE/dx (can be used for TOF calibration)
945 // 2 - only TOF (can be used for dE/dx calibration)
946 // 3 - Both dE/dx and TOF
947 if ( m_npip == 2 && m_npim == 1 )
948 {
949 ( *( evtRecTrkCol->begin() + ipip[0] ) )->setQuality( 2 );
950 ( *( evtRecTrkCol->begin() + ipip[1] ) )->setQuality( 2 );
951 ( *( evtRecTrkCol->begin() + ipim[0] ) )->setQuality( 2 );
952 ( *( evtRecTrkCol->begin() + ikm[0] ) )->setQuality( 2 );
953 }
954 if ( m_npip == 1 && m_npim == 2 )
955 {
956 ( *( evtRecTrkCol->begin() + ipip[0] ) )->setQuality( 2 );
957 ( *( evtRecTrkCol->begin() + ipim[0] ) )->setQuality( 2 );
958 ( *( evtRecTrkCol->begin() + ipim[1] ) )->setQuality( 2 );
959 ( *( evtRecTrkCol->begin() + ikp[0] ) )->setQuality( 2 );
960 }
961 // DQA
962 // Add the line below at the end of execute(), (before return)
963 //
964 setFilterPassed( true );
965 ////////////////////////////////////////////////////////////
966
967 m_tuple->write().ignore();
968
969 return StatusCode::SUCCESS;
970}
HepGeom::Point3D< double > HepPoint3D
const Hep3Vector u_cms
const double mks0
const HepLorentzVector p_cms(0.034067, 0.0, 0.0, 3.097)
EvtRecTrackCol::iterator EvtRecTrackIterator
std::vector< HepLorentzVector > Vp4
Definition Gam4pikp.cxx:38
const double xmass[5]
Definition Gam4pikp.cxx:35
const double velc
Definition Gam4pikp.cxx:36
std::vector< int > Vint
Definition Gam4pikp.cxx:37
IMessageSvc * msgSvc()
const HepSymMatrix err() const
const HepVector helix() const
......
virtual bool isVertexValid()=0
virtual double * SigmaPrimaryVertex()=0
virtual double * PrimaryVertex()=0
static KinematicFit * instance()
void AddFourMomentum(int number, HepLorentzVector p4)
double chiTof2(int n) const
static ParticleID * instance()
bool IsPidInfoValid() const
double chiTof1(int n) const
void calculate()
void init()
double chiDedx(int n) const
void setPrimaryVertex(const VertexParameter vpar)
static SecondVertexFit * instance()
void setStatus(unsigned int status)
void AddTrack(const int number, const double mass, const RecMdcTrack *trk)
Definition TrackPool.cxx:21
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()
const double ecms
Definition inclkstar.cxx:26

◆ finalize()

StatusCode DQAKsKpiDEDX::finalize ( )

Definition at line 973 of file DQAKsKpiDEDX.cxx.

973 {
974
975 MsgStream log( msgSvc(), name() );
976 log << MSG::INFO << "in finalize()" << endmsg;
977 return StatusCode::SUCCESS;
978}

◆ initialize()

StatusCode DQAKsKpiDEDX::initialize ( )

Definition at line 71 of file DQAKsKpiDEDX.cxx.

71 {
72 MsgStream log( msgSvc(), name() );
73
74 log << MSG::INFO << "in initialize()" << endmsg;
75 StatusCode status;
76
77 if ( service( "THistSvc", m_thsvc ).isFailure() )
78 {
79 log << MSG::ERROR << "Couldn't get THistSvc" << endmsg;
80 return StatusCode::FAILURE;
81 }
82
83 // "DQAHist" is fixed
84 // "DQAKsKpi" is control sample name, just as ntuple case.
85 TH1F* hks_dl = new TH1F( "ks_dl", "ks_dl", 300, -5.0, 25.0 );
86 if ( m_thsvc->regHist( "/DQAHist/DQAKsKpiDEDX/hks_dl", hks_dl ).isFailure() )
87 { log << MSG::ERROR << "Couldn't register ks_dl" << endmsg; }
88
89 TH1F* hks_m = new TH1F( "ks_m", "ks_m", 200, 0.4, 0.6 );
90 if ( m_thsvc->regHist( "/DQAHist/DQAKsKpiDEDX/hks_m", hks_m ).isFailure() )
91 { log << MSG::ERROR << "Couldn't register ks_m" << endmsg; }
92
93 TH1F* hkspi_m = new TH1F( "kspi_m", "kspi_m", 200, 0.6, 2.6 );
94 if ( m_thsvc->regHist( "/DQAHist/DQAKsKpiDEDX/hkspi_m", hkspi_m ).isFailure() )
95 { log << MSG::ERROR << "Couldn't register kspi_m" << endmsg; }
96
97 TH1F* hks_p = new TH1F( "ks_p", "ks_p", 100, 0.0, 1.5 );
98 if ( m_thsvc->regHist( "/DQAHist/DQAKsKpiDEDX/hks_p", hks_p ).isFailure() )
99 { log << MSG::ERROR << "Couldn't register ks_p" << endmsg; }
100
101 TH1F* hkpi_m = new TH1F( "kpi_m", "kpi_m", 200, 0.6, 2.6 );
102 if ( m_thsvc->regHist( "/DQAHist/DQAKsKpiDEDX/hkpi_m", hkpi_m ).isFailure() )
103 { log << MSG::ERROR << "Couldn't register kpi_m" << endmsg; }
104
105 // DQA
106 // The first directory specifier must be "DQAFILE"
107 // The second is the control sample name, the first letter is in upper format. eg. "Rhopi"
108 NTuplePtr nt( ntupleSvc(), "DQAFILE/KsKpiDEDX" );
109 if ( nt ) m_tuple = nt;
110 else
111 {
112 m_tuple =
113 ntupleSvc()->book( "DQAFILE/KsKpiDEDX", CLID_ColumnWiseTuple, "KsKpiDEDX ntuple" );
114 if ( m_tuple )
115 {
116 status = m_tuple->addItem( "runNo", m_runNo );
117 status = m_tuple->addItem( "event", m_event );
118 // status = m_tuple->addItem("Nchrg", m_nchrg);
119 // status = m_tuple->addItem("Nneu", m_nneu);
120
121 status = m_tuple->addItem( "npip", m_npip );
122 status = m_tuple->addItem( "npim", m_npim );
123 status = m_tuple->addItem( "nkp", m_nkp );
124 status = m_tuple->addItem( "nkm", m_nkm );
125 status = m_tuple->addItem( "np", m_np );
126 status = m_tuple->addItem( "npb", m_npb );
127
128 status = m_tuple->addItem( "vfits_chi", m_vfits_chi );
129 status = m_tuple->addItem( "vfits_vx", m_vfits_vx );
130 status = m_tuple->addItem( "vfits_vy", m_vfits_vy );
131 status = m_tuple->addItem( "vfits_vz", m_vfits_vz );
132 status = m_tuple->addItem( "vfits_vr", m_vfits_vr );
133
134 status = m_tuple->addItem( "vfitp_chi", m_vfitp_chi );
135 status = m_tuple->addItem( "vfitp_vx", m_vfitp_vx );
136 status = m_tuple->addItem( "vfitp_vy", m_vfitp_vy );
137 status = m_tuple->addItem( "vfitp_vz", m_vfitp_vz );
138 status = m_tuple->addItem( "vfitp_vr", m_vfitp_vr );
139
140 status = m_tuple->addItem( "vfit2_chi", m_vfit2_chi );
141 status = m_tuple->addItem( "vfit2_mks", m_vfit2_mks );
142 status = m_tuple->addItem( "vfit2_ct", m_vfit2_ct );
143 status = m_tuple->addItem( "vfit2_dl", m_vfit2_dl );
144 status = m_tuple->addItem( "vfit2_dle", m_vfit2_dle );
145
146 status = m_tuple->addItem( "chi2_fs4c", m_chi2_fs4c );
147 status = m_tuple->addItem( "mks_fs4c", m_mks_fs4c );
148 status = m_tuple->addItem( "mkspi_fs4c", m_mkspi_fs4c );
149 status = m_tuple->addItem( "mksk_fs4c", m_mksk_fs4c );
150 status = m_tuple->addItem( "mkpi_fs4c", m_mkpi_fs4c );
151
152 status = m_tuple->addItem( "4c_chi2", m_4c_chi2 );
153 status = m_tuple->addItem( "4c_mks", m_4c_mks );
154 status = m_tuple->addItem( "4c_mkspi", m_4c_mkspi );
155 status = m_tuple->addItem( "4c_mksk", m_4c_mksk );
156 status = m_tuple->addItem( "4c_mkpi", m_4c_mkpi );
157 status = m_tuple->addItem( "4c_ks_px", m_4c_ks_px );
158 status = m_tuple->addItem( "4c_ks_py", m_4c_ks_py );
159 status = m_tuple->addItem( "4c_ks_pz", m_4c_ks_pz );
160 status = m_tuple->addItem( "4c_ks_p", m_4c_ks_p );
161 status = m_tuple->addItem( "4c_ks_cos", m_4c_ks_cos );
162
163 status = m_tuple->addItem( "NGch", m_ngch, 0, 10 );
164 status = m_tuple->addIndexedItem( "pidcode", m_ngch, m_pidcode );
165 status = m_tuple->addIndexedItem( "pidprob", m_ngch, m_pidprob );
166 status = m_tuple->addIndexedItem( "pidchiDedx", m_ngch, m_pidchiDedx );
167 status = m_tuple->addIndexedItem( "pidchiTof1", m_ngch, m_pidchiTof1 );
168 status = m_tuple->addIndexedItem( "pidchiTof2", m_ngch, m_pidchiTof2 );
169
170 status = m_tuple->addIndexedItem( "charge", m_ngch, m_charge );
171 status = m_tuple->addIndexedItem( "vx0", m_ngch, m_vx0 );
172 status = m_tuple->addIndexedItem( "vy0", m_ngch, m_vy0 );
173 status = m_tuple->addIndexedItem( "vz0", m_ngch, m_vz0 );
174 status = m_tuple->addIndexedItem( "vr0", m_ngch, m_vr0 );
175
176 status = m_tuple->addIndexedItem( "vx", m_ngch, m_vx );
177 status = m_tuple->addIndexedItem( "vy", m_ngch, m_vy );
178 status = m_tuple->addIndexedItem( "vz", m_ngch, m_vz );
179 status = m_tuple->addIndexedItem( "vr", m_ngch, m_vr );
180
181 status = m_tuple->addIndexedItem( "px", m_ngch, m_px );
182 status = m_tuple->addIndexedItem( "py", m_ngch, m_py );
183 status = m_tuple->addIndexedItem( "pz", m_ngch, m_pz );
184 status = m_tuple->addIndexedItem( "p", m_ngch, m_p );
185 status = m_tuple->addIndexedItem( "cost", m_ngch, m_cost );
186
187 status = m_tuple->addIndexedItem( "probPH", m_ngch, m_probPH );
188 status = m_tuple->addIndexedItem( "normPH", m_ngch, m_normPH );
189 status = m_tuple->addIndexedItem( "chie", m_ngch, m_chie );
190 status = m_tuple->addIndexedItem( "chimu", m_ngch, m_chimu );
191 status = m_tuple->addIndexedItem( "chipi", m_ngch, m_chipi );
192 status = m_tuple->addIndexedItem( "chik", m_ngch, m_chik );
193 status = m_tuple->addIndexedItem( "chip", m_ngch, m_chip );
194 status = m_tuple->addIndexedItem( "ghit", m_ngch, m_ghit );
195 status = m_tuple->addIndexedItem( "thit", m_ngch, m_thit );
196
197 status = m_tuple->addIndexedItem( "e_emc", m_ngch, m_e_emc );
198
199 status = m_tuple->addIndexedItem( "qual_etof", m_ngch, m_qual_etof );
200 status = m_tuple->addIndexedItem( "tof_etof", m_ngch, m_tof_etof );
201 status = m_tuple->addIndexedItem( "te_etof", m_ngch, m_te_etof );
202 status = m_tuple->addIndexedItem( "tmu_etof", m_ngch, m_tmu_etof );
203 status = m_tuple->addIndexedItem( "tpi_etof", m_ngch, m_tpi_etof );
204 status = m_tuple->addIndexedItem( "tk_etof", m_ngch, m_tk_etof );
205 status = m_tuple->addIndexedItem( "tp_etof", m_ngch, m_tp_etof );
206
207 status = m_tuple->addIndexedItem( "qual_btof1", m_ngch, m_qual_btof1 );
208 status = m_tuple->addIndexedItem( "tof_btof1", m_ngch, m_tof_btof1 );
209 status = m_tuple->addIndexedItem( "te_btof1", m_ngch, m_te_btof1 );
210 status = m_tuple->addIndexedItem( "tmu_btof1", m_ngch, m_tmu_btof1 );
211 status = m_tuple->addIndexedItem( "tpi_btof1", m_ngch, m_tpi_btof1 );
212 status = m_tuple->addIndexedItem( "tk_btof1", m_ngch, m_tk_btof1 );
213 status = m_tuple->addIndexedItem( "tp_btof1", m_ngch, m_tp_btof1 );
214
215 status = m_tuple->addIndexedItem( "qual_btof2", m_ngch, m_qual_btof2 );
216 status = m_tuple->addIndexedItem( "tof_btof2", m_ngch, m_tof_btof2 );
217 status = m_tuple->addIndexedItem( "te_btof2", m_ngch, m_te_btof2 );
218 status = m_tuple->addIndexedItem( "tmu_btof2", m_ngch, m_tmu_btof2 );
219 status = m_tuple->addIndexedItem( "tpi_btof2", m_ngch, m_tpi_btof2 );
220 status = m_tuple->addIndexedItem( "tk_btof2", m_ngch, m_tk_btof2 );
221 status = m_tuple->addIndexedItem( "tp_btof2", m_ngch, m_tp_btof2 );
222 }
223 else { log << MSG::ERROR << "Can not book N-tuple:" << long( m_tuple ) << endmsg; }
224 }
225
226 //--------end of book--------
227
228 log << MSG::INFO << "successfully return from initialize()" << endmsg;
229 return StatusCode::SUCCESS;
230}
INTupleSvc * ntupleSvc()

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