FairRoot/PandaRoot
PndMQFileSink.cxx
Go to the documentation of this file.
1 /*
2  * File: PndMQFileSink.tpl
3  * Author: winckler, A. Rybalchenko
4  *
5  * Created on March 11, 2014, 12:12 PM
6  */
7 
8 // Implementation of PndMQFileSink::Run() with Boost transport data format
9 #include <PndMQFileSink.h>
10 
12 {
14  {
15  int receivedMsgs = 0;
16 
17  // store the channel references to avoid traversing the map on every loop iteration
18  FairMQChannel& dataInChannel = fChannels.at("data-in").at(0);
19 
20  while (CheckCurrentState(RUNNING))
21  {
22  FairMQMessage* msg = fTransportFactory->CreateMessage();
23 
24  if (dataInChannel.Receive(msg) > 0)
25  {
26  receivedMsgs++;
27  string msgStr(static_cast<char*>(msg->GetData()), msg->GetSize());
28  istringstream ibuffer(msgStr);
29  boost::archive::binary_iarchive InputArchive(ibuffer);
30  LOG(INFO) << "Received Message: " << receivedMsgs;
31  try
32  {
33  InputArchive >> fHitVector;
34  }
35  catch (boost::archive::archive_exception& e)
36  {
37  LOG(ERROR) << e.what();
38  }
39 
40  int numInput = fHitVector.size();
41  fOutput->Delete();
42 
43  for (Int_t i = 0; i < numInput; ++i)
44  {
45  new ((*fOutput)[i]) PndSdsDigiTopix4(fHitVector.at(i));
46  // LOG(INFO) << "Data: " << i << " " << fHitVector.at(i).GetTimeStamp();
47  }
48 
49  if (fOutput->IsEmpty())
50  {
51  LOG(ERROR) << "PndMQFileSink::Run(): No Output array!";
52  }
53 
54  fTree->Fill();
55  }
56 
57  delete msg;
58 
59  if (fHitVector.size() > 0)
60  {
61  fHitVector.clear();
62  }
63  }
64 
65  LOG(INFO) << "I've received " << receivedMsgs << " messages!";
66  }
67  else
68  {
69  LOG(ERROR) << " Boost Serialization not ok";
70  }
71 }
Int_t i
Definition: run_full.C:25
Data class to store the digi output of a pixel module.
bool fHasBoostSerialization
vector< PndSdsDigiTopix4 > fHitVector
virtual void Run()
TClonesArray * fOutput