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"

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 
)

Definition at line 153 of file gtestMuELoss.cxx.

154 {
155  LOG("test", pNOTICE) << "Parsing command line arguments";
156 
157  CmdLnArgParser parser(argc,argv);
158 
159  if ( parser.OptionExists('m') ) {
160  LOG("test", pINFO) << "Reading material ids";
161  gOptMaterials = parser.ArgAsString('m');
162  } else {
163  LOG("test", pINFO) << "Unspecified material ids - Exiting";
164  exit(1);
165  }
166 }
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pINFO
Definition: Messenger.h:62
string gOptMaterials
Command line argument parser.
#define pNOTICE
Definition: Messenger.h:61
int main ( int  argc,
char **  argv 
)

Definition at line 56 of file gtestMuELoss.cxx.

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
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 }
intermediate_table::iterator iterator
static constexpr double g
Definition: Units.h:144
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
void GetCommandLineArgs(int argc, char **argv)
string gOptMaterials
virtual const AlgId & Id(void) const
Get algorithm ID.
Definition: Algorithm.h:97
vector< string > Split(string input, string delim)
Definition: StringUtils.cxx:36
const char * AsString(Resonance_t res)
resonance id -> string
virtual double dE_dx(double E, MuELMaterial_t m) const =0
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.