FairRoot/PandaRoot
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
PndMQTopix4Sorter Class Reference

#include <PndMQTopix4Sorter.h>

Inheritance diagram for PndMQTopix4Sorter:

Public Member Functions

 PndMQTopix4Sorter ()
 
virtual ~PndMQTopix4Sorter ()
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Protected Member Functions

virtual void Run ()
 

Protected Attributes

bool fHasBoostSerialization
 
std::vector< PndSdsDigiTopix4fTopixData
 
std::vector< PndSdsDigiTopix4fOutputData
 

Friends

class boost::serialization::access
 

Detailed Description

PndMQTopix4Sorter.h

Since
2014-10-10
Author
A. Rybalchenko

Definition at line 28 of file PndMQTopix4Sorter.h.

Constructor & Destructor Documentation

PndMQTopix4Sorter::PndMQTopix4Sorter ( )

Definition at line 33 of file PndMQTopix4Sorter.cxx.

References fHasBoostSerialization.

33  : 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 }
Data class to store the digi output of a pixel module.
PndMQTopix4Sorter::~PndMQTopix4Sorter ( )
virtual

Definition at line 169 of file PndMQTopix4Sorter.cxx.

170 {
171 }

Member Function Documentation

void PndMQTopix4Sorter::Run ( )
protectedvirtual

Definition at line 49 of file PndMQTopix4Sorter.cxx.

References PndMapSorterTpl< TData >::AddElement(), PndMapSorterTpl< TData >::DeleteOutputData(), fHasBoostSerialization, fOutputData, fTopixData, PndMapSorterTpl< TData >::GetOutputData(), status, PndMQStatus::STOP, PndMapSorterTpl< TData >::WriteOutAll(), and PndMapSorterTpl< TData >::WriteOutData().

50 {
51  LOG(INFO) << "Boost Serialization "<< fHasBoostSerialization;
53  FairMQChannel& dataInChannel = fChannels.at("data-in").at(0);
54  FairMQChannel& dataOutChannel = fChannels.at("data-out").at(0);
55 
56  int receivedMsgs = 0;
58 
59 
60  while (CheckCurrentState(RUNNING))
61  {
62  FairMQMessage* header = fTransportFactory->CreateMessage();
63  FairMQMessage* msg = fTransportFactory->CreateMessage();
64 
65  if (dataInChannel.Receive(header) > 0)
66  {
67  int status = *(static_cast<int*>(header->GetData()));
68 
69  if (dataInChannel.ExpectsAnotherPart())
70  {
71  if (dataInChannel.Receive(msg)){
72  string msgStr(static_cast<char*>(msg->GetData()), msg->GetSize());
73  istringstream ibuffer(msgStr);
74 
75  boost::archive::binary_iarchive InputArchive(ibuffer);
76 
77  try {
78  InputArchive >> fTopixData;
79  }
80  catch (boost::archive::archive_exception& e)
81  {
82  LOG(ERROR) << e.what();
83  }
84 
85  // LOG(INFO) << "TopixData: " << fTopixData.size();
86  // for (auto iter : fTopixData){
87  // LOG(INFO) << iter.GetTimeStamp();
88  // }
89 
90  bool endSorting = false;
91  double timeOfLast = 0;
92  if (fTopixData.size() > 0){
93  for (auto iter : fTopixData){
94  if (iter.GetTimeStamp() > 0){
95  sorter.AddElement(iter, iter.GetTimeStamp());
96  timeOfLast = iter.GetTimeStamp();
97  }
98  else {
99  endSorting = true;
100  // LOG(INFO) << "---END SORTING---";
101  }
102  }
103  if (endSorting == false){
104  sorter.WriteOutData(timeOfLast);
105  fOutputData = sorter.GetOutputData();
106  sorter.DeleteOutputData();
107  }
108  else if (endSorting == true || status == PndMQStatus::STOP){
109  LOG(INFO) << "EndSorting or STOP-Status " << status;
110  sorter.WriteOutAll();
111  fOutputData = sorter.GetOutputData();
112  fOutputData.push_back(PndSdsDigiTopix4());
113  sorter.DeleteOutputData();
114  endSorting = false;
115  }
116 
117  unique_ptr<FairMQMessage> headerCpy(fTransportFactory->CreateMessage(sizeof(int)));
118  headerCpy->Copy(header);
119  dataOutChannel.SendPart(headerCpy);
120 
121 
122  std::ostringstream obuffer;
123  boost::archive::binary_oarchive OutputArchive(obuffer);
124  OutputArchive << fOutputData;
125  int outputSize = obuffer.str().length();
126  unique_ptr<FairMQMessage> msg2(fTransportFactory->CreateMessage(outputSize));
127  memcpy(msg2->GetData(), obuffer.str().c_str(), outputSize);
128  dataOutChannel.Send(msg2);
129 
130  //LOG(INFO) << "Data: " << fTopixData.size() << " " << timeOfLast;
131  // LOG(INFO) << "Output: " << fOutputData.size() << " timeOfLast: " << timeOfLast;
132  // for(auto itr : fOutputData)
133  // LOG(INFO) << itr.GetTimeStamp();
134 
135  fTopixData.clear();
136  fOutputData.clear();
137  }
138  delete(msg);
139  delete (header);
140  }
141  }
142  // LOG(INFO) << "Received Message: " << receivedMsgs++ << " Size: " << msg->GetSize();
143  if (status == PndMQStatus::STOP){
144  LOG(INFO) << "STOP-Signal Received!";
145  sorter.WriteOutAll();
146  fOutputData = sorter.GetOutputData();
147  fOutputData.push_back(PndSdsDigiTopix4());
148  sorter.DeleteOutputData();
149 
150  unique_ptr<FairMQMessage> headerCpy(fTransportFactory->CreateMessage(sizeof(int)));
151  headerCpy->Copy(header);
152  dataOutChannel.SendPart(headerCpy);
153 
154  std::ostringstream obuffer;
155  boost::archive::binary_oarchive OutputArchive(obuffer);
156  OutputArchive << fOutputData;
157  int outputSize = obuffer.str().length();
158  unique_ptr<FairMQMessage> msg2(fTransportFactory->CreateMessage(outputSize));
159  memcpy(msg2->GetData(), obuffer.str().c_str(), outputSize);
160  dataOutChannel.Send(msg2);
161  }
162 
163 
164  }
165  }
166  }
167 }
virtual void WriteOutData(double time)
Data class to store the digi output of a pixel module.
std::vector< PndSdsDigiTopix4 > fTopixData
virtual std::vector< TData > GetOutputData()
std::vector< PndSdsDigiTopix4 > fOutputData
virtual void AddElement(TData digi, double timestamp)
virtual void DeleteOutputData()
int status[10]
Definition: f_Init.h:28
virtual void WriteOutAll()
template<class Archive >
void PndMQTopix4Sorter::serialize ( Archive &  ar,
const unsigned int  version 
)
inline

Definition at line 37 of file PndMQTopix4Sorter.h.

References fOutputData, and fTopixData.

38  {
39  ar& fTopixData;
40  ar& fOutputData;
41  }
std::vector< PndSdsDigiTopix4 > fTopixData
std::vector< PndSdsDigiTopix4 > fOutputData

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 47 of file PndMQTopix4Sorter.h.

Member Data Documentation

bool PndMQTopix4Sorter::fHasBoostSerialization
protected

Definition at line 48 of file PndMQTopix4Sorter.h.

Referenced by PndMQTopix4Sorter(), and Run().

std::vector<PndSdsDigiTopix4> PndMQTopix4Sorter::fOutputData
protected

Definition at line 52 of file PndMQTopix4Sorter.h.

Referenced by Run(), and serialize().

std::vector<PndSdsDigiTopix4> PndMQTopix4Sorter::fTopixData
protected

Definition at line 51 of file PndMQTopix4Sorter.h.

Referenced by Run(), and serialize().


The documentation for this class was generated from the following files: