Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JRadiation2D.cc File Reference

Example program to histogram shower energy as a function of the muon energy. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <memory>
#include "TROOT.h"
#include "TFile.h"
#include "TH2D.h"
#include "TProfile2D.h"
#include "JTools/JQuantile.hh"
#include "JPhysics/JRadiation.hh"
#include "JPhysics/JRadiationFunction.hh"
#include "JPhysics/JRadiationSource.hh"
#include "JPhysics/JGeane.hh"
#include "JPhysics/JConstants.hh"
#include "JSirene/JSeaWater.hh"
#include "JLang/JSharedPointer.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Detailed Description

Example program to histogram shower energy as a function of the muon energy.

Author
mdejong

Definition in file JRadiation2D.cc.

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 33 of file JRadiation2D.cc.

34{
35 using namespace std;
36 using namespace JPP;
37
38 string outputFile;
40 int debug;
41
42 try {
43
44 JParser<> zap("Example program to histogram shower energy.");
45
46 zap['o'] = make_field(outputFile) = "radiation.root";
47 zap['n'] = make_field(numberOfPoints) = 0;
48 zap['d'] = make_field(debug) = 0;
49
50 zap(argc, argv);
51 }
52 catch(const exception &error) {
53 FATAL(error.what() << endl);
54 }
55
56
57 TFile out(outputFile.c_str(), "recreate");
58
59 TH2* h0 = new TH2D("total", NULL, 24, 2.0, 10.0, 20, -5.0, 0.0); // master histogram
60 TH2* h2 = (TH2*) h0->Clone("h2");
61
62 NOTICE("Setting up radiation tables... " << flush);
63
65 typedef vector<tuple> ntuple;
66
67 ntuple radiation;
68
69 const JRadiation hydrogen ( 1.0, 1.0, 40, 0.01, 0.1, 0.1);
70 const JRadiation oxygen ( 8.0, 16.0, 40, 0.01, 0.1, 0.1);
71 const JRadiation chlorine (17.0, 35.0, 40, 0.01, 0.1, 0.1);
72 const JRadiation sodium (11.0, 23.0, 40, 0.01, 0.1, 0.1);
73
74 JSharedPointer<JRadiation> Hydrogen (new JRadiationFunction(hydrogen, 300, 0.2, 1.0e11));
75 JSharedPointer<JRadiation> Oxygen (new JRadiationFunction(oxygen, 300, 0.2, 1.0e11));
76 JSharedPointer<JRadiation> Chlorine (new JRadiationFunction(chlorine, 300, 0.2, 1.0e11));
77 JSharedPointer<JRadiation> Sodium (new JRadiationFunction(sodium, 300, 0.2, 1.0e11));
78
79 radiation.push_back(tuple(new JRadiationSource(11, Oxygen, DENSITY_SEA_WATER * JSeaWater::O(), EErad_t), (TH2D*) h0->Clone("[eerad O]" )));
80 radiation.push_back(tuple(new JRadiationSource(12, Chlorine, DENSITY_SEA_WATER * JSeaWater::Cl(), EErad_t), (TH2D*) h0->Clone("[eerad Cl]")));
81 radiation.push_back(tuple(new JRadiationSource(13, Hydrogen, DENSITY_SEA_WATER * JSeaWater::H(), EErad_t), (TH2D*) h0->Clone("[eerad H]" )));
82 radiation.push_back(tuple(new JRadiationSource(14, Sodium, DENSITY_SEA_WATER * JSeaWater::Na(), EErad_t), (TH2D*) h0->Clone("[eerad Na]" )));
83
84 radiation.push_back(tuple(new JRadiationSource(21, Oxygen, DENSITY_SEA_WATER * JSeaWater::O(), Brems_t), (TH2D*) h0->Clone("[Brems O]" )));
85 radiation.push_back(tuple(new JRadiationSource(22, Chlorine, DENSITY_SEA_WATER * JSeaWater::Cl(), Brems_t), (TH2D*) h0->Clone("[Brems Cl]")));
86 radiation.push_back(tuple(new JRadiationSource(23, Hydrogen, DENSITY_SEA_WATER * JSeaWater::H(), Brems_t), (TH2D*) h0->Clone("[Brems H]" )));
87 radiation.push_back(tuple(new JRadiationSource(24, Sodium, DENSITY_SEA_WATER * JSeaWater::Na(), Brems_t), (TH2D*) h0->Clone("[Brems Na]" )));
88
89 radiation.push_back(tuple(new JRadiationSource(31, Oxygen, DENSITY_SEA_WATER * JSeaWater::O(), GNrad_t), (TH2D*) h0->Clone("[gnrad O]" )));
90 radiation.push_back(tuple(new JRadiationSource(32, Chlorine, DENSITY_SEA_WATER * JSeaWater::Cl(), GNrad_t), (TH2D*) h0->Clone("[gnrad Cl]")));
91 radiation.push_back(tuple(new JRadiationSource(33, Hydrogen, DENSITY_SEA_WATER * JSeaWater::H(), GNrad_t), (TH2D*) h0->Clone("[gnrad H]" )));
92 radiation.push_back(tuple(new JRadiationSource(34, Sodium, DENSITY_SEA_WATER * JSeaWater::Na(), GNrad_t), (TH2D*) h0->Clone("[gnrad Na]" )));
93
94 NOTICE("OK" << endl);
95
96 for (int i = 1; i <= h0->GetXaxis()->GetNbins(); ++i) {
97
98 const double x = h0->GetXaxis()->GetBinCenter(i);
99 const double E = pow(10.0, x);
100 const double W = 1.0 / (double) numberOfPoints;
101
102 STATUS("Energy: " << SCIENTIFIC(8,1) << E << '\r'); DEBUG(endl);
103
104 for (ntuple::iterator p = radiation.begin(); p != radiation.end(); ++p) {
105
106 for (int n = 0; n != numberOfPoints; ++n) {
107
108 const double li = p->first->getInverseInteractionLength(E);
109 const double Es = p->first->getEnergyOfShower(E);
110 const double y = log10(Es/E);
111
112 p->second->Fill(x, y, W);
113
114 h2->Fill(x, y, li * W);
115 }
116 }
117 STATUS(endl);
118 }
119
120 delete h0;
121
122 out.Write();
123 out.Close();
124}
string outputFile
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define STATUS(A)
Definition JMessage.hh:63
#define NOTICE(A)
Definition JMessage.hh:64
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
int numberOfPoints
Definition JResultPDF.cc:22
The template JSharedPointer class can be used to share a pointer to an object.
Utility class to parse command line options.
Definition JParser.hh:1698
Fast implementation of class JRadiation.
Implementation for calculation of inverse interaction length and shower energy.
Auxiliary class for the calculation of the muon radiative cross sections.
Definition JRadiation.hh:36
T pow(const T &x, const double y)
Power .
Definition JMath.hh:97
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
const int n
Definition JPolint.hh:791
Auxiliary data structure for floating point format specification.
Definition JManip.hh:488