Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:26:12

0001 //
0002 // Original Author:  Marco ZANETTI
0003 //         Created:  Mon Jan 28 18:22:13 CET 2008
0004 
0005 #include "EventFilter/RawDataCollector/interface/RawDataFEDSelector.h"
0006 
0007 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
0008 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
0009 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
0010 
0011 #include <cstdio>
0012 #include <cstring>
0013 
0014 using namespace std;
0015 using namespace edm;
0016 
0017 std::unique_ptr<FEDRawDataCollection> RawDataFEDSelector::select(const Handle<FEDRawDataCollection>& rawData) {
0018   auto selectedRawData = std::make_unique<FEDRawDataCollection>();
0019 
0020   // if vector of FED indexes is defined, loop over it
0021   if (!fedList.empty()) {
0022     vector<int>::const_iterator it = fedList.begin();
0023     vector<int>::const_iterator itEnd = fedList.end();
0024     for (; it != itEnd; ++it) {
0025       const FEDRawData& fedData = rawData->FEDData(*it);
0026       size_t size = fedData.size();
0027 
0028       FEDRawData& fedDataProd = selectedRawData->FEDData(*it);
0029       fedDataProd.resize(size);
0030 
0031       memcpy(fedDataProd.data(), fedData.data(), size);
0032     }
0033   }
0034 
0035   // if vector of FED indexes is NOT defined, loop over it FED range
0036   else {
0037     // FED range is <0,0> (i.e. neither the list nor the rage are defined) copy the entire payload
0038     if (fedRange.second == 0)
0039       setRange(pair<int, int>(0, FEDNumbering::lastFEDId()));
0040 
0041     for (int i = fedRange.first; i <= fedRange.second; ++i) {
0042       const FEDRawData& fedData = rawData->FEDData(i);
0043       size_t size = fedData.size();
0044 
0045       FEDRawData& fedDataProd = selectedRawData->FEDData(i);
0046       fedDataProd.resize(size);
0047 
0048       memcpy(fedDataProd.data(), fedData.data(), size);
0049     }
0050   }
0051 
0052   return selectedRawData;
0053 }
0054 
0055 std::unique_ptr<FEDRawDataCollection> RawDataFEDSelector::select(const Handle<FEDRawDataCollection>& rawData,
0056                                                                  const pair<int, int>& range) {
0057   setRange(range);
0058   return select(rawData);
0059 }
0060 
0061 std::unique_ptr<FEDRawDataCollection> RawDataFEDSelector::select(const Handle<FEDRawDataCollection>& rawData,
0062                                                                  const vector<int>& list) {
0063   setRange(list);
0064   return select(rawData);
0065 }