Jpp  19.1.0-rc.1
the software that should make you happy
JVolume1D.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 
4 #include "TROOT.h"
5 #include "TFile.h"
6 #include "TH1D.h"
7 
11 #include "JDAQ/JDAQEventIO.hh"
12 #include "JAAnet/JAAnetToolkit.hh"
13 #include "JAAnet/JVolume.hh"
14 
17 #include "JSupport/JSupport.hh"
18 
19 #include "Jeep/JParser.hh"
20 #include "Jeep/JMessage.hh"
21 
22 /**
23  * \file
24  *
25  * Example program to histogram neutrino effective volume for triggered events.\n
26  * For genie/gSeaGen events, use application JEffectiveMassOnline1D or JEffectiveMassOffline1D.\n
27  * The unit of the contents of the histogram is \f$km^{3}\f$.
28  * \author mdejong, bstrandberg
29  */
30 int main(int argc, char **argv)
31 {
32  using namespace std;
33  using namespace JPP;
34  using namespace KM3NETDAQ;
35 
36  JTriggeredFileScanner<> inputFile;
37  string outputFile;
38  JLimit& numberOfEvents = inputFile.getLimit();
39  bool logx;
40  int numberOfBins;
41  int debug;
42 
43  try {
44 
45  JParser<> zap("Example program to histogram neutrino effective volume for triggered events."\
46  "\nFor genie/gSeaGen events, use application JEffectiveMass1D.");
47 
48  zap['f'] = make_field(inputFile);
49  zap['o'] = make_field(outputFile) = "volume.root";
50  zap['n'] = make_field(numberOfEvents) = JLimit::max();
51  zap['X'] = make_field(logx, "Use logarithm of energy");
52  zap['N'] = make_field(numberOfBins, "Number of bins in the energy range of the MC simulation") = 10;
53  zap['d'] = make_field(debug) = 1;
54 
55  zap(argc, argv);
56  }
57  catch(const exception &error) {
58  FATAL(error.what() << endl);
59  }
60 
61  Head head;
62 
63  try {
64  head = getHeader(inputFile);
65  }
66  catch(const JException& error) {
67  FATAL(error);
68  }
69 
70  const JHead buffer(head);
71 
72  if (!is_genhen(buffer)) {
73  FATAL("Use JEffectiveMass1D" << endl);
74  }
75 
76  const JVolume volume(head, logx);
77 
78  TFile out(outputFile.c_str(), "recreate");
79 
80  TH1D hV("hV", "effective volume in km^3", numberOfBins, volume.getXmin(), volume.getXmax());
81 
82  hV.Sumw2();
83 
84  while (inputFile.hasNext()) {
85 
86  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
87 
89 
90  const Evt* event = ps;
91 
92  if (has_neutrino(*event)) {
93 
94  const Trk& neutrino = get_neutrino(*event);
95  const double E = neutrino.E;
96 
97  hV.Fill(volume.getX(E), volume.getW(hV.GetXaxis(), E));
98  }
99  else {
100  WARNING("JVolume1D: cannot find neutrino in triggered event " << inputFile.getCounter() );
101  }
102  }
103  STATUS(endl);
104 
105  out.Write();
106  out.Close();
107 }
Definition of hit and track types and auxiliary methods for handling Monte Carlo data.
string outputFile
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
#define STATUS(A)
Definition: JMessage.hh:63
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
#define WARNING(A)
Definition: JMessage.hh:65
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
int numberOfBins
number of bins for average CDF integral of optical module
Definition: JSirene.cc:70
ROOT TTree parameter settings of various packages.
Synchronously read DAQ events and Monte Carlo events (and optionally other events).
int main(int argc, char **argv)
Definition: JVolume1D.cc:30
Monte Carlo run header.
Definition: JHead.hh:1236
General exception.
Definition: JException.hh:24
Utility class to parse command line options.
Definition: JParser.hh:1714
counter_type getCounter() const
Get counter.
bool is_genhen(const JHead &header)
Check for generator.
Definition: JHeadToolkit.hh:37
const Trk & get_neutrino(const Evt &evt)
Get incoming neutrino.
bool has_neutrino(const Evt &evt)
Test whether given event has an incoming neutrino.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
Definition: JSTDTypes.hh:14
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:21
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
Definition: Head.hh:65
Auxiliary class for histogramming of effective volume.
Definition: JVolume.hh:29
Double_t getX(const Double_t E, double constrain=false) const
Get abscissa value.
Definition: JVolume.hh:115
Double_t getW(TAxis *axis, const Double_t E) const
Get bin width corrected energy spectrum dependent weight.
Definition: JVolume.hh:156
Double_t getXmax() const
Get maximal abscissa value.
Definition: JVolume.hh:102
Double_t getXmin() const
Get minimal abscissa value.
Definition: JVolume.hh:91
General purpose class for multiple pointers.
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:45
Auxiliary class to synchronously read DAQ events and Monte Carlo events (and optionally other events)...
virtual bool hasNext() override
Check availability of next element.
virtual const multi_pointer_type & next() override
Get next element.
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Definition: Trk.hh:15
double E
Energy [GeV] (either MC truth or reconstructed)
Definition: Trk.hh:20