Jpp  18.3.0-209-g56ce19a
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JEffectiveMassOffline1D.cc File Reference

Example program to histogram neutrino effective mass for triggered events for offline reconstruction files, using the event weights only. More...

#include <string>
#include <iostream>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "km3net-dataformat/definitions/weightlist.hh"
#include "km3net-dataformat/definitions/w2list_gseagen.hh"
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "km3net-dataformat/offline/Vec.hh"
#include "JAAnet/JVolume.hh"
#include "JAAnet/JHeadToolkit.hh"
#include "JAAnet/JAAnetToolkit.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JEvtWeightFileScannerSet.hh"
#include "JSupport/JMonteCarloFileSupportkit.hh"
#include "JROOT/JManager.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 mass for triggered events for offline reconstruction files, using the event weights only.


The unit of the contents of the histogram is $Mton$ or $km^{3}$.

Author
bjung, mdejong

Definition in file JEffectiveMassOffline1D.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 41 of file JEffectiveMassOffline1D.cc.

42 {
43  using namespace std;
44  using namespace JPP;
45  using namespace KM3NETDAQ;
46 
47  JMultipleFileScanner_t inputFiles;
48  string outputFile;
49  bool logx;
50  int numberOfBins;
51  std::string option;
52  int debug;
53 
54 
55  try {
56 
57  JParser<> zap("Example program to histogram neutrino effective mass for triggered events.");
58 
59  zap['f'] = make_field(inputFiles);
60  zap['o'] = make_field(outputFile) = "Meff.root";
61  zap['X'] = make_field(logx, "Use logarithm of energy");
62  zap['N'] = make_field(numberOfBins, "Number of bins in the energy range of the MC simulation") = 10;
63  zap['O'] = make_field(option, "Result option") = Mass_t, Volume_t;
64  zap['d'] = make_field(debug) = 2;
65 
66  zap(argc, argv);
67  }
68  catch(const exception &error) {
69  FATAL(error.what() << endl);
70  }
71 
72  try {
73 
74  double Xmin = numeric_limits<double>::max();
75  double Xmax = numeric_limits<double>::lowest();
76 
77  JEvtWeightFileScannerSet<> scanners(inputFiles);
78 
79  for (JEvtWeightFileScannerSet<>::const_iterator scanner = scanners.cbegin(); scanner != scanners.cend(); ++scanner) {
80 
81  const JHead header = scanner->getHeader();
82 
83  if (!is_gseagen(header)) {
84  ERROR("Not a gSeaGen file; you may want to use JVolume1D" << endl);
85  }
86 
87  const JVolume volume(header, logx);
88 
89  if (volume.getXmin() < Xmin) { Xmin = volume.getXmin(); }
90  if (volume.getXmax() > Xmax) { Xmax = volume.getXmax(); }
91  }
92 
93  JManager<int, TH1D> hm(new TH1D("hm[%]", option.c_str(), numberOfBins, Xmin, Xmax));
94 
95  for (JEvtWeightFileScannerSet<>::iterator scanner = scanners.begin(); scanner != scanners.end(); ++scanner) {
96 
97  const JHead header = scanner->getHeader();
98 
99  const double Wnorm = header.genvol.numberOfEvents * log(10) * hm->GetBinWidth(1) * 4*M_PI;
100 
101  NOTICE("Scanning file type " << distance(scanners.begin(), scanner) << endl);
102  DEBUG (header << endl);
103 
104  while (scanner->hasNext()) {
105 
106  STATUS("event: " << setw(10) << scanner->getCounter() << '\r'); DEBUG(endl);
107 
108  const Evt* event = scanner->next();
109  const Trk& primary = get_primary(*event);
110 
111  const double weight = (event->w[WEIGHTLIST_DIFFERENTIAL_EVENT_RATE] *
112  event->w2list[W2LIST_GSEAGEN_WATER_INT_LEN] /
113  event->w2list[W2LIST_GSEAGEN_P_EARTH] /
114  primary.E /
115  Wnorm); // cm^3
116 
117  const double x = logx ? log10(primary.E) : primary.E;
118 
119  double y = 0.0;
120 
121  if (option == Mass_t) {
122  y = weight * DENSITY_SEA_WATER * 1e-6; // Mton
123  } else if (option == Volume_t) {
124  y = weight * 1e-15; // km^3
125  }
126 
127  hm[primary.type]->Fill(x, y);
128  }
129  STATUS(endl);
130  }
131 
132  TFile out(outputFile.c_str(), "recreate");
133 
134  out << hm;
135 
136  out.Close();
137  }
138  catch(const JException& error) {
139  FATAL(error << endl << "You may want to use \"offline\" formatted file.");
140  }
141 }
Utility class to parse command line options.
Definition: JParser.hh:1711
General exception.
Definition: JException.hh:24
then usage $script< input file >[option[primary[working directory]]] nWhere option can be E
Definition: JMuonPostfit.sh:40
bool is_gseagen(const JHead &header)
Check for generator.
Definition: JHeadToolkit.hh:61
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
#define STATUS(A)
Definition: JMessage.hh:63
double numberOfEvents
Number of events.
Definition: JHead.hh:721
const Trk & get_primary(const Evt &evt)
Get primary.
static const double DENSITY_SEA_WATER
Fixed environment values.
string outputFile
double E
Energy [GeV] (either MC truth or reconstructed)
Definition: Trk.hh:20
Auxiliary class for histogramming of effective volume.
Definition: JVolume.hh:29
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys...
Definition: JManager.hh:43
Monte Carlo run header.
Definition: JHead.hh:1234
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
set_variable E_E log10(E_{fit}/E_{#mu})"
#define NOTICE(A)
Definition: JMessage.hh:64
#define ERROR(A)
Definition: JMessage.hh:66
then awk string
JAANET::genvol genvol
Definition: JHead.hh:1597
#define FATAL(A)
Definition: JMessage.hh:67
int type
MC: particle type in PDG encoding.
Definition: Trk.hh:24
static const int W2LIST_GSEAGEN_WATER_INT_LEN
Interaction length in pure water in m.
Auxiliary base class for list of file names.
std::vector< filescanner_type >::iterator iterator
static const int W2LIST_GSEAGEN_P_EARTH
Transmission probability in the Earth (XSEC_MEAN and COLUMN_DEPTH used to compute PEarth) ...
static const int WEIGHTLIST_DIFFERENTIAL_EVENT_RATE
Event rate per unit of flux (c.f. taglist document) [GeV m2 sr].
Definition: weightlist.hh:14
Primary particle.
Definition: JHead.hh:1174
const JHead & getHeader() const
Get header.
Definition: JHead.hh:1270
Auxiliary class for organising Monte Carlo file scanners associated with event weighters.
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Definition: Trk.hh:14
std::vector< filescanner_type >::const_iterator const_iterator
int numberOfBins
number of bins for average CDF integral of optical module
Definition: JSirene.cc:69
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