CMS 3D CMS Logo

DistServer.cc
Go to the documentation of this file.
3 
4 #include <algorithm>
5 #include <iostream>
6 
7 using namespace std;
8 using namespace trackerTFP;
9 
10 DistServer::DistServer(unsigned int nInputs, unsigned int nOutputs, unsigned int nInterleaving)
11  : nInputs_(nInputs), nOutputs_(nOutputs), nInterleaving_(nInterleaving), inputs_(nInputs_) {
12  for (unsigned int iInput = 0; iInput < this->nInputs(); ++iInput) {
13  addr_.emplace_back(this->nInterleaving(), 0);
14  for (unsigned int iInterleave = 0; iInterleave < this->nInterleaving(); ++iInterleave) {
15  addr_[iInput][iInterleave] = iInterleave;
16  }
17  }
18 }
19 
21  for (unsigned int iInput = 0; iInput < nInputs(); ++iInput) {
22  if (data[iInput]->dataValid()) {
23  inputs()[iInput].push_back(data[iInput]);
24  }
25  }
26 
27  vector<vector<bool> > lMap(nInputs(), vector<bool>(nOutputs()));
28 
29  TrackKFOutSAPtrCollection lInputs(nInputs(), std::make_shared<TrackKFOut>());
30 
31  std::vector<std::vector<unsigned int> >& addr = this->addr();
32 
33  for (unsigned int iInput = 0; iInput < nInputs(); ++iInput) {
34  unsigned int lAddr = addr[iInput][0];
35  if (lAddr < inputs()[iInput].size()) {
36  lInputs[iInput] = inputs()[iInput][lAddr];
37  lMap[iInput][lInputs[iInput]->sortKey()] = true;
38  }
39  }
40 
41  for (unsigned int iInput = 0; iInput < nInputs(); ++iInput) {
42  vector<unsigned int>& toRotate = addr[iInput];
43  rotate(toRotate.begin(), toRotate.begin() + 1, toRotate.end());
44  }
45 
46  TrackKFOutSAPtrCollection lOutputs(nOutputs(), std::make_shared<TrackKFOut>());
47 
48  for (unsigned int iOutput = 0; iOutput < lOutputs.size(); ++iOutput) {
49  for (unsigned int iInput = 0; iInput < nInputs(); ++iInput) {
50  if (lMap[iInput][iOutput]) {
51  lOutputs[iOutput] = lInputs[iInput];
52  addr[iInput].back() += this->nInterleaving();
53  break;
54  }
55  }
56  }
57 
58  return lOutputs;
59 }
std::vector< std::vector< unsigned int > > & addr()
Definition: DistServer.h:20
unsigned int nInputs() const
Definition: DistServer.h:17
std::vector< TrackKFOutSAPtr > TrackKFOutSAPtrCollection
Definition: DataFormats.h:1029
TrackKFOutSAPtrCollection clock(TrackKFOutSAPtrCollection &inputs)
Definition: DistServer.cc:20
std::vector< std::vector< unsigned int > > addr_
Definition: DistServer.h:29
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
TrackKFOutSAPtrCollections & inputs()
Definition: DistServer.h:21
def rotate(angle, cx=0, cy=0)
Definition: svgfig.py:705
unsigned int nInterleaving() const
Definition: DistServer.h:19
unsigned int nOutputs() const
Definition: DistServer.h:18