#include <cstdio> #include <cstdlib> #include "TApplication.h" #include "boost/program_options.hpp" #include "math.h" #include "Riostream.h" #include "TMath.h" #include "TApplication.h" #include "KVEnv.h" #include "KVString.h" #include "MFMFileReader.h" #include "KVDataRepositoryManager.h" #include "KVDataSetManager.h" #include "KVMultiDetArray.h" #include "KVINDRADetector.h" #include "KVNameValueList.h" #include "KVINDRA.h" #include "TRandom3.h" #include <iostream> #include <fstream> #include <string> #include <sstream> #include "zmq.hpp" #include "MergerInfo.pb.h" #include "merger_spy.h" #include "MFMMergeFrame.h" #include "MFMFaziaFrame.h" #include "MFMMesytecMDPPFrame.h" namespace po = boost::program_options; using namespace std; int main(int argc, char* argv[]) { std::string hostin, portin, urlin; std::string hostout, portout, urlout; std::string path_to_mesytec_conf; bool simu = false; po::options_description desc("\nindra-scaler - allowed options"); desc.add_options() ("help", "produce help message") ("hostin" , po::value<std::string>() , "[optional] NARVAL publisher hostname to contact (default: ganp548)") ("portin" , po::value<std::string>() , "[optional] NARVAL merger publisher port (default: 9098)") ("hostout" , po::value<std::string>() , "[optional] this publisher hostname to contact (default: *)") ("portout" , po::value<std::string>() , "[optional] this publisher port (default: 9099)") ("config-path" , po::value<std::string>() , "[optional] path to Mesytec config files (/home/eindra/ganacq_manip/e818_test_indra)") ("simu" , "[optional] simulation mode"); po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); if(vm.count("help")) { std::cout << desc << "\n"; return 0; } if (vm.count("hostin")) hostin = vm["hostin"].as<std::string>(); else hostin = "ganp548"; if (vm.count("portin")) portin = vm["portin"].as<std::string>(); else portin = "9098"; if (vm.count("hostout")) hostout = vm["hostout"].as<std::string>(); else hostout = "*"; if (vm.count("portout")) portout = vm["portout"].as<std::string>(); else portout = "9099"; if (vm.count("simu")) simu = true; if (vm.count("config-path")) path_to_mesytec_conf = vm["config-path"].as<std::string>(); else path_to_mesytec_conf = "/home/eindra/ganacq_manip/e818_test_indra"; if(path_to_mesytec_conf=="") { cerr << "ERROR: you forgot to give path to Mesytec config files (crate_map.dat & detector_correspondence.dat)" << endl; cerr << "ERROR: use option --config-path=[path]" << endl; exit(1); } urlin = "tcp://" + hostin + ":" + portin; std::cout << "trying to connect to : " << urlin << std::endl; urlout = "tcp://" + hostout + ":" + portout; std::cout << "histo published on : " << urlout << std::endl; TApplication* rootapp= new TApplication("MERGER SPY", &argc, argv); merger_spy spy(1,simu); //once fixed Dt, use the same value in the merger-gui rate display xaxis spy.ConnectZmqIn(urlin); spy.ConnectZmqOut(urlout); spy.Run(); rootapp->Run(); return 0; } //void FillSimulatedBuffer(myprotobuf::merger_info &minfo, vector<TH1F> &histos) //{ // TF1 ff("ff","gaus",0,10); // ff.SetParameters(1,3,1); // auto hf = minfo.add_histo_frames(); // std::string fname = "Merger"; // hf->set_name(fname.c_str()); // for(int ih=0; ih<10; ih++){ // auto hh = hf->add_histos(); // std::stringstream tmp; // tmp << "Histogram #" << ih; // std::string name = tmp.str(); // hh->set_name(name.c_str()); // hh->set_labelx("time (ns)"); // auto& dist = histos[ih]; // for(int ip=0; ip<10; ip++) dist.Fill(ff.GetRandom()); // for(int ib=0; ib<dist.GetXaxis()->GetNbins(); ib++) // { // auto pp = hh->add_points(); // pp->set_x(dist.GetXaxis()->GetBinCenter(ib)); // pp->set_y(dist.GetBinContent(ib)); // } // } // auto rf = minfo.add_rate_frames(); // fname = "Rates"; // rf->set_name(fname.c_str()); // for(int ih=0; ih<3; ih++){ // auto hh = rf->add_rates(); // std::string name = ""; // switch(ih){ // case 0: name = "Merged"; break; // case 1: name = "INDRA"; break; // case 2: name = "FAZIA"; break; // } // hh->set_name(name.c_str()); // double val = gRandom->Rndm()*100; // hh->set_value(val); // } //}