CMS 3D CMS Logo

SiStripRawToDigiModule.cc
Go to the documentation of this file.
1 
4 
16 #include <cstdlib>
17 
18 namespace sistrip {
19 
21  : rawToDigi_(nullptr),
22  cabling_(nullptr),
23  cacheId_(0),
24  extractCm_(false),
25  doFullCorruptBufferChecks_(false),
26  doAPVEmulatorCheck_(true) {
27  if (edm::isDebugEnabled()) {
28  LogTrace("SiStripRawToDigi") << "[sistrip::RawToDigiModule::" << __func__ << "]"
29  << " Constructing object...";
30  }
31 
32  token_ = consumes<FEDRawDataCollection>(pset.getParameter<edm::InputTag>("ProductLabel"));
33  int16_t appended_bytes = pset.getParameter<int>("AppendedBytes");
34  int16_t trigger_fed_id = pset.getParameter<int>("TriggerFedId");
35  bool legacy_unpacker = pset.getParameter<bool>("LegacyUnpacker");
36  bool use_daq_register = pset.getParameter<bool>("UseDaqRegister");
37  bool using_fed_key = pset.getParameter<bool>("UseFedKey");
38  bool unpack_bad_channels = pset.getParameter<bool>("UnpackBadChannels");
39  bool mark_missing_feds = pset.getParameter<bool>("MarkModulesOnMissingFeds");
40 
41  int16_t fed_buffer_dump_freq = pset.getUntrackedParameter<int>("FedBufferDumpFreq", 0);
42  int16_t fed_event_dump_freq = pset.getUntrackedParameter<int>("FedEventDumpFreq", 0);
43  bool quiet = pset.getUntrackedParameter<bool>("Quiet", true);
44  extractCm_ = pset.getParameter<bool>("UnpackCommonModeValues");
45  doFullCorruptBufferChecks_ = pset.getParameter<bool>("DoAllCorruptBufferChecks");
46  doAPVEmulatorCheck_ = pset.getParameter<bool>("DoAPVEmulatorCheck");
47 
48  uint32_t errorThreshold = pset.getParameter<unsigned int>("ErrorThreshold");
49 
50  rawToDigi_ = new sistrip::RawToDigiUnpacker(appended_bytes,
51  fed_buffer_dump_freq,
52  fed_event_dump_freq,
53  trigger_fed_id,
54  using_fed_key,
55  unpack_bad_channels,
56  mark_missing_feds,
57  errorThreshold);
58  rawToDigi_->legacy(legacy_unpacker);
59  rawToDigi_->quiet(quiet);
60  rawToDigi_->useDaqRegister(use_daq_register);
61  rawToDigi_->extractCm(extractCm_);
62  rawToDigi_->doFullCorruptBufferChecks(doFullCorruptBufferChecks_);
63  rawToDigi_->doAPVEmulatorCheck(doAPVEmulatorCheck_);
64 
65  produces<SiStripEventSummary>();
66  produces<edm::DetSetVector<SiStripRawDigi> >("ScopeMode");
67  produces<edm::DetSetVector<SiStripRawDigi> >("VirginRaw");
68  produces<edm::DetSetVector<SiStripRawDigi> >("ProcessedRaw");
69  produces<edm::DetSetVector<SiStripDigi> >("ZeroSuppressed");
70  produces<DetIdCollection>();
71  if (extractCm_)
72  produces<edm::DetSetVector<SiStripRawDigi> >("CommonMode");
73  }
74 
76  if (rawToDigi_) {
77  delete rawToDigi_;
78  }
79  if (cabling_) {
80  cabling_ = nullptr;
81  }
82  if (edm::isDebugEnabled()) {
83  LogTrace("SiStripRawToDigi") << "[sistrip::RawToDigiModule::" << __func__ << "]"
84  << " Destructing object...";
85  }
86  }
87 
89 
97  updateCabling(setup);
98 
99  // Retrieve FED raw data (by label, which is "source" by default)
101  event.getByToken(token_, buffers);
102 
103  // Populate SiStripEventSummary object with "trigger FED" info
104  auto summary = std::make_unique<SiStripEventSummary>();
105  rawToDigi_->triggerFed(*buffers, *summary, event.id().event());
106 
107  // Create containers for digis
114 
115  // Create digis
116  if (rawToDigi_) {
117  rawToDigi_->createDigis(*cabling_, *buffers, *summary, *sm, *vr, *pr, *zs, *ids, *cm);
118  }
119 
120  // Create unique_ptr's of digi products
121  std::unique_ptr<edm::DetSetVector<SiStripRawDigi> > sm_dsv(sm);
122  std::unique_ptr<edm::DetSetVector<SiStripRawDigi> > vr_dsv(vr);
123  std::unique_ptr<edm::DetSetVector<SiStripRawDigi> > pr_dsv(pr);
124  std::unique_ptr<edm::DetSetVector<SiStripDigi> > zs_dsv(zs);
125  std::unique_ptr<DetIdCollection> det_ids(ids);
126  std::unique_ptr<edm::DetSetVector<SiStripRawDigi> > cm_dsv(cm);
127 
128  // Add to event
129  event.put(std::move(summary));
130  event.put(std::move(sm_dsv), "ScopeMode");
131  event.put(std::move(vr_dsv), "VirginRaw");
132  event.put(std::move(pr_dsv), "ProcessedRaw");
133  event.put(std::move(zs_dsv), "ZeroSuppressed");
134  event.put(std::move(det_ids));
135  if (extractCm_)
136  event.put(std::move(cm_dsv), "CommonMode");
137  }
138 
140  uint32_t cache_id = setup.get<SiStripFedCablingRcd>().cacheIdentifier();
141 
142  if (cacheId_ != cache_id) {
144  setup.get<SiStripFedCablingRcd>().get(c);
145  cabling_ = c.product();
146 
147  if (edm::isDebugEnabled()) {
148  if (!cacheId_) {
149  std::stringstream ss;
150  ss << "[sistrip::RawToDigiModule::" << __func__ << "]"
151  << " Updating cabling for first time..." << std::endl
152  << " Terse print out of FED cabling:" << std::endl;
153  cabling_->terse(ss);
154  LogTrace("SiStripRawToDigi") << ss.str();
155  }
156  }
157 
158  if (edm::isDebugEnabled()) {
159  std::stringstream sss;
160  sss << "[sistrip::RawToDigiModule::" << __func__ << "]"
161  << " Summary of FED cabling:" << std::endl;
163  setup.get<TrackerTopologyRcd>().get(tTopo);
164  cabling_->summary(sss, tTopo.product());
165  LogTrace("SiStripRawToDigi") << sss.str();
166  }
167  cacheId_ = cache_id;
168  }
169  }
170 
172 } // namespace sistrip
void triggerFed(const FEDRawDataCollection &, SiStripEventSummary &, const uint32_t &event)
trigger info
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:40
bool isDebugEnabled()
T getUntrackedParameter(std::string const &, T const &) const
RawToDigiModule(const edm::ParameterSet &)
void terse(std::stringstream &) const
edm::EDGetTokenT< FEDRawDataCollection > token_
#define nullptr
void produce(edm::Event &, const edm::EventSetup &) override
sistrip classes
void updateCabling(const edm::EventSetup &)
#define LogTrace(id)
void beginRun(const edm::Run &, const edm::EventSetup &) override
edm::EventID id() const
Definition: EventBase.h:59
void summary(std::stringstream &ss, const TrackerTopology *trackerTopo) const
LEFT FOR COMPATIBILITY. SHOULD BE REPLACED BY PRINTSUMMARY.
T get() const
Definition: EventSetup.h:73
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_
const SiStripFedCabling * cabling_
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1
Definition: Run.h:45