BOSS 7.0.3
BESIII Offline Software System
Loading...
Searching...
No Matches
BesTwogam.cxx
Go to the documentation of this file.
1//*****************************************************************************
2//
3// BesTwogam.cxx
4//
5//*****************************************************************************
6
7// Header for this module:-
8#include "BesTwogam/BesTwogam.h"
9
10// Framework Related Headers:-
11#include "HepMC/GenEvent.h"
12//#include "CLHEP/HepMC/GenVertex.h"
13//#include "CLHEP/HepMC/GenParticle.h"
14
15#include "HepMC/HEPEVT_Wrapper.h"
16#include "HepMC/IO_HEPEVT.h"
17
18#include "GaudiKernel/MsgStream.h"
19#include "GaudiKernel/ISvcLocator.h"
20#include "GaudiKernel/AlgFactory.h"
21#include "GaudiKernel/DataSvc.h"
22#include "GaudiKernel/SmartDataPtr.h"
23
24#include "GeneratorObject/McGenEvent.h"
25
26#include "cfortran/cfortran.h"
27
28#include <stdlib.h>
29
30typedef struct{
31 int ISEED;
33#define ISEEDC COMMON_BLOCK(ISEEDC_DEF,iseedc)
35
36typedef struct{
38 char cardName[255];
40#define FNAMES COMMON_BLOCK(FNAMES_DEF,fnames)
42
43typedef struct{
44 int NEVTOT,NTUNW,NSMALL,IPROC1,LUNOUT,IDEBUG,LUN,NTRY;
46#define INPARC COMMON_BLOCK(INPARC_DEF,inparc)
48typedef struct{
49 float RLUMI;
50 float CST;
52#define LUMINO COMMON_BLOCK( LUMINO_DEF,lumino)
54typedef struct{
55 int NEVENT,NEVCUT,NEVUNW;
57#define EVENUM COMMON_BLOCK(EVENUM_DEF,evenum)
59typedef struct{
60 double MAXESW,SUMW[5],MEANW[5],SUMW2[5],MAXW;
61 double SUMWC[5],MEANWC[5],SUMW2C[5];
63#define UNWEIT COMMON_BLOCK(UNWEIT_DEF,unweit)
65typedef struct{
66 double WT,SUMWT,SUMWTC;
68#define WEIGHTED COMMON_BLOCK(WEIGHTED_DEF,weighted)
70typedef struct{
71 int GOODEV;
73#define CFLAGS COMMON_BLOCK(CFLAGS_DEF,cflags)
75
76typedef struct{
77 float OM1MNE, OM1MXE, OM2MNE, OM2MXE,
78 T1MINE, T1MAXE, T2MINE, T2MAXE,
79 Q12MNE, Q12MXE, Q22MNE, Q22MXE,
80 W2MINE, W2MAXE, TKMINE, TKMAXE, EBEAME, MAXESW;
82#define EXCUTS COMMON_BLOCK(EXCUTS_DEF, excuts)
84
85typedef struct{
86 int N;
87 int K[5][4000];
88 float P[5][4000],V[5][4000];
90#define LUJETS COMMON_BLOCK(LUJETS_DEF,lujets)
92
94#define PRINTEVT() CCALLSFSUB0(PRINTEVT,printevt)
95
97#define INIRUN() CCALLSFSUB0(INIRUN,inirun)
98
100#define FINISH() CCALLSFSUB0(FINISH,finish)
101
103#define GENEVT() CCALLSFSUB0(GENEVT,genevt)
104
106#define GEN1EVT() CCALLSFSUB0(GEN1EVT,gen1evt)
107
108PROTOCCALLSFSUB0( RDCUTS , rdcuts)
109#define RDCUTS() CCALLSFSUB0( RDCUTS,rdcuts)
110
111PROTOCCALLSFSUB0( SETDEF , setdef)
112#define SETDEF() CCALLSFSUB0( SETDEF,setdef)
113
114PROTOCCALLSFSUB0( QCDSTA , qcdsta)
115#define QCDSTA() CCALLSFSUB0( QCDSTA,qcdsta)
116
117PROTOCCALLSFSUB0( DOCUTS , docuts)
118#define DOCUTS() CCALLSFSUB0( DOCUTS,docuts)
119
120PROTOCCALLSFSUB0( ESTMAXCS , estmaxcs)
121#define ESTMAXCS() CCALLSFSUB0( ESTMAXCS,estmaxcs)
122
123PROTOCCALLSFSUB0( PRTCUT , prtcut)
124#define PRTCUT() CCALLSFSUB0( PRTCUT,prtcut)
125
126PROTOCCALLSFSUB0( USRINI , usrini)
127#define USRINI() CCALLSFSUB0( USRINI,usrini)
128
129PROTOCCALLSFSUB0( USRHIS , usrhis)
130#define USRHIS() CCALLSFSUB0( USRHIS,usrhis)
131
132PROTOCCALLSFSUB0( USREND , usrend)
133#define USREND() CCALLSFSUB0( USREND,usrend)
134//
135PROTOCCALLSFSUB1(LUHEPC, luhepc, INT)
136#define LUHEPC(ICONV) CCALLSFSUB1(LUHEPC, luhepc, INT, ICONV)
137
138PROTOCCALLSFSUB0(HEPEVT_CLEAN, hepevt_clean)
139#define HEPEVT_CLEAN() CCALLSFSUB0(HEPEVT_CLEAN, hepevt_clean)
140
141PROTOCCALLSFSUB1(LULIST, lulist, INT)
142#define LULIST(ICONV) CCALLSFSUB1(LULIST, lulist, INT, ICONV)
143
144PROTOCCALLSFSUB0(HEPEVT_PRINT, hepevt_print)
145#define HEPEVT_PRINT() CCALLSFSUB0(HEPEVT_PRINT, hepevt_print)
146
147extern "C" {
148 extern void pygive_(const char *cnfgstr,int length);
149}
150
151
152BesTwogam::BesTwogam(const string& name, ISvcLocator* pSvcLocator):Algorithm( name, pSvcLocator )
153{
154 declareProperty("InitialSeed",m_seed=1001);
155 declareProperty("CMEnergy", m_cmEnergy = 3.097); // 2*Ebeam [GeV]
156 declareProperty("MinimumW2",m_m2min=0.02);
157 declareProperty("Unweighted",m_unw=1);
158 declareProperty("CardFileName", m_fcard="BesTwogam.conf");
159 //interface set pythia pars, pingrg
160 m_pypars.clear();
161 declareProperty("setPythiaPars", m_pypars);
162}
163
165 MsgStream log(messageService(), name());
166 log << MSG::WARNING << "BesTwogam initialize" << endreq;
167
168 if(m_fcard.size()>254){
169 log << MSG::ERROR << "Too big name of BesTwogam card file" << endreq;
170 return StatusCode::FAILURE;
171 }
172 // FNAMES.dummy=61777;
173 strcpy(FNAMES.cardName,m_fcard.c_str());
174 FNAMES.i_cardName=m_fcard.size();
175
176 RDCUTS();
177 ISEEDC.ISEED=m_seed;
178 EXCUTS.EBEAME=0.5*m_cmEnergy;
179 EXCUTS.W2MINE=m_m2min;
180 INPARC.NTUNW=m_unw;
181
182 SETDEF();
183 QCDSTA();
184 DOCUTS();
185 ESTMAXCS();
186 PRTCUT();
187 // USRINI();
188 m_numberEvent=0;
189 //for pythia parameter setting,pingrg-2013-12-11
190 for(int i=0;i<m_pypars.size();i++){
191 pygive_(m_pypars[i].c_str(),strlen(m_pypars[i].c_str()));
192 }
193 return StatusCode::SUCCESS;
194}
195
197{
198 MsgStream log(messageService(), name());
199 log << MSG::INFO << "BesTwogam executing" << endreq;
200 HepMC::HEPEVT_Wrapper::set_max_number_entries(2000);
201 HepMC::HEPEVT_Wrapper::set_sizeof_real(8);
202 HepMC::IO_HEPEVT HepEvtIO;
203 HEPEVT_CLEAN();
204 GEN1EVT();
205 //PRINTEVT();
206 if(CFLAGS.GOODEV!=1){
207 log << MSG::ERROR<<" BesTwogam: fail to generate good event"<<endl;
208 return StatusCode::FAILURE;
209 }
210 m_numberEvent++;
211 if( log.level() < MSG::INFO )LULIST(1);
212 LUHEPC(1);
213 // HEPEVT_PRINT();
214 HepMC::GenEvent* evt = HepEvtIO.read_next_event();
215 evt->set_event_number(m_numberEvent);
216 evt->set_signal_process_id(1);
217 //Check if the McCollection already exists
218 SmartDataPtr<McGenEventCol> anMcCol(eventSvc(), "/Event/Gen");
219 if (anMcCol!=0) {
220 // Add event to existing collection
221 MsgStream log(messageService(), name());
222 log << MSG::INFO << "Add McGenEvent to existing collection" << endreq;
223 McGenEvent* mcEvent = new McGenEvent(evt);
224 anMcCol->push_back(mcEvent);
225 } else {
226 // Create Collection and add to the transient store
227 McGenEventCol *mcColl = new McGenEventCol;
228 McGenEvent* mcEvent = new McGenEvent(evt);
229 mcColl->push_back(mcEvent);
230 StatusCode sc = eventSvc()->registerObject("/Event/Gen",mcColl);
231 if (sc != StatusCode::SUCCESS) {
232 log << MSG::ERROR << "Could not register McGenEvent" << endreq;
233 delete mcColl;
234 delete evt;
235 delete mcEvent;
236 return StatusCode::FAILURE;
237 }
238 }
239 return StatusCode::SUCCESS;
240}
241
243{
244 MsgStream log(messageService(), name());
245 log << MSG::INFO << "BesTwogam finalized" << endreq;
246 FINISH();
247 return StatusCode::SUCCESS;
248}
#define LULIST(ICONV)
Definition: BesBdkRc.cxx:97
#define FINISH(IN, SIGT, ER)
Definition: BesBdkRc.cxx:109
#define GEN1EVT()
Definition: BesBdkRc.cxx:118
#define LUHEPC(ICONV)
Definition: BesBdkRc.cxx:94
#define HEPEVT_CLEAN()
Definition: BesBdkRc.cxx:100
#define INIRUN()
Definition: BesTwogam.cxx:97
#define ISEEDC
Definition: BesTwogam.cxx:33
#define DOCUTS()
Definition: BesTwogam.cxx:118
#define FNAMES
Definition: BesTwogam.cxx:40
#define LULIST(ICONV)
Definition: BesTwogam.cxx:142
#define EVENUM
Definition: BesTwogam.cxx:57
#define ESTMAXCS()
Definition: BesTwogam.cxx:121
#define HEPEVT_PRINT()
Definition: BesTwogam.cxx:145
#define GENEVT()
Definition: BesTwogam.cxx:103
#define USRINI()
Definition: BesTwogam.cxx:127
void pygive_(const char *cnfgstr, int length)
#define UNWEIT
Definition: BesTwogam.cxx:63
#define EXCUTS
Definition: BesTwogam.cxx:82
#define USREND()
Definition: BesTwogam.cxx:133
#define PRTCUT()
Definition: BesTwogam.cxx:124
#define SETDEF()
Definition: BesTwogam.cxx:112
#define PRINTEVT()
Definition: BesTwogam.cxx:94
#define RDCUTS()
Definition: BesTwogam.cxx:109
#define FINISH()
Definition: BesTwogam.cxx:100
#define INPARC
Definition: BesTwogam.cxx:46
#define GEN1EVT()
Definition: BesTwogam.cxx:106
#define LUHEPC(ICONV)
Definition: BesTwogam.cxx:136
#define WEIGHTED
Definition: BesTwogam.cxx:68
#define LUMINO
Definition: BesTwogam.cxx:52
#define CFLAGS
Definition: BesTwogam.cxx:73
#define QCDSTA()
Definition: BesTwogam.cxx:115
#define USRHIS()
Definition: BesTwogam.cxx:130
#define HEPEVT_CLEAN()
Definition: BesTwogam.cxx:139
#define LUJETS
Definition: BesTwogam.cxx:90
double P(RecMdcKalTrack *trk)
#define COMMON_BLOCK_DEF(DEFINITION, NAME)
#define PROTOCCALLSFSUB0(UN, LN)
#define PROTOCCALLSFSUB1(UN, LN, T1)
void pygive_(const char *cnfgstr, int length)
BesTwogam(const string &name, ISvcLocator *pSvcLocator)
Definition: BesTwogam.cxx:152
StatusCode execute()
Definition: BesTwogam.cxx:196
StatusCode finalize()
Definition: BesTwogam.cxx:242
StatusCode initialize()
Definition: BesTwogam.cxx:164
float EBEAME
Definition: BesTwogam.cxx:80
float Q12MNE
Definition: BesTwogam.cxx:79
float OM1MNE
Definition: BesTwogam.cxx:77
float T1MAXE
Definition: BesTwogam.cxx:78
int i_cardName
Definition: BesTwogam.cxx:37
float CST
Definition: BesTwogam.cxx:50
float RLUMI
Definition: BesTwogam.cxx:49
double MAXESW
Definition: BesTwogam.cxx:60
double SUMWT
Definition: BesTwogam.cxx:66