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