BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Eepipi/src/Eepipi.cxx
Go to the documentation of this file.
1//*****************************************************************************
2//
3// Eepipi.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 "Eepipi.h"
13#include "BesRndmGenSvc/IBesRndmGenSvc.h"
14#include "EepipiRandom.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
52/***
53typedef struct {
54 double setcos;
55} COSEE_DEF;
56#define COSEE COMMON_BLOCK( COSEE_DEF, cosee )
57COMMON_BLOCK_DEF( COSEE_DEF, COSEE );
58
59// common/cosee/setcos
60typedef struct {
61 double onlyDigam;
62 double excludeDigam;
63} DIGAM_DEF;
64#define DIGAM COMMON_BLOCK( DIGAM_DEF, digam )
65COMMON_BLOCK_DEF( DIGAM_DEF, DIGAM );
66***/
67
68// common/MCTRUTH/mccheck
69typedef struct {
72#define MCTRUTH COMMON_BLOCK( MCTRUTH_DEF, mctruth )
74
75// common/FORMFACTOR/
76/***
77typedef struct {
78 char* myfile;
79} FORMFACTOR_DEF;
80#define FORMFACTOR COMMON_BLOCK( FORMFACTOR_DEF, formfactor )
81COMMON_BLOCK_DEF( FORMFACTOR_DEF, FORMFACTOR );
82***/
83
84//--//Unify Eepipi random engine with Bes random servive
85extern "C" {
86extern float flat_();
87}
88
89float flat_() {
90 float rr;
91 double rd = EepipiRandom::random();
92 // std::cout<<"EepipiRandom::random()="<<rd<<endl;
93 rr = (float)rd;
94 return (float)EepipiRandom::random();
95 // return rr;
96}
97extern "C" {
98extern void intxs_();
99}
100
101PROTOCCALLSFSUB1( GEVENT, gevent, INT )
102#define GEVENT( NEVENTS ) CCALLSFSUB1( GEVENT, gevent, INT, NEVENTS )
103
105
106Eepipi::Eepipi( const string& name, ISvcLocator* pSvcLocator )
107 : Algorithm( name, pSvcLocator ) {
108 declareProperty( "Ecms", m_Ecms = 3.65 ); // Ecm = sqrt(s) [GeV]
109 declareProperty( "OnlyDigam", m_onlyDigam = 0 ); // 1: only with the digamma process
110 declareProperty( "ExcludeDigam", m_excludeDigam = 0 ); // 1: Exclude digamma process in the
111 // whole Feynman diagram
112 declareProperty( "WriteMC",
113 m_mctruth = 0 ); // write out the MC truth of final state to "pdata1.dat"
114}
115
116StatusCode Eepipi::initialize() {
117
118 MsgStream log( msgSvc(), name() );
119
120 log << MSG::INFO << "Eepipi initialize" << endmsg;
121
122 // set Bes unified random engine
123 static const bool CREATEIFNOTTHERE( true );
124 StatusCode RndmStatus = service( "BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE );
125 if ( !RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc )
126 {
127 log << MSG::ERROR << " Could not initialize Random Number Service" << endmsg;
128 return RndmStatus;
129 }
130 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->GetEngine( "Eepipi" );
131 std::cout << "===============================" << engine << endl;
133 // *****************
134 MCTRUTH.mccheck = m_mctruth;
135 BEAMENERGY.ecms = m_Ecms;
136 // COSEE.setcos = m_cosee;
137 // std::cout<<"m_Ires= "<<m_Ires<<endl;
138 // DIGAM.onlyDigam = m_onlyDigam;
139 // DIGAM.excludeDigam = m_excludeDigam;
140 //--
141 std::string locvp = getenv( "EEPIPIROOT" );
142 locvp += "/share/fitpipi.dat";
143 // FORMFACTOR.myfile = (char*)locvp.c_str();
144 // std::cout << "myfile :" << FORMFACTOR.myfile << std::endl;
145 system( "cat $EEPIPIROOT/share/fitpipi.dat>fitpipi.dat" );
146
147 getMaxEvent().ignore();
148 std::cout << "m_evtMax = " << m_evtMax << std::endl;
149 intxs_();
150 GEVENT( m_evtMax );
151
152 return StatusCode::SUCCESS;
153}
154
155static int evtgen = 1;
156StatusCode Eepipi::execute() {
157 MsgStream log( msgSvc(), name() );
158
159 int npart = 0;
160 int pid1, pid2, pid3, pid4, pst1, pst2;
161 pid1 = 11;
162 pid2 = -11;
163 pid3 = 211;
164 pid4 = -211;
165 pst1 = 1;
166 pst2 = 1;
167
168 // Fill event information
169 GenEvent* evt = new GenEvent( 1, 1 );
170
171 GenVertex* prod_vtx = new GenVertex();
172 // prod_vtx->add_particle_out( p );
173 evt->add_vertex( prod_vtx );
174
175 // incoming beam e- HepLorentzVector(px,py,pz,energy) required!
176 GenParticle* p =
177 new GenParticle( CLHEP::HepLorentzVector( MOMSET.p1[1][evtgen], MOMSET.p1[2][evtgen],
178 MOMSET.p1[3][evtgen], MOMSET.p1[0][evtgen] ),
179 11, 3 );
180 p->suggest_barcode( ++npart );
181 prod_vtx->add_particle_in( p );
182
183 // std::cout<<"incoming beam e+"<<endl;
184 // incoming beam e+, e+ moving along the z-direction
185 p = new GenParticle( CLHEP::HepLorentzVector( MOMSET.q1[1][evtgen], MOMSET.q1[2][evtgen],
186 MOMSET.q1[3][evtgen], MOMSET.q1[4][evtgen] ),
187 -11, 3 );
188
189 p->suggest_barcode( ++npart );
190 prod_vtx->add_particle_in( p );
191
192 // scattered lepton +
193 p = new GenParticle( CLHEP::HepLorentzVector( MOMSET.p2[1][evtgen], MOMSET.p2[2][evtgen],
194 MOMSET.p2[3][evtgen], MOMSET.p2[0][evtgen] ),
195 pid1, pst1 );
196 p->suggest_barcode( ++npart );
197 prod_vtx->add_particle_out( p );
198
199 // scattered lepton -
200 p = new GenParticle( CLHEP::HepLorentzVector( MOMSET.q2[1][evtgen], MOMSET.q2[2][evtgen],
201 MOMSET.q2[3][evtgen], MOMSET.q2[0][evtgen] ),
202 pid2, pst2 );
203 p->suggest_barcode( ++npart );
204 prod_vtx->add_particle_out( p );
205
206 // outgoing pi+
207 p = new GenParticle( CLHEP::HepLorentzVector( MOMSET.p3[1][evtgen], MOMSET.p3[2][evtgen],
208 MOMSET.p3[3][evtgen], MOMSET.p3[0][evtgen] ),
209 pid3, pst1 );
210 p->suggest_barcode( ++npart );
211 prod_vtx->add_particle_out( p );
212
213 // outgoing pi-
214 p = new GenParticle( CLHEP::HepLorentzVector( MOMSET.q3[1][evtgen], MOMSET.q3[2][evtgen],
215 MOMSET.q3[3][evtgen], MOMSET.q3[0][evtgen] ),
216 pid4, pst2 );
217 p->suggest_barcode( ++npart );
218 prod_vtx->add_particle_out( p );
219
220 evtgen++;
221
222 if ( log.level() < MSG::INFO ) { evt->print(); }
223
224 // Check if the McCollection already exists
225 SmartDataPtr<McGenEventCol> anMcCol( eventSvc(), "/Event/Gen" );
226 if ( anMcCol != 0 )
227 {
228 // Add event to existing collection
229 MsgStream log( msgSvc(), name() );
230 log << MSG::INFO << "Add McGenEvent to existing collection" << endmsg;
231 McGenEvent* mcEvent = new McGenEvent( evt );
232 anMcCol->push_back( mcEvent );
233 }
234 else
235 {
236 // Create Collection and add to the transient store
237 McGenEventCol* mcColl = new McGenEventCol;
238 McGenEvent* mcEvent = new McGenEvent( evt );
239 mcColl->push_back( mcEvent );
240 StatusCode sc = eventSvc()->registerObject( "/Event/Gen", mcColl );
241 if ( sc != StatusCode::SUCCESS )
242 {
243 log << MSG::ERROR << "Could not register McGenEvent" << endmsg;
244 delete mcColl;
245 delete evt;
246 delete mcEvent;
247 return StatusCode::FAILURE;
248 }
249 else
250 {
251 // log << MSG::INFO << "McGenEventCol created and " << npart <<" particles stored in
252 // McGenEvent" << endmsg;
253 }
254 }
255
256 return StatusCode::SUCCESS;
257}
258
259StatusCode Eepipi::finalize() {
260 MsgStream log( msgSvc(), name() );
261 char delcmd[300];
262 strcpy( delcmd, "cat " );
263 strcat( delcmd, "fresult.dat" );
264 system( delcmd );
265
266 std::cout << "Eepipi finalized" << endl;
267 return StatusCode::SUCCESS;
268}
269
271 IProperty* appPropMgr = 0;
272 StatusCode status =
273 serviceLocator()->getService( "ApplicationMgr", IProperty::interfaceID(),
274 reinterpret_cast<IInterface*&>( appPropMgr ) );
275 if ( status.isFailure() ) return status;
276
277 IntegerProperty evtMax( "EvtMax", 0 );
278 status = appPropMgr->getProperty( &evtMax );
279 if ( status.isFailure() ) return status;
280
281 m_evtMax = evtMax.value();
282 return status;
283}
double p2[4]
double p1[4]
#define MOMSET
Definition Babayaga.cxx:43
#define BEAMENERGY
Definition Babayaga.cxx:63
DECLARE_COMPONENT(BesBdkRc)
#define GEVENT(NEVENTS)
void intxs_()
#define MCTRUTH
COMMON_BLOCK_DEF(MOMSET_DEF, MOMSET)
float flat_()
ObjectVector< McGenEvent > McGenEventCol
IMessageSvc * msgSvc()
static void setRandomEngine(CLHEP::HepRandomEngine *randomEngine)
static double random()
Eepipi(const string &name, ISvcLocator *pSvcLocator)
StatusCode initialize()
StatusCode execute()
StatusCode finalize()
StatusCode getMaxEvent()
PROTOCCALLSFSUB1(RLXDRESETF, rlxdresetf, INTV)
double q3[4][160001]
double p3[4][160001]