Functions | Variables
client_test.C File Reference

Go to the source code of this file.

Functions

gROOT Reset ()
 
bool handshake (void)
 
void configure (string particle_list)
 
void request_xsec (string opt)
 
void request_event (string opt)
 
void shutdown (void)
 
void client_test ()
 

Variables

int port = 9090
 
TSocket * sock = 0
 

Function Documentation

void client_test ( )

Definition at line 20 of file client_test.C.

References ana::assert(), configure(), handshake(), request_event(), request_xsec(), and shutdown().

21 {
22  // handhake with genie event server
23  //
24  bool is_alive = handshake();
25  assert(is_alive);
26 
27  // configure genie event server
28  //
29  configure("load-splines neutrino-list=14,-14,12,-12 target-list=1000260560");
30 
31  // request total cross section data (sum for all enabled channels) for
32  // some initial state
33  //
34  request_xsec("14 1000260560");
35 
36  // request the generation of some events
37  //
38  request_event("14011011 1 14 1.849474 0.740705 53.184013 14 1000260560 0.012129 -0.941614 16.443062");
39  request_event("14011011 2 14 2.187474 0.362736 22.218212 14 1000260560 0.120932 0.239200 3.212121");
40  request_event("14011011 3 14 1.094340 0.127128 18.210291 14 1000260560 0.239001 -0.129101 8.029121");
41 
42  // shutdown the genie event server
43  //
44  shutdown();
45 }
void shutdown(void)
Definition: client_test.C:148
void request_event(string opt)
Definition: client_test.C:116
bool handshake(void)
Definition: client_test.C:47
void request_xsec(string opt)
Definition: client_test.C:86
assert(nhit_max >=nhit_nbins)
void configure(string particle_list)
Definition: client_test.C:65
void configure ( string  particle_list)

Definition at line 65 of file client_test.C.

References ana::assert(), run_hadd::cmd, om::cout, and allTimeWatchdog::endl.

Referenced by client_test().

66 {
67 // Sytnax:
68 // mesg sent:
69 // CONFIG: load-splines neutrino-list=comma_separated_list_of_pdg_codes target_list=comma_separated_list_of_pdg_codes
70 //
71  cout << "Configuring the GENIE event server" << endl;
72 
73  string cmd = "CONFIG: " + particle_list;
74 
75  sock->Send(cmd.c_str());
76  cout << "Sent: " << cmd << endl;
77 
78  char mesg[2048];
79  sock->Recv(mesg,2048);
80  cout << "Received: " << mesg << endl;
81 
82  bool is_configured = (strcmp(mesg,"CONFIG COMPLETED") == 0);
83  assert(is_configured);
84 }
TSocket * sock
Definition: client_test.C:11
string cmd
Definition: run_hadd.py:52
OStream cout
Definition: OStream.cxx:6
assert(nhit_max >=nhit_nbins)
bool handshake ( void  )

Definition at line 47 of file client_test.C.

References om::cout, and allTimeWatchdog::endl.

Referenced by client_test().

48 {
49  sock = new TSocket("localhost", port);
50  if(!sock) return false;
51 
52  cout << "Pinging the GENIE event server" << endl;
53 
54  sock->Send("RUB GENIE LAMP");
55  cout << "Sent: RUB GENIE LAMP" << endl;
56 
57  char mesg[2048];
58  sock->Recv(mesg,2048);
59  cout << "Received: " << mesg << endl;
60 
61  bool is_alive = (strcmp(mesg,"YOU HAVE 3 WISHES!") == 0);
62  return is_alive;
63 }
TSocket * sock
Definition: client_test.C:11
OStream cout
Definition: OStream.cxx:6
int port
Definition: client_test.C:9
void request_event ( string  opt)

Definition at line 116 of file client_test.C.

References run_hadd::cmd, om::cout, allTimeWatchdog::endl, and MECModelEnuComparisons::opt.

Referenced by client_test().

117 {
118 // Syntax:
119 // mesg sent:
120 // EVTVTX: irun ievt ipdgnunosoc vtx_x vtx_y vtx_z ipdgnu ipdgtgt px_nu py_nu pz_nu
121 // mesg recv:
122 // EVTREC: irun ievt ipdgnunosoc vtx_x vtx_y vtx_z
123 // ipdgnu ipdgtgt px_nu py_nu pz_nu
124 // int_type iaction nucleon struck-quark xbj_int ybj_int w2_int q2_int
125 // total-xsection diff-xsection ihadmod
126 // STDHEP: nlines
127 // indx ist ipdg jmo1 jmo2 jda1 jda2 px py pz E mass vx vy vz time
128 // ...
129 // indx ist ipdg jmo1 jmo2 jda1 jda2 px py pz E mass vx vy vz time
130 //
131  string cmd = "EVTVTX: " + opt;
132 
133  sock->Send(cmd.c_str());
134  cout << "Sent: " << cmd << endl;
135 
136  while(1) {
137  char mesg[2048];
138  sock->Recv(mesg,2048);
139  cout << "Received: " << mesg << endl;
140 
141  bool exit_loop = (strcmp(mesg,"FAILED")==0) ||
142  (strcmp(mesg,"EVENT GENERATED")==0);
143 
144  if(exit_loop) break;
145  }
146 }
TSocket * sock
Definition: client_test.C:11
string cmd
Definition: run_hadd.py:52
OStream cout
Definition: OStream.cxx:6
void request_xsec ( string  opt)

Definition at line 86 of file client_test.C.

References run_hadd::cmd, om::cout, allTimeWatchdog::endl, and MECModelEnuComparisons::opt.

Referenced by client_test().

87 {
88 // Syntax:
89 // mesg sent:
90 // XSEC: ipdgnu ipdgtgt
91 // mesg recv (E in GeV, Sig in 1E-38 cm^2):
92 // XSECSPL: npoints
93 // knot(0) E(0) Sig(0)
94 // knot(1) E(1) Sig(1)
95 // knot(2) E(2) Sig(2)
96 // ....
97 //
98 
99  string cmd = "XSEC: " + opt;
100 
101  sock->Send(cmd.c_str());
102  cout << "Sent: " << cmd << endl;
103 
104  while(1) {
105  char mesg[2048];
106  sock->Recv(mesg,2048);
107  cout << "Received: " << mesg << endl;
108 
109  bool exit_loop = (strcmp(mesg,"FAILED")==0) ||
110  (strcmp(mesg,"XSEC SENT")==0);
111 
112  if(exit_loop) break;
113  }
114 }
TSocket * sock
Definition: client_test.C:11
string cmd
Definition: run_hadd.py:52
OStream cout
Definition: OStream.cxx:6
gROOT Reset ( )

Definition at line 120 of file LIDTrainingDedx.cxx.

References slidt::fChain, slidt::hlongdedx, slidt::htransdedx, slidt::kNumEnergyBin, slidt::kNumLongitudinalPlane, slidt::kNumTransversePlane, and slidt::kNumXYRegion.

Referenced by osc::_PMNS< T >::_PMNS(), genie::AxialFormFactor::AxialFormFactor(), genie::QPMDISStrucFuncBase::CalcPDFs(), genie::ELFormFactors::Calculate(), genie::AxialFormFactor::Calculate(), genie::QELFormFactors::Calculate(), genie::DISStructureFunc::Calculate(), genie::DISStructureFunc::DISStructureFunc(), genie::ELFormFactors::ELFormFactors(), slidt::FillHists(), genie::FKR::FKR(), ana::Hist::GetEigenStan(), genie::flux::GSimpleNtpAux::GSimpleNtpAux(), genie::flux::GSimpleNtpEntry::GSimpleNtpEntry(), genie::flux::GSimpleNtpNuMI::GSimpleNtpNuMI(), genie::QELFormFactors::QELFormFactors(), genie::ELFormFactors::SetModel(), genie::AxialFormFactor::SetModel(), genie::QELFormFactors::SetModel(), genie::DISStructureFunc::SetModel(), beamlinereco::LEHitFinder< T >::SetWaveform(), beamlinereco::CFDHitFinder< T >::SetWaveform(), beamlinereco::ToFClusterAlg::ToFClusterAlg(), genie::flux::GJPARCNuFluxPassThroughInfo::~GJPARCNuFluxPassThroughInfo(), and rsim::PulseShaper::~PulseShaper().

121  {
122  for( int idet=0; idet < kNumXYRegion; ++idet){
123  for( int iebin=0; iebin < kNumEnergyBin; ++iebin){
124  for( int iplane=0; iplane < kNumTransversePlane; ++iplane){
125  htransdedx[idet][iebin][iplane]->Reset();
126  }
127  }
128  }
129  for( int idet=0; idet < kNumXYRegion; ++idet){
130  for( int iebin=0; iebin < kNumEnergyBin; ++iebin){
131  for( int iplane=0; iplane < kNumLongitudinalPlane; ++iplane){
132  hlongdedx[idet][iebin][iplane]->Reset();
133  }
134  }
135  }
136 
137  fChain->Reset();
138  }// Reset all histograms
TH1D * htransdedx[kNumXYRegion][kNumEnergyBin][kNumTransversePlane]
static const int kNumTransversePlane
Number of "transverse" planes considered for dE/dx histograms ("planes" transverse to shower axis)...
static const int kNumXYRegion
Number of XY regions into which detector is divided for dE/dx histograms.
TH1D * hlongdedx[kNumXYRegion][kNumEnergyBin][kNumLongitudinalPlane]
TChain * fChain
static const int kNumEnergyBin
Number of energy bins into which detector is divided for dE/dx histograms.
static const int kNumLongitudinalPlane
Number of longitudinal planes considered for dE/dx histograms.
void shutdown ( void  )

Definition at line 148 of file client_test.C.

References om::cout, and allTimeWatchdog::endl.

Referenced by client_test().

149 {
150  sock->Send("SHUTDOWN");
151  cout << "Sent: SHUTDOWN" << endl;
152 
153  char mesg[2048];
154  sock->Recv(mesg,2048);
155  cout << "Received: " << mesg << endl;
156 
157  sock->Close();
158 }
TSocket * sock
Definition: client_test.C:11
OStream cout
Definition: OStream.cxx:6

Variable Documentation

int port = 9090
TSocket* sock = 0

Definition at line 11 of file client_test.C.