Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPizza.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 #include <cmath>
6 
7 #include "TROOT.h"
8 #include "TFile.h"
9 #include "TH1D.h"
10 #include "TH2D.h"
11 #include "TProfile.h"
12 
13 #include "evt/Evt.hh"
14 #include "JAAnet/JAAnetToolkit.hh"
15 #include "JAAnet/JPDB.hh"
16 
19 #include "JSupport/JSupport.hh"
20 #include "JTools/JRange.hh"
21 #include "JPhysics/JGeane.hh"
22 
23 #include "Jeep/JPrint.hh"
24 #include "Jeep/JParser.hh"
25 #include "Jeep/JMessage.hh"
26 
27 namespace {
28 
29  using namespace JPP;
30 
31  /**
32  * Particle Data Book.
33  */
34  const JPDB pdb = JPDB::getInstance();
35 
36 
37  /**
38  * Get energy of initial state.\n
39  * This method includes baryon number conservation.
40  *
41  * \param evt event
42  * \return energy [GeV]
43  */
44  inline double getE0(const Evt& evt)
45  {
46  double E0 = 0.0;
47 
48  if (!evt.mc_trks.empty() && is_neutrino(evt.mc_trks[0])) {
49 
50  const Trk& neutrino = evt.mc_trks[0];
51 
52  E0 += neutrino.E;
53 
54  for (size_t i = 1; i != evt.mc_trks.size(); ++i) {
55 
56  const Trk& track = evt.mc_trks[i];
57 
58  if (track.type == TRACK_TYPE_NEUTRON ||
59  track.type == TRACK_TYPE_SIGMA_MINUS) {
60  E0 += MASS_NEUTRON;
61  }
62 
63  if (track.type == TRACK_TYPE_PROTON ||
64  track.type == TRACK_TYPE_LAMBDA ||
65  track.type == TRACK_TYPE_SIGMA_PLUS) {
66  E0 += MASS_PROTON;
67  }
68 
69  if (track.type == TRACK_TYPE_ANTINEUTRON) {
70  E0 -= MASS_NEUTRON;
71  }
72 
73  if (track.type == TRACK_TYPE_ANTIPROTON ||
74  track.type == TRACK_TYPE_ANTILAMBDA) {
75  E0 -= MASS_PROTON;
76  }
77  }
78  }
79 
80  return E0;
81  }
82 
83 
84  /**
85  * Get energy of final state.\n
86  * This method includes muon energy loss.
87  *
88  * \param evt event
89  * \return energy [GeV]
90  */
91  inline double getE1(const Evt& evt)
92  {
93  double E1 = 0.0;
94 
95  if (!evt.mc_trks.empty() && is_neutrino(evt.mc_trks[0])) {
96 
97  const Trk& neutrino = evt.mc_trks[0];
98 
99  for (size_t i = 1; i != evt.mc_trks.size(); ++i) {
100 
101  const Trk& track = evt.mc_trks[i];
102 
103  if (track.type == TRACK_TYPE_MUON ||
104  track.type == TRACK_TYPE_ANTIMUON) {
105 
106  E1 += gWater(track.E, -(track.pos - neutrino.pos).len());
107 
108  } else {
109 
110  E1 += track.E;
111  }
112  }
113  }
114 
115  return E1;
116  }
117 }
118 
119 
120 /**
121  * \file
122  *
123  * Example program to verify generator data.
124  * \author mdejong
125  */
126 int main(int argc, char **argv)
127 {
128  using namespace std;
129  using namespace JPP;
130 
131  JMultipleFileScanner<Evt> inputFile;
132  JLimit_t& numberOfEvents = inputFile.getLimit();
133  string outputFile;
134  JRange<double> range;
135  int debug;
136 
137  try {
138 
139  JParser<> zap("Example program to verify generator data.");
140 
141  zap['f'] = make_field(inputFile);
142  zap['o'] = make_field(outputFile) = "pizza.root";
143  zap['n'] = make_field(numberOfEvents) = JLimit::max();
144  zap['R'] = make_field(range, "fractional energy conservation") = JRange<double>(-0.01, +0.01);
145  zap['d'] = make_field(debug) = 0;
146 
147  zap(argc, argv);
148  }
149  catch(const exception &error) {
150  FATAL(error.what() << endl);
151  }
152 
153  cout.tie(&cerr);
154 
155  TFile out(outputFile.c_str(), "recreate");
156 
157  TH1D h0 ("h0", NULL, 1001, -1.0, +1.0);
158  TH1D job("job", NULL, 10001, -5000.5, +5000.5);
159 
160  TH1D hn ("hn", NULL, 2001, -0.5, +2000.5);
161  TH1D he ("he", NULL, 1000, 0.0, 10.0);
162 
163  TH2D h2 ("h2", NULL,
164  100, 0.0, 2.0e5,
165  200, 0.0, 1.5e3);
166 
167 
168  while (inputFile.hasNext()) {
169 
170  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
171 
172  const Evt* event = inputFile.next();
173 
174  for (vector<Trk>::const_iterator track = event->mc_trks.begin(); track != event->mc_trks.end(); ++track) {
175  job.Fill((double) track->type);
176  }
177 
178  if (has_neutrino(*event) && is_neutrino(event->mc_trks[0])) {
179 
180  const double E0 = getE0(*event);
181  const double E1 = getE1(*event);
182 
183  if (!range((E0 - E1)/E0) || debug >= debug_t) {
184 
185  const Trk& neutrino = event->mc_trks[0];
186 
187  cout << endl << "--------------------------------------------------------" << endl;
188  cout << "event: " << setw(8) << event->mc_id << " energy [GeV] distance [m]" << endl;
189 
190  for (size_t i = 0; i != event->mc_trks.size(); ++i) {
191 
192  const Trk& track = event->mc_trks[i];
193  const JParticle& particle = pdb.getPDG(track.type);
194 
195  cout << setw(32) << left << particle.name << ' ' << FIXED(7,3) << track.E << " " << FIXED(7,3) << (track.pos - neutrino.pos).len() << endl;
196  }
197  cout << setw(32) << left << "balance" << ' ' << FIXED(7,3) << E0 - E1 << endl;
198  }
199 
200  h0.Fill((E0 - E1)/E0);
201  }
202 
203 
204  int n = 0;
205 
206  for (vector<Trk>::const_iterator track = event->mc_trks.begin(); track != event->mc_trks.end(); ++track) {
207 
208  if (is_muon(*track)) {
209  ++n;
210  he.Fill(log10(track->E));
211  h2.Fill(track->pos.x*track->pos.x + track->pos.y*track->pos.y, track->pos.z);
212  }
213  }
214 
215  hn.Fill((Double_t) n);
216  }
217  STATUS(endl);
218 
219  out.Write();
220  out.Close();
221 }
static const double MASS_PROTON
proton mass [GeV]
Definition: JConstants.hh:67
Utility class to parse command line options.
Definition: JParser.hh:1410
std::string name
name of particle
Definition: JPDB.hh:85
static const JGeane gWater(2.67e-1 *JTOOLS::DENSITY_SEA_WATER, 3.4e-4 *JTOOLS::DENSITY_SEA_WATER)
Function object for Energy loss of muon in sea water.
debug
Definition: JMessage.hh:27
Energy loss of muon.
#define STATUS(A)
Definition: JMessage.hh:61
bool has_neutrino(const Evt &evt)
Test whether given event has an incoming neutrino.
bool is_muon(const Trk &track)
Test whether given track is a (anti-)muon.
Structure to store the ToT mean and standard deviation of the hits produced by a nanobeacon in a sour...
Auxiliary data structure for floating point format specification.
Definition: JPrint.hh:461
string outputFile
Collection of particles.
Definition: JPDB.hh:105
static const JPDB & getInstance()
Get particle data book.
Definition: JPDB.hh:121
bool is_neutrino(const Trk &track)
Test whether given track is a neutrino.
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
Definition of hit and track types and auxiliary methods for handling Monte Carlo data.
int debug
debug level
Definition: JSirene.cc:59
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:65
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Auxiliary class to handle particle name, codes and mass.
Definition: JPDB.hh:33
Auxiliary class to define a range between two values.
General purpose class for object reading from a list of file names.
Utility class to parse command line options.
ROOT TTree parameter settings.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:72
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:60
static const double MASS_NEUTRON
neutron mass [GeV]
Definition: JConstants.hh:68
int main(int argc, char *argv[])
Definition: Main.cpp:15