BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
BesBdkRc.cxx
Go to the documentation of this file.
1//*****************************************************************************
2//
3//
4//
5//*****************************************************************************
6
7// Header for this module:-
8#include "BesBdkRc.h"
9#include "BesBdkRcRandom.h"
10
11// Framework Related Headers:-
12#include "HepMC/GenEvent.h"
13
14#include "HepMC/GenEvent.h"
15#include "HepMC/HEPEVT_Wrapper.h"
16#include "HepMC/IO_HEPEVT.h"
17
18#include "BesRndmGenSvc/IBesRndmGenSvc.h"
19#include "GaudiKernel/ISvcLocator.h"
20#include "GaudiKernel/MsgStream.h"
21#include "GaudiKernel/SmartDataPtr.h"
22
23#include "GeneratorObject/McGenEvent.h"
24#include "cfortran/cfortran.h"
25
26using namespace std;
27
28typedef struct {
29 double EB, W2MIN, K0, KS, EWE;
30} INPUT_DEF;
31#define INPUT COMMON_BLOCK( INPUT_DEF, input )
33
34typedef struct {
35 double ME, MU, PI, ALFA, BARN;
37#define PCONST COMMON_BLOCK( PCONST_DEF, pconst )
39
40typedef struct {
41 float TCHMIN, PCHMIN;
43#define FINCUT COMMON_BLOCK( FINCUT_DEF, fincut )
45
46typedef struct {
48 int ISEED;
49 float QMASS[6];
51#define LOCALC COMMON_BLOCK( LOCALC_DEF, localc )
53
54typedef struct {
55 double COLCHA;
56 int IFINAL;
58#define COLCHC COMMON_BLOCK( COLCHC_DEF, colchc )
60
61typedef struct {
64#define DELPHC COMMON_BLOCK( DELPHC_DEF, delphc )
66
67typedef struct {
69 double CSTOT, CSERR;
72#define XSECTC COMMON_BLOCK( XSECTC_DEF, xsectc )
74
75typedef struct {
77} FLAGS_DEF;
78#define FLAGS COMMON_BLOCK( FLAGS_DEF, flags )
80
81typedef struct {
82 int N;
83 int K[5][4000];
84 float P[5][4000], V[5][4000];
86#define LUJETS COMMON_BLOCK( LUJETS_DEF, lujets )
88
89PROTOCCALLSFSUB1( LUHEPC, luhepc, INT )
90#define LUHEPC( ICONV ) CCALLSFSUB1( LUHEPC, luhepc, INT, ICONV )
91
92PROTOCCALLSFSUB1( LULIST, lulist, INT )
93#define LULIST( ICONV ) CCALLSFSUB1( LULIST, lulist, INT, ICONV )
94
95PROTOCCALLSFSUB0( HEPEVT_CLEAN, hepevt_clean )
96#define HEPEVT_CLEAN() CCALLSFSUB0( HEPEVT_CLEAN, hepevt_clean )
97
98PROTOCCALLSFSUB0( HEPEVT_PRINT, hepevt_print )
99#define HEPEVT_PRINT() CCALLSFSUB0( HEPEVT_PRINT, hepevt_print )
100
101PROTOCCALLSFSUB1( BDKRC, bdkrc, INT )
102#define BDKRC( IDUMP ) CCALLSFSUB1( BDKRC, bdkrc, INT, IDUMP )
103
104PROTOCCALLSFSUB3( FINISH, finish, PINT, PDOUBLE, PDOUBLE )
105#define FINISH( IN, SIGT, ER ) \
106 CCALLSFSUB3( FINISH, finish, PINT, PDOUBLE, PDOUBLE, IN, SIGT, ER )
107
108PROTOCCALLSFSUB4( RLUXGO, rluxgo, INT, INT, INT, INT )
109#define RLUXGO( lux, ISEED, K1, K2 ) \
110 CCALLSFSUB4( RLUXGO, rluxgo, INT, INT, INT, INT, lux, ISEED, K1, K2 )
111
112PROTOCCALLSFSUB0( GEN_INIT, gen_init )
113#define GEN_INIT() CCALLSFSUB0( GEN_INIT, gen_init )
114
115PROTOCCALLSFSUB0( GEN1EVT, gen1evt )
116#define GEN1EVT() CCALLSFSUB0( GEN1EVT, gen1evt )
117
118extern "C" {
119extern float flat_();
120}
121
122float flat_() { return (float)BesBdkRcRandom::random(); }
123
125
126BesBdkRc::BesBdkRc( const string& name, ISvcLocator* pSvcLocator )
127 : Algorithm( name, pSvcLocator ) {
128 // declareProperty("InitialSeed",m_iseed=1001);
129 declareProperty( "CMEnergy", m_CMEnergy = 3.097 ); // 2*Ebeam [GeV]
130 declareProperty( "W2min", m_w2min = 0.02 ); // Cut on invariant gamma-gamma mass
131 declareProperty( "EstimatedMaxWeight", m_ewe = 2.5 );
132 declareProperty( "SoftPhotonMaxEnergy", m_kzero = 0.002 );
133 qmass[0] = 0.2;
134 qmass[1] = 0.2;
135 qmass[2] = 0.5;
136 qmass[3] = 1.5;
137 qmass[4] = 4.5;
138 qmass[5] = 180.;
139 declareProperty( "MaxNTry", m_maxNTry );
140 declareProperty( "FinalState", m_ifinal );
141 declareProperty( "MinTheta", m_tcmin );
142 declareProperty( "MinMomentum", m_pcmin );
143
144 m_numberEvent = 0;
145 toRad = M_PI / 180.0;
146 toDeg = 180.0 / M_PI;
147}
148
150 MsgStream log( msgSvc(), name() );
151 log << MSG::WARNING << "BesBdkRc initialize" << endmsg;
152
153 static const bool CREATEIFNOTTHERE( true );
154 StatusCode RndmStatus = service( "BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE );
155 if ( !RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc )
156 {
157 log << MSG::ERROR << " Could not initialize Random Number Service" << endmsg;
158 return RndmStatus;
159 }
160 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->GetEngine( "BesBdkRc" );
161 engine->showStatus();
163
164 //"INIT" subroutine action is replaced by c++ code
165 // for gen_init fortran code is called
166
167 FINCUT.TCHMIN = m_tcmin * toRad;
168 FINCUT.PCHMIN = m_pcmin;
169 // RLUXGO(3,m_iseed,0,0);
170
171 DELPHC.MAXNTRY = m_maxNTry;
172
173 COLCHC.IFINAL = m_ifinal;
174
175 INPUT.EB = 0.5 * m_CMEnergy;
176
177 LOCALC.W2MINR = m_w2min;
178 LOCALC.EBEAM = 0.5 * m_CMEnergy;
179 LOCALC.MAXESW = m_ewe;
180 LOCALC.KZERO = m_kzero;
181 // LOCALC.ISEED=m_iseed;
182 for ( int i = 0; i < 6; i++ ) LOCALC.QMASS[i] = qmass[i];
183 GEN_INIT();
184 XSECTC.NEVUNW = 0;
185
186 return StatusCode::SUCCESS;
187}
188
189StatusCode BesBdkRc::execute() {
190 MsgStream log( msgSvc(), name() );
191 log << MSG::INFO << "BesBdkRc executing" << endmsg;
192 HepMC::HEPEVT_Wrapper::set_max_number_entries( 2000 );
193 HepMC::HEPEVT_Wrapper::set_sizeof_real( 8 );
194 HepMC::IO_HEPEVT HepEvtIO;
195
196 HEPEVT_CLEAN();
197 GEN1EVT();
198
199 if ( FLAGS.GOODEVT != 1 )
200 {
201 log << MSG::ERROR << " BesBdkRc: fail to generate good event" << endl;
202 return StatusCode::FAILURE;
203 }
204
205 m_numberEvent++;
206 if ( log.level() < MSG::INFO ) LULIST( 1 );
207 // LULIST(1);
208 LUHEPC( 1 );
209 HepMC::GenEvent* evt = HepEvtIO.read_next_event();
210 evt->set_event_number( m_numberEvent );
211 evt->set_signal_process_id( 1 );
212 // evt->print();
213 // Check if the McCollection already exists
214 SmartDataPtr<McGenEventCol> anMcCol( eventSvc(), "/Event/Gen" );
215 if ( anMcCol != 0 )
216 {
217 // Add event to existing collection
218 MsgStream log( msgSvc(), name() );
219 log << MSG::INFO << "Add McGenEvent to existing collection" << endmsg;
220 McGenEvent* mcEvent = new McGenEvent( evt );
221 anMcCol->push_back( mcEvent );
222 }
223 else
224 {
225 // Create Collection and add to the transient store
226 McGenEventCol* mcColl = new McGenEventCol;
227 McGenEvent* mcEvent = new McGenEvent( evt );
228 mcColl->push_back( mcEvent );
229 StatusCode sc = eventSvc()->registerObject( "/Event/Gen", mcColl );
230 if ( sc != StatusCode::SUCCESS )
231 {
232 log << MSG::ERROR << "Could not register McGenEvent" << endmsg;
233 delete mcColl;
234 delete evt;
235 delete mcEvent;
236 return StatusCode::FAILURE;
237 }
238 }
239 // string s;
240 // getline(cin,s);
241
242 return StatusCode::SUCCESS;
243}
244
245StatusCode BesBdkRc::finalize() {
246 MsgStream log( msgSvc(), name() );
247 log << MSG::INFO << "BesBdkRc finalized" << endmsg;
248 int itot;
249 itot = XSECTC.ITOT;
250 double cstot;
251 double cserr;
252 FINISH( itot, cstot, cserr );
253 float effcut = 0;
254 float cscut = 0;
255 float efferr = 0;
256 float cscuterr = 0;
257 if ( XSECTC.NEVUNW )
258 {
259 effcut = float( DELPHC.NEVCUT ) / float( XSECTC.NEVUNW );
260 cscut = effcut * cstot;
261 efferr = sqrt( effcut * ( 1.0 - effcut ) / float( XSECTC.NEVUNW ) );
262 cscuterr = sqrt( cstot * efferr * cstot * efferr + effcut * effcut * cserr * cserr );
263 }
264 printf( "BDKRC SUMMARY: Cross section after user cuts= %G +- %G nb\n", cscut, cscuterr );
265 printf( " Cut acceptance = %G +- %G \n", effcut, efferr );
266 return StatusCode::SUCCESS;
267}
#define RLUXGO(lux, ISEED, K1, K2)
Definition BesBdkRc.cxx:109
#define COLCHC
Definition BesBdkRc.cxx:58
#define INPUT
Definition BesBdkRc.cxx:31
#define LULIST(ICONV)
Definition BesBdkRc.cxx:93
#define PCONST
Definition BesBdkRc.cxx:37
#define BDKRC(IDUMP)
Definition BesBdkRc.cxx:102
#define HEPEVT_PRINT()
Definition BesBdkRc.cxx:99
#define GEN_INIT()
Definition BesBdkRc.cxx:113
#define DELPHC
Definition BesBdkRc.cxx:64
#define FLAGS
Definition BesBdkRc.cxx:78
COMMON_BLOCK_DEF(INPUT_DEF, INPUT)
#define FINCUT
Definition BesBdkRc.cxx:43
#define LOCALC
Definition BesBdkRc.cxx:51
#define FINISH(IN, SIGT, ER)
Definition BesBdkRc.cxx:105
#define GEN1EVT()
Definition BesBdkRc.cxx:116
DECLARE_COMPONENT(BesBdkRc)
#define LUHEPC(ICONV)
Definition BesBdkRc.cxx:90
#define XSECTC
Definition BesBdkRc.cxx:72
#define HEPEVT_CLEAN()
Definition BesBdkRc.cxx:96
#define LUJETS
Definition BesBdkRc.cxx:86
float flat_()
Definition BesBdkRc.cxx:122
ObjectVector< McGenEvent > McGenEventCol
IMessageSvc * msgSvc()
#define M_PI
Definition TConstant.h:4
static double random()
static void setRandomEngine(CLHEP::HepRandomEngine *randomEngine)
StatusCode finalize()
Definition BesBdkRc.cxx:245
StatusCode execute()
Definition BesBdkRc.cxx:189
StatusCode initialize()
Definition BesBdkRc.cxx:149
BesBdkRc(const std::string &name, ISvcLocator *pSvcLocator)
Definition BesBdkRc.cxx:126
PROTOCCALLSFSUB3(INPUT, input, PLONG, PINT, PSTRING)
PROTOCCALLSFSUB1(RLXDRESETF, rlxdresetf, INTV)
PROTOCCALLSFSUB0(INITHISTO, inithisto)
double COLCHA
Definition BesBdkRc.cxx:55
float TCHMIN
Definition BesBdkRc.cxx:41
float PCHMIN
Definition BesBdkRc.cxx:41
int GOODEVT
Definition BesBdkRc.cxx:76
double EB
Definition BesBdkRc.cxx:29
double KS
Definition BesBdkRc.cxx:29
double K0
Definition BesBdkRc.cxx:29
double EWE
Definition BesBdkRc.cxx:29
double W2MIN
Definition BesBdkRc.cxx:29
float EBEAM
Definition BesBdkRc.cxx:47
float MAXESW
Definition BesBdkRc.cxx:47
float W2MINR
Definition BesBdkRc.cxx:47
float KZERO
Definition BesBdkRc.cxx:47
float QMASS[6]
Definition BesBdkRc.cxx:49
int K[5][4000]
Definition BesBdkRc.cxx:83
float P[5][4000]
Definition BesBdkRc.cxx:84
float V[5][4000]
Definition BesBdkRc.cxx:84
double ALFA
Definition BesBdkRc.cxx:35
double ME
Definition BesBdkRc.cxx:35
double BARN
Definition BesBdkRc.cxx:35
double PI
Definition BesBdkRc.cxx:35
double MU
Definition BesBdkRc.cxx:35
double CSTOT
Definition BesBdkRc.cxx:69
double CSERR
Definition BesBdkRc.cxx:69
float CSCUTERR
Definition BesBdkRc.cxx:70
float CSCUT
Definition BesBdkRc.cxx:70