89 MsgStream log(
msgSvc(), name() );
91 log << MSG::INFO <<
"Mcgpj initialize" << endmsg;
93 static const bool CREATEIFNOTTHERE(
true );
94 StatusCode RndmStatus = service(
"BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE );
95 if ( !RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc )
97 log << MSG::ERROR <<
" Could not initialize Random Number Service" << endmsg;
100 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->GetEngine(
"Mcgpj" );
101 engine->showStatus();
110 if ( gRandom )
delete gRandom;
111 gRandom =
new TRandom3();
112 gRandom->SetSeed( engine->getSeed() );
122 if ( ( proc % 10 ) == 3 )
131 const int MaxList = 20;
132 bool InList[MaxList];
133 for (
int j = 0; j < MaxList; j++ ) InList[j] =
true;
135 double EBeam = 0.5 * cmE;
139 log << MSG::ERROR <<
"Invalid value of beam energy:" <<
EBeam << endmsg;
140 return StatusCode::FAILURE;
145 gGlobal->Set_RelativeError( re );
147 gGlobal->Set_Type( ( proc % 10 ) );
153 if ( 0 > td )
gGlobal->Set_ThetaMin( at - dt / 2 );
154 else gGlobal->Set_ThetaMin( td );
158 if ( ( proc % 10 ) == 0 )
gGlobal->Set_dE_Abs( 0.015 *
EBeam );
161 else gGlobal->Set_dE_Abs( de );
165 if ( proc > 10 )
gGlobal->Set_Theta0_Rel( 0.0 );
166 else gGlobal->Set_Theta0_Rel( 1.5 );
168 else gGlobal->Set_Theta0_Rel( nt0 );
172 gCut->ThetaMinM( thm );
176 if ( 0 < thp )
gCut->ThetaMinP( thp );
180 gCut->DeltaTheta( dt );
182 gCut->AverageTheta( at );
184 gCut->DeltaPhi( dp );
186 gCut->PAverage( am );
192 gConst->SetAlphaScale( al );
197 {
gGlobal->Init(); }
catch ( std::logic_error lge )
199 log << MSG::ERROR << lge.what() << endmsg;
200 return StatusCode::FAILURE;
203 gGlobal->SetDatadir( m_datapath );
204 gGlobal->SetVpolFname( m_vpolfname );
212 log << MSG::INFO <<
"Cross-section statistical precision will be better than "
213 <<
gGlobal->Get_TotalError() <<
" nb and " <<
gGlobal->Get_RelativeError() * 100 <<
"%"
217 log << MSG::INFO <<
"Hard photon on big angle is not included!" << endmsg;
219 if ( IsNoVacPol ) log << MSG::INFO <<
"Vacuum polarization is not included!" << endmsg;
221 if ( !IsFSR ) log << MSG::INFO <<
"Final state radiation is not included!" << endmsg;
223 if ( proc > 10 ) log << MSG::INFO <<
"Alpha order generation only!" << endmsg;
237 else if ( proc == 10 )
240 for (
int j = 0; j < MaxList; j++ ) InList[j] =
false;
245 else return StatusCode::FAILURE;
252 gRad->SetNEvents( NRad );
253 gRad->SetPartList( InList );
257 gRad->MakeCrossSection();
260 if ( ( proc % 10 ) == 0 )
266 if ( ( proc % 10 ) == 1 )
272 if ( ( proc % 10 ) == 2 )
278 if ( ( proc % 10 ) == 3 )
284 if ( ( proc % 10 ) == 4 )
290 if ( ( proc % 10 ) == 5 )
296 if ( ( proc % 10 ) == 6 )
305 double EBeam = 0.5 * cmE;
306 if ( 0 > de ) de = 0.005 *
EBeam;
308 if ( 0 > nt0 ) nt0 = 1;
313 if ( spread > 0 )
CS->SetBeamSpread( spread );
315 else if ( proc == 101 )
318 if ( spread > 0 )
CS->SetBeamSpread( spread );
320 else if ( proc == 102 )
323 if ( spread > 0 )
CS->SetBeamSpread( spread );
328 log << MSG::INFO <<
"Mcgpj initialize finished" << endmsg;
330 return StatusCode::SUCCESS;
334 MsgStream log(
msgSvc(), name() );
335 log << MSG::INFO <<
"Mcgpj executing" << endmsg;
336 log << MSG::WARNING <<
"execute start" << endmsg;
339 GenEvent* evt =
new GenEvent( 1, 1 );
341 GenVertex* prod_vtx =
new GenVertex();
343 evt->add_vertex( prod_vtx );
347 new GenParticle( HepLorentzVector( 0, 0, 0.5 * cmE * 1e-3, 0.5 * cmE * 1e-3 ), -11, 3 );
348 p->suggest_barcode( 1 );
349 prod_vtx->add_particle_in( p );
352 p =
new GenParticle( HepLorentzVector( 0, 0, 0.5 * cmE * 1e-3, 0.5 * cmE * 1e-3 ), 11, 3 );
353 p->suggest_barcode( 2 );
354 prod_vtx->add_particle_in( p );
361 gRad->MakeEvent( mom, np );
364 for (
int i = 0; i < np; i++ )
366 double ptot = mom[i * 4 + 3];
367 double px = ptot * mom[i * 4 + 0];
368 double py = ptot * mom[i * 4 + 1];
369 double pz = ptot * mom[i * 4 + 2];
378 p =
new GenParticle( HepLorentzVector( px, py, pz,
etot ), pid, 1 );
379 p->suggest_barcode( i + 3 );
380 prod_vtx->add_particle_out( p );
386 int ipart =
CS->GenUnWeightedEvent();
387 size_t nmax =
CS->GetNfinal() + ( ( ipart == 0 ) ? 1 : 2 );
388 for (
size_t i = 0; i < nmax; i++ )
390 TLorentzVector&
q = *(
CS->GetParticles()[i] );
391 int pid =
CS->GetPid( i );
393 HepLorentzVector(
q.X() * 1e-3,
q.Y() * 1e-3,
q.Z() * 1e-3,
q.T() * 1e-3 ), pid, 1 );
394 p->suggest_barcode( i + 3 );
395 prod_vtx->add_particle_out( p );
400 if ( log.level() < MSG::INFO ) { evt->print(); }
403 SmartDataPtr<McGenEventCol> anMcCol( eventSvc(),
"/Event/Gen" );
407 log << MSG::WARNING <<
"add event" << endmsg;
408 MsgStream log(
msgSvc(), name() );
409 log << MSG::INFO <<
"Add McGenEvent to existing collection" << endmsg;
411 anMcCol->push_back( mcEvent );
416 log << MSG::WARNING <<
"create collection" << endmsg;
419 mcColl->push_back( mcEvent );
420 StatusCode sc = eventSvc()->registerObject(
"/Event/Gen", mcColl );
421 if ( sc != StatusCode::SUCCESS )
423 log << MSG::ERROR <<
"Could not register McGenEvent" << endmsg;
427 return StatusCode::FAILURE;
431 log << MSG::INFO <<
"McGenEventCol created and " << npart
432 <<
" particles stored in McGenEvent" << endmsg;
436 log << MSG::WARNING <<
"execute end" << endmsg;
437 return StatusCode::SUCCESS;