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
36#include "DTagTool/DTagTool.h"
37#include "DDecayAlg/DDecay.h"
39#include "VertexFit/KinematicFit.h"
40#include "VertexFit/VertexFit.h"
41#include "ParticleID/ParticleID.h"
44typedef std::vector<int>
Vint;
45typedef std::vector<HepLorentzVector>
Vp4;
51 Algorithm(name, pSvcLocator){
57 MsgStream log(
msgSvc(), name());
59 log << MSG::INFO <<
"in initialize()" << endmsg;
63 if ( nt1 ) m_tuple1 = nt1;
65 m_tuple1 =
ntupleSvc()->book (
"FILE1/vxyz", CLID_ColumnWiseTuple,
"track N-Tuple example");
67 status = m_tuple1->addItem (
"vx0", m_vx0);
68 status = m_tuple1->addItem (
"vy0", m_vy0);
69 status = m_tuple1->addItem (
"vz0", m_vz0);
70 status = m_tuple1->addItem (
"vr0", m_vr0);
73 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple1) << endmsg;
74 return StatusCode::FAILURE;
79 if ( nt2 ) m_tuple2 = nt2;
81 m_tuple2 =
ntupleSvc()->book (
"FILE1/ks", CLID_ColumnWiseTuple,
"ks N-Tuple example");
83 status = m_tuple2->addItem (
"ksmass", m_ksmass);
84 status = m_tuple2->addItem (
"ksd", m_ksd);
85 status = m_tuple2->addItem (
"ksmode", m_ksmode);
88 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple2) << endmsg;
89 return StatusCode::FAILURE;
94 if ( nt3 ) m_tuple3 = nt3;
96 m_tuple3 =
ntupleSvc()->book (
"FILE1/pi0", CLID_ColumnWiseTuple,
"pi0 N-Tuple example");
98 status = m_tuple3->addItem (
"pi0mass", m_pi0mass);
99 status = m_tuple3->addItem (
"pi0mode", m_pi0mode);
102 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple3) << endmsg;
103 return StatusCode::FAILURE;
107 NTuplePtr nt4(
ntupleSvc(),
"FILE1/tagD");
108 if ( nt4 ) m_tuple4 = nt4;
110 m_tuple4 =
ntupleSvc()->book (
"FILE1/tagD", CLID_ColumnWiseTuple,
"DTag N-Tuple example");
112 status = m_tuple4->addItem (
"mode", m_mode);
113 status = m_tuple4->addItem (
"type", m_type);
114 status = m_tuple4->addItem (
"charge", m_charge);
115 status = m_tuple4->addItem (
"charm", m_charm);
116 status = m_tuple4->addItem (
"numofchildren", m_numofchildren);
117 status = m_tuple4->addItem (
"mass", m_mass);
118 status = m_tuple4->addItem (
"mBC", m_mBC);
119 status = m_tuple4->addItem (
"deltaE", m_deltae);
120 status = m_tuple4->addItem (
"E", m_e);
121 status = m_tuple4->addItem (
"notherTrk", m_ntrk);
124 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple4) << endmsg;
125 return StatusCode::FAILURE;
134 log << MSG::INFO <<
"successfully return from initialize()" <<endmsg;
135 return StatusCode::SUCCESS;
142 MsgStream log(
msgSvc(), name());
143 log << MSG::INFO <<
"in execute()" << endreq;
145 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
146 int runNo=eventHeader->runNumber();
147 int eventNo=eventHeader->eventNumber();
154 SmartDataPtr<EvtRecVeeVertexCol> evtRecVeeVertexCol(eventSvc(),
"/Event/EvtRec/EvtRecVeeVertexCol");
155 if ( ! evtRecVeeVertexCol ) {
156 log << MSG::FATAL <<
"Could not find EvtRecVeeVertexCol" << endreq;
157 return StatusCode::FAILURE;
161 SmartDataPtr<EvtRecPi0Col> recPi0Col(eventSvc(),
"/Event/EvtRec/EvtRecPi0Col");
163 log << MSG::FATAL <<
"Could not find EvtRecPi0Col" << endreq;
164 return StatusCode::FAILURE;
169 Hep3Vector xorigin(0,0,0);
171 Gaudi::svcLocator()->service(
"VertexDbSvc", vtxsvc);
176 xorigin.setX(vertex[0]);
177 xorigin.setY(vertex[1]);
178 xorigin.setZ(vertex[2]);
189 return StatusCode::SUCCESS;
195 cout<<
"size of dtag:******:"<<iter_end-iter_begin<<endl;
205 cout<<
" there are "<< mode.size() <<
" candidates for this mode" <<endl;
206 for(
int i=0; i < mode.size(); i++){
209 cout<<
"No."<<i+1<<
" candidate deltaE is : "<< (*iter)->deltaE()<<endl;
216 for (
DTagToolIterator iter_dtag=iter_begin; iter_dtag != iter_end; iter_dtag++){
219 cout<<
"***********"<<endl;
220 cout<<
"***********"<<endl;
221 dtagTool<< iter_dtag;
230 HepLorentzVector p4=(*iter_dtag)->
p4();
231 p4.boost(-0.011,0,0);
233 Hep3Vector p3=p4.v();
235 m_mode=(*iter_dtag)->decayMode();
236 m_type=(*iter_dtag)->type();
237 m_charge=(*iter_dtag)->charge();
238 m_charm=(*iter_dtag)->charm();
239 m_numofchildren=(*iter_dtag)->numOfChildren();
240 m_mass=(*iter_dtag)->mass();
241 m_mBC=(*iter_dtag)->mBC();
242 m_e=(*iter_dtag)->beamE();
243 m_deltae=(*iter_dtag)->deltaE();
245 SmartRefVector<EvtRecTrack> tracks=(*iter_dtag)->tracks();
246 SmartRefVector<EvtRecTrack> othertracks=(*iter_dtag)->otherTracks();
247 SmartRefVector<EvtRecTrack> othershowers=(*iter_dtag)->otherShowers();
248 m_ntrk=othertracks.size();
255 cout<<
"same side track 1 charge is:"<<mdcKalTrk1->
charge()<<endl;
256 cout<<
"same side track 2 charge is:"<<mdcKalTrk2->
charge()<<endl;
258 for(
int tk=0; tk<othertracks.size(); tk++){
260 double pch=mdcTrk->
p();
261 double x0=mdcTrk->
x();
262 double y0=mdcTrk->
y();
263 double z0=mdcTrk->
z();
264 double phi0=mdcTrk->
helix(1);
265 double xp=xorigin.x();
266 double yp=xorigin.y();
267 double Rxy=(x0-xp)*
cos(phi0)+(y0-yp)*
sin(phi0);
274 nCharge += mdcTrk->
charge();
276 std::cout<<
"other side track ID is: "<<othertracks[tk]->trackId()<<std::endl;
278 if(dtagTool.
isPion(othertracks[tk]) )
279 cout<<
"it is pion"<<endl;
280 if(dtagTool.
isKaon(othertracks[tk]) )
281 cout<<
"it is kaon"<<endl;
287 for(
int i=0; i<othershowers.size(); i++){
301 m_mode=(*iter_dtag)->decayMode();
302 m_type=(*iter_dtag)->type();
303 m_charge=(*iter_dtag)->charge();
304 m_charm=(*iter_dtag)->charm();
305 m_numofchildren=(*iter_dtag)->numOfChildren();
306 m_mass=(*iter_dtag)->mass();
307 m_mBC=(*iter_dtag)->mBC();
308 m_e=(*iter_dtag)->beamE();
309 m_deltae=(*iter_dtag)->deltaE();
311 SmartRefVector<EvtRecTrack> othertracks=(*iter_dtag)->otherTracks();
312 m_ntrk=othertracks.size();
320 vector<int> pi0id= dtagTool.
pi0Id(iter_dtag);
321 cout<<
"xxxxxxxxxxxxxxxxxxxxxxxxx"<<
"num of pi0 is:"<<pi0id.size()<<endl;
323 for(
int i=0; i<pi0id.size(); i++){
325 cout<<
"pi0Mass: " << (*pi0Itr)->unconMass() << endl;
330 SmartRefVector<EvtRecTrack> showers=(*iter_dtag)->showers();
332 for(EvtRecPi0Col::iterator pi0Itr = recPi0Col->begin();
333 pi0Itr < recPi0Col->end(); pi0Itr++){
339 int heGammaTrkId = heGammaTrk->
trackId();
340 int leGammaTrkId = leGammaTrk->
trackId();
342 if((heGammaTrkId != showers[0]->trackId())&&
343 (heGammaTrkId != showers[1]->trackId()))
continue;
344 if((leGammaTrkId != showers[0]->trackId())&&
345 (leGammaTrkId != showers[1]->trackId()))
continue;
350 cout<<
"pi0Mass: " << (*pi0Itr)->unconMass() << endl;
351 cout<<
" E(high): " << heGamma->
energy() << endl;
352 cout<<
" E(low) : " << leGamma->
energy() << endl;
354 m_pi0mass = (*pi0Itr)->unconMass();
355 m_pi0mode = (*iter_dtag)->decayMode();
372 m_mode=(*iter_dtag)->decayMode();
373 m_type=(*iter_dtag)->type();
374 m_charge=(*iter_dtag)->charge();
375 m_charm=(*iter_dtag)->charm();
376 m_numofchildren=(*iter_dtag)->numOfChildren();
377 m_mass=(*iter_dtag)->mass();
378 m_mBC=(*iter_dtag)->mBC();
379 m_e=(*iter_dtag)->beamE();
380 m_deltae=(*iter_dtag)->deltaE();
382 SmartRefVector<EvtRecTrack> othertracks=(*iter_dtag)->otherTracks();
383 m_ntrk=othertracks.size();
390 vector<int> ksid= dtagTool.
ksId(iter_dtag);
391 cout<<
"xxxxxxxxxxxxxxxxxxxxxxxxx"<<
"num of ks is:"<<ksid.size()<<endl;
393 for(
int i=0; i<ksid.size(); i++){
395 cout<<
"ksMass: " << (*ksItr)->mass() << endl;
401 SmartRefVector<EvtRecTrack> tracks=(*iter_dtag)->tracks();
403 for(EvtRecVeeVertexCol::iterator ksItr = evtRecVeeVertexCol->begin();
404 ksItr < evtRecVeeVertexCol->end(); ksItr++){
407 if((*ksItr)->vertexId() != 310)
continue;
412 int ksChild1TrkId = aKsChild1Trk->
trackId();
413 int ksChild2TrkId = aKsChild2Trk->
trackId();
415 if((ksChild1TrkId != tracks[0]->trackId())&&
416 (ksChild1TrkId != tracks[1]->trackId()))
continue;
417 if((ksChild2TrkId != tracks[0]->trackId())&&
418 (ksChild2TrkId != tracks[1]->trackId()))
continue;
420 cout<<
"ksMass: " << (*ksItr)->mass() << endl;
422 Hep3Vector ks_D3(0,0,0);
423 ks_D3.set((*ksItr)->w()[4],(*ksItr)->w()[5],(*ksItr)->w()[6]);
425 m_ksmass = (*ksItr)->mass();
427 m_ksmode = (*iter_dtag)->decayMode();
443 m_mode=(*iter_dtag)->decayMode();
444 m_type=(*iter_dtag)->type();
445 m_charge=(*iter_dtag)->charge();
446 m_charm=(*iter_dtag)->charm();
447 m_numofchildren=(*iter_dtag)->numOfChildren();
448 m_mass=(*iter_dtag)->mass();
449 m_mBC=(*iter_dtag)->mBC();
450 m_e=(*iter_dtag)->beamE();
451 m_deltae=(*iter_dtag)->deltaE();
453 SmartRefVector<EvtRecTrack> othertracks=(*iter_dtag)->otherTracks();
454 m_ntrk=othertracks.size();
464 m_mode=(*iter_dtag)->decayMode();
465 m_type=(*iter_dtag)->type();
466 m_charge=(*iter_dtag)->charge();
467 m_charm=(*iter_dtag)->charm();
468 m_numofchildren=(*iter_dtag)->numOfChildren();
469 m_mass=(*iter_dtag)->mass();
470 m_mBC=(*iter_dtag)->mBC();
471 m_e=(*iter_dtag)->beamE();
472 m_deltae=(*iter_dtag)->deltaE();
474 SmartRefVector<EvtRecTrack> othertracks=(*iter_dtag)->otherTracks();
475 m_ntrk=othertracks.size();
485 cout<<
"**************"<<endl;
486 cout<<
"**************"<<endl;
487 cout<<
"test print only D0/Dp/Ds modes"<<endl;
490 vector<int> d0itindex= dtagTool.
D0modes();
491 for(
int i=0; i< d0itindex.size(); i++){
493 cout<<
"No."<<i+1<<
" D0 mode is :"<< (*iter)->decayMode()<<endl;
497 vector<int> dpitindex= dtagTool.
Dpmodes();
498 for(
int i=0; i< dpitindex.size(); i++){
500 cout<<
"No."<<i+1<<
" Dp mode is :"<< (*iter)->decayMode()<<endl;
504 vector<int> dsitindex= dtagTool.
Dsmodes();
505 for(
int i=0; i< dsitindex.size(); i++){
507 cout<<
"No."<<i+1<<
" Ds mode is :"<< (*iter)->decayMode()<<endl;
513 cout<<
"**************"<<endl;
514 cout<<
"**************"<<endl;
515 cout<<
"test single tag "<<endl;
518 cout<<
" find single tag mode: "<< (*dtagTool.
stag())->decayMode() <<endl;
522 cout<<
"cosmic and lepton backgaround veto"<<endl;
523 cout<<
" find single tag mode: "<< (*dtagTool.
stag())->decayMode() <<endl;
528 cout<<
"**************"<<endl;
529 cout<<
"**************"<<endl;
530 cout<<
"test double tag "<<endl;
537 cout<<
" find double tag mode 1 :"<<endl;
538 dtagTool<<dtagTool.
dtag1();
539 cout<<
" find double tag mode 2: "<< endl;
540 dtagTool<<dtagTool.
dtag2();
546 cout<<
" find double tag mode 1 :"<<endl;
547 dtagTool<<dtagTool.
dtag1();
548 cout<<
" find double tag mode 2: "<< endl;
549 dtagTool<<dtagTool.
dtag2();
556 cout<<
" double tag by invariant mass:"<<endl;
557 cout<<
" find double tag mode 1 :"<<endl;
558 dtagTool<<dtagTool.
dtag1();
559 cout<<
" find double tag mode 2: "<< endl;
560 dtagTool<<dtagTool.
dtag2();
567 vector<DTagToolIterator> vdtag1=dtagTool.
vdtag1();
568 vector<DTagToolIterator> vdtag2=dtagTool.
vdtag2();
570 cout<<
" list of all doule tags:"<<endl;
571 for(
int i=0;i<vdtag1.size();i++){
572 cout<<
" find double tag mode 1 :"<<endl;
574 cout<<
" find double tag mode 2: "<< endl;
588 MsgStream log(
msgSvc(), name());
589 log << MSG::INFO <<
"in finalize()" << endmsg;
590 return StatusCode::SUCCESS;
HepGeom::Point3D< double > HepPoint3D
std::vector< HepLorentzVector > Vp4
double sin(const BesAngle a)
double cos(const BesAngle a)
DDecay(const std::string &name, ISvcLocator *pSvcLocator)
const HepVector helix() const
......
RecEmcShower * emcShower()
virtual bool isVertexValid()=0
virtual double * PrimaryVertex()=0