Jpp  18.6.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JVolume1D.cc File Reference

Example program to histogram neutrino effective volume for triggered events. More...

#include <string>
#include <iostream>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "km3net-dataformat/offline/Vec.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JAAnet/JAAnetToolkit.hh"
#include "JAAnet/JVolume.hh"
#include "JSupport/JTriggeredFileScanner.hh"
#include "JSupport/JMonteCarloFileSupportkit.hh"
#include "JSupport/JSupport.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 neutrino effective volume for triggered events.


For genie/gSeaGen events, use application JEffectiveMassOnline1D or JEffectiveMassOffline1D.
The unit of the contents of the histogram is $km^{3}$.

Author
mdejong, bstrandberg

Definition in file JVolume1D.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 30 of file JVolume1D.cc.

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 
88  JTriggeredFileScanner<>::multi_pointer_type ps = inputFile.next();
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 }
Utility class to parse command line options.
Definition: JParser.hh:1711
General exception.
Definition: JException.hh:24
#define WARNING(A)
Definition: JMessage.hh:65
then usage $script< input file >[option[primary[working directory]]] nWhere option can be E
Definition: JMuonPostfit.sh:40
#define STATUS(A)
Definition: JMessage.hh:63
bool has_neutrino(const Evt &evt)
Test whether given event has an incoming neutrino.
Auxiliary class to synchronously read DAQ events and Monte Carlo events (and optionally other events)...
string outputFile
double E
Energy [GeV] (either MC truth or reconstructed)
Definition: Trk.hh:20
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
Auxiliary class for histogramming of effective volume.
Definition: JVolume.hh:29
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Monte Carlo run header.
Definition: JHead.hh:1234
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
Definition: Head.hh:65
#define FATAL(A)
Definition: JMessage.hh:67
bool is_genhen(const JHead &header)
Check for generator.
Definition: JHeadToolkit.hh:37
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:84
const Trk & get_neutrino(const Evt &evt)
Get incoming neutrino.
General purpose class for multiple pointers.
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Definition: Trk.hh:14
int numberOfBins
number of bins for average CDF integral of optical module
Definition: JSirene.cc:70
int debug
debug level
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:20
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62