BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
KKMC.cxx
Go to the documentation of this file.
1// #include "HepMC/HEPEVT_Wrapper.h"
2#include "HepMC/IO_HEPEVT.h"
3// #include "HepMC/IO_Ascii.h"
4#include "HepMC/GenEvent.h"
5
6#include "GaudiKernel/DataSvc.h"
7#include "GaudiKernel/ISvcLocator.h"
8#include "GaudiKernel/MsgStream.h"
9#include "GaudiKernel/SmartDataPtr.h"
10
11#include "BesRndmGenSvc/IBesRndmGenSvc.h"
12#include "GeneratorObject/McGenEvent.h"
13#include "KKMC.h"
14#include "KKMCRandom.h"
15#include "cfortran/cfortran.h"
16
17#include "EventModel/EventHeader.h"
18
19PROTOCCALLSFSUB3( PSEUMAR_INITIALIZE, pseumar_initialize, INT, INT, INT )
20#define PSEUMAR_INITIALIZE( ijklin, ntot1n, ntot2n ) \
21 CCALLSFSUB3( PSEUMAR_INITIALIZE, pseumar_initialize, INT, INT, INT, ijklin, ntot1n, ntot2n );
22
23PROTOCCALLSFSUB1( WHYM_SETDEF, whym_setdef, DOUBLEV )
24#define WHYM_SETDEF( XPAR ) CCALLSFSUB1( WHYM_SETDEF, whym_setdef, DOUBLEV, XPAR );
25PROTOCCALLSFSUB0( MY_PYUPD, my_pyupd )
26#define MY_PYUPD() CCALLSFSUB0( MY_PYUPD, my_pyupd );
27
28PROTOCCALLSFSUB1( KK2F_INITIALIZE, kk2f_initialize, DOUBLEV )
29#define KK2F_INITIALIZE( XPAR ) CCALLSFSUB1( KK2F_INITIALIZE, kk2f_initialize, DOUBLEV, XPAR );
30
31PROTOCCALLSFSUB0( HEPEVT_CLEAN, hepevt_clean )
32#define HEPEVT_CLEAN() CCALLSFSUB0( HEPEVT_CLEAN, hepevt_clean );
33PROTOCCALLSFSUB0( KK2F_MAKE, kk2f_make )
34#define KK2F_MAKE() CCALLSFSUB0( KK2F_MAKE, kk2f_make );
35
36PROTOCCALLSFSUB1( KK2F_GETKEYSKIP, kk2f_getkeyskip, PINT )
37#define KK2F_GETKEYSKIP( KEY ) CCALLSFSUB1( KK2F_GETKEYSKIP, kk2f_getkeyskip, PINT, KEY );
38
39PROTOCCALLSFSUB1( PSIPP_DDBARCUT, psipp_ddbarcut, PINT )
40#define PSIPP_DDBARCUT( KEY ) CCALLSFSUB1( PSIPP_DDBARCUT, psipp_ddbarcut, PINT, KEY );
41
42PROTOCCALLSFSUB0( KK2F_FINALIZE, kk2f_finalize )
43#define KK2F_FINALIZE() CCALLSFSUB0( KK2F_FINALIZE, kk2f_finalize );
44PROTOCCALLSFSUB2( KK2F_GETXSECMC, kk2f_getxsecmc, PDOUBLE, PDOUBLE )
45#define KK2F_GETXSECMC( xsecpb, xerrpb ) \
46 CCALLSFSUB2( KK2F_GETXSECMC, kk2f_getxsecmc, PDOUBLE, PDOUBLE, xsecpb, xerrpb );
47
48PROTOCCALLSFSUB1( PYLIST, pylist, INT )
49#define PYLIST( LIST ) CCALLSFSUB1( PYLIST, pylist, INT, LIST );
50
51PROTOCCALLSFSUB1( PYHEPC, pyhepc, INT )
52#define PYHEPC( ICONV ) CCALLSFSUB1( PYHEPC, pyhepc, INT, ICONV );
53
54PROTOCCALLSFSUB1( KK2F_SETEVTGENINTERFACE, kk2f_setevtgeninterface, INT )
55#define KK2F_SETEVTGENINTERFACE( KEY ) \
56 CCALLSFSUB1( KK2F_SETEVTGENINTERFACE, kk2f_setevtgeninterface, INT, KEY );
57PROTOCCALLSFSUB1( KK2F_GETEVTGENINTERFACE, kk2f_getevtgeninterface, PINT )
58#define KK2F_GETEVTGENINTERFACE( KEY ) \
59 CCALLSFSUB1( KK2F_GETEVTGENINTERFACE, kk2f_getevtgeninterface, PINT, KEY );
60
61PROTOCCALLSFSUB1( HEPEVT_NUMHEP, hepevt_numhep, PINT )
62#define HEPEVT_NUMHEP( Nhep ) CCALLSFSUB1( HEPEVT_NUMHEP, hepevt_numhep, PINT, Nhep );
63PROTOCCALLSFSUB1( HEPEVT_GETF, hepevt_getf, PINT )
64#define HEPEVT_GETF( POS ) CCALLSFSUB1( HEPEVT_GETF, hepevt_getf, PINT, POS );
65PROTOCCALLSFSUB1( HEPEVT_GETFBAR, hepevt_getfbar, PINT )
66#define HEPEVT_GETFBAR( POS ) CCALLSFSUB1( HEPEVT_GETFBAR, hepevt_getfbar, PINT, POS );
67PROTOCCALLSFSUB1( HEPEVT_GETKFFIN, hepevt_getkffin, PINT )
68#define HEPEVT_GETKFFIN( KFIN ) CCALLSFSUB1( HEPEVT_GETKFFIN, hepevt_getkffin, PINT, KFIN );
69PROTOCCALLSFSUB1( HEPEVT_SETPHOTOSFLAGTRUE, hepevt_setphotosflagtrue, INT )
70#define HEPEVT_SETPHOTOSFLAGTRUE( IP ) \
71 CCALLSFSUB1( HEPEVT_SETPHOTOSFLAGTRUE, hepevt_setphotosflagtrue, INT, IP );
72PROTOCCALLSFSUB1( PHOTOS, photos, INT )
73#define PHOTOS( IP ) CCALLSFSUB1( PHOTOS, photos, INT, IP );
74PROTOCCALLSFSUB0( PHOINI, phoini )
75#define PHOINI() CCALLSFSUB0( PHOINI, phoini );
76
77PROTOCCALLSFSUB0( TURNOFFTAUDECAY, turnofftaudecay )
78#define TURNOFFTAUDECAY() CCALLSFSUB0( TURNOFFTAUDECAY, turnofftaudecay );
79
80PROTOCCALLSFSUB2( PYUPDA, pyupda, INT, INT )
81#define PYUPDA( MUPDA, LFN ) CCALLSFSUB2( PYUPDA, pyupda, INT, INT, MUPDA, LFN );
82
83typedef struct {
85} DDBAR_DEF;
86#define DDBARMASS COMMON_BLOCK( DDBAR_DEF, ddbarmass )
88
89typedef struct {
92#define PHOTONTAG COMMON_BLOCK( PHOTONTAG_DEF, photontag )
94
95typedef struct {
96 int ich;
98#define MODEXS COMMON_BLOCK( MODEXS_DEF, modexs )
100
101extern "C" {
102extern void pygive_( const char* cnfgstr, int length );
103}
104
105using namespace HepMC;
106int KKMC::m_runNo = 0;
107
109KKMC::KKMC( const std::string& name, ISvcLocator* pSvcLocator )
110 : Algorithm( name, pSvcLocator ) {
111 m_numberEvent = 0;
112
113 m_kkseed.clear();
114 m_kkseed.push_back( 123456 );
115 m_kkseed.push_back( 1 );
116 m_kkseed.push_back( 0 );
117
118 declareProperty( "NumberOfEventPrinted", m_numberEventPrint = 100 );
119 declareProperty( "InitializedSeed", m_kkseed );
120 declareProperty( "CMSEnergy", m_cmsEnergy = 3.773 );
121 declareProperty( "ReadMeasuredEcms",
122 m_RdMeasuredEcms = false ); // Read ecms from database (Wu Lianjin)
123 declareProperty( "BeamEnergySpread",
124 m_cmsEnergySpread =
125 0.0013 ); // it should be beam energy spread,pingrg-2009-09-24
126 declareProperty( "GenerateResonance", m_generateResonance = true );
127 declareProperty( "GenerateContinuum", m_generateContinuum = true );
128 declareProperty( "GenerateDownQuark", m_generateDownQuark = true );
129 declareProperty( "GenerateUpQuark", m_generateUpQuark = true );
130 declareProperty( "GenerateStrangeQuark", m_generateStrangeQuark = true );
131 declareProperty( "GenerateCharmQuark", m_generateCharmQuark = true );
132 declareProperty( "GenerateBottomQuark", m_generateBottomQuark = false );
133 declareProperty( "GenerateMuonPair", m_generateMuonPair = true );
134 declareProperty( "GenerateTauPair", m_generateTauPair = true );
135 declareProperty( "GenerateRho", m_generateRho = true );
136 declareProperty( "GenerateOmega", m_generateOmega = true );
137 declareProperty( "GeneratePhi", m_generatePhi = true );
138 declareProperty( "GenerateJPsi", m_generateJPsi = true );
139 declareProperty( "GeneratePsiPrime", m_generatePsiPrime = true );
140 declareProperty( "GeneratePsi3770", m_generatePsi3770 = true );
141 declareProperty( "GeneratePsi4030", m_generatePsi4030 = true );
142 declareProperty( "GeneratePsi4160", m_generatePsi4160 = true );
143 declareProperty( "GeneratePsi4415", m_generatePsi4415 = true );
144 declareProperty( "GeneratePsi4260", m_generatePsi4260 = true );
145 declareProperty( "ThresholdCut",
146 m_DdbarCutPsi3770 = -3.0 ); // generate DDbar decay, pingrg-2009-10-14
147 declareProperty( "TagISR", m_isrtag = false ); // Tag ISR photon, false: ID=22, true: ID=-22,
148 // pingrg-2010-6-30
149 declareProperty( "TagFSR", m_fsrtag = false ); // Tag FSR photon, false: ID=22, true: ID=-22,
150 // pingrg-2010-6-30
151 declareProperty( "ModeIndexExpXS",
152 m_ich = -10 ); // mode index using the measured cross section
153 // Added by Ke LI (like@ihep.ac.cn), 2015-02-16
154 declareProperty( "IHVP", m_ihvp = 1 ); // m_ihvp=0, switch off vacuum polarization;
155 // 1, 2, 3 for three different caculations (Jegerlehner/Eidelman, Jegerlehner(1988),
156 // Burkhardt etal.). By default, is 1.
157
158 m_paramRho.clear();
159 m_paramRho.push_back( 0.77457e0 );
160 m_paramRho.push_back( 147.65e-3 );
161 m_paramRho.push_back( 6.89e-6 );
162 m_paramRh2.clear();
163 m_paramRh2.push_back( 1.465e0 );
164 m_paramRh2.push_back( 310e-3 );
165 m_paramRh2.push_back( 0.0e-6 );
166 m_paramRh3.clear();
167 m_paramRh3.push_back( 1.700e0 );
168 m_paramRh3.push_back( 240e-3 );
169 m_paramRh3.push_back( 0.0e-6 );
170 m_paramOme.clear();
171 m_paramOme.push_back( 0.78194e0 );
172 m_paramOme.push_back( 8.41e-3 );
173 m_paramOme.push_back( 0.60e-6 );
174 m_paramOm2.clear();
175 m_paramOm2.push_back( 1.419e0 );
176 m_paramOm2.push_back( 174e-3 );
177 m_paramOm2.push_back( 0.00e-6 );
178 m_paramOm3.clear();
179 m_paramOm3.push_back( 1.649e0 );
180 m_paramOm3.push_back( 220e-3 );
181 m_paramOm3.push_back( 0.00e-6 );
182 m_paramPhi.clear();
183 m_paramPhi.push_back( 1.01942e0 );
184 m_paramPhi.push_back( 4.46e-3 );
185 m_paramPhi.push_back( 1.33e-6 );
186 m_paramPh2.clear();
187 m_paramPh2.push_back( 1.680e0 );
188 m_paramPh2.push_back( 150e-3 );
189 m_paramPh2.push_back( 0.00e-6 );
190 m_paramPsi.clear();
191 m_paramPsi.push_back( 3.096916e0 );
192 m_paramPsi.push_back( 0.0929e-3 );
193 m_paramPsi.push_back( 5.40e-6 );
194 m_paramPs2.clear();
195 m_paramPs2.push_back( 3.686109e0 );
196 m_paramPs2.push_back( 0.304e-3 );
197 m_paramPs2.push_back( 2.12e-6 );
198 m_paramPs3.clear();
199 m_paramPs3.push_back( 3.77315e0 );
200 m_paramPs3.push_back( 27.2e-3 );
201 m_paramPs3.push_back( 0.26e-6 );
202 m_paramPs4.clear();
203 m_paramPs4.push_back( 4.039e0 );
204 m_paramPs4.push_back( 80e-3 );
205 m_paramPs4.push_back( 0.86e-6 );
206 m_paramPs5.clear();
207 m_paramPs5.push_back( 4.153e0 );
208 m_paramPs5.push_back( 103e-3 );
209 m_paramPs5.push_back( 0.83e-6 );
210 m_paramPs6.clear();
211 m_paramPs6.push_back( 4.421e0 );
212 m_paramPs6.push_back( 62e-3 );
213 m_paramPs6.push_back( 0.58e-6 );
214 m_paramPs7.clear();
215 m_paramPs7.push_back( 4.263e0 );
216 m_paramPs7.push_back( 95e-3 );
217 m_paramPs7.push_back( 0.47e-6 );
218 m_paramPs8.clear();
219 m_paramPs8.push_back( 3.872e0 );
220 m_paramPs8.push_back( 100e-3 );
221 m_paramPs8.push_back( 0.00e-6 );
222 m_paramUps.clear();
223 m_paramUps.push_back( 9.46030e0 );
224 m_paramUps.push_back( 0.0525e-3 );
225 m_paramUps.push_back( 1.32e-6 );
226 m_paramUp2.clear();
227 m_paramUp2.push_back( 10.02326e0 );
228 m_paramUp2.push_back( 0.044e-3 );
229 m_paramUp2.push_back( 0.52e-6 );
230 m_paramUp3.clear();
231 m_paramUp3.push_back( 10.3552e0 );
232 m_paramUp3.push_back( 0.026e-3 );
233 m_paramUp3.push_back( 0.00e-6 );
234 m_paramUp4.clear();
235 m_paramUp4.push_back( 10.580e0 );
236 m_paramUp4.push_back( 14e-3 );
237 m_paramUp4.push_back( 0.248e-6 );
238 m_paramUp5.clear();
239 m_paramUp5.push_back( 10.865e0 );
240 m_paramUp5.push_back( 110e-3 );
241 m_paramUp5.push_back( 0.31e-6 );
242 m_paramUp6.clear();
243 m_paramUp6.push_back( 11.019 );
244 m_paramUp6.push_back( 79e-3 );
245 m_paramUp6.push_back( 0.13e-6 );
246 m_paramZeta.clear();
247 m_paramZeta.push_back( 91.1876e0 );
248 m_paramZeta.push_back( 2.4952e0 );
249 m_paramZeta.push_back( 0.08391e0 );
250 m_paramW.clear();
251 m_paramW.push_back( 80.43 );
252 m_paramW.push_back( 2.11e0 );
253
254 declareProperty( "ResParameterRho", m_paramRho );
255 declareProperty( "ResParameterRh2", m_paramRh2 );
256 declareProperty( "ResParameterRh3", m_paramRh3 );
257 declareProperty( "ResParameterOme", m_paramOme );
258 declareProperty( "ResParameterOm2", m_paramOm2 );
259 declareProperty( "ResParameterOm3", m_paramOm3 );
260 declareProperty( "ResParameterPhi", m_paramPhi );
261 declareProperty( "ResParameterPh2", m_paramPh2 );
262 declareProperty( "ResParameterPsi", m_paramPsi );
263 declareProperty( "ResParameterPs2", m_paramPs2 );
264 declareProperty( "ResParameterPs3", m_paramPs3 );
265 declareProperty( "ResParameterPs4", m_paramPs4 );
266 declareProperty( "ResParameterPs5", m_paramPs5 );
267 declareProperty( "ResParameterPs6", m_paramPs6 );
268 declareProperty( "ResParameterPs7", m_paramPs7 );
269 declareProperty( "ResParameterPs8", m_paramPs8 );
270 declareProperty( "ResParameterUps", m_paramUps );
271 declareProperty( "ResParameterUp2", m_paramUp2 );
272 declareProperty( "ResParameterUp3", m_paramUp3 );
273 declareProperty( "ResParameterUp4", m_paramUp4 );
274 declareProperty( "ResParameterUp5", m_paramUp5 );
275 declareProperty( "ResParameterUp6", m_paramUp6 );
276 declareProperty( "ResParameterZeta", m_paramZeta );
277 declareProperty( "ResParameterW", m_paramW );
278
279 // psi(3770) decay
280 declareProperty( "Psi3770toNonDDb", m_ps3toNonDDb = 0.0 );
281 declareProperty( "Psi3770RatioOfD0toDp", m_ps3D0toDp = 0.563 );
282 // psi(4030) decay
283 declareProperty( "Psi4030toD0D0b", m_ps4toD0D0b = 0.0227 );
284 declareProperty( "Psi4030toDpDm", m_ps4toDpDm = 0.0167 );
285 declareProperty( "Psi4030toDsDs", m_ps4toDsDs = 0.0383 );
286 declareProperty( "Psi4030toD0D0Star", m_ps4toD0D0Star = 0.2952 );
287 declareProperty( "Psi4030toDpDmStar", m_ps4toDpDmStar = 0.2764 );
288 declareProperty( "Psi4030toD0StarD0Star", m_ps4toD0StarD0Star = 0.2476 );
289 declareProperty( "Psi4030toDpStarDmStar", m_ps4toDpStarDmStar = 0.1041 );
290 // psi(4160) decay
291 declareProperty( "Psi4160toD0D0b", m_ps5toD0D0b = 0.0190 );
292 declareProperty( "Psi4160toDpDm", m_ps5toDpDm = 0.0180 );
293 declareProperty( "Psi4160toDsDs", m_ps5toDsDs = 0.0488 );
294 declareProperty( "Psi4160toD0D0Star", m_ps5toD0D0Star = 0.1248 );
295 declareProperty( "Psi4160toDpDmStar", m_ps5toDpDmStar = 0.1240 );
296 declareProperty( "Psi4160toDsDsStar", m_ps5toDsDsStar = 0.0820 );
297 declareProperty( "Psi4160toD0StarD0Star", m_ps5toD0StarD0Star = 0.3036 );
298 declareProperty( "Psi4160toDpStarDmStar", m_ps5toDpStarDmStar = 0.2838 );
299 // beam polarization vector, pingrg:2016-9-27: confirmed by Z.Was at tao2016 Conference at
300 // IHEP for the definition of spin density of beam, see arXiv:9905452
301 m_beam1PolVec.clear();
302 m_beam2PolVec.clear();
303 declareProperty( "Beam1PolVec", m_beam1PolVec ); // e.g. beam1 has polarization 0.5:
304 // KKMC.Beam1PolVec={0,0,0.5}
305 declareProperty( "Beam2PolVec", m_beam2PolVec );
306 // interface to EvtGen
307 declareProperty( "ParticleDecayThroughEvtGen", m_evtGenDecay = true );
308 declareProperty( "RadiationCorrection", m_radiationCorrection = true );
309 // interface set pythia pars
310 m_pypars.clear();
311 declareProperty( "setPythiaPars", m_pypars );
312}
313
314StatusCode KKMC::initialize() {
315
316 MsgStream log( msgSvc(), name() );
317
318 log << MSG::INFO << "KKMC in initialize()" << endmsg;
319
320 // set Bes unified random engine
321 static const bool CREATEIFNOTTHERE( true );
322 StatusCode RndmStatus = service( "BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE );
323 if ( !RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc )
324 {
325 log << MSG::ERROR << " Could not initialize Random Number Service" << endmsg;
326 return RndmStatus;
327 }
328 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->GetEngine( "KKMC" );
330 //---
331 if ( m_ich == -2 || m_ich >= 0 )
332 { // ISR exclusive default set particle as Psi(4260)
333 m_generatePsi4260 = true;
334 m_generateJPsi = 0;
335 m_generatePsiPrime = 0;
336 m_generatePsi3770 = 0;
337 m_generatePsi4030 = 0;
338 m_generatePsi4160 = 0;
339 m_generatePsi4415 = 0;
340 }
341
342 WHYM_SETDEF( xwpar );
343 xwpar[0] = m_cmsEnergy; // c.m.s energy
344 xwpar[1] = m_cmsEnergySpread; // energy spread of c.m.s.
345 xwpar[3] = 6.0; // fortran output unit
346
347 // by Ke LI (like@ihep.ac.cn) 2015-02-16
348 xwpar[900] = m_ihvp; // (1,2,3)flag of hadronic vacuum polarization, 0: no vacuum
349 // polarization(leptonic and hadronic)
350 if ( m_beam1PolVec.size() == 3 )
351 {
352 xwpar[61] = m_beam1PolVec[0];
353 xwpar[62] = m_beam1PolVec[1];
354 xwpar[63] = m_beam1PolVec[2];
355 xwpar[28] = 1;
356 }
357
358 if ( m_beam2PolVec.size() == 3 )
359 {
360 xwpar[64] = m_beam2PolVec[0];
361 xwpar[65] = m_beam2PolVec[1];
362 xwpar[66] = m_beam2PolVec[2];
363 xwpar[28] = 1;
364 }
365
366 if ( m_generateResonance ) // flag indicate to generate Resonance data
367 xwpar[12] = 1.0;
368 else xwpar[12] = 0.0;
369
370 if ( m_generateContinuum ) // generate continuum
371 xwpar[3000] = 1.0;
372 else xwpar[3000] = 0.0;
373
374 if ( m_generateDownQuark ) // d quark production
375 xwpar[400] = 1.0;
376 else xwpar[400] = 0.0;
377
378 if ( m_generateUpQuark ) // u quark production
379 xwpar[401] = 1.0;
380 else xwpar[401] = 0.0;
381
382 if ( m_generateStrangeQuark ) // s quark production
383 xwpar[402] = 1.0;
384 else xwpar[402] = 0.0;
385
386 if ( m_generateCharmQuark ) // c quark production
387 xwpar[403] = 1.0;
388 else xwpar[403] = 0.0;
389
390 if ( m_generateBottomQuark ) // b quark production
391 xwpar[404] = 1.0;
392 else xwpar[404] = 0.0;
393
394 if ( m_generateMuonPair ) // e+ e- --> mu+ mu-
395 xwpar[412] = 1.0;
396 else xwpar[412] = 0.0;
397
398 if ( m_generateTauPair ) // e+ e- --> tau+ tau-
399 xwpar[414] = 1.0;
400 else xwpar[414] = 0.0;
401 int keyuds = 0;
402 if ( m_generateRho ) keyuds |= 1;
403 if ( m_generateOmega ) keyuds |= 2;
404 if ( m_generatePhi ) keyuds |= 4;
405
406 int keycharm = 0;
407 if ( m_generateJPsi ) keycharm |= 1;
408 if ( m_generatePsiPrime ) keycharm |= 2;
409 if ( m_generatePsi3770 ) keycharm |= 4;
410 if ( m_generatePsi4030 ) keycharm |= 8;
411 if ( m_generatePsi4160 ) keycharm |= 16;
412 if ( m_generatePsi4415 ) keycharm |= 32;
413 if ( m_generatePsi4260 ) keycharm |= 64;
414
415 // resonant parameters
416 int offset = 3100;
417 for ( int i = 0; i < 3; i++ ) xwpar[offset + i] = m_paramRho[i];
418 offset = offset + 3;
419 for ( int i = 0; i < 3; i++ ) xwpar[offset + i] = m_paramRh2[i];
420 offset = offset + 3;
421 for ( int i = 0; i < 3; i++ ) xwpar[offset + i] = m_paramRh3[i];
422 offset = offset + 3;
423 for ( int i = 0; i < 3; i++ ) xwpar[offset + i] = m_paramOme[i];
424 offset = offset + 3;
425 for ( int i = 0; i < 3; i++ ) xwpar[offset + i] = m_paramOm2[i];
426 offset = offset + 3;
427 for ( int i = 0; i < 3; i++ ) xwpar[offset + i] = m_paramOm3[i];
428 offset = offset + 3;
429 for ( int i = 0; i < 3; i++ ) xwpar[offset + i] = m_paramPhi[i];
430 offset = offset + 3;
431 for ( int i = 0; i < 3; i++ ) xwpar[offset + i] = m_paramPh2[i];
432 offset = offset + 3;
433 for ( int i = 0; i < 3; i++ ) xwpar[offset + i] = m_paramPsi[i];
434 offset = offset + 3;
435 for ( int i = 0; i < 3; i++ ) xwpar[offset + i] = m_paramPs2[i];
436 offset = offset + 3;
437 for ( int i = 0; i < 3; i++ ) xwpar[offset + i] = m_paramPs3[i];
438 offset = offset + 3;
439 for ( int i = 0; i < 3; i++ ) xwpar[offset + i] = m_paramPs4[i];
440 offset = offset + 3;
441 for ( int i = 0; i < 3; i++ ) xwpar[offset + i] = m_paramPs5[i];
442 offset = offset + 3;
443 for ( int i = 0; i < 3; i++ ) xwpar[offset + i] = m_paramPs6[i];
444 offset = offset + 3;
445 for ( int i = 0; i < 3; i++ ) xwpar[offset + i] = m_paramPs7[i];
446 offset = offset + 3;
447 for ( int i = 0; i < 3; i++ ) xwpar[offset + i] = m_paramPs8[i];
448 offset = offset + 3;
449 for ( int i = 0; i < 3; i++ ) xwpar[offset + i] = m_paramUps[i];
450 offset = offset + 3;
451 for ( int i = 0; i < 3; i++ ) xwpar[offset + i] = m_paramUp2[i];
452 offset = offset + 3;
453 for ( int i = 0; i < 3; i++ ) xwpar[offset + i] = m_paramUp3[i];
454 offset = offset + 3;
455 for ( int i = 0; i < 3; i++ ) xwpar[offset + i] = m_paramUp4[i];
456 offset = offset + 3;
457 for ( int i = 0; i < 3; i++ ) xwpar[offset + i] = m_paramUp5[i];
458 offset = offset + 3;
459 for ( int i = 0; i < 3; i++ ) xwpar[offset + i] = m_paramUp6[i];
460 offset = offset + 3;
461 for ( int i = 0; i < 3; i++ ) xwpar[offset + i] = m_paramZeta[i];
462 offset = offset + 3;
463 for ( int i = 0; i < 2; i++ ) xwpar[offset + i] = m_paramW[i];
464 // offset = offset + 2;
465
466 xwpar[3001] = keyuds + 0.0;
467 xwpar[3002] = keycharm + 0.0;
468
469 // psi(3770) decay
470 offset = 3200;
471 xwpar[offset + 0] = m_ps3toNonDDb;
472 xwpar[offset + 1] = m_ps3D0toDp;
473 DDBARMASS.ddbarmassCUT = m_DdbarCutPsi3770;
474 MODEXS.ich = m_ich;
475 // tag ISR or FSR photon
476 if ( m_isrtag ) { PHOTONTAG.isrtag = 1; }
477 else { PHOTONTAG.isrtag = 0; }
478 if ( m_fsrtag ) { PHOTONTAG.fsrtag = 1; }
479 else { PHOTONTAG.fsrtag = 0; }
480
481 // psi(4030) decay
482 offset = 3210;
483 xwpar[offset + 0] = m_ps4toD0D0b;
484 xwpar[offset + 1] = m_ps4toDpDm;
485 xwpar[offset + 2] = m_ps4toDsDs;
486 xwpar[offset + 3] = m_ps4toD0D0Star;
487 xwpar[offset + 4] = m_ps4toDpDmStar;
488 xwpar[offset + 5] = m_ps4toD0StarD0Star;
489 xwpar[offset + 6] = m_ps4toDpStarDmStar;
490 // psi(4160) decay
491 offset = 3220;
492 xwpar[offset + 0] = m_ps5toD0D0b;
493 xwpar[offset + 1] = m_ps5toDpDm;
494 xwpar[offset + 2] = m_ps5toDsDs;
495 xwpar[offset + 3] = m_ps5toD0D0Star;
496 xwpar[offset + 4] = m_ps5toDpDmStar;
497 xwpar[offset + 5] = m_ps5toDsDsStar;
498 xwpar[offset + 6] = m_ps5toD0StarD0Star;
499 xwpar[offset + 7] = m_ps5toDpStarDmStar;
500
501 if ( !m_radiationCorrection )
502 {
503 xwpar[19] = 0;
504 xwpar[20] = 0;
505 xwpar[26] = 0;
506 }
507
508 KK2F_INITIALIZE( xwpar );
509 MY_PYUPD();
510 PYUPDA( 1, 22 );
511 // for pythia parameter tunning,pingrg-2013-6-9
512 for ( int i = 0; i < m_pypars.size(); i++ )
513 { pygive_( m_pypars[i].c_str(), strlen( m_pypars[i].c_str() ) ); }
514
515 if ( m_evtGenDecay )
516 {
519 }
520 else
521 {
523 PHOINI();
524 }
525
526 HepMC::HEPEVT_Wrapper::set_sizeof_real( 8 );
527 HepMC::HEPEVT_Wrapper::set_sizeof_int( 4 );
528 HepMC::HEPEVT_Wrapper::set_max_number_entries( 4000 );
529 // std::cout << "max entries = " << HepMC::HEPEVT_Wrapper::max_number_entries() <<std::endl;
530 // std::cout << "size of real = " << HepMC::HEPEVT_Wrapper::sizeof_real() <<std::endl;
531
532 /*** Read Database --Wu Lianjin ***/
533 if ( m_RdMeasuredEcms )
534 {
535 StatusCode status = serviceLocator()->service( "MeasuredEcmsSvc", ecmsSvc, true );
536 if ( !status.isSuccess() )
537 {
538 std::cout << "ERROR: Can not initial the IMeasuredEcmsSvc right" << std::endl;
539 return status;
540 }
541 }
542 /*** ***/
543
544 log << MSG::INFO << "Finish KKMC initialize()" << endmsg;
545 return StatusCode::SUCCESS;
546}
547
548StatusCode KKMC::execute() {
549 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(), "/Event/EventHeader" );
550 int runNo = eventHeader->runNumber();
551 int event = eventHeader->eventNumber();
552 bool newRunFlag = 0;
553 if ( runNo != 0 && runNo != m_runNo )
554 {
555 m_runNo = runNo;
556 newRunFlag = true;
557 }
558 else { newRunFlag = false; }
559
560 // std::cout<<"runNo= "<<runNo<<" m_runNo "<<m_runNo<<" newRunFlag= "<<newRunFlag<<std::endl;
561
562 /****** Lianjin Wu add ******/
563 if ( m_RdMeasuredEcms && newRunFlag )
564 { // using cms energy of beam read from database
565 // if(!ecmsSvc->isRunNoValid()){
566 // std::cout<<"ERROR: Can not read the MeasuredEcms, try to turn off the
567 // ReadEcmsDB"<<std::endl; return StatusCode::FAILURE;
568 // }
569 double dbEcms = ecmsSvc->getEcms();
570 std::cout << "INFO: Read the MeasuredEcms: " << dbEcms << " GeV" << std::endl;
571 m_cmsEnergy = dbEcms;
572 xwpar[0] = m_cmsEnergy;
573 KK2F_INITIALIZE( xwpar );
574 }
575 /****** ******/
576 // std::cout<<"The beam energy is "<<m_cmsEnergy<<", set for RunNo "<<runNo<<std::endl;
577
578 MsgStream log( msgSvc(), name() );
579
580 log << MSG::INFO << "KKMC in execute()" << endmsg;
581
582 HepMC::IO_HEPEVT HepEvtIO;
583
584 int KeySkip, iflag;
585 do {
586 HEPEVT_CLEAN();
587 KK2F_MAKE();
588 KK2F_GETKEYSKIP( KeySkip );
589 PSIPP_DDBARCUT( iflag );
590 } while ( KeySkip != 0 || iflag == 0 );
591
592 int KeyInter;
593 KK2F_GETEVTGENINTERFACE( KeyInter );
594
595 // PSIPP_DDBARCUT(iflag);
596 // if(iflag == 0) {return StatusCode::SUCCESS;}
597
598 if ( KeyInter == 0 )
599 { // make photos correction
600 int Pos1, Pos2, KFfin, Nhep;
601 HEPEVT_NUMHEP( Nhep );
602 HEPEVT_GETF( Pos1 );
603 HEPEVT_GETFBAR( Pos2 );
604 HEPEVT_GETKFFIN( KFfin );
605 int Posn = Pos1;
606 if ( Pos2 > Posn ) Posn = Pos2;
607 Posn = Posn + 1;
608 if ( KFfin < 10 ) Posn = Posn + 1;
609 for ( int ip = Posn; ip <= Nhep; ip++ ) HEPEVT_SETPHOTOSFLAGTRUE( ip );
610 for ( int ip = Posn; ip <= Nhep; ip++ ) PHOTOS( ip );
611 PYHEPC( 2 );
612 }
613
614 // sleep(5);
615
616 m_numberEvent += 1;
617
618 if ( m_numberEvent <= m_numberEventPrint ) PYLIST( 1 );
619 log << MSG::INFO << " " << m_numberEvent << "th event was generated !!" << endmsg;
620
621 PYHEPC( 1 );
622
623 HepMC::GenEvent* evt = HepEvtIO.read_next_event();
624 evt->set_event_number( m_numberEvent );
625 evt->set_signal_process_id( 1 );
626 // evt->print();
627
628 // Check if the McCollection already exists
629 SmartDataPtr<McGenEventCol> anMcCol( eventSvc(), "/Event/Gen" );
630 if ( anMcCol != 0 )
631 {
632 // Add event to existing collection
633 MsgStream log( msgSvc(), name() );
634 log << MSG::INFO << "Add McGenEvent to existing collection" << endmsg;
635 McGenEvent* mcEvent = new McGenEvent( evt );
636 anMcCol->push_back( mcEvent );
637 }
638 else
639 {
640 // Create Collection and add to the transient store
641 McGenEventCol* mcColl = new McGenEventCol;
642 McGenEvent* mcEvent = new McGenEvent( evt );
643 mcColl->push_back( mcEvent );
644 StatusCode sc = eventSvc()->registerObject( "/Event/Gen", mcColl );
645 if ( sc != StatusCode::SUCCESS )
646 {
647 log << MSG::ERROR << "Could not register McGenEvent" << endmsg;
648 delete mcColl;
649 delete evt;
650 delete mcEvent;
651 return StatusCode::FAILURE;
652 }
653 else
654 {
655 // log << MSG::INFO << "McGenEventCol created and " << npart <<" particles stored in
656 // McGenEvent" << endmsg;
657 }
658 }
659
660 return StatusCode::SUCCESS;
661}
662
663StatusCode KKMC::finalize() {
664
665 MsgStream log( msgSvc(), name() );
666
667 log << MSG::INFO << "KKMC in finalize()" << endmsg;
668
670 double xSecPb, xErrPb;
671 KK2F_GETXSECMC( xSecPb, xErrPb );
672
673 log << MSG::INFO << "Total MC Xsec = " << xSecPb << " +/- " << xErrPb << endmsg;
674 return StatusCode::SUCCESS;
675}
DECLARE_COMPONENT(BesBdkRc)
#define HEPEVT_CLEAN()
Definition BesBdkRc.cxx:96
int runNo
Definition DQA_TO_DB.cxx:13
ObjectVector< McGenEvent > McGenEventCol
void pygive_(const char *cnfgstr, int length)
#define MY_PYUPD()
Definition KKMC.cxx:26
#define PYHEPC(ICONV)
Definition KKMC.cxx:52
#define PSIPP_DDBARCUT(KEY)
Definition KKMC.cxx:40
#define KK2F_SETEVTGENINTERFACE(KEY)
Definition KKMC.cxx:55
#define PHOINI()
Definition KKMC.cxx:75
#define KK2F_GETEVTGENINTERFACE(KEY)
Definition KKMC.cxx:58
#define WHYM_SETDEF(XPAR)
Definition KKMC.cxx:24
#define HEPEVT_GETKFFIN(KFIN)
Definition KKMC.cxx:68
COMMON_BLOCK_DEF(DDBAR_DEF, DDBARMASS)
#define DDBARMASS
Definition KKMC.cxx:86
void pygive_(const char *cnfgstr, int length)
#define PSEUMAR_INITIALIZE(ijklin, ntot1n, ntot2n)
Definition KKMC.cxx:20
#define PYLIST(LIST)
Definition KKMC.cxx:49
#define KK2F_GETXSECMC(xsecpb, xerrpb)
Definition KKMC.cxx:45
#define PHOTONTAG
Definition KKMC.cxx:92
#define PYUPDA(MUPDA, LFN)
Definition KKMC.cxx:81
#define KK2F_FINALIZE()
Definition KKMC.cxx:43
#define HEPEVT_NUMHEP(Nhep)
Definition KKMC.cxx:62
#define KK2F_MAKE()
Definition KKMC.cxx:34
#define KK2F_GETKEYSKIP(KEY)
Definition KKMC.cxx:37
#define HEPEVT_GETF(POS)
Definition KKMC.cxx:64
#define MODEXS
Definition KKMC.cxx:98
#define KK2F_INITIALIZE(XPAR)
Definition KKMC.cxx:29
#define HEPEVT_SETPHOTOSFLAGTRUE(IP)
Definition KKMC.cxx:70
#define TURNOFFTAUDECAY()
Definition KKMC.cxx:78
#define HEPEVT_GETFBAR(POS)
Definition KKMC.cxx:66
#define PHOTOS(IP)
Definition KKMC.cxx:73
IMessageSvc * msgSvc()
static void setRandomEngine(CLHEP::HepRandomEngine *randomEngine)
Definition KKMC.h:19
KKMC(const std::string &name, ISvcLocator *pSvcLocator)
Definition KKMC.cxx:109
StatusCode initialize()
Definition KKMC.cxx:314
StatusCode finalize()
Definition KKMC.cxx:663
StatusCode execute()
Definition KKMC.cxx:548
PROTOCCALLSFSUB3(INPUT, input, PLONG, PINT, PSTRING)
PROTOCCALLSFSUB1(RLXDRESETF, rlxdresetf, INTV)
PROTOCCALLSFSUB2(RANLXDF, ranlxdf, DOUBLEV, INT)
PROTOCCALLSFSUB0(INITHISTO, inithisto)
double ddbarmassCUT
Definition KKMC.cxx:84
int ich
Definition KKMC.cxx:96