CMS 3D CMS Logo

SiStripSpyUnpackerModule.cc
Go to the documentation of this file.
1 /*\ \file SiStripSpyUnpackerModule.cc
2  * \brief Source code for the spy unpacking plugin module.
3  */
4 
5 // CMSSW includes
17 
18 // Needed for the FED cabling
23 
24 // Needed for the FED raw data collection
26 
27 // For the digi stuff.
30 
31 // For the unpacking object.
34 
35 // Standard includes
36 #include <memory>
37 #include <utility>
38 #include <string>
39 #include <cstdint>
40 
41 namespace sistrip {
42  class SpyUnpacker;
43 } // namespace sistrip
44 
45 using edm::LogError;
46 using edm::LogInfo;
47 
48 namespace sistrip {
49 
59  public:
61  ~SpyUnpackerModule() override;
62  void produce(edm::Event&, const edm::EventSetup&) override;
63 
64  private:
65  static const char* msgLb_;
66 
67  // Data members
68  //--------------
69  // Configuration
70  std::vector<uint32_t> fed_ids_;
74  const bool storeCounters_;
75  const bool storeScopeRawDigis_;
76  // Unpacking
78 
79  //utilities for cabling etc...
83  void updateFedCabling(const SiStripFedCablingRcd& rcd);
84  }; // end of SpyUnpackerModule class.
85 
86 } // end of namespace sistrip.
87 
88 namespace sistrip {
89 
90  const char* SpyUnpackerModule::msgLb_ = "SiStripSpyUnpackerModule";
91 
93  : fed_ids_(pset.getParameter<std::vector<uint32_t> >("FEDIDs")),
94  productLabel_(pset.getParameter<edm::InputTag>("InputProductLabel")),
95  allowIncompleteEvents_(pset.getParameter<bool>("AllowIncompleteEvents")),
96  storeCounters_(pset.getParameter<bool>("StoreCounters")),
97  storeScopeRawDigis_(pset.getParameter<bool>("StoreScopeRawDigis")),
98  unpacker_(nullptr),
99  fedCablingToken_(esConsumes<>()),
100  cablingWatcher_(this, &sistrip::SpyUnpackerModule::updateFedCabling) {
101  productToken_ = consumes<FEDRawDataCollection>(productLabel_);
102 
103  if ((fed_ids_.empty())) {
104  LogInfo(msgLb_) << "No FED IDs specified, so will try to unpack all FEDs with data" << std::endl;
106  for (uint32_t ifed = FEDNumbering::MINSiStripFEDID; ifed <= FEDNumbering::MAXSiStripFEDID; ifed++) {
107  fed_ids_.push_back(ifed);
108  }
109  } // end of FED ID specified check.
110 
111  if (edm::isDebugEnabled())
112  LogTrace(msgLb_) << "[" << __func__ << "]:"
113  << " Constructing object...";
114 
116 
118  produces<edm::DetSetVector<SiStripRawDigi> >("ScopeRawDigis");
119 
120  if (storeCounters_) {
121  produces<std::vector<uint32_t> >("L1ACount");
122  produces<std::vector<uint32_t> >("TotalEventCount");
123  }
124 
125  produces<uint32_t>("GlobalRunNumber");
126 
127  } // end of SpyUnpackerModule constructor.
128 
130  if (unpacker_) {
131  delete unpacker_;
132  }
133  if (edm::isDebugEnabled()) {
134  LogTrace("SiStripSpyUnpacker") << "[sistrip::SpyUnpackerModule::" << __func__ << "]"
135  << " Destructing object...";
136  }
137  }
138 
141  }
142 
151  //retrieve FED raw data (by label, which is "source" by default)
153  event.getByToken(productToken_, buffers);
154 
155  //create container for digis
156  std::unique_ptr<edm::DetSetVector<SiStripRawDigi> > digis(new edm::DetSetVector<SiStripRawDigi>);
157 
158  //if necessary, create container for event counters
159  std::unique_ptr<std::vector<uint32_t> > pTotalCounts(new std::vector<uint32_t>);
160  std::unique_ptr<std::vector<uint32_t> > pL1ACounts(new std::vector<uint32_t>);
161  //and for run number
162  std::unique_ptr<uint32_t> pGlobalRun(new uint32_t);
163  //create digis
164  // Using FED IDs...
166  *fedCabling_, *buffers, digis.get(), fed_ids_, pTotalCounts.get(), pL1ACounts.get(), pGlobalRun.get());
167 
168  // Add digis to event
170  event.put(std::move(digis), "ScopeRawDigis");
171 
172  //add counters to event
173  if (storeCounters_) {
174  event.put(std::move(pTotalCounts), "TotalEventCount");
175  event.put(std::move(pL1ACounts), "L1ACount");
176  }
177 
178  //add global run to the event
179  event.put(std::move(pGlobalRun), "GlobalRunNumber");
180 
181  } // end of SpyUnpackerModule::produce method.
182 
183 } // namespace sistrip
184 
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
SiStripSpyUnpackerModule
sistrip::SpyUnpackerModule SiStripSpyUnpackerModule
Definition: SiStripSpyUnpackerModule.cc:185
FEDNumbering.h
edm::DetSetVector< SiStripRawDigi >
Handle.h
electrons_cff.bool
bool
Definition: electrons_cff.py:366
sistrip::SpyUnpackerModule::productLabel_
const edm::InputTag productLabel_
The product label of the FEDRawDataCollection input.
Definition: SiStripSpyUnpackerModule.cc:71
MessageLogger.h
sistrip::SpyUnpackerModule::storeCounters_
const bool storeCounters_
True = store L1ID and TotalEventCount by FED key.
Definition: SiStripSpyUnpackerModule.cc:74
EDProducer.h
edm::ESWatcher< SiStripFedCablingRcd >
sistrip::SpyUnpackerModule::msgLb_
static const char * msgLb_
Definition: SiStripSpyUnpackerModule.cc:65
edm::EDGetTokenT< FEDRawDataCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
sistrip::SpyUnpackerModule::unpacker_
SpyUnpacker * unpacker_
Definition: SiStripSpyUnpackerModule.cc:77
SiStripRawDigi.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89281
SiStripFedCabling.h
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
SiStripFedCabling
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses,...
Definition: SiStripFedCabling.h:25
edm::Handle< FEDRawDataCollection >
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
SiStripSpyUtilities.h
sistrip::SpyUnpackerModule::produce
void produce(edm::Event &, const edm::EventSetup &) override
Scope mode digis and event counter producer. Retrieves cabling map from EventSetup and FEDRawDataColl...
Definition: SiStripSpyUnpackerModule.cc:149
MakerMacros.h
SiStripFedCablingRcd
Definition: SiStripCondDataRecords.h:22
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
sistrip::SpyUnpacker
Unpacks spy channel data into scope mode-like digis.
Definition: SiStripSpyUnpacker.h:31
EDGetToken.h
sistrip::SpyUnpackerModule::updateFedCabling
void updateFedCabling(const SiStripFedCablingRcd &rcd)
Definition: SiStripSpyUnpackerModule.cc:139
FEDNumbering::MAXSiStripFEDID
Definition: FEDNumbering.h:30
edm::ParameterSet
Definition: ParameterSet.h:47
sistrip::SpyUnpackerModule::fed_ids_
std::vector< uint32_t > fed_ids_
Vector of FED IDs to examine (FEDs).
Definition: SiStripSpyUnpackerModule.cc:70
Event.h
sistrip::SpyUnpackerModule::SpyUnpackerModule
SpyUnpackerModule(const edm::ParameterSet &)
Definition: SiStripSpyUnpackerModule.cc:92
SiStripSpyUnpacker.h
FEDRawDataCollection.h
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
sistrip::SpyUnpackerModule::productToken_
edm::EDGetTokenT< FEDRawDataCollection > productToken_
Definition: SiStripSpyUnpackerModule.cc:72
edm::EventSetup
Definition: EventSetup.h:58
DetSetVector.h
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
SiStripSpyUnpackerModule
A plug-in module that takes a FEDRawDataCollection as input from the Event and creates EDProducts con...
edm::ESGetToken< SiStripFedCabling, SiStripFedCablingRcd >
sistrip::SpyUnpackerModule::storeScopeRawDigis_
const bool storeScopeRawDigis_
True = store the scope mode raw digis.
Definition: SiStripSpyUnpackerModule.cc:75
InputTag.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
FedChannelConnection.h
Frameworkfwd.h
ESWatcher.h
sistrip::SpyUnpackerModule::cablingWatcher_
edm::ESWatcher< SiStripFedCablingRcd > cablingWatcher_
Definition: SiStripSpyUnpackerModule.cc:82
sistrip::SpyUnpackerModule
Definition: SiStripSpyUnpackerModule.cc:58
sistrip::SpyUnpackerModule::~SpyUnpackerModule
~SpyUnpackerModule() override
Definition: SiStripSpyUnpackerModule.cc:129
EventSetup.h
edm::EDProducer
Definition: EDProducer.h:35
sistrip::SpyUnpackerModule::allowIncompleteEvents_
const bool allowIncompleteEvents_
Allow inconsistent (by event count, APV address) event storage.
Definition: SiStripSpyUnpackerModule.cc:73
SiStripFedCablingRcd.h
edm::isDebugEnabled
bool isDebugEnabled()
Definition: MessageLogger.cc:12
edm::eventsetup::EventSetupRecordImplementation::get
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
Definition: EventSetupRecordImplementation.h:74
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
ParameterSet.h
sistrip
sistrip classes
Definition: SiStripQualityHelpers.h:14
sistrip::SpyUnpackerModule::fedCablingToken_
edm::ESGetToken< SiStripFedCabling, SiStripFedCablingRcd > fedCablingToken_
Definition: SiStripSpyUnpackerModule.cc:80
event
Definition: event.py:1
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
sistrip::SpyUnpacker::createDigis
void createDigis(const SiStripFedCabling &, const FEDRawDataCollection &, RawDigis *pDigis, const std::vector< uint32_t > &ids, Counters *pTotalEventCounts, Counters *pL1ACounts, uint32_t *aRunRef)
Creates the scope mode digis for the supplied FED IDs or detIds and stores event counters.
Definition: SiStripSpyUnpacker.cc:43
sistrip::SpyUnpackerModule::fedCabling_
const SiStripFedCabling * fedCabling_
Definition: SiStripSpyUnpackerModule.cc:81
edm::InputTag
Definition: InputTag.h:15
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
FEDNumbering::MINSiStripFEDID
Definition: FEDNumbering.h:29