54 using namespace genie;
77 int countfate [nfates];
78 double sigma [nfates];
79 double sigma_err [nfates];
80 string fatestr [nfates] =
" ";
93 for (
int k=0;
k<nfates;
k++) {
105 double kin_energy = 0.;
117 tree = dynamic_cast <TTree *> (
file.Get(
"gtree") );
118 ginuke = dynamic_cast <TTree *> (
file.Get(
"ginuke") );
130 tree->SetBranchAddress(
"gmcrec", &mcrec);
133 nev = (
int) tree->GetEntries();
135 <<
"Processing " << nev <<
" events";
141 for(
int ievent = 0; ievent < nev; ievent++) {
144 tree->GetEntry(ievent);
152 probe_pdg =
event.Particle(0)->Pdg();
153 target_pdg =
event.Particle(1)->Pdg();
159 if(ievent<displayno) {
167 case 0: countfate[0]++;
break;
168 case 1: countfate[1]++;
break;
169 case 2: countfate[2]++;
break;
170 case 3: countfate[3]++;
break;
171 case 4: countfate[4]++;
break;
172 case 5: countfate[5]++;
break;
173 case 6: countfate[6]++;
break;
174 case 13: countfate[8]++;
break;
176 if (7<=fate && fate<=12) countfate[7]++;
179 <<
"Undefined fate from FindhAFate() : " << fate;
193 <<
"Found ginuke type file";
195 nev = (
int) ginuke->GetEntries();
197 <<
"Processing " << nev <<
" events";
209 ginuke->SetBranchAddress(
"ke", &kin_energy);
210 ginuke->SetBranchAddress(
"probe",&probe_pdg );
211 ginuke->SetBranchAddress(
"tgt", &target_pdg);
212 ginuke->SetBranchAddress(
"nh", &numh );
213 ginuke->SetBranchAddress(
"npip", &numpip );
214 ginuke->SetBranchAddress(
"npi0", &numpi0 );
215 ginuke->SetBranchAddress(
"npim", &numpim );
216 ginuke->SetBranchAddress(
"pdgh", &pdg_had );
217 ginuke->SetBranchAddress(
"Eh", &E_had );
218 ginuke->SetBranchAddress(
"e", &energy );
221 for(
int ievent = 0; ievent < nev; ievent++) {
224 ginuke->GetEntry(ievent);
227 if (energy==E_had[0] && numh==1)
229 else if (energy!=E_had[0] && numh==1)
231 else if (
pdg::IsPion(probe_pdg) && numpip+numpi0+numpim==0)
233 else if ( (
pdg::IsNucleon(probe_pdg) && numpip+numpi0+numpim==0 && numh>2 )
234 || (probe_pdg==
kPdgGamma && energy!=E_had[0] && numpip+numpi0+numpim==0))
236 else if ( numpip+numpi0+numpim> (
pdg::IsPion(probe_pdg) ? 1 : 0) )
240 if ( (
pdg::IsPion(probe_pdg) && ( probe_pdg==pdg_had[0] || probe_pdg==pdg_had[1] ))
249 for (
int iter = 0; iter < numh; iter++)
251 if (probe_pdg==211 && pdg_had[iter]==-211) { index=8; undef=
false; }
252 else if (probe_pdg==-211 && pdg_had[iter]==211) { index=8; undef=
false; }
255 if (undef) { index=0; }
258 if (ievent<displayno) {
267 <<
"Could not read input file!";
276 const double dnev = (double) nev;
278 const double R0 = 1.4;
282 double nuclear_radius = NR * R0 * TMath::Power(A, 1./3.);
283 double area = TMath::Pi() * TMath::Power(nuclear_radius,2);
286 string probe_name = pdglib->
Find(probe_pdg)->GetName();
287 string target_name = pdglib->
Find(target_pdg)->GetName();
290 <<
" Probe = " << probe_name
291 <<
", KE = " << kin_energy <<
" GeV";
293 <<
" Target = " << target_name
294 <<
" (Z,A) = (" << Z <<
", " << A
295 <<
"), nuclear radius = " << nuclear_radius
296 <<
" fm, area = " << area <<
" fm**2 " <<
'\n';
299 int nullint = countfate[1];
301 double sigtoterr = 0;
302 double sigtotScat = 0;
303 double sigtotAbs = 0;
305 for(
int k=0;
k<nfates;
k++) {
307 cnttot += countfate[
k];
308 double ratio = countfate[
k]/dnev;
309 sigma[
k] = fm2tomb * area *
ratio;
310 sigma_err[
k] = fm2tomb * area * TMath::Sqrt(ratio*(1-ratio)/dnev);
311 if(sigma_err[
k]==0) {
312 sigma_err[
k] = fm2tomb * area * TMath::Sqrt(countfate[
k])/dnev;
316 <<
" --> " <<
setw(26) << fatestr[
k]
317 <<
": " <<
setw(7) << countfate[
k] <<
" events -> " 318 <<
setw(7) << sigma[
k] <<
" +- " << sigma_err[
k] <<
" (mb)" <<
'\n';
321 sigtotAbs += sigma[
k];
325 sigtotScat += sigma[
k];
330 sigtot = fm2tomb * area * cnttot/dnev;
331 sigtoterr = fm2tomb * area * TMath::Sqrt(cnttot)/dnev;
333 double sigtot_noelas = fm2tomb * area * (cnttot-countfate[3])/dnev;
334 double sigtoterr_noelas = fm2tomb * area * TMath::Sqrt(cnttot-countfate[3])/dnev;
336 double ratio_as = (sigtotScat==0) ? 0 : sigtotAbs/(
double)sigtotScat;
339 <<
"\n\n --------------------------------------------------- " 340 <<
"\n ==> " <<
setw(28) <<
" Total: " <<
setw(7) << cnttot
341 <<
" events -> " <<
setw(7) << sigtot <<
" +- " << sigtoterr <<
" (mb)" 342 <<
"\n (-> " <<
setw(28) <<
" Hadrons escaped nucleus: " 343 <<
setw(7) << nullint <<
" events)" 344 <<
"\n ==> " <<
setw(28) <<
" Ratio (abs/scat) = " 345 <<
setw(7) << ratio_as
346 <<
"\n ==> " <<
setw(28) <<
" avg. num of int. = " 347 <<
setw(7) << cnttot/dnev
348 <<
"\n ==> " <<
setw(28) <<
" no interaction = " 349 <<
setw(7) << (dnev-cnttot)/dnev
350 <<
"\n ------------------------------------------------------- \n";
357 file_exists=test_file.is_open();
363 xsec_file <<
"#KE" <<
"\t" <<
"Undef" <<
"\t" 364 <<
"sig" <<
"\t" <<
"CEx" <<
"\t" 365 <<
"sig" <<
"\t" <<
"Elas" <<
"\t" 366 <<
"sig" <<
"\t" <<
"Inelas"<<
"\t" 367 <<
"sig" <<
"\t" <<
"Abs" <<
"\t" 368 <<
"sig" <<
"\t" <<
"KO" <<
"\t" 369 <<
"sig" <<
"\t" <<
"PiPro" <<
"\t" 370 <<
"sig" <<
"\t" <<
"DCEx" <<
"\t" 371 <<
"sig" <<
"\t" <<
"Reac" <<
"\t" 372 <<
"sig" <<
"\t" <<
"Tot" <<
"\t" <<
"sig" <<
endl;
374 xsec_file << kin_energy;
375 for(
int k=0;
k<nfates;
k++) {
377 xsec_file <<
"\t" << sigma[
k] <<
"\t" << sigma_err[
k];
379 xsec_file <<
"\t" << sigtot_noelas <<
"\t" << sigtoterr_noelas;
380 xsec_file <<
"\t" << sigtot <<
"\t" << sigtoterr <<
endl;
394 double p_pdg = evrec->
Probe()->
Pdg();
399 int num[] = {0,0,0,0,0,0,0,0,0};
405 double numKE[] = {0,0,0,0,0,0,0,0,0};
409 bool hasBlob =
false;
413 TObjArrayIter piter(evrec);
422 switch((
int) p->
Pdg())
426 case ((
int)
kPdgPiP) : index = 2;
break;
427 case ((
int)
kPdgPiM) : index = 3;
break;
428 case ((
int)
kPdgPi0) : index = 4;
break;
429 case ((
int)
kPdgKP) : index = 5;
break;
430 case ((
int)
kPdgKM) : index = 6;
break;
431 case ((
int)
kPdgK0) : index = 7;
break;
432 case ((
int)
kPdgGamma) : index = 8;
break;
433 case (2000000002) : index = 9; hasBlob=
true;
break;
434 default: index = 9;
break;
439 if(numFsPart==0) fs=
p;
449 double dE = TMath::Abs( probe->
E() - fs->
E() );
450 double dPz = TMath::Abs( probe->
Pz() - fs->
Pz() );
451 double dPy = TMath::Abs( probe->
Py() - fs->
Py() );
452 double dPx = TMath::Abs( probe->
Px() - fs->
Px() );
457 num_t = num[0]+num[1]+num[2]+num[3]+num[4]+num[5]+num[6]+num[7];
458 num_nu = num[0]+num[1];
459 num_pi = num[2]+num[3]+num[4];
460 num_k = num[5]+num[6]+num[7];
474 if (num[0]==1 && num[1]==1)
return kIHAFtAbs;
475 else if(num[0]==2 && num[1]==0)
return kIHAFtAbs;
476 else if(num[0]==2 && num[1]==1)
return kIHAFtAbs;
477 else if(num[0]==1 && num[1]==2)
return kIHAFtAbs;
478 else if(num[0]==2 && num[1]==2)
return kIHAFtAbs;
479 else if(num[0]==3 && num[1]==2)
return kIHAFtAbs;
492 if (num[2]==1) { fs_pdg=
kPdgPiP; fs_ind=2; }
493 else if(num[3]==1) { fs_pdg=
kPdgPiM; fs_ind=3; }
494 else if(num[4]==1) { fs_pdg=
kPdgPi0; fs_ind=4; }
495 else if(num[5]==1) { fs_pdg=
kPdgKP; fs_ind=5; }
496 else if(num[6]==1) { fs_pdg=
kPdgKM; fs_ind=6; }
497 else { fs_pdg=
kPdgK0; fs_ind=7; }
505 ((fs_ind==2 || fs_ind==3) && p_pdg==
kPdgPi0))
509 else if(((p_pdg==
kPdgKP || p_pdg==
kPdgKM) && fs_ind==7) ||
510 ((fs_ind==5 || fs_ind==6) && p_pdg==
kPdgK0))
514 else if((p_pdg==
kPdgPiP && fs_ind==3) ||
519 else if((p_pdg==
kPdgKP && fs_ind==6) ||
520 (p_pdg==
kPdgKM &&fs_ind==5))
528 if(num[0]>=1) { fs_ind=0; }
538 if(numKE[1]>numKE[0]) { fs_ind=1; }
540 if(numtype[fs_ind]==p_pdg)
568 if (num[0]==2 && num[1]==1)
return kIHAFtKo;
569 else if(num[0]==1 && num[1]==2)
return kIHAFtKo;
570 else if(num[0]==2 && num[1]==2)
return kIHAFtKo;
571 else if(num[0]==3 && num[1]==2)
return kIHAFtKo;
579 if (num[5]==1) fs_ind=5;
580 else if (num[6]==1) fs_ind=6;
583 if(numKE[fs_ind]>=(.8*p_KE))
return kIHAFtElas;
586 else if (p_pdg==kPdgGamma)
588 if (num[0]==2 && num[1]==1)
return kIHAFtKo;
589 else if(num[0]==1 && num[1]==2)
return kIHAFtKo;
590 else if(num[0]==2 && num[1]==2)
return kIHAFtKo;
591 else if(num[0]==3 && num[1]==2)
return kIHAFtKo;
597 LOG(
"Intranuke",
pWARN) <<
"---> *** Undefined fate! ***" <<
"\n" << (*evrec);
603 LOG(
"gtestINukeHadroXSec",
pNOTICE) <<
"Parsing command line arguments";
609 LOG(
"gtestINukeHadroXSec",
pINFO) <<
"Reading input filename";
613 <<
"Unspecified input filename - Exiting";
619 LOG(
"gtestINukeHadroXSec",
pINFO) <<
"Reading output filename";
632 <<
" gtestINukeHadroXSec -f event_file [-w]"
virtual GHepParticle * Particle(int position) const
void GetCommandLineArgs(int argc, char **argv)
string ArgAsString(char opt)
THE MAIN GENIE PROJECT NAMESPACE
MINOS-style ntuple record. Each such ntuple record holds a generated EventRecord object. Ntuples of this type are intended for feeding GENIE events into other applications (for example the GEANT4 based MC generation framework of an experiment) if no direct interface exists.
int IonPdgCodeToA(int pdgc)
static constexpr double fs
double Pz(void) const
Get Pz.
GHepStatus_t Status(void) const
double Px(void) const
Get Px.
virtual GHepParticle * Probe(void) const
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
string gOptInpFilename
input event file
bool gOptWriteOutput
write out hadron cross sections
static constexpr double mb
static constexpr double fm2
int main(int argc, char **argv)
Q_EXPORT QTSManip setw(int w)
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
string gOptOutputFilename
double KinE(bool mass_from_pdg=false) const
Get kinetic energy.
static PDGLibrary * Instance(void)
Singleton class to load & serve a TDatabasePDG.
static string AsString(INukeFateHN_t fate)
int IonPdgCodeToZ(int pdgc)
bool file_exists(std::string const &qualified_filename)
TParticlePDG * Find(int pdgc, bool must_exist=true)
Command line argument parser.
void Clear(Option_t *opt="")
INukeFateHA_t FindhAFate(const GHepRecord *evrec)
GENIE's GHEP MC event record.
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
Q_EXPORT QTSManip setfill(int f)
STDHEP-like event record entry that can fit a particle or a nucleus.
bool OptionExists(char opt)
was option set?
enum genie::EINukeFateHA_t INukeFateHA_t
QTextStream & endl(QTextStream &s)
enum genie::EGHepStatus GHepStatus_t
double Py(void) const
Get Py.