Jpp test-rotations-old-533-g2bdbdb559
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 "JPhysics/JSeaWater.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 31 of file JRadiation2D.cc.

32{
33 using namespace std;
34 using namespace JPP;
35
36 string outputFile;
38 int debug;
39
40 try {
41
42 JParser<> zap("Example program to histogram shower energy.");
43
44 zap['o'] = make_field(outputFile) = "radiation.root";
45 zap['n'] = make_field(numberOfPoints) = 0;
46 zap['d'] = make_field(debug) = 0;
47
48 zap(argc, argv);
49 }
50 catch(const exception &error) {
51 FATAL(error.what() << endl);
52 }
53
54
55 TFile out(outputFile.c_str(), "recreate");
56
57 TH2* h0 = new TH2D("total", NULL, 24, 2.0, 10.0, 20, -5.0, 0.0); // master histogram
58 TH2* h2 = (TH2*) h0->Clone("h2");
59
60 NOTICE("Setting up radiation tables... " << flush);
61
62 typedef pair<shared_ptr<JRadiationInterface>, TH2*> tuple;
63 typedef vector<tuple> ntuple;
64
65 ntuple radiation;
66
67 const JRadiation hydrogen (JSeaWater::H .Z, JSeaWater::H .A, 40, 0.01, 0.1, 0.1);
68 const JRadiation oxygen (JSeaWater::O .Z, JSeaWater::O .A, 40, 0.01, 0.1, 0.1);
69 const JRadiation chlorine (JSeaWater::Cl.Z, JSeaWater::Cl.A, 40, 0.01, 0.1, 0.1);
70 const JRadiation sodium (JSeaWater::Na.Z, JSeaWater::Na.A, 40, 0.01, 0.1, 0.1);
71
72 shared_ptr<JRadiation> Hydrogen (make_shared<JRadiationFunction>(hydrogen, 300, 0.2, 1.0e11));
73 shared_ptr<JRadiation> Oxygen (make_shared<JRadiationFunction>(oxygen, 300, 0.2, 1.0e11));
74 shared_ptr<JRadiation> Chlorine (make_shared<JRadiationFunction>(chlorine, 300, 0.2, 1.0e11));
75 shared_ptr<JRadiation> Sodium (make_shared<JRadiationFunction>(sodium, 300, 0.2, 1.0e11));
76
77 radiation.push_back(tuple(make_shared<JRadiationSource>(11, Oxygen, DENSITY_SEA_WATER * JSeaWater::O(), JRadiation::EErad_t), (TH2D*) h0->Clone("[eerad O]" )));
78 radiation.push_back(tuple(make_shared<JRadiationSource>(12, Chlorine, DENSITY_SEA_WATER * JSeaWater::Cl(), JRadiation::EErad_t), (TH2D*) h0->Clone("[eerad Cl]")));
79 radiation.push_back(tuple(make_shared<JRadiationSource>(13, Hydrogen, DENSITY_SEA_WATER * JSeaWater::H(), JRadiation::EErad_t), (TH2D*) h0->Clone("[eerad H]" )));
80 radiation.push_back(tuple(make_shared<JRadiationSource>(14, Sodium, DENSITY_SEA_WATER * JSeaWater::Na(), JRadiation::EErad_t), (TH2D*) h0->Clone("[eerad Na]")));
81
82 radiation.push_back(tuple(make_shared<JRadiationSource>(21, Oxygen, DENSITY_SEA_WATER * JSeaWater::O(), JRadiation::Brems_t), (TH2D*) h0->Clone("[Brems O]" )));
83 radiation.push_back(tuple(make_shared<JRadiationSource>(22, Chlorine, DENSITY_SEA_WATER * JSeaWater::Cl(), JRadiation::Brems_t), (TH2D*) h0->Clone("[Brems Cl]")));
84 radiation.push_back(tuple(make_shared<JRadiationSource>(23, Hydrogen, DENSITY_SEA_WATER * JSeaWater::H(), JRadiation::Brems_t), (TH2D*) h0->Clone("[Brems H]" )));
85 radiation.push_back(tuple(make_shared<JRadiationSource>(24, Sodium, DENSITY_SEA_WATER * JSeaWater::Na(), JRadiation::Brems_t), (TH2D*) h0->Clone("[Brems Na]")));
86
87 radiation.push_back(tuple(make_shared<JRadiationSource>(31, Oxygen, DENSITY_SEA_WATER * JSeaWater::O(), JRadiation::GNrad_t), (TH2D*) h0->Clone("[gnrad O]" )));
88 radiation.push_back(tuple(make_shared<JRadiationSource>(32, Chlorine, DENSITY_SEA_WATER * JSeaWater::Cl(), JRadiation::GNrad_t), (TH2D*) h0->Clone("[gnrad Cl]")));
89 radiation.push_back(tuple(make_shared<JRadiationSource>(33, Hydrogen, DENSITY_SEA_WATER * JSeaWater::H(), JRadiation::GNrad_t), (TH2D*) h0->Clone("[gnrad H]" )));
90 radiation.push_back(tuple(make_shared<JRadiationSource>(34, Sodium, DENSITY_SEA_WATER * JSeaWater::Na(), JRadiation::GNrad_t), (TH2D*) h0->Clone("[gnrad Na]")));
91
92 NOTICE("OK" << endl);
93
94 for (int i = 1; i <= h0->GetXaxis()->GetNbins(); ++i) {
95
96 const double x = h0->GetXaxis()->GetBinCenter(i);
97 const double E = pow(10.0, x);
98 const double W = 1.0 / (double) numberOfPoints;
99
100 STATUS("Energy: " << SCIENTIFIC(8,1) << E << '\r'); DEBUG(endl);
101
102 for (ntuple::iterator p = radiation.begin(); p != radiation.end(); ++p) {
103
104 for (int n = 0; n != numberOfPoints; ++n) {
105
106 const double li = p->first->getInverseInteractionLength(E);
107 const double Es = p->first->getEnergyOfShower(E);
108 const double y = log10(Es/E);
109
110 p->second->Fill(x, y, W);
111
112 h2->Fill(x, y, li * W);
113 }
114 }
115 STATUS(endl);
116 }
117
118 delete h0;
119
120 out.Write();
121 out.Close();
122}
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
Utility class to parse command line options.
Definition JParser.hh:1698
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