BOSS 6.6.4.p03
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.

135 :Algorithm( name, pSvcLocator )
136{
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 gamma;4:e+e--->pi+pi-
139 declareProperty("Ebeam", m_Ebeam = 1.548); // Ecm = 2*Ebeam [GeV]
140 declareProperty("MinThetaAngle", m_Thmin = 70); // [degree]
141 declareProperty("MaxThetaAngle", m_Thmax = 178); // [degree]
142 declareProperty("MinimumEnergy", m_Emin = 0.4); // Minimum Energy(GeV)
143 declareProperty("MaximumAcollinearity", m_Zmax = 10); //Maximum acollinearity (degree)
144 declareProperty("RunningAlpha", m_Iarun = 1); //running alpha, 0=off, 1=on
145 declareProperty("HadronicResonance", m_Ires = 0); //hadronic resoances for ICH=1 or 2
146 declareProperty("FSR_swich", m_on = 0); // FSR switch for ICH=2 ( 0=off, 1=on)
147 declareProperty("MinEnerCutG", m_Egmin = 0.01); // minimum energy for CUTG=Y (GeV)
148 declareProperty("MinAngCutG", m_Thgmin = 5); // minimum angle for cuts =Y (deg.)
149 declareProperty("MaxAngCutG", m_Thgmax = 21); //maximum angle for CUTG=Y (deg.)
150 declareProperty("HBOOK", HN= 1); //INTUPLE: if events have to be stored (1/0)
151 declareProperty("PHCUT", m_PHCUT = 0); //PHCUT: to avoid double counting when ICH = 3 (1/0), for other channels, it set as 0 by default
152 declareProperty("CUTG", m_CUTG = 0); //CUTG: explicit cuts on the generated photons (1/0)
153}

Member Function Documentation

◆ execute()

StatusCode Babayaga::execute ( )

Definition at line 201 of file Babayaga.cxx.

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

◆ finalize()

StatusCode Babayaga::finalize ( )

Definition at line 317 of file Babayaga.cxx.

318{
319 MsgStream log(messageService(), name());
320 char delcmd[300];
321 strcpy(delcmd,"cat ");
322 strcat(delcmd,"CrossSection.txt");
323 system(delcmd);
324
325 std::cout<< "BABAYAGA finalized" << endl;
326 return StatusCode::SUCCESS;
327}

◆ getMaxEvent()

StatusCode Babayaga::getMaxEvent ( )

Definition at line 329 of file Babayaga.cxx.

329 {
330 IProperty* appPropMgr=0;
331 StatusCode status =
332 serviceLocator()->getService("ApplicationMgr", IProperty::interfaceID(),
333 reinterpret_cast<IInterface*&>( appPropMgr ));
334 if( status.isFailure() ) return status;
335
336 IntegerProperty evtMax("EvtMax",0);
337 status = appPropMgr->getProperty( &evtMax );
338 if (status.isFailure()) return status;
339
340 m_evtMax = evtMax.value();
341 return status;
342}

Referenced by initialize().

◆ initialize()

StatusCode Babayaga::initialize ( )

Definition at line 155 of file Babayaga.cxx.

155 {
156
157 MsgStream log(messageService(), name());
158
159 log << MSG::INFO << "Babayaga initialize" << endreq;
160
161 //set Bes unified random engine
162 static const bool CREATEIFNOTTHERE(true);
163 StatusCode RndmStatus = service("BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE);
164 if (!RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc)
165 {
166 log << MSG::ERROR << " Could not initialize Random Number Service" << endreq;
167 return RndmStatus;
168 }
169 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->GetEngine("Babayaga");
170 std::cout<<"==============================="<<engine<<endl;
172 // *****************
173
174 if(HN==1) {DECLARESTR.tuple='Y';} else DECLARESTR.tuple='N';
175 if(m_PHCUT==1){ DECLARESTR.phcut='Y';} else DECLARESTR.cutg='N';
176 if(m_CUTG ==1){ DECLARESTR.cutg='Y';} else DECLARESTR.cutg='N';
177 CHANNEL.ich = m_Ich;
178 BEAMENERGY.ebeam=m_Ebeam;
179 EXPCUTS.thmin=m_Thmin;
180 EXPCUTS.thmax=m_Thmax;
181 EXPCUTS.emin =m_Emin;
182 EXPCUTS.zmax=m_Zmax;
183 SWITCHARUN.iarun=m_Iarun;
184 RESONANCES.ires =m_Ires;
185 SWITCH.on =m_on;
186 EXPCUTS.egmin=m_Egmin;
187 EXPCUTS.thgmin=m_Thgmin;
188 EXPCUTS.thgmax=m_Thgmax;
189
190 // std::cout<<"m_Ires= "<<m_Ires<<endl;
191
192 getMaxEvent();
193 std::cout<<"m_evtMax = "<<m_evtMax<<std::endl;
194 DECLAREINT.seed=m_Int;
195 BABAYAGA(m_evtMax);
196
197 return StatusCode::SUCCESS;
198}
#define SWITCHARUN
Definition: Babayaga.cxx:82
#define EXPCUTS
Definition: Babayaga.cxx:67
#define BABAYAGA(NEVENTS)
Definition: Babayaga.cxx:132
#define DECLAREINT
Definition: Babayaga.cxx:103
#define DECLARESTR
Definition: Babayaga.cxx:110
#define SWITCH
Definition: Babayaga.cxx:75
#define CHANNEL
Definition: Babayaga.cxx:89
#define BEAMENERGY
Definition: Babayaga.cxx:59
#define RESONANCES
Definition: Babayaga.cxx:96
static void setRandomEngine(CLHEP::HepRandomEngine *randomEngine)
StatusCode getMaxEvent()
Definition: Babayaga.cxx:329
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: