1#include "GaudiKernel/MsgStream.h"
2#include "GaudiKernel/AlgFactory.h"
3#include "GaudiKernel/ISvcLocator.h"
4#include "GaudiKernel/SmartDataPtr.h"
5#include "GaudiKernel/IDataProviderSvc.h"
6#include "GaudiKernel/PropertyMgr.h"
8#include "EventModel/EventModel.h"
9#include "EventModel/Event.h"
10#include "EventModel/EventHeader.h"
12#include "EvtRecEvent/EvtRecEvent.h"
13#include "EvtRecEvent/EvtRecTrack.h"
14#include "EvtRecEvent/EvtRecDTag.h"
15#include "EvtRecEvent/EvtRecVeeVertex.h"
16#include "EvtRecEvent/EvtRecPi0.h"
17#include "DstEvent/TofHitStatus.h"
20#include "GaudiKernel/INTupleSvc.h"
21#include "GaudiKernel/NTuple.h"
22#include "GaudiKernel/Bootstrap.h"
23#include "GaudiKernel/IHistogramSvc.h"
24#include "CLHEP/Vector/ThreeVector.h"
25#include "CLHEP/Vector/LorentzVector.h"
26#include "CLHEP/Vector/TwoVector.h"
27#include "CLHEP/Geometry/Point3D.h"
29using CLHEP::Hep3Vector;
30using CLHEP::Hep2Vector;
31using CLHEP::HepLorentzVector;
32#ifndef ENABLE_BACKWARDS_COMPATIBILITY
37#include "DSemilepAlg/DSemilepAlg.h"
39#include "VertexFit/KinematicFit.h"
40#include "VertexFit/Helix.h"
41#include "VertexFit/VertexFit.h"
42#include "McTruth/McParticle.h"
47typedef std::vector<int>
Vint;
48typedef std::vector<HepLorentzVector>
Vp4;
51const double me = 0.000511;
64 MsgStream log(
msgSvc(), name());
65 log << MSG::INFO <<
"in initialize()" << endmsg;
69 NTuplePtr nt0(
ntupleSvc(),
"FILE1/dsemilep");
70 if ( nt0 ) m_tuple0 = nt0;
72 m_tuple0 =
ntupleSvc()->book (
"FILE1/dsemilep", CLID_ColumnWiseTuple,
"track N-Tuple example");
74 status = m_tuple0->addItem (
"U", m_U);
75 status = m_tuple0->addItem (
"MM2", m_MM2);
76 status = m_tuple0->addItem (
"mBC", m_mBC);
77 status = m_tuple0->addItem (
"q2", m_q2);
78 status = m_tuple0->addItem (
"deltaE", m_deltaE);
79 status = m_tuple0->addItem (
"mode", m_mode);
82 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple0) << endmsg;
83 return StatusCode::FAILURE;
87 StatusCode sc = service(
"SimplePIDSvc", m_simplePIDSvc);
88 if ( sc.isFailure()) {
89 log << MSG::FATAL <<
"Could not load SimplePIDSvc!" << endreq;
93 log << MSG::INFO <<
"successfully return from initialize()" <<endmsg;
94 return StatusCode::SUCCESS;
102 MsgStream log(
msgSvc(), name());
103 log << MSG::INFO <<
"in execute()" << endreq;
105 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
106 int runNo=eventHeader->runNumber();
107 int eventNo=eventHeader->eventNumber();
113 SmartDataPtr<EvtRecEvent> evtRecEvent(eventSvc(),
"/Event/EvtRec/EvtRecEvent");
114 if ( ! evtRecEvent ) {
115 log << MSG::FATAL <<
"Could not find EvtRecEvent" << endreq;
116 return StatusCode::FAILURE;
119 SmartDataPtr<EvtRecTrackCol> evtRecTrackCol( eventSvc(),
"/Event/EvtRec/EvtRecTrackCol");
120 if ( ! evtRecTrackCol ) {
121 log << MSG::FATAL <<
"Could not find EvtRecTrackCol" << endreq;
122 return StatusCode::FAILURE;
126 SmartDataPtr<EvtRecVeeVertexCol> evtRecVeeVertexCol(eventSvc(),
"/Event/EvtRec/EvtRecVeeVertexCol");
127 if ( ! evtRecVeeVertexCol ) {
128 log << MSG::FATAL <<
"Could not find EvtRecVeeVertexCol" << endreq;
129 return StatusCode::FAILURE;
133 SmartDataPtr<EvtRecPi0Col> recPi0Col(eventSvc(),
"/Event/EvtRec/EvtRecPi0Col");
135 log << MSG::FATAL <<
"Could not find EvtRecPi0Col" << endreq;
136 return StatusCode::FAILURE;
141 Hep3Vector xorigin(0,0,0);
143 Gaudi::svcLocator()->service(
"VertexDbSvc", vtxsvc);
147 xorigin.setX(vertex[0]);
148 xorigin.setY(vertex[1]);
149 xorigin.setZ(vertex[2]);
158 return StatusCode::SUCCESS;
168 vector<DTagToolIterator> vsditer;
173 vsditer.push_back(dtagTool.
stag());
175 vsditer.push_back(dtagTool.
stag());
177 vsditer.push_back(dtagTool.
stag());
179 vsditer.push_back(dtagTool.
stag());
181 vsditer.push_back(dtagTool.
stag());
183 vsditer.push_back(dtagTool.
stag());
186 typedef vector<DTagToolIterator>::size_type vec_sz;
189 for(vec_sz i = 0 ; i < vsditer.size() ; i++){
192 m_deltaE = (*vsditer[i])->deltaE();
193 m_mode = (*vsditer[i])->decayMode();
194 m_mBC = (*vsditer[i])->mBC();
200 SmartRefVector<EvtRecTrack> othertracks = (*sditer)->otherTracks();
201 vector<int> iGood;
int tcharge=0;
203 for(
int i = 0 ; i < othertracks.size() ; i++){
207 tcharge += mdcKalTrk->
charge();
212 if(iGood.size() != 2 || tcharge != 0)
216 m_simplePIDSvc->
preparePID(othertracks[iGood[0]]);
217 bool FtrkElectron = m_simplePIDSvc->
iselectron();
218 bool FtrkKaon = m_simplePIDSvc->
iskaon();
220 m_simplePIDSvc->
preparePID(othertracks[iGood[1]]);
221 bool StrkElectron = m_simplePIDSvc->
iselectron();
222 bool StrkKaon = m_simplePIDSvc->
iskaon();
228 if(FtrkElectron && StrkKaon) {
233 SmartRefVector<EvtRecTrack> tracks = (*sditer)->tracks();
243 calU(sditer,strk,ftrk,U_1,MM2_1,q2_1);
256 if(StrkElectron && FtrkKaon){
261 SmartRefVector<EvtRecTrack> tracks = (*sditer)->tracks();
273 calU(sditer,strk,ftrk,U_1,MM2_1,q2_1);
293 MsgStream log(
msgSvc(), name());
294 log << MSG::INFO <<
"in finalize()" << endmsg;
296 return StatusCode::SUCCESS;
311 HepSymMatrix Ea = mdcKalTrk->
getZError();
313 HepPoint3D IP(xorigin[0],xorigin[1],xorigin[2]);
316 HepVector
vec = helixp.
a();
319 double costheta =
cos(mdcKalTrk->
theta());
322 if(fabs(vrl) < 1 && fabs(vzl) < 10 && fabs(costheta) < 0.93)
331 SmartRefVector<EvtRecTrack> tracks=(*iter_dtag)->tracks();
332 SmartRefVector<EvtRecTrack> showers=(*iter_dtag)->showers();
334 HepLorentzVector p4=(*iter_dtag)->p4();
335 p4.boost(-0.011,0,0);
336 Hep3Vector p3=p4.v();
347 Hep3Vector P3_tag =
tagDP3(sditer);
349 Hep3Vector P3_E(Etrack->
px(), Etrack->
py(),Etrack->
pz());
350 Hep3Vector P3_K(Ktrack->
px(), Ktrack->
py(),Ktrack->
pz());
352 HepLorentzVector P4_E(P3_E, sqrt( P3_E.mag2() +
me *
me));
353 HepLorentzVector P4_K(P3_K, sqrt( P3_K.mag2() +
mkaon *
mkaon));
356 P4_E.boost(-0.011,0,0);
357 P4_K.boost(-0.011,0,0);
359 double e_miss = (*sditer)->beamE() - P4_E.e() - P4_K.e();
360 Hep3Vector P3_miss = -P3_tag - P4_E.vect() - P4_K.vect();
362 U = e_miss - P3_miss.mag();
363 MM2 = U * (e_miss + P3_miss.mag());
365 HepLorentzVector P4_W(P3_E+P3_miss*fabs(e_miss/P3_miss.mag()),e_miss+P4_E.e());
HepGeom::Point3D< double > HepPoint3D
std::vector< HepLorentzVector > Vp4
double cos(const BesAngle a)
bool isGoodTrack(EvtRecTrack *trk, Hep3Vector xorigin)
Hep3Vector tagDP3(DTagToolIterator iter_dtag)
DSemilepAlg(const std::string &name, ISvcLocator *pSvcLocator)
void calU(DTagToolIterator sditer, RecMdcKalTrack *Etrack, RecMdcKalTrack *Ktrack, double &U, double &MM2, double &q2)
const double theta() const
static void setPidType(PidType pidType)
bool isMdcKalTrackValid()
RecMdcKalTrack * mdcKalTrack()
virtual void preparePID(EvtRecTrack *track)=0
virtual bool iselectron(bool emc=false)=0
virtual bool isVertexValid()=0
virtual double * PrimaryVertex()=0
const HepVector & getZHelix() const
const HepSymMatrix & getZError() const
const HepPoint3D & pivot(void) const
returns pivot position.
const HepVector & a(void) const
returns helix parameters.