CGEM BOSS 6.6.5.f
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
147BesTwogam::BesTwogam(const string& name, ISvcLocator* pSvcLocator):Algorithm( name, pSvcLocator )
148{
149 declareProperty("InitialSeed",m_seed=1001);
150 declareProperty("CMEnergy", m_cmEnergy = 3.097); // 2*Ebeam [GeV]
151 declareProperty("MinimumW2",m_m2min=0.02);
152 declareProperty("Unweighted",m_unw=1);
153 declareProperty("CardFileName", m_fcard="BesTwogam.conf");
154}
155
157 MsgStream log(messageService(), name());
158 log << MSG::WARNING << "BesTwogam initialize" << endreq;
159
160 if(m_fcard.size()>254){
161 log << MSG::ERROR << "Too big name of BesTwogam card file" << endreq;
162 return StatusCode::FAILURE;
163 }
164 // FNAMES.dummy=61777;
165 strcpy(FNAMES.cardName,m_fcard.c_str());
166 FNAMES.i_cardName=m_fcard.size();
167
168 RDCUTS();
169 ISEEDC.ISEED=m_seed;
170 EXCUTS.EBEAME=0.5*m_cmEnergy;
171 EXCUTS.W2MINE=m_m2min;
172 INPARC.NTUNW=m_unw;
173
174 SETDEF();
175 QCDSTA();
176 DOCUTS();
177 ESTMAXCS();
178 PRTCUT();
179 // USRINI();
180 m_numberEvent=0;
181 return StatusCode::SUCCESS;
182}
183
185{
186 MsgStream log(messageService(), name());
187 log << MSG::INFO << "BesTwogam executing" << endreq;
188 HepMC::HEPEVT_Wrapper::set_max_number_entries(2000);
189 HepMC::HEPEVT_Wrapper::set_sizeof_real(8);
190 HepMC::IO_HEPEVT HepEvtIO;
191 HEPEVT_CLEAN();
192 GEN1EVT();
193 //PRINTEVT();
194 if(CFLAGS.GOODEV!=1){
195 log << MSG::ERROR<<" BesTwogam: fail to generate good event"<<endl;
196 return StatusCode::FAILURE;
197 }
198 m_numberEvent++;
199 if( log.level() < MSG::INFO )LULIST(1);
200 LUHEPC(1);
201 // HEPEVT_PRINT();
202 HepMC::GenEvent* evt = HepEvtIO.read_next_event();
203 evt->set_event_number(m_numberEvent);
204 evt->set_signal_process_id(1);
205 //Check if the McCollection already exists
206 SmartDataPtr<McGenEventCol> anMcCol(eventSvc(), "/Event/Gen");
207 if (anMcCol!=0) {
208 // Add event to existing collection
209 MsgStream log(messageService(), name());
210 log << MSG::INFO << "Add McGenEvent to existing collection" << endreq;
211 McGenEvent* mcEvent = new McGenEvent(evt);
212 anMcCol->push_back(mcEvent);
213 } else {
214 // Create Collection and add to the transient store
215 McGenEventCol *mcColl = new McGenEventCol;
216 McGenEvent* mcEvent = new McGenEvent(evt);
217 mcColl->push_back(mcEvent);
218 StatusCode sc = eventSvc()->registerObject("/Event/Gen",mcColl);
219 if (sc != StatusCode::SUCCESS) {
220 log << MSG::ERROR << "Could not register McGenEvent" << endreq;
221 delete mcColl;
222 delete evt;
223 delete mcEvent;
224 return StatusCode::FAILURE;
225 }
226 }
227 return StatusCode::SUCCESS;
228}
229
231{
232 MsgStream log(messageService(), name());
233 log << MSG::INFO << "BesTwogam finalized" << endreq;
234 FINISH();
235 return StatusCode::SUCCESS;
236}
#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
#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 PROTOCCALLSFSUB1(UN, LN, T1)
BesTwogam(const string &name, ISvcLocator *pSvcLocator)
Definition: BesTwogam.cxx:147
StatusCode execute()
Definition: BesTwogam.cxx:184
StatusCode finalize()
Definition: BesTwogam.cxx:230
StatusCode initialize()
Definition: BesTwogam.cxx:156
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