26 static const std::string LENGTH =
"length";
27 static const std::string ENERGY =
"energy";
28 static const std::string RANGE =
"range";
29 static const std::string ELOSS =
"eloss";
38 inline TH1* clone(TH1*
h1,
const char* buffer)
41 return (TH1*) h1->Clone(buffer);
55 int main(
int argc,
char* argv[])
66 JParser<> zap(
"Example program to histogram radiation cross sections, shower energy, range and b(E).");
70 zap[
'O'] =
make_field(option) = LENGTH, ENERGY, RANGE, ELOSS;
75 catch(
const exception &error) {
76 FATAL(error.what() << endl);
87 if (option == LENGTH) {
88 h0 =
new TH1D(
"total", NULL, 160, 2.0, 10.0);
91 if (option == ENERGY) {
92 h0 =
new TH1D(
"total", NULL, 24, 2.0, 10.0);
95 NOTICE(
"Setting up radiation tables... " << flush);
102 const JRadiation hydrogen( 1.0, 1.0, 40, 0.01, 0.1, 0.1);
103 const JRadiation oxygen ( 8.0, 16.0, 40, 0.01, 0.1, 0.1);
104 const JRadiation chlorine(17.0, 35.0, 40, 0.01, 0.1, 0.1);
106 JSharedPointer<JRadiation> Hydrogen(
new JRadiationFunction(hydrogen, 300, 0.2, 1.0e11));
107 JSharedPointer<JRadiation> Oxygen (
new JRadiationFunction(oxygen, 300, 0.2, 1.0e11));
108 JSharedPointer<JRadiation> Chlorine(
new JRadiationFunction(chlorine, 300, 0.2, 1.0e11));
110 JRadiationSource::source_type EErad(&JRadiation::TotalCrossSectionEErad, &JRadiation::EfromEErad);
111 JRadiationSource::source_type Brems(&JRadiation::TotalCrossSectionBrems, &JRadiation::EfromBrems);
112 JRadiationSource::source_type GNrad(&JRadiation::TotalCrossSectionGNrad, &JRadiation::EfromGNrad);
114 radiation.push_back(tuple(
new JRadiationSource(Oxygen,
DENSITY_SEA_WATER * JSeaWater::O(), EErad), clone(h0,
"[eerad O]" )));
115 radiation.push_back(tuple(
new JRadiationSource(Chlorine,
DENSITY_SEA_WATER * JSeaWater::Cl(), EErad), clone(h0,
"[eerad Cl]")));
118 radiation.push_back(tuple(
new JRadiationSource(Oxygen,
DENSITY_SEA_WATER * JSeaWater::O(), Brems), clone(h0,
"[Brems O]" )));
119 radiation.push_back(tuple(
new JRadiationSource(Chlorine,
DENSITY_SEA_WATER * JSeaWater::Cl(), Brems), clone(h0,
"[Brems Cl]")));
122 radiation.push_back(tuple(
new JRadiationSource(Oxygen,
DENSITY_SEA_WATER * JSeaWater::O(), GNrad), clone(h0,
"[gnrad O]" )));
123 radiation.push_back(tuple(
new JRadiationSource(Chlorine,
DENSITY_SEA_WATER * JSeaWater::Cl(), GNrad), clone(h0,
"[gnrad Cl]")));
129 if (option == LENGTH) {
131 for (
int i = 1; i <= h0->GetNbinsX(); ++i) {
133 const double x = h0->GetBinCenter(i);
134 const double E = pow(10.0, x);
138 for (ntuple::iterator p = radiation.begin(); p != radiation.end(); ++p) {
140 const double li = p->first->getInverseInteractionLength(E);
142 p->second->Fill(x, 1.0/li);
149 if (option == ENERGY) {
151 for (
int i = 1; i <= h0->GetNbinsX(); ++i) {
153 const double x = h0->GetBinCenter(i);
154 const double E = pow(10.0, x);
158 for (ntuple::iterator p = radiation.begin(); p != radiation.end(); ++p) {
163 Q.put(p->first->getEnergyOfShower(E));
166 p->second->SetBinContent(i, Q.getMean());
174 if (option == RANGE) {
176 TH1D* Ra =
new TH1D(
"R[analytical]", NULL, 12, 2.0, 8.0);
177 TH1D* Rb =
new TH1D(
"R[numerical]", NULL, 12, 2.0, 8.0);
179 for (
int i = 1; i <= Ra->GetNbinsX(); ++i) {
181 const double x = Ra->GetBinCenter(i);
182 const double E0 = pow(10.0, x);
183 const double Z =
gWater(E0);
185 Ra->SetBinContent(i, Z*1e-3);
188 for (
int j = 1;
j <= Rb->GetNbinsX(); ++
j) {
190 const double x = Rb->GetBinCenter(
j);
191 const double E0 = pow(10.0, x);
204 const int N = radiation.size();
209 for (
int i = 0; i !=
N; ++i) {
210 ls += li[i] = radiation[i].first->getInverseInteractionLength(E);
213 double dz = min(gRandom->Exp(1.0) / ls,
gWater(E));
218 double y = gRandom->Uniform(ls);
220 for (
int i = 0; i !=
N; ++i) {
225 Es = radiation[i].first->getEnergyOfShower(E);
237 Rb->SetBinContent(
j, Q.getMean() * 1e-3);
244 if (option == ELOSS) {
246 TH1D* hb =
new TH1D(
"hb", NULL, 12, 2.0, 8.0);
248 for (
int j = 1;
j <= hb->GetNbinsX(); ++
j) {
250 const double x = hb->GetBinCenter(
j);
251 const double E = pow(10.0, x);
257 const int N = radiation.size();
262 for (
int i = 0; i !=
N; ++i) {
263 ls += li[i] = radiation[i].first->getInverseInteractionLength(E);
269 double y = gRandom->Uniform(ls);
271 for (
int i = 0; i !=
N; ++i) {
276 Es = radiation[i].first->getEnergyOfShower(E);
284 hb->SetBinContent(
j, Q.getMean());
Utility class to parse command line options.
then for HISTOGRAM in h0 h1
static const JGeaneWater gWater
Function object for energy loss of muon in sea water.
Muon radiative cross sections.
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
General purpose messaging.
Utility class to parse command line options.
alias put_queue eval echo n
Auxiliary data structure for floating point format specification.
then usage $script[input file[working directory[option]]] nWhere option can be N
then usage $script[input file[working directory[option]]] nWhere option can be E
#define DEBUG(A)
Message macros.
int main(int argc, char *argv[])
virtual double getA() const
Get energy loss constant.