#include #include #include #include #include "TROOT.h" #include "TH1D.h" #include "km3net-dataformat/online/JDAQ.hh" #include "JDetector/JDetectorAddressMapToolkit.hh" #include "JDetector/JDetectorAddressMap.hh" #include "JDetector/JDetectorAddressMapToolkit.hh" #include "JGizmo/JGizmoToolkit.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example program to test the module address map in conjunction with ROOT histograms. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; using namespace KM3NETDAQ; int debug; try { JParser<> zap("Example program to test the module address map in conjunction with ROOT histograms."); zap['d'] = make_field(debug) = 3; zap(argc, argv); } catch(const exception& error) { FATAL(error.what() << endl); } const JDetectorAddressMap& demo = getDetectorAddressMap(1); const JModuleAddressMap& memo = demo.getDefaultModuleAddressMap(); for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) { // pmt corresponds to TDC channel TH1D h0("h0", NULL, NUMBER_OF_PMTS, -0.5, NUMBER_OF_PMTS - 0.5); // test of a priori setting of axis labels according address map of module TH1D h1("h1", NULL, NUMBER_OF_PMTS, -0.5, NUMBER_OF_PMTS - 0.5); // test of a priori setting of axis labels according address map of module TH1D h2("h2", NULL, NUMBER_OF_PMTS, -0.5, NUMBER_OF_PMTS - 0.5); // test of a posteriori setting of axis labels according address map of module TH1D h3("h3", NULL, NUMBER_OF_PMTS, -0.5, NUMBER_OF_PMTS - 0.5); // test of a posteriori setting of axis labels according address map of module setAxisLabels(h0.GetXaxis(), memo); h0.Fill(memo.getPMTPhysicalAddress(pmt).toString().c_str(), 1.0); for (int i = 0; i != NUMBER_OF_PMTS; ++i) { const JPMTPhysicalAddress& address = memo[i]; const Double_t content = h0.GetBinContent(memo.getIndex(i) + 1); ASSERT(address.toString() == h0.GetXaxis()->GetBinLabel(i+1), "Test label bin " << setw(2) << (i+1) << ' ' << h0.GetXaxis()->GetBinLabel(i+1) << ' ' << address.toString() << endl); if (i == pmt) ASSERT(content == 1.0, "Test content PMT/bin " << setw(2) << pmt << '/' << setw(2) << i << " -> " << setw(2) << memo.getIndex(i) << ' ' << content); else ASSERT(content == 0.0, "Test content PMT/bin " << setw(2) << pmt << '/' << setw(2) << i << " -> " << setw(2) << memo.getIndex(i) << ' ' << content); } setAxisLabels(h1.GetXaxis(), memo); h1.Fill((Double_t) memo.getIndex(pmt), 1.0); for (int i = 0; i != NUMBER_OF_PMTS; ++i) { const JPMTPhysicalAddress& address = memo[i]; const Double_t content = h1.GetBinContent(memo.getIndex(i) + 1); ASSERT(address.toString() == h1.GetXaxis()->GetBinLabel(i+1), "Test label bin " << setw(2) << (i+1) << ' ' << h1.GetXaxis()->GetBinLabel(i+1) << ' ' << address.toString() << endl); if (i == pmt) ASSERT(content == 1.0, "Test content PMT/bin " << setw(2) << pmt << '/' << setw(2) << i << " -> " << setw(2) << memo.getIndex(i) << ' ' << content); else ASSERT(content == 0.0, "Test content PMT/bin " << setw(2) << pmt << '/' << setw(2) << i << " -> " << setw(2) << memo.getIndex(i) << ' ' << content); } h2.Fill((Double_t) memo.getIndex(pmt), 1.0); setAxisLabels(h2.GetXaxis(), memo); for (int i = 0; i != NUMBER_OF_PMTS; ++i) { const JPMTPhysicalAddress& address = memo[i]; const Double_t content = h2.GetBinContent(memo.getIndex(i) + 1); ASSERT(address.toString() == h2.GetXaxis()->GetBinLabel(i+1), "Test label bin " << setw(2) << (i+1) << ' ' << h2.GetXaxis()->GetBinLabel(i+1) << ' ' << address.toString() << endl); if (i == pmt) ASSERT(content == 1.0, "Test content PMT/bin " << setw(2) << pmt << '/' << setw(2) << i << " -> " << setw(2) << memo.getIndex(i) << ' ' << content); else ASSERT(content == 0.0, "Test content PMT/bin " << setw(2) << pmt << '/' << setw(2) << i << " -> " << setw(2) << memo.getIndex(i) << ' ' << content); } h3.Fill((Double_t) pmt, 1.0); setAxisLabels(h3, "X", memo); for (int i = 0; i != NUMBER_OF_PMTS; ++i) { const JPMTPhysicalAddress& address = memo[i]; const Double_t content = h3.GetBinContent(memo.getIndex(i) + 1); ASSERT(address.toString() == h3.GetXaxis()->GetBinLabel(i+1), "Test label bin " << setw(2) << (i+1) << ' ' << h3.GetXaxis()->GetBinLabel(i+1) << ' ' << address.toString() << endl); if (i == pmt) ASSERT(content == 1.0, "Test content PMT/bin " << setw(2) << pmt << '/' << setw(2) << i << " -> " << setw(2) << memo.getIndex(i) << ' ' << content); else ASSERT(content == 0.0, "Test content PMT/bin " << setw(2) << pmt << '/' << setw(2) << i << " -> " << setw(2) << memo.getIndex(i) << ' ' << content); } } return 0; }