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