Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JPizza.cc File Reference

Example program to verify generator data. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <cmath>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "TH2D.h"
#include "TProfile.h"
#include "evt/Evt.hh"
#include "JAAnet/JAAnetToolkit.hh"
#include "JAAnet/JPDB.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JMonteCarloFileSupportkit.hh"
#include "JSupport/JSupport.hh"
#include "JTools/JRange.hh"
#include "JPhysics/JGeane.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 verify generator data.

Author
mdejong

Definition in file JPizza.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 126 of file JPizza.cc.

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 }
Utility class to parse command line options.
Definition: JParser.hh:1410
std::string name
name of particle
Definition: JPDB.hh:85
debug
Definition: JMessage.hh:27
#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
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
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
int debug
debug level
Definition: JSirene.cc:59
#define FATAL(A)
Definition: JMessage.hh:65
Auxiliary class to handle particle name, codes and mass.
Definition: JPDB.hh:33
General purpose class for object reading from a list of file names.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:72
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:60