BOSS 7.0.6
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 141 of file Babayaga.cxx.

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

Member Function Documentation

◆ execute()

StatusCode Babayaga::execute ( )

Definition at line 209 of file Babayaga.cxx.

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

◆ finalize()

StatusCode Babayaga::finalize ( )

Definition at line 325 of file Babayaga.cxx.

326{
327 MsgStream log(messageService(), name());
328 char delcmd[300];
329 strcpy(delcmd,"cat ");
330 strcat(delcmd,"CrossSection.txt");
331 system(delcmd);
332
333 std::cout<< "BABAYAGA finalized" << endl;
334 return StatusCode::SUCCESS;
335}

◆ getMaxEvent()

StatusCode Babayaga::getMaxEvent ( )

Definition at line 337 of file Babayaga.cxx.

337 {
338 IProperty* appPropMgr=0;
339 StatusCode status =
340 serviceLocator()->getService("ApplicationMgr", IProperty::interfaceID(),
341 reinterpret_cast<IInterface*&>( appPropMgr ));
342 if( status.isFailure() ) return status;
343
344 IntegerProperty evtMax("EvtMax",0);
345 status = appPropMgr->getProperty( &evtMax );
346 if (status.isFailure()) return status;
347
348 m_evtMax = evtMax.value();
349 return status;
350}

Referenced by initialize().

◆ initialize()

StatusCode Babayaga::initialize ( )

Definition at line 163 of file Babayaga.cxx.

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

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