1#include "HepMC/HEPEVT_Wrapper.h"
2#include "HepMC/IO_HEPEVT.h"
5#include "HepMC/GenEvent.h"
8#include "GaudiKernel/MsgStream.h"
9#include "GaudiKernel/ISvcLocator.h"
10#include "GaudiKernel/AlgFactory.h"
11#include "GaudiKernel/DataSvc.h"
12#include "GaudiKernel/SmartDataPtr.h"
13#include "GaudiKernel/IHistogramSvc.h"
15#include "Ekhara/Ekhara.h"
16#include "Ekhara/EkharaRandom.h"
17#include "GeneratorObject/McGenEvent.h"
18#include "BesKernel/IBesRndmGenSvc.h"
19#include "Ekhara/cfortran.h"
21#include <TLorentzVector.h>
24#include "CLHEP/Matrix/Vector.h"
25#include "CLHEP/Vector/LorentzVector.h"
26#include "CLHEP/Vector/ThreeVector.h"
27#include "CLHEP/Matrix/SymMatrix.h"
28#include "CLHEP/Matrix/Matrix.h"
34using CLHEP::HepVector;
35using CLHEP::HepLorentzVector;
36using CLHEP::Hep3Vector;
37using CLHEP::HepMatrix;
38using CLHEP::HepSymMatrix;
45#define CHANNELSEL COMMON_BLOCK(CHANNELSEL_DEF, channelsel)
53#define SWDIAG COMMON_BLOCK(SWDIAG_DEF, swdiag)
61#define PIONFFSW COMMON_BLOCK(PIONFFSW_DEF, pionffsw)
66#define EKHARA_SET_ONE_EVENT_MODE() CCALLSFSUB0(EKHARA_SET_ONE_EVENT_MODE,ekhara_set_one_event_mode)
69#define EKHARA(i) CCALLSFSUB1(EKHARA,ekhara,INT,i)
72#define BOSS_INIT_READ(xpar) CCALLSFSUB1(BOSS_INIT_READ,boss_init_read,DOUBLEV,xpar)
75#define DIAGNOSE() CCALLSFSUB0(DIAGNOSE,diagnose)
78#define EKHARA_SET_SILENT() CCALLSFSUB0( EKHARA_SET_SILENT,ekhara_set_silent)
81#define GET_MOMENTUM(p1,p2,q1,q2,pi1,pi2,qpion) CCALLSFSUB7(GET_MOMENTUM,get_momentum,DOUBLEV,DOUBLEV,DOUBLEV,DOUBLEV,DOUBLEV,DOUBLEV,DOUBLEV,p1,p2,q1,q2,pi1,pi2,qpion)
83Ekhara::Ekhara(
const std::string& name, ISvcLocator* pSvcLocator) : Algorithm(name, pSvcLocator)
85 declareProperty(
"Ecm", m_E = 1.02 );
86 declareProperty(
"InitialSeed", m_initSeed = 100);
87 declareProperty(
"InitialEvents", m_ngUpperBound = 50000 );
88 declareProperty(
"Channel", m_channel_id = 2 );
89 declareProperty(
"Thetaminpositron", cut_th1min = 0.00 );
90 declareProperty(
"Thetamaxpositron", cut_th1max = 180.00 );
91 declareProperty(
"Energyminpositron", cut_E1min = 0.00 );
92 declareProperty(
"Energymaxpositron", cut_E1max = 110.00 );
93 declareProperty(
"Thetaminelectron", cut_th2min = 0.00 );
94 declareProperty(
"Thetamaxelectron", cut_th2max = 180.00 );
95 declareProperty(
"Energyminelectron", cut_E2min = 0.00 );
96 declareProperty(
"Energymaxelectron", cut_E2max = 110.00 );
97 declareProperty(
"Thetaminpion", cut_thpionmin = 0.00 );
98 declareProperty(
"Thetamaxpion", cut_thpionmax = 180.00 );
99 declareProperty(
"Eminpion", cut_Epionmin = 0.00 );
100 declareProperty(
"Emaxpion", cut_Epionmax = 100.00 );
101 declareProperty(
"sw_silent", m_sw_silent = 1 );
102 declareProperty(
"sw_2pi", m_sw_2pi = 2 );
103 declareProperty(
"sw_1pi", m_sw_1pi = 2 );
104 declareProperty(
"sw", m_sw = 2 );
105 declareProperty(
"Formfactor", m_piggFFsw = 5 );
110 MsgStream log(
msgSvc(), name());
111 log << MSG::INFO <<
"Ekhara in initialize()" << endreq;
114 hMCPosiMom =
histoSvc()->book(
"MonteCarlo",1,
"PosiMom",250,0.,5.);
115 hMCPosiThe =
histoSvc()->book(
"MonteCarlo",2,
"PosiThe",45,0.,180.);
116 hMCPosiPhi =
histoSvc()->book(
"MonteCarlo",3,
"PosiPhi",90,-180.,180.);
117 hMCElecMom =
histoSvc()->book(
"MonteCarlo",4,
"ElecMom",250,0.,5.);
118 hMCElecThe =
histoSvc()->book(
"MonteCarlo",5,
"ElecThe",45,0.,180.);
119 hMCElecPhi =
histoSvc()->book(
"MonteCarlo",6,
"ElecPhi",90,-180.,180.);
120 hMCEtaPMom =
histoSvc()->book(
"MonteCarlo",7,
"EtaPMom",250,0.,5.);
121 hMCEtaPThe =
histoSvc()->book(
"MonteCarlo",8,
"EtaPThe",45,0.,180.);
122 hMCEtaPPhi =
histoSvc()->book(
"MonteCarlo",9,
"EtaPPhi",90,-180.,180.);
126 static const bool CREATEIFNOTTHERE(
true);
127 StatusCode RndmStatus = service(
"BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE);
128 if (!RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc)
130 log << MSG::ERROR <<
" Could not initialize Random Number Service" << endreq;
133 HepRandomEngine* engine = p_BesRndmGenSvc->
GetEngine(
"Ekhara");
148 cout <<
"-------------------------------------------------------------" << endl;
150 cout <<
" EKHARA 2.1 : e^+ e^- -> e^+ e^- pi^0" << endl;
152 cout <<
" EKHARA 2.1: e^+ e^- -> e^+ e^- pi^+ pi^-" << endl;
154 cout <<
" EKHARA 2.1: e^+ e^- -> e^+ e^- eta" << endl;
156 cout <<
" EKHARA 2.1: e^+ e^- -> e^+ e^- eta'" << endl;
159 if(m_channel_id ==2||m_channel_id ==3||m_channel_id ==4)
160 printf(
" %s %f,%f\n",
"angular cuts on e+ = ",cut_th1min,cut_th1max);
161 printf(
" %s %f,%f\n",
"angular cuts on e- = ",cut_th2min,cut_th2max);
162 printf(
" %s %f,%f\n",
"Energy cuts on e+ = ",cut_E1min,cut_E1max);
163 printf(
" %s %f,%f\n",
"Energy cuts on e- = ",cut_E2min,cut_E2max);
169 xpar[1]=m_ngUpperBound;
170 xpar[2]=m_channel_id;
179 xpar[11]=cut_thpionmin;
180 xpar[12]=cut_thpionmax;
181 xpar[13]=cut_Epionmin;
182 xpar[14]=cut_Epionmax;
184 log << MSG::DEBUG <<
"Options filled in array" << endreq;
186 log << MSG::DEBUG <<
"Options read by FORTRAN routine" << endreq;
188 log << MSG::DEBUG <<
"FORTRAN diagnose passed" << endreq;
190 log << MSG::DEBUG <<
"Ekhara Fortran routines initialized" << endreq;
196 return StatusCode::SUCCESS;
200 MsgStream log(
msgSvc(), name());
201 log << MSG::INFO <<
"Ekhara in execute()" << endreq;
209 double p1[4],p2[4],q1[4],q2[4];
210 double pi1[4],pi2[4],qpion[4];
212 for (
int i=0;i<4;i++) {
224 double PosiMom = sqrt(q1[1]*q1[1]+q1[2]*q1[2]+q1[3]*q1[3]);
225 double PosiThe = acos(q1[3]/PosiMom);
226 double PosiPhi = atan2(q1[2],q1[1]);
228 double ElecMom = sqrt(q2[1]*q2[1]+q2[2]*q2[2]+q2[3]*q2[3]);
229 double ElecThe = acos(q2[3]/ElecMom);
230 double ElecPhi = atan2(q2[2],q2[1]);
232 double EtaPMom = sqrt(qpion[1]*qpion[1]+qpion[2]*qpion[2]+qpion[3]*qpion[3]);
233 double EtaPThe = acos(qpion[3]/EtaPMom);
234 double EtaPPhi = atan2(qpion[2],qpion[1]);
236 hMCPosiMom->fill(PosiMom);
237 hMCElecMom->fill(ElecMom);
238 hMCEtaPMom->fill(EtaPMom);
240 hMCPosiPhi->fill(PosiPhi*TMath::RadToDeg());
241 hMCElecPhi->fill(ElecPhi*TMath::RadToDeg());
242 hMCEtaPPhi->fill(EtaPPhi*TMath::RadToDeg());
244 hMCPosiThe->fill(PosiThe*TMath::RadToDeg());
245 hMCElecThe->fill(ElecThe*TMath::RadToDeg());
246 hMCEtaPThe->fill(EtaPThe*TMath::RadToDeg());
251 GenEvent* evt =
new GenEvent(1,1);
253 GenVertex* prod_vtx =
new GenVertex();
254 evt->add_vertex( prod_vtx );
257 GenParticle* p =
new GenParticle( HepLorentzVector(p1[1],p1[2],p1[3],p1[0]), -11, 3);
258 p->suggest_barcode(1 );
259 prod_vtx->add_particle_in(p);
262 p =
new GenParticle(HepLorentzVector(p2[1],p2[2],p2[3],p2[0]), 11, 3);
263 p->suggest_barcode( 2 );
264 prod_vtx->add_particle_in(p);
268 p =
new GenParticle(HepLorentzVector(q1[1],q1[2],q1[3],q1[0]), -11, 1);
269 p->suggest_barcode(3 );
270 prod_vtx->add_particle_out(p);
273 p =
new GenParticle( HepLorentzVector(q2[1],q2[2],q2[3],q2[0] ), 11, 1);
274 p->suggest_barcode( 4 );
275 prod_vtx->add_particle_out(p);
277 if (m_channel_id == 2){
278 p =
new GenParticle( HepLorentzVector( qpion[1],qpion[2],qpion[3],qpion[0]), 111, 1);
279 p->suggest_barcode( 5 );
280 prod_vtx->add_particle_out(p);
282 else if (m_channel_id == 3){
283 p =
new GenParticle( HepLorentzVector( qpion[1],qpion[2],qpion[3],qpion[0]), 221, 1);
284 p->suggest_barcode( 5 );
285 prod_vtx->add_particle_out(p);
287 else if (m_channel_id == 4){
288 p =
new GenParticle( HepLorentzVector( qpion[1],qpion[2],qpion[3],qpion[0]), 331, 1);
289 p->suggest_barcode( 5 );
290 prod_vtx->add_particle_out(p);
292 else if (m_channel_id == 1) {
294 p =
new GenParticle( HepLorentzVector( pi1[1],pi1[2],pi1[3],pi1[0]),211, 1);
295 p->suggest_barcode( 5 );
296 prod_vtx->add_particle_out(p);
298 p =
new GenParticle( HepLorentzVector(pi2[1],pi2[2],pi2[3],pi2[0]), -211, 1);
299 p->suggest_barcode( 6 );
300 prod_vtx->add_particle_out(p);
303 if( log.level() <= MSG::INFO )
313 SmartDataPtr<McGenEventCol> anMcCol(eventSvc(),
"/Event/Gen");
317 MsgStream log(messageService(), name());
318 log << MSG::INFO <<
"Add McGenEvent to existing collection" << endreq;
320 anMcCol->push_back(mcEvent);
327 mcColl->push_back(mcEvent);
328 StatusCode sc = eventSvc()->registerObject(
"/Event/Gen",mcColl);
329 if (sc != StatusCode::SUCCESS)
331 log << MSG::ERROR <<
"Could not register McGenEvent" << endreq;
335 return StatusCode::FAILURE;
339 log << MSG::INFO <<
"McGenEventCol created " << endreq;
344 log<<MSG::INFO<<
"before execute() return"<<endreq;
345 return StatusCode::SUCCESS;
350 MsgStream log(
msgSvc(), name());
351 log << MSG::INFO <<
"Ekhara in finalize()" << endreq;
352 log << MSG::INFO <<
"Ekhara is terminated now successfully" << endreq;
355 return StatusCode::SUCCESS;
#define COMMON_BLOCK_DEF(DEFINITION, NAME)
#define PROTOCCALLSFSUB7(UN, LN, T1, T2, T3, T4, T5, T6, T7)
#define PROTOCCALLSFSUB0(UN, LN)
#define PROTOCCALLSFSUB1(UN, LN, T1)
#define GET_MOMENTUM(p1, p2, q1, q2, pi1, pi2, qpion)
#define BOSS_INIT_READ(xpar)
#define GET_MOMENTUM(p1, p2, q1, q2, pi1, pi2, qpion)
#define EKHARA_SET_SILENT()
#define BOSS_INIT_READ(xpar)
#define EKHARA_SET_ONE_EVENT_MODE()
ObjectVector< McGenEvent > McGenEventCol
IHistogramSvc * histoSvc()
static void setRandomEngine(CLHEP::HepRandomEngine *randomEngine)
Ekhara(const std::string &name, ISvcLocator *pSvcLocator)
virtual CLHEP::HepRandomEngine * GetEngine(const std::string &StreamName)=0
Interface to the CLHEP engine.