128 #include "libxml/parser.h"
129 #include "libxml/xmlmemory.h"
136 #include <TObjString.h>
140 #include "Framework/Conventions/GBuild.h"
162 #ifdef __GENIE_FLUX_DRIVERS_ENABLED__
167 #ifdef __GENIE_HEAVY_NEUTRAL_LEPTON_ENABLED__
174 using std::ostringstream;
178 using std::setprecision;
181 using std::setiosflags;
184 using namespace genie;
185 using namespace genie::constants;
200 int HAProbeFSI (
int,
int,
int,
double [],
int [],
int,
int,
int);
201 #ifdef __GENIE_HEAVY_NEUTRAL_LEPTON_ENABLED__
202 void DeclareHNLBranches (TTree * tree, TTree * intree,
203 double * dVars,
int * iVars);
204 #endif // #ifdef __GENIE_HEAVY_NEUTRAL_LEPTON_ENABLED__
238 int main(
int argc,
char ** argv)
306 const double e_h = 1.3;
312 int brFSPrimLept = 0;
318 bool brFromSea =
false;
320 bool brIsQel =
false;
321 bool brIsRes =
false;
322 bool brIsDis =
false;
323 bool brIsCoh =
false;
324 bool brIsMec =
false;
325 bool brIsDfr =
false;
326 bool brIsImd =
false;
327 bool brIsNrm =
false;
328 bool brIsSingleK =
false;
329 bool brIsImdAnh =
false;
330 bool brIsNuEL =
false;
334 bool brIsCharmPro =
false;
335 bool brIsAMNuGamma =
false;
336 bool brIsHNL =
false;
338 int brCodeNuance = 0;
343 double brKineQ2s = 0;
421 TTree * s_tree =
new TTree(
"gst",
"GENIE Summary Event Tree");
425 s_tree->Branch(
"iev", &brIev,
"iev/I" );
426 s_tree->Branch(
"neu", &brNeutrino,
"neu/I" );
427 s_tree->Branch(
"fspl", &brFSPrimLept,
"fspl/I" );
428 s_tree->Branch(
"tgt", &brTarget,
"tgt/I" );
429 s_tree->Branch(
"Z", &brTargetZ,
"Z/I" );
430 s_tree->Branch(
"A", &brTargetA,
"A/I" );
431 s_tree->Branch(
"hitnuc", &brHitNuc,
"hitnuc/I" );
432 s_tree->Branch(
"hitqrk", &brHitQrk,
"hitqrk/I" );
433 s_tree->Branch(
"resid", &brResId,
"resid/I" );
434 s_tree->Branch(
"sea", &brFromSea,
"sea/O" );
435 s_tree->Branch(
"qel", &brIsQel,
"qel/O" );
436 s_tree->Branch(
"mec", &brIsMec,
"mec/O" );
437 s_tree->Branch(
"res", &brIsRes,
"res/O" );
438 s_tree->Branch(
"dis", &brIsDis,
"dis/O" );
439 s_tree->Branch(
"coh", &brIsCoh,
"coh/O" );
440 s_tree->Branch(
"dfr", &brIsDfr,
"dfr/O" );
441 s_tree->Branch(
"imd", &brIsImd,
"imd/O" );
442 s_tree->Branch(
"norm", &brIsNrm,
"norm/O" );
443 s_tree->Branch(
"imdanh", &brIsImdAnh,
"imdanh/O" );
444 s_tree->Branch(
"singlek", &brIsSingleK,
"singlek/O" );
445 s_tree->Branch(
"nuel", &brIsNuEL,
"nuel/O" );
446 s_tree->Branch(
"em", &brIsEM,
"em/O" );
447 s_tree->Branch(
"cc", &brIsCC,
"cc/O" );
448 s_tree->Branch(
"nc", &brIsNC,
"nc/O" );
449 s_tree->Branch(
"charm", &brIsCharmPro,
"charm/O" );
450 s_tree->Branch(
"amnugamma", &brIsAMNuGamma,
"amnugamma/O" );
451 s_tree->Branch(
"hnl", &brIsHNL,
"hnl/O" );
452 s_tree->Branch(
"neut_code", &brCodeNeut,
"neut_code/I" );
453 s_tree->Branch(
"nuance_code", &brCodeNuance,
"nuance_code/I" );
454 s_tree->Branch(
"wght", &brWeight,
"wght/D" );
455 s_tree->Branch(
"xs", &brKineXs,
"xs/D" );
456 s_tree->Branch(
"ys", &brKineYs,
"ys/D" );
457 s_tree->Branch(
"ts", &brKineTs,
"ts/D" );
458 s_tree->Branch(
"Q2s", &brKineQ2s,
"Q2s/D" );
459 s_tree->Branch(
"Ws", &brKineWs,
"Ws/D" );
460 s_tree->Branch(
"x", &brKineX,
"x/D" );
461 s_tree->Branch(
"y", &brKineY,
"y/D" );
462 s_tree->Branch(
"t", &brKineT,
"t/D" );
463 s_tree->Branch(
"Q2", &brKineQ2,
"Q2/D" );
464 s_tree->Branch(
"W", &brKineW,
"W/D" );
465 s_tree->Branch(
"EvRF", &brEvRF,
"EvRF/D" );
466 s_tree->Branch(
"Ev", &brEv,
"Ev/D" );
467 s_tree->Branch(
"pxv", &brPxv,
"pxv/D" );
468 s_tree->Branch(
"pyv", &brPyv,
"pyv/D" );
469 s_tree->Branch(
"pzv", &brPzv,
"pzv/D" );
470 s_tree->Branch(
"En", &brEn,
"En/D" );
471 s_tree->Branch(
"pxn", &brPxn,
"pxn/D" );
472 s_tree->Branch(
"pyn", &brPyn,
"pyn/D" );
473 s_tree->Branch(
"pzn", &brPzn,
"pzn/D" );
474 s_tree->Branch(
"El", &brEl,
"El/D" );
475 s_tree->Branch(
"pxl", &brPxl,
"pxl/D" );
476 s_tree->Branch(
"pyl", &brPyl,
"pyl/D" );
477 s_tree->Branch(
"pzl", &brPzl,
"pzl/D" );
478 s_tree->Branch(
"pl", &brPl,
"pl/D" );
479 s_tree->Branch(
"cthl", &brCosthl,
"cthl/D" );
480 s_tree->Branch(
"nfp", &brNfP,
"nfp/I" );
481 s_tree->Branch(
"nfn", &brNfN,
"nfn/I" );
482 s_tree->Branch(
"nfpip", &brNfPip,
"nfpip/I" );
483 s_tree->Branch(
"nfpim", &brNfPim,
"nfpim/I" );
484 s_tree->Branch(
"nfpi0", &brNfPi0,
"nfpi0/I" );
485 s_tree->Branch(
"nfkp", &brNfKp,
"nfkp/I" );
486 s_tree->Branch(
"nfkm", &brNfKm,
"nfkm/I" );
487 s_tree->Branch(
"nfk0", &brNfK0,
"nfk0/I" );
488 s_tree->Branch(
"nfem", &brNfEM,
"nfem/I" );
489 s_tree->Branch(
"nfother", &brNfOther,
"nfother/I" );
490 s_tree->Branch(
"nip", &brNiP,
"nip/I" );
491 s_tree->Branch(
"nin", &brNiN,
"nin/I" );
492 s_tree->Branch(
"nipip", &brNiPip,
"nipip/I" );
493 s_tree->Branch(
"nipim", &brNiPim,
"nipim/I" );
494 s_tree->Branch(
"nipi0", &brNiPi0,
"nipi0/I" );
495 s_tree->Branch(
"nikp", &brNiKp,
"nikp/I" );
496 s_tree->Branch(
"nikm", &brNiKm,
"nikm/I" );
497 s_tree->Branch(
"nik0", &brNiK0,
"nik0/I" );
498 s_tree->Branch(
"niem", &brNiEM,
"niem/I" );
499 s_tree->Branch(
"niother", &brNiOther,
"niother/I" );
500 s_tree->Branch(
"ni", &brNi,
"ni/I" );
501 s_tree->Branch(
"pdgi", brPdgi,
"pdgi[ni]/I" );
502 s_tree->Branch(
"resc", brResc,
"resc[ni]/I" );
503 s_tree->Branch(
"Ei", brEi,
"Ei[ni]/D" );
504 s_tree->Branch(
"pxi", brPxi,
"pxi[ni]/D" );
505 s_tree->Branch(
"pyi", brPyi,
"pyi[ni]/D" );
506 s_tree->Branch(
"pzi", brPzi,
"pzi[ni]/D" );
507 s_tree->Branch(
"nf", &brNf,
"nf/I" );
508 s_tree->Branch(
"pdgf", brPdgf,
"pdgf[nf]/I" );
509 s_tree->Branch(
"Ef", brEf,
"Ef[nf]/D" );
510 s_tree->Branch(
"pxf", brPxf,
"pxf[nf]/D" );
511 s_tree->Branch(
"pyf", brPyf,
"pyf[nf]/D" );
512 s_tree->Branch(
"pzf", brPzf,
"pzf[nf]/D" );
513 s_tree->Branch(
"pf", brPf,
"pf[nf]/D" );
514 s_tree->Branch(
"cthf", brCosthf,
"cthf[nf]/D" );
515 s_tree->Branch(
"vtxx", &brVtxX,
"vtxx/D" );
516 s_tree->Branch(
"vtxy", &brVtxY,
"vtxy/D" );
517 s_tree->Branch(
"vtxz", &brVtxZ,
"vtxz/D" );
518 s_tree->Branch(
"vtxt", &brVtxT,
"vtxt/D" );
519 s_tree->Branch(
"sumKEf", &brSumKEf,
"sumKEf/D" );
520 s_tree->Branch(
"calresp0", &brCalResp0,
"calresp0/D" );
521 s_tree->Branch(
"XSec", &brXSec,
"XSec/D" );
522 s_tree->Branch(
"DXSec", &brDXSec,
"DXSec/D" );
523 s_tree->Branch(
"KPS", &brKPS,
"KPS/i" );
529 er_tree = dynamic_cast <TTree *> ( fin.Get(
"gtree") );
532 LOG(
"gntpc",
pERROR) <<
"Null input GHEP event tree";
535 LOG(
"gntpc",
pINFO) <<
"Input tree header: " << *thdr;
539 er_tree->SetBranchAddress(
"gmcrec", &mcrec);
541 LOG(
"gntpc",
pERROR) <<
"Null MC record";
546 Long64_t nmax = (
gOptN<0) ?
547 er_tree->GetEntries() : TMath::Min( er_tree->GetEntries(),
gOptN );
549 LOG(
"gntpc",
pERROR) <<
"Number of events = 0";
553 LOG(
"gntpc",
pNOTICE) <<
"*** Analyzing: " << nmax <<
" events";
555 TLorentzVector pdummy(0,0,0,0);
558 for(Long64_t iev = 0; iev < nmax; iev++) {
559 er_tree->GetEntry(iev);
568 bool is_unphysical =
event.IsUnphysical();
570 LOG(
"gntpc",
pINFO) <<
"Skipping unphysical event";
577 for(
int j=0; j<
kNPmax; j++) {
603 if( neutrino ) {
LOG(
"gntpc",
pDEBUG) <<
"neutrino p4 = ( "
604 << neutrino->
GetP4()->E() <<
", "
605 << neutrino->
GetP4()->Px() <<
", "
606 << neutrino->
GetP4()->Py() <<
", "
607 << neutrino->
GetP4()->Pz() <<
" )"; }
608 if( target ) {
LOG(
"gntpc",
pDEBUG) <<
"target p4 = ( "
609 << target->
GetP4()->E() <<
", "
610 << target->
GetP4()->Px() <<
", "
611 << target->
GetP4()->Py() <<
", "
612 << target->
GetP4()->Pz() <<
" )"; }
613 if( fsl ) {
LOG(
"gntpc",
pDEBUG) <<
"fsl p4 = ( "
614 << fsl->
GetP4()->E() <<
", "
615 << fsl->
GetP4()->Px() <<
", "
616 << fsl->
GetP4()->Py() <<
", "
617 << fsl->
GetP4()->Pz() <<
" )"; }
619 if( hitnucl ) {
LOG(
"gntpc",
pDEBUG) <<
"hitnucl p4 = ( "
620 << hitnucl->
GetP4()->E() <<
", "
621 << hitnucl->
GetP4()->Px() <<
", "
622 << hitnucl->
GetP4()->Py() <<
", "
623 << hitnucl->
GetP4()->Pz() <<
" )"; }
643 TLorentzVector * vtx =
event.Vertex();
656 bool is_em = proc_info.
IsEM();
657 bool is_weakcc = proc_info.
IsWeakCC();
658 bool is_weaknc = proc_info.
IsWeakNC();
659 bool is_mec = proc_info.
IsMEC();
662 bool is_norm = proc_info.
IsNorm();
664 if (!hitnucl && neutrino) {
665 assert(is_coh || is_imd || is_imdanh || is_nuel | is_amnugamma || is_coh_el || is_hnl || is_norm);
669 int qrk = (is_dis) ? tgt.
HitQrkPdg() : 0;
670 bool seaq = (is_dis) ? tgt.
HitSeaQrk() :
false;
684 double weight =
event.Weight();
690 bool get_selected =
true;
691 double xs = kine.
x (get_selected);
692 double ys = kine.
y (get_selected);
693 double ts = (is_coh || is_dfr || is_hnl) ? kine.
t (get_selected) : -1;
694 double Q2s = kine.
Q2(get_selected);
695 double Ws = kine.
W (get_selected);
698 <<
"[Select] Q2 = " << Q2s <<
", W = " << Ws
699 <<
", x = " << xs <<
", y = " << ys <<
", t = " << ts;
705 const TLorentzVector & k1 = (neutrino) ? *(neutrino->
P4()) : pdummy;
706 const TLorentzVector & k2 = (fsl) ? *(fsl->
P4()) : pdummy;
707 const TLorentzVector & p1 = (hitnucl) ? *(hitnucl->
P4()) : pdummy;
710 TLorentzVector q = k1-k2;
711 double Q2 = -1 * q.M2();
713 double v = (hitnucl) ? q.Energy() : -1;
717 x = (hitnucl) ? 0.5*Q2/(M*v) : -1;
718 y = (hitnucl) ? v/k1.Energy() : -1;
720 W2 = (hitnucl) ? M*M + 2*M*v - Q2 : -1;
721 W = (hitnucl) ? TMath::Sqrt(W2) : -1;
722 }
else if( is_hnl ) {
728 <<
"Here is k1 = ( " << k1.E() <<
", " << k1.Px() <<
", " << k1.Py() <<
", " << k1.Pz() <<
" )";
738 W2 = M*M + 2*M*v -
Q2;
743 double t = (is_coh || is_dfr || is_hnl) ? kine.
t (get_selected) : -1;
746 TLorentzVector k1_rf = k1;
748 k1_rf.Boost(-1.*p1.BoostVector());
760 <<
"[Calc] Q2 = " << Q2 <<
", W = " << W
761 <<
", x = " << x <<
", y = " << y <<
", t = " << t;
767 bool study_hadsyst = (is_qel || is_res || is_dis || is_coh || is_dfr || is_mec || is_singlek || is_hnl);
770 TObjArrayIter piter(&event);
779 LOG(
"gntpc",
pDEBUG) <<
"Extracting final state hadronic system";
781 vector<int> final_had_syst;
782 while( (p = (
GHepParticle *) piter.Next()) && study_hadsyst)
787 if(!is_hnl && event.Particle(ip)->FirstMother()==0)
continue;
788 if(is_hnl && event.Particle(0)->FirstDaughter()==ip)
continue;
796 final_had_syst.push_back(ip);
799 final_had_syst.push_back(ip);
811 LOG(
"gntpc",
pDEBUG ) <<
"Adding pdg code " << ip <<
" to FS hadronic system";
812 final_had_syst.push_back(ip);
816 if( count(final_had_syst.begin(), final_had_syst.end(), -1) > 0) {
829 LOG(
"gntpc",
pDEBUG) <<
"Extracting primary hadronic system";
832 TObjArrayIter piter_prim(&event);
834 vector<int> prim_had_syst;
841 for( vector<int>::const_iterator hiter = final_had_syst.begin();
842 hiter != final_had_syst.end(); ++hiter) {
844 prim_had_syst.push_back(*hiter);
870 int ist_comp = p->
Status();
877 prim_had_syst.push_back(ip);
884 int ist_comp = p->
Status();
890 prim_had_syst.push_back(ip);
897 int ist_comp = p->
Status();
904 prim_had_syst.push_back(ip);
911 int ist_comp = p->
Status();
918 prim_had_syst.push_back(ip);
936 if( count(prim_had_syst.begin(), prim_had_syst.end(), -1) > 0) {
945 brNeutrino = (neutrino) ? neutrino->
Pdg() : 0;
946 brFSPrimLept = (fsl) ? fsl->
Pdg() : 0;
947 brTarget = target->
Pdg();
950 brHitNuc = (hitnucl) ? hitnucl->
Pdg() : 0;
961 brIsSingleK = is_singlek;
967 brIsCharmPro = charm;
968 brIsAMNuGamma= is_amnugamma;
981 brEvRF = k1_rf.Energy();
986 brEn = (hitnucl) ? p1.Energy() : 0;
987 brPxn = (hitnucl) ? p1.Px() : 0;
988 brPyn = (hitnucl) ? p1.Py() : 0;
989 brPzn = (hitnucl) ? p1.Pz() : 0;
995 brCosthl = TMath::Cos( k2.Vect().Angle(k1.Vect()) );
1000 brDXSec =
event.DiffXSec()*(1E+38/
units::cm2);
1001 brKPS =
event.DiffXSecVars();
1014 brNi = prim_had_syst.size();
1015 for(
int j=0; j<brNi; j++) {
1016 p =
event.Particle(prim_had_syst[j]);
1018 brPdgi[j] = p->
Pdg();
1021 brPxi [j] = p->
Px();
1022 brPyi [j] = p->
Py();
1023 brPzi [j] = p->
Pz();
1037 <<
"Counting in primary hadronic system: idx = " << prim_had_syst[j]
1038 <<
" -> " << p->
Name();
1043 <<
", N(n):" << brNiN
1044 <<
", N(pi+):" << brNiPip
1045 <<
", N(pi-):" << brNiPim
1046 <<
", N(pi0):" << brNiPi0
1047 <<
", N(K+,K-,K0):" << brNiKp+brNiKm+brNiK0
1048 <<
", N(gamma,e-,e+):" << brNiEM
1049 <<
", N(etc):" << brNiOther <<
"\n";
1063 brSumKEf = (fsl) ? fsl->
KinE() : 0;
1066 brNf = final_had_syst.size();
1067 for(
int j=0; j<brNf; j++) {
1068 p =
event.Particle(final_had_syst[j]);
1071 int hpdg = p->
Pdg();
1073 double hKE = p->
KinE();
1074 double hpx = p->
Px();
1075 double hpy = p->
Py();
1076 double hpz = p->
Pz();
1077 double hp = TMath::Sqrt(hpx*hpx + hpy*hpy + hpz*hpz);
1078 double hm = p->
Mass();
1079 double hcth = TMath::Cos( p->
P4()->Vect().Angle(k1.Vect()) );
1091 if ( hpdg ==
kPdgProton ) { brNfP++; brCalResp0 += hKE; }
1092 else if ( hpdg ==
kPdgAntiProton ) { brNfP++; brCalResp0 += (hE + 2*hm);}
1093 else if ( hpdg ==
kPdgNeutron ) { brNfN++; brCalResp0 += hKE; }
1094 else if ( hpdg ==
kPdgAntiNeutron ) { brNfN++; brCalResp0 += (hE + 2*hm);}
1095 else if ( hpdg ==
kPdgPiP ) { brNfPip++; brCalResp0 += hKE; }
1096 else if ( hpdg ==
kPdgPiM ) { brNfPim++; brCalResp0 += hKE; }
1097 else if ( hpdg ==
kPdgPi0 ) { brNfPi0++; brCalResp0 += (e_h * hE); }
1098 else if ( hpdg ==
kPdgKP ) { brNfKp++; brCalResp0 += hKE; }
1099 else if ( hpdg ==
kPdgKM ) { brNfKm++; brCalResp0 += hKE; }
1100 else if ( hpdg ==
kPdgK0 ) { brNfK0++; brCalResp0 += hKE; }
1101 else if ( hpdg ==
kPdgAntiK0 ) { brNfK0++; brCalResp0 += hKE; }
1102 else if ( hpdg ==
kPdgGamma ) { brNfEM++; brCalResp0 += (e_h * hE); }
1103 else if ( hpdg ==
kPdgElectron ) { brNfEM++; brCalResp0 += (e_h * hE); }
1104 else if ( hpdg ==
kPdgPositron ) { brNfEM++; brCalResp0 += (e_h * hE); }
1105 else { brNfOther++; brCalResp0 += hKE; }
1108 <<
"Counting in f/s system from hadronic vtx: idx = " << final_had_syst[j]
1109 <<
" -> " << p->
Name();
1114 <<
", N(n):" << brNfN
1115 <<
", N(pi+):" << brNfPip
1116 <<
", N(pi-):" << brNfPim
1117 <<
", N(pi0):" << brNfPi0
1118 <<
", N(K+,K-,K0):" << brNfKp+brNfKm+brNfK0
1119 <<
", N(gamma,e-,e+):" << brNfEM
1120 <<
", N(etc):" << brNfOther <<
"\n";
1136 TFolder * genv = (TFolder*) fin.Get(
"genv");
1137 TFolder * gconfig = (TFolder*) fin.Get(
"gconfig");
1139 genv ->
Write(
"genv");
1140 gconfig ->
Write(
"gconfig");
1157 tree = dynamic_cast <TTree *> ( fin.Get(
"gtree") );
1160 LOG(
"gntpc",
pINFO) <<
"Input tree header: " << *thdr;
1164 tree->SetBranchAddress(
"gmcrec", &mcrec);
1170 output <<
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
1171 output << endl << endl;
1172 output <<
"<!-- generated by GENIE gntpc utility -->";
1173 output << endl << endl;
1174 output <<
"<genie_event_list version=\"1.00\">" << endl;
1177 Long64_t nmax = (
gOptN<0) ?
1178 tree->GetEntries() : TMath::Min(tree->GetEntries(),
gOptN);
1180 LOG(
"gntpc",
pERROR) <<
"Number of events = 0";
1183 LOG(
"gntpc",
pNOTICE) <<
"*** Analyzing: " << nmax <<
" events";
1186 for(Long64_t iev = 0; iev < nmax; iev++) {
1187 tree->GetEntry(iev);
1198 output << endl << endl;
1199 output <<
" <!-- GENIE GHEP event -->" << endl;
1200 output <<
" <ghep np=\"" <<
event.GetEntries()
1201 <<
"\" unphysical=\""
1202 << (
event.IsUnphysical() ?
"true" :
"false") <<
"\">" << endl;
1203 output << setiosflags(ios::scientific);
1207 output <<
" <!-- event weight -->";
1208 output <<
" <wgt> " <<
event.Weight() <<
" </wgt>";
1211 output <<
" <!-- cross sections -->";
1212 output <<
" <xsec_evnt> " <<
event.XSec() <<
" </xsec_evnt>";
1213 output <<
" <xsec_kine> " <<
event.DiffXSec() <<
" </xsec_kine>";
1216 output <<
" <!-- event vertex -->";
1217 output <<
" <vx> " <<
event.Vertex()->X() <<
" </vx>";
1218 output <<
" <vy> " <<
event.Vertex()->Y() <<
" </vy>";
1219 output <<
" <vz> " <<
event.Vertex()->Z() <<
" </vz>";
1220 output <<
" <vt> " <<
event.Vertex()->T() <<
" </vt>";
1224 output <<
" <!-- particle list -->" << endl;
1227 TIter event_iter(&event);
1228 while ( (p = dynamic_cast<GHepParticle *>(event_iter.Next())) ) {
1234 output <<
" <p idx=\"" << i <<
"\" type=\"" << type <<
"\">" << endl;
1236 output <<
" <pdg> " << p->
Pdg() <<
" </pdg>";
1237 output <<
" <ist> " << p->
Status() <<
" </ist>";
1240 output <<
" <mother> "
1241 <<
" <fst> " << setfill(
' ') << setw(3) << p->
FirstMother() <<
" </fst> "
1242 <<
" <lst> " << setfill(
' ') << setw(3) << p->
LastMother() <<
" </lst> "
1246 output <<
" <daughter> "
1247 <<
" <fst> " << setfill(
' ') << setw(3) << p->
FirstDaughter() <<
" </fst> "
1248 <<
" <lst> " << setfill(
' ') << setw(3) << p->
LastDaughter() <<
" </lst> "
1252 output <<
" <px> " << setfill(
' ') << setw(20) << p->
Px() <<
" </px>";
1253 output <<
" <py> " << setfill(
' ') << setw(20) << p->
Py() <<
" </py>";
1254 output <<
" <pz> " << setfill(
' ') << setw(20) << p->
Pz() <<
" </pz>";
1255 output <<
" <E> " << setfill(
' ') << setw(20) << p->
E() <<
" </E> ";
1258 output <<
" <x> " << setfill(
' ') << setw(20) << p->
Vx() <<
" </x> ";
1259 output <<
" <y> " << setfill(
' ') << setw(20) << p->
Vy() <<
" </y> ";
1260 output <<
" <z> " << setfill(
' ') << setw(20) << p->
Vz() <<
" </z> ";
1261 output <<
" <t> " << setfill(
' ') << setw(20) << p->
Vt() <<
" </t> ";
1273 output <<
" <rescatter> " << p->
RescatterCode() <<
" </rescatter>";
1277 output <<
" </p>" << endl;
1280 output <<
" </ghep>" << endl;
1286 output << endl << endl;
1287 output <<
"<genie_event_list version=\"1.00\">";
1292 LOG(
"gntpc",
pINFO) <<
"\nDone converting GENIE's GHEP ntuple";
1303 tree = dynamic_cast <TTree *> ( fin.Get(
"gtree") );
1306 LOG(
"gntpc",
pINFO) <<
"Input tree header: " << *thdr;
1310 tree->SetBranchAddress(
"gmcrec", &mcrec);
1313 Long64_t nmax = (
gOptN<0) ?
1314 tree->GetEntries() : TMath::Min(tree->GetEntries(),
gOptN);
1316 LOG(
"gntpc",
pERROR) <<
"Number of events = 0";
1319 LOG(
"gntpc",
pNOTICE) <<
"*** Analyzing: " << nmax <<
" events";
1327 for(Long64_t iev = 0; iev < nmax; iev++) {
1328 tree->GetEntry(iev);
1338 stripped_event -> AttachSummary (nullint);
1339 stripped_event -> SetWeight (event.Weight());
1340 stripped_event -> SetVertex (*event.Vertex());
1349 p->Pdg(), ist, -1,-1,-1,-1, *p->P4(), *p->X4());
1364 LOG(
"gntpc",
pINFO) <<
"\nDone converting GENIE's GHEP ntuple";
1375 tree = dynamic_cast <TTree *> ( fin.Get(
"gtree") );
1378 LOG(
"gntpc",
pINFO) <<
"Input tree header: " << *thdr;
1386 tree->SetBranchAddress(
"gmcrec", &mcrec);
1388 #ifdef __GENIE_FLUX_DRIVERS_ENABLED__
1390 tree->SetBranchAddress(
"flux", &flux_info);
1393 <<
"\n Flux drivers are not enabled."
1394 <<
"\n No flux pass-through information will be written-out in the rootracker file"
1395 <<
"\n If this isn't what you are supposed to be doing then build GENIE by adding "
1396 <<
"--with-flux-drivers in the configuration step.";
1403 Long64_t nmax = (
gOptN<0) ?
1404 tree->GetEntries() : TMath::Min(tree->GetEntries(),
gOptN);
1406 LOG(
"gntpc",
pERROR) <<
"Number of events = 0";
1409 LOG(
"gntpc",
pNOTICE) <<
"*** Analyzing: " << nmax <<
" events";
1412 for(Long64_t iev = 0; iev < nmax; iev++) {
1413 tree->GetEntry(iev);
1422 TIter event_iter(&event);
1430 output <<
"$ begin" << endl;
1439 LOG(
"gntpc",
pNOTICE) <<
"NEUT-like event type = " << evtype;
1440 output <<
"$ genie " << evtype << endl;
1446 LOG(
"gntpc",
pNOTICE) <<
"NUANCE-like event type = " << evtype;
1447 output <<
"$ nuance " << evtype << endl;
1458 output <<
"$ vertex "
1459 <<
event.Vertex()->X() <<
" "
1460 <<
event.Vertex()->Y() <<
" "
1461 <<
event.Vertex()->Z() <<
" "
1462 <<
event.Vertex()->T() << endl;
1474 while ( (p = dynamic_cast<GHepParticle *>(event_iter.Next())) )
1478 int ghep_pdgc = p->
Pdg();
1491 bool is_pi0_dec =
false;
1496 for(
int jd = ghep_fd; jd <= ghep_ld; jd++) {
1498 pi0dv.push_back(event.Particle(jd)->Pdg());
1501 sort(pi0dv.begin(), pi0dv.end());
1508 int ghep_fmpdgc = (ghep_fm==-1) ? 0 : event.Particle(ghep_fm)->Pdg();
1524 tracks.push_back(iparticle);
1531 for(
int iloop=0; iloop<=1; iloop++)
1533 for(vector<int>::const_iterator ip = tracks.begin(); ip != tracks.end(); ++ip)
1536 p =
event.Particle(iparticle);
1538 int ghep_pdgc = p->
Pdg();
1544 if(iloop==0 && fs)
continue;
1545 if(iloop==1 && !fs)
continue;
1560 default: ist = -999;
break;
1566 int pdgc = ghep_pdgc;
1578 double R = rnd->
RndGen().Rndm();
1584 const TLorentzVector * p4 = p->
P4();
1591 double dcosx = (P>0) ? Px/P : -999;
1592 double dcosy = (P>0) ? Py/P : -999;
1593 double dcosz = (P>0) ? Pz/P : -999;
1609 <<
"Adding $track corrsponding to GHEP particle at position: " << iparticle
1610 <<
" (tracker status code: " << ist <<
")";
1612 output <<
"$ track " << pdgc <<
" " << E <<
" "
1613 << dcosx <<
" " << dcosy <<
" " << dcosz <<
" "
1683 output <<
"$ info " << (int) iev <<
" " << *(event.EventFlags()) <<
" " << interaction->
AsString() << endl;
1684 output <<
"$ info " << (1E+38/
units::cm2) * event.XSec() <<
" "
1685 << (1E+38/
units::cm2) * event.DiffXSec() <<
" "
1686 <<
event.Weight() <<
" "
1687 <<
event.Probability()
1689 output <<
"$ info " <<
event.Vertex()->X() <<
" "
1690 <<
event.Vertex()->Y() <<
" "
1691 <<
event.Vertex()->Z() <<
" "
1692 <<
event.Vertex()->T()
1701 quark_id = 10 * quark_pdg + sorv;
1703 output <<
"$ info " << quark_id << endl;
1711 output <<
"$ info " <<
event.GetEntries() << endl;
1712 while ( (p = dynamic_cast<GHepParticle *>(event_iter.Next())) )
1717 << p->
Pdg() <<
" " << (int) p->
Status() <<
" "
1720 << p->
X4()->X() <<
" " << p->
X4()->Y() <<
" " << p->
X4()->Z() <<
" " << p->
X4()->T() <<
" "
1721 << p->
P4()->Px() <<
" " << p->
P4()->Py() <<
" " << p->
P4()->Pz() <<
" " << p->
P4()->E() <<
" ";
1727 output <<
"0. 0. 0.";
1732 int rescat_code = -1;
1733 bool have_rescat_code =
false;
1735 if(gFileMinorVrs >= 5) {
1736 if(gFileRevisVrs >= 1) {
1737 have_rescat_code =
true;
1741 if(have_rescat_code) {
1745 output << rescat_code;
1806 output <<
"$ end" << endl;
1812 output <<
"$ stop" << endl;
1817 LOG(
"gntpc",
pINFO) <<
"\nDone converting GENIE's GHEP ntuple";
1828 TBits* brEvtFlags = 0;
1829 TObjString* brEvtCode = 0;
1839 int brStdHepPdg [
kNPmax];
1840 int brStdHepStatus[
kNPmax];
1841 int brStdHepRescat[
kNPmax];
1842 double brStdHepX4 [
kNPmax][4];
1843 double brStdHepP4 [
kNPmax][4];
1844 double brStdHepPolz [
kNPmax][3];
1853 TObjString* brNuFileName = 0;
1858 int brNuParentDecMode;
1859 double brNuParentDecP4 [4];
1860 double brNuParentDecX4 [4];
1861 double brNuParentProP4 [4];
1862 double brNuParentProX4 [4];
1863 int brNuParentProNVtx;
1914 int brNumiFluxEvtno;
1915 double brNumiFluxNdxdz;
1916 double brNumiFluxNdydz;
1917 double brNumiFluxNpz;
1918 double brNumiFluxNenergy;
1919 double brNumiFluxNdxdznea;
1920 double brNumiFluxNdydznea;
1921 double brNumiFluxNenergyn;
1922 double brNumiFluxNwtnear;
1923 double brNumiFluxNdxdzfar;
1924 double brNumiFluxNdydzfar;
1925 double brNumiFluxNenergyf;
1926 double brNumiFluxNwtfar;
1927 int brNumiFluxNorig;
1928 int brNumiFluxNdecay;
1943 int brNumiFluxNtype;
1944 double brNumiFluxVx;
1945 double brNumiFluxVy;
1946 double brNumiFluxVz;
1947 double brNumiFluxPdpx;
1948 double brNumiFluxPdpy;
1949 double brNumiFluxPdpz;
1950 double brNumiFluxPpdxdz;
1951 double brNumiFluxPpdydz;
1952 double brNumiFluxPppz;
1953 double brNumiFluxPpenergy;
1954 int brNumiFluxPpmedium;
1955 int brNumiFluxPtype;
1956 double brNumiFluxPpvx;
1957 double brNumiFluxPpvy;
1958 double brNumiFluxPpvz;
1959 double brNumiFluxMuparpx;
1960 double brNumiFluxMuparpy;
1961 double brNumiFluxMuparpz;
1962 double brNumiFluxMupare;
1963 double brNumiFluxNecm;
1964 double brNumiFluxNimpwt;
1965 double brNumiFluxXpoint;
1966 double brNumiFluxYpoint;
1967 double brNumiFluxZpoint;
1968 double brNumiFluxTvx;
1969 double brNumiFluxTvy;
1970 double brNumiFluxTvz;
1971 double brNumiFluxTpx;
1972 double brNumiFluxTpy;
1973 double brNumiFluxTpz;
1974 double brNumiFluxTptype;
1975 double brNumiFluxTgen;
1979 double brNumiFluxTgptype;
1980 double brNumiFluxTgppx;
1982 double brNumiFluxTgppy;
1984 double brNumiFluxTgppz;
1986 double brNumiFluxTprivx;
1987 double brNumiFluxTprivy;
1988 double brNumiFluxTprivz;
1989 double brNumiFluxBeamx;
1990 double brNumiFluxBeamy;
1991 double brNumiFluxBeamz;
1992 double brNumiFluxBeampx;
1993 double brNumiFluxBeampy;
1994 double brNumiFluxBeampz;
2000 TTree * rootracker_tree =
new TTree(
"gRooTracker",
"GENIE event tree rootracker format");
2010 rootracker_tree->Branch(
"EvtFlags",
"TBits", &brEvtFlags, 32000, 1);
2011 rootracker_tree->Branch(
"EvtCode",
"TObjString", &brEvtCode, 32000, 1);
2012 rootracker_tree->Branch(
"EvtNum", &brEvtNum,
"EvtNum/I");
2013 rootracker_tree->Branch(
"EvtXSec", &brEvtXSec,
"EvtXSec/D");
2014 rootracker_tree->Branch(
"EvtDXSec", &brEvtDXSec,
"EvtDXSec/D");
2015 rootracker_tree->Branch(
"EvtKPS", &brEvtKPS,
"EvtKPS/i");
2016 rootracker_tree->Branch(
"EvtWght", &brEvtWght,
"EvtWght/D");
2017 rootracker_tree->Branch(
"EvtProb", &brEvtProb,
"EvtProb/D");
2018 rootracker_tree->Branch(
"EvtVtx", brEvtVtx,
"EvtVtx[4]/D");
2019 rootracker_tree->Branch(
"StdHepN", &brStdHepN,
"StdHepN/I");
2020 rootracker_tree->Branch(
"StdHepPdg", brStdHepPdg,
"StdHepPdg[StdHepN]/I");
2021 rootracker_tree->Branch(
"StdHepStatus", brStdHepStatus,
"StdHepStatus[StdHepN]/I");
2022 rootracker_tree->Branch(
"StdHepRescat", brStdHepRescat,
"StdHepRescat[StdHepN]/I");
2023 rootracker_tree->Branch(
"StdHepX4", brStdHepX4,
"StdHepX4[StdHepN][4]/D");
2024 rootracker_tree->Branch(
"StdHepP4", brStdHepP4,
"StdHepP4[StdHepN][4]/D");
2025 rootracker_tree->Branch(
"StdHepPolz", brStdHepPolz,
"StdHepPolz[StdHepN][3]/D");
2026 rootracker_tree->Branch(
"StdHepFd", brStdHepFd,
"StdHepFd[StdHepN]/I");
2027 rootracker_tree->Branch(
"StdHepLd", brStdHepLd,
"StdHepLd[StdHepN]/I");
2028 rootracker_tree->Branch(
"StdHepFm", brStdHepFm,
"StdHepFm[StdHepN]/I");
2029 rootracker_tree->Branch(
"StdHepLm", brStdHepLm,
"StdHepLm[StdHepN]/I");
2032 rootracker_tree->Branch(
"EvtNum", &brEvtNum,
"EvtNum/I");
2033 rootracker_tree->Branch(
"EvtWght", &brEvtWght,
"EvtWght/D");
2034 rootracker_tree->Branch(
"EvtVtx", brEvtVtx,
"EvtVtx[4]/D");
2035 rootracker_tree->Branch(
"StdHepN", &brStdHepN,
"StdHepN/I");
2036 rootracker_tree->Branch(
"StdHepPdg", brStdHepPdg,
"StdHepPdg[StdHepN]/I");
2037 rootracker_tree->Branch(
"StdHepX4", brStdHepX4,
"StdHepX4[StdHepN][4]/D");
2038 rootracker_tree->Branch(
"StdHepP4", brStdHepP4,
"StdHepP4[StdHepN][4]/D");
2045 rootracker_tree->Branch(
"G2NeutEvtCode", &brNeutCode,
"G2NeutEvtCode/I");
2047 rootracker_tree->Branch(
"NuFileName",
"TObjString", &brNuFileName, 32000, 1);
2048 rootracker_tree->Branch(
"NuParentPdg", &brNuParentPdg,
"NuParentPdg/I");
2049 rootracker_tree->Branch(
"NuParentDecMode", &brNuParentDecMode,
"NuParentDecMode/I");
2050 rootracker_tree->Branch(
"NuParentDecP4", brNuParentDecP4,
"NuParentDecP4[4]/D");
2051 rootracker_tree->Branch(
"NuParentDecX4", brNuParentDecX4,
"NuParentDecX4[4]/D");
2052 rootracker_tree->Branch(
"NuParentProP4", brNuParentProP4,
"NuParentProP4[4]/D");
2053 rootracker_tree->Branch(
"NuParentProX4", brNuParentProX4,
"NuParentProX4[4]/D");
2054 rootracker_tree->Branch(
"NuParentProNVtx", &brNuParentProNVtx,
"NuParentProNVtx/I");
2056 rootracker_tree->Branch(
"NuFluxEntry", &brNuFluxEntry,
"NuFluxEntry/L");
2057 rootracker_tree->Branch(
"NuIdfd", &brNuIdfd,
"NuIdfd/I");
2058 rootracker_tree->Branch(
"NuCospibm", &brNuCospibm,
"NuCospibm/F");
2059 rootracker_tree->Branch(
"NuCospi0bm", &brNuCospi0bm,
"NuCospi0bm/F");
2060 rootracker_tree->Branch(
"NuGipart", &brNuGipart,
"NuGipart/I");
2061 rootracker_tree->Branch(
"NuGpos0", brNuGpos0,
"NuGpos0[3]/F");
2062 rootracker_tree->Branch(
"NuGvec0", brNuGvec0,
"NuGvec0[3]/F");
2063 rootracker_tree->Branch(
"NuGamom0", &brNuGamom0,
"NuGamom0/F");
2065 rootracker_tree->Branch(
"NuXnu", brNuXnu,
"NuXnu[2]/F");
2066 rootracker_tree->Branch(
"NuRnu", &brNuRnu,
"NuRnu/F");
2067 rootracker_tree->Branch(
"NuNg", &brNuNg,
"NuNg/I");
2068 rootracker_tree->Branch(
"NuGpid", brNuGpid,
"NuGpid[NuNg]/I");
2069 rootracker_tree->Branch(
"NuGmec", brNuGmec,
"NuGmec[NuNg]/I");
2070 rootracker_tree->Branch(
"NuGv", brNuGv,
"NuGv[NuNg][3]/F");
2071 rootracker_tree->Branch(
"NuGp", brNuGp,
"NuGp[NuNg][3]/F");
2072 rootracker_tree->Branch(
"NuGcosbm", brNuGcosbm,
"NuGcosbm[NuNg]/F");
2073 rootracker_tree->Branch(
"NuGmat", brNuGmat,
"NuGmat[NuNg]/I");
2074 rootracker_tree->Branch(
"NuGdistc", brNuGdistc,
"NuGdistc[NuNg]/F");
2075 rootracker_tree->Branch(
"NuGdistal", brNuGdistal,
"NuGdistal[NuNg]/F");
2076 rootracker_tree->Branch(
"NuGdistti", brNuGdistti,
"NuGdistti[NuNg]/F");
2077 rootracker_tree->Branch(
"NuGdistfe", brNuGdistfe,
"NuGdistfe[NuNg]/F");
2078 rootracker_tree->Branch(
"NuNorm", &brNuNorm,
"NuNorm/F");
2079 rootracker_tree->Branch(
"NuEnusk", &brNuEnusk,
"NuEnusk/F");
2080 rootracker_tree->Branch(
"NuNormsk", &brNuNormsk,
"NuNormsk/F");
2081 rootracker_tree->Branch(
"NuAnorm", &brNuAnorm,
"NuAnorm/F");
2082 rootracker_tree->Branch(
"NuVersion", &brNuVersion,
"NuVersion/F");
2083 rootracker_tree->Branch(
"NuNtrig", &brNuNtrig,
"NuNtrig/I");
2084 rootracker_tree->Branch(
"NuTuneid", &brNuTuneid,
"NuTuneid/I");
2085 rootracker_tree->Branch(
"NuPint", &brNuPint,
"NuPint/I");
2086 rootracker_tree->Branch(
"NuBpos", brNuBpos,
"NuBpos[2]/F");
2087 rootracker_tree->Branch(
"NuBtilt", brNuBtilt,
"NuBtilt[2]/F");
2088 rootracker_tree->Branch(
"NuBrms", brNuBrms,
"NuBrms[2]/F");
2089 rootracker_tree->Branch(
"NuEmit", brNuEmit,
"NuEmit[2]/F");
2090 rootracker_tree->Branch(
"NuAlpha", brNuAlpha,
"NuAlpha[2]/F");
2091 rootracker_tree->Branch(
"NuHcur", brNuHcur,
"NuHcur[3]/F");
2092 rootracker_tree->Branch(
"NuRand", &brNuRand,
"NuRand/I");
2100 rootracker_tree->Branch(
"NumiFluxRun", &brNumiFluxRun,
"NumiFluxRun/I");
2101 rootracker_tree->Branch(
"NumiFluxEvtno", &brNumiFluxEvtno,
"NumiFluxEvtno/I");
2102 rootracker_tree->Branch(
"NumiFluxNdxdz", &brNumiFluxNdxdz,
"NumiFluxNdxdz/D");
2103 rootracker_tree->Branch(
"NumiFluxNdydz", &brNumiFluxNdydz,
"NumiFluxNdydz/D");
2104 rootracker_tree->Branch(
"NumiFluxNpz", &brNumiFluxNpz,
"NumiFluxNpz/D");
2105 rootracker_tree->Branch(
"NumiFluxNenergy", &brNumiFluxNenergy,
"NumiFluxNenergy/D");
2106 rootracker_tree->Branch(
"NumiFluxNdxdznea", &brNumiFluxNdxdznea,
"NumiFluxNdxdznea/D");
2107 rootracker_tree->Branch(
"NumiFluxNdydznea", &brNumiFluxNdydznea,
"NumiFluxNdydznea/D");
2108 rootracker_tree->Branch(
"NumiFluxNenergyn", &brNumiFluxNenergyn,
"NumiFluxNenergyn/D");
2109 rootracker_tree->Branch(
"NumiFluxNwtnear", &brNumiFluxNwtnear,
"NumiFluxNwtnear/D");
2110 rootracker_tree->Branch(
"NumiFluxNdxdzfar", &brNumiFluxNdxdzfar,
"NumiFluxNdxdzfar/D");
2111 rootracker_tree->Branch(
"NumiFluxNdydzfar", &brNumiFluxNdydzfar,
"NumiFluxNdydzfar/D");
2112 rootracker_tree->Branch(
"NumiFluxNenergyf", &brNumiFluxNenergyf,
"NumiFluxNenergyf/D");
2113 rootracker_tree->Branch(
"NumiFluxNwtfar", &brNumiFluxNwtfar,
"NumiFluxNwtfar/D");
2114 rootracker_tree->Branch(
"NumiFluxNorig", &brNumiFluxNorig,
"NumiFluxNorig/I");
2115 rootracker_tree->Branch(
"NumiFluxNdecay", &brNumiFluxNdecay,
"NumiFluxNdecay/I");
2116 rootracker_tree->Branch(
"NumiFluxNtype", &brNumiFluxNtype,
"NumiFluxNtype/I");
2117 rootracker_tree->Branch(
"NumiFluxVx", &brNumiFluxVx,
"NumiFluxVx/D");
2118 rootracker_tree->Branch(
"NumiFluxVy", &brNumiFluxVy,
"NumiFluxVy/D");
2119 rootracker_tree->Branch(
"NumiFluxVz", &brNumiFluxVz,
"NumiFluxVz/D");
2120 rootracker_tree->Branch(
"NumiFluxPdpx", &brNumiFluxPdpx,
"NumiFluxPdpx/D");
2121 rootracker_tree->Branch(
"NumiFluxPdpy", &brNumiFluxPdpy,
"NumiFluxPdpy/D");
2122 rootracker_tree->Branch(
"NumiFluxPdpz", &brNumiFluxPdpz,
"NumiFluxPdpz/D");
2123 rootracker_tree->Branch(
"NumiFluxPpdxdz", &brNumiFluxPpdxdz,
"NumiFluxPpdxdz/D");
2124 rootracker_tree->Branch(
"NumiFluxPpdydz", &brNumiFluxPpdydz,
"NumiFluxPpdydz/D");
2125 rootracker_tree->Branch(
"NumiFluxPppz", &brNumiFluxPppz,
"NumiFluxPppz/D");
2126 rootracker_tree->Branch(
"NumiFluxPpenergy", &brNumiFluxPpenergy,
"NumiFluxPpenergy/D");
2127 rootracker_tree->Branch(
"NumiFluxPpmedium", &brNumiFluxPpmedium,
"NumiFluxPpmedium/I");
2128 rootracker_tree->Branch(
"NumiFluxPtype", &brNumiFluxPtype,
"NumiFluxPtype/I");
2129 rootracker_tree->Branch(
"NumiFluxPpvx", &brNumiFluxPpvx,
"NumiFluxPpvx/D");
2130 rootracker_tree->Branch(
"NumiFluxPpvy", &brNumiFluxPpvy,
"NumiFluxPpvy/D");
2131 rootracker_tree->Branch(
"NumiFluxPpvz", &brNumiFluxPpvz,
"NumiFluxPpvz/D");
2132 rootracker_tree->Branch(
"NumiFluxMuparpx", &brNumiFluxMuparpx,
"NumiFluxMuparpx/D");
2133 rootracker_tree->Branch(
"NumiFluxMuparpy", &brNumiFluxMuparpy,
"NumiFluxMuparpy/D");
2134 rootracker_tree->Branch(
"NumiFluxMuparpz", &brNumiFluxMuparpz,
"NumiFluxMuparpz/D");
2135 rootracker_tree->Branch(
"NumiFluxMupare", &brNumiFluxMupare,
"NumiFluxMupare/D");
2136 rootracker_tree->Branch(
"NumiFluxNecm", &brNumiFluxNecm,
"NumiFluxNecm/D");
2137 rootracker_tree->Branch(
"NumiFluxNimpwt", &brNumiFluxNimpwt,
"NumiFluxNimpwt/D");
2138 rootracker_tree->Branch(
"NumiFluxXpoint", &brNumiFluxXpoint,
"NumiFluxXpoint/D");
2139 rootracker_tree->Branch(
"NumiFluxYpoint", &brNumiFluxYpoint,
"NumiFluxYpoint/D");
2140 rootracker_tree->Branch(
"NumiFluxZpoint", &brNumiFluxZpoint,
"NumiFluxZpoint/D");
2141 rootracker_tree->Branch(
"NumiFluxTvx", &brNumiFluxTvx,
"NumiFluxTvx/D");
2142 rootracker_tree->Branch(
"NumiFluxTvy", &brNumiFluxTvy,
"NumiFluxTvy/D");
2143 rootracker_tree->Branch(
"NumiFluxTvz", &brNumiFluxTvz,
"NumiFluxTvz/D");
2144 rootracker_tree->Branch(
"NumiFluxTpx", &brNumiFluxTpx,
"NumiFluxTpx/D");
2145 rootracker_tree->Branch(
"NumiFluxTpy", &brNumiFluxTpy,
"NumiFluxTpy/D");
2146 rootracker_tree->Branch(
"NumiFluxTpz", &brNumiFluxTpz,
"NumiFluxTpz/D");
2147 rootracker_tree->Branch(
"NumiFluxTptype", &brNumiFluxTptype,
"NumiFluxTptype/I");
2148 rootracker_tree->Branch(
"NumiFluxTgen", &brNumiFluxTgen,
"NumiFluxTgen/I");
2149 rootracker_tree->Branch(
"NumiFluxTgptype", &brNumiFluxTgptype,
"NumiFluxTgptype/I");
2150 rootracker_tree->Branch(
"NumiFluxTgppx", &brNumiFluxTgppx,
"NumiFluxTgppx/D");
2151 rootracker_tree->Branch(
"NumiFluxTgppy", &brNumiFluxTgppy,
"NumiFluxTgppy/D");
2152 rootracker_tree->Branch(
"NumiFluxTgppz", &brNumiFluxTgppz,
"NumiFluxTgppz/D");
2153 rootracker_tree->Branch(
"NumiFluxTprivx", &brNumiFluxTprivx,
"NumiFluxTprivx/D");
2154 rootracker_tree->Branch(
"NumiFluxTprivy", &brNumiFluxTprivy,
"NumiFluxTprivy/D");
2155 rootracker_tree->Branch(
"NumiFluxTprivz", &brNumiFluxTprivz,
"NumiFluxTprivz/D");
2156 rootracker_tree->Branch(
"NumiFluxBeamx", &brNumiFluxBeamx,
"NumiFluxBeamx/D");
2157 rootracker_tree->Branch(
"NumiFluxBeamy", &brNumiFluxBeamy,
"NumiFluxBeamy/D");
2158 rootracker_tree->Branch(
"NumiFluxBeamz", &brNumiFluxBeamz,
"NumiFluxBeamz/D");
2159 rootracker_tree->Branch(
"NumiFluxBeampx", &brNumiFluxBeampx,
"NumiFluxBeampx/D");
2160 rootracker_tree->Branch(
"NumiFluxBeampy", &brNumiFluxBeampy,
"NumiFluxBeampy/D");
2161 rootracker_tree->Branch(
"NumiFluxBeampz", &brNumiFluxBeampz,
"NumiFluxBeampz/D");
2168 gtree = dynamic_cast <TTree *> ( fin.Get(
"gtree") );
2171 LOG(
"gntpc",
pINFO) <<
"Input tree header: " << *thdr;
2175 gtree->SetBranchAddress(
"gmcrec", &mcrec);
2186 LOG(
"gntpc",
pINFO) <<
"Found T2KMetaData!";
2191 <<
"Could not find T2KMetaData attached to the event tree!";
2195 #ifdef __GENIE_FLUX_DRIVERS_ENABLED__
2198 gtree->SetBranchAddress(
"flux", &jnubeam_flux_info);
2202 gtree->SetBranchAddress(
"flux", &gnumi_flux_info);
2204 #ifdef __GENIE_HEAVY_NEUTRAL_LEPTON_ENABLED__
2208 gtree->SetBranchAddress(
"flux", &gnumi_flux_ster);
2211 double dVars[9] = { -9.9, -9.9, -9.9, -9.9, -9.9, -9.9, -9.9, -9.9, -9.9 };
2212 int iVars[4] = { -9, -9, -9, -9 };
2213 DeclareHNLBranches( rootracker_tree, gtree, dVars, iVars );
2214 #endif // #ifdef __GENIE_HEAVY_NEUTRAL_LEPTON_ENABLED__
2217 <<
"\n Flux drivers are not enabled."
2218 <<
"\n No flux pass-through information will be written-out in the rootracker file"
2219 <<
"\n If this isn't what you are supposed to be doing then build GENIE by adding "
2220 <<
"--with-flux-drivers in the configuration step.";
2224 Long64_t nmax = (
gOptN<0) ?
2225 gtree->GetEntries() : TMath::Min(gtree->GetEntries(),
gOptN);
2227 LOG(
"gntpc",
pERROR) <<
"Number of events = 0";
2230 LOG(
"gntpc",
pNOTICE) <<
"*** Analyzing: " << nmax <<
" events";
2233 for(Long64_t iev = 0; iev < nmax; iev++) {
2234 gtree->GetEntry(iev);
2242 LOG(
"gntpc",
pINFO) << *interaction;
2243 #ifdef __GENIE_FLUX_DRIVERS_ENABLED__
2245 if(jnubeam_flux_info) {
2246 LOG(
"gntpc",
pINFO) << *jnubeam_flux_info;
2248 LOG(
"gntpc",
pINFO) <<
"No JNUBEAM flux info associated with this event";
2256 if(brEvtFlags)
delete brEvtFlags;
2258 if(brEvtCode)
delete brEvtCode;
2266 for(
int k=0; k<4; k++) {
2270 for(
int i=0; i<
kNPmax; i++) {
2271 brStdHepPdg [i] = 0;
2272 brStdHepStatus[i] = -1;
2273 brStdHepRescat[i] = -1;
2274 for(
int k=0; k<4; k++) {
2275 brStdHepX4 [i][k] = 0;
2276 brStdHepP4 [i][k] = 0;
2278 for(
int k=0; k<3; k++) {
2279 brStdHepPolz [i][k] = 0;
2287 brNuParentDecMode = 0;
2288 for(
int k=0; k<4; k++) {
2289 brNuParentDecP4 [k] = 0;
2290 brNuParentDecX4 [k] = 0;
2291 brNuParentProP4 [k] = 0;
2292 brNuParentProX4 [k] = 0;
2294 brNuParentProNVtx = 0;
2298 brNuCospibm = -999999.;
2299 brNuCospi0bm = -999999.;
2301 brNuGamom0 = -999999.;
2302 for(
int k=0; k< 3; k++){
2303 brNuGvec0[k] = -999999.;
2304 brNuGpos0[k] = -999999.;
2307 for(
int k=0; k<2; k++) {
2308 brNuXnu[k] = brNuBpos[k] = brNuBtilt[k] = brNuBrms[k] = brNuEmit[k] = brNuAlpha[k] = -999999.;
2310 for(
int k=0; k<3; k++) brNuHcur[k] = -999999.;
2312 for(
int k=0; k<3; k++){
2313 brNuGv[np][k] = -999999.;
2314 brNuGp[np][k] = -999999.;
2316 brNuGpid[np] = -999999;
2317 brNuGmec[np] = -999999;
2318 brNuGmat[np] = -999999;
2319 brNuGcosbm[np] = -999999.;
2320 brNuGdistc[np] = -999999.;
2321 brNuGdistal[np] = -999999.;
2322 brNuGdistti[np] = -999999.;
2323 brNuGdistfe[np] = -999999.;
2327 brNuNorm = -999999.;
2328 brNuEnusk = -999999.;
2329 brNuNormsk = -999999.;
2330 brNuAnorm = -999999.;
2331 brNuVersion= -999999.;
2332 brNuNtrig = -999999;
2333 brNuTuneid = -999999;
2336 if(brNuFileName)
delete brNuFileName;
2343 brEvtFlags =
new TBits(*event.EventFlags());
2344 brEvtCode =
new TObjString(event.Summary()->AsString().c_str());
2345 brEvtNum = (int) iev;
2346 brEvtXSec = (1E+38/
units::cm2) * event.XSec();
2347 brEvtDXSec = (1E+38/
units::cm2) * event.DiffXSec();
2348 brEvtKPS =
event.DiffXSecVars();
2350 <<
"brEvtKPS = " << brEvtKPS
2351 <<
", event.DiffXSecVars() = " <<
event.DiffXSecVars();
2352 brEvtWght =
event.Weight();
2353 brEvtProb =
event.Probability();
2354 brEvtVtx[0] =
event.Vertex()->X();
2355 brEvtVtx[1] =
event.Vertex()->Y();
2356 brEvtVtx[2] =
event.Vertex()->Z();
2357 brEvtVtx[3] =
event.Vertex()->T();
2361 TIter event_iter(&event);
2362 while ( (p = dynamic_cast<GHepParticle *>(event_iter.Next())) ) {
2368 brStdHepPdg [iparticle] = p->
Pdg();
2369 brStdHepStatus[iparticle] = (int) p->
Status();
2371 brStdHepX4 [iparticle][0] = p->
X4()->X();
2372 brStdHepX4 [iparticle][1] = p->
X4()->Y();
2373 brStdHepX4 [iparticle][2] = p->
X4()->Z();
2374 brStdHepX4 [iparticle][3] = p->
X4()->T();
2375 brStdHepP4 [iparticle][0] = p->
P4()->Px();
2376 brStdHepP4 [iparticle][1] = p->
P4()->Py();
2377 brStdHepP4 [iparticle][2] = p->
P4()->Pz();
2378 brStdHepP4 [iparticle][3] = p->
P4()->E();
2390 brStdHepN = iparticle;
2400 #ifdef __GENIE_FLUX_DRIVERS_ENABLED__
2405 if(jnubeam_flux_info) {
2407 brNuParentDecMode = jnubeam_flux_info->
mode;
2409 brNuParentDecP4 [0] = jnubeam_flux_info->
ppi * jnubeam_flux_info->
npi[0];
2410 brNuParentDecP4 [1] = jnubeam_flux_info->
ppi * jnubeam_flux_info->
npi[1];
2411 brNuParentDecP4 [2] = jnubeam_flux_info->
ppi * jnubeam_flux_info->
npi[2];
2412 brNuParentDecP4 [3] = TMath::Sqrt(
2413 TMath::Power(pdglib->
Find(brNuParentPdg)->Mass(), 2.)
2414 + TMath::Power(jnubeam_flux_info->
ppi, 2.)
2416 brNuParentDecX4 [0] = jnubeam_flux_info->
xpi[0];
2417 brNuParentDecX4 [1] = jnubeam_flux_info->
xpi[1];
2418 brNuParentDecX4 [2] = jnubeam_flux_info->
xpi[2];
2419 brNuParentDecX4 [3] = 0;
2421 brNuParentProP4 [0] = jnubeam_flux_info->
ppi0 * jnubeam_flux_info->
npi0[0];
2422 brNuParentProP4 [1] = jnubeam_flux_info->
ppi0 * jnubeam_flux_info->
npi0[1];
2423 brNuParentProP4 [2] = jnubeam_flux_info->
ppi0 * jnubeam_flux_info->
npi0[2];
2424 brNuParentProP4 [3] = TMath::Sqrt(
2425 TMath::Power(pdglib->
Find(brNuParentPdg)->Mass(), 2.)
2426 + TMath::Power(jnubeam_flux_info->
ppi0, 2.)
2428 brNuParentProX4 [0] = jnubeam_flux_info->
xpi0[0];
2429 brNuParentProX4 [1] = jnubeam_flux_info->
xpi0[1];
2430 brNuParentProX4 [2] = jnubeam_flux_info->
xpi0[2];
2431 brNuParentProX4 [3] = 0;
2433 brNuParentProNVtx = jnubeam_flux_info->
nvtx0;
2436 brNuFluxEntry = jnubeam_flux_info->
fluxentry;
2437 brNuIdfd = jnubeam_flux_info->
idfd;
2438 brNuCospibm = jnubeam_flux_info->
cospibm;
2439 brNuCospi0bm = jnubeam_flux_info->
cospi0bm;
2440 brNuGipart = jnubeam_flux_info->
gipart;
2441 brNuGamom0 = jnubeam_flux_info->
gamom0;
2442 for(
int k=0; k<3; k++){
2443 brNuGpos0[k] = (double) jnubeam_flux_info->
gpos0[k];
2444 brNuGvec0[k] = (
double) jnubeam_flux_info->
gvec0[k];
2447 brNuXnu[0] = (double) jnubeam_flux_info->
xnu;
2448 brNuXnu[1] = (
double) jnubeam_flux_info->
ynu;
2449 brNuRnu = (double) jnubeam_flux_info->
rnu;
2450 for(
int k=0; k<2; k++){
2451 brNuBpos[k] = (double) jnubeam_flux_info->
bpos[k];
2452 brNuBtilt[k] = (
double) jnubeam_flux_info->
btilt[k];
2453 brNuBrms[k] = (double) jnubeam_flux_info->
brms[k];
2454 brNuEmit[k] = (
double) jnubeam_flux_info->
emit[k];
2455 brNuAlpha[k] = (double) jnubeam_flux_info->
alpha[k];
2457 for(
int k=0; k<3; k++) brNuHcur[k] = jnubeam_flux_info->
hcur[k];
2458 for(
int np = 0; np < flux::fNgmax; np++){
2459 brNuGv[np][0] = jnubeam_flux_info->
gvx[np];
2460 brNuGv[np][1] = jnubeam_flux_info->
gvy[np];
2461 brNuGv[np][2] = jnubeam_flux_info->
gvz[np];
2462 brNuGp[np][0] = jnubeam_flux_info->
gpx[np];
2463 brNuGp[np][1] = jnubeam_flux_info->
gpy[np];
2464 brNuGp[np][2] = jnubeam_flux_info->
gpz[np];
2465 brNuGpid[np] = jnubeam_flux_info->
gpid[np];
2466 brNuGmec[np] = jnubeam_flux_info->
gmec[np];
2467 brNuGcosbm[np] = jnubeam_flux_info->
gcosbm[np];
2468 brNuGmat[np] = jnubeam_flux_info->
gmat[np];
2469 brNuGdistc[np] = jnubeam_flux_info->
gdistc[np];
2470 brNuGdistal[np] = jnubeam_flux_info->
gdistal[np];
2471 brNuGdistti[np] = jnubeam_flux_info->
gdistti[np];
2472 brNuGdistfe[np] = jnubeam_flux_info->
gdistfe[np];
2474 brNuNg = jnubeam_flux_info->
ng;
2475 brNuNorm = jnubeam_flux_info->
norm;
2476 brNuEnusk = jnubeam_flux_info->
Enusk;
2477 brNuNormsk = jnubeam_flux_info->
normsk;
2478 brNuAnorm = jnubeam_flux_info->
anorm;
2479 brNuVersion= jnubeam_flux_info->
version;
2480 brNuNtrig = jnubeam_flux_info->
ntrig;
2481 brNuTuneid = jnubeam_flux_info->
tuneid;
2482 brNuPint = jnubeam_flux_info->
pint;
2483 brNuRand = jnubeam_flux_info->
rand;
2484 brNuFileName =
new TObjString(jnubeam_flux_info->
fluxfilename.c_str());
2493 #ifdef __GENIE_FLUX_DRIVERS_ENABLED__
2496 if(gnumi_flux_info) {
2497 brNumiFluxRun = gnumi_flux_info->
run;
2498 brNumiFluxEvtno = gnumi_flux_info->
evtno;
2499 brNumiFluxNdxdz = gnumi_flux_info->
ndxdz;
2500 brNumiFluxNdydz = gnumi_flux_info->
ndydz;
2501 brNumiFluxNpz = gnumi_flux_info->
npz;
2502 brNumiFluxNenergy = gnumi_flux_info->
nenergy;
2503 brNumiFluxNdxdznea = gnumi_flux_info->
ndxdznea;
2504 brNumiFluxNdydznea = gnumi_flux_info->
ndydznea;
2505 brNumiFluxNenergyn = gnumi_flux_info->
nenergyn;
2506 brNumiFluxNwtnear = gnumi_flux_info->
nwtnear;
2507 brNumiFluxNdxdzfar = gnumi_flux_info->
ndxdzfar;
2508 brNumiFluxNdydzfar = gnumi_flux_info->
ndydzfar;
2509 brNumiFluxNenergyf = gnumi_flux_info->
nenergyf;
2510 brNumiFluxNwtfar = gnumi_flux_info->
nwtfar;
2511 brNumiFluxNorig = gnumi_flux_info->
norig;
2512 brNumiFluxNdecay = gnumi_flux_info->
ndecay;
2513 brNumiFluxNtype = gnumi_flux_info->
ntype;
2514 brNumiFluxVx = gnumi_flux_info->
vx;
2515 brNumiFluxVy = gnumi_flux_info->
vy;
2516 brNumiFluxVz = gnumi_flux_info->
vz;
2517 brNumiFluxPdpx = gnumi_flux_info->
pdpx;
2518 brNumiFluxPdpy = gnumi_flux_info->
pdpy;
2519 brNumiFluxPdpz = gnumi_flux_info->
pdpz;
2520 brNumiFluxPpdxdz = gnumi_flux_info->
ppdxdz;
2521 brNumiFluxPpdydz = gnumi_flux_info->
ppdydz;
2522 brNumiFluxPppz = gnumi_flux_info->
pppz;
2523 brNumiFluxPpenergy = gnumi_flux_info->
ppenergy;
2524 brNumiFluxPpmedium = gnumi_flux_info->
ppmedium;
2525 brNumiFluxPtype = gnumi_flux_info->
ptype;
2526 brNumiFluxPpvx = gnumi_flux_info->
ppvx;
2527 brNumiFluxPpvy = gnumi_flux_info->
ppvy;
2528 brNumiFluxPpvz = gnumi_flux_info->
ppvz;
2529 brNumiFluxMuparpx = gnumi_flux_info->
muparpx;
2530 brNumiFluxMuparpy = gnumi_flux_info->
muparpy;
2531 brNumiFluxMuparpz = gnumi_flux_info->
muparpz;
2532 brNumiFluxMupare = gnumi_flux_info->
mupare;
2533 brNumiFluxNecm = gnumi_flux_info->
necm;
2534 brNumiFluxNimpwt = gnumi_flux_info->
nimpwt;
2535 brNumiFluxXpoint = gnumi_flux_info->
xpoint;
2536 brNumiFluxYpoint = gnumi_flux_info->
ypoint;
2537 brNumiFluxZpoint = gnumi_flux_info->
zpoint;
2538 brNumiFluxTvx = gnumi_flux_info->
tvx;
2539 brNumiFluxTvy = gnumi_flux_info->
tvy;
2540 brNumiFluxTvz = gnumi_flux_info->
tvz;
2541 brNumiFluxTpx = gnumi_flux_info->
tpx;
2542 brNumiFluxTpy = gnumi_flux_info->
tpy;
2543 brNumiFluxTpz = gnumi_flux_info->
tpz;
2544 brNumiFluxTptype = gnumi_flux_info->
tptype;
2545 brNumiFluxTgen = gnumi_flux_info->
tgen;
2546 brNumiFluxTgptype = gnumi_flux_info->
tgptype;
2547 brNumiFluxTgppx = gnumi_flux_info->
tgppx;
2548 brNumiFluxTgppy = gnumi_flux_info->
tgppy;
2549 brNumiFluxTgppz = gnumi_flux_info->
tgppz;
2550 brNumiFluxTprivx = gnumi_flux_info->
tprivx;
2551 brNumiFluxTprivy = gnumi_flux_info->
tprivy;
2552 brNumiFluxTprivz = gnumi_flux_info->
tprivz;
2553 brNumiFluxBeamx = gnumi_flux_info->
beamx;
2554 brNumiFluxBeamy = gnumi_flux_info->
beamy;
2555 brNumiFluxBeamz = gnumi_flux_info->
beamz;
2556 brNumiFluxBeampx = gnumi_flux_info->
beampx;
2557 brNumiFluxBeampy = gnumi_flux_info->
beampy;
2558 brNumiFluxBeampz = gnumi_flux_info->
beampz;
2566 #ifdef __GENIE_HEAVY_NEUTRAL_LEPTON_ENABLED__
2567 if( gnumi_flux_ster ){
2568 iVars[1] = gnumi_flux_ster->
prodChan;
2569 iVars[2] = gnumi_flux_ster->
nuPdg;
2570 iVars[3] = gnumi_flux_ster->
lepPdg;
2572 dVars[4] = gnumi_flux_ster->
p4User.Px() / gnumi_flux_ster->
p4User.Pz();
2573 dVars[5] = gnumi_flux_ster->
p4User.Py() / gnumi_flux_ster->
p4User.Pz();
2574 dVars[6] = gnumi_flux_ster->
p4User.Pz();
2575 dVars[7] = gnumi_flux_ster->
nuEcm;
2576 dVars[8] = gnumi_flux_ster->
accCorr;
2578 #endif // #ifdef __GENIE_HEAVY_NEUTRAL_LEPTON_ENABLED__
2581 rootracker_tree->Fill();
2587 double pot = gtree->GetWeight();
2588 rootracker_tree->SetWeight(pot);
2592 TFolder * genv = (TFolder*) fin.Get(
"genv");
2593 TFolder * gconfig = (TFolder*) fin.Get(
"gconfig");
2595 genv ->
Write(
"genv");
2596 gconfig ->
Write(
"gconfig");
2604 LOG(
"gntpc",
pINFO) <<
"\nDone converting GENIE's GHEP ntuple";
2627 tree = dynamic_cast <TTree *> ( fin.Get(
"gtree") );
2630 LOG(
"gntpc",
pINFO) <<
"Input tree header: " << *thdr;
2634 tree->SetBranchAddress(
"gmcrec", &mcrec);
2641 TFile fout(
"ghad.root",
"recreate");
2642 TTree * ghad =
new TTree(
"ghad",
"");
2643 ghad->Branch(
"i", &brIev,
"i/I" );
2644 ghad->Branch(
"W", &brW,
"W/D" );
2645 ghad->Branch(
"n", &brN,
"n/I" );
2646 ghad->Branch(
"pdg", brPdg,
"pdg[n]/I" );
2647 ghad->Branch(
"E", brE,
"E[n]/D" );
2648 ghad->Branch(
"px", brPx,
"px[n]/D" );
2649 ghad->Branch(
"py", brPy,
"py[n]/D" );
2650 ghad->Branch(
"pz", brPz,
"pz[n]/D" );
2654 Long64_t nmax = (
gOptN<0) ?
2655 tree->GetEntries() : TMath::Min(tree->GetEntries(),
gOptN);
2657 LOG(
"gntpc",
pERROR) <<
"Number of events = 0";
2660 LOG(
"gntpc",
pNOTICE) <<
"*** Analyzing: " << nmax <<
" events";
2663 for(Long64_t iev = 0; iev < nmax; iev++) {
2664 tree->GetEntry(iev);
2673 for(
int k=0; k<
kNPmax; k++) {
2685 const Interaction * interaction =
event.Summary();
2693 bool pass = is_cc && (is_dis || is_res);
2699 int ccnc = is_cc ? 1 : 0;
2703 if (init_state.
IsNuP ()) im = 1;
2704 else if (init_state.
IsNuN ()) im = 2;
2705 else if (init_state.
IsNuBarP ()) im = 3;
2706 else if (init_state.
IsNuBarN ()) im = 4;
2718 int nupdg = neutrino->
Pdg();
2719 int fslpdg = fsl->
Pdg();
2720 int A = target->
A();
2721 int Z = target->
Z();
2723 const TLorentzVector & k1 = *(neutrino->
P4());
2724 const TLorentzVector & k2 = *(fsl->
P4());
2730 GHepParticle * hadsyst =
event.FinalStateHadronicSystem();
2732 ph = *(hadsyst->
P4());
2736 ph = *(hadres->
P4());
2740 bool get_selected =
true;
2741 double x = kine.
x (get_selected);
2742 double y = kine.
y (get_selected);
2743 double W = kine.
W (get_selected);
2747 TIter event_iter(&event);
2750 while ( (p = dynamic_cast<GHepParticle *>(event_iter.Next())) ) {
2754 if (pdg ==
kPdgString ) { hadmod=11; ihadmom=i; }
2755 if (pdg ==
kPdgCluster ) { hadmod=12; ihadmom=i; }
2756 if (pdg ==
kPdgIndep ) { hadmod=13; ihadmom=i; }
2760 output << iev <<
"\t"
2761 << nupdg <<
"\t" << ccnc <<
"\t" << im <<
"\t"
2762 << A <<
"\t" << Z << endl;
2763 output << inttyp <<
"\t" << x <<
"\t" << y <<
"\t" << W <<
"\t"
2765 output << nupdg <<
"\t"
2766 << k1.Px() <<
"\t" << k1.Py() <<
"\t" << k1.Pz() <<
"\t"
2767 << k1.Energy() <<
"\t" << k1.M() << endl;
2768 output << fslpdg <<
"\t"
2769 << k2.Px() <<
"\t" << k2.Py() <<
"\t" << k2.Pz() <<
"\t"
2770 << k2.Energy() <<
"\t" << k2.M() << endl;
2771 output << 111111 <<
"\t"
2772 << ph.Px() <<
"\t" << ph.Py() <<
"\t" << ph.Pz() <<
"\t"
2773 << ph.Energy() <<
"\t" << ph.M() << endl;
2779 while ( (p = dynamic_cast<GHepParticle *>(event_iter.Next())) ) {
2781 if(i<ihadmom)
continue;
2791 int mom_pdg = mom->
Pdg();
2793 if(!skip) { hadv.push_back(i); }
2799 output << hadv.size() << endl;
2808 vector<int>::const_iterator hiter = hadv.begin();
2809 for( ; hiter != hadv.end(); ++hiter) {
2812 int pdg = particle->
Pdg();
2813 double px = particle->
P4()->Px();
2814 double py = particle->
P4()->Py();
2815 double pz = particle->
P4()->Pz();
2816 double E = particle->
P4()->Energy();
2817 double m = particle->
P4()->M();
2818 output << pdg <<
"\t"
2819 << px <<
"\t" << py <<
"\t" << pz <<
"\t"
2820 << E <<
"\t" << m << endl;
2844 ghad->Write(
"ghad");
2849 LOG(
"gntpc",
pINFO) <<
"\nDone converting GENIE's GHEP ntuple";
2892 TTree * tEvtTree =
new TTree(
"ginuke",
"GENIE INuke Summary Tree");
2897 tEvtTree->Branch(
"iev", &brIEv,
"iev/I" );
2898 tEvtTree->Branch(
"probe", &brProbe,
"probe/I" );
2899 tEvtTree->Branch(
"tgt" , &brTarget,
"tgt/I" );
2900 tEvtTree->Branch(
"ke", &brKE,
"ke/D" );
2901 tEvtTree->Branch(
"e", &brE,
"e/D" );
2902 tEvtTree->Branch(
"p", &brP,
"p/D" );
2903 tEvtTree->Branch(
"A", &brTgtA,
"A/I" );
2904 tEvtTree->Branch(
"Z", &brTgtZ,
"Z/I" );
2905 tEvtTree->Branch(
"vtxx", &brVtxX,
"vtxx/D" );
2906 tEvtTree->Branch(
"vtxy", &brVtxY,
"vtxy/D" );
2907 tEvtTree->Branch(
"vtxz", &brVtxZ,
"vtxz/D" );
2908 tEvtTree->Branch(
"probe_fsi", &brProbeFSI,
"probe_fsi/I" );
2909 tEvtTree->Branch(
"dist", &brDist,
"dist/D" );
2910 tEvtTree->Branch(
"nh", &brNh,
"nh/I" );
2911 tEvtTree->Branch(
"pdgh", brPdgh,
"pdgh[nh]/I" );
2912 tEvtTree->Branch(
"Eh", brEh,
"Eh[nh]/D" );
2913 tEvtTree->Branch(
"ph", brPh,
"ph[nh]/D" );
2914 tEvtTree->Branch(
"pxh", brPxh,
"pxh[nh]/D" );
2915 tEvtTree->Branch(
"pyh", brPyh,
"pyh[nh]/D" );
2916 tEvtTree->Branch(
"pzh", brPzh,
"pzh[nh]/D" );
2917 tEvtTree->Branch(
"cth", brCosth,
"cth[nh]/D" );
2918 tEvtTree->Branch(
"mh", brMh,
"mh[nh]/D" );
2919 tEvtTree->Branch(
"np", &brNp,
"np/I" );
2920 tEvtTree->Branch(
"nn", &brNn,
"nn/I" );
2921 tEvtTree->Branch(
"npip", &brNpip,
"npip/I" );
2922 tEvtTree->Branch(
"npim", &brNpim,
"npim/I" );
2923 tEvtTree->Branch(
"npi0", &brNpi0,
"npi0/I" );
2927 TTree * er_tree = 0;
2929 er_tree = dynamic_cast <TTree *> ( fin.Get(
"gtree") );
2932 LOG(
"gntpc",
pERROR) <<
"Null input tree";
2935 LOG(
"gntpc",
pINFO) <<
"Input tree header: " << *thdr;
2939 er_tree->SetBranchAddress(
"gmcrec", &mcrec);
2941 LOG(
"gntpc",
pERROR) <<
"Null MC record";
2946 Long64_t nmax = (
gOptN<0) ?
2947 er_tree->GetEntries() : TMath::Min( er_tree->GetEntries(),
gOptN );
2949 LOG(
"gntpc",
pERROR) <<
"Number of events = 0";
2952 LOG(
"gntpc",
pNOTICE) <<
"*** Analyzing: " << nmax <<
" events";
2954 for(Long64_t iev = 0; iev < nmax; iev++) {
2956 er_tree->GetEntry(iev);
2967 for(
int j=0; j<
kNPmax; j++) {
2982 assert(probe && target);
2984 brProbe = probe -> Pdg();
2985 brTarget = target -> Pdg();
2986 brKE = probe -> KinE();
2988 brP = probe -> P4()->Vect().Mag();
2991 brVtxX = probe -> Vx();
2992 brVtxY = probe -> Vy();
2993 brVtxZ = probe -> Vz();
2994 brProbeFSI = probe -> RescatterCode();
2996 assert(rescattered_hadron);
3001 double x = rescattered_hadron->
Vx();
3002 double y = rescattered_hadron->
Vy();
3003 double z = rescattered_hadron->
Vz();
3004 double d2 = TMath::Power(brVtxX-x,2) +
3005 TMath::Power(brVtxY-y,2) +
3006 TMath::Power(brVtxZ-z,2);
3007 brDist = TMath::Sqrt(d2);
3018 TIter event_iter(&event);
3019 while ( (p = dynamic_cast<GHepParticle *>(event_iter.Next())) ) {
3023 brPdgh[i] = p->
Pdg();
3025 brPxh [i] = p->
Px();
3026 brPyh [i] = p->
Py();
3027 brPzh [i] = p->
Pz();
3029 TMath::Sqrt(brPxh[i]*brPxh[i]+brPyh[i]*brPyh[i]
3030 +brPzh[i]*brPzh[i]);
3031 brCosth[i] = brPzh[i]/brPh[i];
3032 brMh [i] = p->
Mass();
3045 int tempProbeFSI = brProbeFSI;
3046 brProbeFSI =
HAProbeFSI(tempProbeFSI, brProbe, brNh, brEh, brPdgh, brNpip, brNpim, brNpi0);
3062 LOG(
"gntpc",
pINFO) <<
"\nDone converting GENIE's GHEP ntuple";
3077 if( parser.OptionExists(
'i') ) {
3078 LOG(
"gntpc",
pINFO) <<
"Reading input filename";
3082 <<
"Unspecified input filename - Exiting";
3092 <<
"The input ROOT file ["
3099 if( parser.OptionExists(
'f') ) {
3100 LOG(
"gntpc",
pINFO) <<
"Reading output file format";
3101 string fmt = parser.ArgAsString(
'f');
3117 LOG(
"gntpc",
pFATAL) <<
"Unknown output file format (" << fmt <<
")";
3123 LOG(
"gntpc",
pFATAL) <<
"Unspecified output file format";
3129 if( parser.OptionExists(
'o') ) {
3130 LOG(
"gntpc",
pINFO) <<
"Reading output filename";
3134 <<
"Unspecified output filename - Using default";
3139 if( parser.OptionExists(
'n') ) {
3140 LOG(
"gntpc",
pINFO) <<
"Reading number of events to analyze";
3141 gOptN = parser.ArgAsInt(
'n');
3144 <<
"Unspecified number of events to analyze - Use all";
3149 if( parser.OptionExists(
'v') ) {
3150 LOG(
"gntpc",
pINFO) <<
"Reading format version number";
3156 <<
"Unspecified version number - Use latest";
3166 if( parser.OptionExists(
"seed") ) {
3167 LOG(
"gntpc",
pINFO) <<
"Reading random number seed";
3170 LOG(
"gntpc",
pINFO) <<
"Unspecified random number seed - Using default";
3178 LOG(
"gntpc",
pNOTICE) <<
"Number of events to be converted = " <<
gOptN;
3202 unsigned int L = inpname.length();
3206 if(inpname.substr(L-4, L).find(
"root") != string::npos) {
3207 inpname.erase(L-4, L);
3211 size_t pos = inpname.find(
"ghep.");
3212 if(pos != string::npos) {
3213 inpname.erase(pos, pos+4);
3217 name << inpname << ext;
3219 return gSystem->BaseName(name.str().c_str());
3241 string basedir = string( gSystem->Getenv(
"GENIE") );
3242 string thisfile = basedir + string(
"/src/Apps/gNtpConv.cxx");
3243 string cmd =
"less " + thisfile;
3245 gSystem->Exec(cmd.c_str());
3249 int HAProbeFSI(
int probe_fsi,
int probe_pdg,
int numh,
double E_had[],
int pdg_had[],
int numpip,
int numpim,
int numpi0)
3254 for(
int i=0; i<numh; i++)
3255 { energy += E_had[i]; }
3259 if (probe_fsi==3 && numh==1)
3261 else if (energy==E_had[0] && numh==1)
3263 else if (
pdg::IsPion(probe_pdg) && numpip+numpi0+numpim==0)
3265 else if ( (
pdg::IsNucleon(probe_pdg) && numpip+numpi0+numpim==0 && numh>2 )
3266 || (probe_pdg==
kPdgGamma && energy!=E_had[0] && numpip+numpi0+numpim==0))
3268 else if ( numpip+numpi0+numpim > (
pdg::IsPion(probe_pdg) ? 1 : 0) )
3272 for(
int i = 0; i < numh; i++)
3274 if ( (
pdg::IsPion(probe_pdg) && ( probe_pdg==pdg_had[i] ))
3286 for (
int iter = 0; iter < numh; iter++)
3288 if (probe_pdg==211 && pdg_had[iter]==-211) { index=8; undef=
false; }
3289 else if (probe_pdg==-211 && pdg_had[iter]==211) { index=8; undef=
false; }
3292 if (undef) { index=0; }
3300 #ifdef __GENIE_HEAVY_NEUTRAL_LEPTON_ENABLED__
3301 void DeclareHNLBranches( TTree * tree, TTree * intree,
3302 double * dVars,
int * iVars )
3304 tree->Branch(
"HNL_mass", &dVars[0],
"HNL_mass/D" );
3305 tree->Branch(
"HNL_coup_e", &dVars[1],
"HNL_coup_e/D" );
3306 tree->Branch(
"HNL_coup_m", &dVars[2],
"HNL_coup_m/D" );
3307 tree->Branch(
"HNL_coup_t", &dVars[3],
"HNL_coup_t/D" );
3308 tree->Branch(
"HNL_Majorana", &iVars[0],
"HNL_Majorana/O" );
3310 tree->Branch(
"NumiHNLFluxNdxdz", &dVars[4],
"NumiHNLFluxNdxdz/D" );
3311 tree->Branch(
"NumiHNLFluxNdydz", &dVars[5],
"NumiHNLFluxNdydz/D" );
3312 tree->Branch(
"NumiHNLFluxNpz", &dVars[6],
"NumiHNLFluxNpz/D" );
3313 tree->Branch(
"NumiHNLFluxNdecay", &iVars[1],
"NumiHNLFluxNdecay/I" );
3314 tree->Branch(
"NumiHNLFluxNtype", &iVars[2],
"NumiHNLFluxNtype/I" );
3315 tree->Branch(
"NumiHNLFluxLepPdg", &iVars[3],
"NumiHNLFluxLepPdg/I" );
3316 tree->Branch(
"NumiHNLFluxNecm", &dVars[7],
"NumiHNLFluxNecm/D" );
3317 tree->Branch(
"NumiHNLFluxAccCorr", &dVars[8],
"NumiHNLFluxAccCorr/D" );
3320 intree->SetBranchAddress(
"hnl_mass", &dVars[0] );
3321 intree->SetBranchAddress(
"hnl_coup_e", &dVars[1] );
3322 intree->SetBranchAddress(
"hnl_coup_m", &dVars[2] );
3323 intree->SetBranchAddress(
"hnl_coup_t", &dVars[3] );
3324 intree->SetBranchAddress(
"hnl_ismaj", &iVars[0] );
3326 #endif // #ifdef __GENIE_HEAVY_NEUTRAL_LEPTON_ENABLED__
bool IsResonant(void) const
void RandGen(long int seed)
static void SetPrintLevel(int print_level)
int NeutReactionCode(const GHepRecord *evrec)
double W(bool selected=false) const
int RescatterCode(void) const
int GenieMajorVrsNum(string tag)
bool IsParticle(int pdgc)
not ion or pseudo-particle
bool HitSeaQrk(void) const
bool IsWeakCC(void) const
bool IsNuBarN(void) const
is anti-neutrino + neutron?
NtpMCRecHeader hdr
record header
double nuEcm
Parent rest-frame energy of equivalent SM neutrino [GeV].
double E(void) const
Get energy.
void AddDarkMatter(double mass, double med_ratio)
static const double kNucleonMass
double Q2(const Interaction *const i)
static RandomGen * Instance()
Access instance.
void CustomizeFilename(string filename)
const TLorentzVector * P4(void) const
int FirstDaughter(void) const
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.
double PolzPolarAngle(void) const
int HitQrkPdg(void) const
bool IsInverseMuDecay(void) const
void ReadFromCommandLine(int argc, char **argv)
bool IsQuasiElastic(void) const
bool IsNuN(void) const
is neutrino + neutron?
int NuanceReactionCode(const GHepRecord *evrec)
int lepPdg
PDG code of lepton produced with HNL on parent decay.
bool gOptCopyJobMeta
copy MC job metadata (gconfig, genv TFolders)
int IonPdgCodeToA(int pdgc)
Generated/set kinematical variables for an event.
static constexpr double fs
A GENIE flux container specific for HNL containers. Based on the dk2nu flux paradigm and genie::flux:...
double x(bool selected=false) const
bool IsDiffractive(void) const
bool IsCoherentProduction(void) const
double Mass(void) const
Mass that corresponds to the PDG code.
bool IsIMDAnnihilation(void) const
static constexpr double MeV
A singleton holding random number generator classes. All random number generation in GENIE should tak...
string gOptInpFileName
input file name
double Pz(void) const
Get Pz.
string AsString(void) const
GHepStatus_t Status(void) const
bool IsHNLDecay(void) const
double Energy(void) const
Get energy.
int main(int argc, char **argv)
Contains minimal information for tagging exclusive processes.
void ConvertToGINuke(void)
double Px(void) const
Get Px.
double y(bool selected=false) const
int LastMother(void) const
bool IsCharmEvent(void) const
double Vt(void) const
Get production time.
bool IsSingleKaon(void) const
double W(const Interaction *const i)
int FirstMother(void) const
enum EGNtpcFmt GNtpcFmt_t
string Name(void) const
Name that corresponds to the PDG code.
int GenieMinorVrsNum(string tag)
Summary information for an interaction.
int GeantToPdg(int geant_code)
int LastDaughter(void) const
bool IsWeakNC(void) const
bool IsNuP(void) const
is neutrino + proton?
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
bool IsCoherentElastic(void) const
void ConvertToGRooTracker(void)
TLorentzVector p4User
HNL momentum in USER coords [GeV/c].
bool IsNuElectronElastic(void) const
static constexpr double A
static constexpr double cm2
A class encapsulating an enumeration of interaction types (EM, Weak-CC, Weak-NC) and scattering types...
bool IsAMNuGamma(void) const
TLorentzVector * GetP4(void) const
Long64_t gOptN
number of events to process
const Kinematics & Kine(void) const
A Neutrino Interaction Target. Is a transparent encapsulation of quite different physical systems suc...
int prodChan
Decay mode that produced HNL.
void Save(void)
get the even tree
bool CheckRootFilename(string filename)
void AddEventRecord(int ievent, const EventRecord *ev_rec)
save the event tree
Resonance_t Resonance(void) const
int HAProbeFSI(int, int, int, double[], int[], int, int, int)
GNtpcFmt_t gOptOutFileFormat
output file format id
bool PolzIsSet(void) const
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
bool IsDeepInelastic(void) const
double accCorr
acceptance correction (collimation effect. SM v == 1)
void Initialize(void)
add event
double KinE(bool mass_from_pdg=false) const
Get kinetic energy.
static PDGLibrary * Instance(void)
static RunOpt * Instance(void)
int GenieRevisVrsNum(string tag)
int gOptVersion
output file format version
A utility class to facilitate creating the GENIE MC Ntuple from the output GENIE GHEP event records...
int nuPdg
PDG code of SM neutrino that would have been produced.
Singleton class to load & serve a TDatabasePDG.
bool HitQrkIsSet(void) const
double Vz(void) const
Get production z.
const TLorentzVector * X4(void) const
const int kPdgAntiNeutron
void ConvertToGHepMock(void)
bool IsPseudoParticle(int pdgc)
const XclsTag & ExclTag(void) const
void ConvertToGTracker(void)
bool IsNuBarP(void) const
is anti-neutrino + proton?
TRandom3 & RndGen(void) const
rnd number generator for generic usage
virtual void AddParticle(const GHepParticle &p)
const InitialState & InitState(void) const
int LatestFormatVersionNumber(void)
const ProcessInfo & ProcInfo(void) const
double t(bool selected=false) const
int IonPdgCodeToZ(int pdgc)
void MesgThresholds(string inpfile)
TParticlePDG * Find(int pdgc, bool must_exist=true)
double Vy(void) const
Get production y.
Command line argument parser.
double Q2(bool selected=false) const
const Target & Tgt(void) const
void GetCommandLineArgs(int argc, char **argv)
double PolzAzimuthAngle(void) const
void Clear(Option_t *opt="")
static constexpr double ys
string DefaultOutputFile(void)
const int kPdgHadronicSyst
static constexpr double m
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
STDHEP-like event record entry that can fit a particle or a nucleus.
enum genie::EGHepStatus GHepStatus_t
double Vx(void) const
Get production x.
Initial State information.
double Py(void) const
Get Py.