CMS 3D CMS Logo

ExcludedFEDListProducer.cc
Go to the documentation of this file.
13 #include <iostream>
14 #include <sstream>
15 #include <iomanip>
16 #include <ext/algorithm>
17 
18 namespace sistrip {
19 
21  : runNumber_(0),
22  cacheId_(0),
23  cabling_(nullptr),
24  token_(consumes<FEDRawDataCollection>(pset.getParameter<edm::InputTag>("ProductLabel"))),
25  cablingToken_(esConsumes<SiStripFedCabling, SiStripFedCablingRcd, edm::Transition::BeginRun>()) {
26  produces<DetIdCollection>();
27  }
28 
30 
32  uint32_t cacheId = es.get<SiStripFedCablingRcd>().cacheIdentifier();
33 
34  if (cacheId_ != cacheId) {
35  cacheId_ = cacheId;
36 
38  cabling_ = c.product();
39  }
40  }
41 
44  desc.add<edm::InputTag>("ProductLabel", edm::InputTag("rawDataCollector"));
45  descriptions.add("siStripExcludedFEDListProducer", desc);
46  }
47 
49  if (runNumber_ != event.run()) {
50  runNumber_ = event.run();
51 
52  DetIdCollection emptyDetIdCollection;
53  detids_.swap(emptyDetIdCollection);
54  // Reserve space in bad module list
55  detids_.reserve(100);
56 
58  event.getByToken(token_, buffers);
59 
60  // Retrieve FED ids from cabling map and iterate through
61  for (auto ifed = cabling_->fedIds().begin(); ifed != cabling_->fedIds().end(); ifed++) {
62  // ignore trigger FED
63  // if ( *ifed == triggerFedId_ ) { continue; }
64 
65  // Retrieve FED raw data for given FED
66  const FEDRawData& input = buffers->FEDData(static_cast<int>(*ifed));
67  // The FEDData contains a vector<unsigned char>. Check the size of this vector:
68 
69  if (input.size() == 0) {
70  // std::cout << "Input size == 0 for FED number " << static_cast<int>(*ifed) << std::endl;
71  // get the cabling connections for this FED
72  auto conns = cabling_->fedConnections(*ifed);
73  // Mark FED modules as bad
74  detids_.reserve(detids_.size() + conns.size());
75  for (auto iconn = conns.begin(); iconn != conns.end(); ++iconn) {
76  if (!iconn->detId() || iconn->detId() == sistrip::invalid32_)
77  continue;
78  detids_.push_back(iconn->detId()); //@@ Possible multiple entries
79  }
80  }
81  }
82  }
83 
84  // for( unsigned int it = 0; it < detids->size(); ++it ) {
85  // std::cout << "detId = " << (*detids)[it]() << std::endl;
86  // }
87 
88  event.put(std::make_unique<DetIdCollection>(detids_));
89  }
90 } // namespace sistrip
static const char runNumber_[]
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
void produce(edm::Event &event, const edm::EventSetup &es) override
static const uint32_t invalid32_
Definition: Constants.h:15
void push_back(T const &t)
Definition: EDCollection.h:60
const edm::EDGetTokenT< FEDRawDataCollection > token_
sistrip classes
static std::string const input
Definition: EdmProvDump.cc:50
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ExcludedFEDListProducer(const edm::ParameterSet &pset)
constructor
T get() const
Definition: EventSetup.h:82
Transition
Definition: Transition.h:12
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
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)
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
HLT enums.
size_type size() const
Definition: EDCollection.h:82
FedsConstIterRange fedIds() const
edm::ESGetToken< SiStripFedCabling, SiStripFedCablingRcd > cablingToken_
~ExcludedFEDListProducer() override
default constructor
void swap(EDCollection< T > &other)
Definition: EDCollection.h:65
ConnsConstIterRange fedConnections(uint16_t fed_id) const
Definition: event.py:1
Definition: Run.h:45