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
JEffectiveMass1D.cc File Reference

Example program to histogram neutrino effective mass for triggered events by counting events inside the can volume. 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 "JDAQ/JDAQEventIO.hh"
#include "JGeometry3D/JCylinder3D.hh"
#include "JGeometry3D/JPosition3D.hh"
#include "JAAnet/JVolume.hh"
#include "JAAnet/JHeadToolkit.hh"
#include "JAAnet/JAAnetToolkit.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JTriggeredFileScanner.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 by counting events inside the can volume.


All generated events should therefore be available in the input file(s).
This implies that option JSirene -N 0 should be used and option JTriggerEfficiency -O should not be used.
Alternatively, the option -C can be used to specify a cylinder as the can.
The unit of the contents of the histogram is $Mton$ or $km^{3}$.

Author
mdejong, bstrandberg, bjung

Definition in file JEffectiveMass1D.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 47 of file JEffectiveMass1D.cc.

48 {
49  using namespace std;
50  using namespace JPP;
51  using namespace KM3NETDAQ;
52 
53  JMultipleFileScanner_t inputFiles;
54  string outputFile;
55  double margin;
56  bool logx;
57  int numberOfBins;
58  JCylinder3D cylinder;
59  std::string option;
60  int debug;
61 
62 
63  try {
64 
65  JParser<> zap("Example program to histogram neutrino effective mass for triggered events.");
66 
67  zap['f'] = make_field(inputFiles);
68  zap['o'] = make_field(outputFile) = "Meff.root";
69  zap['R'] = make_field(margin, "Margin around the volume in which the considered events must reside") = 0.0;
70  zap['X'] = make_field(logx, "Use logarithm of energy");
71  zap['N'] = make_field(numberOfBins, "Number of bins in the energy range of the MC simulation") = 10;
72  zap['C'] = make_field(cylinder, "User cylinder") = JPARSER::initialised();
73  zap['O'] = make_field(option, "Result option") = Mass_t, Volume_t;
74  zap['d'] = make_field(debug) = 2;
75 
76  zap(argc, argv);
77  }
78  catch(const exception &error) {
79  FATAL(error.what() << endl);
80  }
81 
82  try{
83 
84  double Xmin = numeric_limits<double>::max();
85  double Xmax = numeric_limits<double>::lowest();
86 
87  JEvtWeightFileScannerSet<> scanners(inputFiles);
88 
89  for (JEvtWeightFileScannerSet<>::const_iterator scanner = scanners.cbegin(); scanner != scanners.cend(); ++scanner) {
90 
91  const JVolume volume(scanner->getHeader(), logx);
92 
93  if (volume.getXmin() < Xmin) { Xmin = volume.getXmin(); }
94  if (volume.getXmax() > Xmax) { Xmax = volume.getXmax(); }
95  }
96 
97  JManager<int, TH1D> hM (new TH1D("hM[%]", NULL, numberOfBins, Xmin, Xmax));
98  JManager<int, TH1D> hNM(new TH1D("hNM[%]", NULL, numberOfBins, Xmin, Xmax));
99 
100  for (JEvtWeightFileScannerSet<>::iterator scanner = scanners.begin(); scanner != scanners.end(); ++scanner) {
101 
102  const JHead header = scanner->getHeader();
103 
104  NOTICE("Scanning file type " << scanner->getName() << endl);
105  DEBUG (header << endl);
106 
107  JCylinder3D can = cylinder;
108 
109  if (can.getVolume() == 0.0) {
110  can = getCylinder(header);
111  }
112 
113  can.addMargin(margin);
114 
115  NOTICE("Cylinder, including margin: " << can << endl);
116 
117  //------------------------------------------------------------------------------
118  // loop over all generated events in the input files
119  //------------------------------------------------------------------------------
120 
121  size_t N = 0;
122 
123  while (scanner->hasNext()) {
124 
125  STATUS("event: " << setw(10) << scanner->getCounter() << '\r'); DEBUG(endl);
126 
127  const Evt* event = scanner->next();
128  const Trk& primary = get_primary(*event);
129  const JVertex3D& vertex = getVertex(*event);
130 
131  if (event->mc_hits.empty()) {
132  N += 1;
133  }
134 
135  const double x = logx ? log10(primary.E) : primary.E;
136 
137  if (can.is_inside(vertex)) {
138  hNM[primary.type]->Fill(x);
139  }
140  }
141  STATUS(endl);
142 
143  if (N == 0) {
144  ERROR("No events with zero hits -> use application JEffectiveMassOffline1D." << endl);
145  }
146 
147  //------------------------------------------------------------------------------
148  // loop over triggered events in the input files
149  //------------------------------------------------------------------------------
150 
151  for (JTriggeredFileScanner<> in(scanner->getFilelist()); in.hasNext(); ) {
152 
153  STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl);
154 
155  const Evt* event = in.next();
156  const Trk& primary = get_primary(*event);
157 
158  double x = logx ? log10(primary.E) : primary.E;
159  double y = 0.0;
160 
161  if (option == Mass_t) {
162  y = can .getVolume() * DENSITY_SEA_WATER * 1e-6; // Mton
163  } else if (option == Volume_t) {
164  y = can .getVolume() * 1.0e-9; // km^3
165  }
166 
167  hM[primary.type]->Fill(x, y);
168  }
169  STATUS(endl);
170  }
171 
172  //------------------------------------------------------------------------------
173  // convert 'generated' and 'triggered' histograms to effective mass
174  //------------------------------------------------------------------------------
175 
176  for (int pdg : get_keys(hM)) {
177  hM[pdg]->Divide(hNM[pdg]);
178  }
179 
180  TFile out(outputFile.c_str(), "recreate");
181 
182  out << hM;
183 
184  out.Close();
185  }
186  catch(const JException& error) {
187  FATAL(error << endl);
188  }
189 }
JVertex3D getVertex(const Trk &track)
Get vertex.
Utility class to parse command line options.
Definition: JParser.hh:1711
General exception.
Definition: JException.hh:24
Double_t getXmin() const
Get minimal abscissa value.
Definition: JVolume.hh:91
then usage $script< input file >[option[primary[working directory]]] nWhere option can be E
Definition: JMuonPostfit.sh:40
JCylinder3D getCylinder(const JHead &header)
Get cylinder corresponding to the positions of generated tracks (i.e.
#define STATUS(A)
Definition: JMessage.hh:63
Auxiliary class to synchronously read DAQ events and Monte Carlo events (and optionally other events)...
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:84
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
Cylinder object.
Definition: JCylinder3D.hh:39
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
void addMargin(const double D)
Add (safety) margin.
Definition: JCylinder3D.hh:172
#define FATAL(A)
Definition: JMessage.hh:67
int type
MC: particle type in PDG encoding.
Definition: Trk.hh:24
double getVolume() const
Get volume.
Definition: JCylinder3D.hh:185
Auxiliary base class for list of file names.
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
Definition: JMuonPostfit.sh:40
std::vector< filescanner_type >::iterator iterator
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
bool is_inside(const JVector3D &pos) const
Check whether given point is inside cylinder.
Definition: JCylinder3D.hh:208
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:70
const array_type< JKey_t > & get_keys(const std::map< JKey_t, JValue_t, JComparator_t, JAllocator_t > &data)
Method to create array of keys of map.
Definition: JVectorize.hh:139
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
The cylinder used for photon tracking.
Definition: JHead.hh:575