FairRoot/PandaRoot
PndMQTopix4ProcessorTask.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_oarchive.hpp>
19 #include <queue>
20 
21 #include "baseMQtools.h"
22 
23 #include "FairMQLogger.h"
24 #include "mrfdata_8b.h"
25 #include "PndSdsDigiTopix4.h"
26 
27 
28 using namespace std;
29 
30 PndMQTopix4ProcessorTask::PndMQTopix4ProcessorTask() : fHasBoostSerialization(false)
31 {
32  using namespace baseMQ::tools::resolve;
33  bool checkOutputClass = false;
34 
35  if (is_same<boost::archive::binary_oarchive, boost::archive::binary_oarchive>::value)
36  {
37  if (has_BoostSerialization<PndSdsDigiTopix4, void(boost::archive::binary_oarchive&, const unsigned int)>::value == 1)
38  {
39  checkOutputClass = true;
41  }
42  }
43  LOG(INFO) << "HasBoostSerialization: " << fHasBoostSerialization;
44 }
45 
46 
48 {
49  TMrfData_8b* message = new TMrfData_8b();
50  message->setNumWords(fPayload->GetSize());
51  memcpy(reinterpret_cast<u_int8_t*>(&message->regdata[0]),fPayload->GetData(), fPayload->GetSize());
52 // LOG(INFO) << "Received message: \""
53 // << message->getNumWords() << " " << message->getNumBits()
54 // << "\"";
55  std::vector<ULong64_t> rawArray;
56  PndTopix4 topix;
57  rawArray = topix.GetRawData(message);
58  std::vector<std::vector<PndSdsDigiTopix4> > frames = fTopixDataReader.AnalyzeData(rawArray, 50);
59 
60  LOG(INFO) << "Frames.size " << frames.size();
61  if (frames.size() > 0)
62  LOG(INFO) << "Frames.front().size() " << frames.front().size();
63  if (frames.size() > 0){
64  ostringstream obuffer;
65  boost::archive::binary_oarchive OutputArchive(obuffer);
66  fPndSdsDigiTopix4Vector = frames.front();
67  OutputArchive << fPndSdsDigiTopix4Vector;
68  int outputSize = obuffer.str().length();
69  fPayload->Rebuild(outputSize);
70  memcpy(fPayload->GetData(), obuffer.str().c_str(), outputSize);
71  //unique_ptr<FairMQMessage> msg2(fTransportFactory->CreateMessage(const_cast<char*>(obuffer.str().c_str()), outputSize, CustomCleanup, &obuffer));
72  //fChannels.at("data-out").at(0).Send(msg);
73  LOG(INFO) << "Data: " << frames.front().size();
74  }
75 }
76 
78 {
79 }
Data class to store the digi output of a pixel module.
void setNumWords(const UInt_t &length)
Sets the length of the register to lengths words.
std::vector< std::vector< PndSdsDigiTopix4 > > AnalyzeData(std::vector< ULong64_t > &rawData, Double_t clockFrequency)
std::vector< ULong64_t > GetRawData(TMrfData_8b *data)
Definition: PndTopix4.cxx:25
Base interface class for data storage and manipulation. Compatible with IO classes from MRF Suite...
std::vector< UChar_t > regdata
Internal storage for data structure.
std::vector< PndSdsDigiTopix4 > fPndSdsDigiTopix4Vector
PndMvdReadInToPix4TBData fTopixDataReader
virtual void Exec(Option_t *opt="0")