Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#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);
// }
//}