69 pt::read_json(name, conf);
70 pt::ptree pads = conf.get_child(
"modules");
71 for (
auto v = pads.begin();
v != pads.end();
v++) {
72 cout << (*v).second.get_optional<Int_t>(
"nAsicChannels") << endl;
73 pt::ptree maps = (*v).second.get_child(
"channelMapping");
74 for (
auto m = maps.begin();
m != maps.end();
m++) {
76 .LayerType = (*m).second.get<
char>(
"layerType"),
77 .channelLow = (*m).second.get<
int>(
"chLow"),
78 .channelHi = (*m).second.get<
int>(
"chHigh")});
79 pt::ptree strips = (*m).second.get_child(
"stripsMapping");
80 for (
auto stripNode = strips.begin(); stripNode != strips.end(); stripNode++) {
81 auto it = (*stripNode).second.begin();
84 int stripId = (it)->second.get_value<
int>();
85 int chanlId = (++it)->second.get_value<
int>();
90 }
catch (boost::exception& e) {
91 cerr << boost::diagnostic_information(e);
92 cout <<
"Unable to parse the channel map!\n" << endl;
193int GetCluster(vector<int>& input, vector<float>& mean,
float& sig)
204 vector<ClusterInfo> clusters;
207 float dif = input[iCh] - mean[iCh];
214 printf(
"new {%2zu, %2d}\n", start, len);
215 clusters.push_back(ClusterInfo{(int)start, len});
220 sort(begin(clusters), end(clusters), [](ClusterInfo& a, ClusterInfo& b) ->
bool {
return a.width < b.width; });
221 if (clusters.size()) {
223 ClusterInfo&
max = clusters[clusters.size() - 1];
224 printf(
"min %d max %d\n", clusters[0].width,
max.width);
225 for (
int iCh =
max.start; iCh < (
max.start +
max.width); ++iCh)
226 sig += input[iCh] - mean[iCh];
228 printf(
"mean sig %f\n", sig);
229 return (
max.start +
max.width / 2);
241 for (
auto& h :
hVec) {
247 for (
size_t iChar = 0; iChar <
channel_maps.size(); iChar++) {
249 for (
size_t iEvent = 0; iEvent <
adc1_ch[iChar].size(); iEvent++) {
270 cb[iChar].push_front(move(cur));
273 size_t event_count = 0;
279 for (
size_t iSpill = 0; iSpill <
cb[iChar].size(); iSpill++) {
280 sum +=
cb[iChar][iSpill][iCh];
283 sum /= (float)event_count;
291 for (
size_t iEvent = 0; iEvent <
adc1_ch[0].size(); iEvent++) {
292 bitset<NChannels_run9> x = 0;
293 bitset<NChannels_run9> y = 0;
294 for (
size_t iChar = 0; iChar <
channel_maps.size(); iChar++) {
364 string name = string(getenv(
"VMCWORKDIR")) +
"/input/" +
"Prof_map_run_9.json";
367 Int_t _webPort = 10000;
368 string TargetBoardId =
"board1";
369 string ServerMode =
"fastcgi";
372 SourceAddr = argv[1];
375 _webPort = stoi(str);
378 TargetBoardId = argv[3];
381 ServerMode = argv[4];
383 TString cgiStr = Form(
"%s:%d;noglobal", ServerMode.data(), _webPort);
384 THttpServer* fServer =
new THttpServer(cgiStr.Data());
387 fServer->Register(
"/",
can);
392 for (
size_t iMap = 0; iMap <
NChars; ++iMap) {
394 TH1* h =
new TH1F(Form(
"h%c_%c_strips", map.ChannelName, map.LayerType),
396 TH1* hMean =
new TH1F(Form(
"h%c_%c_strips_mean", map.ChannelName, map.LayerType),
399 new TH1F(Form(
"h%c_%c_sig", map.ChannelName, map.LayerType),
401 TH1* hPed =
new TH2F(Form(
"h%c_%c_ped", map.ChannelName, map.LayerType),
402 Form(
"%c %c side pedestals", map.ChannelName, map.LayerType),
ASIC_channel, 0,
412 h->SetTitleSize(0.1);
414 can2d->Divide(1, 1, 0.001, 0.001);
415 fServer->Register(
"/",
can2d);
424 for (
size_t iChar = 0; iChar <
channel_maps.size(); iChar++) {
430 void* _ctx =
nullptr;
431 void* _rawSocket =
nullptr;
432 _ctx = zmq_ctx_new();
433 _rawSocket = zmq_socket(_ctx, ZMQ_SUB);
434 if (_rawSocket == NULL) {
438 if (zmq_connect(_rawSocket, SourceAddr) != 0) {
446 if (zmq_setsockopt(_rawSocket, ZMQ_SUBSCRIBE, NULL, 0) == -1) {
450 printf(
"MonProf listens to %s\n", SourceAddr);
454 TBufferFile t(TBuffer::kRead);
456 bool keepWorking = kTRUE;
457 bool isReceiving = kTRUE;
458 const Int_t MaxStrLen = 100;
459 bool isIdFound = kFALSE;
460 bool isHeaderFound = kFALSE;
461 bool isTrailerFound = kFALSE;
462 while (keepWorking) {
467 gSystem->ProcessEvents();
471 Int_t frame_size = zmq_msg_recv(&msg, _rawSocket, ZMQ_DONTWAIT);
473 if (frame_size == -1) {
482 isReceiving = kFALSE;
483 keepWorking = kFALSE;
488 zmq_close(_rawSocket);
489 isReceiving = kFALSE;
490 keepWorking = kFALSE;
496 if (frame_size < MaxStrLen) {
497 string str(
static_cast<char*
>(zmq_msg_data(&msg)), zmq_msg_size(&msg));
498 printf(
"str %s\n", str.c_str());
501 isTrailerFound = kTRUE;
505 isHeaderFound = kTRUE;
509 if (str == TargetBoardId) {
517 ProcessBuffer(
static_cast<uint32_t*
>(zmq_msg_data(&msg)), zmq_msg_size(&msg) / 4);
521 size_t opt_size =
sizeof(recv_more);
522 if (zmq_getsockopt(_rawSocket, ZMQ_RCVMORE, &recv_more, &opt_size) == -1) {
523 printf(
"ZMQ socket options error #%s\n", zmq_strerror(errno));
528 }
while (recv_more && isReceiving && (!isTrailerFound));
530 if (isTrailerFound) {
540 isHeaderFound = kFALSE;
541 isTrailerFound = kFALSE;
551 zmq_close(_rawSocket);
552 zmq_ctx_destroy(_ctx);