Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

EvtDecay Class Reference

#include <EvtDecay.h>

List of all members.

Public Member Functions

 EvtDecay (const string &name, ISvcLocator *pSvcLocator)
StatusCode execute ()
StatusCode finalize ()
StatusCode initialize ()

Public Attributes

DataInfoSvcdataInfoSvc
IDataInfoSvctmpInfoSvc

Private Member Functions

void assign_momentum (int pdx, EvtVector4R pv4)
void assign_momentum2 (int pdx, EvtVector4R pv4)
double CalAmpsMax (EvtParticle *part)
double CalAmpsMDIY (EvtParticle *part)
StatusCode callBesEvtGen (HepMC::GenEvent *hepMCevt)
StatusCode callEvtGen (HepMC::GenEvent *hepMCevt)
void countChannel (EvtParticle *part)
int decayType (EvtParticle *par)
void FinalState_make (EvtId ppid, EvtVector4R p_init)
void FinalState_sort (EvtParticle *part)
void findPart (EvtParticle *part)
std::string getModel (EvtParticle *par)
std::string getModel (EvtParticle *par, int mode)
void GeVToMeV (HepMC::GenEvent *hepMCevt)
bool isCharm (EvtId xid)
bool isCharmonium (EvtId xid)
bool isRadecay (EvtParticle *par)
StatusCode makeHepMC (EvtParticle *, HepMC::GenEvent *, HepMC::GenParticle *)
void MeVToGeV (HepMC::GenEvent *hepMCevt)
bool SuperBody3decay_judge (EvtParticle *part)
void SuperBody3decay_make (EvtId ppid, EvtVector4R p_init)

Private Attributes

NTuple::Item< double > _cos1
NTuple::Item< double > _cos2
NTuple::Item< double > _cos3
NTuple::Item< long > _ich
NTuple::Item< double > _m1
NTuple::Item< double > _m12
NTuple::Item< double > _m13
NTuple::Item< double > _m2
NTuple::Item< double > _m23
NTuple::Item< double > _m3
bool _mDIY
int AllTrk_index
int br [500]
double en_trk [50]
EvtId FDP_id
EvtVector4R FDP_init
EvtParticleFDP_part
bool first
bool identical_flag
bool m_ampscalflag
NTuple::Item< double > m_cos1
NTuple::Item< double > m_cos2
NTuple::Item< double > m_cos3
string m_DecayDec
string m_DecayRec
string m_DecayTop
NTuple::Array< double > m_en_trk
string m_FDPparticle
NTuple::Array< long > m_fst
NTuple::Item< long > m_gamma
NTuple::Item< long > m_gammaFSR
EvtGenm_Gen
NTuple::Item< long > m_ich
std::vector< int > m_InSeeds
EvtId m_KKMCRes
NTuple::Item< double > m_m1
NTuple::Item< double > m_m12
NTuple::Item< double > m_m13
NTuple::Item< double > m_m2
NTuple::Item< double > m_m23
NTuple::Item< double > m_m3
bool m_Ncharge
NTuple::Item< long > m_nchr
NTuple::Item< long > m_nchr_e
NTuple::Item< long > m_nchr_k
NTuple::Item< long > m_nchr_mu
NTuple::Item< long > m_nchr_p
NTuple::Item< long > m_nchr_pi
bool m_NtupleFile
int m_numberEvent
string m_ParentPart
string m_PdtTable
bool m_Psi4040OpenCharm
NTuple::Array< double > m_px_trk
NTuple::Array< double > m_py_trk
NTuple::Array< double > m_pz_trk
EvtBesRandomm_RandomEngine
string m_SB3File
string m_SB3HT
vector< long int > m_seeds
bool m_statDecays
bool m_tagLundModel
int m_targetID
NTuple::Array< long > m_Trk_index
NTuple::Tuple * m_tuple
NTuple::Tuple * mass_tuple
NTuple::Tuple * massgen_tuple
int multi
std::ofstream outfile
std::ofstream outfile2
IBesRndmGenSvcp_BesRndmGenSvc
double parentMass
int parentPDGcode
int pdg
int pdg0
int pdg1
int pdg2
double px_trk [50]
double py_trk [50]
double pz_trk [50]
EvtVector4R son
EvtVector4R son0
EvtVector4R son1
EvtVector4R son2
EvtHis2F SuperBody3decay
int totalChannels
NTuple::Item< long > TotNumTrk
int Trk_index [50]
string userDecFileName
int vbr [500]
int writeFlag


Constructor & Destructor Documentation

EvtDecay::EvtDecay const string &  name,
ISvcLocator *  pSvcLocator
 

00073                                                               :Algorithm( name, pSvcLocator )
00074 {
00075 
00076 
00077  
00078   // these can be used to specify alternative locations or filenames
00079   // for the EvtGen particle and channel definition files.
00080 
00081   declareProperty("DecayDecDir", m_DecayDec = "");
00082   declareProperty("PdtTableDir", m_PdtTable = "");
00083   declareProperty("userDecayTableName", userDecFileName = "NONE");
00084   declareProperty("DecayTopology", m_DecayTop = "");    // output decay topology to a file specified by user    
00085   declareProperty("DecayRecord", m_DecayRec = "");    // output decay topology of one particle specified by user to a file                   
00086   declareProperty("ParentParticle", m_ParentPart = "NONE");  // Mothor particle name in pdt.table for only running BesEvtGen
00087   declareProperty("Multiplicity", m_Ncharge = false);  // output ncharge number of an event
00088   declareProperty("NutupleFile",m_NtupleFile= false);  // output Ntuple file 
00089   declareProperty("mDIY",_mDIY= false);  // mDIY model 
00090   declareProperty("FDPdata",m_SB3File= ""); // Fit Dalitz Plot (FDP) data file name (*.root) 
00091   declareProperty("FDPHisT",m_SB3HT= ""); // histogram title of Dalitz plot in  data file  
00092   declareProperty("FDPpart",m_FDPparticle=""); //to assign the FDP parent particle name (string)
00093 
00094   declareProperty("Psi3SopenCharm",m_Psi4040OpenCharm=false);
00095   declareProperty("statDecays",m_statDecays=false);
00096   declareProperty("TagLundCharmModel", m_tagLundModel=false);
00097 }


Member Function Documentation

void EvtDecay::assign_momentum int  pdx,
EvtVector4R  pv4
[private]
 

01121                                                       {
01122       if(id0==pdg0){son0=pd0;}
01123  else if(id0==pdg1){son1=pd0;}
01124  else if(id0==pdg2){son2=pd0;}
01125       else {std::cout<<"PID= "<<id0<<" not machted, I stop"<<std::endl; ::abort();}
01126 }

void EvtDecay::assign_momentum2 int  pdx,
EvtVector4R  pv4
[private]
 

01128                                                        { // for two identicle particle case
01129       if(id0==pdg0 && identical_flag){son0=pd0;identical_flag=false;}
01130  else if(id0==pdg1){son1=pd0;identical_flag=true;}
01131  else if(id0==pdg2){son2=pd0;}
01132       else {std::cout<<"PID not machted, I stop"<<std::endl; ::abort();}
01133 }

double EvtDecay::CalAmpsMax EvtParticle part  )  [private]
 

00900 {
00901   double amps_max=0;
00902   for(int i=0;i<100000;i++){
00903   m_Gen->generateDecay(part);
00904   double amps=CalAmpsMDIY(part);
00905   if(amps > amps_max) amps_max=amps;
00906   }
00907   amps_max=amps_max*1.05;
00908   m_ampscalflag = false;
00909   return amps_max;
00910 }

double EvtDecay::CalAmpsMDIY EvtParticle part  )  [private]
 

00039                                               {
00040 //---- read out the momentum for each particle, then using them to calculate the amplitude squared, for example:
00041 /*********** using the following decay cards ****************
00042 Decay J/psi
00043 1 gamma eta_c  PHSP;
00044 Enddecay
00045  
00046 Decay eta_c
00047 1 phi phi PHSP;
00048 Enddecay
00049  
00050 Decay phi
00051 1 K+ K- PHSP;
00052 Enddecay
00053  
00054 End
00055 */
00056 //----------------------------------
00057     EvtVector4R pjsi,petac,pphi1,pphi2,pkp1,pkp2;
00058     pjsi = part->getP4();
00059     petac= part->getDaug(1)->getP4();  //etac momentum 
00060     pphi1= part->getDaug(1)->getDaug(0)->getP4();  //phi1 momentum
00061     pphi2= part->getDaug(1)->getDaug(1)->getP4();  //phi2 momentum
00062 
00063     pkp1 = part->getDaug(1)->getDaug(0)->getDaug(0)->getP4();  //K+ from phi1 
00064     pkp2 = part->getDaug(1)->getDaug(1)->getDaug(0)->getP4();  //K+ from phi2 
00065 
00066     EvtHelSys angles0(pjsi,petac);
00067     double theta0 = angles0.getHelAng(1);
00068     double phi0   = angles0.getHelAng(2);
00069  
00070     EvtHelSys angles2(pphi1,pkp1);
00071     double theta2 = angles2.getHelAng(1);
00072     double phi2   = angles2.getHelAng(2);
00073 
00074     EvtHelSys angles3(pphi2,pkp2);
00075     double theta3 = angles3.getHelAng(1);
00076     double phi3   = angles3.getHelAng(2);
00077 
00078     double amps=(3+cos(2*theta0)) * sin(theta2)*sin(theta2) * sin(theta3)*sin(theta3) * sin(phi2+phi3)*sin(phi2+phi3);
00079 
00080 
00082     if(amps <=0){
00083     report(INFO,"EvtGen") << "Amplitude square of modified DIY should be positive, but found to be equal "<<amps<<endl;
00084     abort();
00085     } else {
00086     return amps;
00087     }
00088 }

StatusCode EvtDecay::callBesEvtGen HepMC::GenEvent *  hepMCevt  )  [private]
 

00552 {
00553   MsgStream log(messageService(), name());
00554    
00555    nchr   = -1;
00556    nchr_e = 0;
00557    nchr_mu= 0;
00558    nchr_pi= 0;
00559    nchr_k = 0;
00560    nchr_p = 0;
00561    N_gamma=0;
00562    N_gammaFSR = 0;
00563    SmartDataPtr<Event::EventHeader>  eventHeader(eventSvc(),"/Event/EventHeader");  
00564   for (int i=0;i<13;i++) fst[i]=0;
00565   HepMC::GenEvent::particle_const_iterator itp;
00566     // This is the main loop.
00567     // We iterate over particles and we look for ones that
00568     // should be decayed with EvtGen.
00569     //
00570     // status == 1     - undecayed Pythia particle (also for particles that are not supposed to decay)
00571     // status == 999   - particle already decayed by EvtGen
00572     // status == 899   - particle was supposed to decay by EvtGen - but found no model
00573     //                   this may be also intentional - such events are then excluded from
00574     //                   being written into persistent output.
00575     // ISTHEP(IHEP):
00576     // status code for entry IHEP, with the following meanings:
00577     //  
00578     //  = 0 : null entry. 
00579     //  = 1 : an existing entry, which has not decayed or fragmented. This is the main class of entries, which represents the `final state' given by the generator. 
00580     //  = 2 : an entry which has decayed or fragmented and is therefore not appearing in the final state, but is retained for event history information. 
00581     //  = 3 : a documentation line, defined separately from the event history. This could include the two incoming reacting particles, etc. 
00582     //  = 4 - 10 : undefined, but reserved for future standards. 
00583     //  = 11 - 200 : at the disposal of each model builder for constructs specific to his program, but equivalent to a null line in the context of any other program. 
00584     //  = 201 - : at the disposal of users, in particular for event tracking in the detector. 
00585 
00586  loop_to_select_eventsB:  
00587     EvtId ppid=EvtPDL::getId(m_ParentPart); //parent particle name
00588     double ppmass=EvtPDL::getMass(ppid);
00589     parentMass=ppmass;
00590     int pid=EvtPDL::getStdHep(ppid);
00591     parentPDGcode=pid;
00592 
00593     EvtVector4R p_init(ppmass,0.0,0.0,0.0);
00594  
00595     EvtParticle* part=EvtParticleFactory::particleFactory(ppid,p_init);
00596     HepMC::GenParticle* hepMCpart=new GenParticle(HepLorentzVector(0,0,0,ppmass),pid,3);
00597 
00598     bool parentFlag = false;
00599     // set spin density matrix for e+ e- -> V
00600     if(writeFlag ==0 && part->getSpinType() == EvtSpinType::VECTOR) {
00601       part->setVectorSpinDensity();
00602       parentFlag = true;
00603       writeFlag++;
00604     }
00605  
00606  // for SuperBody3decay generator
00607     EvtVector4R fdp_init;
00608     EvtId fdp_ppid;
00609     if(m_FDPparticle!=""){
00610       findPart(part);
00611       fdp_ppid = FDP_id;
00612       fdp_init = FDP_init;
00613     } else{
00614       fdp_ppid = ppid;
00615       fdp_init = p_init;
00616     }
00617 
00618     if(!(m_SB3File=="" || m_SB3HT=="") &&  first ){ SuperBody3decay_make( fdp_ppid, fdp_init);}
00619  // -----------------------------------
00620   
00621   loop_to_select_events:
00622     m_Gen->generateDecay(part);
00623 
00624     double ratio,rdm;
00625     if(_mDIY &&  m_ampscalflag ) _amps_max=CalAmpsMax(part);
00626     if(_mDIY ) {
00627     rdm=EvtRandom::Flat(0.0, 1.0);
00628     double amps=CalAmpsMDIY( part );
00629     ratio=amps/_amps_max;
00630     }
00631     if(_mDIY && ratio<=rdm) goto   loop_to_select_events;
00632 
00633 //--------- For superbody3
00634     bool accept; 
00635     if(m_FDPparticle==""){FDP_part=part;}
00636    if(!(m_SB3File=="" || m_SB3HT=="")){
00637      accept=SuperBody3decay_judge( FDP_part);
00638       }
00639    if(!(m_SB3File=="" || m_SB3HT=="") && !accept) {
00640        delete hepMCpart;
00641        part->deleteTree();
00642      goto loop_to_select_eventsB;
00643    }else  if(!(m_SB3File=="" || m_SB3HT=="") && parentFlag  && accept){
00644      countChannel(FDP_part);
00645    }
00646 
00647       int Nchannel=part->getChannel();
00648 
00649      if(m_statDecays && parentFlag) countChannel(part);
00650  //------------- dump the decay tree to the event model
00651     //     int Nchannel=part->getChannel();
00652     //     if(Nchannel>=0) part->dumpTree();
00653      
00654       if(parentFlag){
00655        EvtDecayTag theTag(part);
00656        unsigned int modeTag, multiplicityTag;
00657        modeTag = theTag.getModeTag();
00658        if(getModel(part) == "LUNDCHARM" && m_tagLundModel ){ multiplicityTag = decayType(part);} else {
00659          multiplicityTag = theTag.getMultTag() + decayType(part);
00660        }
00661        if(eventHeader == 0) std::cout << "event header unavailable: " << std::endl;
00662         if (eventHeader != 0) {
00663             eventHeader->setFlag1(modeTag);
00664             eventHeader->setFlag2(multiplicityTag);
00665         } 
00666       }
00667      
00668     if(!(m_DecayRec=="")) {mydecayrec=part->writeTreeRec(m_DecayRec);std::cout<<std::endl;};
00669  // ----------- pingrg 2008-03-25 ---------
00670 
00671     if ( log.level() <= MSG::DEBUG ) part->printTree() ;
00672     log << MSG::DEBUG << "Converting particles to HepMC" << endreq;
00673 
00674     makeHepMC(part, hepMCevt, hepMCpart);
00675 
00676     if(part->getNDaug()!=0) hepMCpart->set_status(999);  
00677 
00678     part->deleteTree();
00679 
00680     AllTrk_index=0;
00681   for( itp=hepMCevt->particles_begin(); itp!=hepMCevt->particles_end(); ++itp )   
00682   {
00683       if (!(*itp)->end_vertex() && ( (*itp)->status()==899 || (*itp)->status()==999 ))
00684         (*itp)->set_status(1);
00685       HepMC::GenParticle* hepMCpart=*itp;
00686       int stat = hepMCpart->status();
00687       int id = hepMCpart->pdg_id();
00688 
00689        if ( stat != 1 ) continue;
00690        if( id == 22 ) {N_gamma ++;fst[0]++;}
00691        if( id == -22 ){N_gammaFSR ++;}
00692   if( id == 11 ) {fst[1]++;} else if(id == -11) {fst[2]++;} 
00693                              else if(id == 13 ) {fst[3]++;} 
00694                              else if(id ==-13)  {fst[4]++;}
00695                              else if(id==211)   {fst[5]++;}
00696                              else if(id==-211)  {fst[6]++;}
00697                              else if(id== 321)  {fst[7]++;} 
00698                              else if(id ==-321) {fst[8]++;} 
00699                              else if(id ==2212) {fst[9]++;}
00700                              else if(id==-2212) {fst[10]++;} 
00701                              else if(id == 2112){fst[11]++;} 
00702                              else if(id==-2112) {fst[12]++;}
00703        if( fabs(id) == 11)   {nchr_e++;}
00704        if( fabs(id) == 13)   {nchr_mu++;}
00705        if( fabs(id) == 211)  {nchr_pi++;}
00706        if( fabs(id) == 321)  {nchr_k++;}
00707        if( fabs(id) == 2212) {nchr_p++;}
00708 
00709        //for Nuple
00710         double en =(hepMCpart->momentum()).e();
00711         double pex=(hepMCpart->momentum()).px();
00712         double pey=(hepMCpart->momentum()).py();
00713         double pez=(hepMCpart->momentum()).pz();
00714         if( m_NtupleFile==true ){
00715           Trk_index[AllTrk_index]=id;
00716           px_trk[AllTrk_index]=pex;
00717           py_trk[AllTrk_index]=pey;
00718           pz_trk[AllTrk_index]=pez;
00719           en_trk[AllTrk_index]=en ; /*
00720           std::cout<<"trk# "   <<AllTrk_index
00721                    <<" PID:"   <<id
00722                    <<" px: "   <<pex
00723                    <<" py: "   <<pey
00724                    <<" pz: "   <<pez
00725                    <<" E:  "   <<en<<std::endl;*/
00726          AllTrk_index++;
00727          Trk_index[AllTrk_index]=0;
00728         }
00729   } 
00730 
00731   itp=hepMCevt->particles_begin(); // parent decaying particle status set
00732     (*itp)->set_status(2);
00733 
00734   nchr = nchr_e + nchr_mu + nchr_pi + nchr_k +nchr_p;
00735   if(m_Ncharge == true ) {std::cout<<"MultiplicityTotoalCharge_e_mu_pi_K_p_gamma_gammaFSR: "
00736                                    <<nchr<<" "
00737                                    <<nchr_e<<" "
00738                                    << nchr_mu <<" "
00739                                    << nchr_pi <<" "
00740                                    << nchr_k <<" "
00741                                    <<nchr_p<<" "
00742                                    <<N_gamma<<" "
00743                                    <<N_gammaFSR<<endl;}   
00744   if(m_Ncharge == true  ){std::cout<<"FinalStates: "
00745                                   <<fst[0]<<" "
00746                                   <<fst[1]<<" "
00747                                   <<fst[2]<<" "
00748                                   <<fst[3]<<" "
00749                                   <<fst[4]<<" "
00750                                   <<fst[5]<<" "
00751                                   <<fst[6]<<" "
00752                                   <<fst[7]<<" "
00753                                   <<fst[8]<<" "
00754                                   <<fst[9]<<" "
00755                                   <<fst[10]<<" "
00756                                   <<fst[11]<<" "
00757                                   <<fst[12]<<std::endl;}  
00758 
00759    if( m_NtupleFile ){ 
00760     TotNumTrk=50;  
00761     m_nchr   = nchr;
00762     m_nchr_e = nchr_e;
00763     m_nchr_mu = nchr_mu;
00764     m_nchr_pi = nchr_pi;
00765     m_nchr_k = nchr_k;
00766     m_nchr_p = nchr_p;
00767     m_gamma=N_gamma;
00768     m_gammaFSR=N_gammaFSR;
00769     for(int i=0;i<=50;i++){
00770       if(Trk_index[i] == 0) break;
00771       m_Trk_index[i] = Trk_index[i];
00772       m_fst[i]       = fst[i];
00773       m_px_trk[i]    = px_trk[i];
00774       m_py_trk[i]    = py_trk[i];
00775       m_pz_trk[i]    = pz_trk[i];
00776       m_en_trk[i]    = en_trk[i];
00777     }
00778     m_tuple->write();
00779    }
00780    //std::cout<<"Flag= "<<eventHeader->flag1()<<"  "<<eventHeader->flag2()<<std::endl;
00781    return StatusCode::SUCCESS;
00782 }

StatusCode EvtDecay::callEvtGen HepMC::GenEvent *  hepMCevt  )  [private]
 

00308 {
00309   MsgStream log(messageService(), name());
00310    nchr   = 0;
00311    nchr_e = 0;
00312    nchr_mu= 0;
00313    nchr_pi= 0;
00314    nchr_k = 0;
00315    nchr_p = 0;
00316    N_gamma=0;
00317    N_gammaFSR = 0;
00318    SmartDataPtr<Event::EventHeader>  eventHeader(eventSvc(),"/Event/EventHeader");
00319   
00320   for (int i=0;i<13;i++) fst[i]=0;
00321   HepMC::GenEvent::particle_const_iterator itp;
00322   AllTrk_index=0;
00323   for( itp=hepMCevt->particles_begin(); itp!=hepMCevt->particles_end(); ++itp )   
00324   {
00325     // This is the main loop.
00326     // We iterate over particles and we look for ones that
00327     // should be decayed with EvtGen.
00328     //
00329     // status == 1     - undecayed Pythia particle (also for particles that are not supposed to decay)
00330     // status == 999   - particle already decayed by EvtGen
00331     // status == 899   - particle was supposed to decay by EvtGen - but found no model
00332     //                   this may be also intentional - such events are then excluded from
00333     //                   being written into persistent output.
00334     // ISTHEP(IHEP):
00335     // status code for entry IHEP, with the following meanings:
00336     //  
00337     //  = 0 : null entry. 
00338     //  = 1 : an existing entry, which has not decayed or fragmented. This is the main class of entries, which represents the `final state' given by the generator. 
00339     //  = 2 : an entry which has decayed or fragmented and is therefore not appearing in the final state, but is retained for event history information. 
00340     //  = 3 : a documentation line, defined separately from the event history. This could include the two incoming reacting particles, etc. 
00341     //  = 4 - 10 : undefined, but reserved for future standards. 
00342     //  = 11 - 200 : at the disposal of each model builder for constructs specific to his program, but equivalent to a null line in the context of any other program. 
00343     //  = 201 - : at the disposal of users, in particular for event tracking in the detector. 
00344 
00345     HepMC::GenParticle* hepMCpart=*itp;
00346     int stat = hepMCpart->status();
00347 
00348 
00349     if ( stat != 1 ) continue;
00350 
00351   loop_to_select_eventsB:
00352     int id = hepMCpart->pdg_id();
00353     parentPDGcode=id;
00354     hepMCpart->set_status(899);
00355     EvtId eid=EvtPDL::evtIdFromStdHep(id);
00356     string parentName=EvtPDL::name(eid);
00357     
00358     double en =(hepMCpart->momentum()).e();
00359     double pex=(hepMCpart->momentum()).px();
00360     double pey=(hepMCpart->momentum()).py();
00361     double pez=(hepMCpart->momentum()).pz();
00362         
00363     EvtVector4R p_init(en,pex,pey,pez);
00364     parentMass=p_init.mass();
00365 
00366     EvtParticle* part=EvtParticleFactory::particleFactory(eid,p_init);
00367     // set spin density matrix for e+ e- -> V
00368     bool parentFlag=false;
00369     if(  writeFlag==0 && part->getSpinType() == EvtSpinType::VECTOR) {
00370       part->setVectorSpinDensity();
00371       parentFlag=true;
00372       writeFlag++;
00373      } else {
00374          int id = hepMCpart->pdg_id();
00375         if( id == 22 ) {N_gamma ++;fst[0]++;}  //fst[0]:photon
00376         if( id == -22 ){N_gammaFSR ++;}
00377         if( id == 11 ) {fst[1]++;} else if(id == -11){fst[2]++;} // fst[1]: electron  ; fst[]: positron
00378                                    else if(id ==  13){fst[3]++;} // fst[3]: mu-
00379                                    else if(id == -13){fst[4]++;} // fst[4]: mu+
00380                                    else if(id == 211){fst[5]++;} // fst[5]: pi+
00381                                    else if(id ==-211){fst[6]++;} // fst[6]: pi-
00382                                    else if(id == 321){fst[7]++;} // fst[7]: K+
00383                                    else if(id ==-321){fst[8]++;} // fst[8]: K-
00384                                    else if(id ==2212){fst[9]++;} // fst[9]: pronton
00385                                    else if(id ==-2212){fst[10]++;} // fst[10]: anti-proton
00386                                    else if(id == 2112){fst[11]++;} // fst[11]: nucleon
00387                                    else if(id ==-2112){fst[12]++;} // fst[12]: ant-nucleon
00388         if( fabs(id) == 11)   {nchr_e++;}
00389         if( fabs(id) == 13)   {nchr_mu++;}
00390         if( fabs(id) == 211)  {nchr_pi++;}
00391         if( fabs(id) == 321)  {nchr_k++;}
00392         if( fabs(id) == 2212) {nchr_p++;}
00393         
00394         if( m_NtupleFile==true ){
00395           Trk_index[AllTrk_index]=id;
00396           px_trk[AllTrk_index]=pex;
00397           py_trk[AllTrk_index]=pey;
00398           pz_trk[AllTrk_index]=pez;
00399           en_trk[AllTrk_index]=en ;
00400 
00401          AllTrk_index++;
00402          Trk_index[AllTrk_index]=0;
00403         }
00404 
00405         
00406     } 
00407 
00408  // for SuperBody3decay generator
00409  //    EvtVector4R pd1,pd2,pd3;
00410     EvtVector4R fdp_init;
00411     EvtId fdp_ppid;
00412     if(m_FDPparticle!=""){
00413       findPart(part);
00414       fdp_ppid = FDP_id;
00415       fdp_init = FDP_init;
00416     } else{
00417       fdp_ppid = eid;
00418       fdp_init = p_init;
00419     }
00420 
00421     if(!(m_SB3File=="" || m_SB3HT=="") && parentFlag &&  first ){
00422       SuperBody3decay_make(fdp_ppid, fdp_init );
00423      }
00424 
00425   loop_to_select_eventsA:
00426     m_Gen->generateDecay(part);
00427     
00428     double ratio,rdm;
00429     if(_mDIY && parentFlag &&  m_ampscalflag ) _amps_max=CalAmpsMax(part);
00430     if(_mDIY && parentFlag) {
00431     rdm=EvtRandom::Flat(0.0, 1.0);
00432     double amps=CalAmpsMDIY( part );
00433     ratio=amps/_amps_max;
00434     }
00435     if(_mDIY && parentFlag && ratio<=rdm){ goto   loop_to_select_eventsA;}
00436     
00437     //-------- For superbody3------------------------------
00438     bool accept; 
00439    if(m_FDPparticle==""){FDP_part=part;}
00440    if(!(m_SB3File=="" || m_SB3HT=="") && parentFlag            ){ accept=SuperBody3decay_judge(  FDP_part); }
00441    if(!(m_SB3File=="" || m_SB3HT=="") && parentFlag  && !accept){ 
00442      part->deleteTree();
00443      writeFlag=0;
00444      goto loop_to_select_eventsB; 
00445    }else if(!(m_SB3File=="" || m_SB3HT=="") && parentFlag  && accept){
00446      countChannel(FDP_part);
00447    }
00448    //-------- for psi4040 open charm inclusive decay
00449    if(m_Psi4040OpenCharm && parentFlag ){
00450      EvtPsi3Sdecay opencharm(en, part);
00451      bool theDecay = opencharm.choseDecay();
00452      if(!theDecay ) {
00453      part->deleteTree();
00454      writeFlag=0;
00455      goto loop_to_select_eventsB;
00456      }
00457    }
00458     //------------- dump the decay tree to the event model
00459       // if(Nchannel>=0) part->dumpTree();
00460       // if(Nchannel>=0) part->printTree();
00461    
00462       if(parentFlag){
00463        EvtDecayTag theTag(part);
00464        unsigned int modeTag, multiplicityTag;
00465        modeTag = theTag.getModeTag();
00466        if(getModel(part) == "LUNDCHARM" && m_tagLundModel){ multiplicityTag = decayType(part);} else {
00467          multiplicityTag = theTag.getMultTag() + decayType(part);
00468        }
00469       
00470        //  std::cout<<"StdHep= "<<EvtPDL::getStdHep(part->getId())<<" getChannel "<<part->getChannel()<<" flag1,flag2= "<<modeTag<<" "<<multiplicityTag<<std::endl;
00471        if(eventHeader == 0) std::cout << "event header unavailable: " << std::endl;
00472         if (eventHeader != 0) {
00473             eventHeader->setFlag1(modeTag);
00474             eventHeader->setFlag2(multiplicityTag);
00475             //      std::cout<<"flag1,flag2= "<<modeTag<<" "<<multiplicityTag<<std::endl;
00476         } 
00477       }
00478    
00479      if(!(m_DecayRec=="")) mydecayrec=part->writeTreeRec(m_DecayRec);
00480     //-- decay statistics
00481      if(m_statDecays && parentFlag ) countChannel(part);
00482     // ----------- pingrg 2008-03-25 ---------
00483 
00484     if ( log.level() <= MSG::DEBUG ) part->printTree() ;
00485     log << MSG::DEBUG << "Converting particles to HepMC" << endreq;
00486 
00487     makeHepMC(part, hepMCevt, hepMCpart);
00488     if(part->getNDaug()!=0)  
00489         hepMCpart->set_status(999);  
00490 
00491     part->deleteTree();
00492   };
00493 
00494   for( itp=hepMCevt->particles_begin(); itp!=hepMCevt->particles_end(); ++itp )   
00495   {
00496       if (!(*itp)->end_vertex() && ( (*itp)->status()==899 || (*itp)->status()==999 ))
00497         (*itp)->set_status(1);
00498   } 
00499   nchr = nchr_e + nchr_mu + nchr_pi + nchr_k +nchr_p;
00500   if(m_Ncharge == true ) {std::cout<<"MultiplicityTotoalCharge_e_mu_pi_K_p_gamma_gammaFSR: "
00501                                    <<nchr     <<" "
00502                                    <<nchr_e   <<" "
00503                                    << nchr_mu <<" "
00504                                    << nchr_pi <<" "
00505                                    << nchr_k  <<" "
00506                                    <<nchr_p   <<" "
00507                                    <<N_gamma  <<" "
00508                                    <<N_gammaFSR<<endl;} 
00509   if(m_Ncharge == true  ){std::cout<<"FinalStates: "
00510                                   <<fst[0]<<" "
00511                                   <<fst[1]<<" "
00512                                   <<fst[2]<<" "
00513                                   <<fst[3]<<" "
00514                                   <<fst[4]<<" "
00515                                   <<fst[5]<<" "
00516                                   <<fst[6]<<" "
00517                                   <<fst[7]<<" "
00518                                   <<fst[8]<<" "
00519                                   <<fst[9]<<" "
00520                                   <<fst[10]<<" "
00521                                   <<fst[11]<<" "
00522                                   <<fst[12]<<std::endl;}   
00523    if( m_NtupleFile ){ 
00524     TotNumTrk=50;  
00525     m_nchr   = nchr;
00526     m_nchr_e = nchr_e;
00527     m_nchr_mu = nchr_mu;
00528     m_nchr_pi = nchr_pi;
00529     m_nchr_k = nchr_k;
00530     m_nchr_p = nchr_p;
00531     m_gamma=N_gamma;
00532     m_gammaFSR=N_gammaFSR;
00533     for(int i=0;i<=50;i++){
00534       if(Trk_index[i] == 0) break;
00535       m_Trk_index[i] = Trk_index[i];
00536       m_fst[i]       = fst[i];
00537       m_px_trk[i]    = px_trk[i];
00538       m_py_trk[i]    = py_trk[i];
00539       m_pz_trk[i]    = pz_trk[i];
00540       m_en_trk[i]    = en_trk[i];
00541     }
00542     m_tuple->write();
00543    }
00544    //   std::cout<<"Flag= "<<eventHeader->flag1()<<"  "<<eventHeader->flag2()<<std::endl;
00545   return StatusCode::SUCCESS;
00546 }

void EvtDecay::countChannel EvtParticle part  )  [private]
 

01159                                             {
01160   int ich=part->getChannel();
01161   //std::cout<<"the channel is "<<ich<<std::endl;
01162   br[ich]++;
01163   if(ich>totalChannels) totalChannels = ich;
01164   //std::cout<<"EVENT IN br_i "<<br[ich]<<std::endl;
01165 }

int EvtDecay::decayType EvtParticle par  )  [private]
 

01256                                        {
01257  /*************************************
01258   * 0: gamma light_hadrons
01259   * 1: gamma charmonium
01260   * 2: DDbar (D0 D0bar or D+D-)
01261   * 3: ligh_hadrons
01262   * 4: others
01263   *************************************/
01264   int Nchannel=par->getChannel();
01265   int ndg = par->getNDaug();
01266   int nfsr=0;
01267 
01268   std::string model = getModel(par,Nchannel);
01269   if(model == "LUNDCHARM" && m_tagLundModel){ // lundcharm model tag
01270     int ldm = par->getGeneratorFlag();
01271     // std::cout<<"LundCharmFlag = "<<ldm<<std::endl;
01272     return ldm;
01273   }
01274 
01275   for(int i=0;i<ndg;i++){ //remove the FSR photon
01276     EvtId xid =par->getDaug(i)->getId(); 
01277     if(EvtPDL::getStdHep(xid) == -22 ){nfsr++;}
01278       }
01279 
01280   if( isRadecay(par) ){
01281     for(int i=0;i<ndg;i++){
01282       EvtId xid = par->getDaug(i)->getId();
01283       if( isCharmonium(xid) ) return 1;
01284       }
01285     return 0;
01286   } else{
01287     if(ndg-nfsr ==2 ){
01288     int ndg = par->getNDaug();
01289       EvtId xd1 = par->getDaug(0)->getId();
01290       EvtId xd2 = par->getDaug(1)->getId();
01291       if( isCharm(xd1) && isCharm(xd2) ) {return 2;} else 
01292       if( !isCharmonium(xd1) && !isCharmonium(xd2) && !isCharm(xd1) && !isCharm(xd2) ){
01293         return 3;
01294       }
01295     } else{  // ndg>=3
01296       bool flag = false;
01297       for(int i=0;i<ndg;i++){
01298         EvtId xid = par->getDaug(i)->getId();
01299         if( isCharmonium(xid) ) {flag = true; break;}
01300         if( isCharm(xid)      ) {flag = true; break;}
01301       } // for_i block
01302       if( !flag ){return 3;} else {return 4;}
01303     }// if_ndg block
01304   }  
01305  
01306 }

StatusCode EvtDecay::execute  ) 
 

00256 { 
00257 
00258   MsgStream log(messageService(), name());
00259   // log << MSG::INFO << "EvtDecay executing" << endreq;
00260   //------------------
00261   string   key = "GEN_EVENT";
00262   // retrieve event from Transient Store (Storegate)
00263   SmartDataPtr<McGenEventCol> McEvtColl(eventSvc(), "/Event/Gen");      
00264 
00265   m_numberEvent += 1;  
00266   writeFlag = 0;
00267   //std::cout<<"EvtNumber= "<<m_numberEvent<<std::endl;
00268   if ( McEvtColl == 0 ) 
00269   {
00270     HepMC::GenEvent* evt=new GenEvent();  
00271     evt->set_event_number(m_numberEvent);
00272     callBesEvtGen( evt );
00273     if(!(m_DecayTop==""))  evt->print(outfile);  
00274 
00275     //create a Transient store 
00276     McGenEventCol *mcColl = new McGenEventCol;
00277     McGenEvent* mcEvent = new McGenEvent(evt);
00278     mcColl->push_back(mcEvent);
00279     StatusCode sc = eventSvc()->registerObject("/Event/Gen",mcColl);
00280     if(sc != SUCCESS)  return StatusCode::FAILURE;    
00281 
00282   } else  //  (McEvtColl != 0) 
00283  {
00284   McGenEventCol::iterator mcItr;
00285   for( mcItr = McEvtColl->begin(); mcItr != McEvtColl->end(); mcItr++ )   
00286   {
00287      HepMC::GenEvent* hEvt = (*mcItr)->getGenEvt();
00288     // MeVToGeV( hEvt );
00289 
00290      callEvtGen( hEvt );
00291 
00292      if(!(m_DecayTop==""))  hEvt->print(outfile); 
00293     // GeVToMeV( hEvt );
00294      //   if(!(m_DecayRec=="")) outfile2<<std::endl;
00295   if(!(m_DecayRec=="")) std::cout<<std::endl;
00296   };
00297  }
00298        
00299   return StatusCode::SUCCESS; 
00300 }

StatusCode EvtDecay::finalize  ) 
 

00786 {
00787   MsgStream log(messageService(), name());
00788 
00789   log << MSG::INFO << "EvtDecay finalized" << endreq;
00790    fstream Forfile;
00791    Forfile.open("fort.16",ios::in);
00792    char delcmd[300];
00793    strcpy(delcmd,"rm -f ");
00794    strcat(delcmd,"fort.16");
00795    if(Forfile)system(delcmd);
00796 
00797    fstream Forfile2;
00798    Forfile2.open("fort.22",ios::in);
00799    strcpy(delcmd,"rm -f ");
00800    strcat(delcmd,"fort.22");
00801    if(Forfile2)system(delcmd);
00802 
00803    //   To get the branching fraction of the specified mode in Lundcharm Model
00804    /*    
00805    EvtLundCharm lundcharmEvt;
00806    int nevt=lundcharmEvt.getTotalEvt();
00807    std::cout<<"The total number of the specified mode is  "<<nevt<<std::endl;
00808    */ 
00809    int totalEvt=0;
00810    if(!(m_SB3File=="" || m_SB3HT=="")){
00811    for(int i=0;i<500;i++){totalEvt=totalEvt+br[i];}
00812    for(int i=0;i<500;i++){
00813      double bi=1.0*br[i]/totalEvt;
00814      std::cout<<"Branching fraction of channel "<<i<<" is: "<<bi<<std::endl;
00815      if(br[i]==0) break;
00816    }
00817    }
00818 
00819    if(m_statDecays){
00820      int totalEvt=0;
00821      for(int i=0;i<=totalChannels;i++){totalEvt=totalEvt+br[i];}
00822      std::cout<<"==================Statistical first chain decay ==============================="<<std::endl;
00823      std::cout<<"i-th channel      Events Generated         Branching fraction generated        "<<std::endl;
00824      for(int i=0;i<=totalChannels;i++){
00825       std::cout<<"|  "<<i<<"              "<<br[i]<<"                        "<<br[i]*1.0/totalEvt<<std::endl;      
00826 
00827      }
00828      std::cout<<"--------------------------------------------------------------------------------"<<std::endl;
00829      std::cout<<"  sum:            "<<totalEvt<<"                     "<<"1"<<std::endl;
00830      std::cout<<"================== End of statistical first chain decay ========================"<<std::endl;
00831    }
00832 
00833   return StatusCode::SUCCESS;
00834 }

void EvtDecay::FinalState_make EvtId  ppid,
EvtVector4R  p_init
[private]
 

01026                                                               {
01027   // get the final state pdg cond and count the identicle particle
01028   multi=1;
01029   identical_flag=true;
01030 
01031   for(int i=1;i<10000;i++){ //sigle out the final state
01032    EvtParticle* part=EvtParticleFactory::particleFactory(ppid,p_init);
01033    HepMC::GenParticle* hepMCpart=new GenParticle(HepLorentzVector(0,0,0,parentMass),parentPDGcode,3); 
01034 
01035    m_Gen->generateDecay(part);
01036    int nson=part->getNDaug();
01037 
01038    if(nson == 2) {continue;} else 
01039    if(nson ==3){
01040    EvtId xid0,xid1,xid2;
01041    xid0=part->getDaug(0)->getId();
01042    xid1=part->getDaug(1)->getId();
01043    xid2=part->getDaug(2)->getId();
01044    
01045 //-- pdg code 
01046    pdg0=EvtPDL::getStdHep(xid0);
01047    pdg1=EvtPDL::getStdHep(xid1);
01048    pdg2=EvtPDL::getStdHep(xid2);
01049 
01050    if(pdg0==pdg1 && pdg1==pdg2) {multi=3;} 
01051    else if(pdg0==pdg1 ){multi=2;}  // two identical particle list as 0,1 index
01052    else if(pdg0==pdg2 ){multi=2;pdg=pdg1; pdg1=pdg2; pdg2=pdg;} 
01053    else if(pdg1==pdg2) {multi=2;pdg=pdg0; pdg0=pdg1; pdg1=pdg2; pdg2=pdg;} 
01054    else {multi=1;}
01055    break;
01056    } else{
01057      std::cout<<"No direct three body decay channel found in decay card, I stop run"<<std::endl;
01058      ::abort();
01059    }   
01060   }
01061   //  std::cout<<"pdg_i "<<pdg0<<" "<<pdg1<<" "<<pdg2<<std::endl;
01062   //  std::cout<<"identical particle "<<multi<<std::endl;
01063 }

void EvtDecay::FinalState_sort EvtParticle part  )  [private]
 

01065                                                {
01066   // sort the momentum to aon0, son1, son2
01067    EvtVector4R pd0,pd1,pd2;
01068    EvtId xid0,xid1,xid2;
01069    int id0,id1,id2;
01070 
01071     int nson=part->getNDaug();
01072     if(nson==2){
01073       pd0=part->getDaug(0)->getP4Lab();
01074       pd1=part->getDaug(1)->getDaug(0)->getP4Lab();
01075       pd2=part->getDaug(1)->getDaug(1)->getP4Lab();
01076 
01077       xid0=part->getDaug(0)->getId();
01078       xid1=part->getDaug(1)->getDaug(0)->getId();
01079       xid2=part->getDaug(1)->getDaug(1)->getId();        
01080 
01081      } else if(nson==3){
01082       pd0=part->getDaug(0)->getP4Lab();
01083       pd1=part->getDaug(1)->getP4Lab();
01084       pd2=part->getDaug(2)->getP4Lab();
01085 
01086       xid0=part->getDaug(0)->getId();
01087       xid1=part->getDaug(1)->getId();
01088       xid2=part->getDaug(2)->getId();
01089      }
01090       //-- pdg code
01091       id0=EvtPDL::getStdHep(xid0);
01092       id1=EvtPDL::getStdHep(xid1);
01093       id2=EvtPDL::getStdHep(xid2);
01094 
01095       //      std::cout<<"pid before match: "<<id0<<" "<<id1<<" "<<id2<<std::endl; 
01096       //-- assign sons momentum
01097       if(multi==1){
01098         assign_momentum(id0,pd0);
01099         assign_momentum(id1,pd1);
01100         assign_momentum(id2,pd2);
01101       } else if(multi==2){
01102         assign_momentum2(id0,pd0);
01103         assign_momentum2(id1,pd1);
01104         assign_momentum2(id2,pd2);
01105        if(son0.get(0)>son1.get(0)){son=son0;son0=son1;son1=son;} // change into E_0 < E_1
01106       } else if(multi==3){    // sort sons according to energy E_0 < E_1 < E_2
01107         double En0=pd0.get(0);
01108         double En1=pd1.get(0);
01109         double En2=pd2.get(0);
01110         if(En0 < En1 && En1 < En2) {son0=pd0;son1=pd1;son2=pd2;}
01111         if(En0 < En2 && En2 < En1) {son0=pd0;son1=pd2;son2=pd1;}
01112         if(En1 < En0 && En0 < En2) {son0=pd1;son1=pd0;son2=pd2;}
01113         if(En1 < En2 && En2 < En0) {son0=pd1;son1=pd2;son2=pd0;}
01114         if(En2 < En0 && En0 < En1) {son0=pd2;son1=pd0;son2=pd1;}
01115         if(En2 < En1 && En1 < En0) {son0=pd2;son1=pd1;son2=pd0;}
01116       }
01117  
01118 }

void EvtDecay::findPart EvtParticle part  )  [private]
 

01135                                         {
01136   FDP_id=EvtPDL::getId(m_FDPparticle);
01137   int FDP_pdg=EvtPDL::getStdHep(FDP_id);
01138 
01139   m_Gen->generateDecay(part);
01140   int dn=part->getNDaug();
01141 
01142   if(dn!=0){
01143     for(int i=0;i<dn;i++){
01144       EvtParticle* part1=part->getDaug(i);
01145       EvtId sonid=part1->getId();
01146       int son_pdg = EvtPDL::getStdHep(sonid);
01147       if(son_pdg == FDP_pdg){
01148         FDP_init=part1->getP4Lab();
01149         FDP_part=part1;
01150         return;
01151       } else{
01152       findPart(part1);
01153       }
01154     }
01155   } //if (dn block
01156 
01157 }

std::string EvtDecay::getModel EvtParticle par  )  [private]
 

01314                                             {
01315   int mode = par->getChannel();
01316   EvtDecayBase* thedecay = EvtDecayTable::gettheDecay(par->getId(),mode);
01317   return thedecay->getModelName();
01318 }

std::string EvtDecay::getModel EvtParticle par,
int  mode
[private]
 

01309                                                       {
01310   EvtDecayBase* thedecay = EvtDecayTable::gettheDecay(par->getId(),mode);
01311   return thedecay->getModelName();
01312 }

void EvtDecay::GeVToMeV HepMC::GenEvent *  hepMCevt  )  [private]
 

00891 {
00892   for ( HepMC::GenEvent::particle_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p ) {
00893     //              cout << " PDG, BAR " << (*p)->pdg_id() << " " << (*p)->barcode() << endl;
00894     (*p)->set_momentum( (*p)->momentum() * 1000. );
00895   }
00896 }

StatusCode EvtDecay::initialize  ) 
 

00100                                {
00101 
00102   MsgStream log(messageService(), name());
00103   
00104   log << MSG::INFO << "EvtDecay initialize" << endreq;
00105   static const bool CREATEIFNOTTHERE(true);
00106   StatusCode RndmStatus = service("BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE);
00107   if (!RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc)
00108   {
00109     log << MSG::ERROR << " Could not initialize Random Number Service" << endreq;
00110     return RndmStatus;
00111   }
00112 
00113   m_numberEvent=0; 
00114   first = true; 
00115   m_ampscalflag = true;
00116   // Save the random number seeds in the event
00117   HepRandomEngine* engine  = p_BesRndmGenSvc->GetEngine("EVTGEN");
00118   const long    s  = engine->getSeed();
00119   p_BesRndmGenSvc->setGenseed(s+1);
00120 
00121   m_seeds.clear();
00122   m_seeds.push_back(s);
00123   totalChannels = 0;
00124 
00125  // open an interface to EvtGen
00126 
00127   if ( m_DecayDec == "") {  //use default DECAY.DEC and pdt.table if not defined by user
00128    m_DecayDec=getenv("BESEVTGENROOT");
00129    m_DecayDec +="/share/DECAY.DEC";
00130    }
00131 
00132   if ( m_PdtTable == "") {
00133    m_PdtTable =getenv("BESEVTGENROOT");
00134    m_PdtTable +="/share/pdt.table";
00135    }  
00136 
00137   char catcmd[300];  //output user decay cards to log file
00138   std::cout<<"===================== user decay card ========================"<<std::endl;
00139   strcpy(catcmd, "cat ");
00140   strcat(catcmd, userDecFileName.c_str());
00141   system(catcmd);
00142   
00143   // write decay cards to the root file: pingrg@2009-09-09
00144   StatusCode status;
00145   status = service("DataInfoSvc",tmpInfoSvc);
00146   if (status.isSuccess()) {
00147     log << MSG::INFO << "got the DataInfoSvc" << endreq;
00148     dataInfoSvc=dynamic_cast<DataInfoSvc *>(tmpInfoSvc);
00149     dataInfoSvc->setDecayCard(userDecFileName);
00150   } else { 
00151     log << MSG::ERROR << "could not get the DataInfoSvc" << endreq;
00152     return StatusCode::FAILURE;
00153   }
00154 
00155   
00156 
00157   m_RandomEngine  = new EvtBesRandom(engine);
00158   m_Gen = new EvtGen( m_DecayDec.c_str(), m_PdtTable.c_str(), m_RandomEngine );
00159       
00160   if(userDecFileName =="NONE")  log << MSG::INFO << "EvtDecay User did not define his Decay table EvtGen will use standart" << endreq;   
00161   if(!(userDecFileName =="NONE")) m_Gen->readUDecay(userDecFileName.c_str());
00162 
00163  if(!(m_DecayTop==" ")) {
00164    outfile.open(m_DecayTop.c_str()); 
00165   }
00166 
00167  //for output Ntuple file, pingrg-2009-09-07
00168 
00169 
00170   if(m_NtupleFile) {
00171        NTuplePtr nt1(ntupleSvc(),"MYROOTFILE/Trk");
00172        if(nt1) {m_tuple=nt1;}
00173        else {
00174           m_tuple = ntupleSvc()->book ("MYROOTFILE/Trk", CLID_ColumnWiseTuple, "Generator-trk-Ntuple");
00175           if(m_tuple){
00176           status = m_tuple->addItem ("TotNumTrk", TotNumTrk, 0,100);
00177           status = m_tuple->addIndexedItem ("Trk_index", TotNumTrk, m_Trk_index);    
00178           status = m_tuple->addIndexedItem ("m_px_trk",  TotNumTrk, m_px_trk); 
00179           status = m_tuple->addIndexedItem ("m_py_trk",  TotNumTrk, m_py_trk); 
00180           status = m_tuple->addIndexedItem ("m_pz_trk",  TotNumTrk, m_pz_trk); 
00181           status = m_tuple->addIndexedItem ("m_en_trk",  TotNumTrk, m_en_trk); 
00182           status = m_tuple->addIndexedItem ("FST",       TotNumTrk, m_fst); 
00183 
00184           status = m_tuple->addItem ("nchr",     m_nchr); 
00185           status = m_tuple->addItem ("nchr_e",   m_nchr_e); 
00186           status = m_tuple->addItem ("nchr_mu",  m_nchr_mu); 
00187           status = m_tuple->addItem ("nchr_pi",  m_nchr_pi); 
00188           status = m_tuple->addItem ("nchr_k",   m_nchr_k); 
00189           status = m_tuple->addItem ("nchr_p",   m_nchr_p); 
00190           status = m_tuple->addItem ("N_gamma",  m_gamma);
00191           status = m_tuple->addItem ("N_gammaFSR",  m_gammaFSR); 
00192           } else {   
00193                    log << MSG::ERROR << "    Cannot book N-tuple:"<< long(m_tuple) << endmsg;  
00194                    return StatusCode::FAILURE;
00195           }    
00196        }
00197 
00198        NTuplePtr nt2(ntupleSvc(),"MYROOTFILE/mass");
00199        if(nt2) {mass_tuple=nt2;}
00200        else {
00201           mass_tuple = ntupleSvc()->book ("MYROOTFILE/mass", CLID_ColumnWiseTuple, "Generator-mass-Ntuple");
00202           if(mass_tuple){
00203           status = mass_tuple->addItem ("m12", m_m12);
00204           status = mass_tuple->addItem ("m13", m_m13);
00205           status = mass_tuple->addItem ("m23", m_m23);
00206           status = mass_tuple->addItem ("m1", m_m1);
00207           status = mass_tuple->addItem ("m2", m_m2);
00208           status = mass_tuple->addItem ("m3", m_m3);
00209           status = mass_tuple->addItem ("costheta1", m_cos1);
00210           status = mass_tuple->addItem ("costheta2", m_cos2);
00211           status = mass_tuple->addItem ("costheta3", m_cos3);
00212           status = mass_tuple->addItem ("ichannel", m_ich);
00213           } else {   
00214                    log << MSG::ERROR << "    Cannot book N-tuple:"<< long(m_tuple) << endmsg;  
00215                    return StatusCode::FAILURE;
00216           }    
00217        }
00218 
00219        NTuplePtr nt3(ntupleSvc(),"MYROOTFILE/massGen");
00220        if(nt3) {massgen_tuple=nt3;}
00221        else {
00222           massgen_tuple = ntupleSvc()->book ("MYROOTFILE/massGen", CLID_ColumnWiseTuple, "Generator-mass-Ntuple");
00223           if(massgen_tuple){
00224           status = massgen_tuple->addItem ("m12", _m12);
00225           status = massgen_tuple->addItem ("m13", _m13);
00226           status = massgen_tuple->addItem ("m23", _m23);
00227           status = massgen_tuple->addItem ("m1", _m1);
00228           status = massgen_tuple->addItem ("m2", _m2);
00229           status = massgen_tuple->addItem ("m3", _m3);
00230           status = massgen_tuple->addItem ("costheta1", _cos1);
00231           status = massgen_tuple->addItem ("costheta2", _cos2);
00232           status = massgen_tuple->addItem ("costheta3", _cos3);
00233           status = massgen_tuple->addItem ("ichannel", _ich);
00234           } else {   
00235                    log << MSG::ERROR << "    Cannot book N-tuple:"<< long(m_tuple) << endmsg;  
00236                    return StatusCode::FAILURE;
00237           }    
00238        }
00239 
00240 
00241   }
00242   for(int i=0;i<500;i++){br[i]=0;}
00243   if(!(m_SB3File=="" && m_SB3HT=="")) {
00244     const char *filename, *histitle;
00245     filename=(char*)m_SB3File.c_str();
00246     histitle=(char*)m_SB3HT.c_str();
00247     SuperBody3decay.setFile(filename);
00248     SuperBody3decay.setHTitle(histitle);
00249     SuperBody3decay.init();
00250   }
00251 
00252   return StatusCode::SUCCESS;
00253 }

bool EvtDecay::isCharm EvtId  xid  )  [private]
 

01206                                {
01207 EvtId d0    = EvtPDL::getId(std::string("D0"));
01208 EvtId d0bar = EvtPDL::getId(std::string("anti-D0"));
01209 EvtId dp    = EvtPDL::getId(std::string("D+"));
01210 EvtId dm    = EvtPDL::getId(std::string("D-"));
01211 EvtId d0h   = EvtPDL::getId(std::string("D0H"));
01212 EvtId d0l    = EvtPDL::getId(std::string("D0L"));
01213 EvtId dstp   = EvtPDL::getId(std::string("D*+"));
01214 EvtId dstm   = EvtPDL::getId(std::string("D*-"));
01215 EvtId ds0    = EvtPDL::getId(std::string("D*0"));
01216 EvtId ds0bar = EvtPDL::getId(std::string("anti-D*0"));
01217 EvtId dsp    = EvtPDL::getId(std::string("D_s+"));
01218 EvtId dsm    = EvtPDL::getId(std::string("D_s-"));
01219 EvtId dsstp  = EvtPDL::getId(std::string("D_s*+"));
01220 EvtId dsstm  = EvtPDL::getId(std::string("D_s*-"));
01221 EvtId ds0stp = EvtPDL::getId(std::string("D_s0*+"));
01222 EvtId ds0stm = EvtPDL::getId(std::string("D_s0*-"));
01223 
01224  std::vector<EvtId> Vid; Vid.clear();
01225  Vid.push_back(d0);
01226  Vid.push_back(d0bar);
01227  Vid.push_back(dp);
01228  Vid.push_back(dm);
01229  Vid.push_back(d0h);
01230  Vid.push_back(d0l);
01231  Vid.push_back(dstp);
01232  Vid.push_back(dstm);
01233  Vid.push_back(ds0);
01234  Vid.push_back(ds0bar );
01235  Vid.push_back(dsp );
01236  Vid.push_back(dsm );
01237  Vid.push_back(dsstp );
01238  Vid.push_back(dsstm );
01239  Vid.push_back(ds0stp );
01240  Vid.push_back(ds0stm );
01241 
01242  bool flag=true;
01243  for(int i=0;i<Vid.size();i++){ if(xid == Vid[i]) return flag;}
01244  return false;
01245 }

bool EvtDecay::isCharmonium EvtId  xid  )  [private]
 

01167                                     {
01168 EvtId psi4415 = EvtPDL::getId(std::string("psi(4415)"));
01169 EvtId psi4160 = EvtPDL::getId(std::string("psi(4160)"));
01170 EvtId psi4040 = EvtPDL::getId(std::string("psi(4040)"));
01171 EvtId psi3770 = EvtPDL::getId(std::string("psi(3770)"));
01172 EvtId psiprim = EvtPDL::getId(std::string("psi(2S)"));
01173 EvtId jpsi    = EvtPDL::getId(std::string("J/psi"));
01174 EvtId etac    = EvtPDL::getId(std::string("eta_c"));
01175 EvtId etac2s  = EvtPDL::getId(std::string("eta_c(2S)"));
01176 EvtId hc = EvtPDL::getId(std::string("h_c"));
01177 EvtId chic0   = EvtPDL::getId(std::string("chi_c0"));
01178 EvtId chic1   = EvtPDL::getId(std::string("chi_c1"));
01179 EvtId chic2   = EvtPDL::getId(std::string("chi_c2"));
01180 EvtId chic0p  = EvtPDL::getId(std::string("chi_c0p"));
01181 EvtId chic1p  = EvtPDL::getId(std::string("chi_c1p"));
01182 EvtId chic2p  = EvtPDL::getId(std::string("chi_c1p"));
01183  std::vector<EvtId> Vid; Vid.clear();
01184  Vid.push_back(psi4415);
01185  Vid.push_back(psi4160);
01186  Vid.push_back(psi4040);
01187  Vid.push_back(psi3770);
01188  Vid.push_back(psiprim);
01189  Vid.push_back(jpsi);
01190  Vid.push_back(etac);
01191  Vid.push_back(etac2s);
01192  Vid.push_back(hc);
01193  Vid.push_back(chic0);
01194  Vid.push_back(chic1);
01195  Vid.push_back(chic2);
01196  Vid.push_back(chic0p);
01197  Vid.push_back(chic1p);
01198  Vid.push_back(chic2p);
01199 
01200  bool flag=true;
01201  for(int i=0;i<Vid.size();i++){ if(xid == Vid[i]) return flag;}
01202  return false;
01203 }

bool EvtDecay::isRadecay EvtParticle par  )  [private]
 

01247                                         {
01248   int ndg = par->getNDaug();
01249   for(int i=0;i<ndg;i++){
01250     EvtId xid = par->getDaug(i)->getId();
01251     if(EvtPDL::getStdHep(xid) == 22){return true;}
01252   }
01253   return false;
01254 }

StatusCode EvtDecay::makeHepMC EvtParticle ,
HepMC::GenEvent *  ,
HepMC::GenParticle * 
[private]
 

00839 {  
00840   MsgStream log(messageService(), name());
00841 
00842   if(part->getNDaug()!=0)
00843     {  
00844       double ct=(part->getDaug(0)->get4Pos()).get(0);
00845       double x=(part->getDaug(0)->get4Pos()).get(1);
00846       double y=(part->getDaug(0)->get4Pos()).get(2);
00847       double z=(part->getDaug(0)->get4Pos()).get(3);
00848          
00849       HepMC::GenVertex* end_vtx = new HepMC::GenVertex(HepLorentzVector(x,y,z,ct));
00850       hEvt->add_vertex( end_vtx );
00851       end_vtx->add_particle_in(hPart);
00852 
00853       int ndaug=part->getNDaug();
00854             
00855       for(int it=0;it<ndaug;it++)
00856         {
00857                 
00858           double e=(part->getDaug(it)->getP4Lab()).get(0);
00859           double px=(part->getDaug(it)->getP4Lab()).get(1);
00860           double py=(part->getDaug(it)->getP4Lab()).get(2);
00861           double pz=(part->getDaug(it)->getP4Lab()).get(3);
00862           int id=EvtPDL::getStdHep(part->getDaug(it)->getId());
00863           int status=1;
00864 
00865           if(part->getDaug(it)->getNDaug()!=0) status=999;
00866 
00867           HepMC::GenParticle* prod_part = new HepMC::GenParticle(HepLorentzVector(px,py,pz,e),id,status);
00868           end_vtx->add_particle_out(prod_part); 
00869           makeHepMC(part->getDaug(it),hEvt,prod_part);
00870 
00871       
00872      
00873           if( log.level()<MSG::INFO )
00874            prod_part->print();
00875         }
00876     }
00877 
00878   return StatusCode::SUCCESS;
00879 }

void EvtDecay::MeVToGeV HepMC::GenEvent *  hepMCevt  )  [private]
 

00883 {
00884   for ( HepMC::GenEvent::particle_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p ) {
00885     //              cout << " PDG, BAR " << (*p)->pdg_id() << " " << (*p)->barcode() << endl;
00886     (*p)->set_momentum( (*p)->momentum() / 1000. );
00887   }
00888 }

bool EvtDecay::SuperBody3decay_judge EvtParticle part  )  [private]
 

00989                                                       {
00990     double xmass2,ymass2;
00991     bool accept;
00992     EvtVector4R pd1,pd2,pd3;
00993 
00994 
00995         FinalState_sort( part);
00996 
00997         pd1=son0;
00998         pd2=son1;
00999         pd3=son2;
01000 
01001 
01002       xmass2=(pd1+pd2).mass2(); // Dalitz plot m12^2 ~ m13^2 
01003       ymass2=(pd1+pd3).mass2();
01004       accept=SuperBody3decay.AR(xmass2,ymass2); 
01005 
01006       //debugging
01007      if(accept && m_NtupleFile) {
01008      _ich=part->getChannel();
01009      _m1=pd1.mass(); 
01010      _m2=pd2.mass();
01011      _m3=pd3.mass();
01012      _m12=(pd1+pd2).mass();
01013      _m23=(pd2+pd3).mass();
01014      _m13=(pd1+pd3).mass();
01015      _cos1=pd1.get(3)/pd1.d3mag();
01016      _cos2=pd2.get(3)/pd2.d3mag();
01017      _cos3=pd3.get(3)/pd3.d3mag();
01018      massgen_tuple->write();
01019      }
01020      //     std::cout<<"mass 1 2 3 chicj>> "<<_m1<<" "<<_m2<<" "<<_m3<<" "<<_m23<<std::endl;
01021 
01022       return accept;
01023 }

void EvtDecay::SuperBody3decay_make EvtId  ppid,
EvtVector4R  p_init
[private]
 

00929                                                                    {
00930     double xmass2,ymass2;
00931     bool accept;
00932     EvtVector4R pd1,pd2,pd3;
00933 
00934     //---- find out the pdg codes of final state and count the identical particles
00935       FinalState_make( ppid, p_init); 
00936 
00937     //begin to loop with events
00938       for(int i=0;i<100000;i++){ 
00939       regen:
00940        EvtParticle* part=EvtParticleFactory::particleFactory(ppid,p_init);
00941        HepMC::GenParticle* hepMCpart=new GenParticle(HepLorentzVector(0,0,0,parentMass),parentPDGcode,3);  //this line make the decay to select different channel
00942 
00943        if(part->getSpinType() == EvtSpinType::VECTOR) {
00944           part->setVectorSpinDensity();
00945         }
00946         m_Gen->generateDecay(part);
00947        
00948 
00949         FinalState_sort(part);
00950         pd1=son0;
00951         pd2=son1;
00952         pd3=son2;
00953 
00954         //    std::cout<<"multi, pdg, pi= "<<multi<<" "<<pdg0<<" "<<pdg1<<" "<<pdg2<<" "<<son0<<son1<<son2<<std::endl;
00955 
00956         xmass2=(pd1+pd2).mass2(); // Dalitz plot m12^2 ~ m13^2 
00957         ymass2=(pd1+pd3).mass2();
00958         double xlow=SuperBody3decay.getXlow();
00959         double xup=SuperBody3decay.getXup();
00960         double ylow=SuperBody3decay.getYlow();
00961         double yup=SuperBody3decay.getYup();
00962         if(xmass2<xlow || xmass2>xup || ymass2<ylow || ymass2>yup) {  part->deleteTree();goto regen;}
00963         SuperBody3decay.HFill(xmass2,ymass2);
00964 
00965         if( m_NtupleFile ){
00966         m_ich=part->getChannel();
00967         m_m1=pd1.mass(); 
00968         m_m2=pd2.mass();
00969         m_m3=pd3.mass();
00970         m_m12=(pd1+pd2).mass();
00971         m_m23=(pd2+pd3).mass();
00972         m_m13=(pd1+pd3).mass();
00973         m_cos1=pd1.get(3)/pd1.d3mag();
00974         m_cos2=pd2.get(3)/pd2.d3mag();
00975         m_cos3=pd3.get(3)/pd3.d3mag();
00976         mass_tuple->write();
00977         }
00978         double m1=pd1.mass(); double m2=pd2.mass();double m3=pd3.mass();
00979          double mj=(pd2+pd3).mass();
00980          //       std::cout<<"mass 1 2 3 chicj <<=="<<m1<<" "<<m2<<" "<<m3<<" "<<mj<<std::endl;
00981          //      delete hepMCpart;
00982       }
00983   
00984       SuperBody3decay.HReweight(); //reweighting Dalitz plot
00985       SuperBody3decay.setZmax();   // find out the maximum value after reweighting
00986       first=false;
00987 }


Member Data Documentation

NTuple::Item<double> EvtDecay::_cos1 [private]
 

NTuple::Item<double> EvtDecay::_cos2 [private]
 

NTuple::Item<double> EvtDecay::_cos3 [private]
 

NTuple::Item<long> EvtDecay::_ich [private]
 

NTuple::Item<double> EvtDecay::_m1 [private]
 

NTuple::Item<double> EvtDecay::_m12 [private]
 

NTuple::Item<double> EvtDecay::_m13 [private]
 

NTuple::Item<double> EvtDecay::_m2 [private]
 

NTuple::Item<double> EvtDecay::_m23 [private]
 

NTuple::Item<double> EvtDecay::_m3 [private]
 

bool EvtDecay::_mDIY [private]
 

int EvtDecay::AllTrk_index [private]
 

int EvtDecay::br[500] [private]
 

DataInfoSvc* EvtDecay::dataInfoSvc
 

double EvtDecay::en_trk[50] [private]
 

EvtId EvtDecay::FDP_id [private]
 

EvtVector4R EvtDecay::FDP_init [private]
 

EvtParticle* EvtDecay::FDP_part [private]
 

bool EvtDecay::first [private]
 

bool EvtDecay::identical_flag [private]
 

bool EvtDecay::m_ampscalflag [private]
 

NTuple::Item<double> EvtDecay::m_cos1 [private]
 

NTuple::Item<double> EvtDecay::m_cos2 [private]
 

NTuple::Item<double> EvtDecay::m_cos3 [private]
 

string EvtDecay::m_DecayDec [private]
 

string EvtDecay::m_DecayRec [private]
 

string EvtDecay::m_DecayTop [private]
 

NTuple::Array<double> EvtDecay::m_en_trk [private]
 

string EvtDecay::m_FDPparticle [private]
 

NTuple::Array<long> EvtDecay::m_fst [private]
 

NTuple::Item<long> EvtDecay::m_gamma [private]
 

NTuple::Item<long> EvtDecay::m_gammaFSR [private]
 

EvtGen* EvtDecay::m_Gen [private]
 

NTuple::Item<long> EvtDecay::m_ich [private]
 

std::vector<int> EvtDecay::m_InSeeds [private]
 

EvtId EvtDecay::m_KKMCRes [private]
 

NTuple::Item<double> EvtDecay::m_m1 [private]
 

NTuple::Item<double> EvtDecay::m_m12 [private]
 

NTuple::Item<double> EvtDecay::m_m13 [private]
 

NTuple::Item<double> EvtDecay::m_m2 [private]
 

NTuple::Item<double> EvtDecay::m_m23 [private]
 

NTuple::Item<double> EvtDecay::m_m3 [private]
 

bool EvtDecay::m_Ncharge [private]
 

NTuple::Item<long> EvtDecay::m_nchr [private]
 

NTuple::Item<long> EvtDecay::m_nchr_e [private]
 

NTuple::Item<long> EvtDecay::m_nchr_k [private]
 

NTuple::Item<long> EvtDecay::m_nchr_mu [private]
 

NTuple::Item<long> EvtDecay::m_nchr_p [private]
 

NTuple::Item<long> EvtDecay::m_nchr_pi [private]
 

bool EvtDecay::m_NtupleFile [private]
 

int EvtDecay::m_numberEvent [private]
 

string EvtDecay::m_ParentPart [private]
 

string EvtDecay::m_PdtTable [private]
 

bool EvtDecay::m_Psi4040OpenCharm [private]
 

NTuple::Array<double> EvtDecay::m_px_trk [private]
 

NTuple::Array<double> EvtDecay::m_py_trk [private]
 

NTuple::Array<double> EvtDecay::m_pz_trk [private]
 

EvtBesRandom* EvtDecay::m_RandomEngine [private]
 

string EvtDecay::m_SB3File [private]
 

string EvtDecay::m_SB3HT [private]
 

vector<long int> EvtDecay::m_seeds [private]
 

bool EvtDecay::m_statDecays [private]
 

bool EvtDecay::m_tagLundModel [private]
 

int EvtDecay::m_targetID [private]
 

NTuple::Array<long> EvtDecay::m_Trk_index [private]
 

NTuple::Tuple* EvtDecay::m_tuple [private]
 

NTuple::Tuple* EvtDecay::mass_tuple [private]
 

NTuple::Tuple* EvtDecay::massgen_tuple [private]
 

int EvtDecay::multi [private]
 

std::ofstream EvtDecay::outfile [private]
 

std::ofstream EvtDecay::outfile2 [private]
 

IBesRndmGenSvc* EvtDecay::p_BesRndmGenSvc [private]
 

double EvtDecay::parentMass [private]
 

int EvtDecay::parentPDGcode [private]
 

int EvtDecay::pdg [private]
 

int EvtDecay::pdg0 [private]
 

int EvtDecay::pdg1 [private]
 

int EvtDecay::pdg2 [private]
 

double EvtDecay::px_trk[50] [private]
 

double EvtDecay::py_trk[50] [private]
 

double EvtDecay::pz_trk[50] [private]
 

EvtVector4R EvtDecay::son [private]
 

EvtVector4R EvtDecay::son0 [private]
 

EvtVector4R EvtDecay::son1 [private]
 

EvtVector4R EvtDecay::son2 [private]
 

EvtHis2F EvtDecay::SuperBody3decay [private]
 

IDataInfoSvc* EvtDecay::tmpInfoSvc
 

int EvtDecay::totalChannels [private]
 

NTuple::Item<long> EvtDecay::TotNumTrk [private]
 

int EvtDecay::Trk_index[50] [private]
 

string EvtDecay::userDecFileName [private]
 

int EvtDecay::vbr[500] [private]
 

int EvtDecay::writeFlag [private]
 


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 16:04:49 2011 for BOSS6.5.5 by  doxygen 1.3.9.1