CMS 3D CMS Logo

SiStripRawToDigiModule.cc
Go to the documentation of this file.
1 
4 
14 #include <cstdlib>
15 
16 namespace sistrip {
17 
19  : rawToDigi_(nullptr),
20  cabling_(nullptr),
21  extractCm_(false),
22  doFullCorruptBufferChecks_(false),
23  doAPVEmulatorCheck_(true),
24  tTopoToken_(esConsumes()),
25  fedCablingToken_(esConsumes()) {
26  if (edm::isDebugEnabled()) {
27  LogTrace("SiStripRawToDigi") << "[sistrip::RawToDigiModule::" << __func__ << "]"
28  << " Constructing object...";
29  }
30 
31  token_ = consumes<FEDRawDataCollection>(pset.getParameter<edm::InputTag>("ProductLabel"));
32  int16_t appended_bytes = pset.getParameter<int>("AppendedBytes");
33  int16_t trigger_fed_id = pset.getParameter<int>("TriggerFedId");
34  bool legacy_unpacker = pset.getParameter<bool>("LegacyUnpacker");
35  bool use_daq_register = pset.getParameter<bool>("UseDaqRegister");
36  bool using_fed_key = pset.getParameter<bool>("UseFedKey");
37  bool unpack_bad_channels = pset.getParameter<bool>("UnpackBadChannels");
38  bool mark_missing_feds = pset.getParameter<bool>("MarkModulesOnMissingFeds");
39 
40  int16_t fed_buffer_dump_freq = pset.getUntrackedParameter<int>("FedBufferDumpFreq", 0);
41  int16_t fed_event_dump_freq = pset.getUntrackedParameter<int>("FedEventDumpFreq", 0);
42  bool quiet = pset.getUntrackedParameter<bool>("Quiet", true);
43  extractCm_ = pset.getParameter<bool>("UnpackCommonModeValues");
44  doFullCorruptBufferChecks_ = pset.getParameter<bool>("DoAllCorruptBufferChecks");
45  doAPVEmulatorCheck_ = pset.getParameter<bool>("DoAPVEmulatorCheck");
46 
47  uint32_t errorThreshold = pset.getParameter<unsigned int>("ErrorThreshold");
48 
49  rawToDigi_ = new sistrip::RawToDigiUnpacker(appended_bytes,
50  fed_buffer_dump_freq,
51  fed_event_dump_freq,
52  trigger_fed_id,
53  using_fed_key,
54  unpack_bad_channels,
55  mark_missing_feds,
56  errorThreshold);
57  rawToDigi_->legacy(legacy_unpacker);
58  rawToDigi_->quiet(quiet);
59  rawToDigi_->useDaqRegister(use_daq_register);
63 
64  produces<SiStripEventSummary>();
65  produces<edm::DetSetVector<SiStripRawDigi> >("ScopeMode");
66  produces<edm::DetSetVector<SiStripRawDigi> >("VirginRaw");
67  produces<edm::DetSetVector<SiStripRawDigi> >("ProcessedRaw");
68  produces<edm::DetSetVector<SiStripDigi> >("ZeroSuppressed");
69  produces<DetIdCollection>();
70  if (extractCm_)
71  produces<edm::DetSetVector<SiStripRawDigi> >("CommonMode");
72  }
73 
75  if (rawToDigi_) {
76  delete rawToDigi_;
77  }
78  if (cabling_) {
79  cabling_ = nullptr;
80  }
81  if (edm::isDebugEnabled()) {
82  LogTrace("SiStripRawToDigi") << "[sistrip::RawToDigiModule::" << __func__ << "]"
83  << " Destructing object...";
84  }
85  }
86 
95 
96  // Retrieve FED raw data (by label, which is "source" by default)
98  event.getByToken(token_, buffers);
99 
100  // Populate SiStripEventSummary object with "trigger FED" info
101  auto summary = std::make_unique<SiStripEventSummary>();
102  rawToDigi_->triggerFed(*buffers, *summary, event.id().event());
103 
104  // Create containers for digis
109  DetIdCollection* ids = new DetIdCollection();
111 
112  // Create digis
113  if (rawToDigi_) {
114  rawToDigi_->createDigis(*cabling_, *buffers, *summary, *sm, *vr, *pr, *zs, *ids, *cm);
115  }
116 
117  // Create unique_ptr's of digi products
118  std::unique_ptr<edm::DetSetVector<SiStripRawDigi> > sm_dsv(sm);
119  std::unique_ptr<edm::DetSetVector<SiStripRawDigi> > vr_dsv(vr);
120  std::unique_ptr<edm::DetSetVector<SiStripRawDigi> > pr_dsv(pr);
121  std::unique_ptr<edm::DetSetVector<SiStripDigi> > zs_dsv(zs);
122  std::unique_ptr<DetIdCollection> det_ids(ids);
123  std::unique_ptr<edm::DetSetVector<SiStripRawDigi> > cm_dsv(cm);
124 
125  // Add to event
126  event.put(std::move(summary));
127  event.put(std::move(sm_dsv), "ScopeMode");
128  event.put(std::move(vr_dsv), "VirginRaw");
129  event.put(std::move(pr_dsv), "ProcessedRaw");
130  event.put(std::move(zs_dsv), "ZeroSuppressed");
131  event.put(std::move(det_ids));
132  if (extractCm_)
133  event.put(std::move(cm_dsv), "CommonMode");
134  }
135 
138  const bool isFirst = cabling_ != nullptr;
139  cabling_ = &setup.getData(fedCablingToken_);
140 
141  if (edm::isDebugEnabled()) {
142  if (isFirst) {
143  std::stringstream ss;
144  ss << "[sistrip::RawToDigiModule::" << __func__ << "]"
145  << " Updating cabling for first time..." << std::endl
146  << " Terse print out of FED cabling:" << std::endl;
147  cabling_->terse(ss);
148  LogTrace("SiStripRawToDigi") << ss.str();
149  }
150  }
151 
152  if (edm::isDebugEnabled()) {
153  std::stringstream sss;
154  sss << "[sistrip::RawToDigiModule::" << __func__ << "]"
155  << " Summary of FED cabling:" << std::endl;
156  cabling_->summary(sss, &setup.getData(tTopoToken_));
157  LogTrace("SiStripRawToDigi") << sss.str();
158  }
159  }
160  }
161 
163 } // namespace sistrip
void summary(std::stringstream &ss, const TrackerTopology *trackerTopo) const
LEFT FOR COMPATIBILITY. SHOULD BE REPLACED BY PRINTSUMMARY.
void triggerFed(const FEDRawDataCollection &, SiStripEventSummary &, const uint32_t &event)
trigger info
bool isDebugEnabled()
void useDaqRegister(bool)
EventSummary update request -> not yet implemented for FEDBuffer class.
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
RawToDigiModule(const edm::ParameterSet &)
edm::EDGetTokenT< FEDRawDataCollection > token_
void produce(edm::Event &, const edm::EventSetup &) override
sistrip classes
#define LogTrace(id)
edm::ESGetToken< SiStripFedCabling, SiStripFedCablingRcd > fedCablingToken_
void updateCabling(const edm::EventSetup &)
edm::ESWatcher< SiStripFedCablingRcd > fedCablingWatcher_
isFirst
Definition: cuy.py:418
void terse(std::stringstream &) const
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
void createDigis(const SiStripFedCabling &, const FEDRawDataCollection &, SiStripEventSummary &, RawDigis &scope_mode, RawDigis &virgin_raw, RawDigis &proc_raw, Digis &zero_suppr, DetIdCollection &, RawDigis &common_mode)
creates digis
edm::EDCollection< DetId > DetIdCollection
RawToDigiUnpacker * rawToDigi_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
const SiStripFedCabling * cabling_
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1