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 <costas.andreopoulos \at stfc.ac.uk>
10  University of Liverpool & STFC Rutherford Appleton Lab
11 
12 \created June 20, 2004
13 
14 \cpright Copyright (c) 2003-2016, GENIE Neutrino MC Generator Collaboration
15  For the full text of the license visit http://copyright.genie-mc.org
16  or see $GENIE/LICENSE
17 */
18 //____________________________________________________________________________
19 
20 #include <TFile.h>
21 #include <TNtuple.h>
22 #include <TMath.h>
23 #include <TVector3.h>
24 
25 #include "../Interfaces/NuclearModelI.h"
26 #include "Algorithm/AlgFactory.h"
27 #include "Interaction/Target.h"
28 #include "Messenger/Messenger.h"
29 #include "PDG/PDGCodes.h"
30 #include "Utils/PrintUtils.h"
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 //____________________________________________________________________________
int iev
Definition: runWimpSim.h:118
const XML_Char * target
Definition: expat.h:268
double RemovalEnergy(void) const
Definition: NuclearModelI.h:57
set< int >::iterator it
THE MAIN GENIE PROJECT NAMESPACE
Definition: GeneratorBase.h:8
const char * p
Definition: xmltok.h:285
Pure abstract base class. Defines the NuclearModelI interface to be implemented by any physics model ...
Definition: NuclearModelI.h:42
int main(int, char **)
Definition: gtestFermiP.cxx:34
const TVector3 & Momentum3(void) const
Definition: NuclearModelI.h:67
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
A Neutrino Interaction Target. Is a transparent encapsulation of quite different physical systems suc...
Definition: Target.h:41
const Algorithm * GetAlgorithm(const AlgId &algid)
Definition: AlgFactory.cxx:86
const unsigned int kNEvents
virtual const AlgId & Id(void) const
Get algorithm ID.
Definition: Algorithm.h:98
static AlgFactory * Instance()
Definition: AlgFactory.cxx:75
void SetHitNucPdg(int pdgc)
Definition: Target.cxx:188
virtual bool GenerateNucleon(const Target &) const =0
const int kPdgProton
Definition: PDGCodes.h:65
#define pNOTICE
Definition: Messenger.h:62
The GENIE Algorithm Factory.
Definition: AlgFactory.h:40
Float_t w
Definition: plot.C:20
string Vec3AsString(const TVector3 *vec)
Definition: PrintUtils.cxx:87
#define pDEBUG
Definition: Messenger.h:64