FairRoot/PandaRoot
PndMQTopix4OnlineHisto.cxx
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence version 3 (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
15 #include <boost/thread.hpp>
16 #include <boost/bind.hpp>
17 #include <boost/archive/binary_iarchive.hpp>
18 #include <PndMQTopix4OnlineHisto.h>
19 
20 #include "baseMQtools.h"
21 
22 #include "FairMQLogger.h"
23 #include "mrfdata_8b.h"
24 #include "PndSdsDigiTopix4.h"
25 #include "TSystem.h"
26 
27 #include <TH2.h>
28 #include <TCanvas.h>
29 
30 
31 using namespace std;
32 
33 PndMQTopix4OnlineHisto::PndMQTopix4OnlineHisto() : fHasBoostSerialization(false)
34 {
35  gSystem->ResetSignal(kSigInterrupt);
36  gSystem->ResetSignal(kSigTermination);
37 
38  using namespace baseMQ::tools::resolve;
39  // coverity[pointless_expression]: suppress coverity warnings on apparant if(const).
40  if (has_BoostSerialization<PndSdsDigiTopix4, void(boost::archive::binary_iarchive&, const unsigned int)>::value == 1)
42 }
43 
44 //void PndMQTopix4OnlineHisto::CustomCleanup(void *data, void *object)
45 //{
46 // delete (string*)object;
47 //}
48 
50 {
51  LOG(INFO) << "Boost Serialization "<< fHasBoostSerialization;
53  FairMQChannel& dataInChannel = fChannels.at("data-in").at(0);
54  int receivedMsgs = 0;
55 
56  TH2* h2 = new TH2D("h2","h2", 21, -0.5, 20.5, 33, -0.5, 32.5);
57  TCanvas *c1 = new TCanvas("c1", "Dynamic Filling Example", 500, 100, 700, 500);
58  c1->Show();
59  while (CheckCurrentState(RUNNING))
60  {
61  FairMQMessage* msg = fTransportFactory->CreateMessage();
62 
63  if (dataInChannel.Receive(msg) > 0)
64  {
65  LOG(INFO) << "Received Message: ";
66  LOG(INFO) << receivedMsgs++;
67  LOG(INFO) << msg->GetSize();
68 
69  string msgStr(static_cast<char*>(msg->GetData()), msg->GetSize());
70  istringstream ibuffer(msgStr);
71 
72  boost::archive::binary_iarchive InputArchive(ibuffer);
73 
74  try {
75  InputArchive >> fTopixData;
76  }
77  catch (boost::archive::archive_exception& e)
78  {
79  LOG(ERROR) << e.what();
80  }
81 
82  LOG(INFO) << "TopixData: " << fTopixData.size();
83 
84  if (fTopixData.size() > 0){
85  for (auto itr : fTopixData){
86  h2->Fill(itr.GetPixelColumn(), itr.GetPixelRow());
87  }
88  }
89  delete(msg);
90 
91  const int kUPDATE = 100;
92  if (receivedMsgs){
93  if (receivedMsgs == kUPDATE) h2->Draw("colz");
94  c1->Modified();
95  c1->Update();
96  }
97 
98  if (fTopixData.size() > 0)
99  fTopixData.clear();
100  }
101  }
102  }
103 }
104 
106 {
107 }
Data class to store the digi output of a pixel module.
c1
Definition: plot_dirc.C:35
std::vector< PndSdsDigiTopix4 > fTopixData