36 #include <TDirectory.h>
39 #include <TLorentzVector.h>
41 #include <TClonesArray.h>
42 #include <TIterator.h>
46 #include "Physics/Hadronization/HadronizationModelI.h"
56 #include "Physics/Hadronization/FragmRecUtils.h"
62 using std::ostringstream;
64 using namespace genie;
66 extern "C" void pysphe_(
double *,
double *);
67 extern "C" void pythru_(
double *,
double *);
73 int * QrkCode,
bool * SeaQrk,
int nmax,
int & nqrk);
81 int main(
int argc,
char ** argv)
87 const HadronizationModelI * model =
88 dynamic_cast<const HadronizationModelI *
> (
92 gOutFile =
new TFile(
"./genie-hadronization.root",
"recreate");
94 const int npmax = 100;
110 const int kNQrkMax = 4;
113 int CcNc[kCcNc] = { 1 };
117 double W[kNW] = { 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 4.0, 6.0, 8.0, 10.0, 15.0, 20.0 };
119 int QrkCode[kNQrkMax];
120 bool SeaQrk [kNQrkMax];
124 TTree * hadnt =
new TTree(
"hadnt",
"hadronizer multiplicities");
162 hadnt->Branch(
"iev", &br_iev,
"iev/I");
163 hadnt->Branch(
"nuc", &br_nuc,
"nuc/I");
164 hadnt->Branch(
"neut", &br_neut,
"neut/I");
165 hadnt->Branch(
"qrk", &br_qrk,
"qrk/I");
166 hadnt->Branch(
"sea", &br_sea,
"sea/I");
167 hadnt->Branch(
"ccnc", &br_ccnc,
"ccnc/I");
168 hadnt->Branch(
"W", &br_W,
"W/F");
169 hadnt->Branch(
"np", &br_np,
"np/I");
170 hadnt->Branch(
"nn", &br_nn,
"nn/I");
171 hadnt->Branch(
"npip", &br_npip,
"npip/I");
172 hadnt->Branch(
"npim", &br_npim,
"npim/I");
173 hadnt->Branch(
"npi0", &br_npi0,
"npi0/I");
174 hadnt->Branch(
"nKp", &br_nKp,
"nKp/I");
175 hadnt->Branch(
"nKm", &br_nKm,
"nKm/I");
176 hadnt->Branch(
"nK0", &br_nK0,
"nK0/I");
177 hadnt->Branch(
"n", &br_n,
"n/I");
178 hadnt->Branch(
"jmod", &br_model,
"jmod/I");
179 hadnt->Branch(
"nstrst",&br_nstrst,
"nstrst/I");
180 hadnt->Branch(
"sph", &br_sphericity,
"sph/F");
181 hadnt->Branch(
"apl", &br_aplanarity,
"apl/F");
182 hadnt->Branch(
"thr", &br_thrust,
"thr/F");
183 hadnt->Branch(
"obl", &br_oblateness,
"obl/F");
184 hadnt->Branch(
"pdg", br_pdg,
"pdg[n]/I");
185 hadnt->Branch(
"ist", br_ist,
"ist[n]/I");
186 hadnt->Branch(
"dec", br_dec,
"dec[n]/I");
187 hadnt->Branch(
"px", br_px,
"px[n]/F");
188 hadnt->Branch(
"py", br_py,
"py[n]/F");
189 hadnt->Branch(
"pz", br_pz,
"pz[n]/F");
190 hadnt->Branch(
"KE", br_KE,
"KE[n]/F");
191 hadnt->Branch(
"E", br_E,
"E[n]/F");
192 hadnt->Branch(
"M", br_M,
"M[n]/F");
193 hadnt->Branch(
"pL", br_pL,
"pL[n]/F");
194 hadnt->Branch(
"pT2", br_pT2,
"pT2[n]/F");
195 hadnt->Branch(
"xF", br_xF,
"xF[n]/F");
196 hadnt->Branch(
"z", br_z,
"z[n]/F");
198 const int nnull_max=100;
202 for(
int iccnc=0; iccnc<kCcNc; iccnc++) {
206 for(
int inu=0; inu<kNNu; inu++) {
207 for(
int inuc=0; inuc<kNNuc; inuc++) {
218 FillQrkArray(it, NuCode[inu], QrkCode, SeaQrk, kNQrkMax, nqrk);
220 for(
int iqrk=0; iqrk<nqrk; iqrk++) {
228 for(
int iw=0; iw<kNW; iw++) {
232 TClonesArray * plist = model->Hadronize(&intr);
238 if(nnull>nnull_max) exit(1);
242 utils::fragmrec::Print(plist);
245 br_nuc = NucCode[inuc];
246 br_neut = NuCode[inu];
249 br_ccnc = CcNc[iccnc];
251 br_np = utils::fragmrec::NParticles(
kPdgProton, plist);
252 br_nn = utils::fragmrec::NParticles(
kPdgNeutron, plist);
253 br_npip = utils::fragmrec::NParticles(
kPdgPiP, plist);
254 br_npim = utils::fragmrec::NParticles(
kPdgPiM, plist);
255 br_npi0 = utils::fragmrec::NParticles(
kPdgPi0, plist);
256 br_nKp = utils::fragmrec::NParticles(
kPdgKP, plist);
257 br_nKm = utils::fragmrec::NParticles(
kPdgKM, plist);
258 br_nK0 = utils::fragmrec::NParticles(
kPdgK0, plist);
259 br_n = plist->GetEntries();
265 TIter particle_iter(plist);
268 unsigned int daughter1=0, daughter2=0;
269 bool model_set=
false;
271 while( (particle = (
GHepParticle *) particle_iter.Next()) ) {
272 br_pdg[i] = particle->
Pdg();
273 br_ist[i] = particle->
Status();
274 br_px[i] = particle->
Px();
275 br_py[i] = particle->
Py();
276 br_pz[i] = particle->
Pz();
277 br_KE[i] = particle->
Energy() - particle->
Mass();
278 br_E[i] = particle->
Energy();
279 br_M[i] = particle->
Mass();
280 br_pL[i] = particle->
Pz();
281 br_pT2[i] = TMath::Power(particle->
Px(),2) +
282 TMath::Power(particle->
Py(),2);
283 br_xF[i] = particle->
Pz() / (W[iw]/2);
284 br_z[i] = particle->
Energy() / W[iw];
287 if(model_set) exit(1);
289 if (particle->KF() ==
kPdgString ) br_model=1;
290 else if (particle->KF() ==
kPdgCluster) br_model=2;
291 else if (particle->KF() ==
kPdgIndep ) br_model=3;
295 br_nstrst = daughter2-daughter1+1;
299 if(i>=daughter1 && i<=daughter2) br_dec[i] = 1;
308 double sph=0, apl=0, thr=0, obl=0;
312 LOG(
"test",
pINFO) <<
"Sphericity = " << sph <<
", aplanarity = " << apl;
331 hadnt->Write(
"hadnt");
339 int * QrkCode,
bool * SeaQrk,
int nmax,
int & nqrk)
344 for(
int i=0; i<nmax; i++) {
379 if( parser.OptionExists(
'n') ) {
380 LOG(
"test",
pINFO) <<
"Reading number of events to generate";
383 LOG(
"test",
pFATAL) <<
"Number of events was not specified";
389 if( parser.OptionExists(
'a') ) {
390 LOG(
"test",
pINFO) <<
"Reading hadronization algorithm name";
391 gHadAlg = parser.ArgAsString(
'a');
393 LOG(
"test",
pINFO) <<
"No hadronization algorithm was specified";
399 if( parser.OptionExists(
'c') ) {
400 LOG(
"test",
pINFO) <<
"Reading hadronization algorithm config name";
403 LOG(
"test",
pINFO) <<
"No hadronization algorithm config was specified";
409 if( parser.OptionExists(
'q') ) {
410 LOG(
"test",
pINFO) <<
"reading struck quark option";
413 LOG(
"test",
pINFO) <<
"Using default option for setting hit quark";
421 <<
"\n\n" <<
"Syntax:" <<
"\n"
422 <<
" testHadronization -n nevents -a hadronizer -c config [-q]\n";
bool IsNeutrino(int pdgc)
Kinematics * KinePtr(void) const
int FirstDaughter(void) const
void pysphe_(double *, double *)
void SetHitQrkPdg(int pdgc)
double Mass(void) const
Mass that corresponds to the PDG code.
double Pz(void) const
Get Pz.
string AsString(void) const
GHepStatus_t Status(void) const
double Energy(void) const
Get energy.
int main(int argc, char **argv)
double Px(void) const
Get Px.
double W(const Interaction *const i)
Summary information for an interaction.
int LastDaughter(void) const
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
A class encapsulating an enumeration of interaction types (EM, Weak-CC, Weak-NC) and scattering types...
bool IsAntiNeutrino(int pdgc)
const Algorithm * GetAlgorithm(const AlgId &algid)
void SetW(double W, bool selected=false)
static AlgFactory * Instance()
void SetHitNucPdg(int pdgc)
Target * TgtPtr(void) const
InitialState * InitStatePtr(void) const
Command line argument parser.
void GetCommandLineArgs(int argc, char **argv)
The GENIE Algorithm Factory.
void SetHitSeaQrk(bool tf)
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
enum genie::EInteractionType InteractionType_t
STDHEP-like event record entry that can fit a particle or a nucleus.
void pythru_(double *, double *)
string gOutFile
output XML file
void FillQrkArray(InteractionType_t it, int nu, int *QrkCode, bool *SeaQrk, int nmax, int &nqrk)
Initial State information.
double Py(void) const
Get Py.