CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
150  cablingWatcher_.check(setup);
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 
std::vector< uint32_t > fed_ids_
Vector of FED IDs to examine (FEDs).
bool isDebugEnabled()
SpyUnpackerModule(const edm::ParameterSet &)
edm::EDGetTokenT< FEDRawDataCollection > productToken_
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.
const bool storeScopeRawDigis_
True = store the scope mode raw digis.
Unpacks spy channel data into scope mode-like digis.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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.
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
#define LogTrace(id)
edm::ESWatcher< SiStripFedCablingRcd > cablingWatcher_
edm::ESGetToken< SiStripFedCabling, SiStripFedCablingRcd > fedCablingToken_
const SiStripFedCabling * fedCabling_
def move
Definition: eostools.py:511
const bool storeCounters_
True = store L1ID and TotalEventCount by FED key.
const edm::InputTag productLabel_
The product label of the FEDRawDataCollection input.
Log< level::Info, false > LogInfo
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
void produce(edm::Event &, const edm::EventSetup &) override
Scope mode digis and event counter producer. Retrieves cabling map from EventSetup and FEDRawDataColl...
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
sistrip::SpyUnpackerModule SiStripSpyUnpackerModule
void updateFedCabling(const SiStripFedCablingRcd &rcd)
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283