41#include "HepMC/GenEvent.h"
42#include "HepMC/GenVertex.h"
43#include "HepMC/GenParticle.h"
45#include "GaudiKernel/SmartDataPtr.h"
48#include "GaudiKernel/MsgStream.h"
49#include "GaudiKernel/ISvcLocator.h"
50#include "GaudiKernel/AlgFactory.h"
51#include "GaudiKernel/DataSvc.h"
52#include "GaudiKernel/SmartDataPtr.h"
53#include "GaudiKernel/IPartPropSvc.h"
57#include "CLHEP/Random/Ranlux64Engine.h"
58#include "CLHEP/Random/RandFlat.h"
63static string mydecayrec;
64static double _amps_max;
83 declareProperty(
"DecayDecDir", m_DecayDec =
"");
84 declareProperty(
"PdtTableDir", m_PdtTable =
"");
85 declareProperty(
"userDecayTableName", userDecFileName =
"NONE");
86 declareProperty(
"DecayTopology", m_DecayTop =
"");
87 declareProperty(
"DecayRecord", m_DecayRec =
"");
88 declareProperty(
"ParentParticle", m_ParentPart =
"NONE");
89 declareProperty(
"Multiplicity", m_Ncharge =
false);
90 declareProperty(
"NutupleFile",m_NtupleFile =
false);
91 declareProperty(
"mDIY",_mDIY=
false);
92 declareProperty(
"FDPdata",m_SB3File =
"");
93 declareProperty(
"FDPHisT",m_SB3HT =
"");
94 declareProperty(
"FDPpart",m_FDPparticle =
"");
95 declareProperty(
"TruthFile",m_truthFile =
"");
96 declareProperty(
"TruthPart",m_truthPart =
"");
97 declareProperty(
"Psi3SopenCharm",m_Psi4040OpenCharm=
false);
98 declareProperty(
"Psi2openCharm", m_Psi2openCharm=
false);
99 declareProperty(
"statDecays",m_statDecays=
false);
100 declareProperty(
"TagLundCharmModel", m_tagLundModel=
false);
102 m_polarization.clear();
103 declareProperty(
"polarization", m_polarization);
109 MsgStream log(messageService(), name());
110 if(m_truthFile!=
""){truth.open(m_truthFile.c_str());}
111 log << MSG::INFO <<
"EvtDecay initialize" << endreq;
112 static const bool CREATEIFNOTTHERE(
true);
113 StatusCode RndmStatus = service(
"BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE);
114 if (!RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc)
116 log << MSG::ERROR <<
" Could not initialize Random Number Service" << endreq;
122 m_ampscalflag =
true;
124 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->
GetEngine(
"EVTGEN");
125 const long s = engine->getSeed();
129 m_seeds.push_back(
s);
134 if ( m_DecayDec ==
"") {
135 m_DecayDec=getenv(
"BESEVTGENROOT");
136 m_DecayDec +=
"/share/DECAY.DEC";
139 if ( m_PdtTable ==
"") {
140 m_PdtTable =getenv(
"BESEVTGENROOT");
141 m_PdtTable +=
"/share/pdt.table";
145 std::cout<<
"===================== user decay card ========================"<<std::endl;
146 strcpy(catcmd,
"cat ");
147 strcat(catcmd, userDecFileName.c_str());
156 if (status.isSuccess()) {
157 log << MSG::INFO <<
"got the DataInfoSvc" << endreq;
161 log << MSG::ERROR <<
"could not get the DataInfoSvc" << endreq;
162 return StatusCode::FAILURE;
168 m_Gen =
new EvtGen( m_DecayDec.c_str(), m_PdtTable.c_str(), m_RandomEngine );
170 if(userDecFileName ==
"NONE") log << MSG::INFO <<
"EvtDecay User did not define his Decay table EvtGen will use standart" << endreq;
171 if(!(userDecFileName ==
"NONE")) m_Gen->
readUDecay(userDecFileName.c_str());
173 if(!(m_DecayTop==
" ")) {
174 outfile.open(m_DecayTop.c_str());
181 NTuplePtr nt1(
ntupleSvc(),
"MYROOTFILE/Trk");
182 if(nt1) {m_tuple=nt1;}
184 m_tuple =
ntupleSvc()->book (
"MYROOTFILE/Trk", CLID_ColumnWiseTuple,
"Generator-trk-Ntuple");
186 status = m_tuple->addItem (
"TotNumTrk", TotNumTrk, 0,1000);
187 status = m_tuple->addIndexedItem (
"Trk_index", TotNumTrk, m_Trk_index);
188 status = m_tuple->addIndexedItem (
"m_px_trk", TotNumTrk, m_px_trk);
189 status = m_tuple->addIndexedItem (
"m_py_trk", TotNumTrk, m_py_trk);
190 status = m_tuple->addIndexedItem (
"m_pz_trk", TotNumTrk, m_pz_trk);
191 status = m_tuple->addIndexedItem (
"m_en_trk", TotNumTrk, m_en_trk);
192 status = m_tuple->addIndexedItem (
"FST", TotNumTrk, m_fst);
194 status = m_tuple->addItem (
"nchr", m_nchr);
195 status = m_tuple->addItem (
"nchr_e", m_nchr_e);
196 status = m_tuple->addItem (
"nchr_mu", m_nchr_mu);
197 status = m_tuple->addItem (
"nchr_pi", m_nchr_pi);
198 status = m_tuple->addItem (
"nchr_k", m_nchr_k);
199 status = m_tuple->addItem (
"nchr_p", m_nchr_p);
200 status = m_tuple->addItem (
"N_gamma", m_gamma);
201 status = m_tuple->addItem (
"N_gammaFSR", m_gammaFSR);
203 log << MSG::ERROR <<
" Cannot book N-tuple:"<< long(m_tuple) << endmsg;
204 return StatusCode::FAILURE;
208 NTuplePtr nt2(
ntupleSvc(),
"MYROOTFILE/mass");
209 if(nt2) {mass_tuple=nt2;}
211 mass_tuple =
ntupleSvc()->book (
"MYROOTFILE/mass", CLID_ColumnWiseTuple,
"Generator-mass-Ntuple");
213 status = mass_tuple->addItem (
"m12", m_m12);
214 status = mass_tuple->addItem (
"m13", m_m13);
215 status = mass_tuple->addItem (
"m23", m_m23);
216 status = mass_tuple->addItem (
"m1", m_m1);
217 status = mass_tuple->addItem (
"m2", m_m2);
218 status = mass_tuple->addItem (
"m3", m_m3);
219 status = mass_tuple->addItem (
"costheta1", m_cos1);
220 status = mass_tuple->addItem (
"costheta2", m_cos2);
221 status = mass_tuple->addItem (
"costheta3", m_cos3);
222 status = mass_tuple->addItem (
"ichannel", m_ich);
224 log << MSG::ERROR <<
" Cannot book N-tuple:"<< long(m_tuple) << endmsg;
225 return StatusCode::FAILURE;
229 NTuplePtr nt3(
ntupleSvc(),
"MYROOTFILE/massGen");
230 if(nt3) {massgen_tuple=nt3;}
232 massgen_tuple =
ntupleSvc()->book (
"MYROOTFILE/massGen", CLID_ColumnWiseTuple,
"Generator-mass-Ntuple");
234 status = massgen_tuple->addItem (
"m12", _m12);
235 status = massgen_tuple->addItem (
"m13", _m13);
236 status = massgen_tuple->addItem (
"m23", _m23);
237 status = massgen_tuple->addItem (
"m1", _m1);
238 status = massgen_tuple->addItem (
"m2", _m2);
239 status = massgen_tuple->addItem (
"m3", _m3);
240 status = massgen_tuple->addItem (
"costheta1", _cos1);
241 status = massgen_tuple->addItem (
"costheta2", _cos2);
242 status = massgen_tuple->addItem (
"costheta3", _cos3);
243 status = massgen_tuple->addItem (
"ichannel", _ich);
245 log << MSG::ERROR <<
" Cannot book N-tuple:"<< long(m_tuple) << endmsg;
246 return StatusCode::FAILURE;
252 for(
int i=0;i<500;i++){br[i]=0;}
253 if(!(m_SB3File==
"" && m_SB3HT==
"")) {
254 const char *filename, *histitle;
255 filename=(
char*)m_SB3File.c_str();
256 histitle=(
char*)m_SB3HT.c_str();
257 SuperBody3decay.
setFile(filename);
259 SuperBody3decay.
init();
262 return StatusCode::SUCCESS;
268 MsgStream log(messageService(), name());
271 string key =
"GEN_EVENT";
273 SmartDataPtr<McGenEventCol> McEvtColl(eventSvc(),
"/Event/Gen");
278 if ( McEvtColl == 0 )
280 HepMC::GenEvent* evt=
new GenEvent();
281 evt->set_event_number(m_numberEvent);
282 callBesEvtGen( evt );
283 if(!(m_DecayTop==
"")) evt->print(outfile);
288 mcColl->push_back(mcEvent);
289 StatusCode sc = eventSvc()->registerObject(
"/Event/Gen",mcColl);
290 if(sc != SUCCESS)
return StatusCode::FAILURE;
294 McGenEventCol::iterator mcItr;
295 for( mcItr = McEvtColl->begin(); mcItr != McEvtColl->end(); mcItr++ )
297 HepMC::GenEvent* hEvt = (*mcItr)->getGenEvt();
302 if(!(m_DecayTop==
"")) hEvt->print(outfile);
305 if(!(m_DecayRec==
"")) std::cout<<std::endl;
308 if( m_NtupleFile ){ m_tuple->write();}
309 return StatusCode::SUCCESS;
317StatusCode EvtDecay::callEvtGen( HepMC::GenEvent* hepMCevt )
319 MsgStream log(messageService(), name());
328 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
330 for (
int i=0;i<13;i++)
fst[i]=0;
331 HepMC::GenEvent::particle_const_iterator itp;
333 for( itp=hepMCevt->particles_begin(); itp!=hepMCevt->particles_end(); ++itp )
355 HepMC::GenParticle* hepMCpart=*itp;
356 int stat = hepMCpart->status();
359 if ( stat != 1 )
continue;
361 loop_to_select_eventsB:
362 int id = hepMCpart->pdg_id();
364 hepMCpart->set_status(899);
368 double en =(hepMCpart->momentum()).e();
369 double pex=(hepMCpart->momentum()).px();
370 double pey=(hepMCpart->momentum()).py();
371 double pez=(hepMCpart->momentum()).pz();
374 parentMass=p_init.mass();
379 bool parentFlag=
false;
381 if(m_polarization.size()>0) {part->
setPolarizedSpinDensity(m_polarization[0],m_polarization[1],m_polarization[2]);}
else
386 int id = hepMCpart->pdg_id();
389 if(
id == 11 ) {
fst[1]++;}
else if(
id == -11){
fst[2]++;}
390 else if(
id == 13){
fst[3]++;}
391 else if(
id == -13){
fst[4]++;}
392 else if(
id == 211){
fst[5]++;}
393 else if(
id ==-211){
fst[6]++;}
394 else if(
id == 321){
fst[7]++;}
395 else if(
id ==-321){
fst[8]++;}
396 else if(
id ==2212){
fst[9]++;}
397 else if(
id ==-2212){
fst[10]++;}
398 else if(
id == 2112){
fst[11]++;}
399 else if(
id ==-2112){
fst[12]++;}
400 if( fabs(
id) == 11) {
nchr_e++;}
401 if( fabs(
id) == 13) {
nchr_mu++;}
402 if( fabs(
id) == 211) {
nchr_pi++;}
403 if( fabs(
id) == 321) {
nchr_k++;}
404 if( fabs(
id) == 2212) {
nchr_p++;}
406 if( m_NtupleFile==
true &&
id!=0 ){
407 m_Trk_index[AllTrk_index]=id;
408 m_px_trk[AllTrk_index]=pex;
409 m_py_trk[AllTrk_index]=pey;
410 m_pz_trk[AllTrk_index]=pez;
411 m_en_trk[AllTrk_index]=en ;
424 if(m_FDPparticle!=
""){
433 if(!(m_SB3File==
"" || m_SB3HT==
"") && parentFlag && first ){
434 SuperBody3decay_make(fdp_ppid, fdp_init );
437 loop_to_select_eventsA:
439 if(m_truthFile!=
"" && m_truthPart!=
""){
442 for(
int id=0;
id<ndaug;
id++){
445 truth<<son.
get(0)<<
" "<<son.
get(1)<<
" "<<son.
get(2)<<
" "<<son.
get(3)<<std::endl;
450 if(_mDIY && parentFlag && m_ampscalflag ) _amps_max=CalAmpsMax(part);
451 if(_mDIY && parentFlag) {
453 double amps=CalAmpsMDIY( part );
454 ratio=amps/_amps_max;
456 if(_mDIY && parentFlag && ratio<=rdm){
goto loop_to_select_eventsA;}
460 if(m_FDPparticle==
""){FDP_part=part;}
461 if(!(m_SB3File==
"" || m_SB3HT==
"") && parentFlag ){ accept=SuperBody3decay_judge( FDP_part); }
462 if(!(m_SB3File==
"" || m_SB3HT==
"") && parentFlag && !accept){
465 goto loop_to_select_eventsB;
466 }
else if(!(m_SB3File==
"" || m_SB3HT==
"") && parentFlag && accept){
467 countChannel(FDP_part);
470 if((m_Psi2openCharm || m_Psi4040OpenCharm) && parentFlag ){
471 if(getModel(part) ==
"OPENCHARM"){
472 std::cout<<
"OPENCHARM model need to set Psi2openCharm and Psi3SopenCharm to be false!"<<std::endl;
476 bool theDecay = opencharm.choseDecay();
480 goto loop_to_select_eventsB;
489 unsigned int modeTag, multiplicityTag;
490 modeTag = theTag.getModeTag();
491 if( getModel(part) ==
"OPENCHARM"||getModel(part) ==
"LUNDCHARM" && m_tagLundModel){
492 multiplicityTag = decayType(part);
496 multiplicityTag = theTag.getMultTag() + decayType(part);
500 if(eventHeader == 0) std::cout <<
"event header unavailable: " << std::endl;
501 if (eventHeader != 0) {
502 eventHeader->setFlag1(modeTag);
503 eventHeader->setFlag2(multiplicityTag);
508 if(!(m_DecayRec==
"")) mydecayrec=part->
writeTreeRec(m_DecayRec);
510 if(m_statDecays && parentFlag ) countChannel(part);
513 if ( log.level() <= MSG::DEBUG ) part->
printTree() ;
514 log << MSG::DEBUG <<
"Converting particles to HepMC" << endreq;
516 makeHepMC(part, hepMCevt, hepMCpart);
518 hepMCpart->set_status(999);
523 for( itp=hepMCevt->particles_begin(); itp!=hepMCevt->particles_end(); ++itp )
525 if (!(*itp)->end_vertex() && ( (*itp)->status()==899 || (*itp)->status()==999 ))
526 (*itp)->set_status(1);
529 if(m_Ncharge ==
true ) {std::cout<<
"MultiplicityTotoalCharge_e_mu_pi_K_p_gamma_gammaFSR: "
538 if(m_Ncharge ==
true ){std::cout<<
"FinalStates: "
551 <<
fst[12]<<std::endl;}
566 return StatusCode::SUCCESS;
572StatusCode EvtDecay::callBesEvtGen( HepMC::GenEvent* hepMCevt )
574 MsgStream log(messageService(), name());
584 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
585 for (
int i=0;i<13;i++)
fst[i]=0;
586 HepMC::GenEvent::particle_const_iterator itp;
607 loop_to_select_eventsB:
617 HepMC::GenParticle* hepMCpart=
new GenParticle(HepLorentzVector(0,0,0,ppmass),pid,3);
619 bool parentFlag =
false;
630 if(m_FDPparticle!=
""){
639 if(!(m_SB3File==
"" || m_SB3HT==
"") && first ){ SuperBody3decay_make( fdp_ppid, fdp_init);}
642 loop_to_select_events:
644 if(m_truthFile!=
"" && m_truthPart!=
""){
647 for(
int id=0;
id<ndaug;
id++){
650 truth<<son.
get(0)<<
" "<<son.
get(1)<<
" "<<son.
get(2)<<
" "<<son.
get(3)<<std::endl;
655 if(_mDIY && m_ampscalflag ) _amps_max=CalAmpsMax(part);
658 double amps=CalAmpsMDIY( part );
659 ratio=amps/_amps_max;
661 if(_mDIY && ratio<=rdm)
goto loop_to_select_events;
665 if(m_FDPparticle==
""){FDP_part=part;}
666 if(!(m_SB3File==
"" || m_SB3HT==
"")){
667 accept=SuperBody3decay_judge( FDP_part);
669 if(!(m_SB3File==
"" || m_SB3HT==
"") && !accept) {
672 goto loop_to_select_eventsB;
673 }
else if(!(m_SB3File==
"" || m_SB3HT==
"") && parentFlag && accept){
674 countChannel(FDP_part);
679 if(m_statDecays && parentFlag) countChannel(part);
686 unsigned int modeTag, multiplicityTag;
687 modeTag = theTag.getModeTag();
688 if( getModel(part) ==
"OPENCHARM"|| getModel(part) ==
"LUNDCHARM" && m_tagLundModel ){
689 multiplicityTag = decayType(part);
693 multiplicityTag = theTag.getMultTag() + decayType(part);
695 if(eventHeader == 0) std::cout <<
"event header unavailable: " << std::endl;
696 if (eventHeader != 0) {
697 eventHeader->setFlag1(modeTag);
698 eventHeader->setFlag2(multiplicityTag);
702 if(!(m_DecayRec==
"")) {mydecayrec=part->
writeTreeRec(m_DecayRec);std::cout<<std::endl;};
705 if ( log.level() <= MSG::DEBUG ) part->
printTree() ;
706 log << MSG::DEBUG <<
"Converting particles to HepMC" << endreq;
708 makeHepMC(part, hepMCevt, hepMCpart);
710 if(part->
getNDaug()!=0) hepMCpart->set_status(999);
715 for( itp=hepMCevt->particles_begin(); itp!=hepMCevt->particles_end(); ++itp )
717 if (!(*itp)->end_vertex() && ( (*itp)->status()==899 || (*itp)->status()==999 ))
718 (*itp)->set_status(1);
719 HepMC::GenParticle* hepMCpart=*itp;
720 int stat = hepMCpart->status();
721 int id = hepMCpart->pdg_id();
723 if ( stat != 1 )
continue;
726 if(
id == 11 ) {
fst[1]++;}
else if(
id == -11) {
fst[2]++;}
727 else if(
id == 13 ) {
fst[3]++;}
728 else if(
id ==-13) {
fst[4]++;}
729 else if(
id==211) {
fst[5]++;}
730 else if(
id==-211) {
fst[6]++;}
731 else if(
id== 321) {
fst[7]++;}
732 else if(
id ==-321) {
fst[8]++;}
733 else if(
id ==2212) {
fst[9]++;}
734 else if(
id==-2212) {
fst[10]++;}
735 else if(
id == 2112){
fst[11]++;}
736 else if(
id==-2112) {
fst[12]++;}
737 if( fabs(
id) == 11) {
nchr_e++;}
738 if( fabs(
id) == 13) {
nchr_mu++;}
739 if( fabs(
id) == 211) {
nchr_pi++;}
740 if( fabs(
id) == 321) {
nchr_k++;}
741 if( fabs(
id) == 2212) {
nchr_p++;}
744 double en =(hepMCpart->momentum()).e();
745 double pex=(hepMCpart->momentum()).px();
746 double pey=(hepMCpart->momentum()).py();
747 double pez=(hepMCpart->momentum()).pz();
749 if( m_NtupleFile==
true &&
id!=0){
750 m_Trk_index[AllTrk_index]=id;
751 m_px_trk[AllTrk_index]=pex;
752 m_py_trk[AllTrk_index]=pey;
753 m_pz_trk[AllTrk_index]=pez;
754 m_en_trk[AllTrk_index]=en ;
766 itp=hepMCevt->particles_begin();
767 (*itp)->set_status(2);
770 if(m_Ncharge ==
true ) {std::cout<<
"MultiplicityTotoalCharge_e_mu_pi_K_p_gamma_gammaFSR: "
779 if(m_Ncharge ==
true ){std::cout<<
"FinalStates: "
792 <<
fst[12]<<std::endl;}
807 return StatusCode::SUCCESS;
813 MsgStream log(messageService(), name());
815 log << MSG::INFO <<
"EvtDecay finalized" << endreq;
817 Forfile.open(
"fort.16",ios::in);
819 strcpy(delcmd,
"rm -f ");
820 strcat(delcmd,
"fort.16");
824 Forfile2.open(
"fort.22",ios::in);
825 strcpy(delcmd,
"rm -f ");
826 strcat(delcmd,
"fort.22");
836 if(!(m_SB3File==
"" || m_SB3HT==
"")){
837 for(
int i=0;i<500;i++){totalEvt=totalEvt+br[i];}
838 for(
int i=0;i<500;i++){
839 double bi=1.0*br[i]/totalEvt;
840 std::cout<<
"Branching fraction of channel "<<i<<
" is: "<<bi<<std::endl;
847 for(
int i=0;i<=totalChannels;i++){totalEvt=totalEvt+br[i];}
848 std::cout<<
"==================Statistical first chain decay ==============================="<<std::endl;
849 std::cout<<
"i-th channel Events Generated Branching fraction generated "<<std::endl;
850 for(
int i=0;i<=totalChannels;i++){
851 std::cout<<
"| "<<i<<
" "<<br[i]<<
" "<<br[i]*1.0/totalEvt<<std::endl;
854 std::cout<<
"--------------------------------------------------------------------------------"<<std::endl;
855 std::cout<<
" sum: "<<totalEvt<<
" "<<
"1"<<std::endl;
856 std::cout<<
"================== End of statistical first chain decay ========================"<<std::endl;
859 return StatusCode::SUCCESS;
863StatusCode EvtDecay::makeHepMC(
EvtParticle* part, HepMC::GenEvent* hEvt,
864 HepMC::GenParticle* hPart)
866 MsgStream log(messageService(), name());
875 HepMC::GenVertex* end_vtx =
new HepMC::GenVertex(HepLorentzVector(x,y,z,ct));
876 hEvt->add_vertex( end_vtx );
877 end_vtx->add_particle_in(hPart);
881 for(
int it=0;it<ndaug;it++)
893 HepMC::GenParticle* prod_part =
new HepMC::GenParticle(HepLorentzVector(px,py,pz,e),
id,status);
894 end_vtx->add_particle_out(prod_part);
895 makeHepMC(part->
getDaug(it),hEvt,prod_part);
899 if( log.level()<MSG::INFO )
904 return StatusCode::SUCCESS;
908void EvtDecay::MeVToGeV (HepMC::GenEvent* evt)
910 for ( HepMC::GenEvent::particle_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p ) {
913 (*p)->momentum().setX((*p)->momentum().x()/1000.);
914 (*p)->momentum().setY((*p)->momentum().y()/1000.);
915 (*p)->momentum().setZ((*p)->momentum().z()/1000.);
916 (*p)->momentum().setT((*p)->momentum().t()/1000.);
918 (*p)->set_momentum( (*p)->momentum() );
922void EvtDecay::GeVToMeV (HepMC::GenEvent* evt)
924 for ( HepMC::GenEvent::particle_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p ) {
927 (*p)->momentum().setX((*p)->momentum().x()*1000.);
928 (*p)->momentum().setY((*p)->momentum().y()*1000.);
929 (*p)->momentum().setZ((*p)->momentum().z()*1000.);
930 (*p)->momentum().setT((*p)->momentum().t()*1000.);
932 (*p)->set_momentum( (*p)->momentum() );
940 for(
int i=0;i<100000;i++){
942 double amps=CalAmpsMDIY(part);
943 if(amps > amps_max) amps_max=amps;
945 amps_max=amps_max*1.05;
946 m_ampscalflag =
false;
955 m_engine->showStatus();
963 return RandFlat::shoot(m_engine);
968 double xmass2,ymass2;
973 FinalState_make( ppid, p_init);
976 for(
int i=0;i<100000;i++){
979 HepMC::GenParticle* hepMCpart=
new GenParticle(HepLorentzVector(0,0,0,parentMass),parentPDGcode,3);
987 FinalState_sort(part);
994 xmass2=(pd1+pd2).mass2();
995 ymass2=(pd1+pd3).mass2();
996 double xlow=SuperBody3decay.
getXlow();
997 double xup=SuperBody3decay.
getXup();
998 double ylow=SuperBody3decay.
getYlow();
999 double yup=SuperBody3decay.
getYup();
1000 if(xmass2<xlow || xmass2>xup || ymass2<ylow || ymass2>yup) { part->
deleteTree();
goto regen;}
1001 SuperBody3decay.
HFill(xmass2,ymass2);
1008 m_m12=(pd1+pd2).
mass();
1009 m_m23=(pd2+pd3).
mass();
1010 m_m13=(pd1+pd3).
mass();
1014 mass_tuple->write();
1016 double m1=pd1.
mass();
double m2=pd2.
mass();
double m3=pd3.
mass();
1017 double mj=(pd2+pd3).
mass();
1027bool EvtDecay::SuperBody3decay_judge(
EvtParticle* part){
1028 double xmass2,ymass2;
1033 FinalState_sort( part);
1040 xmass2=(pd1+pd2).mass2();
1041 ymass2=(pd1+pd3).mass2();
1042 accept=SuperBody3decay.
AR(xmass2,ymass2);
1045 if(accept && m_NtupleFile) {
1050 _m12=(pd1+pd2).
mass();
1051 _m23=(pd2+pd3).
mass();
1052 _m13=(pd1+pd3).
mass();
1056 massgen_tuple->write();
1067 identical_flag=
true;
1069 for(
int i=1;i<10000;i++){
1071 HepMC::GenParticle* hepMCpart=
new GenParticle(HepLorentzVector(0,0,0,parentMass),parentPDGcode,3);
1076 if(nson == 2) {
continue;}
else
1078 EvtId xid0,xid1,xid2;
1088 if(pdg0==pdg1 && pdg1==pdg2) {multi=3;}
1089 else if(pdg0==pdg1 ){multi=2;}
1090 else if(pdg0==pdg2 ){multi=2;pdg=pdg1; pdg1=pdg2; pdg2=pdg;}
1091 else if(pdg1==pdg2) {multi=2;pdg=pdg0; pdg0=pdg1; pdg1=pdg2; pdg2=pdg;}
1095 std::cout<<
"No direct three body decay channel found in decay card, I stop run"<<std::endl;
1106 EvtId xid0,xid1,xid2;
1136 assign_momentum(id0,pd0);
1137 assign_momentum(id1,pd1);
1138 assign_momentum(id2,pd2);
1139 }
else if(multi==2){
1140 assign_momentum2(id0,pd0);
1141 assign_momentum2(id1,pd1);
1142 assign_momentum2(id2,pd2);
1143 if(son0.
get(0)>son1.
get(0)){son=son0;son0=son1;son1=son;}
1144 }
else if(multi==3){
1145 double En0=pd0.
get(0);
1146 double En1=pd1.
get(0);
1147 double En2=pd2.
get(0);
1148 if(En0 < En1 && En1 < En2) {son0=pd0;son1=pd1;son2=pd2;}
1149 if(En0 < En2 && En2 < En1) {son0=pd0;son1=pd2;son2=pd1;}
1150 if(En1 < En0 && En0 < En2) {son0=pd1;son1=pd0;son2=pd2;}
1151 if(En1 < En2 && En2 < En0) {son0=pd1;son1=pd2;son2=pd0;}
1152 if(En2 < En0 && En0 < En1) {son0=pd2;son1=pd0;son2=pd1;}
1153 if(En2 < En1 && En1 < En0) {son0=pd2;son1=pd1;son2=pd0;}
1159void EvtDecay::assign_momentum(
int id0,
EvtVector4R pd0){
1160 if(id0==pdg0){son0=pd0;}
1161 else if(id0==pdg1){son1=pd0;}
1162 else if(id0==pdg2){son2=pd0;}
1163 else {std::cout<<
"PID= "<<id0<<
" not machted, I stop"<<std::endl; ::abort();}
1166void EvtDecay::assign_momentum2(
int id0,
EvtVector4R pd0){
1167 if(id0==pdg0 && identical_flag){son0=pd0;identical_flag=
false;}
1168 else if(id0==pdg1){son1=pd0;identical_flag=
true;}
1169 else if(id0==pdg2){son2=pd0;}
1170 else {std::cout<<
"PID not machted, I stop"<<std::endl; ::abort();}
1181 for(
int i=0;i<dn;i++){
1185 if(son_pdg == FDP_pdg){
1205 if(ich>totalChannels) totalChannels = ich;
1209bool EvtDecay::isCharmonium(
EvtId xid){
1225 std::vector<EvtId> Vid; Vid.clear();
1226 Vid.push_back(psi4415);
1227 Vid.push_back(psi4160);
1228 Vid.push_back(psi4040);
1229 Vid.push_back(psi3770);
1230 Vid.push_back(psiprim);
1231 Vid.push_back(jpsi);
1232 Vid.push_back(etac);
1233 Vid.push_back(etac2s);
1235 Vid.push_back(chic0);
1236 Vid.push_back(chic1);
1237 Vid.push_back(chic2);
1238 Vid.push_back(chic0p);
1239 Vid.push_back(chic1p);
1240 Vid.push_back(chic2p);
1243 for(
int i=0;i<Vid.size();i++){
if(xid == Vid[i])
return flag;}
1248bool EvtDecay::isCharm(
EvtId xid){
1266 std::vector<EvtId> Vid; Vid.clear();
1268 Vid.push_back(d0bar);
1273 Vid.push_back(dstp);
1274 Vid.push_back(dstm);
1276 Vid.push_back(ds0bar );
1277 Vid.push_back(dsp );
1278 Vid.push_back(dsm );
1279 Vid.push_back(dsstp );
1280 Vid.push_back(dsstm );
1281 Vid.push_back(ds0stp );
1282 Vid.push_back(ds0stm );
1285 for(
int i=0;i<Vid.size();i++){
if(xid == Vid[i])
return flag;}
1291 for(
int i=0;i<ndg;i++){
1310 std::string model = getModel(par,Nchannel);
1311 if( model ==
"OPENCHARM" || model ==
"LUNDCHARM" && m_tagLundModel){
1318 for(
int i=0;i<ndg;i++){
1323 if( isRadecay(par) ){
1324 for(
int i=0;i<ndg;i++){
1326 if( isCharmonium(xid) )
return 1;
1334 if( isCharm(xd1) && isCharm(xd2) ) {
return 2;}
else
1335 if( !isCharmonium(xd1) && !isCharmonium(xd2) && !isCharm(xd1) && !isCharm(xd2) ){
1340 for(
int i=0;i<ndg;i++){
1342 if( isCharmonium(xid) ) {flag =
true;
break;}
1343 if( isCharm(xid) ) {flag =
true;
break;}
1345 if( !flag ){
return 3;}
else {
return 4;}
1352std::string EvtDecay::getModel(
EvtParticle *par,
int mode){
ObjectVector< McGenEvent > McGenEventCol
*************DOUBLE PRECISION m_pi *DOUBLE PRECISION m_HvecTau2 DOUBLE PRECISION m_HvClone2 DOUBLE PRECISION m_gamma1 DOUBLE PRECISION m_gamma2 DOUBLE PRECISION m_thet1 DOUBLE PRECISION m_thet2 INTEGER m_IFPHOT *COMMON c_Taupair $ !Spin Polarimeter vector first Tau $ !Spin Polarimeter vector second Tau $ !Clone Spin Polarimeter vector first Tau $ !Clone Spin Polarimeter vector second Tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !phi of HvecTau1 $ !theta of HvecTau1 $ !phi of HvecTau2 $ !theta of HvecTau2 $ !super key
void setDecayCard(string card)
EvtBesRandom(HepRandomEngine *engine)
std::string getModelName()
static EvtDecayBase * gettheDecay(EvtId parent, int imode)
EvtDecay(const string &name, ISvcLocator *pSvcLocator)
DataInfoSvc * dataInfoSvc
IDataInfoSvc * tmpInfoSvc
void readUDecay(const char *const udecay_name)
void generateDecay(int stdhepid, EvtVector4R P, EvtVector4R D, EvtStdHep *evtStdHep, EvtSpinDensity *spinDensity=0)
bool AR(double xmass2, double ymass2)
void HFill(double xmass2, double ymass2)
void setHTitle(const char *htitle)
void setFile(const char *dtfile)
static int getStdHep(EvtId id)
static EvtId evtIdFromStdHep(int stdhep)
static std::string name(EvtId i)
static double getMass(EvtId i)
static EvtId getId(const std::string &name)
static EvtParticle * particleFactory(EvtSpinType::spintype spinType)
void setVectorSpinDensity()
void setPolarizedSpinDensity(double r00, double r11, double r22)
EvtSpinType::spintype getSpinType() const
const EvtVector4R & getP4() const
EvtParticle * getDaug(int i)
std::string writeTreeRec(std::string) const
virtual void setGenseed(long)=0
virtual CLHEP::HepRandomEngine * GetEngine(const std::string &StreamName)=0
Interface to the CLHEP engine.