BOSS 7.0.9
BESIII Offline Software System
Loading...
Searching...
No Matches
BesGenModule.cxx
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2//
3//------------------------------------------------------------------------
4// Header for this module:-
7
8// Framework Related Headers:-
9#include "GaudiKernel/MsgStream.h"
10#include "GaudiKernel/DataSvc.h"
11#include "GaudiKernel/SmartDataPtr.h"
12
13// Other classes used by this class:-
14//#include "StoreGate/StoreGateSvc.h"
15//#include "StoreGate/DataHandle.h"
16
17//#include "GeneratorObject/McEventCollection.h"
19#include "McTruth/DecayMode.h"
20
21//#include "HepMC/GenEvent.h"
22#include "HepMC/GenEvent.h"
23
24//#include "HepMC/ParticleDataTable.h"
25//#include "HepMC/ParticleData.h"
26#include "HepMC/IO_HEPEVT.h"
27//#include "HepMC/IO_HERWIG.h"
28#include "HepMC/HEPEVT_Wrapper.h"
29#include "McTruth/McEvent.h"
30
31
34#include <stdlib.h>
35#include <vector>
36#include <iostream>
37#include <string>
38//for random seed of genbes
39#include "GaudiKernel/ISvcLocator.h"
40#include "GaudiKernel/Bootstrap.h"
41#include "GaudiKernel/IDataProviderSvc.h"
43//-------------------------------
44
45// Pointer On AtRndmGenSvc
46#include "CLHEP/Random/RandFlat.h"
47
48std::string BesGenModule::besMcGen_stream="PHOTOS_INIT";
49
50// calls to fortran routines
51
52
53extern "C" {
54 void mainini_(int *,const char *);
55// void mainini_(int*);
56 void mainexe_(int*,int* mvec);
57 void mainfin_(int*);
58 void runi_seed_(int*);
59}
60//-----------------------------------
61//using HepMC::ParticleData;
62//using HepMC::IO_HERWIG;
63using HepMC::IO_HEPEVT;
64using HepMC::HEPEVT_Wrapper;
65
66
67// File scope declarations:-
68
69// set pointer to zero at start
70// Bes_HEPEVT* BesMcGen::bes_HEPEVT = new Bes_HEPEVT();
71
72//--------------------------------------------------------------------------
73BesGenModule::BesGenModule(const std::string& name,
74 ISvcLocator* pSvcLocator): GenModule(name,pSvcLocator)
75{
76//--------------------------------------------------------------------------
77 besMcGen_stream = "PHOTOS_INIT";
78// declareProperty("BesMcGenCommand", m_BesMcGenCommandVector);
79
80 declareProperty("Runcards", runname = "run.cards");
81 declareProperty("Ratio", Nr = 1);
82
83}
84
86{}
87
88//-------------------------------------------------------------
89//--------------
90// Operations --
91//--------------
92
93/*
94Ffphot& BesGenModule::ffphot(){
95 return m_ffphot;
96}
97
98Ffpholun& BesGenModule::ffpholun(){
99 return m_ffpholun;
100}
101*/
102
103//---------------------------------------------------------------------------
105//---------------------------------------------------------------------------
106
107 MsgStream log(messageService(), name());
108 log << MSG::INFO << " BES PHOTOS INITIALISING. \n" << endreq;
109// log << MSG::INFO << " BES PHOTOS 2. \n" << endreq;
110
111 //caogf add for random seed of genbes
112 StatusCode RndmStatus = service("BesRndmGenSvc", p_BesRndmGenSvc, true);
113 if (!RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc)
114 {
115 log << MSG::ERROR << " Could not initialize Random Number Service" << endreq;
116 return RndmStatus;
117 }
118
119 BesGenModule::besMcGen_stream = "PHOTOS_INIT";
120
121 BesGenModule::besMcGen_stream = "PHOTOS111";
122
123 m_events = 0;
124 n=0;
125 cardname = runname.c_str();
126
127
129
130 int theseed;
131 runi_seed_(&theseed);
132 p_BesRndmGenSvc->setGenseed(theseed+1);
133
134 HepMC::HEPEVT_Wrapper::set_sizeof_int(4);
135 HepMC::HEPEVT_Wrapper::set_sizeof_real(4);
136 HepMC::HEPEVT_Wrapper::set_max_number_entries(2000);
137
138
139 return StatusCode::SUCCESS;
140}
141
142//---------------------------------------------------------------------------
144//---------------------------------------------------------------------------
145 MsgStream log(messageService(), name());
146 log << MSG::INFO << " BesGenModule generating. \n" << endreq;
147
148 StatusCode status = StatusCode::SUCCESS;
149 int iq;
150
151// n=1;
152
153
154 mainexe_(&Nr,mvec);
155
156/*
157 for (int iq = 1; iq < 11; iq++) {
158 nvec[iq-1]=mvec[iq];
159 }
160*/
161
162 McEvent* aMcEvent = new McEvent;
163 StatusCode sc = eventSvc()->registerObject("/Event/MC",aMcEvent);
164
165
166 SmartDataPtr<DecayMode> anMcCol(eventSvc(), "/Event/MC/DecayMode");
167 if (anMcCol!=0) {
168// log << MSG::INFO << "Add McEvent to existing collection" << endreq;
169 }
170 else {
171// log << MSG::INFO << "No decay mode now" << endreq;
172 DecayMode *decayMode = new DecayMode;
173 decayMode->putData(mvec, 10);
174 StatusCode sc = eventSvc()->registerObject("/Event/MC/DecayMode",decayMode);
175 }
176
177
178 SmartDataPtr<DecayMode> aMcCol(eventSvc(), "/Event/MC/DecayMode");
179 if (aMcCol!=0) {
180// log << MSG::INFO << "Haha signal exist!!!!" << endreq;
181 }
182
183
184
185
186// HEPEVT_Wrapper::print_hepevt();
187
188 ++m_events;
189
190
191
192 log << MSG::INFO << " BESGenModule generating done. \n" << endreq;
193 return status;
194
195}
196
197//---------------------------------------------------------------------------
199 //---------------------------------------------------------------------------
200 MsgStream log(messageService(), name());
201 mainfin_(&n);
202 log << MSG:: INFO << " BESGenModule Ending... \n" << endreq;
203 return StatusCode::SUCCESS;
204}
205//---------------------------------------------------------------------------
206StatusCode BesGenModule::fillEvt(GenEvent* evt) {
207 //---------------------------------------------------------------------------
208 MsgStream log(messageService(), name());
209 log << MSG:: INFO << " BESGenModule Filling... \n" << endreq;
210
211 evt->set_event_number(m_events);
212 HepMC::IO_HEPEVT hepio;
213 hepio.fill_next_event(evt);
214// cmTomm(evt);
215// GeVToMeV(evt);
216
217
218 return StatusCode::SUCCESS;
219}
220
221//---------------------------------------------------------------------------
void mainexe_(int *, int *mvec)
void mainfin_(int *)
void mainini_(int *, const char *)
void runi_seed_(int *)
virtual StatusCode fillEvt(GenEvent *evt)
static std::string besMcGen_stream
Definition: BesGenModule.h:33
std::string runname
Definition: BesGenModule.h:45
virtual StatusCode genInitialize()
IBesRndmGenSvc * p_BesRndmGenSvc
Definition: BesGenModule.h:32
virtual StatusCode callGenerator()
const char * cardname
Definition: BesGenModule.h:44
virtual StatusCode genFinalize()
BesGenModule(const std::string &name, ISvcLocator *pSvcLocator)
int mvec[10]
Definition: BesGenModule.h:47
virtual ~BesGenModule()
void putData(int *data, unsigned int size)
virtual void setGenseed(long)=0
Definition: McEvent.h:8