BOSS 7.1.2
BESIII Offline Software System
Loading...
Searching...
No Matches
BesBdkRc.cxx
Go to the documentation of this file.
1//*****************************************************************************
2//
3//
4//
5//*****************************************************************************
6
7// Header for this module:-
8#include "BesBdkRc/BesBdkRc.h"
10
11// Framework Related Headers:-
12#include "HepMC/GenEvent.h"
13
14#include "HepMC/HEPEVT_Wrapper.h"
15#include "HepMC/IO_HEPEVT.h"
16#include "HepMC/GenEvent.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"
24
26#include "cfortran/cfortran.h"
27#include <cstdlib>
28#include <cassert>
29
30using namespace std;
31
32typedef struct{
33 double EB,W2MIN,K0,KS,EWE;
35#define INPUT COMMON_BLOCK(INPUT_DEF,input)
37
38typedef struct{
39 double ME,MU,PI,ALFA,BARN;
41#define PCONST COMMON_BLOCK(PCONST_DEF, pconst)
43
44typedef struct{
45 float TCHMIN, PCHMIN;
47#define FINCUT COMMON_BLOCK(FINCUT_DEF, fincut)
49
50typedef struct{
51 float W2MINR, EBEAM, MAXESW, KZERO;
52 int ISEED;
53 float QMASS[6];
55#define LOCALC COMMON_BLOCK(LOCALC_DEF, localc)
57
58typedef struct{
59 double COLCHA;
60 int IFINAL;
62#define COLCHC COMMON_BLOCK(COLCHC_DEF, colchc)
64
65typedef struct{
66 int NEVCUT, NEVTOT, MAXNTRY;
68#define DELPHC COMMON_BLOCK(DELPHC_DEF, delphc)
70
71typedef struct{
72 int ITOT, NEVUNW;
73 double CSTOT,CSERR;
74 float CSCUT, CSCUTERR;
76#define XSECTC COMMON_BLOCK(XSECTC_DEF, xsectc)
78
79typedef struct{
82#define FLAGS COMMON_BLOCK(FLAGS_DEF, flags)
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
93PROTOCCALLSFSUB1(LUHEPC, luhepc, INT)
94#define LUHEPC(ICONV) CCALLSFSUB1(LUHEPC, luhepc, INT, ICONV)
95
96PROTOCCALLSFSUB1(LULIST, lulist, INT)
97#define LULIST(ICONV) CCALLSFSUB1(LULIST, lulist, INT, ICONV)
98
99PROTOCCALLSFSUB0(HEPEVT_CLEAN, hepevt_clean)
100#define HEPEVT_CLEAN() CCALLSFSUB0(HEPEVT_CLEAN, hepevt_clean)
101
102PROTOCCALLSFSUB0(HEPEVT_PRINT, hepevt_print)
103#define HEPEVT_PRINT() CCALLSFSUB0(HEPEVT_PRINT, hepevt_print)
104
105PROTOCCALLSFSUB1(BDKRC,bdkrc,INT)
106#define BDKRC(IDUMP) CCALLSFSUB1(BDKRC, bdkrc, INT, IDUMP)
107
108PROTOCCALLSFSUB3(FINISH,finish,PINT,PDOUBLE,PDOUBLE)
109#define FINISH(IN,SIGT,ER) CCALLSFSUB3(FINISH,finish,PINT,PDOUBLE,PDOUBLE,IN,SIGT,ER)
110
111PROTOCCALLSFSUB4(RLUXGO,rluxgo,INT,INT,INT,INT)
112#define RLUXGO(lux,ISEED,K1,K2) CCALLSFSUB4(RLUXGO,rluxgo,INT,INT,INT,INT,lux,ISEED,K1,K2)
113
114PROTOCCALLSFSUB0(GEN_INIT, gen_init)
115#define GEN_INIT() CCALLSFSUB0(GEN_INIT, gen_init)
116
118#define GEN1EVT() CCALLSFSUB0(GEN1EVT, gen1evt)
119
120extern "C" {
121 extern float flat_();
122}
123
124float flat_()
125{
126 return (float)BesBdkRcRandom::random();
127}
128
129BesBdkRc::BesBdkRc(const string& name, ISvcLocator* pSvcLocator):Algorithm( name, pSvcLocator )
130{
131// declareProperty("InitialSeed",m_iseed=1001);
132 declareProperty("CMEnergy", m_CMEnergy = 3.097); // 2*Ebeam [GeV]
133 declareProperty("W2min",m_w2min=0.02); // Cut on invariant gamma-gamma mass
134 declareProperty("EstimatedMaxWeight", m_ewe=2.5);
135 declareProperty("SoftPhotonMaxEnergy", m_kzero=0.002);
136 qmass[0] = 0.2;
137 qmass[1] = 0.2;
138 qmass[2] = 0.5;
139 qmass[3] = 1.5;
140 qmass[4] = 4.5;
141 qmass[5] = 180.;
142 declareProperty("MaxNTry", m_maxNTry);
143 declareProperty("FinalState", m_ifinal);
144 declareProperty("MinTheta",m_tcmin);
145 declareProperty("MinMomentum",m_pcmin);
146
147 m_numberEvent=0;
148 toRad=M_PI/180.0;
149 toDeg=180.0/M_PI;
150}
151
153 MsgStream log(messageService(), name());
154 log << MSG::WARNING << "BesBdkRc initialize" << endreq;
155
156 static const bool CREATEIFNOTTHERE(true);
157 StatusCode RndmStatus = service("BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE);
158 if (!RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc)
159 {
160 log << MSG::ERROR << " Could not initialize Random Number Service" << endreq;
161 return RndmStatus;
162 }
163 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->GetEngine("BesBdkRc");
164 engine->showStatus();
166
167 //"INIT" subroutine action is replaced by c++ code
168 // for gen_init fortran code is called
169
170 FINCUT.TCHMIN=m_tcmin*toRad;
171 FINCUT.PCHMIN=m_pcmin;
172// RLUXGO(3,m_iseed,0,0);
173
174 DELPHC.MAXNTRY=m_maxNTry;
175
176 COLCHC.IFINAL=m_ifinal;
177
178 INPUT.EB=0.5*m_CMEnergy;
179
180 LOCALC.W2MINR=m_w2min;
181 LOCALC.EBEAM=0.5*m_CMEnergy;
182 LOCALC.MAXESW=m_ewe;
183 LOCALC.KZERO=m_kzero;
184// LOCALC.ISEED=m_iseed;
185 for(int i=0; i<6;i++)LOCALC.QMASS[i]=qmass[i];
186 GEN_INIT();
187 XSECTC.NEVUNW=0;
188
189 return StatusCode::SUCCESS;
190}
191
192StatusCode BesBdkRc::execute()
193{
194 MsgStream log(messageService(), name());
195 log << MSG::INFO << "BesBdkRc executing" << endreq;
196 HepMC::HEPEVT_Wrapper::set_max_number_entries(2000);
197 HepMC::HEPEVT_Wrapper::set_sizeof_real(8);
198 HepMC::IO_HEPEVT HepEvtIO;
199
200 HEPEVT_CLEAN();
201 GEN1EVT();
202
203 if(FLAGS.GOODEVT!=1){
204 log << MSG::ERROR<<" BesBdkRc: fail to generate good event"<<endl;
205 return StatusCode::FAILURE;
206 }
207
208 m_numberEvent++;
209 if( log.level() < MSG::INFO )LULIST(1);
210 // LULIST(1);
211 LUHEPC(1);
212 HepMC::GenEvent* evt = HepEvtIO.read_next_event();
213 evt->set_event_number(m_numberEvent);
214 evt->set_signal_process_id(1);
215 // evt->print();
216 //Check if the McCollection already exists
217 SmartDataPtr<McGenEventCol> anMcCol(eventSvc(), "/Event/Gen");
218 if (anMcCol!=0) {
219 // Add event to existing collection
220 MsgStream log(messageService(), name());
221 log << MSG::INFO << "Add McGenEvent to existing collection" << endreq;
222 McGenEvent* mcEvent = new McGenEvent(evt);
223 anMcCol->push_back(mcEvent);
224 } else {
225 // Create Collection and add to the transient store
226 McGenEventCol *mcColl = new McGenEventCol;
227 McGenEvent* mcEvent = new McGenEvent(evt);
228 mcColl->push_back(mcEvent);
229 StatusCode sc = eventSvc()->registerObject("/Event/Gen",mcColl);
230 if (sc != StatusCode::SUCCESS) {
231 log << MSG::ERROR << "Could not register McGenEvent" << endreq;
232 delete mcColl;
233 delete evt;
234 delete mcEvent;
235 return StatusCode::FAILURE;
236 }
237 }
238 // string s;
239 // getline(cin,s);
240
241 return StatusCode::SUCCESS;
242}
243
245{
246 MsgStream log(messageService(), name());
247 log << MSG::INFO << "BesBdkRc finalized" << endreq;
248 int itot;
249 itot=XSECTC.ITOT;
250 double cstot;
251 double cserr;
252 FINISH(itot,cstot,cserr);
253 float effcut=0;
254 float cscut=0;
255 float efferr=0;
256 float cscuterr=0;
257 if(XSECTC.NEVUNW){
258 effcut=float(DELPHC.NEVCUT)/float(XSECTC.NEVUNW);
259 cscut=effcut*cstot;
260 efferr=sqrt(effcut*(1.0-effcut)/float(XSECTC.NEVUNW));
261 cscuterr = sqrt(cstot*efferr*cstot*efferr + effcut*effcut*cserr*cserr);
262 }
263 printf("BDKRC SUMMARY: Cross section after user cuts= %G +- %G nb\n",cscut,cscuterr);
264 printf(" Cut acceptance = %G +- %G \n",effcut,efferr);
265 return StatusCode::SUCCESS;
266}
#define RLUXGO(lux, ISEED, K1, K2)
Definition BesBdkRc.cxx:112
#define COLCHC
Definition BesBdkRc.cxx:62
#define INPUT
Definition BesBdkRc.cxx:35
#define LULIST(ICONV)
Definition BesBdkRc.cxx:97
#define PCONST
Definition BesBdkRc.cxx:41
#define BDKRC(IDUMP)
Definition BesBdkRc.cxx:106
#define HEPEVT_PRINT()
Definition BesBdkRc.cxx:103
#define GEN_INIT()
Definition BesBdkRc.cxx:115
#define DELPHC
Definition BesBdkRc.cxx:68
#define FLAGS
Definition BesBdkRc.cxx:82
#define FINCUT
Definition BesBdkRc.cxx:47
#define LOCALC
Definition BesBdkRc.cxx:55
#define FINISH(IN, SIGT, ER)
Definition BesBdkRc.cxx:109
#define GEN1EVT()
Definition BesBdkRc.cxx:118
#define LUHEPC(ICONV)
Definition BesBdkRc.cxx:94
#define XSECTC
Definition BesBdkRc.cxx:76
#define HEPEVT_CLEAN()
Definition BesBdkRc.cxx:100
#define LUJETS
Definition BesBdkRc.cxx:90
float flat_()
Definition BesBdkRc.cxx:124
double P(RecMdcKalTrack *trk)
#define PI
ObjectVector< McGenEvent > McGenEventCol
Definition McGenEvent.h:39
#define M_PI
Definition TConstant.h:4
#define PROTOCCALLSFSUB3(UN, LN, T1, T2, T3)
Definition cfortran.h:1005
#define COMMON_BLOCK_DEF(DEFINITION, NAME)
Definition cfortran.h:271
#define PROTOCCALLSFSUB4(UN, LN, T1, T2, T3, T4)
Definition cfortran.h:1007
#define PROTOCCALLSFSUB0(UN, LN)
Definition cfortran.h:1082
#define PROTOCCALLSFSUB1(UN, LN, T1)
Definition cfortran.h:1001
static double random()
static void setRandomEngine(CLHEP::HepRandomEngine *randomEngine)
StatusCode finalize()
Definition BesBdkRc.cxx:244
StatusCode execute()
Definition BesBdkRc.cxx:192
StatusCode initialize()
Definition BesBdkRc.cxx:152
BesBdkRc(const std::string &name, ISvcLocator *pSvcLocator)
Definition BesBdkRc.cxx:129
virtual CLHEP::HepRandomEngine * GetEngine(const std::string &StreamName)=0
Interface to the CLHEP engine.
double COLCHA
Definition BesBdkRc.cxx:59
float PCHMIN
Definition BesBdkRc.cxx:45
int GOODEVT
Definition BesBdkRc.cxx:80
double EB
Definition BesBdkRc.cxx:33
float EBEAM
Definition BesBdkRc.cxx:51
double ALFA
Definition BesBdkRc.cxx:39
double CSERR
Definition BesBdkRc.cxx:73
float CSCUT
Definition BesBdkRc.cxx:74