Jpp in_tag_pdf_generation
the software that should make you happy
Loading...
Searching...
No Matches
JEffectiveMassOnline1D.cc File Reference

Example program to histogram neutrino effective mass for triggered events for online reconstruction files, using the event weights only. 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 "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 "JPhysics/JConstants.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 online 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 JEffectiveMassOnline1D.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 42 of file JEffectiveMassOnline1D.cc.

43{
44 using namespace std;
45 using namespace JPP;
46 using namespace KM3NETDAQ;
47
48 JMultipleFileScanner_t inputFiles;
49 string outputFile;
50 bool logx;
51 int numberOfBins;
52 std::string option;
53 JDAQTriggerMask trigger_mask;
54 int debug;
55
56
57 try {
58
59 JParser<> zap("Example program to histogram neutrino effective mass for triggered events.");
60
61 zap['f'] = make_field(inputFiles);
62 zap['o'] = make_field(outputFile) = "Meff.root";
63 zap['X'] = make_field(logx, "Use logarithm of energy");
64 zap['N'] = make_field(numberOfBins, "Number of bins in the energy range of the MC simulation") = 10;
65 zap['O'] = make_field(option, "Result option") = Mass_t, Volume_t;
66 zap['T'] = make_field(trigger_mask, "Trigger mask") = TRIGGER_MASK_ON;
67 zap['d'] = make_field(debug) = 2;
68
69 zap(argc, argv);
70 }
71 catch(const exception &error) {
72 FATAL(error.what() << endl);
73 }
74
75 try {
76
77 double Xmin = numeric_limits<double>::max();
78 double Xmax = numeric_limits<double>::lowest();
79
80 JEvtWeightFileScannerSet<> scanners(inputFiles);
81
82 for (JEvtWeightFileScannerSet<>::const_iterator scanner = scanners.cbegin(); scanner != scanners.cend(); ++scanner) {
83
84 const JVolume volume(scanner->getHeader(), logx);
85
86 if (volume.getXmin() < Xmin) { Xmin = volume.getXmin(); }
87 if (volume.getXmax() > Xmax) { Xmax = volume.getXmax(); }
88 }
89
90 JManager<int, TH1D> hm(new TH1D("hm[%]", option.c_str(), numberOfBins, Xmin, Xmax));
91
92 for (JEvtWeightFileScannerSet<>::iterator scanner = scanners.begin(); scanner != scanners.end(); ++scanner) {
93
94 const JHead header = scanner->getHeader();
95
96 NOTICE("Scanning file type " << scanner->getName() << endl);
97 DEBUG (header << endl);
98
99 const JEvtWeight& weighter = scanner->getEvtWeighter();
100
101 if (!header.is_valid(&JHead::genvol)) {
102 FATAL("Mising normalisation in header." << endl);
103 }
104
105 double Wnorm = header.genvol.numberOfEvents;
106
107 if (header.is_valid(&JHead::cut_nu))
108 Wnorm *= 2*PI * (header.cut_nu.cosT.getUpperLimit() - header.cut_nu.cosT.getLowerLimit());
109 else
110 Wnorm *= 4*PI;
111
112 for (JTriggeredFileScanner<> in(scanner->getFilelist()); in.hasNext(); ) {
113
114 STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl);
115
117
118 const JDAQEvent* tev = ps;
119 const Evt* event = ps;
120 const Trk& primary = get_primary(*event);
121
122 if (tev->hasTriggerMask(trigger_mask)) {
123
124 double x = logx ? log10(primary.E) : primary.E;
125 double y = 0.0;
126 double w = (getVolume(weighter, *event) /
127 (logx ? log(10.0) * primary.E * hm->GetBinWidth(1) : hm->GetBinWidth(1)) /
128 Wnorm);
129
130 if (option == Mass_t) {
131 y = w * DENSITY_SEA_WATER * 1e-6; // Mton
132 } else if (option == Volume_t) {
133 y = w * 1e-9; // km^3
134 }
135
136 hm[primary.type]->Fill(x, y);
137 }
138 }
139 STATUS(endl);
140 }
141
142 TFile out(outputFile.c_str(), "recreate");
143
144 out << hm;
145
146 out.Close();
147 }
148 catch(const JException& error) {
149 FATAL(error << endl);
150 }
151}
string outputFile
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define STATUS(A)
Definition JMessage.hh:63
#define NOTICE(A)
Definition JMessage.hh:64
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
int numberOfBins
number of bins for average CDF integral of optical module
Definition JSirene.cc:73
Monte Carlo run header.
Definition JHead.hh:1236
JAANET::cut_nu cut_nu
Definition JHead.hh:1596
const JHead & getHeader() const
Get header.
Definition JHead.hh:1270
JAANET::genvol genvol
Definition JHead.hh:1600
bool is_valid(T JHead::*pd) const
Check validity of given data member in JHead.
Definition JHead.hh:1319
General exception.
Definition JException.hh:24
Utility class to parse command line options.
Definition JParser.hh:1698
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys.
Definition JManager.hh:47
T getLowerLimit() const
Get lower limit.
Definition JRange.hh:202
T getUpperLimit() const
Get upper limit.
Definition JRange.hh:213
Auxiliary class for trigger mask.
bool hasTriggerMask(const JDAQTriggerMask &mask) const
Has trigger bit pattern.
double getVolume(const JType< JEvtWeightGSeaGen > &type, const Evt &evt)
Get volume of given event according given weighter.
const Trk & get_primary(const Evt &evt)
Auxiliary function to retrieve the primary track of an event.
static const double PI
Mathematical constants.
static const double DENSITY_SEA_WATER
Fixed environment values.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
static const JDAQTriggerMask TRIGGER_MASK_ON
Trigger mask on;.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition Evt.hh:21
Abstract base class for event weighing.
Definition JEvtWeight.hh:31
Auxiliary class for histogramming of effective volume.
Definition JVolume.hh:29
JRange_t cosT
Cosine zenith angle range
Definition JHead.hh:420
double numberOfEvents
Number of events.
Definition JHead.hh:721
Primary particle.
Definition JHead.hh:1174
int type
Particle type.
Definition JHead.hh:1204
General purpose class for multiple pointers.
Auxiliary class for organising Monte Carlo file scanners associated with event weighters.
std::vector< filescanner_type >::const_iterator const_iterator
std::vector< filescanner_type >::iterator iterator
Auxiliary base class for list of file names.
Auxiliary class to synchronously read DAQ events and Monte Carlo events (and optionally other events)...
virtual bool hasNext() override
Check availability of next element.
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Definition Trk.hh:15