#include #include #include #include #include "TROOT.h" #include "TGraph.h" #include "TH1D.h" #include "JROOT/JGraph.hh" #include "JROOT/JManager.hh" #include "JMath/JMath.hh" #include "JPhysics/JConstants.hh" #include "JDetector/JDetector.hh" #include "JDetector/JDetectorToolkit.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * Auxiliary program to draw the z-positions of the modules in detector. * \author mdejong */ int main(int argc, char**argv) { using namespace std; using namespace JPP; string detectorFile; string outputFile; int debug; try { JParser<> zap("Auxiliary program to draw the z-positions of the modules in detector."); zap['a'] = make_field(detectorFile, "detector file") = JPARSER::initialised(); zap['o'] = make_field(outputFile, "graphics output") = "detector.root"; zap['d'] = make_field(debug) = 1; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } JDetector detector; try { load(detectorFile, detector); } catch(const JException& error) { FATAL(error); } const double V = 0.61 * C; JManager H1(new TH1D("H[%].s", NULL, 500, -1.0e3, 1.0e+3)); map HA; map z0; map > z1; for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) { if (module->getFloor() == 1) { z0[module->getString()] = module->getZ() - getAverage(make_array(module->begin(), module->end(), &JPMT::getT0)) * V; } z1[module->getString()][module->getFloor()] = module->getZ(); } for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) { if (module->getFloor() != 0) { const double ds = module->getZ() - getAverage(make_array(module->begin(), module->end(), &JPMT::getT0)) * V - z0[module->getString()]; HA[module->getString()].put((Double_t) module->getFloor(), module->getZ()); H1[module->getString()]->Fill(ds); } } TFile out(outputFile.c_str(), "recreate"); out << H1; for (map::const_iterator i = HA.begin(); i != HA.end(); ++i) { out << JGraph(i->second, MAKE_CSTRING("G[" << i->first << "].string")); } for (auto& string : z1) { JGraph_t g1; for (auto& module : string.second) { if (module.first > 0 && string.second.count(module.first - 1) != 0) { g1.put((Double_t) module.first, module.second - string.second[module.first - 1]); } } out << JGraph(g1, MAKE_CSTRING("G[" << string.first << "].floor")); } out.Write(); out.Close(); }