GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gtestFermiP.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*!
3 
4 \program gtestFermiP
5 
6 \brief Program used for testing / debugging the Fermi momentum distribution
7  models
8 
9 \author Costas Andreopoulos <c.andreopoulos \at cern.ch>
10  University of Liverpool
11 
12 \created June 20, 2004
13 
14 \cpright Copyright (c) 2003-2024, The GENIE Collaboration
15  For the full text of the license visit http://copyright.genie-mc.org
16 
17 */
18 //____________________________________________________________________________
19 
20 #include <TFile.h>
21 #include <TNtuple.h>
22 #include <TMath.h>
23 #include <TVector3.h>
24 
31 
32 using namespace genie;
33 
34 int main(int /*argc*/, char ** /*argv*/)
35 {
36  const unsigned int kNTargets = 2;
37  const unsigned int kNModels = 4;
38  const unsigned int kNEvents = 3000;
39 
40  //-- Get nuclear models
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 }
101 //____________________________________________________________________________
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
int main(int argc, char **argv)
Definition: gAtmoEvGen.cxx:327
#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
static AlgFactory * Instance()
Definition: AlgFactory.cxx:64
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
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
string Vec3AsString(const TVector3 *vec)
Definition: PrintUtils.cxx:80
#define pDEBUG
Definition: Messenger.h:63