43 inline bool test_event(
const JCylinder3D& cylinder,
const Evt& event)
48 Bool_t accepted =
true;
71 inline Vec get_coord_origin(
const JHead &header)
81 NOTICE(
"JVolume1D::get_coord_origin() Coordinate origin (x, y, z) " << coord_origin <<
" read from header" << endl);
87 NOTICE(
"JVolume1D::get_coord_origin() Coordinate origin (x, y, z) " << coord_origin <<
" calculated from can dimensions (zmin, zmax, r) " << header.
can.
zmin <<
" " << header.
can.
zmax <<
" " << header.
can.
r << endl);
91 FATAL(
"JVolume1D::get_coord_origin() Error in determining the coordinate origin.");
105 int main(
int argc,
char **argv)
109 using namespace KM3NETDAQ;
126 JParser<> zap(
"Example program to histogram neutrino effective volume for triggered events. For genie/gSeaGen events a histogram depicting the fraction of events that triggered the detector inside the instrumented volume is also shown.");
131 zap[
'R'] =
make_field(wall,
"Addition margin around the volume in which the considered events must reside") = 0.0;
132 zap[
'X'] =
make_field(logx,
"Use logarithm of energy");
133 zap[
'N'] =
make_field(numberOfBins,
"Number of bins in the energy range of the MC simulation") = 10;
135 zap[
'a'] =
make_field(detectorFile,
"Detector file: if not provided, trigger fraction is not calculated") =
"";
139 catch(
const exception &error) {
140 FATAL(error.what() << endl);
158 if (detectorFile !=
"") {
172 const JHead buffer(head);
174 const bool genie =
is_genie(buffer);
177 const JVolume volume(head, logx);
187 NOTICE(
"JVolume1D: Instrumented volume dimensions (zmin, zmax, r): " << instvol.getZmin() <<
" " << instvol.getZmax() <<
" " << instvol.getRadius() << endl );
195 TH1D hV(
"hV",
"effective volume in km^3" , numberOfBins, volume.
getXmin(), volume.
getXmax());
196 TH1D hF(
"hF",
"n_trig/n_gen in instrumented volume", numberOfBins, volume.
getXmin(), volume.
getXmax());
204 NOTICE(
"JVolume1D: Scanning triggered events." << endl);
205 while (inputFile.hasNext()) {
207 STATUS(
"event: " << setw(10) << inputFile.getCounter() <<
'\r');
DEBUG(endl);
211 const Evt*
event = ps;
216 const double E = neutrino.
E;
222 hV.Fill(volume.
getX(E), test_event(canvol, *event) ? 1.0 : 0.0);
225 hF.Fill(volume.
getX(E), test_event(instvol, *event) ? 1.0 : 0.0);
230 hV.Fill(volume.
getX(E), volume.
getW(hV.GetXaxis(),
E));
235 WARNING(
"JVolume1D: cannot find neutrino in triggered event " << inputFile.getCounter() );
248 TH1D* hNV = (TH1D*) hV.Clone(
"hNV");
252 TH1D* hNF = (TH1D*) hF.Clone(
"hNF");
255 NOTICE(
"JVolume1D: Scanning generated events." << endl);
268 const double E = neutrino.
E;
270 hNV->Fill(volume.
getX(E), test_event(canvol, *event) ? 1.0 : 0.0);
271 hNF->Fill(volume.
getX(E), test_event(instvol, *event) ? 1.0 : 0.0);
275 WARNING(
"JVolume1D: cannot find neutrino in generated event " << inputFile.getCounter() );
282 FATAL(
"JVolume1D: generated events not stored in the input file, JTriggerEfficiency should be run without option -O");
290 hV.Scale(canvol.getVolume()*1e-9);
Utility class to parse command line options.
virtual const pointer_type & next()
Get next element.
ROOT TTree parameter settings.
Synchronously read DAQ events and Monte Carlo events (and optionally other events).
bool has_neutrino(const Evt &evt)
Test whether given event has an incoming neutrino.
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Auxiliary class to synchronously read DAQ events and Monte Carlo events (and optionally other events)...
static counter_type max()
Get maximum counter value.
Double_t getX(const Double_t E, double constrain=false) const
Get abscissa value.
double E
Energy [GeV] (either MC truth or reconstructed)
Data structure for detector geometry and calibration.
Double_t getXmin() const
Get minimal abscissa value.
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
Auxiliary class for defining the range of iterations of objects.
The Vec class is a straightforward 3-d vector, which also works in pyroot.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
void addMargin(const double D)
Add (safety) margin.
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
Double_t getW(TAxis *axis, const Double_t E) const
Get bin width corrected energy spectrum dependent weight.
General purpose messaging.
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
virtual bool hasNext()
Check availability of next element.
General purpose class for object reading from a list of file names.
Utility class to parse command line options.
bool is_inside(const JVector3D &pos) const
Check whether given point is inside cylinder.
counter_type getCounter() const
Get counter.
const JLimit & getLimit() const
Get limit.
const Trk & get_neutrino(const Evt &evt)
Get incoming neutrino.
JAANET::coord_origin coord_origin
General purpose class for multiple pointers.
bool is_valid(T JHead::*pd) const
Check validity of given data member in Head.
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Double_t getXmax() const
Get maximal abscissa value.
Vec coord_origin() const
Get coordinate origin.
Auxiliary class for histogramming of effective volume.
bool is_genie(const JHead &header)
Check for generator.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
then usage $script[input file[working directory[option]]] nWhere option can be E
#define DEBUG(A)
Message macros.
JPosition3D getPosition(const Vec &v)
Get position.
int main(int argc, char *argv[])