LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
GSimpleInterface.cxx
Go to the documentation of this file.
1 #include "GSimpleInterface.h"
2 #include "TFile.h"
3 #include "TTree.h"
4 
5 namespace fluxr {
7 
9 
10  void GSimpleInterface::SetRootFile(TFile* fluxInputFile)
11  {
12  fFluxTree = dynamic_cast<TTree*>(fluxInputFile->Get("flux"));
13  fMetaTree = dynamic_cast<TTree*>(fluxInputFile->Get("meta"));
14  fGSimpleEntry = new genie::flux::GSimpleNtpEntry;
15  fGSimpleNuMI = new genie::flux::GSimpleNtpNuMI;
16  fGSimpleAux = new genie::flux::GSimpleNtpAux;
17  fGSimpleMeta = new genie::flux::GSimpleNtpMeta;
18  fFluxTree->SetBranchAddress("entry", &fGSimpleEntry);
19  fFluxTree->SetBranchAddress("numi", &fGSimpleNuMI);
20  fFluxTree->SetBranchAddress("aux", &fGSimpleAux);
21  fMetaTree->SetBranchAddress("meta", &fGSimpleMeta);
22 
23  fNEntries = fFluxTree->GetEntries();
24  fFluxTree->GetEntry(0);
25  fRun = fGSimpleNuMI->run;
26  fMetaTree->GetEntry(0);
27  fPOT = fGSimpleMeta->protons;
28  }
29 
30  bool GSimpleInterface::FillMCFlux(Long64_t ientry, simb::MCFlux& flux)
31  {
32  if (!fFluxTree->GetEntry(ientry)) return false;
33 
34  fNuPos = TLorentzVector(
35  fGSimpleEntry->vtxx * 100, fGSimpleEntry->vtxy * 100, fGSimpleEntry->vtxz * 100, 0);
36  fNuMom =
37  TLorentzVector(fGSimpleEntry->px, fGSimpleEntry->py, fGSimpleEntry->pz, fGSimpleEntry->E);
38 
39  //stealing code from GenieHelper (nutools/EventGeneratorBase/GENIE/GENIEHelper.cxx)
40  flux.fntype = fGSimpleEntry->pdg;
41  flux.fnimpwt = fGSimpleEntry->wgt;
42  flux.fdk2gen = fGSimpleEntry->dist;
43  flux.fnenergyn = flux.fnenergyf = fGSimpleEntry->E;
44 
45  if (fGSimpleNuMI) {
46  flux.frun = fGSimpleNuMI->run;
47  flux.fevtno = fGSimpleNuMI->evtno;
48  flux.ftpx = fGSimpleNuMI->tpx;
49  flux.ftpy = fGSimpleNuMI->tpy;
50  flux.ftpz = fGSimpleNuMI->tpz;
51  flux.ftptype = fGSimpleNuMI->tptype; // converted to PDG
52  flux.fvx = fGSimpleNuMI->vx;
53  flux.fvy = fGSimpleNuMI->vy;
54  flux.fvz = fGSimpleNuMI->vz;
55 
56  flux.fndecay = fGSimpleNuMI->ndecay;
57  flux.fppmedium = fGSimpleNuMI->ppmedium;
58 
59  flux.fpdpx = fGSimpleNuMI->pdpx;
60  flux.fpdpy = fGSimpleNuMI->pdpy;
61  flux.fpdpz = fGSimpleNuMI->pdpz;
62 
63  double apppz = fGSimpleNuMI->pppz;
64  if (TMath::Abs(fGSimpleNuMI->pppz) < 1.0e-30) apppz = 1.0e-30;
65  flux.fppdxdz = fGSimpleNuMI->pppx / apppz;
66  flux.fppdydz = fGSimpleNuMI->pppy / apppz;
67  flux.fpppz = fGSimpleNuMI->pppz;
68 
69  flux.fptype = fGSimpleNuMI->ptype;
70  }
71 
72  // anything useful stuffed into vdbl or vint?
73  // need to check the metadata auxintname, auxdblname
74  if (fGSimpleAux && fGSimpleMeta) {
75  // references just for reducing complexity
76  const std::vector<std::string>& auxdblname = fGSimpleMeta->auxdblname;
77  const std::vector<std::string>& auxintname = fGSimpleMeta->auxintname;
78  const std::vector<int>& auxint = fGSimpleAux->auxint;
79  const std::vector<double>& auxdbl = fGSimpleAux->auxdbl;
80 
81  for (size_t id = 0; id < auxdblname.size(); ++id) {
82  if ("muparpx" == auxdblname[id]) flux.fmuparpx = auxdbl[id];
83  if ("muparpy" == auxdblname[id]) flux.fmuparpy = auxdbl[id];
84  if ("muparpz" == auxdblname[id]) flux.fmuparpz = auxdbl[id];
85  if ("mupare" == auxdblname[id]) flux.fmupare = auxdbl[id];
86  if ("necm" == auxdblname[id]) flux.fnecm = auxdbl[id];
87  if ("nimpwt" == auxdblname[id]) flux.fnimpwt = auxdbl[id];
88  if ("fgXYWgt" == auxdblname[id]) { flux.fnwtnear = flux.fnwtfar = auxdbl[id]; }
89  }
90  for (size_t ii = 0; ii < auxintname.size(); ++ii) {
91  if ("tgen" == auxintname[ii]) flux.ftgen = auxint[ii];
92  if ("tgptype" == auxintname[ii]) flux.ftgptype = auxint[ii];
93  }
94  }
95  return true;
96  }
97 }
int frun
Definition: MCFlux.h:35
double fpdpx
Definition: MCFlux.h:55
double ftpx
Definition: MCFlux.h:79
genie::flux::GSimpleNtpEntry * fGSimpleEntry
int fppmedium
Definition: MCFlux.h:62
int ftptype
Definition: MCFlux.h:82
double fvx
Definition: MCFlux.h:52
double fnwtfar
Definition: MCFlux.h:48
genie::flux::GSimpleNtpNuMI * fGSimpleNuMI
double fppdxdz
Definition: MCFlux.h:58
int ftgen
Definition: MCFlux.h:83
double fdk2gen
distance from decay to ray origin
Definition: MCFlux.h:103
int ftgptype
Definition: MCFlux.h:84
double fnenergyf
Definition: MCFlux.h:47
double fnwtnear
Definition: MCFlux.h:44
int fptype
Definition: MCFlux.h:63
void SetRootFile(TFile *rootFileName)
int fndecay
Definition: MCFlux.h:50
double fpdpz
Definition: MCFlux.h:57
genie::flux::GSimpleNtpMeta * fGSimpleMeta
double fmuparpz
Definition: MCFlux.h:69
int fevtno
Definition: MCFlux.h:36
double fppdydz
Definition: MCFlux.h:59
double ftpz
Definition: MCFlux.h:81
genie::flux::GSimpleNtpAux * fGSimpleAux
double fpdpy
Definition: MCFlux.h:56
double fvy
Definition: MCFlux.h:53
double fmupare
Definition: MCFlux.h:70
int fntype
Definition: MCFlux.h:51
double fnecm
Definition: MCFlux.h:71
double fmuparpy
Definition: MCFlux.h:68
double fpppz
Definition: MCFlux.h:60
double ftpy
Definition: MCFlux.h:80
double fvz
Definition: MCFlux.h:54
bool FillMCFlux(Long64_t ientry, simb::MCFlux &mcflux)
double fmuparpx
Definition: MCFlux.h:67
double fnenergyn
Definition: MCFlux.h:43
double fnimpwt
Definition: MCFlux.h:72