FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairMQExHistoDevice.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 (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 #include "FairMQExHistoDevice.h"
9 
10 #include "RootSerializer.h"
11 
12 #include <TMath.h>
13 #include <chrono>
14 #include <thread>
15 
17  : FairMQDevice()
18  , fRandom(0)
19  , fArrayHisto()
20 {}
21 
23 
25 {
26  fh_histo1 = TH1F("histo1", "", 200, -0.5, 1.5);
27  fh_histo2 = TH1F("histo2", "", 1000, -5., 5.);
28  fh_histo3 = TH2F("histo3", "", 40, -2., 2., 40, -2., 2.);
29  fh_histo4 = TH2F("histo4", "", 40, -2., 2., 40, -2., 2.);
30 
31  fArrayHisto.Add(&fh_histo1);
32  fArrayHisto.Add(&fh_histo2);
33  fArrayHisto.Add(&fh_histo3);
34  fArrayHisto.Add(&fh_histo4);
35 }
36 
38 
40 
42 {
43  fh_histo1.Fill(fRandom.Uniform(0., 1.));
44  fh_histo2.Fill(fRandom.Gaus(0., 1.));
45  double x = fRandom.Uniform(0., 1.);
46  double y = fRandom.Uniform(x, 1.);
47  fh_histo3.Fill(x, y);
48  double r = fRandom.Uniform(0., 1.);
49  double phi = TMath::DegToRad() * fRandom.Uniform(0., 360.);
50  x = r * TMath::Cos(phi);
51  y = r * TMath::Sin(phi);
52  fh_histo4.Fill(x, y);
53 
54  FairMQMessagePtr message(NewMessage());
55  Serialize<RootSerializer>(*message, &fArrayHisto);
56 
57  for (auto& channel : fChannels) {
58  Send(message, channel.first.data());
59  }
60 
61  fh_histo1.Reset();
62  fh_histo2.Reset();
63  fh_histo3.Reset();
64  fh_histo4.Reset();
65 
66  std::this_thread::sleep_for(std::chrono::milliseconds(10));
67 
68  return true;
69 }
virtual bool ConditionalRun()