BOSS 7.1.2
BESIII Offline Software System
Loading...
Searching...
No Matches
Eepipi/Eepipi-00-01-00/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/Eepipi.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//common/cosee/setcos
55typedef struct {
56 double setcos;
57} COSEE_DEF;
58#define COSEE COMMON_BLOCK(COSEE_DEF, cosee)
60
61//common/cosee/setcos
62typedef struct {
63 double onlyDigam;
65} DIGAM_DEF;
66#define DIGAM COMMON_BLOCK(DIGAM_DEF, digam)
68
69//common/MCTRUTH/mccheck
70typedef struct {
73#define MCTRUTH COMMON_BLOCK(MCTRUTH_DEF, mctruth)
75
76//common/FORMFACTOR/
77typedef struct {
78 char* myfile;
80#define FORMFACTOR COMMON_BLOCK(FORMFACTOR_DEF, formfactor)
82
83//--//Unify Eepipi random engine with Bes random servive
84extern "C" {
85 extern float flat_();
86}
87
88float flat_(){
89 float rr;
90 double rd=EepipiRandom::random();
91// std::cout<<"EepipiRandom::random()="<<rd<<endl;
92 rr=(float)rd;
93 return (float)EepipiRandom::random();
94 // return rr;
95}
96extern "C" {
97 extern void intxs_();
98}
99
100
101PROTOCCALLSFSUB1(GEVENT,gevent,INT)
102#define GEVENT(NEVENTS) CCALLSFSUB1(GEVENT,gevent,INT,NEVENTS)
103
104
105Eepipi::Eepipi(const string& name, ISvcLocator* pSvcLocator):Algorithm( name, pSvcLocator )
106{
107 declareProperty("Ecms", m_Ecms = 3.65); // Ecm = sqrt(s) [GeV]
108 declareProperty("OnlyDigam", m_onlyDigam = 0); //1: only with the digamma process
109 declareProperty("ExcludeDigam", m_excludeDigam = 0); //1: Exclude digamma process in the whole Feynman diagram
110 declareProperty("WriteMC", m_mctruth = 0); //write out the MC truth of final state to "pdata1.dat"
111}
112
114
115 MsgStream log(messageService(), name());
116
117 log << MSG::INFO << "Eepipi initialize" << endreq;
118
119 //set Bes unified random engine
120 static const bool CREATEIFNOTTHERE(true);
121 StatusCode RndmStatus = service("BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE);
122 if (!RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc)
123 {
124 log << MSG::ERROR << " Could not initialize Random Number Service" << endreq;
125 return RndmStatus;
126 }
127 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->GetEngine("Eepipi");
128 std::cout<<"==============================="<<engine<<endl;
130 // *****************
131 MCTRUTH.mccheck=m_mctruth;
132 BEAMENERGY.ecms=m_Ecms;
133 COSEE.setcos=m_cosee;
134 // std::cout<<"m_Ires= "<<m_Ires<<endl;
135 DIGAM.onlyDigam =m_onlyDigam;
136 DIGAM.excludeDigam=m_excludeDigam;
137 //--
138 std::string locvp=getenv("EEPIPIROOT");
139 locvp +="/share/fitpipi.dat";
140 FORMFACTOR.myfile=(char*)locvp.c_str();
141 std::cout<<"myfile :"<<FORMFACTOR.myfile<<std::endl;
142 system("cat $EEPIPIROOT/share/fitpipi.dat>fitpipi.dat");
143
144 getMaxEvent();
145 std::cout<<"m_evtMax = "<<m_evtMax<<std::endl;
146 intxs_();
147 GEVENT(m_evtMax);
148
149 return StatusCode::SUCCESS;
150}
151
152static int evtgen=1;
153StatusCode Eepipi::execute()
154{
155 MsgStream log(messageService(), name());
156
157
158 int npart = 0;
159 int pid1,pid2,pid3,pid4,pst1,pst2;
160 pid1 = 11;
161 pid2 =-11;
162 pid3 = 211;
163 pid4 =-211;
164 pst1 = 1;
165 pst2 = 1;
166
167
168
169 // Fill event information
170 GenEvent* evt = new GenEvent(1,1);
171
172 GenVertex* prod_vtx = new GenVertex();
173// prod_vtx->add_particle_out( p );
174 evt->add_vertex( prod_vtx );
175
176 // incoming beam e- HepLorentzVector(px,py,pz,energy) required!
177 GenParticle* p = 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
221
222 evtgen++;
223
224 if( log.level() < MSG::INFO )
225 {
226 evt->print();
227 }
228
229 // Check if the McCollection already exists
230 SmartDataPtr<McGenEventCol> anMcCol(eventSvc(), "/Event/Gen");
231 if (anMcCol!=0)
232 {
233 // Add event to existing collection
234 MsgStream log(messageService(), name());
235 log << MSG::INFO << "Add McGenEvent to existing collection" << endreq;
236 McGenEvent* mcEvent = new McGenEvent(evt);
237 anMcCol->push_back(mcEvent);
238 }
239 else
240 {
241 // Create Collection and add to the transient store
242 McGenEventCol *mcColl = new McGenEventCol;
243 McGenEvent* mcEvent = new McGenEvent(evt);
244 mcColl->push_back(mcEvent);
245 StatusCode sc = eventSvc()->registerObject("/Event/Gen",mcColl);
246 if (sc != StatusCode::SUCCESS)
247 {
248 log << MSG::ERROR << "Could not register McGenEvent" << endreq;
249 delete mcColl;
250 delete evt;
251 delete mcEvent;
252 return StatusCode::FAILURE;
253 }
254 else
255 {
256 // log << MSG::INFO << "McGenEventCol created and " << npart <<" particles stored in McGenEvent" << endreq;
257 }
258 }
259
260 return StatusCode::SUCCESS;
261}
262
263StatusCode Eepipi::finalize()
264{
265 MsgStream log(messageService(), name());
266 char delcmd[300];
267 strcpy(delcmd,"cat ");
268 strcat(delcmd,"fresult.dat");
269 system(delcmd);
270
271 std::cout<< "Eepipi finalized" << endl;
272 return StatusCode::SUCCESS;
273}
274
276 IProperty* appPropMgr=0;
277 StatusCode status =
278 serviceLocator()->getService("ApplicationMgr", IProperty::interfaceID(),
279 reinterpret_cast<IInterface*&>( appPropMgr ));
280 if( status.isFailure() ) return status;
281
282 IntegerProperty evtMax("EvtMax",0);
283 status = appPropMgr->getProperty( &evtMax );
284 if (status.isFailure()) return status;
285
286 m_evtMax = evtMax.value();
287 return status;
288}
289
double p1[4]
double p2[4]
#define MOMSET
Definition Babayaga.cxx:45
#define BEAMENERGY
Definition Babayaga.cxx:65
#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()
Eepipi(const string &name, ISvcLocator *pSvcLocator)
virtual CLHEP::HepRandomEngine * GetEngine(const std::string &StreamName)=0
Interface to the CLHEP engine.
double double * p3
Definition qcdloop1.h:76