LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
GENIE2ART.cxx
Go to the documentation of this file.
1 
11 #include "GENIE2ART.h"
12 //#include <math.h>
13 //#include <map>
14 //#include <fstream>
15 #include <memory> // for unique_ptr
16 #include <typeinfo>
17 
18 // ROOT includes
19 #include "TVector3.h"
20 #include "TLorentzVector.h"
21 #include "TSystem.h"
22 
23 //GENIE includes
24 #include "Conventions/Units.h"
25 #include "EVGCore/EventRecord.h"
26 #include "GHEP/GHepUtils.h"
27 #include "PDG/PDGCodes.h"
28 #include "PDG/PDGLibrary.h"
29 
30 #include "Interaction/InitialState.h"
31 #include "Interaction/Interaction.h"
32 #include "Interaction/Kinematics.h"
33 #include "Interaction/KPhaseSpace.h"
34 #include "Interaction/ProcessInfo.h"
35 #include "Interaction/XclsTag.h"
36 #include "GHEP/GHepParticle.h"
37 #include "PDG/PDGCodeList.h"
38 #include "Conventions/Constants.h" //for calculating event kinematics
39 
40 // GENIE
41 #include "EVGDrivers/GFluxI.h"
42 #include "FluxDrivers/GFluxBlender.h"
43 #include "FluxDrivers/GNuMIFlux.h"
44 #include "FluxDrivers/GSimpleNtpFlux.h"
45 
46 #ifndef ART_V1
52 #else
53  #include "SimulationBase/MCTruth.h"
56  #include "SimulationBase/GTruth.h"
57  #include "SimulationBase/MCFlux.h"
58 #endif
59 
60 // dk2nu
61 #include "dk2nu/tree/dk2nu.h"
62 #include "dk2nu/tree/NuChoice.h"
63 #include "dk2nu/tree/dkmeta.h"
64 #include "dk2nu/genie/GDk2NuFlux.h"
65 
67 
68 //---------------------------------------------------------------------------
69 //choose a spill time (ns) to shift the vertex times by:
70 // double spillTime = fGlobalTimeOffset +
71 // fHelperRandom->Uniform()*fRandomTimeOffset;
72 
73 void evgb::FillMCTruth(const genie::EventRecord *record, double spillTime,
74  simb::MCTruth &truth)
75 {
76  TLorentzVector vtxOffset(0,0,0,spillTime);
77  FillMCTruth(record,vtxOffset,truth);
78 }
79 
80 void evgb::FillMCTruth(const genie::EventRecord *record,
81  TLorentzVector &vtxOffset,
82  simb::MCTruth &truth)
83 {
84  TLorentzVector *vertex = record->Vertex();
85 
86  // get the Interaction object from the record - this is the object
87  // that talks to the event information objects and is in m
88  const genie::Interaction *inter = record->Summary();
89 
90  // get the different components making up the interaction
91  const genie::InitialState &initState = inter->InitState();
92  const genie::ProcessInfo &procInfo = inter->ProcInfo();
93 
94  //const genie::Kinematics &kine = inter->Kine();
95  //const genie::XclsTag &exclTag = inter->ExclTag();
96  //const genie::KPhaseSpace &phaseSpace = inter->PhaseSpace();
97 
98  // add the particles from the interaction
99  TIter partitr(record);
100  genie::GHepParticle *part = 0;
101  // GHepParticles return units of GeV/c for p. the V_i are all in fermis
102  // and are relative to the center of the struck nucleus.
103  // add the vertex X/Y/Z to the V_i for status codes 0 and 1
104  int trackid = 0;
105  std::string primary("primary");
106 
107  while( (part = dynamic_cast<genie::GHepParticle *>(partitr.Next())) ){
108 
109  simb::MCParticle tpart(trackid,
110  part->Pdg(),
111  primary,
112  part->FirstMother(),
113  part->Mass(),
114  part->Status());
115  double vtx[4] = {part->Vx(), part->Vy(), part->Vz(), part->Vt()};
116  /*
117  if ( vtx[0] == 0 &&
118  vtx[1] == 0 &&
119  vtx[2] == 0 &&
120  vtx[3] == 0 ) {
121  //mf::LogInfo("GENIEHelper") << "tweak vtx[3] for MCParticle";
122  vtx[3] = 1.0e-30;
123  }
124  */
125  tpart.SetGvtx(vtx);
126  tpart.SetRescatter(part->RescatterCode());
127 
128  // set the vertex location for the neutrino, nucleus and everything
129  // that is to be tracked. vertex returns values in meters.
130  if (part->Status() == 0 || part->Status() == 1){
131  vtx[0] = 100.*(part->Vx()*1.e-15 + vertex->X() + vtxOffset.X());
132  vtx[1] = 100.*(part->Vy()*1.e-15 + vertex->Y() + vtxOffset.Y());
133  vtx[2] = 100.*(part->Vz()*1.e-15 + vertex->Z() + vtxOffset.Z());
134  vtx[3] = part->Vt() + vtxOffset.T();
135  }
136  TLorentzVector pos(vtx[0], vtx[1], vtx[2], vtx[3]);
137  TLorentzVector mom(part->Px(), part->Py(), part->Pz(), part->E());
138  tpart.AddTrajectoryPoint(pos,mom);
139  if (part->PolzIsSet()) {
140  TVector3 polz;
141  part->GetPolarization(polz);
142  tpart.SetPolarization(polz);
143  }
144  truth.Add(tpart);
145 
146  ++trackid;
147  }// end loop to convert GHepParticles to MCParticles
148 
149  // is the interaction NC or CC
150  int CCNC = simb::kCC;
151  if (procInfo.IsWeakNC()) CCNC = simb::kNC;
152 
153  // what is the interaction type
154  int mode = simb::kUnknownInteraction;
155 
156  if (procInfo.IsQuasiElastic() ) mode = simb::kQE;
157  else if (procInfo.IsDeepInelastic() ) mode = simb::kDIS;
158  else if (procInfo.IsResonant() ) mode = simb::kRes;
159  else if (procInfo.IsCoherent() ) mode = simb::kCoh;
160  else if (procInfo.IsCoherentElas() ) mode = simb::kCohElastic;
161  else if (procInfo.IsElectronScattering() ) mode = simb::kElectronScattering;
162  else if (procInfo.IsNuElectronElastic() ) mode = simb::kNuElectronElastic;
163  else if (procInfo.IsInverseMuDecay() ) mode = simb::kInverseMuDecay;
164  else if (procInfo.IsIMDAnnihilation() ) mode = simb::kIMDAnnihilation;
165  else if (procInfo.IsInverseBetaDecay() ) mode = simb::kInverseBetaDecay;
166  else if (procInfo.IsGlashowResonance() ) mode = simb::kGlashowResonance;
167  else if (procInfo.IsAMNuGamma() ) mode = simb::kAMNuGamma;
168  else if (procInfo.IsMEC() ) mode = simb::kMEC;
169  else if (procInfo.IsDiffractive() ) mode = simb::kDiffractive;
170  else if (procInfo.IsEM() ) mode = simb::kEM;
171  else if (procInfo.IsWeakMix() ) mode = simb::kWeakMix;
172 
173  int itype = simb::kNuanceOffset + genie::utils::ghep::NuanceReactionCode(record);
174 
175  // set the neutrino information in MCTruth
177 
178  // The genie event kinematics are subtle different from the event
179  // kinematics that a experimentalist would calculate
180  // Instead of retriving the genie values for these kinematic variables
181  // calcuate them from the the final state particles
182  // while ingnoring the fermi momentum and the off-shellness of the bound nucleon.
183  genie::GHepParticle * hitnucl = record->HitNucleon();
184  TLorentzVector pdummy(0, 0, 0, 0);
185  // these don't exist if it came from nucleon decay .. RWH
186  const TLorentzVector v4_null;
187  genie::GHepParticle* probe = record->Probe();
188  genie::GHepParticle* finallepton = record->FinalStatePrimaryLepton();
189  const TLorentzVector & k1 = ( probe ? *(probe->P4()) : v4_null );
190  const TLorentzVector & k2 = ( finallepton ? *(finallepton->P4()) : v4_null );
191 
192 #ifdef OLD_KINE_CALC
193  //const TLorentzVector & p1 = (hitnucl) ? *(hitnucl->P4()) : pdummy;
194 
195  double M = genie::constants::kNucleonMass;
196  TLorentzVector q = k1-k2; // q=k1-k2, 4-p transfer
197  double Q2 = -1 * q.M2(); // momemtum transfer
198  double v = (hitnucl) ? q.Energy() : -1; // v (E transfer to the nucleus)
199  double x = (hitnucl) ? 0.5*Q2/(M*v) : -1; // Bjorken x
200  double y = (hitnucl) ? v/k1.Energy() : -1; // Inelasticity, y = q*P1/k1*P1
201  double W2 = (hitnucl) ? M*M + 2*M*v - Q2 : -1; // Hadronic Invariant mass ^ 2
202  double W = (hitnucl) ? std::sqrt(W2) : -1;
203 #else
204  // (same strategy as in gNtpConv.cxx::ConvertToGST().)
205 
206  // also note that since most of these variables are calculated purely
207  // from the leptonic system, they have meaning in reactions that didn't
208  // strike a nucleon (or even a hadron) as well.
209  TLorentzVector q = k1-k2; // q=k1-k2, 4-p transfer
210 
211  double Q2 = -1 * q.M2(); // momemtum transfer
212  double v = q.Energy(); // v (E transfer to the had system)
213  double y = v/k1.Energy(); // Inelasticity, y = q*P1/k1*P1
214  double x, W2, W;
215  x = W2 = W = -1;
216 
217  if ( hitnucl || procInfo.IsCoherent() ) {
218  const double M = genie::constants::kNucleonMass;
219  // Bjorken x.
220  // Rein & Sehgal use this same formulation of x even for Coherent
221  x = 0.5*Q2/(M*v);
222  // Hadronic Invariant mass ^ 2.
223  // ("wrong" for Coherent, but it's "experimental", so ok?)
224  W2 = M*M + 2*M*v - Q2;
225  W = std::sqrt(W2);
226  }
227 #endif
228 
229  truth.SetNeutrino(CCNC,
230  mode,
231  itype,
232  initState.Tgt().Pdg(),
233  initState.Tgt().HitNucPdg(),
234  initState.Tgt().HitQrkPdg(),
235  W,
236  x,
237  y,
238  Q2);
239  return;
240 }
241 
242 //---------------------------------------------------------------------------
243 void evgb::FillGTruth(const genie::EventRecord* record,
244  simb::GTruth& truth) {
245 
246  //interactions info
247  genie::Interaction *inter = record->Summary();
248  const genie::ProcessInfo &procInfo = inter->ProcInfo();
249  truth.fGint = (int)procInfo.InteractionTypeId();
250  truth.fGscatter = (int)procInfo.ScatteringTypeId();
251 
252  //Event info
253  truth.fweight = record->Weight();
254  truth.fprobability = record->Probability();
255  truth.fXsec = record->XSec();
256  truth.fDiffXsec = record->DiffXSec();
257  truth.fGPhaseSpace = (int)record->DiffXSecVars();
258 
259  TLorentzVector vtx;
260  TLorentzVector *erVtx = record->Vertex();
261  vtx.SetXYZT(erVtx->X(), erVtx->Y(), erVtx->Z(), erVtx->T() );
262  truth.fVertex = vtx;
263 
264  //true reaction information and byproducts
265  //(PRE FSI)
266  const genie::XclsTag &exclTag = inter->ExclTag();
267  truth.fIsCharm = exclTag.IsCharmEvent();
268  truth.fResNum = (int)exclTag.Resonance();
269 
270  //note that in principle this information could come from the XclsTag,
271  //but that object isn't completely filled for most reactions,
272  //at least for GENIE <= 2.12
273 // truth.fNumPiPlus = exclTag.NPiPlus();
274 // truth.fNumPiMinus = exclTag.NPiMinus();
275 // truth.fNumPi0 = exclTag.NPi0();
276 // truth.fNumProton = exclTag.NProtons();
277 // truth.fNumNeutron = exclTag.NNucleons();
278  truth.fNumPiPlus = truth.fNumPiMinus = truth.fNumPi0 = truth.fNumProton = truth.fNumNeutron = 0;
279  for (int idx = 0; idx < record->GetEntries(); idx++)
280  {
281  // want hadrons that are about to be sent to the FSI model
282  const genie::GHepParticle * particle = record->Particle(idx);
283  if (particle->Status() != genie::kIStHadronInTheNucleus)
284  continue;
285 
286  int pdg = particle->Pdg();
287  if (pdg == genie::kPdgPi0)
288  truth.fNumPi0++;
289  else if (pdg == genie::kPdgPiP)
290  truth.fNumPiPlus++;
291  else if (pdg == genie::kPdgPiM)
292  truth.fNumPiMinus++;
293  else if (pdg == genie::kPdgNeutron)
294  truth.fNumNeutron++;
295  else if (pdg == genie::kPdgProton)
296  truth.fNumProton++;
297  } // for (idx)
298 
299  // Get the GENIE kinematics info
300  const genie::Kinematics &kine = inter->Kine();
301  // RWH: really should be looping of GENIE Conventions/KineVar_t enum
302  // and only recording/resetting those that were originally there ...
303  truth.fgQ2 = kine.Q2(true);
304  truth.fgq2 = kine.q2(true);
305  truth.fgW = kine.W(true);
306  if ( kine.KVSet(genie::kKVSelt) ) {
307  // only get this if it is set in the Kinematics class
308  // to avoid a warning message
309  truth.fgT = kine.t(true);
310  }
311  truth.fgX = kine.x(true);
312  truth.fgY = kine.y(true);
313 
314  /*
315  truth.fgQ2 = kine.Q2(false);
316  truth.fgW = kine.W(false);
317  truth.fgT = kine.t(false);
318  truth.fgX = kine.x(false);
319  truth.fgY = kine.y(false);
320  */
321  truth.fFShadSystP4 = kine.HadSystP4();
322 
323  //Initial State info
324  const genie::InitialState &initState = inter->InitState();
325  truth.fProbePDG = initState.ProbePdg();
326  truth.fProbeP4 = *initState.GetProbeP4();
327 
328  //Target info
329  const genie::Target &tgt = initState.Tgt();
330  truth.fIsSeaQuark = tgt.HitSeaQrk();
331  truth.fHitNucP4 = tgt.HitNucP4();
332  truth.ftgtZ = tgt.Z();
333  truth.ftgtA = tgt.A();
334  truth.ftgtPDG = tgt.Pdg();
335 
336  return;
337 
338 }
339 
340 //---------------------------------------------------------------------------
341 genie::EventRecord* evgb::RetrieveGHEP(const simb::MCTruth& mctruth,
342  const simb::GTruth& gtruth,
343  bool useFirstTrajPosition)
344 {
345  genie::EventRecord* newEvent = new genie::EventRecord;
346 
347  newEvent->SetWeight(gtruth.fweight);
348  newEvent->SetProbability(gtruth.fprobability);
349  newEvent->SetXSec(gtruth.fXsec);
350 
351  genie::KinePhaseSpace_t space = (genie::KinePhaseSpace_t)gtruth.fGPhaseSpace;
352 
353  newEvent->SetDiffXSec(gtruth.fDiffXsec,space);
354 
355  TLorentzVector vtx = gtruth.fVertex;
356  newEvent->SetVertex(vtx);
357 
358  //mf::LogWarning("GENIE2ART")
359  // << "####### mctruth.NParticles() " << mctruth.NParticles();
360 
361  for (int i = 0; i < mctruth.NParticles(); i++) {
362  simb::MCParticle mcpart = mctruth.GetParticle(i);
363 
364  int gmid = mcpart.PdgCode();
365  genie::GHepStatus_t gmst = (genie::GHepStatus_t)mcpart.StatusCode();
366  int gmmo = mcpart.Mother();
367  int gmfd = -1;
368  int gmld = -1;
369 
370  /*
371  // GENIE will update daughter references as particles are added
372  // without a need to jump through these hoops ... which gets
373  // it wrong anyway (always sets 0th particles daughter to
374  // mctruth.NParticles()-1, and leave the others at -1 (which then
375  // GENIE handles correctly ...
376 
377  int ndaughters = mcpart.NumberDaughters();
378  //find the track ID of the first and last daughter particles
379  int fdtrkid = 0;
380  int ldtrkid = 0;
381  if (ndaughters !=0) {
382  fdtrkid = mcpart.Daughter(0);
383  if (ndaughters == 1) {
384  ldtrkid = 1;
385  }
386  else if (ndaughters >1) {
387  fdtrkid = mcpart.Daughter(ndaughters-1);
388  }
389  }
390 
391  // Genie uses the index in the particle array to reference
392  // the daughter particles.
393  // MCTruth keeps the particles in the same order so use the
394  // track ID to find the proper index.
395  for (int j = 0; j < mctruth.NParticles(); j++) {
396  simb::MCParticle temp = mctruth.GetParticle(i);
397  if (temp.TrackId() == fdtrkid) {
398  gmfd = j;
399  }
400  if (temp.TrackId() == ldtrkid) {
401  gmld = j;
402  }
403  }
404  */
405 
406  double gmpx = mcpart.Px(0);
407  double gmpy = mcpart.Py(0);
408  double gmpz = mcpart.Pz(0);
409  double gme = mcpart.E(0);
410 
411  double gmvx = mcpart.Gvx();
412  double gmvy = mcpart.Gvy();
413  double gmvz = mcpart.Gvz();
414  double gmvt = mcpart.Gvt();
415  bool GvtxFunky = false;
416  if ( gmvx == 0 && gmvy == 0 &&
417  gmvz == 0 && gmvt == 0 ) GvtxFunky = true;
418  if ( gmvx == simb::GTruth::kUndefinedValue &&
421  gmvt == simb::GTruth::kUndefinedValue ) GvtxFunky = true;
422  if (GvtxFunky) {
423  static int nmsg = 0; // don't warn about this for now
424  if (nmsg > 0) {
425  --nmsg;
426  std::string andOut = "";
427  if (nmsg == 0 ) andOut = "... last of such messages";
428  mf::LogWarning("GENIE2ART")
429  << "RetrieveGHEP(simb::MCTruth,simb::Gtruth) ... Gv[xyzt] all "
430  << gmvx << " for index " << i
431  << "; probably not filled ..."
432  << andOut << std::endl;
433  }
434  // MCParticle Vx(), Vy(), Vz() implicitly are index=0
435  // put it's likely we want the _last_ position ...
436  const TLorentzVector mcpartTrjPos =
437  ( useFirstTrajPosition ) ? mcpart.Position() : // default indx=0
438  mcpart.EndPosition();
439  unsigned int nTrj = mcpart.NumberTrajectoryPoints();
440  if ( nTrj < 1 ) // || nTrj > 1 )
441  mf::LogWarning("GENIE2ART") << "############### nTrj = " << nTrj;
442 
443  // set the vertex location for the neutrino, nucleus and everything
444  // that is to be tracked. vertex returns values in meters.
445  if ( mcpart.StatusCode() == 0 || mcpart.StatusCode() == 1 ){
446  // inverse of this....
447  // mcpartvtx[0] = 100.*(gpart->Vx()*1.e-15 + vertex->X());
448  // mcpartvtx[1] = 100.*(gpart->Vy()*1.e-15 + vertex->Y());
449  // mcpartvtx[2] = 100.*(gpart->Vz()*1.e-15 + vertex->Z());
450  // mcpartvtx[3] = gpart->Vt() + spillTime;
451  // local "vtx" is equiv to "vertex" ; solve for (genie)part->V
452  gmvx = 1.e15*((mcpartTrjPos.X()*1.e-2) - vtx.X());
453  gmvy = 1.e15*((mcpartTrjPos.Y()*1.e-2) - vtx.Y());
454  gmvz = 1.e15*((mcpartTrjPos.Z()*1.e-2) - vtx.Z());
455  gmvt = mcpartTrjPos.T() - vtx.T();
456  } else {
457  gmvx = mcpartTrjPos.X();
458  gmvy = mcpartTrjPos.Y();
459  gmvz = mcpartTrjPos.Z();
460  gmvt = mcpartTrjPos.T();
461  }
462 
463  } // if Gv[xyzt] seem unset
464 
465  int gmri = mcpart.Rescatter();
466 
467  genie::GHepParticle gpart(gmid, gmst, gmmo, -1, gmfd, gmld,
468  gmpx, gmpy, gmpz, gme, gmvx, gmvy, gmvz, gmvt);
469  gpart.SetRescatterCode(gmri);
470  TVector3 polz = mcpart.Polarization();
471  if (polz.x() !=0 || polz.y() !=0 || polz.z() !=0) {
472  gpart.SetPolarization(polz);
473  }
474  newEvent->AddParticle(gpart);
475  }
476 
477  genie::ProcessInfo proc_info;
478  genie::ScatteringType_t gscty = (genie::ScatteringType_t)gtruth.fGscatter;
479  genie::InteractionType_t ginty = (genie::InteractionType_t)gtruth.fGint;
480 
481  proc_info.Set(gscty,ginty);
482 
483  genie::XclsTag gxt;
484 
485  //Set Exclusive Final State particle numbers
486  genie::Resonance_t gres = (genie::Resonance_t)gtruth.fResNum;
487  gxt.SetResonance(gres);
488  gxt.SetNPions(gtruth.fNumPiPlus, gtruth.fNumPi0, gtruth.fNumPiMinus);
489  gxt.SetNNucleons(gtruth.fNumProton, gtruth.fNumNeutron);
490 
491  if (gtruth.fIsCharm) {
492  gxt.SetCharm(0);
493  }
494  else {
495  gxt.UnsetCharm();
496  }
497 
498  // Set the GENIE kinematics info
499  genie::Kinematics gkin;
500  // RWH: really should be looping of GENIE Conventions/KineVar_t enum
501  // and only recording/resetting those that were originally there ...
502  const double flagVal = -99999;
503  if ( gtruth.fgX != flagVal) gkin.Setx(gtruth.fgX, true);
504  if ( gtruth.fgY != flagVal) gkin.Sety(gtruth.fgY, true);
505  if ( gtruth.fgT != flagVal) gkin.Sett(gtruth.fgT, true);
506  if ( gtruth.fgW != flagVal) gkin.SetW(gtruth.fgW, true);
507  if ( gtruth.fgQ2 != flagVal) gkin.SetQ2(gtruth.fgQ2, true);
508  if ( gtruth.fgq2 != flagVal) gkin.Setq2(gtruth.fgq2, true);
509  simb::MCNeutrino nu = mctruth.GetNeutrino();
510  simb::MCParticle lep = nu.Lepton();
511  // is this even real?
512  if ( lep.NumberTrajectoryPoints() > 0 ) {
513  gkin.SetFSLeptonP4(lep.Px(), lep.Py(), lep.Pz(), lep.E());
514  }
515  gkin.SetHadSystP4(gtruth.fFShadSystP4.Px(),
516  gtruth.fFShadSystP4.Py(),
517  gtruth.fFShadSystP4.Pz(),
518  gtruth.fFShadSystP4.E());
519 
520  // reordering this to avoid warning (A=0,Z=0)
521  int probe_pdgc = gtruth.fProbePDG;
522  int tgtZ = gtruth.ftgtZ;
523  int tgtA = gtruth.ftgtA;
524 
525  //std::cerr << " tgtZ " << tgtZ << " tgtA " << tgtA << " probe " << probe_pdgc << std::endl;
526 
527  // genie::InitialState::Init() will fail if target_pdgc or probe_pdgc
528  // come back with nothign from PDGLibrary::Instance()->Find()
529  // fake it ... (what does nucleon decay do here??)
530  if ( tgtZ == 0 || tgtA == 0 ) { tgtZ = tgtA = 1; } // H1
531  if ( probe_pdgc == 0 || probe_pdgc == -1 ) { probe_pdgc = 22; } // gamma
532 
533  //std::cerr << " tgtZ " << tgtZ << " tgtA " << tgtA << " probe " << probe_pdgc << std::endl;
534 
535  int target_pdgc = genie::pdg::IonPdgCode(tgtA,tgtZ);
536 
537  /*
538  TParticlePDG * t = genie::PDGLibrary::Instance()->Find(target_pdgc);
539  TParticlePDG * p = genie::PDGLibrary::Instance()->Find(probe_pdgc );
540 
541  std::cerr << " target " << target_pdgc << " t " << t << " p " << p << std::endl;
542  */
543 
544  int targetNucleon = nu.HitNuc();
545  int struckQuark = nu.HitQuark();
546 
547  //genie::Target tmptgt(gtruth.ftgtZ, gtruth.ftgtA, targetNucleon);
548  // this ctor doesn't copy the state of the Target beyond the PDG value!
549  // so don't bother creating a tmptgt ...
550  //genie::InitialState ginitstate(tmptgt,probe_pdgc);
551 
552  genie::InitialState ginitstate(target_pdgc,probe_pdgc);
553 
554  // do this here _after_ creating InitialState
555  genie::Target* tgtptr = ginitstate.TgtPtr();
556  tgtptr->SetHitNucPdg(targetNucleon);
557  tgtptr->SetHitQrkPdg(struckQuark);
558  tgtptr->SetHitSeaQrk(gtruth.fIsSeaQuark);
559 
560  if (newEvent->HitNucleonPosition() >= 0) {
561  genie::GHepParticle * hitnucleon = newEvent->HitNucleon();
562  std::unique_ptr<TLorentzVector> p4hitnucleon(hitnucleon->GetP4());
563  tgtptr->SetHitNucP4(*p4hitnucleon);
564  } else {
565  if ( targetNucleon != 0 ) {
566  mf::LogWarning("GENIE2ART")
567  << "evgb::RetrieveGHEP() no hit nucleon position "
568  << " but targetNucleon is " << targetNucleon
569  << " at " << __FILE__ << ":" << __LINE__
570  << std::endl << std::flush;
571  }
572  TLorentzVector dummy(0.,0.,0.,0.);
573  tgtptr->SetHitNucP4(dummy);
574  }
575 
576  if (newEvent->TargetNucleusPosition() >= 0) {
577  genie::GHepParticle * target = newEvent->TargetNucleus();
578  std::unique_ptr<TLorentzVector> p4target(target->GetP4());
579  ginitstate.SetTgtP4(*p4target);
580  } else {
581  double Erest = 0.;
582  if ( gtruth.ftgtPDG != 0 ) {
583  TParticlePDG* ptmp = genie::PDGLibrary::Instance()->Find(gtruth.ftgtPDG);
584  if ( ptmp ) Erest = ptmp->Mass();
585  } else {
586  mf::LogWarning("GENIE2ART")
587  << "evgb::RetrieveGHEP() no target nucleus position "
588  << " but gtruth.ftgtPDG is " << gtruth.ftgtPDG
589  << " at " << __FILE__ << ":" << __LINE__
590  << std::endl << std::flush;
591  }
592  TLorentzVector dummy(0.,0.,0.,Erest);
593  ginitstate.SetTgtP4(dummy);
594  }
595 
596  genie::GHepParticle * probe = newEvent->Probe();
597  if ( probe ) {
598  std::unique_ptr<TLorentzVector> p4probe(probe->GetP4());
599  ginitstate.SetProbeP4(*p4probe);
600  } else {
601  // this can happen ...
602  mf::LogDebug("GENIE2ART")
603  << "evgb::RetrieveGHEP() no probe "
604  << " at " << __FILE__ << ":" << __LINE__
605  << std::endl << std::flush;
606  TLorentzVector dummy(0.,0.,0.,0.);
607  ginitstate.SetProbeP4(dummy);
608  }
609 
610  genie::Interaction * p_gint = new genie::Interaction(ginitstate,proc_info);
611 
612  p_gint->SetProcInfo(proc_info);
613  p_gint->SetKine(gkin);
614  p_gint->SetExclTag(gxt);
615  newEvent->AttachSummary(p_gint);
616 
617  /*
618  //For temporary debugging purposes
619  genie::Interaction *inter = newEvent->Summary();
620  const genie::InitialState &initState = inter->InitState();
621  const genie::Target &tgt = initState.Tgt();
622  std::cout << "TargetPDG as Recorded: " << gtruth.ftgtPDG << std::endl;
623  std::cout << "TargetZ as Recorded: " << gtruth.ftgtZ << std::endl;
624  std::cout << "TargetA as Recorded: " << gtruth.ftgtA << std::endl;
625  std::cout << "TargetPDG as Recreated: " << tgt.Pdg() << std::endl;
626  std::cout << "TargetZ as Recreated: " << tgt.Z() << std::endl;
627  std::cout << "TargetA as Recreated: " << tgt.A() << std::endl;
628  */
629 
630  return newEvent;
631 
632 }
633 
634 //---------------------------------------------------------------------------
635 void evgb::FillMCFlux(genie::GFluxI* fdriver, simb::MCFlux& mcflux)
636 {
637  // is the real driver hidden behind a blender?
638  genie::flux::GFluxBlender* gblender =
639  dynamic_cast<genie::flux::GFluxBlender *>(fdriver);
640  if ( gblender ) {
641  // it is, it is ... proceed with that ...
642  fdriver = gblender->GetFluxGenerator();
643  }
644 
645  genie::flux::GNuMIFlux* gnumi =
646  dynamic_cast<genie::flux::GNuMIFlux *>(fdriver);
647  if ( gnumi ) {
648  FillMCFlux(gnumi,mcflux);
649  return;
650  } else {
651  genie::flux::GSimpleNtpFlux* gsimple =
652  dynamic_cast<genie::flux::GSimpleNtpFlux *>(fdriver);
653  if ( gsimple ) {
654  FillMCFlux(gsimple,mcflux);
655  return;
656  } else {
657  genie::flux::GDk2NuFlux* gdk2nu =
658  dynamic_cast<genie::flux::GDk2NuFlux *>(fdriver);
659  if ( gdk2nu ) {
660  FillMCFlux(gdk2nu,mcflux);
661  return;
662  } else {
663  static bool first = true;
664  if ( first ) {
665  first = false;
666  std::string dname = typeid(*fdriver).name();
667  // can't use fdriver->GetClass()->GetName(); not derived from TObject
668  mf::LogInfo("GENIE2ART")
669  << " " << __FILE__ << ":" << __LINE__ << "\n"
670  << " no FillMCFlux() for this flux driver: "
671  << dname
672  << " (typeid.name, use \"c++filt -t\" to demangle)"
673  << std::endl;
674  // atmospheric fluxes don't have a method for FillMCFLux
675  // don't abort ... just note the problem, once // abort();
676  }
677  }
678  }
679  }
680 }
681 
682 //---------------------------------------------------------------------------
683 
684 void evgb::FillMCFlux(genie::flux::GNuMIFlux* gnumi,
685  simb::MCFlux& flux)
686 {
687  const genie::flux::GNuMIFluxPassThroughInfo& numiflux =
688  gnumi->PassThroughInfo();
689  const genie::flux::GNuMIFluxPassThroughInfo* nflux = &numiflux;
690  double dk2gen = gnumi->GetDecayDist();
691  evgb::FillMCFlux(nflux,dk2gen,flux);
692 }
693 void evgb::FillMCFlux(const genie::flux::GNuMIFluxPassThroughInfo* nflux,
694  double dk2gen,
695  simb::MCFlux& flux)
696 {
697  flux.Reset();
698  flux.fFluxType = simb::kNtuple;
699 
700  // check the particle codes and the units passed through
701  // nflux->pcodes: 0=original GEANT particle codes, 1=converted to PDG
702  // nflux->units: 0=original GEANT cm, 1=meters
703  if (nflux->pcodes != 1 && nflux->units != 0) {
704  mf::LogError("FillMCFlux")
705  << "either wrong particle codes or units "
706  << "from flux object - beware!!";
707  }
708 
709  // maintained variable names from gnumi ntuples
710  // see http://www.hep.utexas.edu/~zarko/wwwgnumi/v19/[/v19/output_gnumi.html]
711 
712  flux.frun = nflux->run;
713  flux.fevtno = nflux->evtno;
714  flux.fndxdz = nflux->ndxdz;
715  flux.fndydz = nflux->ndydz;
716  flux.fnpz = nflux->npz;
717  flux.fnenergy = nflux->nenergy;
718  flux.fndxdznea = nflux->ndxdznea;
719  flux.fndydznea = nflux->ndydznea;
720  flux.fnenergyn = nflux->nenergyn;
721  flux.fnwtnear = nflux->nwtnear;
722  flux.fndxdzfar = nflux->ndxdzfar;
723  flux.fndydzfar = nflux->ndydzfar;
724  flux.fnenergyf = nflux->nenergyf;
725  flux.fnwtfar = nflux->nwtfar;
726  flux.fnorig = nflux->norig;
727  flux.fndecay = nflux->ndecay;
728  flux.fntype = nflux->ntype;
729  flux.fvx = nflux->vx;
730  flux.fvy = nflux->vy;
731  flux.fvz = nflux->vz;
732  flux.fpdpx = nflux->pdpx;
733  flux.fpdpy = nflux->pdpy;
734  flux.fpdpz = nflux->pdpz;
735  flux.fppdxdz = nflux->ppdxdz;
736  flux.fppdydz = nflux->ppdydz;
737  flux.fpppz = nflux->pppz;
738  flux.fppenergy = nflux->ppenergy;
739  flux.fppmedium = nflux->ppmedium;
740  flux.fptype = nflux->ptype; // converted to PDG
741  flux.fppvx = nflux->ppvx;
742  flux.fppvy = nflux->ppvy;
743  flux.fppvz = nflux->ppvz;
744  flux.fmuparpx = nflux->muparpx;
745  flux.fmuparpy = nflux->muparpy;
746  flux.fmuparpz = nflux->muparpz;
747  flux.fmupare = nflux->mupare;
748  flux.fnecm = nflux->necm;
749  flux.fnimpwt = nflux->nimpwt;
750  flux.fxpoint = nflux->xpoint;
751  flux.fypoint = nflux->ypoint;
752  flux.fzpoint = nflux->zpoint;
753  flux.ftvx = nflux->tvx;
754  flux.ftvy = nflux->tvy;
755  flux.ftvz = nflux->tvz;
756  flux.ftpx = nflux->tpx;
757  flux.ftpy = nflux->tpy;
758  flux.ftpz = nflux->tpz;
759  flux.ftptype = nflux->tptype; // converted to PDG
760  flux.ftgen = nflux->tgen;
761  flux.ftgptype = nflux->tgptype; // converted to PDG
762  flux.ftgppx = nflux->tgppx;
763  flux.ftgppy = nflux->tgppy;
764  flux.ftgppz = nflux->tgppz;
765  flux.ftprivx = nflux->tprivx;
766  flux.ftprivy = nflux->tprivy;
767  flux.ftprivz = nflux->tprivz;
768  flux.fbeamx = nflux->beamx;
769  flux.fbeamy = nflux->beamy;
770  flux.fbeamz = nflux->beamz;
771  flux.fbeampx = nflux->beampx;
772  flux.fbeampy = nflux->beampy;
773  flux.fbeampz = nflux->beampz;
774 
775  flux.fdk2gen = dk2gen;
776 
777  return;
778 }
779 
780 //---------------------------------------------------------------------------
781 void evgb::FillMCFlux(genie::flux::GSimpleNtpFlux* gsimple,
782  simb::MCFlux& flux)
783 {
784  const genie::flux::GSimpleNtpEntry* nflux_entry =
785  gsimple->GetCurrentEntry();
786  const genie::flux::GSimpleNtpNuMI* nflux_numi =
787  gsimple->GetCurrentNuMI();
788  const genie::flux::GSimpleNtpAux* nflux_aux =
789  gsimple->GetCurrentAux();
790  const genie::flux::GSimpleNtpMeta* nflux_meta =
791  gsimple->GetCurrentMeta();
792  evgb::FillMCFlux(nflux_entry, nflux_numi, nflux_aux, nflux_meta, flux);
793 }
794 void evgb::FillMCFlux(const genie::flux::GSimpleNtpEntry* nflux_entry,
795  const genie::flux::GSimpleNtpNuMI* nflux_numi,
796  const genie::flux::GSimpleNtpAux* nflux_aux,
797  const genie::flux::GSimpleNtpMeta* nflux_meta,
798  simb::MCFlux& flux)
799 {
800  flux.Reset();
802 
803  // maintained variable names from gnumi ntuples
804  // see http://www.hep.utexas.edu/~zarko/wwwgnumi/v19/[/v19/output_gnumi.html]
805 
806 
807  flux.fntype = nflux_entry->pdg;
808  flux.fnimpwt = nflux_entry->wgt;
809  flux.fdk2gen = nflux_entry->dist;
810  flux.fnenergyn = flux.fnenergyf = nflux_entry->E;
811 
812  if ( nflux_numi ) {
813  flux.frun = nflux_numi->run;
814  flux.fevtno = nflux_numi->evtno;
815  flux.ftpx = nflux_numi->tpx;
816  flux.ftpy = nflux_numi->tpy;
817  flux.ftpz = nflux_numi->tpz;
818  flux.ftptype = nflux_numi->tptype; // converted to PDG
819  flux.fvx = nflux_numi->vx;
820  flux.fvy = nflux_numi->vy;
821  flux.fvz = nflux_numi->vz;
822 
823  flux.fndecay = nflux_numi->ndecay;
824  flux.fppmedium = nflux_numi->ppmedium;
825 
826  flux.fpdpx = nflux_numi->pdpx;
827  flux.fpdpy = nflux_numi->pdpy;
828  flux.fpdpz = nflux_numi->pdpz;
829 
830  double apppz = nflux_numi->pppz;
831  if ( TMath::Abs(nflux_numi->pppz) < 1.0e-30 ) apppz = 1.0e-30;
832  flux.fppdxdz = nflux_numi->pppx / apppz;
833  flux.fppdydz = nflux_numi->pppy / apppz;
834  flux.fpppz = nflux_numi->pppz;
835 
836  flux.fptype = nflux_numi->ptype;
837 
838  }
839 
840  // anything useful stuffed into vdbl or vint?
841  // need to check the metadata auxintname, auxdblname
842 
843  if ( nflux_aux && nflux_meta ) {
844 
845  // references just for reducing complexity
846  const std::vector<std::string>& auxdblname = nflux_meta->auxdblname;
847  const std::vector<std::string>& auxintname = nflux_meta->auxintname;
848  const std::vector<int>& auxint = nflux_aux->auxint;
849  const std::vector<double>& auxdbl = nflux_aux->auxdbl;
850 
851  for (size_t id=0; id<auxdblname.size(); ++id) {
852  if ("muparpx" == auxdblname[id]) flux.fmuparpx = auxdbl[id];
853  if ("muparpy" == auxdblname[id]) flux.fmuparpy = auxdbl[id];
854  if ("muparpz" == auxdblname[id]) flux.fmuparpz = auxdbl[id];
855  if ("mupare" == auxdblname[id]) flux.fmupare = auxdbl[id];
856  if ("necm" == auxdblname[id]) flux.fnecm = auxdbl[id];
857  if ("nimpwt" == auxdblname[id]) flux.fnimpwt = auxdbl[id];
858  if ("fgXYWgt" == auxdblname[id]) {
859  flux.fnwtnear = flux.fnwtfar = auxdbl[id];
860  }
861  }
862  for (size_t ii=0; ii<auxintname.size(); ++ii) {
863  if ("tgen" == auxintname[ii]) flux.ftgen = auxint[ii];
864  if ("tgptype" == auxintname[ii]) flux.ftgptype = auxint[ii];
865  }
866 
867  }
868 
869 //#define RWH_TEST
870 #ifdef RWH_TEST
871  static bool first = true;
872  if (first) {
873  first = false;
874  mf::LogDebug("GENIE2ART")
875  << __FILE__ << ":" << __LINE__
876  << " one time dump of GSimple objects\n";
877  if ( nflux_meta ) {
878  mf::LogDebug("GENIE2ART")
879  << "evgb::FillMCFlux() GSimpleNtpMeta:\n"
880  << *nflux_meta << "\n";
881  } else {
882  mf::LogDebug("GENIE2ART")
883  << "evgb::FillMCFlux() no GSimpleNtpMeta:\n";
884  }
885  }
886  //mf::LogDebug("GENIEHelper")
887  mf::LogDebug("GENIE2ART")
888  << "simb::MCFlux:\n"
889  << flux << "\n"
890  << "GSimpleNtpFlux:\n";
891  if ( nflux_entry) mf::LogDebug("GENIE2ART") << *nflux_entry << "\n";
892  else mf::LogDebug("GENIE2ART") << "no GSimpleNtpEntry\n";
893  if ( nflux_numi ) mf::LogDebug("GENIE2ART") << *nflux_numi << "\n";
894  else mf::LogDebug("GENIE2ART") << "no GSimpleNtpNuMI\n";
895  if ( nflux_aux ) mf::LogDebug("GENIE2ART") << *nflux_aux << "\n";
896  else mf::LogDebug("GENIE2ART") << "no GSimpleNtpAux\n";
897 #endif
898 
899  // flux.fndxdz = nflux.ndxdz;
900  // flux.fndydz = nflux.ndydz;
901  // flux.fnpz = nflux.npz;
902  // flux.fnenergy = nflux.nenergy;
903  // flux.fndxdznea = nflux.ndxdznea;
904  // flux.fndydznea = nflux.ndydznea;
905  // flux.fnenergyn = nflux.nenergyn;
906  // flux.fnwtnear = nflux.nwtnear;
907  // flux.fndxdzfar = nflux.ndxdzfar;
908  // flux.fndydzfar = nflux.ndydzfar;
909  // flux.fnenergyf = nflux.nenergyf;
910  // flux.fnwtfar = nflux.nwtfar;
911  // flux.fnorig = nflux.norig;
912  // in numi // flux.fndecay = nflux.ndecay;
913  // flux.fntype = nflux.ntype;
914  // in numi // flux.fvx = nflux.vx;
915  // in numi // flux.fvy = nflux.vy;
916  // in numi // flux.fvz = nflux.vz;
917  // flux.fppenergy = nflux.ppenergy;
918  // in numi // flux.fppmedium = nflux.ppmedium;
919  // flux.fppvx = nflux.ppvx;
920  // flux.fppvy = nflux.ppvy;
921  // flux.fppvz = nflux.ppvz;
922  // see above // flux.fmuparpx = nflux.muparpx;
923  // see above // flux.fmuparpy = nflux.muparpy;
924  // see above // flux.fmuparpz = nflux.muparpz;
925  // see above // flux.fmupare = nflux.mupare;
926  // see above // flux.fnecm = nflux.necm;
927  // see above // flux.fnimpwt = nflux.nimpwt;
928  // flux.fxpoint = nflux.xpoint;
929  // flux.fypoint = nflux.ypoint;
930  // flux.fzpoint = nflux.zpoint;
931  // flux.ftvx = nflux.tvx;
932  // flux.ftvy = nflux.tvy;
933  // flux.ftvz = nflux.tvz;
934  // see above // flux.ftgen = nflux.tgen;
935  // see above // flux.ftgptype = nflux.tgptype; // converted to PDG
936  // flux.ftgppx = nflux.tgppx;
937  // flux.ftgppy = nflux.tgppy;
938  // flux.ftgppz = nflux.tgppz;
939  // flux.ftprivx = nflux.tprivx;
940  // flux.ftprivy = nflux.tprivy;
941  // flux.ftprivz = nflux.tprivz;
942  // flux.fbeamx = nflux.beamx;
943  // flux.fbeamy = nflux.beamy;
944  // flux.fbeamz = nflux.beamz;
945  // flux.fbeampx = nflux.beampx;
946  // flux.fbeampy = nflux.beampy;
947  // flux.fbeampz = nflux.beampz;
948 
949  return;
950 }
951 
952 //---------------------------------------------------------------------------
953 void evgb::FillMCFlux(genie::flux::GDk2NuFlux* gdk2nu,
954  simb::MCFlux& flux)
955 {
956  const bsim::Dk2Nu& dk2nu = gdk2nu->GetDk2Nu();
957  const bsim::NuChoice& nuchoice = gdk2nu->GetNuChoice();
958  evgb::FillMCFlux(&dk2nu,&nuchoice,flux);
959  // do this after Fill as that does a Reset()
960  flux.fdk2gen = gdk2nu->GetDecayDist();
961 }
962 void evgb::FillMCFlux(const bsim::Dk2Nu* dk2nu,
963  const bsim::NuChoice* nuchoice,
964  simb::MCFlux& flux)
965 {
966  flux.Reset();
967  flux.fFluxType = simb::kDk2Nu;
968 
969  if ( dk2nu ) {
970  flux.frun = dk2nu->job;
971  flux.fevtno = dk2nu->potnum;
972 
973  // ignore vector<bsim::NuRay> (see nuchoice above)
974 
975  // bsim::Decay object
976  flux.fnorig = dk2nu->decay.norig;
977  flux.fndecay = dk2nu->decay.ndecay;
978  flux.fntype = dk2nu->decay.ntype;
979  flux.fppmedium = dk2nu->decay.ppmedium;
980  flux.fptype = dk2nu->decay.ptype;
981 
982  flux.fvx = dk2nu->decay.vx;
983  flux.fvy = dk2nu->decay.vy;
984  flux.fvz = dk2nu->decay.vz;
985  flux.fpdpx = dk2nu->decay.pdpx;
986  flux.fpdpy = dk2nu->decay.pdpy;
987  flux.fpdpz = dk2nu->decay.pdpz;
988 
989  flux.fppdxdz = dk2nu->decay.ppdxdz;
990  flux.fppdydz = dk2nu->decay.ppdydz;
991  flux.fpppz = dk2nu->decay.pppz;
992  flux.fppenergy = dk2nu->decay.ppenergy;
993 
994  flux.fmuparpx = dk2nu->decay.muparpx;
995  flux.fmuparpy = dk2nu->decay.muparpy;
996  flux.fmuparpz = dk2nu->decay.muparpz;
997  flux.fmupare = dk2nu->decay.mupare;
998 
999  flux.fnecm = dk2nu->decay.necm;
1000  flux.fnimpwt = dk2nu->decay.nimpwt;
1001 
1002  // no place for: vector<bsim::Ancestor>
1003 
1004  // production vertex of nu parent
1005  flux.fppvx = dk2nu->ppvx;
1006  flux.fppvy = dk2nu->ppvy;
1007  flux.fppvz = dk2nu->ppvz;
1008 
1009  // bsim::TgtExit object
1010  flux.ftvx = dk2nu->tgtexit.tvx;
1011  flux.ftvy = dk2nu->tgtexit.tvy;
1012  flux.ftvz = dk2nu->tgtexit.tvz;
1013  flux.ftpx = dk2nu->tgtexit.tpx;
1014  flux.ftpy = dk2nu->tgtexit.tpy;
1015  flux.ftpz = dk2nu->tgtexit.tpz;
1016  flux.ftptype = dk2nu->tgtexit.tptype; // converted to PDG
1017  flux.ftgen = dk2nu->tgtexit.tgen;
1018 
1019  // ignore vector<bsim::Traj>
1020 
1021  }
1022 
1023  if ( nuchoice ) {
1024  flux.fntype = nuchoice->pdgNu;
1025  flux.fnimpwt = nuchoice->impWgt;
1026 
1027  flux.fnenergyn = flux.fnenergyf = nuchoice->p4NuUser.E();
1028  flux.fnwtnear = flux.fnwtfar = nuchoice->xyWgt;
1029  }
1030 
1031  /*
1032  // anything useful stuffed into vdbl or vint?
1033  // need to check the metadata auxintname, auxdblname
1034 
1035  if ( nflux_aux && nflux_meta ) {
1036 
1037  // references just for reducing complexity
1038  const std::vector<std::string>& auxdblname = nflux_meta->auxdblname;
1039  const std::vector<std::string>& auxintname = nflux_meta->auxintname;
1040  const std::vector<int>& auxint = nflux_aux->auxint;
1041  const std::vector<double>& auxdbl = nflux_aux->auxdbl;
1042 
1043  for (size_t id=0; id<auxdblname.size(); ++id) {
1044  if ("muparpx" == auxdblname[id]) flux.fmuparpx = auxdbl[id];
1045  if ("muparpy" == auxdblname[id]) flux.fmuparpy = auxdbl[id];
1046  if ("muparpz" == auxdblname[id]) flux.fmuparpz = auxdbl[id];
1047  if ("mupare" == auxdblname[id]) flux.fmupare = auxdbl[id];
1048  if ("necm" == auxdblname[id]) flux.fnecm = auxdbl[id];
1049  if ("nimpwt" == auxdblname[id]) flux.fnimpwt = auxdbl[id];
1050  if ("fgXYWgt" == auxdblname[id]) {
1051  flux.fnwtnear = flux.fnwtfar = auxdbl[id];
1052  }
1053  }
1054  for (size_t ii=0; ii<auxintname.size(); ++ii) {
1055  if ("tgen" == auxintname[ii]) flux.ftgen = auxint[ii];
1056  if ("tgptype" == auxintname[ii]) flux.ftgptype = auxint[ii];
1057  }
1058 
1059  }
1060 
1061  // probably can get this from vx,vy,vz + NuChoice
1062  flux.fdk2gen = gdk2nu->GetDecayDist();
1063 
1064  */
1065 
1066  // flux.fndxdz = nflux.ndxdz;
1067  // flux.fndydz = nflux.ndydz;
1068  // flux.fnpz = nflux.npz;
1069  // flux.fnenergy = nflux.nenergy;
1070  // flux.fndxdznea = nflux.ndxdznea;
1071  // flux.fndydznea = nflux.ndydznea;
1072  // flux.fnenergyn = nflux.nenergyn;
1073  // flux.fnwtnear = nflux.nwtnear;
1074  // flux.fndxdzfar = nflux.ndxdzfar;
1075  // flux.fndydzfar = nflux.ndydzfar;
1076  // flux.fnenergyf = nflux.nenergyf;
1077  // flux.fnwtfar = nflux.nwtfar;
1078  // flux.fnorig = nflux.norig;
1079  // in numi // flux.fndecay = nflux.ndecay;
1080  // flux.fntype = nflux.ntype;
1081  // in numi // flux.fvx = nflux.vx;
1082  // in numi // flux.fvy = nflux.vy;
1083  // in numi // flux.fvz = nflux.vz;
1084  // flux.fppenergy = nflux.ppenergy;
1085  // in numi // flux.fppmedium = nflux.ppmedium;
1086  // flux.fppvx = nflux.ppvx;
1087  // flux.fppvy = nflux.ppvy;
1088  // flux.fppvz = nflux.ppvz;
1089  // see above // flux.fmuparpx = nflux.muparpx;
1090  // see above // flux.fmuparpy = nflux.muparpy;
1091  // see above // flux.fmuparpz = nflux.muparpz;
1092  // see above // flux.fmupare = nflux.mupare;
1093  // see above // flux.fnecm = nflux.necm;
1094  // see above // flux.fnimpwt = nflux.nimpwt;
1095  // flux.fxpoint = nflux.xpoint;
1096  // flux.fypoint = nflux.ypoint;
1097  // flux.fzpoint = nflux.zpoint;
1098  // flux.ftvx = nflux.tvx;
1099  // flux.ftvy = nflux.tvy;
1100  // flux.ftvz = nflux.tvz;
1101  // see above // flux.ftgen = nflux.tgen;
1102  // see above // flux.ftgptype = nflux.tgptype; // converted to PDG
1103  // flux.ftgppx = nflux.tgppx;
1104  // flux.ftgppy = nflux.tgppy;
1105  // flux.ftgppz = nflux.tgppz;
1106  // flux.ftprivx = nflux.tprivx;
1107  // flux.ftprivy = nflux.tprivy;
1108  // flux.ftprivz = nflux.tprivz;
1109  // flux.fbeamx = nflux.beamx;
1110  // flux.fbeamy = nflux.beamy;
1111  // flux.fbeamz = nflux.beamz;
1112  // flux.fbeampx = nflux.beampx;
1113  // flux.fbeampy = nflux.beampy;
1114  // flux.fbeampz = nflux.beampz;
1115 
1116  return;
1117 }
1118 
1119 //---------------------------------------------------------------------------
1120 
1121 
double fgW
Definition: GTruth.h:48
Float_t x
Definition: compare.C:6
double E(const int i=0) const
Definition: MCParticle.h:237
int fGint
interaction code
Definition: GTruth.h:25
Unified ntuple flux format (replaces 2)
Definition: MCFlux.h:23
int frun
Definition: MCFlux.h:35
unsigned int NumberTrajectoryPoints() const
Definition: MCParticle.h:222
const TVector3 & Polarization() const
Definition: MCParticle.h:218
const TLorentzVector & Position(const int i=0) const
Definition: MCParticle.h:223
int PdgCode() const
Definition: MCParticle.h:216
double fgq2
Definition: GTruth.h:47
double fnenergy
Definition: MCFlux.h:40
const simb::MCNeutrino & GetNeutrino() const
Definition: MCTruth.h:74
double ftgppy
Definition: MCFlux.h:86
double fgX
Definition: GTruth.h:50
int ftgtA
Definition: GTruth.h:58
double fpdpx
Definition: MCFlux.h:55
double Py(const int i=0) const
Definition: MCParticle.h:235
double Gvz() const
Definition: MCParticle.h:252
double ftpx
Definition: MCFlux.h:79
const TLorentzVector & EndPosition() const
Definition: MCParticle.h:229
int HitQuark() const
Definition: MCNeutrino.h:157
double ftprivy
Definition: MCFlux.h:89
Full flux simulation ntuple.
Definition: MCFlux.h:21
void SetOrigin(simb::Origin_t origin)
Definition: MCTruth.h:78
neutrino electron elastic scatter
Definition: MCNeutrino.h:144
int fppmedium
Definition: MCFlux.h:62
cout<< "-> Edep in the target
Definition: analysis.C:54
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
genie::EventRecord * RetrieveGHEP(const simb::MCTruth &truth, const simb::GTruth &gtruth, bool useFirstTrajPosition=true)
return genie::EventRecord pointer; callee takes possession
Definition: GENIE2ART.cxx:341
double fbeamx
Definition: MCFlux.h:91
void FillMCFlux(genie::GFluxI *fdriver, simb::MCFlux &mcflux)
Definition: GENIE2ART.cxx:635
int Mother() const
Definition: MCParticle.h:217
double fbeampy
Definition: MCFlux.h:95
int ftptype
Definition: MCFlux.h:82
Float_t y
Definition: compare.C:6
int fGPhaseSpace
phase space system of DiffXSec
Definition: GTruth.h:27
simb::flux_code_ fFluxType
Definition: MCFlux.h:98
double Px(const int i=0) const
Definition: MCParticle.h:234
int fNumNeutron
number of neutrons after reaction, before FSI
Definition: GTruth.h:40
double fvx
Definition: MCFlux.h:52
int HitNuc() const
Definition: MCNeutrino.h:156
double fnwtfar
Definition: MCFlux.h:48
int ftgtZ
Definition: GTruth.h:57
double fXsec
cross section of interaction
Definition: GTruth.h:32
Functions for transforming GENIE objects into ART objects (and back)
int fNumPiPlus
number of pi pluses after reaction, before FSI
Definition: GTruth.h:36
offset to account for adding in Nuance codes to this enum
Definition: MCNeutrino.h:99
int StatusCode() const
Definition: MCParticle.h:215
int fNumPiMinus
number of pi minuses after reaction, before FSI
Definition: GTruth.h:37
double fppdxdz
Definition: MCFlux.h:58
double Gvx() const
Definition: MCParticle.h:250
int NParticles() const
Definition: MCTruth.h:72
void SetNeutrino(int CCNC, int mode, int interactionType, int target, int nucleon, int quark, double w, double x, double y, double qsqr)
Definition: MCTruth.cxx:30
int ftgen
Definition: MCFlux.h:83
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
double fdk2gen
distance from decay to ray origin
Definition: MCFlux.h:103
double Gvy() const
Definition: MCParticle.h:251
Particle class.
void Add(simb::MCParticle &part)
Definition: MCTruth.h:77
double ftprivx
Definition: MCFlux.h:88
object containing MC flux information
TLorentzVector fProbeP4
Definition: GTruth.h:63
double fndydzfar
Definition: MCFlux.h:46
int ftgptype
Definition: MCFlux.h:84
int fResNum
resonance number
Definition: GTruth.h:42
int fNumProton
number of protons after reaction, before FSI
Definition: GTruth.h:39
double fprobability
interaction probability
Definition: GTruth.h:31
double fnenergyf
Definition: MCFlux.h:47
void Reset()
Definition: MCFlux.cxx:94
double ftprivz
Definition: MCFlux.h:90
double fbeamz
Definition: MCFlux.h:93
double fnwtnear
Definition: MCFlux.h:44
const simb::MCParticle & Lepton() const
Definition: MCNeutrino.h:151
int fptype
Definition: MCFlux.h:63
int fProbePDG
Definition: GTruth.h:62
double ftvx
Definition: MCFlux.h:76
int fGscatter
neutrino scattering code
Definition: GTruth.h:26
int fndecay
Definition: MCFlux.h:50
double fndydz
Definition: MCFlux.h:38
int fnorig
Definition: MCFlux.h:49
double fbeamy
Definition: MCFlux.h:92
double ftgppz
Definition: MCFlux.h:87
double fpdpz
Definition: MCFlux.h:57
int fNumPi0
number of pi0 after reaction, before FSI
Definition: GTruth.h:38
TString part[npart]
Definition: Style.C:32
bool fIsCharm
did the interaction produce a charmed hadron?
Definition: GTruth.h:41
double fmuparpz
Definition: MCFlux.h:69
double fweight
event interaction weight (genie internal)
Definition: GTruth.h:30
double ftgppx
Definition: MCFlux.h:85
int fevtno
Definition: MCFlux.h:36
double fppdydz
Definition: MCFlux.h:59
double ftpz
Definition: MCFlux.h:81
double ftvy
Definition: MCFlux.h:77
TLorentzVector fHitNucP4
Definition: GTruth.h:56
double fbeampz
Definition: MCFlux.h:96
double fndxdzfar
Definition: MCFlux.h:45
double fpdpy
Definition: MCFlux.h:56
double fnpz
Definition: MCFlux.h:39
const simb::MCParticle & GetParticle(int i) const
Definition: MCTruth.h:73
double fzpoint
Definition: MCFlux.h:75
double fvy
Definition: MCFlux.h:53
double fmupare
Definition: MCFlux.h:70
double fxpoint
Definition: MCFlux.h:73
double fndxdznea
Definition: MCFlux.h:41
double Vx(const int i=0) const
Definition: MCParticle.h:225
void FillMCTruth(const genie::EventRecord *grec, double spillTime, simb::MCTruth &mctruth)
Definition: GENIE2ART.cxx:73
n.b.: this group is similar but not quite, entirely unlike GENIE ScatteringType convention ...
Definition: MCNeutrino.h:84
double fppenergy
Definition: MCFlux.h:61
int fntype
Definition: MCFlux.h:51
int ftgtPDG
PDG of Target Nucleus, nucleon only if free.
Definition: GTruth.h:59
double fgQ2
< these are for the internal (on shell) genie kinematics
Definition: GTruth.h:46
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
double fnecm
Definition: MCFlux.h:71
inverse muon decay
Definition: MCNeutrino.h:145
double Gvt() const
Definition: MCParticle.h:253
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
TLorentzVector fFShadSystP4
Definition: GTruth.h:52
double Pz(const int i=0) const
Definition: MCParticle.h:236
int Rescatter() const
Definition: MCParticle.h:256
double fndydznea
Definition: MCFlux.h:42
double fypoint
Definition: MCFlux.h:74
double fmuparpy
Definition: MCFlux.h:68
double fppvx
Definition: MCFlux.h:64
double fpppz
Definition: MCFlux.h:60
double fppvy
Definition: MCFlux.h:65
double fbeampx
Definition: MCFlux.h:94
double fppvz
Definition: MCFlux.h:66
double fgT
Definition: GTruth.h:49
double ftpy
Definition: MCFlux.h:80
void FillGTruth(const genie::EventRecord *grec, simb::GTruth &gtruth)
Definition: GENIE2ART.cxx:243
double fndxdz
Definition: MCFlux.h:37
Event generator information.
Definition: MCTruth.h:30
double fvz
Definition: MCFlux.h:54
Event generator information.
Definition: MCNeutrino.h:18
bool fIsSeaQuark
Definition: GTruth.h:55
TLorentzVector fVertex
Definition: GTruth.h:64
double fgY
Definition: GTruth.h:51
double fDiffXsec
differential cross section of interaction
Definition: GTruth.h:33
double fmuparpx
Definition: MCFlux.h:67
A simplified flux ntuple for quick running.
Definition: MCFlux.h:22
Beam neutrinos.
Definition: MCTruth.h:21
double fnenergyn
Definition: MCFlux.h:43
static constexpr double kUndefinedValue
Definition: GTruth.h:67
double ftvz
Definition: MCFlux.h:78
double fnimpwt
Definition: MCFlux.h:72
vertex reconstruction