/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Generator/BesEvtGen/BesEvtGen-00-03-58/src/EvtGen/EvtGenModels/EvtTrackGen.cc

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 //
00003 // Modification history:
00004 //
00005 //    pingrg       January 22, 2014       Module created
00006 //
00007 // -------- input file must take the form like:
00008 //           [number of final state particles in this event]
00009 //           [PDG ID of particle 1]  [P_x] [P_y] [P_z] [E]
00010 //           [PDG ID of particle 2]  [P_x] [P_y] [P_z] [E]
00011 //       and so on
00012 //------------------------------------------------------------------------
00013 //
00014 #include "EvtGenBase/EvtPatches.hh"
00015 #include <stdlib.h>
00016 #include "EvtGenBase/EvtParticle.hh"
00017 #include "EvtGenBase/EvtGenKine.hh"
00018 #include "EvtGenBase/EvtPDL.hh"
00019 #include "EvtGenBase/EvtReport.hh"
00020 #include "EvtGenBase/EvtRandom.hh"
00021 #include "EvtTrackGen.hh"
00022 #include "EvtGlobalSet.hh"
00023 #include <string>
00024 
00025 EvtTrackGen::~EvtTrackGen() {}
00026 
00027 void EvtTrackGen::getName(std::string& model_name){
00028 
00029   model_name="TrackGen";     
00030 
00031 }
00032 
00033 EvtDecayBase* EvtTrackGen::clone(){
00034 
00035   return new EvtTrackGen;
00036 
00037 }
00038 
00039 
00040 void EvtTrackGen::init(){
00041 
00042   // check that there are 0 arguments
00043   checkNArg(1);
00044   int idx=getArg(0);
00045   if(EvtGlobalSet::SV.size()==0){
00046     std::cout<<"No track data file is available! "<<std::endl;abort();
00047   }else{m_inputFileName=EvtGlobalSet::SV[idx];}
00048 
00049   m_inputFile.open(m_inputFileName.c_str());
00050   if (!m_inputFile){
00051     cout << "EvtTrackGen: PROBLEMS OPENING FILE "
00052          << m_inputFileName << endl;
00053     exit(0);
00054   }
00055   //load the event P4
00056   Evt.clear();
00057   while(!m_inputFile.eof()){
00058     m_inputFile >> nParticles;
00059     std::vector<EvtVector4R> vp4;
00060     for (int i = 0; i < nParticles; i++){
00061       EvtVector4R p4;
00062       m_inputFile >> idParticles[i];
00063       m_inputFile >> pxParticle;  p4.set(1,pxParticle);
00064       m_inputFile >> pyParticle;  p4.set(2,pyParticle);
00065       m_inputFile >> pzParticle;  p4.set(3,pzParticle);
00066       m_inputFile >> eParticle;   p4.set(0,eParticle);
00067       vp4.push_back(p4);
00068     }
00069     Evt.push_back(vp4);
00070   }
00071   Evt.pop_back();
00072   //check daughters id
00073   if(nParticles!=getNDaug()){std::cout<<"The number of daughters are not cosistent with that the data file"<<std::endl;abort();}
00074   for(int i=0;i<nParticles;i++){
00075     EvtId pid = EvtPDL::evtIdFromStdHep(idParticles[i] );
00076     if(pid!=getDaug(i) ){std::cout<<"The daughter particle pdg in your data file is not consistent with you decay card."<<std::endl;abort();}
00077   }
00078   //debugging
00079   /*
00080   for(int i=0;i<Evt.size();i++){
00081     std::cout<<"Event "<<i<<std::endl;
00082     for(int j=0;j<nParticles;j++){
00083       std::cout<<Evt[i][j].get(0)<<" "<<Evt[i][j].get(1)<<" "<<Evt[i][j].get(2)<<" "<<Evt[i][j].get(3)<<std::endl;
00084     }
00085   }
00086   */
00087 //---------
00088 }
00089 
00090 void EvtTrackGen::initProbMax(){
00091 
00092   noProbMax();
00093 
00094 }
00095 
00096 void EvtTrackGen::decay( EvtParticle *p ){
00097 
00098   double weight = p->initializePhaseSpace(getNDaug(),getDaugs());
00099   int rdm= (int)Evt.size()*EvtRandom::Flat(0.0,1.0);
00100   if(Evt.size()==0) {std::cout<<"EvtTrackGen: out of stored file record"<<std::endl;abort();}
00101   EvtVector4R ptot(0,0,0,0);
00102   for(int i=0;i<nParticles;i++){
00103     EvtParticle* daug=p->getDaug(i);
00104     ptot += Evt[rdm][i];
00105     daug->init(daug->getId(),Evt[rdm][i]);
00106   }
00107   //p->init(p->getId(),ptot);
00108 
00109   //debugging
00110   // std::cout<<p->getDaug(getNDaug()-1)->getP4()<<" =? "<<eParticle<<" "<<pxParticle<<" "<<pyParticle<<" "<<pzParticle<<std::endl;
00111 
00112   return ;
00113 }
00114 
00115 
00116 

Generated on Tue Nov 29 23:12:23 2016 for BOSS_7.0.2 by  doxygen 1.4.7