CMS 3D CMS Logo

RawDataFEDSelector.cc
Go to the documentation of this file.
1 //
2 // Original Author: Marco ZANETTI
3 // Created: Mon Jan 28 18:22:13 CET 2008
4 
6 
10 
11 #include <cstdio>
12 #include <cstring>
13 
14 using namespace std;
15 using namespace edm;
16 
17 std::unique_ptr<FEDRawDataCollection> RawDataFEDSelector::select(const Handle<FEDRawDataCollection>& rawData) {
18  auto selectedRawData = std::make_unique<FEDRawDataCollection>();
19 
20  // if vector of FED indexes is defined, loop over it
21  if (!fedList.empty()) {
22  vector<int>::const_iterator it = fedList.begin();
23  vector<int>::const_iterator itEnd = fedList.end();
24  for (; it != itEnd; ++it) {
25  const FEDRawData& fedData = rawData->FEDData(*it);
26  size_t size = fedData.size();
27 
28  FEDRawData& fedDataProd = selectedRawData->FEDData(*it);
29  fedDataProd.resize(size);
30 
31  memcpy(fedDataProd.data(), fedData.data(), size);
32  }
33  }
34 
35  // if vector of FED indexes is NOT defined, loop over it FED range
36  else {
37  // FED range is <0,0> (i.e. neither the list nor the rage are defined) copy the entire payload
38  if (fedRange.second == 0)
39  setRange(pair<int, int>(0, FEDNumbering::lastFEDId()));
40 
41  for (int i = fedRange.first; i <= fedRange.second; ++i) {
42  const FEDRawData& fedData = rawData->FEDData(i);
43  size_t size = fedData.size();
44 
45  FEDRawData& fedDataProd = selectedRawData->FEDData(i);
46  fedDataProd.resize(size);
47 
48  memcpy(fedDataProd.data(), fedData.data(), size);
49  }
50  }
51 
52  return selectedRawData;
53 }
54 
55 std::unique_ptr<FEDRawDataCollection> RawDataFEDSelector::select(const Handle<FEDRawDataCollection>& rawData,
56  const pair<int, int>& range) {
57  setRange(range);
58  return select(rawData);
59 }
60 
61 std::unique_ptr<FEDRawDataCollection> RawDataFEDSelector::select(const Handle<FEDRawDataCollection>& rawData,
62  const vector<int>& list) {
63  setRange(list);
64  return select(rawData);
65 }
size
Write out results.
std::unique_ptr< FEDRawDataCollection > select(const edm::Handle< FEDRawDataCollection > &rawData)
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
void resize(size_t newsize)
Definition: FEDRawData.cc:28
std::vector< unsigned int > const fedList
Definition: Constants.h:63
HLT enums.
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
static constexpr int lastFEDId()
Definition: FEDNumbering.h:19