BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
EeToeeV.cxx
Go to the documentation of this file.
1//*****************************************************************************
2//
3// EeToeeV.cxx
4//
5// Algorithm runs e+e- ->e+e- rho0, rho0->pi+pi- precess
6//
7// July 2016-4-29 Rong-Gang Ping to create package for BES3
8// The original fortran code is generated with FDC, consult Prof. Wang Jianxiong
9//*****************************************************************************
10
11// Header for this module:-
12#include "../EeToeeV/EeToeeV.h"
13#include "../EeToeeV/EeToeeVRandom.h"
14#include "BesKernel/IBesRndmGenSvc.h"
15
16// Framework Related Headers:-
17#include "HepMC/GenEvent.h"
18#include "HepMC/GenVertex.h"
19#include "HepMC/GenParticle.h"
20
21#include "GaudiKernel/MsgStream.h"
22#include "GaudiKernel/ISvcLocator.h"
23#include "GaudiKernel/AlgFactory.h"
24#include "GaudiKernel/DataSvc.h"
25#include "GaudiKernel/SmartDataPtr.h"
26
27#include "GeneratorObject/McGenEvent.h"
28#include "CLHEP/Vector/LorentzVector.h"
29#include "cfortran/cfortran.h"
30
31#include <stdlib.h>
32#include <time.h>
33
34 typedef struct {
35 double q1[4][160001]; //e+ beam
36 double p1[4][160001]; //e- beam
37 double q2[4][160001]; // e-
38 double p2[4][160001]; // e+
39 double q3[4][160001]; // V
40 } MOMSET_DEF;
41//MOMSET_DEF MOMSET;
42#define MOMSET COMMON_BLOCK(MOMSET_DEF, momset)
44
45//common/beamEnergy/ebeam
46typedef struct {
47 double ecms;
49#define BEAMENERGY COMMON_BLOCK(BEAMENERGY_DEF, beamenergy)
51
52
53//common/vector/vct
54typedef struct {
55 int vct;
57#define VECTOR COMMON_BLOCK(VECTOR_DEF, vector)
59
60//common/MCTRUTH/mccheck
61typedef struct {
62 int mccheck;
64#define MCTRUTH COMMON_BLOCK(MCTRUTH_DEF, mctruth)
66
67
68//--//Unify EeToeeV random engine with Bes random servive
69extern "C" {
70 extern float flat_();
71}
72
73float flat_(){
74 float rr;
75 double rd=EeToeeVRandom::random();
76// std::cout<<"EeToeeVRandom::random()="<<rd<<endl;
77 rr=(float)rd;
78 return (float)EeToeeVRandom::random();
79 // return rr;
80}
81extern "C" {
82 extern void intxs_();
83}
84
85
86PROTOCCALLSFSUB1(GEVENT,gevent,INT)
87#define GEVENT(NEVENTS) CCALLSFSUB1(GEVENT,gevent,INT,NEVENTS)
88
89
90EeToeeV::EeToeeV(const string& name, ISvcLocator* pSvcLocator):Algorithm( name, pSvcLocator )
91{
92 declareProperty("Ecms", m_Ecms = 3.65); // Ecm = sqrt(s) [GeV]
93 declareProperty("Vector", m_vect = "phi"); // Ecm = sqrt(s) [GeV]
94 declareProperty("WriteMC", m_mctruth = 0); // Ecm = sqrt(s) [GeV]
95}
96
97
98
99
101
102 MsgStream log(messageService(), name());
103
104 log << MSG::INFO << "EeToeeV initialize" << endreq;
105
106 //set Bes unified random engine
107 static const bool CREATEIFNOTTHERE(true);
108 StatusCode RndmStatus = service("BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE);
109 if (!RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc)
110 {
111 log << MSG::ERROR << " Could not initialize Random Number Service" << endreq;
112 return RndmStatus;
113 }
114 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->GetEngine("EeToeeV");
115 std::cout<<"==============================="<<engine<<endl;
117 // *****************
118 MCTRUTH.mccheck=m_mctruth;
119 BEAMENERGY.ecms=m_Ecms;
120 double mpar=10.;
121 if(m_vect=="omega"){
122 VECTOR.vct=1;
123 mpar=0.782;
124 }else if(m_vect=="phi"){
125 VECTOR.vct=2;
126 mpar=1.019;
127 }else if(m_vect=="J/psi"){
128 VECTOR.vct=3;
129 mpar=3.097;
130 }else if(m_vect=="psi(2S)"){
131 VECTOR.vct=4;
132 mpar=3.686;
133 }else if(m_vect=="psi(3770)"){
134 VECTOR.vct=5;
135 mpar=3.773;
136 }else if(m_vect=="psi(4040)"){
137 VECTOR.vct=6;
138 mpar=4.039;
139 }else if(m_vect=="psi(4160)"){
140 VECTOR.vct=7;
141 mpar=4.153;
142 }else if(m_vect=="psi(4415)"){
143 VECTOR.vct=8;
144 mpar=4.421;
145 }else{
146 std::cout<<"EeToeeV::initialize() Bad vector "<<std::endl; abort();
147 }
148 if(m_Ecms<mpar){std::cout<<"EeToeeV:initialize: the Ecms less than the vector mass"<<std::endl;abort();}
149 // std::cout<<"m_Ires= "<<m_Ires<<endl;
150
151 getMaxEvent();
152 std::cout<<"m_evtMax = "<<m_evtMax<<std::endl;
153 intxs_();
154 GEVENT(m_evtMax);
155
156 return StatusCode::SUCCESS;
157}
158
159static int evtgen=1;
160StatusCode EeToeeV::execute()
161{
162 MsgStream log(messageService(), name());
163
164
165 int npart = 0;
166 int pid1,pid2,pid3,pid4,pst1,pst2;
167 pid1 = 11;
168 pid2 =-11;
169 pst1 = 1;
170 pst2 = 1; //1: supose the Vector will decay in the BesEvtGen
171
172 if(m_vect=="omega"){
173 pid3=223;
174 }else if(m_vect=="phi"){
175 pid3=333;
176 }else if(m_vect=="J/psi"){
177 pid3=443;
178 }else if(m_vect=="psi(2S)"){
179 pid3=100443;
180 }else if(m_vect=="psi(3770)"){
181 pid3=30443;
182 }else if(m_vect=="psi(4040)"){
183 pid3=9000443;
184 }else if(m_vect=="psi(4160)"){
185 pid3=9010443;
186 }else if(m_vect=="psi(4415)"){
187 pid3=9020443;
188 }
189
190 // Fill event information
191 GenEvent* evt = new GenEvent(1,1);
192
193 GenVertex* prod_vtx = new GenVertex();
194// prod_vtx->add_particle_out( p );
195 evt->add_vertex( prod_vtx );
196
197 // incoming beam e- HepLorentzVector(px,py,pz,energy) required!
198 GenParticle* p = new GenParticle( CLHEP::HepLorentzVector( MOMSET.p1[1][evtgen], MOMSET.p1[2][evtgen],
199 MOMSET.p1[3][evtgen], MOMSET.p1[0][evtgen]),
200 11, 3);
201 p->suggest_barcode( ++npart );
202 prod_vtx->add_particle_in(p);
203
204// std::cout<<"incoming beam e+"<<endl;
205 // incoming beam e+, e+ moving along the z-direction
206 p = new GenParticle( CLHEP::HepLorentzVector( MOMSET.q1[1][evtgen], MOMSET.q1[2][evtgen],
207 MOMSET.q1[3][evtgen], MOMSET.q1[4][evtgen]),
208 -11, 3);
209
210 p->suggest_barcode( ++npart );
211 prod_vtx->add_particle_in(p);
212
213 // scattered lepton -
214 p = new GenParticle( CLHEP::HepLorentzVector( MOMSET.p2[1][evtgen], MOMSET.p2[2][evtgen],
215 MOMSET.p2[3][evtgen], MOMSET.p2[0][evtgen]),
216 pid1,pst1);
217 p->suggest_barcode( ++npart );
218 prod_vtx->add_particle_out(p);
219
220 // scattered lepton +
221 p = new GenParticle( CLHEP::HepLorentzVector( MOMSET.q2[1][evtgen], MOMSET.q2[2][evtgen],
222 MOMSET.q2[3][evtgen], MOMSET.q2[0][evtgen]),
223 pid2, pst1);
224 p->suggest_barcode( ++npart );
225 prod_vtx->add_particle_out(p);
226
227 // outgoing Vector
228 p = new GenParticle( CLHEP::HepLorentzVector( MOMSET.q3[1][evtgen], MOMSET.q3[2][evtgen],
229 MOMSET.q3[3][evtgen], MOMSET.q3[0][evtgen]),
230 pid3,pst2);
231 p->suggest_barcode( ++npart );
232 prod_vtx->add_particle_out(p);
233
234 evtgen++;
235
236 if( log.level() < MSG::INFO )
237 {
238 evt->print();
239 }
240
241 // Check if the McCollection already exists
242 SmartDataPtr<McGenEventCol> anMcCol(eventSvc(), "/Event/Gen");
243 if (anMcCol!=0)
244 {
245 // Add event to existing collection
246 MsgStream log(messageService(), name());
247 log << MSG::INFO << "Add McGenEvent to existing collection" << endreq;
248 McGenEvent* mcEvent = new McGenEvent(evt);
249 anMcCol->push_back(mcEvent);
250 }
251 else
252 {
253 // Create Collection and add to the transient store
254 // std::cout<<"I created McCollection "<<std::endl;
255 McGenEventCol *mcColl = new McGenEventCol;
256 McGenEvent* mcEvent = new McGenEvent(evt);
257 mcColl->push_back(mcEvent);
258 StatusCode sc = eventSvc()->registerObject("/Event/Gen",mcColl);
259 if (sc != StatusCode::SUCCESS)
260 {
261 log << MSG::ERROR << "Could not register McGenEvent" << endreq;
262 delete mcColl;
263 delete evt;
264 delete mcEvent;
265 return StatusCode::FAILURE;
266 }
267 else
268 {
269 // log << MSG::INFO << "McGenEventCol created and " << npart <<" particles stored in McGenEvent" << endreq;
270 }
271 }
272
273 return StatusCode::SUCCESS;
274}
275
276StatusCode EeToeeV::finalize()
277{
278 MsgStream log(messageService(), name());
279 char delcmd[300];
280 strcpy(delcmd,"cat ");
281 strcat(delcmd,"fresult.dat");
282 system(delcmd);
283
284 std::cout<< "EeToeeV finalized" << endl;
285 return StatusCode::SUCCESS;
286}
287
289 IProperty* appPropMgr=0;
290 StatusCode status =
291 serviceLocator()->getService("ApplicationMgr", IProperty::interfaceID(),
292 reinterpret_cast<IInterface*&>( appPropMgr ));
293 if( status.isFailure() ) return status;
294
295 IntegerProperty evtMax("EvtMax",0);
296 status = appPropMgr->getProperty( &evtMax );
297 if (status.isFailure()) return status;
298
299 m_evtMax = evtMax.value();
300 return status;
301}
302
#define MOMSET
Definition: Babayaga.cxx:45
#define BEAMENERGY
Definition: Babayaga.cxx:65
#define GEVENT(NEVENTS)
Definition: EeToeeV.cxx:87
#define MOMSET
Definition: EeToeeV.cxx:42
void intxs_()
#define MCTRUTH
Definition: EeToeeV.cxx:64
#define VECTOR
Definition: EeToeeV.cxx:57
#define BEAMENERGY
Definition: EeToeeV.cxx:49
float flat_()
Definition: EeToeeV.cxx:73
#define GEVENT(NEVENTS)
void intxs_()
#define COMMON_BLOCK_DEF(DEFINITION, NAME)
#define PROTOCCALLSFSUB1(UN, LN, T1)
static double random()
static void setRandomEngine(CLHEP::HepRandomEngine *randomEngine)
StatusCode execute()
Definition: EeToeeV.cxx:160
StatusCode getMaxEvent()
Definition: EeToeeV.cxx:288
EeToeeV(const string &name, ISvcLocator *pSvcLocator)
Definition: EeToeeV.cxx:90
StatusCode initialize()
Definition: EeToeeV.cxx:100
StatusCode finalize()
Definition: EeToeeV.cxx:276
virtual CLHEP::HepRandomEngine * GetEngine(const std::string &StreamName)=0
Interface to the CLHEP engine.
const double ecms
Definition: inclkstar.cxx:42