GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
gtestFermiP.cxx File Reference
#include <TFile.h>
#include <TNtuple.h>
#include <TMath.h>
#include <TVector3.h>
#include "Physics/NuclearState/NuclearModelI.h"
#include "Framework/Algorithm/AlgFactory.h"
#include "Framework/Interaction/Target.h"
#include "Framework/Messenger/Messenger.h"
#include "Framework/ParticleData/PDGCodes.h"
#include "Framework/Utils/PrintUtils.h"
Include dependency graph for gtestFermiP.cxx:

Go to the source code of this file.

Functions

int main (int, char **)
 

Function Documentation

int main ( int  ,
char **   
)

Definition at line 34 of file gtestFermiP.cxx.

References genie::NuclearModelI::GenerateNucleon(), genie::AlgFactory::GetAlgorithm(), genie::Algorithm::Id(), genie::AlgFactory::Instance(), kNEvents, genie::kPdgProton, LOG, genie::NuclearModelI::Momentum3(), pDEBUG, pNOTICE, genie::NuclearModelI::RemovalEnergy(), genie::Target::SetHitNucPdg(), and genie::utils::print::Vec3AsString().

35 {
36  const unsigned int kNTargets = 2;
37  const unsigned int kNModels = 4;
38  const unsigned int kNEvents = 3000;
39 
40  //-- Get nuclear models
41  AlgFactory * algf = AlgFactory::Instance();
42 
43  const NuclearModelI * bodritch =
44  dynamic_cast<const NuclearModelI *> (algf->GetAlgorithm(
45  "genie::FGMBodekRitchie","Default"));
46  const NuclearModelI * benhsf1d =
47  dynamic_cast<const NuclearModelI *> (
48  algf->GetAlgorithm("genie::BenharSpectralFunc1D","Default"));
49  const NuclearModelI * benhsf2d =
50  dynamic_cast<const NuclearModelI *> (
51  algf->GetAlgorithm("genie::BenharSpectralFunc","Default"));
52  const NuclearModelI * effsf =
53  dynamic_cast<const NuclearModelI *> (
54  algf->GetAlgorithm("genie::EffectiveSF","Default"));
55 
56  const NuclearModelI * nuclmodel[kNModels] = { bodritch, benhsf1d, benhsf2d, effsf };
57 
58  //-- Create nuclear targets
59  Target * nucltgt[kNTargets];
60  nucltgt[0] = new Target ( 6, 12); // C12
61  nucltgt[1] = new Target (26, 56); // Fe56
62 
63  //-- Output ntuple
64 
65  TNtuple * nuclnt = new TNtuple("nuclnt","","target:model:p:px:py:pz:w");
66 
67  //-- Loop over targets/models & generate 'target nucleons'
68  for(unsigned int it = 0; it < kNTargets; it++) {
69  nucltgt[it]->SetHitNucPdg(kPdgProton);
70  const Target & target = *nucltgt[it];
71  LOG("test", pNOTICE) << "** Using target : " << target;;
72  for(unsigned int im = 0; im < kNModels; im++) {
73  LOG("test", pNOTICE) << "Running model : " << nuclmodel[im]->Id();
74  for(unsigned int iev = 0; iev < kNEvents; iev++) {
75  nuclmodel[im]->GenerateNucleon(target);
76  double w = nuclmodel[im]->RemovalEnergy();
77  TVector3 p3 = nuclmodel[im]->Momentum3();
78  double px = p3.Px();
79  double py = p3.Py();
80  double pz = p3.Pz();
81  double p = p3.Mag();
82  LOG("test", pDEBUG)
83  << "Nucleon 4-P = " << utils::print::Vec3AsString(&p3);
84  nuclnt->Fill(it,im,p,px,py,pz,w);
85  }//ievents
86  }//immodels
87  }//itargets
88 
89  //-- Save ntuple
90  TFile f("./fermip.root","recreate");
91  nuclnt->Write();
92  f.Close();
93 
94  //-- Clean-up
95  delete nucltgt[0];
96  delete nucltgt[1];
97  delete nuclnt;
98 
99  return 0;
100 }
double RemovalEnergy(void) const
Definition: NuclearModelI.h:65
Pure abstract base class. Defines the NuclearModelI interface to be implemented by any physics model ...
Definition: NuclearModelI.h:46
const TVector3 & Momentum3(void) const
Definition: NuclearModelI.h:75
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
A Neutrino Interaction Target. Is a transparent encapsulation of quite different physical systems suc...
Definition: Target.h:40
const Algorithm * GetAlgorithm(const AlgId &algid)
Definition: AlgFactory.cxx:75
const unsigned int kNEvents
virtual const AlgId & Id(void) const
Get algorithm ID.
Definition: Algorithm.h:98
void SetHitNucPdg(int pdgc)
Definition: Target.cxx:171
const int kPdgProton
Definition: PDGCodes.h:81
#define pNOTICE
Definition: Messenger.h:61
The GENIE Algorithm Factory.
Definition: AlgFactory.h:39
virtual bool GenerateNucleon(const Target &) const =0
string Vec3AsString(const TVector3 *vec)
Definition: PrintUtils.cxx:80
#define pDEBUG
Definition: Messenger.h:63