#include #include #include #include #include "JPhysics/JPDFTable.hh" #include "JIO/JFileStreamIO.hh" #include "JTools/JHistogram1D_t.hh" #include "JTools/JHistogramMap_t.hh" #include "JTools/JTransformableMultiHistogram.hh" #include "JTools/JFunction1D_t.hh" #include "JTools/JFunctionalMap_t.hh" #include "JGeometry3D/JAngle3D.hh" #include "JGeometry3D/JVersor3D.hh" #include "JPhysics/JConstants.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" #include "JPhysics/JPDFTransformer.hh" /** * \file * * Program to add 5-dimensional histograms of shower light * \author jseneca */ int main(int argc, char **argv) { using namespace std; using namespace JPP; vector inputFile; string outputFile; int debug; try { JParser<> zap("Program to add multi-dimensional histograms of shower light"); zap['f'] = make_field(inputFile); zap['o'] = make_field(outputFile); zap['d'] = make_field(debug) = 1; if (zap.read(argc, argv) != 0) return 1; } catch(const exception &error) { FATAL(error.what() << endl); } typedef JHistogram1D_t::abscissa_type abscissa_type; typedef JTransformableMultiHistogram::maplist> JMultiHistogram_t; typedef JPDFTransformer<5, abscissa_type> JFunction5DTransformer_t; JMultiHistogram_t h0; // occurrence rate of PMT (used for normalisation) JMultiHistogram_t h1; // light from cascade h1.transformer.reset(new JFunction5DTransformer_t()); bool add = false; for(vector::const_iterator file_name = inputFile.begin(); file_name != inputFile.end(); ++file_name) { NOTICE("loading input from file " << *file_name << "... " << flush); try { JFileStreamReader in(file_name->c_str()); if (add) { JMultiHistogram_t p0; JMultiHistogram_t p1; p1.transformer.reset(new JFunction5DTransformer_t()); for(JMultiHistogram_t* p : { &p0, &p1 }) { in.load(*p); } in.close(); NOTICE("done." << endl); // Add new histogram to first histogram double integral1 = 0.0; double integral2 = 0.0; for(JMultiHistogram_t::super_iterator i0 = h0.super_begin(), i1 = h1.super_begin(), j0 = p0.super_begin(), j1 = p1.super_begin(); i1 != h1.super_end(); ++i0, ++i1, ++j0, ++j1) { integral1 += i0.getValue().getIntegral(); i0.getValue().add(j0.getValue()); i1.getValue().add(j1.getValue()); integral2 += i0.getValue().getIntegral(); } } else { for(JMultiHistogram_t* p : { &h0, &h1 }) { in.load(*p); } in.close(); NOTICE("done." << endl); add = true; } } catch(const JException& error) { FATAL(error.what() << endl); } } JFileStreamWriter out(outputFile.c_str()); NOTICE("Storing output to file " << outputFile << "... " << flush); for (const JMultiHistogram_t* p : { &h0, &h1 }) { out.store(*p); } out.close(); NOTICE("JAddHDE done." << endl); }