BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
LocalKaonSelector.cxx
Go to the documentation of this file.
1#include "GaudiKernel/Bootstrap.h"
2#include "GaudiKernel/ISvcLocator.h"
3
4#include "EvtRecEvent/EvtRecTrack.h"
5#include "LocalKaonSelector.h"
6#include "ParticleID/ParticleID.h"
7
8#include "VertexDbSvc/IVertexDbSvc.h"
9#include "VertexFit/Helix.h"
10
11#include "SimplePIDSvc/ISimplePIDSvc.h"
12
14
15LocalKaonSelector::LocalKaonSelector( const std::string& type, const std::string& name,
16 const IInterface* parent )
17 : base_class( type, name, parent ) {
18 m_pidtype = 0;
19
20 // Declare the properties
21 declareProperty( "RxyCut", m_VrCut = 1.0 );
22 declareProperty( "Vz0Cut", m_VzCut = 10.0 );
23 declareProperty( "CosThetaCut", m_CosThetaCut = 0.93 );
24
25 declareProperty( "PID", m_PID = true );
26 declareProperty( "useSimplePID", m_useSimplePID = true );
27
28 declareProperty( "PidUseDedx", m_useDedx = true );
29 declareProperty( "PidUseTof1", m_useTof1 = true );
30 declareProperty( "PidUseTof2", m_useTof2 = true );
31 declareProperty( "PidUseTofE", m_useTofE = false );
32 declareProperty( "PidUseTofQ", m_useTofQ = false );
33 declareProperty( "PidUseEmc", m_useEmc = false );
34 declareProperty( "PidUseMuc", m_useMuc = false );
35
36 declareProperty( "PidwithProbability", m_probability = true );
37 declareProperty( "PidProbCut", m_PidProbCut = 0.001 );
38 declareProperty( "RejectPion", m_rejectPion = true );
39 declareProperty( "RejectProton", m_rejectProton = false );
40
41 declareProperty( "PidwithLikelihood", m_likelihood = false );
42 declareProperty( "PidwithNeuronNetwork", m_neuronNetwork = false );
43 declareProperty( "NeuronValue", m_neuronValCut = { 1.5, 2.5 } );
44}
45
47
48 aKaon.setUserTag( 1 );
49 EvtRecTrack* recTrk = const_cast<EvtRecTrack*>( aKaon.track() );
50
51 // MDC track selection
52
54 if ( !recTrk->isMdcKalTrackValid() ) return false;
55 RecMdcKalTrack* mdcKalTrk = recTrk->mdcKalTrack();
56 if ( mdcKalTrk->charge() == 0 ) return false;
57
58 Hep3Vector xorigin( 0, 0, 0 );
59 IVertexDbSvc* vtxsvc;
60 StatusCode sc = serviceLocator()->service( "VertexDbSvc", vtxsvc );
61 if ( vtxsvc->isVertexValid() )
62 {
63 double* dbv = vtxsvc->PrimaryVertex();
64 double* vv = vtxsvc->SigmaPrimaryVertex();
65 xorigin.setX( dbv[0] );
66 xorigin.setY( dbv[1] );
67 xorigin.setZ( dbv[2] );
68 }
69 HepVector a = mdcKalTrk->getZHelixK();
70 HepSymMatrix Ea = mdcKalTrk->getZErrorK();
71 HepPoint3D point0( 0., 0., 0. );
72 HepPoint3D IP( xorigin[0], xorigin[1], xorigin[2] );
73 VFHelix helixip3( point0, a, Ea );
74 helixip3.pivot( IP );
75 HepVector vecipa = helixip3.a();
76
77 double dr = fabs( vecipa[0] );
78 double dz = fabs( vecipa[3] );
79 double costheta = cos( mdcKalTrk->theta() );
80 if ( dr >= m_VrCut ) return false;
81 if ( dz >= m_VzCut ) return false;
82 if ( fabs( costheta ) >= m_CosThetaCut ) return false;
83
84 if ( !m_PID ) return true;
85
86 // Simple PID
87 if ( m_useSimplePID )
88 {
89 ISimplePIDSvc* m_simplePIDSvc;
90 StatusCode sc = serviceLocator()->service( "SimplePIDSvc", m_simplePIDSvc );
91
92 m_simplePIDSvc->preparePID( recTrk );
93 if ( !m_simplePIDSvc->iskaon() ) { aKaon.setUserTag( 2 ); }
94 }
95 else
96 {
97 // particleID pacakge
99 pid->init();
100 pid->setMethod( pid->methodProbability() );
101 pid->setChiMinCut( 4 );
102 pid->setRecTrack( recTrk );
103 pid->usePidSys( pid->useDedx() | pid->useTofCorr() );
104 pid->identify( pid->onlyPion() | pid->onlyKaon() );
105 pid->calculate();
106
107 if ( !( pid->probKaon() > 0 && pid->probKaon() > pid->probPion() ) ) aKaon.setUserTag( 2 );
108 }
109
110 if ( m_pidtype == 0 ) return true;
111
112 if ( aKaon.userTag() == 1 ) return true;
113 else return false;
114}
115
116// LocalKaonSelector kaonSelector;
DECLARE_COMPONENT(BesBdkRc)
HepGeom::Point3D< double > HepPoint3D
CDChargedVisible< DBCandidate::kChargedKaon > CDChargedKaon
void setUserTag(int tag)
int userTag() const
virtual void preparePID(EvtRecTrack *track)=0
virtual bool iskaon()=0
virtual bool isVertexValid()=0
virtual double * SigmaPrimaryVertex()=0
virtual double * PrimaryVertex()=0
LocalKaonSelector(const std::string &type, const std::string &name, const IInterface *parent)
bool operator()(CDChargedKaon &aKaon) override
static ParticleID * instance()
void calculate()
void init()
const HepPoint3D & pivot(void) const
returns pivot position.
const HepVector & a(void) const
returns helix parameters.