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