#include #include #include "TROOT.h" #include "TFile.h" #include "TH1D.h" #include "TH2D.h" #include "TProfile.h" #include "TGraph.h" #include "JSupport/JMultipleFileScanner.hh" #include "JSupport/JTreeScanner.hh" #include "JROOT/JRootToolkit.hh" #include "JROOT/JGraph.hh" #include "JROOT/JManager.hh" #include "JAcoustics/JEvt.hh" #include "JAcoustics/JSupport.hh" #include "Jeep/JPrint.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example program to plot acoustic fit results. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; JMultipleFileScanner inputFile; JLimit_t& numberOfEvents = inputFile.getLimit(); string outputFile; int debug; try { JParser<> zap("Example program to plot acoustic fit results."); zap['f'] = make_field(inputFile, "input file (output of JKatoomba[.sh])"); zap['n'] = make_field(numberOfEvents) = JLimit::max(); zap['o'] = make_field(outputFile) = "parramatta.root"; zap['d'] = make_field(debug) = 2; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } const JFormat_t format(4, 0, std::ios_base::fmtflags(), '0'); TH1D h1("chi2/NDF", NULL, 500, 0.0, 10.0); JGraph_t g0; JGraph_t g1; map GO; map GA; map GS; JManager H1(new TProfile("stretching[%]", NULL, 50, 0.0, 1.0e2)); JManager H2(new TH2D ("[%].tiltdeviation", NULL, 300, -4.0, +4.0, 300, -4.0, +4.0), '%', format); while (inputFile.hasNext()) { STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl); const JEvt* evt = inputFile.next(); h1.Fill(evt->chi2 / evt->ndf); const double t1 = 0.5 * (evt->UNIXTimeStart + evt->UNIXTimeStop); g0.put(t1, evt->nhit - evt->npar); g1.put(t1, evt->chi2 / evt->ndf); double sum_tx = 0; double sum_ty = 0; for (JEvt::const_iterator i = evt->begin(); i != evt->end(); ++i) { const int id = i->id; const double tx = i->tx * 1.0e3; // [mrad] const double ty = i->ty * 1.0e3; // [mrad] const double vs = i->vs * 1.0e2; // [%] const double ts = sqrt(tx*tx + ty*ty); sum_tx += tx; // [mrad] sum_ty += ty; // [mrad] H1 ->Fill(ts, vs); H1[id]->Fill(ts, vs); GO[id].put(t1, atan2(ty, tx)); GA[id].put(t1, ts); GS[id].put(t1, vs); } sum_tx /= evt->size(); sum_ty /= evt->size(); for (JEvt::const_iterator i = evt->begin(); i != evt->end(); ++i) { H2[i->id]->Fill(i->tx * 1.0e3 - sum_tx, i->ty * 1.0e3 - sum_ty); // [mrad] } } STATUS(endl); TFile out(outputFile.c_str(), "recreate"); out << h1 << JGraph(g0, "g0") << JGraph(g1, "g1"); out << H1 << *H1 << H2; for (map::const_iterator i = GO.begin(); i != GO.end(); ++i) { out << JGraph(i->second, MAKE_CSTRING("G[" << FILL(4,'0') << i->first << "].orientation")); } for (map::const_iterator i = GA.begin(); i != GA.end(); ++i) { out << JGraph(i->second, MAKE_CSTRING("G[" << FILL(4,'0') << i->first << "].amplitude")); } for (map::const_iterator i = GS.begin(); i != GS.end(); ++i) { out << JGraph(i->second, MAKE_CSTRING("G[" << FILL(4,'0') << i->first << "].stretching")); } out.Write(); out.Close(); }