BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Babayaga Class Reference

#include <Babayaga.h>

Inheritance diagram for Babayaga:

Public Member Functions

 Babayaga (const string &name, ISvcLocator *pSvcLocator)
StatusCode initialize ()
StatusCode execute ()
StatusCode finalize ()
StatusCode getMaxEvent ()

Detailed Description

Definition at line 26 of file Babayaga.h.

Constructor & Destructor Documentation

◆ Babayaga()

Babayaga::Babayaga ( const string & name,
ISvcLocator * pSvcLocator )

Definition at line 135 of file Babayaga.cxx.

136 : Algorithm( name, pSvcLocator ) {
137 // declareProperty("Seed", m_Int = 62341342); // seed for random number generator
138 declareProperty( "Channel", m_Ich = 1 ); // 1: e+e-->e+e-;2:e+e_->mu+mu-;3:e+e-->gamma
139 // gamma;4:e+e--->pi+pi-
140 declareProperty( "Ebeam", m_Ebeam = 1.548 ); // Ecm = 2*Ebeam [GeV]
141 declareProperty( "MinThetaAngle", m_Thmin = 70 ); // [degree]
142 declareProperty( "MaxThetaAngle", m_Thmax = 178 ); // [degree]
143 declareProperty( "MinimumEnergy", m_Emin = 0.4 ); // Minimum Energy(GeV)
144 declareProperty( "MaximumAcollinearity", m_Zmax = 10 ); // Maximum acollinearity (degree)
145 declareProperty( "RunningAlpha", m_Iarun = 1 ); // running alpha, 0=off, 1=on
146 declareProperty( "HadronicResonance", m_Ires = 0 ); // hadronic resoances for ICH=1 or 2
147 declareProperty( "FSR_swich", m_on = 0 ); // FSR switch for ICH=2 ( 0=off, 1=on)
148 declareProperty( "MinEnerCutG", m_Egmin = 0.01 ); // minimum energy for CUTG=Y (GeV)
149 declareProperty( "MinAngCutG", m_Thgmin = 5 ); // minimum angle for cuts =Y (deg.)
150 declareProperty( "MaxAngCutG", m_Thgmax = 21 ); // maximum angle for CUTG=Y (deg.)
151 declareProperty( "HBOOK", HN = 1 ); // INTUPLE: if events have to be stored (1/0)
152 declareProperty( "PHCUT", m_PHCUT = 0 ); // PHCUT: to avoid double counting when ICH = 3
153 // (1/0), for other channels, it set as 0 by default
154 declareProperty( "CUTG",
155 m_CUTG = 0 ); // CUTG: explicit cuts on the generated photons (1/0)
156 declareProperty( "CutNgam", m_CutNgam = 0 ); // mininum number of ISR photon cut on Radiative
157 // Bhabha events
158 declareProperty( "CutEgam", m_CutEgam = 0 ); // in GeV, mininum energy of ISR photon cut on
159 // Radiative Bhabha events
160}

Referenced by Babayaga().

Member Function Documentation

◆ execute()

StatusCode Babayaga::execute ( )

Definition at line 211 of file Babayaga.cxx.

211 {
212 MsgStream log( msgSvc(), name() );
213 // log << MSG::INFO << "BABAYAGA executing" << endmsg;
214 // std::cout<<"BABAYAGA begin executing"<<std::endl;
215
216 int npart = 0;
217 int pid1, pid2, pst1, pst2;
218 if ( m_Ich == 1 )
219 {
220 pid1 = 11;
221 pid2 = -11;
222 pst1 = 1;
223 pst2 = 1;
224 }
225 if ( m_Ich == 2 )
226 {
227 pid1 = 13;
228 pid2 = -13;
229 pst1 = 1;
230 pst2 = 1;
231 }
232 if ( m_Ich == 3 )
233 {
234 pid1 = 22;
235 pid2 = 22;
236 pst1 = 1;
237 pst2 = 1;
238 }
239 if ( m_Ich == 4 )
240 {
241 pid1 = -211;
242 pid2 = 211;
243 pst1 = 1;
244 pst2 = 1;
245 }
246
247 // Fill event information
248 GenEvent* evt = new GenEvent( 1, 1 );
249
250 GenVertex* prod_vtx = new GenVertex();
251 // prod_vtx->add_particle_out( p );
252 evt->add_vertex( prod_vtx );
253
254 // incoming beam e- HepLorentzVector(px,py,pz,energy) required!
255 GenParticle* p =
256 new GenParticle( CLHEP::HepLorentzVector( MOMSET.p1[1][evtgen], MOMSET.p1[2][evtgen],
257 MOMSET.p1[3][evtgen], MOMSET.p1[0][evtgen] ),
258 11, 3 );
259 p->suggest_barcode( ++npart );
260 prod_vtx->add_particle_in( p );
261
262 // std::cout<<"incoming beam e+"<<endl;
263 // incoming beam e+, e+ moving along the z-direction
264 p = new GenParticle( CLHEP::HepLorentzVector( MOMSET.q1[1][evtgen], MOMSET.q1[2][evtgen],
265 MOMSET.q1[3][evtgen], MOMSET.q1[4][evtgen] ),
266 -11, 3 );
267
268 p->suggest_barcode( ++npart );
269 prod_vtx->add_particle_in( p );
270
271 // scattered lepton +
272 p = new GenParticle( CLHEP::HepLorentzVector( MOMSET.p2[1][evtgen], MOMSET.p2[2][evtgen],
273 MOMSET.p2[3][evtgen], MOMSET.p2[0][evtgen] ),
274 pid1, pst1 );
275 p->suggest_barcode( ++npart );
276 prod_vtx->add_particle_out( p );
277
278 // debuging pingrg
279 // std::cout<<"evtgen= "<<evtgen<<std::endl;
280 // std::cout<<"b:e-: "<<MOMSET.p1[0][evtgen]<<"; "<< MOMSET.p1[1][evtgen]<<";
281 // "<<MOMSET.p1[2][evtgen]<<"; "<< MOMSET.p1[3][evtgen]<<std::endl; std::cout<<"b:e+:
282 // "<<MOMSET.q1[0][evtgen]<<"; "<< MOMSET.q1[1][evtgen]<<"; "<<MOMSET.q1[2][evtgen]<<"; "<<
283 // MOMSET.q1[3][evtgen]<<std::endl; std::cout<<"e-: "<<MOMSET.p2[0][evtgen]<<"; "<<
284 // MOMSET.p2[1][evtgen]<<"; "<<MOMSET.p2[2][evtgen]<<"; "<< MOMSET.p2[3][evtgen]<<std::endl;
285 // std::cout<<"e+: "<<MOMSET.q2[0][evtgen]<<"; "<< MOMSET.q2[1][evtgen]<<";
286 // "<<MOMSET.q2[2][evtgen]<<"; "<< MOMSET.q2[3][evtgen]<<std::endl;
287
288 // scattered lepton -
289 p = new GenParticle( CLHEP::HepLorentzVector( MOMSET.q2[1][evtgen], MOMSET.q2[2][evtgen],
290 MOMSET.q2[3][evtgen], MOMSET.q2[0][evtgen] ),
291 pid2, pst2 );
292 p->suggest_barcode( ++npart );
293 prod_vtx->add_particle_out( p );
294
295 int iphot = 0;
296 // std::cout<<"evtgen, ncqph[events#] "<<evtgen<<"; "<<ISRPHOTONS.ncqph[evtgen-1]<<std::endl;
297 for ( iphot = 0; iphot < ISRPHOTONS.ncqph[evtgen - 1]; iphot++ )
298 {
299 // debuging, pingrg
300 // std::cout<<"evtgen, iphot= "<<evtgen<<"; "<<iphot<<std::endl;
301 // std::cout<<MOMSET.phot[0][iphot][evtgen]<<", "<<MOMSET.phot[1][iphot][evtgen]<<",
302 // "<<MOMSET.phot[2][iphot][evtgen]<<", "<<MOMSET.phot[3][iphot][evtgen]<<std::endl;
303
304 p = new GenParticle( CLHEP::HepLorentzVector(
305 MOMSET.phot[1][iphot][evtgen], MOMSET.phot[2][iphot][evtgen],
306 MOMSET.phot[3][iphot][evtgen], MOMSET.phot[0][iphot][evtgen] ),
307 22, 1 );
308 p->suggest_barcode( ++npart );
309 prod_vtx->add_particle_out( p );
310 }
311
312 evtgen++;
313
314 if ( log.level() < MSG::INFO ) { evt->print(); }
315
316 // Check if the McCollection already exists
317 SmartDataPtr<McGenEventCol> anMcCol( eventSvc(), "/Event/Gen" );
318 if ( anMcCol != 0 )
319 {
320 // Add event to existing collection
321 MsgStream log( msgSvc(), name() );
322 log << MSG::INFO << "Add McGenEvent to existing collection" << endmsg;
323 McGenEvent* mcEvent = new McGenEvent( evt );
324 anMcCol->push_back( mcEvent );
325 }
326 else
327 {
328 // Create Collection and add to the transient store
329 McGenEventCol* mcColl = new McGenEventCol;
330 McGenEvent* mcEvent = new McGenEvent( evt );
331 mcColl->push_back( mcEvent );
332 StatusCode sc = eventSvc()->registerObject( "/Event/Gen", mcColl );
333 if ( sc != StatusCode::SUCCESS )
334 {
335 log << MSG::ERROR << "Could not register McGenEvent" << endmsg;
336 delete mcColl;
337 delete evt;
338 delete mcEvent;
339 return StatusCode::FAILURE;
340 }
341 else
342 {
343 // log << MSG::INFO << "McGenEventCol created and " << npart <<" particles stored in
344 // McGenEvent" << endmsg;
345 }
346 }
347
348 return StatusCode::SUCCESS;
349}
#define MOMSET
Definition Babayaga.cxx:43
#define ISRPHOTONS
Definition Babayaga.cxx:56
ObjectVector< McGenEvent > McGenEventCol
IMessageSvc * msgSvc()

◆ finalize()

StatusCode Babayaga::finalize ( )

Definition at line 351 of file Babayaga.cxx.

351 {
352 MsgStream log( msgSvc(), name() );
353 char delcmd[300];
354 strcpy( delcmd, "cat " );
355 strcat( delcmd, "CrossSection.txt" );
356 system( delcmd );
357
358 std::cout << "BABAYAGA finalized" << endl;
359 return StatusCode::SUCCESS;
360}

◆ getMaxEvent()

StatusCode Babayaga::getMaxEvent ( )

Definition at line 362 of file Babayaga.cxx.

362 {
363 IProperty* appPropMgr = 0;
364 StatusCode status =
365 serviceLocator()->getService( "ApplicationMgr", IProperty::interfaceID(),
366 reinterpret_cast<IInterface*&>( appPropMgr ) );
367 if ( status.isFailure() ) return status;
368
369 IntegerProperty evtMax( "EvtMax", 0 );
370 status = appPropMgr->getProperty( &evtMax );
371 if ( status.isFailure() ) return status;
372
373 m_evtMax = evtMax.value();
374 return status;
375}

Referenced by initialize().

◆ initialize()

StatusCode Babayaga::initialize ( )

Definition at line 162 of file Babayaga.cxx.

162 {
163
164 MsgStream log( msgSvc(), name() );
165
166 log << MSG::INFO << "Babayaga initialize" << endmsg;
167
168 // set Bes unified random engine
169 static const bool CREATEIFNOTTHERE( true );
170 StatusCode RndmStatus = service( "BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE );
171 if ( !RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc )
172 {
173 log << MSG::ERROR << " Could not initialize Random Number Service" << endmsg;
174 return RndmStatus;
175 }
176 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->GetEngine( "Babayaga" );
177 std::cout << "===============================" << engine << endl;
179 // *****************
180
181 if ( HN == 1 ) { DECLARESTR.tuple = 'Y'; }
182 else DECLARESTR.tuple = 'N';
183 if ( m_PHCUT == 1 ) { DECLARESTR.phcut = 'Y'; }
184 else DECLARESTR.cutg = 'N';
185 if ( m_CUTG == 1 ) { DECLARESTR.cutg = 'Y'; }
186 else DECLARESTR.cutg = 'N';
187 CHANNEL.ich = m_Ich;
188 BEAMENERGY.ebeam = m_Ebeam;
189 EXPCUTS.thmin = m_Thmin;
190 EXPCUTS.thmax = m_Thmax;
191 EXPCUTS.emin = m_Emin;
192 EXPCUTS.zmax = m_Zmax;
193 SWITCHARUN.iarun = m_Iarun;
194 RESONANCES.ires = m_Ires;
195 SWITCH.on = m_on;
196 EXPCUTS.egmin = m_Egmin;
197 EXPCUTS.thgmin = m_Thgmin;
198 EXPCUTS.thgmax = m_Thgmax;
199
200 // std::cout<<"m_Ires= "<<m_Ires<<endl;
201
202 getMaxEvent().ignore();
203 std::cout << "m_evtMax = " << m_evtMax << std::endl;
204 DECLAREINT.seed = m_Int;
205 BABAYAGA( m_evtMax );
206
207 return StatusCode::SUCCESS;
208}
#define SWITCHARUN
Definition Babayaga.cxx:86
#define EXPCUTS
Definition Babayaga.cxx:71
#define BABAYAGA(NEVENTS)
Definition Babayaga.cxx:132
#define DECLAREINT
Definition Babayaga.cxx:107
#define DECLARESTR
Definition Babayaga.cxx:114
#define SWITCH
Definition Babayaga.cxx:79
#define CHANNEL
Definition Babayaga.cxx:93
#define BEAMENERGY
Definition Babayaga.cxx:63
#define RESONANCES
Definition Babayaga.cxx:100
static void setRandomEngine(CLHEP::HepRandomEngine *randomEngine)
StatusCode getMaxEvent()
Definition Babayaga.cxx:362

The documentation for this class was generated from the following files: