GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions | Variables
gtestMuELoss.cxx File Reference
#include <cassert>
#include <cstdlib>
#include <string>
#include <vector>
#include <TFile.h>
#include <TNtuple.h>
#include "Framework/AlgorithmAlgFactory.h"
#include "Framework/Conventions/Units.h"
#include "Physics/MuonEnergyLoss/MuELossI.h"
#include "Physics/MuonEnergyLoss/MuELMaterial.h"
#include "Physics/MuonEnergyLoss/MuELProcess.h"
#include "Framework/Messenger/Messenger.h"
#include "Framework/Utils/StringUtils.h"
#include "Framework/Utils/CmdLnArgParser.h"
Include dependency graph for gtestMuELoss.cxx:

Go to the source code of this file.

Functions

void GetCommandLineArgs (int argc, char **argv)
 
int main (int argc, char **argv)
 

Variables

string gOptMaterials
 

Function Documentation

void GetCommandLineArgs ( int  argc,
char **  argv 
)
int main ( int  argc,
char **  argv 
)

Definition at line 56 of file gtestMuELoss.cxx.

References genie::utils::res::AsString(), genie::units::cm2, genie::mueloss::MuELossI::dE_dx(), genie::units::g, genie::AlgFactory::GetAlgorithm(), GetCommandLineArgs(), genie::units::GeV, gOptMaterials, genie::Algorithm::Id(), genie::AlgFactory::Instance(), genie::AlgId::Key(), LOG, pINFO, genie::mueloss::MuELossI::Process(), and genie::utils::str::Split().

57 {
58  GetCommandLineArgs(argc, argv);
59 
60  const int N = 14;
61  double E[N] = {1,5,10,15,20,30,50,100,200,500, 1000,2000, 5000, 9000}; //GeV
62 
63  // split the comma separated list of materials
64  vector<string> mtv = utils::str::Split(gOptMaterials, ",");
65 
66  // get muon energy loss algorithms
67  AlgFactory * algf = AlgFactory::Instance();
68 
69  const MuELossI * betheBloch =
70  dynamic_cast<const MuELossI *> (algf->GetAlgorithm(
71  "genie::mueloss::BetheBlochModel","Default"));
72 
73  const MuELossI * petrukhinShestakov =
74  dynamic_cast<const MuELossI *> (algf->GetAlgorithm(
75  "genie::mueloss::PetrukhinShestakovModel","Default"));
76 
77  const MuELossI * kokoulinPetroukhin =
78  dynamic_cast<const MuELossI *> (algf->GetAlgorithm(
79  "genie::mueloss::KokoulinPetrukhinModel","Default"));
80 
81  const MuELossI * bezroukovBugaev =
82  dynamic_cast<const MuELossI *> (algf->GetAlgorithm(
83  "genie::mueloss::BezrukovBugaevModel","Default"));
84 
85  assert ( betheBloch );
86  assert ( petrukhinShestakov );
87  assert ( kokoulinPetroukhin );
88  assert ( bezroukovBugaev );
89 
90  double myunits_conversion = units::GeV/(units::g/units::cm2);
91  string myunits_name = " GeV/(gr/cm^2)";
92 
93  // open a ROOT file and define the output ntuple.
94  TFile froot("./genie-mueloss.root", "RECREATE");
95  TNtuple muntp("muntp","muon dE/dx", "material:E:ion:brem:pair:pnucl");
96 
97  //loop over materials
98  vector<string>::iterator iter;
99  for(iter = mtv.begin(); iter != mtv.end(); ++iter) {
100 
101  MuELMaterial_t mt = (MuELMaterial_t) atoi(iter->c_str());
102 
103  LOG("test", pINFO)
104  << "---------- Computing/Printing muon energy losses in "
105  << MuELMaterial::AsString(mt) << " ----------";
106 
107  // loop over energies
108  for(int i=0; i<N; i++) {
109 
110  // ionization
111  double ion = betheBloch->dE_dx(E[i],mt) / myunits_conversion;
112 
113  LOG("test", pINFO)
114  << "Process: " << MuELProcess::AsString(betheBloch->Process())
115  << ", Model: " << betheBloch->Id().Key()
116  << " : \n -dE/dx(E=" << E[i] << ") = " << ion << myunits_name;
117 
118  // bremsstrahlung
119  double brem = petrukhinShestakov->dE_dx(E[i],mt) / myunits_conversion;
120 
121  LOG("test", pINFO)
122  << "Process: " << MuELProcess::AsString(petrukhinShestakov->Process())
123  << ", Model: " << petrukhinShestakov->Id().Key()
124  << " : \n -dE/dx(E=" << E[i] << ") = " << brem << myunits_name;
125 
126  // e-e+ pair production
127  double pair = kokoulinPetroukhin->dE_dx(E[i],mt) / myunits_conversion;
128 
129  LOG("test", pINFO)
130  << "Process: " << MuELProcess::AsString(kokoulinPetroukhin->Process())
131  << ", Model: " << kokoulinPetroukhin->Id().Key()
132  << " : \n -dE/dx(E=" << E[i] << ") = " << pair << myunits_name;
133 
134  // photonuclear interactions
135  double pnucl = bezroukovBugaev->dE_dx(E[i],mt) / myunits_conversion;
136 
137  LOG("test", pINFO)
138  << "Process: " << MuELProcess::AsString(bezroukovBugaev->Process())
139  << ", Model: " << bezroukovBugaev->Id().Key()
140  << " : \n -dE/dx(E=" << E[i] << ") = " << pnucl << myunits_name
141  << "\n\n";
142 
143  muntp.Fill( (int)mt,E[i],ion,brem,pair,pnucl);
144  }//e
145  }//m
146 
147  muntp.Write();
148  froot.Close();
149 
150  return 0;
151 }
static constexpr double g
Definition: Units.h:144
virtual double dE_dx(double E, MuELMaterial_t m) const =0
virtual MuELProcess_t Process(void) const =0
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
static constexpr double cm2
Definition: Units.h:69
static constexpr double GeV
Definition: Units.h:28
const Algorithm * GetAlgorithm(const AlgId &algid)
Definition: AlgFactory.cxx:75
#define pINFO
Definition: Messenger.h:62
string gOptMaterials
virtual const AlgId & Id(void) const
Get algorithm ID.
Definition: Algorithm.h:98
vector< string > Split(string input, string delim)
Definition: StringUtils.cxx:36
const char * AsString(Resonance_t res)
resonance id -&gt; string
void GetCommandLineArgs(int argc, char **argv)
Definition: gAtmoEvGen.cxx:563
The GENIE Algorithm Factory.
Definition: AlgFactory.h:39
string Key(void) const
Definition: AlgId.h:46
enum genie::mueloss::EMuELMaterial MuELMaterial_t

Variable Documentation

string gOptMaterials

Definition at line 53 of file gtestMuELoss.cxx.

Referenced by main().