CMS 3D CMS Logo

ExcludedFEDListProducer.cc
Go to the documentation of this file.
17 #include <iostream>
18 #include <sstream>
19 #include <iomanip>
20 #include <ext/algorithm>
21 
22 namespace sistrip {
23 
25  : runNumber_(0),
26  cacheId_(0),
27  cabling_(nullptr),
28  token_(consumes<FEDRawDataCollection>(pset.getParameter<edm::InputTag>("ProductLabel"))) {
29  produces<DetIdCollection>();
30  }
31 
33 
35  uint32_t cacheId = es.get<SiStripFedCablingRcd>().cacheIdentifier();
36 
37  if (cacheId_ != cacheId) {
38  cacheId_ = cacheId;
39 
41  es.get<SiStripFedCablingRcd>().get(c);
42  cabling_ = c.product();
43  }
44  }
45 
48  desc.add<edm::InputTag>("ProductLabel", edm::InputTag("rawDataCollector"));
49  descriptions.add("siStripExcludedFEDListProducer", desc);
50  }
51 
53  if (runNumber_ != event.run()) {
54  runNumber_ = event.run();
55 
56  DetIdCollection emptyDetIdCollection;
57  detids_.swap(emptyDetIdCollection);
58  // Reserve space in bad module list
59  detids_.reserve(100);
60 
62  event.getByToken(token_, buffers);
63 
64  // Retrieve FED ids from cabling map and iterate through
65  for (auto ifed = cabling_->fedIds().begin(); ifed != cabling_->fedIds().end(); ifed++) {
66  // ignore trigger FED
67  // if ( *ifed == triggerFedId_ ) { continue; }
68 
69  // Retrieve FED raw data for given FED
70  const FEDRawData& input = buffers->FEDData(static_cast<int>(*ifed));
71  // The FEDData contains a vector<unsigned char>. Check the size of this vector:
72 
73  if (input.size() == 0) {
74  // std::cout << "Input size == 0 for FED number " << static_cast<int>(*ifed) << std::endl;
75  // get the cabling connections for this FED
76  auto conns = cabling_->fedConnections(*ifed);
77  // Mark FED modules as bad
78  detids_.reserve(detids_.size() + conns.size());
79  for (auto iconn = conns.begin(); iconn != conns.end(); ++iconn) {
80  if (!iconn->detId() || iconn->detId() == sistrip::invalid32_)
81  continue;
82  detids_.push_back(iconn->detId()); //@@ Possible multiple entries
83  }
84  }
85  }
86  }
87 
88  // for( unsigned int it = 0; it < detids->size(); ++it ) {
89  // std::cout << "detId = " << (*detids)[it]() << std::endl;
90  // }
91 
92  event.put(std::make_unique<DetIdCollection>(detids_));
93  }
94 } // namespace sistrip
static const char runNumber_[]
size_type size() const
Definition: EDCollection.h:82
void produce(edm::Event &event, const edm::EventSetup &es) override
static const uint32_t invalid32_
Definition: Constants.h:15
#define nullptr
void push_back(T const &t)
Definition: EDCollection.h:60
const edm::EDGetTokenT< FEDRawDataCollection > token_
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
sistrip classes
static std::string const input
Definition: EdmProvDump.cc:48
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ExcludedFEDListProducer(const edm::ParameterSet &pset)
constructor
FedsConstIterRange fedIds() const
RunNumber_t run() const
Definition: Event.h:107
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void reserve(size_type n)
Definition: EDCollection.h:92
void beginRun(const edm::Run &run, const edm::EventSetup &es) override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
ConnsConstIterRange fedConnections(uint16_t fed_id) const
HLT enums.
T get() const
Definition: EventSetup.h:73
T const * product() const
Definition: ESHandle.h:86
~ExcludedFEDListProducer() override
default constructor
void swap(EDCollection< T > &other)
Definition: EDCollection.h:65
Definition: event.py:1
Definition: Run.h:45