33 #include <TServerSocket.h> 40 #include "EVGCore/EventRecord.h" 41 #include "EVGDrivers/GEVGDriver.h" 42 #include "EVGDrivers/GEVGPool.h" 43 #include "EVGDrivers/GMCJMonitor.h" 50 #include "PDG/PDGCodeList.h" 57 using std::ostringstream;
59 using namespace genie;
95 const string kErrNoEvent =
"*** NULL OR UNPHYSICAL EVENT! ***";
96 const string kErr =
"FAILED";
119 TServerSocket * serv_sock =
new TServerSocket(
gOptPortNum, kTRUE);
122 gSock = serv_sock->Accept();
128 int delay_ok =
gSock->SetOption(kNoDelay,1);
129 LOG(
"gevserv",
pNOTICE) <<
"TCP_NODELAY > " << delay_ok;
142 if(mesg->What() != kMESS_STRING)
continue;
144 char mesg_content[2048];
145 mesg->ReadString(mesg_content, 2048);
147 LOG(
"gevserv",
pNOTICE) <<
"Processing mesg > " << mesg_content;
189 <<
"GENIE was pinged by a client (lamp was rubbed)! Responding...";
193 LOG(
"gevserv",
pINFO) <<
"...done!";
216 LOG(
"gevserv",
pNOTICE) <<
"Configuring GENIE event server";
222 LOG(
"gevserv",
pNOTICE) <<
"Configure options: " << mesg;
237 bool allowdup =
false;
241 vector<string> conf_opt_v =
str::Split(mesg,
" ");
244 for( ; conf_opt_iter != conf_opt_v.end(); ++conf_opt_iter) {
245 string conf_opt = *conf_opt_iter;
247 <<
"Processing config option: " << conf_opt;
249 vector<string> sv =
str::Split(conf_opt,
"=");
250 assert(sv.size()==2);
251 string list_name = sv[0];
252 string particle_list = sv[1];
254 vector<string> particles =
str::Split(particle_list,
",");
257 for( ; particle_iter != particles.end(); ++particle_iter) {
258 string particle_code_str = *particle_iter;
259 int particle_code = atoi(particle_code_str.c_str());
273 <<
"Specified neutrino list: " << neutrinos;
275 <<
"Specified target list: " << targets;
284 for(nuiter = neutrinos.begin(); nuiter != neutrinos.end(); ++nuiter) {
285 for(tgtiter = targets.begin(); tgtiter != targets.end(); ++tgtiter) {
287 int target_code = *tgtiter;
288 int neutrino_code = *nuiter;
293 <<
"\n\n ---- Creating a GEVGDriver object configured for init-state: " 294 << init_state.
AsString() <<
" ----\n\n";
300 gGPool.insert( GEVGPool::value_type(init_state.
AsString(), evgdriver) );
306 <<
"All necessary GEVGDriver object were pushed into GEVGPool\n";
312 LOG(
"gevserv",
pINFO) <<
"...done!";
318 <<
"Sending total xsec for enabled channels - Input info : " << mesg;
322 <<
"Event server is not configured - Can not generate event";
335 assert(sv.size()==2);
337 int ipdgnu = atoi(sv[0].c_str());
338 int ipdgtgt = atoi(sv[1].c_str());
346 <<
"No GEVGDriver object for init state: " << init_state.
AsString();
356 <<
"Requesting total cross section for init state: " 360 1000 , 0.001 , 300 ,
true );
363 assert(total_xsec_spl);
369 double Emax = 200.010;
370 int np = (
int) TMath::Ceil((Emax-Emin)/dE);
372 ostringstream xsec_hdr;
374 gSock->Send(xsec_hdr.str().c_str());
376 for(
int ip=0; ip<np; ip++) {
377 double E = Emin + ip*dE;
380 ostringstream xsec_spl_knot;
381 xsec_spl_knot << ip <<
" " << E <<
" " << Form(
"%15.8e",xs);
382 gSock->Send(xsec_spl_knot.str().c_str());
387 LOG(
"gevserv",
pINFO) <<
"...done!";
392 LOG(
"gevserv",
pNOTICE) <<
"Generating event - Input info : " << mesg;
396 <<
"Event server is not configured - Can not generate event";
410 assert(sv.size()==11);
411 int irun = atoi(sv[0].c_str());
412 int ievt = atoi(sv[1].c_str());
413 int ipdgnunoosc = atoi(sv[2].c_str());
414 double vtxx = atof(sv[3].c_str());
415 double vtxy = atof(sv[4].c_str());
416 double vtxz = atof(sv[5].c_str());
417 int ipdgnu = atoi(sv[6].c_str());
418 int ipdgtgt = atoi(sv[7].c_str());
419 double px = atof(sv[8].c_str());
420 double py = atof(sv[9].c_str());
421 double pz = atof(sv[10].c_str());
422 double E = TMath::Sqrt(px*px + py*py + pz*pz);
424 TLorentzVector p4(px,py,pz,E);
432 <<
"No GEVGDriver object for init state: " << init_state.
AsString();
443 bool failed = (
event==0) ||
event->IsUnphysical();
446 <<
"Failed to generate the requested event";
461 else if (proc_info.
IsResonant()) int_type = 2;
463 else if (proc_info.IsCoherent()) int_type = 4;
468 if (proc_info.
IsWeakNC()) iaction = 0;
469 else if (proc_info.
IsWeakCC()) iaction = 1;
475 nucleon = hitnucl->
Pdg();
480 bool get_selected =
true;
481 double xbj_sel = kine.
x (get_selected);
482 double y_sel = kine.
y (get_selected);
483 double W2_sel = TMath::Power(kine.
W (get_selected), 2.);
484 double q2_sel = -1 * kine.
Q2(get_selected);
486 double tot_xsec =
event->XSec();
487 double diff_xsec =
event->DiffXSec();
493 ostringstream hdr1, hdr2, hdr3, hdr4, stdhep_hdr;
499 << ipdgnunoosc <<
" " 525 <<
event->GetEntriesFast();
527 gSock->Send(hdr1.str().c_str());
528 gSock->Send(hdr2.str().c_str());
529 gSock->Send(hdr3.str().c_str());
530 gSock->Send(hdr4.str().c_str());
531 gSock->Send(stdhep_hdr.str().c_str());
534 TIter event_iter(
event);
536 while ( (p = dynamic_cast<GHepParticle *>(event_iter.Next())) ) {
538 ostringstream stdhep_entry;
541 << i <<
" " << p->
Status() <<
" " << p->
Pdg() <<
" " 544 << p->
Px() <<
" " << p->
Py() <<
" " << p->
Pz() <<
" " << p->
E() <<
" " 546 << p->
Vx() <<
" " << p->
Vy() <<
" " << p->
Vz() <<
" " << p->
Vt();
548 gSock->Send(stdhep_entry.str().c_str());
558 LOG(
"gevserv",
pINFO) <<
"...done!";
563 LOG(
"gevserv",
pNOTICE) <<
"Shutting GENIE event server down ...";
569 LOG(
"gevserv",
pINFO) <<
"...done!";
574 if(gSystem->Getenv(
"GSPLOAD")) {
575 string splines_filename = gSystem->Getenv(
"GSPLOAD");
576 bool is_accessible = ! (gSystem->AccessPathName( splines_filename.c_str() ));
577 if (!is_accessible) {
579 <<
"*** The file (" << splines_filename
580 <<
") specified in $GSPLOAD doesn't seem to be available!";
582 <<
"*** Expect a significant start-up overhead!";
585 LOG(
"gevserv",
pWARN) <<
"*** $GSPLOAD was not set!";
586 LOG(
"gevserv",
pWARN) <<
"*** Expect a significant start-up overhead!";
592 LOG(
"gevserv",
pNOTICE) <<
"Parsing command line arguments";
598 LOG(
"gevserv",
pINFO) <<
"Reading port number";
602 <<
"Unspecified port number - Using default (" <<
kDefPortNum <<
")";
610 <<
"\n\n" <<
"Syntax:" <<
"\n" 611 <<
" gevserv [-p port] \n";
bool IsResonant(void) const
double W(bool selected=false) const
void CreateXSecSumSpline(int nk, double Emin, double Emax, bool inlogE=true)
const string kXSecCmdSent
bool IsWeakCC(void) const
THE MAIN GENIE PROJECT NAMESPACE
double E(void) const
Get energy.
const string kConfigCmdRecv
int FirstDaughter(void) const
int HitQrkPdg(void) const
bool IsInverseMuDecay(void) const
bool IsQuasiElastic(void) const
A numeric analysis tool class for interpolating 1-D functions.
Generated/set kinematical variables for an event.
double x(bool selected=false) const
double Mass(void) const
Mass that corresponds to the PDG code.
const Spline * XSecSumSpline(void) const
GEVGDriver * FindDriver(const InitialState &init) const
static XSecSplineList * Instance()
const string kEvgenHdrCmdSent
double Evaluate(double x) const
double Pz(void) const
Get Pz.
GHepStatus_t Status(void) const
double Px(void) const
Get Px.
double y(bool selected=false) const
int LastMother(void) const
double Vt(void) const
Get production time.
int FirstMother(void) const
void GenerateEvent(string mesg)
Summary information for an interaction.
int LastDaughter(void) const
const string kShutdownCmdRecv
const string kXSecCmdRecv
const string kConfigCmdTgtList
bool IsWeakNC(void) const
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
bool IsNuElectronElastic(void) const
static constexpr double cm2
A class encapsulating an enumeration of interaction types (EM, Weak-CC, Weak-NC) and scattering types...
const string kEvgenStdhepCmdSent
const Kinematics & Kine(void) const
string AsString(void) const
GENIE Event Generation Driver. A minimalist user interface object for generating neutrino interaction...
const string kConfigCmdLdSpl
string TrimSpaces(string input)
const string kShutdownOkMesgSent
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
bool IsDeepInelastic(void) const
const string kConfigOkMesgSent
const string kEvgenCmdRecv
const string kEvgenOkMesgSent
string FilterString(string filt, string input)
void HandleMesg(string mesg)
vector< string > Split(string input, string delim)
const string kHandshakeMesgSent
double Vz(void) const
Get production z.
void CalcTotalXSec(string mesg)
void Configure(string mesg)
void Configure(int nu_pdgc, int Z, int A)
int main(int argc, char **argv)
const InitialState & InitState(void) const
const string kErrNoDriver
const ProcessInfo & ProcInfo(void) const
double Vy(void) const
Get production y.
Command line argument parser.
double Q2(bool selected=false) const
const Target & Tgt(void) const
const string kConfigCmdNeuList
List of cross section vs energy splines.
void GetCommandLineArgs(int argc, char **argv)
STDHEP-like event record entry that can fit a particle or a nucleus.
bool OptionExists(char opt)
was option set?
Root of GENIE utility namespaces.
const string kHandshakeCmdRecv
void push_back(int pdg_code)
Event finding and building.
const string kXSecOkMesgSent
double Vx(void) const
Get production x.
Initial State information.
EventRecord * GenerateEvent(const TLorentzVector &nu4p)
A pool of GEVGDriver objects with an initial state key.
double Py(void) const
Get Py.