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

#include <PndMQTopix4DigiToHit.h>

Inheritance diagram for PndMQTopix4DigiToHit:

Public Member Functions

 PndMQTopix4DigiToHit ()
 
virtual ~PndMQTopix4DigiToHit ()
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 
std::vector< int > GetClusterSize ()
 

Protected Member Functions

virtual void Run ()
 

Private Attributes

std::vector< PndSdsDigiTopix4fTopixDigis
 
std::deque< std::vector
< PndSdsHit > > 
fTopixHitsEvent
 
std::vector< int > fClusterSize
 
bool fHasBoostSerialization
 
PndMQGapEventBuilderToPix fEventBuilder
 
PndMvdTopixClusterFinder fClusterFinder
 
PndMQTopixHitProducer fHitProducer
 
bool fStatusOutput
 

Friends

class boost::serialization::access
 

Detailed Description

PndMQTopix4Sink.h

Since
2014-10-10
Author
A. Rybalchenko

Definition at line 28 of file PndMQTopix4DigiToHit.h.

Constructor & Destructor Documentation

PndMQTopix4DigiToHit::PndMQTopix4DigiToHit ( )

Definition at line 33 of file PndMQTopix4DigiToHit.cxx.

References fHasBoostSerialization.

33  : fHasBoostSerialization(false),
34  fClusterFinder(20, 32, 1.8), fHitProducer(0.01, 0.01, 20, 32), fEventBuilder(50), fClusterSize(11), fStatusOutput(true)
35 {
36  using namespace baseMQ::tools::resolve;
37  bool checkOutputClass = false;
38 
39  if (is_same<boost::archive::binary_oarchive, boost::archive::binary_oarchive>::value)
40  {
41  if (has_BoostSerialization<PndSdsDigiTopix4, void(boost::archive::binary_oarchive&, const unsigned int)>::value == 1)
42  {
43  checkOutputClass = true;
45  }
46  }
47  LOG(INFO) << "HasBoostSerialization: " << fHasBoostSerialization;
48 }
PndMvdTopixClusterFinder fClusterFinder
Data class to store the digi output of a pixel module.
std::vector< int > fClusterSize
PndMQGapEventBuilderToPix fEventBuilder
PndMQTopixHitProducer fHitProducer
PndMQTopix4DigiToHit::~PndMQTopix4DigiToHit ( )
virtual

Definition at line 50 of file PndMQTopix4DigiToHit.cxx.

51 {
52 }

Member Function Documentation

std::vector<int> PndMQTopix4DigiToHit::GetClusterSize ( )
inline

Definition at line 42 of file PndMQTopix4DigiToHit.h.

References fClusterSize.

42 {return fClusterSize;}
std::vector< int > fClusterSize
void PndMQTopix4DigiToHit::Run ( )
protectedvirtual

Definition at line 55 of file PndMQTopix4DigiToHit.cxx.

References fClusterFinder, fClusterSize, fEventBuilder, fHasBoostSerialization, fHitProducer, PndMQGapEventBuilderToPix::FillData(), fStatusOutput, fTopixDigis, fTopixHitsEvent, PndMvdTopixClusterFinder::GetClusters(), PndMQTopixHitProducer::GetHit(), PndMQGapEventBuilderToPix::GetSeparatedData(), hits, status, PndMQStatus::STOP, and PndMQStatus::UNDEFINED.

56 {
58  FairMQChannel& dataInChannel = fChannels.at("data-in").at(0);
59  FairMQChannel& dataOutChannel = fChannels.at("data-out").at(0);
60  bool statusChannelPresent = false;
61 
62  if (fStatusOutput){
63  try {
64  (fChannels.at("status-out"));
65  }
66  catch (...){
67  fStatusOutput = false;
68  LOG(INFO) << "No Status-Out channel!";
69  }
70  }
71 
72  while (CheckCurrentState(RUNNING))
73  {
74  std::unique_ptr<FairMQMessage> header(fTransportFactory->CreateMessage());
75  std::unique_ptr<FairMQMessage> msg(fTransportFactory->CreateMessage());
77  if (dataInChannel.Receive(header) > 0)
78  {
79  status = *(static_cast<int*>(header->GetData()));
80 
81  if (dataInChannel.ExpectsAnotherPart())
82  {
83  if (dataInChannel.Receive(msg) > 0) {
84  string msgStr(static_cast<char*>(msg->GetData()), msg->GetSize());
85  istringstream ibuffer(msgStr);
86 
87  boost::archive::binary_iarchive InputArchive(ibuffer);
88 
89  try {
90  InputArchive >> fTopixDigis;
91  }
92  catch (boost::archive::archive_exception& e)
93  {
94  LOG(ERROR) << e.what();
95  }
96  }
97  }
98  }
99 // LOG(INFO) << "InputData: ";
100 // for (auto itr : fTopixDigis){
101 // LOG(INFO) << std::setw(12) << std::hex << itr.GetTimeStamp();
102 // }
103 
105  std::vector<std::vector<PndSdsDigiTopix4> > separatedData = fEventBuilder.GetSeparatedData();
106 
107  for (auto & eventIter : separatedData){
108  std::vector<PndSdsHit> hits;
109  if (eventIter.size() > 1){
110  std::vector<std::vector<int> > cluster = fClusterFinder.GetClusters(eventIter);
111 // LOG(INFO) << "Multiple Event Found with " << eventIter.size() << " digs and " << cluster.size() << " clusters";
112  for (auto clusterIter : cluster){
113  std::vector<PndSdsDigiTopix4> clusterDigis;
114  for (auto digiIter : clusterIter){
115  clusterDigis.push_back((eventIter)[digiIter]);
116 // LOG(INFO) << "Digis " << digiIter << " TimeStamp: " << (eventIter)[digiIter].GetTimeStamp();
117 // LOG(INFO) << "ClusterDigis: " << clusterDigis.rbegin()->GetTimeStamp();
118  }
119  //PndSdsHit myHit = fDummy.GetHit(clusterDigis);
120  //fHitProducer.GetHit(clusterDigis);
121  if (clusterDigis.size() < fClusterSize.size() - 1) //counts the sizes of clusters. All above fClusterSize.size() -1 are added to last bin
122  fClusterSize[clusterDigis.size()]++;
123  else
124  fClusterSize[fClusterSize.size() - 1]++;
125 
126  hits.push_back(fHitProducer.GetHit(clusterDigis));
127  }
128  } else {
129  //PndSdsHit myHit = fDummy.GetHit(eventIter);
130  //fHitProducer.GetHit(eventIter);
131  hits.push_back(fHitProducer.GetHit(eventIter));
132  }
133  fTopixHitsEvent.push_back(hits);
134  }
135 
136  if (status == PndMQStatus::STOP){
137  LOG(INFO) << "Received STOP-Signal!" << std::endl;
138  }
139 
140  unique_ptr<FairMQMessage> headerOut(fTransportFactory->CreateMessage(sizeof(int)));
141  memcpy(headerOut->GetData(), &status, sizeof(int));
142  dataOutChannel.SendPart(headerOut);
143 
144  std::ostringstream obuffer;
145  boost::archive::binary_oarchive OutputArchive(obuffer);
146  OutputArchive << fTopixHitsEvent;
147  int outputSize = obuffer.str().length();
148  unique_ptr<FairMQMessage> msg2(fTransportFactory->CreateMessage(outputSize));
149  memcpy(msg2->GetData(), obuffer.str().c_str(), outputSize);
150  dataOutChannel.Send(msg2);
151 
152  if (fStatusOutput == true){
153  unique_ptr<FairMQMessage> headerOut2(fTransportFactory->CreateMessage(sizeof(int)));
154  memcpy(headerOut->GetData(), &status, sizeof(int));
155  fChannels.at("status-out").at(0).SendPart(headerOut2);
156 
157  std::ostringstream obuffer2;
158  boost::archive::binary_oarchive OutputArchive2(obuffer2);
159  OutputArchive2 << fClusterSize;
160  int outputSize2 = obuffer2.str().length();
161  unique_ptr<FairMQMessage> msg3(fTransportFactory->CreateMessage(outputSize2));
162  memcpy(msg3->GetData(), obuffer2.str().c_str(), outputSize2);
163  fChannels.at("status-out").at(0).Send(msg3);
164  }
165 
166 // LOG(INFO) << "OutputEventBuilding: ";
167 // for (auto outerIter : fTopixHitsEvent){
168 // LOG(INFO) << "Event: ";
169 // for (auto innerIter : outerIter) {
170 // LOG(INFO)<< innerIter;
171 // }
172 // }
173  fTopixDigis.clear();
174  fTopixHitsEvent.clear();
175  }
176  }
177 }
PndSdsHit GetHit(std::vector< PndSdsDigiTopix4 > pixelArray)
PndMvdTopixClusterFinder fClusterFinder
std::vector< PndSdsDigiTopix4 > fTopixDigis
std::deque< std::vector< PndSdsHit > > fTopixHitsEvent
std::vector< int > fClusterSize
PndMQGapEventBuilderToPix fEventBuilder
std::vector< std::vector< Int_t > > GetClusters(std::vector< PndSdsDigiTopix4 > &hits)
std::vector< std::vector< PndSdsDigiTopix4 > > GetSeparatedData()
PndMQTopixHitProducer fHitProducer
void FillData(std::vector< PndSdsDigiTopix4 > data)
CbmHit * hits[nHits]
Definition: RiemannTest.C:19
int status[10]
Definition: f_Init.h:28
template<class Archive >
void PndMQTopix4DigiToHit::serialize ( Archive &  ar,
const unsigned int  version 
)
inline

Definition at line 35 of file PndMQTopix4DigiToHit.h.

References fClusterSize, fTopixDigis, and fTopixHitsEvent.

36  {
37  ar& fTopixDigis;
38  ar& fTopixHitsEvent;
39  ar& fClusterSize;
40  }
std::vector< PndSdsDigiTopix4 > fTopixDigis
std::deque< std::vector< PndSdsHit > > fTopixHitsEvent
std::vector< int > fClusterSize

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 48 of file PndMQTopix4DigiToHit.h.

Member Data Documentation

PndMvdTopixClusterFinder PndMQTopix4DigiToHit::fClusterFinder
private

Definition at line 56 of file PndMQTopix4DigiToHit.h.

Referenced by Run().

std::vector<int> PndMQTopix4DigiToHit::fClusterSize
private

Definition at line 52 of file PndMQTopix4DigiToHit.h.

Referenced by GetClusterSize(), Run(), and serialize().

PndMQGapEventBuilderToPix PndMQTopix4DigiToHit::fEventBuilder
private

Definition at line 55 of file PndMQTopix4DigiToHit.h.

Referenced by Run().

bool PndMQTopix4DigiToHit::fHasBoostSerialization
private

Definition at line 54 of file PndMQTopix4DigiToHit.h.

Referenced by PndMQTopix4DigiToHit(), and Run().

PndMQTopixHitProducer PndMQTopix4DigiToHit::fHitProducer
private

Definition at line 58 of file PndMQTopix4DigiToHit.h.

Referenced by Run().

bool PndMQTopix4DigiToHit::fStatusOutput
private

Definition at line 59 of file PndMQTopix4DigiToHit.h.

Referenced by Run().

std::vector<PndSdsDigiTopix4> PndMQTopix4DigiToHit::fTopixDigis
private

Definition at line 50 of file PndMQTopix4DigiToHit.h.

Referenced by Run(), and serialize().

std::deque<std::vector<PndSdsHit> > PndMQTopix4DigiToHit::fTopixHitsEvent
private

Definition at line 51 of file PndMQTopix4DigiToHit.h.

Referenced by Run(), and serialize().


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