BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EeTo4e.cxx
Go to the documentation of this file.
1//*****************************************************************************
2//
3// EeTo4e.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 "EeTo4e.h"
13#include "BesRndmGenSvc/IBesRndmGenSvc.h"
14#include "EeTo4eRandom.h"
15
16// Framework Related Headers:-
17#include "HepMC/GenEvent.h"
18#include "HepMC/GenParticle.h"
19#include "HepMC/GenVertex.h"
20
21#include "GaudiKernel/ISvcLocator.h"
22#include "GaudiKernel/MsgStream.h"
23#include "GaudiKernel/SmartDataPtr.h"
24
25#include "CLHEP/Vector/LorentzVector.h"
26#include "GeneratorObject/McGenEvent.h"
27#include "cfortran/cfortran.h"
28
29#include <stdlib.h>
30
31typedef struct {
32 double q1[4][160001]; // e+ beam
33 double p1[4][160001]; // e- beam
34 double q2[4][160001]; // e-
35 double p2[4][160001]; // e+
36 double q3[4][160001]; // pi+
37 double p3[4][160001]; // pi-
39// MOMSET_DEF MOMSET;
40#define MOMSET COMMON_BLOCK( MOMSET_DEF, momset )
42
43// common/beamEnergy/ebeam
44typedef struct {
45 double ecms;
47#define BEAMENERGY COMMON_BLOCK( BEAMENERGY_DEF, beamenergy )
49// BEAMENERGY_DEF,BEAMENERGY
50
51// common/cosee/setcos
52typedef struct {
53 double setcos;
54} COSEE_DEF;
55#define COSEE COMMON_BLOCK( COSEE_DEF, cosee )
57
58// common/MCTRUTH/mccheck
59typedef struct {
60 int mccheck;
62#define MCTRUTH COMMON_BLOCK( MCTRUTH_DEF, mctruth )
64
65//--//Unify EeTo4e random engine with Bes random servive
66extern "C" {
67extern float flat_();
68}
69
70float flat_() {
71 float rr;
72 double rd = EeTo4eRandom::random();
73 // std::cout<<"EeTo4eRandom::random()="<<rd<<endl;
74 rr = (float)rd;
75 return (float)EeTo4eRandom::random();
76 // return rr;
77}
78extern "C" {
79extern void intxs_();
80}
81
82PROTOCCALLSFSUB1( GEVENT, gevent, INT )
83#define GEVENT( NEVENTS ) CCALLSFSUB1( GEVENT, gevent, INT, NEVENTS )
84
86EeTo4e::EeTo4e( const string& name, ISvcLocator* pSvcLocator )
87 : Algorithm( name, pSvcLocator ) {
88 declareProperty( "Ecms", m_Ecms = 3.65 ); // Ecm = sqrt(s) [GeV]
89 declareProperty( "cosee", m_cosee = 0.93 );
90 declareProperty( "WriteMC",
91 m_mctruth = 0 ); // write out the MC truth of final state to "pdata1.dat"
92}
93
94StatusCode EeTo4e::initialize() {
95
96 MsgStream log( msgSvc(), name() );
97
98 log << MSG::INFO << "EeTo4e initialize" << endmsg;
99
100 // set Bes unified random engine
101 static const bool CREATEIFNOTTHERE( true );
102 StatusCode RndmStatus = service( "BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE );
103 if ( !RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc )
104 {
105 log << MSG::ERROR << " Could not initialize Random Number Service" << endmsg;
106 return RndmStatus;
107 }
108 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->GetEngine( "EeTo4e" );
109 std::cout << "===============================" << engine << endl;
111 // *****************
112 MCTRUTH.mccheck = m_mctruth;
113 COSEE.setcos = m_cosee;
114 BEAMENERGY.ecms = m_Ecms;
115 // std::cout<<"m_Ires= "<<m_Ires<<endl;
116
117 getMaxEvent();
118 std::cout << "m_evtMax = " << m_evtMax << std::endl;
119 intxs_();
120 GEVENT( m_evtMax );
121
122 return StatusCode::SUCCESS;
123}
124
125static int evtgen = 1;
126StatusCode EeTo4e::execute() {
127 MsgStream log( msgSvc(), name() );
128
129 int npart = 0;
130 int pid1, pid2, pid3, pid4, pst1, pst2;
131 pid1 = 11;
132 pid2 = -11;
133 pid3 = 11;
134 pid4 = -11;
135 pst1 = 1;
136 pst2 = 1;
137
138 // Fill event information
139 GenEvent* evt = new GenEvent( 1, 1 );
140
141 GenVertex* prod_vtx = new GenVertex();
142 // prod_vtx->add_particle_out( p );
143 evt->add_vertex( prod_vtx );
144
145 // incoming beam e- HepLorentzVector(px,py,pz,energy) required!
146 GenParticle* p =
147 new GenParticle( CLHEP::HepLorentzVector( MOMSET.p1[1][evtgen], MOMSET.p1[2][evtgen],
148 MOMSET.p1[3][evtgen], MOMSET.p1[0][evtgen] ),
149 11, 3 );
150 p->suggest_barcode( ++npart );
151 prod_vtx->add_particle_in( p );
152
153 // std::cout<<"incoming beam e+"<<endl;
154 // incoming beam e+, e+ moving along the z-direction
155 p = new GenParticle( CLHEP::HepLorentzVector( MOMSET.q1[1][evtgen], MOMSET.q1[2][evtgen],
156 MOMSET.q1[3][evtgen], MOMSET.q1[4][evtgen] ),
157 -11, 3 );
158
159 p->suggest_barcode( ++npart );
160 prod_vtx->add_particle_in( p );
161
162 // scattered lepton +
163 p = new GenParticle( CLHEP::HepLorentzVector( MOMSET.p2[1][evtgen], MOMSET.p2[2][evtgen],
164 MOMSET.p2[3][evtgen], MOMSET.p2[0][evtgen] ),
165 pid1, pst1 );
166 p->suggest_barcode( ++npart );
167 prod_vtx->add_particle_out( p );
168
169 // scattered lepton -
170 p = new GenParticle( CLHEP::HepLorentzVector( MOMSET.q2[1][evtgen], MOMSET.q2[2][evtgen],
171 MOMSET.q2[3][evtgen], MOMSET.q2[0][evtgen] ),
172 pid2, pst2 );
173 p->suggest_barcode( ++npart );
174 prod_vtx->add_particle_out( p );
175
176 // outgoing pi+
177 p = new GenParticle( CLHEP::HepLorentzVector( MOMSET.p3[1][evtgen], MOMSET.p3[2][evtgen],
178 MOMSET.p3[3][evtgen], MOMSET.p3[0][evtgen] ),
179 pid3, pst1 );
180 p->suggest_barcode( ++npart );
181 prod_vtx->add_particle_out( p );
182
183 // outgoing pi-
184 p = new GenParticle( CLHEP::HepLorentzVector( MOMSET.q3[1][evtgen], MOMSET.q3[2][evtgen],
185 MOMSET.q3[3][evtgen], MOMSET.q3[0][evtgen] ),
186 pid4, pst2 );
187 p->suggest_barcode( ++npart );
188 prod_vtx->add_particle_out( p );
189
190 evtgen++;
191
192 if ( log.level() < MSG::INFO ) { evt->print(); }
193
194 // Check if the McCollection already exists
195 SmartDataPtr<McGenEventCol> anMcCol( eventSvc(), "/Event/Gen" );
196 if ( anMcCol != 0 )
197 {
198 // Add event to existing collection
199 MsgStream log( msgSvc(), name() );
200 log << MSG::INFO << "Add McGenEvent to existing collection" << endmsg;
201 McGenEvent* mcEvent = new McGenEvent( evt );
202 anMcCol->push_back( mcEvent );
203 }
204 else
205 {
206 // Create Collection and add to the transient store
207 McGenEventCol* mcColl = new McGenEventCol;
208 McGenEvent* mcEvent = new McGenEvent( evt );
209 mcColl->push_back( mcEvent );
210 StatusCode sc = eventSvc()->registerObject( "/Event/Gen", mcColl );
211 if ( sc != StatusCode::SUCCESS )
212 {
213 log << MSG::ERROR << "Could not register McGenEvent" << endmsg;
214 delete mcColl;
215 delete evt;
216 delete mcEvent;
217 return StatusCode::FAILURE;
218 }
219 else
220 {
221 // log << MSG::INFO << "McGenEventCol created and " << npart <<" particles stored in
222 // McGenEvent" << endmsg;
223 }
224 }
225
226 return StatusCode::SUCCESS;
227}
228
229StatusCode EeTo4e::finalize() {
230 MsgStream log( msgSvc(), name() );
231 char delcmd[300];
232 strcpy( delcmd, "cat " );
233 strcat( delcmd, "fresult.dat" );
234 system( delcmd );
235
236 std::cout << "EeTo4e finalized" << endl;
237 return StatusCode::SUCCESS;
238}
239
241 IProperty* appPropMgr = 0;
242 StatusCode status =
243 serviceLocator()->getService( "ApplicationMgr", IProperty::interfaceID(),
244 reinterpret_cast<IInterface*&>( appPropMgr ) );
245 if ( status.isFailure() ) return status;
246
247 IntegerProperty evtMax( "EvtMax", 0 );
248 status = appPropMgr->getProperty( &evtMax );
249 if ( status.isFailure() ) return status;
250
251 m_evtMax = evtMax.value();
252 return status;
253}
double p2[4]
double p1[4]
#define MOMSET
Definition Babayaga.cxx:43
#define BEAMENERGY
Definition Babayaga.cxx:63
DECLARE_COMPONENT(BesBdkRc)
void intxs_()
#define COSEE
Definition EeTo4e.cxx:55
COMMON_BLOCK_DEF(MOMSET_DEF, MOMSET)
float flat_()
Definition EeTo4e.cxx:70
#define GEVENT(NEVENTS)
void intxs_()
#define MCTRUTH
ObjectVector< McGenEvent > McGenEventCol
IMessageSvc * msgSvc()
static void setRandomEngine(CLHEP::HepRandomEngine *randomEngine)
static double random()
StatusCode finalize()
Definition EeTo4e.cxx:229
StatusCode execute()
Definition EeTo4e.cxx:126
EeTo4e(const string &name, ISvcLocator *pSvcLocator)
Definition EeTo4e.cxx:86
StatusCode getMaxEvent()
Definition EeTo4e.cxx:240
StatusCode initialize()
Definition EeTo4e.cxx:94
const double ecms
Definition inclkstar.cxx:26
PROTOCCALLSFSUB1(RLXDRESETF, rlxdresetf, INTV)
double setcos
Definition EeTo4e.cxx:53