CMS 3D CMS Logo

HcalCalibFEDSelector.cc
Go to the documentation of this file.
1 // user include files
4 
7 
10 
16 
18 public:
20 
21 private:
22  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
23 
24  // ----------member data ---------------------------
26  std::vector<int> extraFEDs_;
27 };
28 
30  tok_fed_ = consumes<FEDRawDataCollection>(iConfig.getParameter<edm::InputTag>("rawInputLabel"));
31  extraFEDs_ = iConfig.getParameter<std::vector<int> >("extraFEDsToKeep");
32  produces<FEDRawDataCollection>();
33 }
34 
36  auto producedData = std::make_unique<FEDRawDataCollection>();
37 
39  iEvent.getByToken(tok_fed_, rawIn);
40 
41  std::vector<int> selFEDs;
42 
43  //--- Get the list of FEDs to be kept ---//
44  int calibType = -1;
46  const FEDRawData& fedData = rawIn->FEDData(i);
47  if (fedData.size() < 24)
48  continue; // FED is empty
49  int value = ((const HcalDCCHeader*)(fedData.data()))->getCalibType();
50  if (calibType < 0) {
51  calibType = value;
52  } else {
53  if (calibType != value)
54  edm::LogWarning("HcalCalibFEDSelector") << "Conflicting calibration types found: " << calibType << " vs. "
55  << value << ". Staying with " << calibType;
56  }
57  }
58 
59  HcalFEDList calibFeds(calibType);
60  selFEDs = calibFeds.getListOfFEDs();
61  for (unsigned int i = 0; i < extraFEDs_.size(); i++) {
62  bool duplicate = false;
63  for (unsigned int j = 0; j < selFEDs.size(); j++) {
64  if (extraFEDs_.at(i) == selFEDs.at(j)) {
65  duplicate = true;
66  break;
67  }
68  }
69  if (!duplicate)
70  selFEDs.push_back(extraFEDs_.at(i));
71  }
72 
73  // Copying:
74  const FEDRawDataCollection* rdc = rawIn.product();
75 
76  for (int j = 0; j <= FEDNumbering::lastFEDId(); ++j) {
77  bool rightFED = false;
78  for (uint32_t k = 0; k < selFEDs.size(); k++) {
79  if (j == selFEDs[k]) {
80  rightFED = true;
81  }
82  }
83  if (!rightFED)
84  continue;
85  const FEDRawData& fedData = rdc->FEDData(j);
86  size_t size = fedData.size();
87 
88  if (size > 0) {
89  // this fed has data -- lets copy it
90  FEDRawData& fedDataProd = producedData->FEDData(j);
91  if (fedDataProd.size() != 0) {
92  continue;
93  }
94  fedDataProd.resize(size);
95  unsigned char* dataProd = fedDataProd.data();
96  const unsigned char* data = fedData.data();
97  // memcpy is at-least-as-fast as assignment and can be much faster
98  memcpy(dataProd, data, size);
99  }
100  }
101 
102  iEvent.put(std::move(producedData));
103 }
104 
size
Write out results.
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
HcalCalibFEDSelector(const edm::ParameterSet &)
std::vector< int > extraFEDs_
int iEvent
Definition: GenABIO.cc:224
void resize(size_t newsize)
Definition: FEDRawData.cc:28
edm::EDGetTokenT< FEDRawDataCollection > tok_fed_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Definition: value.py:1
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
Log< level::Warning, false > LogWarning
static constexpr int lastFEDId()
Definition: FEDNumbering.h:19
std::vector< int > getListOfFEDs()
Definition: HcalFEDList.h:19
def move(src, dest)
Definition: eostools.py:511