/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Generator/BesGenModule/BesGenModule-00-00-13/src/BesGenModule.cxx

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 //
00003 //------------------------------------------------------------------------
00004 // Header for this module:-
00005 #include "BesGenModule/BesGenModule.h"
00006 #include "GeneratorModule/GeneratorName.h"
00007 
00008 // Framework Related Headers:-
00009 #include "GaudiKernel/MsgStream.h"
00010 #include "GaudiKernel/DataSvc.h"
00011 #include "GaudiKernel/SmartDataPtr.h"
00012 
00013 // Other classes used by this class:-
00014 //#include "StoreGate/StoreGateSvc.h"
00015 //#include "StoreGate/DataHandle.h"
00016 
00017 //#include "GeneratorObject/McEventCollection.h"
00018 #include "GeneratorObject/McGenEvent.h"
00019 #include "McTruth/DecayMode.h"
00020 
00021 //#include "HepMC/GenEvent.h"
00022 #include "HepMC/GenEvent.h"
00023 
00024 //#include "HepMC/ParticleDataTable.h"
00025 //#include "HepMC/ParticleData.h"
00026 #include "HepMC/IO_HEPEVT.h"
00027 //#include "HepMC/IO_HERWIG.h"
00028 #include "HepMC/HEPEVT_Wrapper.h"
00029 #include "McTruth/McEvent.h"
00030 
00031 
00032 #include "GeneratorObject/McGenEvent.h"
00033 #include "GeneratorUtil/StringParse.h"
00034 #include <stdlib.h>
00035 #include <vector>
00036 #include <iostream>
00037 #include <string>
00038 //for random seed of genbes 
00039 #include "GaudiKernel/ISvcLocator.h"
00040 #include "GaudiKernel/Bootstrap.h"
00041 #include "GaudiKernel/IDataProviderSvc.h"
00042 #include "BesKernel/IBesRndmGenSvc.h"
00043 //-------------------------------
00044 
00045 // Pointer On AtRndmGenSvc
00046 #include "CLHEP/Random/RandFlat.h"
00047 
00048 std::string BesGenModule::besMcGen_stream="PHOTOS_INIT";
00049 
00050 // calls to fortran routines
00051 
00052 
00053 extern "C" {
00054   void mainini_(int *,const char *);
00055 //  void mainini_(int*);
00056   void mainexe_(int*,int* mvec);
00057   void mainfin_(int*);
00058   void runi_seed_(int*);
00059 }
00060 //-----------------------------------
00061 //using HepMC::ParticleData;
00062 //using HepMC::IO_HERWIG;
00063 using HepMC::IO_HEPEVT;
00064 using HepMC::HEPEVT_Wrapper;
00065 
00066 
00067 // File scope declarations:-
00068 
00069 // set pointer to zero at start
00070 // Bes_HEPEVT*  BesMcGen::bes_HEPEVT = new Bes_HEPEVT();
00071 
00072 //--------------------------------------------------------------------------
00073 BesGenModule::BesGenModule(const std::string& name, 
00074       ISvcLocator* pSvcLocator): GenModule(name,pSvcLocator)
00075 {
00076 //--------------------------------------------------------------------------  
00077   besMcGen_stream       =       "PHOTOS_INIT";
00078 //  declareProperty("BesMcGenCommand", m_BesMcGenCommandVector);
00079 
00080   declareProperty("Runcards",  runname = "run.cards");
00081   declareProperty("Ratio",     Nr = 1);  
00082 
00083 }
00084 
00085 BesGenModule::~BesGenModule()
00086 {}
00087 
00088 //-------------------------------------------------------------
00089 //--------------
00090 // Operations --
00091 //--------------
00092 
00093 /*
00094 Ffphot& BesGenModule::ffphot(){
00095   return m_ffphot;
00096 }
00097 
00098 Ffpholun& BesGenModule::ffpholun(){
00099   return m_ffpholun;
00100 }
00101 */
00102 
00103 //---------------------------------------------------------------------------
00104 StatusCode BesGenModule::genInitialize() {
00105 //---------------------------------------------------------------------------
00106 
00107   MsgStream log(messageService(), name());
00108   log << MSG::INFO << " BES PHOTOS INITIALISING.  \n"  << endreq;
00109 //  log << MSG::INFO << " BES PHOTOS 2.  \n"  << endreq;
00110 
00111   //caogf add for random seed of genbes
00112   StatusCode RndmStatus = service("BesRndmGenSvc", p_BesRndmGenSvc, true);
00113   if (!RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc)
00114   {
00115      log << MSG::ERROR << " Could not initialize Random Number Service" << endreq;
00116      return RndmStatus;
00117   }
00118 
00119   BesGenModule::besMcGen_stream =       "PHOTOS_INIT";
00120 
00121   BesGenModule::besMcGen_stream =       "PHOTOS111";
00122 
00123   m_events = 0;
00124   n=0;
00125   cardname = runname.c_str();
00126 
00127 
00128   mainini_(&n,cardname);
00129 
00130   int theseed;
00131   runi_seed_(&theseed);
00132   p_BesRndmGenSvc->setGenseed(theseed+1);
00133 
00134   HepMC::HEPEVT_Wrapper::set_sizeof_int(4);
00135   HepMC::HEPEVT_Wrapper::set_sizeof_real(4);
00136   HepMC::HEPEVT_Wrapper::set_max_number_entries(2000);
00137 
00138  
00139   return StatusCode::SUCCESS;
00140 }
00141 
00142 //---------------------------------------------------------------------------
00143 StatusCode BesGenModule::callGenerator() {
00144 //---------------------------------------------------------------------------
00145   MsgStream log(messageService(), name());
00146   log << MSG::INFO << " BesGenModule generating.  \n"  << endreq;
00147 
00148   StatusCode status = StatusCode::SUCCESS;
00149   int iq;  
00150 
00151 //  n=1;
00152 
00153 
00154   mainexe_(&Nr,mvec);
00155 
00156 /*
00157     for (int iq = 1; iq < 11; iq++) {
00158        nvec[iq-1]=mvec[iq];
00159     }
00160 */
00161 
00162     McEvent* aMcEvent = new McEvent;
00163     StatusCode sc = eventSvc()->registerObject("/Event/MC",aMcEvent);
00164 
00165 
00166     SmartDataPtr<DecayMode> anMcCol(eventSvc(), "/Event/MC/DecayMode");
00167     if (anMcCol!=0) {
00168 //     log << MSG::INFO << "Add McEvent to existing collection" << endreq;
00169     }
00170     else {
00171 //     log << MSG::INFO << "No decay mode now" << endreq;
00172         DecayMode *decayMode = new DecayMode;
00173         decayMode->putData(mvec, 10);
00174     StatusCode sc = eventSvc()->registerObject("/Event/MC/DecayMode",decayMode);   
00175     }
00176 
00177 
00178     SmartDataPtr<DecayMode> aMcCol(eventSvc(), "/Event/MC/DecayMode");
00179     if (aMcCol!=0) {   
00180 //     log << MSG::INFO << "Haha signal exist!!!!" << endreq;
00181     }
00182 
00183 
00184 
00185 
00186 //  HEPEVT_Wrapper::print_hepevt();
00187 
00188   ++m_events;
00189   
00190 
00191 
00192   log << MSG::INFO << " BESGenModule generating done.  \n"  << endreq;
00193   return status;
00194 
00195 }
00196 
00197 //---------------------------------------------------------------------------
00198 StatusCode BesGenModule::genFinalize() {
00199   //---------------------------------------------------------------------------
00200   MsgStream log(messageService(), name());
00201  mainfin_(&n);
00202   log << MSG:: INFO << " BESGenModule Ending...  \n"  << endreq;
00203   return StatusCode::SUCCESS;
00204 }
00205 //---------------------------------------------------------------------------
00206 StatusCode BesGenModule::fillEvt(GenEvent* evt) {
00207   //---------------------------------------------------------------------------
00208   MsgStream log(messageService(), name());
00209   log << MSG:: INFO << " BESGenModule Filling...  \n"  << endreq;
00210 
00211       evt->set_event_number(m_events);
00212       HepMC::IO_HEPEVT hepio;
00213       hepio.fill_next_event(evt);
00214 //   cmTomm(evt);
00215 //   GeVToMeV(evt);
00216 
00217 
00218  return StatusCode::SUCCESS;
00219 }
00220 
00221 //---------------------------------------------------------------------------

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