BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
Bhwide.cxx
Go to the documentation of this file.
1//*****************************************************************************
2//
3// Bhwide.cxx
4//
5// Algorithm runs large angle Bhabha event generator Bhwide
6// and stores output to transient store
7//
8// Aug 2007 A. Zhemchugov, initial version written for BES3
9//*****************************************************************************
10
11// Header for this module:-
12#include "Bhwide/Bhwide.h"
13#include "Bhwide/BhwideRandom.h"
14
15// Framework Related Headers:-
16#include "HepMC/GenEvent.h"
17#include "HepMC/GenVertex.h"
18#include "HepMC/GenParticle.h"
19#include "CLHEP/Vector/LorentzVector.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
27#include "GeneratorObject/McGenEvent.h"
28#include "BesKernel/IBesRndmGenSvc.h"
29
30#include "cfortran/cfortran.h"
31
32#include <stdlib.h>
33
34using namespace std;
35// COMMON / momset / p1(4),q1(4),p2(4),q2(4),phot(100,4),nphot
36// * COMMON / wgtall / wtmod,wtcru1,wtcru2,wtset(300)
37
38typedef struct {
39 double p1[4];
40 double q1[4];
41 double p2[4];
42 double q2[4];
43 double phot[4][100];
44 int nphot; } MOMSET_DEF;
45
46#define MOMSET COMMON_BLOCK(MOMSET_DEF, momset)
48//MOMSET_DEF MOMSET;
49
50//-------------------------
51
52PROTOCCALLSFSUB1(GLIMIT,glimit,INT)
53#define GLIMIT(LENMX) CCALLSFSUB1(GLIMIT,glimit,INT,LENMX)
54
55PROTOCCALLSFSUB1(DUMPS,dumps,INT)
56#define DUMPS(NOUT) CCALLSFSUB1(DUMPS,dumps,INT,NOUT)
57
58PROTOCCALLSFSUB3(BHWIDE,bhwide,INT,DOUBLEV,INTV)
59#define BHWIDE(MODE,XPAR,NPAR) CCALLSFSUB3(BHWIDE,bhwide,INT,DOUBLEV,INTV,MODE,XPAR,NPAR)
60
61PROTOCCALLSFSUB3(MARINI, marini, INT, INT, INT)
62#define MARINI(IJKLIN, NTOTIN, NTOT2N) CCALLSFSUB3(MARINI, marini, INT, INT, INT, IJKLIN, NTOTIN, NTOT2N)
63
64extern "C" {
65 extern double ranmarr_();
66 extern void marran_(float* rvec, int* nma);
67 extern void ecuran_(double* rvec, int* nma);
68 extern void carran_(double* rvec, int* nma);
69}
70
71double ranmarr_()
72{
73 return BhwideRandom::random();
74}
75
76void marran_(float* rvec, int* nma)
77{
78 int nmax = *nma;
79 assert(nmax<100);
80 double rvecd[100];
81 BhwideRandom::FlatArray(rvecd, nmax);
82 for(int i=0; i<nmax; i++) rvec[i]=rvecd[i];
83}
84
85void carran_(double* rvec, int* nma)
86{
87 int nmax = *nma;
88 assert(nmax<100);
89 double rvecd[100];
90 BhwideRandom::FlatArray(rvecd, nmax);
91 for(int i=0; i<nmax; i++) rvec[i]=rvecd[i];
92}
93
94void ecuran_(double* rvec, int* nma)
95{
96 int nmax = *nma;
97 assert(nmax<100);
98 double rvecd[100];
99 BhwideRandom::FlatArray(rvecd, nmax);
100 for(int i=0; i<nmax; i++) rvec[i]=rvecd[i];
101}
102
103
104
105
106//float ranmar_(){
107// return BhwideRandom::random();
108//}
109
110Bhwide::Bhwide(const string& name, ISvcLocator* pSvcLocator):Algorithm( name, pSvcLocator )
111{
112 declareProperty("CMEnergy", m_cmEnergy = 3.097); // 2*Ebeam [GeV]
113 declareProperty("EleMinThetaAngle", m_ThMine = 22); // [deg]
114 declareProperty("EleMaxThetaAngle", m_ThMaxe = 158); // [deg]
115 declareProperty("PosMinThetaAngle", m_ThMinp = 22); // [deg]
116 declareProperty("PosMaxThetaAngle", m_ThMaxp = 158); // [deg]
117 declareProperty("EleMinEnergy", m_EnMine = 0.01); // [GeV]
118 declareProperty("PosMinEnergy", m_EnMinp = 0.01); // [GeV]
119 declareProperty("Acollinearity", m_Acolli = 10); // [deg]
120 declareProperty("SoftPhotonCut", m_infraredCut = 1E-5); // dimensionless, Ephoton > m_infraredCut*sqrt(s)/2
121 declareProperty("VacuumPolarization", m_keyPia = 3); // 0 - OFF, 1 - ON, Burkhardt et.al. 1989, as in BHLUMI 2.0x, 2 - ON, S. Eidelman, F. Jegerlehner, Z.Phys.C(1995), 3 - ON, Burkhardt and Pietrzyk 1995 (Moriond).
122 declareProperty("KeyMod", m_keyMod = 2); // type of MODEL subprogram and QED matrix element for hard bremsstrahlung: 1 - obtained by the authors (helicity amplitudes), 2 - from CALKUL, Nucl. Phys. B206 (1982) 61. Checked to be in a very good agreement!
123 declareProperty("KeyLib", m_keyLib = 2); // option for ElectroWeak Corrections Library: 1 - ElectroWeak Corr. from BABAMC (obsolete), 2 - ElectroWeak Corr. from ALIBABA, RECOMMENDED
124 declareProperty("EWC", m_keyEwc = 1); // switching ON/OFF weak corrections: 0 - only QED corrections included (here both KeyLib =1,2 should be equivalent), 1 - all ElectroWeak Corrections included
125 m_initSeed.clear();
126// m_initSeed.push_back(54217137); m_initSeed.push_back(0); m_initSeed.push_back(0);
127// declareProperty("InitializedSeed", m_initSeed);
128}
129
131
132 MsgStream log(messageService(), name());
133
134 log << MSG::INFO << "Bhwide initialize" << endreq;
135
136 static const bool CREATEIFNOTTHERE(true);
137 StatusCode RndmStatus = service("BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE);
138 if (!RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc)
139 {
140 log << MSG::ERROR << " Could not initialize Random Number Service" << endreq;
141 return RndmStatus;
142 }
143 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->GetEngine("Bhwide");
144 engine->showStatus();
146
147 GLIMIT(50000);
148
149//!---------------------------------------------------------------------------
150//! Input parameters for Bhwide
151//!----------------------------------------------------------------------
152 double WTMAX = 3.0; // ! Maximum Weight for rejection
153 double AMAZ = 91.1882; // ! Z mass
154 double GAMMZ = 2.4952; // ! Z width (may be recalculated by EW library)
155 double SINW2 = 0.22225; // ! sin^2(theta_W) (may be recalculated by EW library)
156 double AMTOP = 174.3; // ! top quark mass
157 double AMHIG = 115.0; // ! Higgs mass
158 //! Try both options for KeyWgt, result should be the same
159 int KeyWgt = 0; // ! unweighted (WT=1) events, for detector simulation
160 //!# KeyWgt = 1 // ! weighted events
161 int KeyRnd = 1; // ! RANMAR random numbers
162 int KeyCha = 0; // ! Channel choice: all/s-only/t-only: =0/1/2
163 int KeyZof = 0; // ! Z-contribution ON/OFF: =0/1
164 int KeyOpt = 1000*KeyZof +100*KeyCha +10*KeyWgt + KeyRnd;
165 // !# KeyEWC = 0 ! QED corrections only
166 int KeyEWC = m_keyEwc; // ! Total O(alpha) ElectroWeak corr. included
167 // !# KeyLib = 1 ! ElectroWeak corrections from BABAMC (obsolete!)
168 int KeyLib = m_keyLib; // ! ElectroWeak corrections from ALIBABA
169 // !# KeyMod = 1 ! Hard bremsstr. matrix element from MODEL1
170 int KeyMod = m_keyMod; // ! Hard bremsstr. matrix alement from MODEL2
171 int KeyPia = m_keyPia; // ! Vacuum polarization option (0/1/2/3)
172 int KeyRad = 1000*KeyEWC + 100*KeyLib + 10*KeyMod + KeyPia;
173
174 //!--------------------------------------
175 npar[0]= KeyOpt;
176 npar[1]= KeyRad;
177
178 xpar[0] = m_cmEnergy; //! 2*Ebeam [GeV]
179 xpar[1] = m_ThMinp;
180 xpar[2] = m_ThMaxp;
181 xpar[3] = m_ThMine;
182 xpar[4] = m_ThMaxe;
183 xpar[5] = m_EnMinp;
184 xpar[6] = m_EnMine;
185 xpar[7] = m_Acolli;
186 xpar[8] = m_infraredCut; // ! Infrared cut on photon energy
187 xpar[9] = WTMAX;
188 xpar[10] = AMAZ;
189 xpar[11] = GAMMZ;
190 xpar[12] = SINW2;
191 xpar[13] = AMTOP;
192 xpar[14] = AMHIG;
193
194 //MARINI(m_initSeed[0], m_initSeed[1], m_initSeed[2]);
195
196 BHWIDE(-1,xpar,npar);
197
198 return StatusCode::SUCCESS;
199}
200
201StatusCode Bhwide::execute()
202{
203 MsgStream log(messageService(), name());
204 log << MSG::INFO << "Bhwide executing" << endreq;
205
206
207 BHWIDE( 0,xpar,npar);
208
209 if( log.level() < MSG::INFO )
210 {
211 DUMPS(6);
212 // dump output to file
213 // DUMPS(16);
214 }
215
216 int npart = 0;
217
218 // Fill event information
219 GenEvent* evt = new GenEvent(1,1);
220
221 GenVertex* prod_vtx = new GenVertex();
222// prod_vtx->add_particle_out( p );
223 evt->add_vertex( prod_vtx );
224
225 // incoming beam e+
226 GenParticle* p = new GenParticle( CLHEP::HepLorentzVector( MOMSET.p1[0], MOMSET.p1[1],
227 MOMSET.p1[2], MOMSET.p1[3]),
228 -11, 3);
229 p->suggest_barcode( ++npart );
230 prod_vtx->add_particle_in(p);
231
232 // incoming beam e-
233 p = new GenParticle( CLHEP::HepLorentzVector( MOMSET.q1[0], MOMSET.q1[1], MOMSET.q1[2], MOMSET.q1[3]),
234 11, 3);
235 p->suggest_barcode( ++npart );
236 prod_vtx->add_particle_in(p);
237
238 // scattered e+
239 p = new GenParticle( CLHEP::HepLorentzVector( MOMSET.p2[0], MOMSET.p2[1],
240 MOMSET.p2[2], MOMSET.p2[3]),
241 -11, 1);
242 p->suggest_barcode( ++npart );
243 prod_vtx->add_particle_out(p);
244
245 // scattered e-
246 p = new GenParticle( CLHEP::HepLorentzVector( MOMSET.q2[0], MOMSET.q2[1], MOMSET.q2[2], MOMSET.q2[3]),
247 11, 1);
248 p->suggest_barcode( ++npart );
249 prod_vtx->add_particle_out(p);
250
251 int iphot=0;
252 for (iphot=0; iphot<MOMSET.nphot; iphot++)
253 {
254 // gamma
255 p = new GenParticle( CLHEP::HepLorentzVector( MOMSET.phot[0][iphot], MOMSET.phot[1][iphot],
256 MOMSET.phot[2][iphot], MOMSET.phot[3][iphot]),
257 22, 1);
258 p->suggest_barcode( ++npart );
259 prod_vtx->add_particle_out(p);
260 }
261
262 if( log.level() < MSG::INFO )
263 {
264 evt->print();
265 }
266
267 // Check if the McCollection already exists
268 SmartDataPtr<McGenEventCol> anMcCol(eventSvc(), "/Event/Gen");
269 if (anMcCol!=0)
270 {
271 // Add event to existing collection
272 MsgStream log(messageService(), name());
273 log << MSG::INFO << "Add McGenEvent to existing collection" << endreq;
274 McGenEvent* mcEvent = new McGenEvent(evt);
275 anMcCol->push_back(mcEvent);
276 }
277 else
278 {
279 // Create Collection and add to the transient store
280 McGenEventCol *mcColl = new McGenEventCol;
281 McGenEvent* mcEvent = new McGenEvent(evt);
282 mcColl->push_back(mcEvent);
283 StatusCode sc = eventSvc()->registerObject("/Event/Gen",mcColl);
284 if (sc != StatusCode::SUCCESS)
285 {
286 log << MSG::ERROR << "Could not register McGenEvent" << endreq;
287 delete mcColl;
288 delete evt;
289 delete mcEvent;
290 return StatusCode::FAILURE;
291 }
292 else
293 {
294 log << MSG::INFO << "McGenEventCol created and " << npart <<" particles stored in McGenEvent" << endreq;
295 }
296 }
297
298 return StatusCode::SUCCESS;
299}
300
301StatusCode Bhwide::finalize()
302{
303 MsgStream log(messageService(), name());
304
305 BHWIDE( 2,xpar,npar);
306
307 log << MSG::INFO << "Bhwide finalized" << endreq;
308
309 return StatusCode::SUCCESS;
310}
#define MOMSET
Definition: Babayaga.cxx:45
#define DUMPS(NOUT)
Definition: Bhlumi.cxx:58
#define GLIMIT(LENMX)
Definition: Bhlumi.cxx:55
void marran_(float *rvec, int *nma)
Definition: Bhwide.cxx:76
#define MOMSET
Definition: Bhwide.cxx:46
void carran_(double *rvec, int *nma)
Definition: Bhwide.cxx:85
#define MARINI(IJKLIN, NTOTIN, NTOT2N)
Definition: Bhwide.cxx:62
#define BHWIDE(MODE, XPAR, NPAR)
Definition: Bhwide.cxx:59
double ranmarr_()
Definition: Bhwide.cxx:71
#define DUMPS(NOUT)
Definition: Bhwide.cxx:56
void ecuran_(double *rvec, int *nma)
Definition: Bhwide.cxx:94
#define GLIMIT(LENMX)
Definition: Bhwide.cxx:53
#define PROTOCCALLSFSUB3(UN, LN, T1, T2, T3)
#define COMMON_BLOCK_DEF(DEFINITION, NAME)
#define PROTOCCALLSFSUB1(UN, LN, T1)
static void FlatArray(double *vect, const int size)
static void setRandomEngine(CLHEP::HepRandomEngine *randomEngine)
static double random()
Bhwide(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode initialize()
Definition: Bhwide.cxx:130
StatusCode finalize()
Definition: Bhwide.cxx:301
StatusCode execute()
Definition: Bhwide.cxx:201
virtual CLHEP::HepRandomEngine * GetEngine(const std::string &StreamName)=0
Interface to the CLHEP engine.