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::StreamID, edm::Event&, const edm::EventSetup&) const override;
63 
64  private:
65  static const char* const 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...
81  }; // end of SpyUnpackerModule class.
82 
83 } // end of namespace sistrip.
84 
85 namespace sistrip {
86 
87  const char* const SpyUnpackerModule::msgLb_ = "SiStripSpyUnpackerModule";
88 
90  : fed_ids_(pset.getParameter<std::vector<uint32_t> >("FEDIDs")),
91  productLabel_(pset.getParameter<edm::InputTag>("InputProductLabel")),
92  allowIncompleteEvents_(pset.getParameter<bool>("AllowIncompleteEvents")),
93  storeCounters_(pset.getParameter<bool>("StoreCounters")),
94  storeScopeRawDigis_(pset.getParameter<bool>("StoreScopeRawDigis")),
95  unpacker_(allowIncompleteEvents_),
96  fedCablingToken_(esConsumes<>()) {
97  productToken_ = consumes<FEDRawDataCollection>(productLabel_);
98 
99  if ((fed_ids_.empty())) {
100  LogInfo(msgLb_) << "No FED IDs specified, so will try to unpack all FEDs with data" << std::endl;
102  for (uint32_t ifed = FEDNumbering::MINSiStripFEDID; ifed <= FEDNumbering::MAXSiStripFEDID; ifed++) {
103  fed_ids_.push_back(ifed);
104  }
105  } // end of FED ID specified check.
106 
107  if (edm::isDebugEnabled())
108  LogTrace(msgLb_) << "[" << __func__ << "]:"
109  << " Constructing object...";
110 
112  produces<edm::DetSetVector<SiStripRawDigi> >("ScopeRawDigis");
113 
114  if (storeCounters_) {
115  produces<std::vector<uint32_t> >("L1ACount");
116  produces<std::vector<uint32_t> >("TotalEventCount");
117  }
118 
119  produces<uint32_t>("GlobalRunNumber");
120 
121  } // end of SpyUnpackerModule constructor.
122 
124  if (edm::isDebugEnabled()) {
125  LogTrace("SiStripSpyUnpacker") << "[sistrip::SpyUnpackerModule::" << __func__ << "]"
126  << " Destructing object...";
127  }
128  }
129 
137  const SiStripFedCabling* fedCabling = &setup.getData(fedCablingToken_);
138  //retrieve FED raw data (by label, which is "source" by default)
140  event.getByToken(productToken_, buffers);
141 
142  //create container for digis
143  std::unique_ptr<edm::DetSetVector<SiStripRawDigi> > digis(new edm::DetSetVector<SiStripRawDigi>);
144 
145  //if necessary, create container for event counters
146  std::unique_ptr<std::vector<uint32_t> > pTotalCounts(new std::vector<uint32_t>);
147  std::unique_ptr<std::vector<uint32_t> > pL1ACounts(new std::vector<uint32_t>);
148  //and for run number
149  std::unique_ptr<uint32_t> pGlobalRun(new uint32_t);
150  //create digis
151  // Using FED IDs...
153  *fedCabling, *buffers, digis.get(), fed_ids_, pTotalCounts.get(), pL1ACounts.get(), pGlobalRun.get());
154 
155  // Add digis to event
157  event.put(std::move(digis), "ScopeRawDigis");
158 
159  //add counters to event
160  if (storeCounters_) {
161  event.put(std::move(pTotalCounts), "TotalEventCount");
162  event.put(std::move(pL1ACounts), "L1ACount");
163  }
164 
165  //add global run to the event
166  event.put(std::move(pGlobalRun), "GlobalRunNumber");
167 
168  } // end of SpyUnpackerModule::produce method.
169 
170 } // namespace sistrip
171 
std::vector< uint32_t > fed_ids_
Vector of FED IDs to examine (FEDs).
bool isDebugEnabled()
SpyUnpackerModule(const edm::ParameterSet &)
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Scope mode digis and event counter producer. Retrieves cabling map from EventSetup and FEDRawDataColl...
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::EDGetTokenT< FEDRawDataCollection > productToken_
const bool storeScopeRawDigis_
True = store the scope mode raw digis.
Unpacks spy channel data into scope mode-like digis.
const edm::ESGetToken< SiStripFedCabling, SiStripFedCablingRcd > fedCablingToken_
Log< level::Error, false > LogError
A plug-in module that takes a FEDRawDataCollection as input from the Event and creates EDProducts con...
const bool allowIncompleteEvents_
Allow inconsistent (by event count, APV address) event storage.
sistrip classes
#define LogTrace(id)
void createDigis(const SiStripFedCabling &, const FEDRawDataCollection &, RawDigis *pDigis, const std::vector< uint32_t > &ids, Counters *pTotalEventCounts, Counters *pL1ACounts, uint32_t *aRunRef) const
Creates the scope mode digis for the supplied FED IDs or detIds and stores event counters.
const bool storeCounters_
True = store L1ID and TotalEventCount by FED key.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const edm::InputTag productLabel_
The product label of the FEDRawDataCollection input.
Log< level::Info, false > LogInfo
static const char *const msgLb_
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
HLT enums.
sistrip::SpyUnpackerModule SiStripSpyUnpackerModule
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1