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