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
22 
23 // Needed for the FED raw data collection
25 
26 // For the digi stuff.
29 
30 // For the unpacking object.
33 
34 // Standard includes
35 #include <memory>
36 #include <utility>
37 #include <string>
38 #include "boost/cstdint.hpp"
39 
40 namespace sistrip { class SpyUnpacker; class SpyUtilities; }
41 class SiStripFedCabling;
42 
43 using edm::LogError;
44 using edm::LogInfo;
45 
46 
47 namespace sistrip {
48 
58  {
59  public:
61  ~SpyUnpackerModule() override;
62  void produce( edm::Event&, const edm::EventSetup& ) override;
63  private:
64  static const char* msgLb_;
65 
66  // Data members
67  //--------------
68  // Configuration
69  std::vector<uint32_t> fed_ids_;
73  const bool storeCounters_;
74  const bool storeScopeRawDigis_;
75 
76  // Unpacking
78 
79  //utilities for cabling etc...
81 
82  }; // end of SpyUnpackerModule class.
83 
84 } // end of namespace sistrip.
85 
86 namespace sistrip {
87 
88  const char* SpyUnpackerModule::msgLb_ = "SiStripSpyUnpackerModule";
89 
91  fed_ids_( pset.getParameter< std::vector<uint32_t> >("FEDIDs")),
92  productLabel_(pset.getParameter<edm::InputTag>("InputProductLabel")),
93  allowIncompleteEvents_(pset.getParameter<bool>("AllowIncompleteEvents")),
94  storeCounters_(pset.getParameter<bool>("StoreCounters")),
95  storeScopeRawDigis_(pset.getParameter<bool>("StoreScopeRawDigis")),
97  {
98  productToken_ = consumes<FEDRawDataCollection>(productLabel_);
99 
100  if ((fed_ids_.empty())) {
101  LogInfo(msgLb_) << "No FED IDs specified, so will try to unpack all FEDs with data" << std::endl;
103  for ( uint32_t ifed = FEDNumbering::MINSiStripFEDID; ifed <= FEDNumbering::MAXSiStripFEDID; ifed++ ) {
104  fed_ids_.push_back( ifed );
105  }
106  } // end of FED ID specified check.
107 
108  if ( edm::isDebugEnabled() ) LogTrace(msgLb_) << "["<< __func__ << "]:" << " Constructing object...";
109 
111 
112  if (storeScopeRawDigis_) 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 ( unpacker_ ) { delete unpacker_; }
125  if ( edm::isDebugEnabled() ) {
126  LogTrace("SiStripSpyUnpacker")
127  << "[sistrip::SpyUnpackerModule::" << __func__ << "]"
128  << " Destructing object...";
129  }
130  }
131 
139 
140 
141  const SiStripFedCabling* lCabling = utility_.getCabling( setup );
142 
143  //retrieve FED raw data (by label, which is "source" by default)
145  event.getByToken( productToken_, buffers );
146 
147  //create container for digis
148  std::unique_ptr< edm::DetSetVector<SiStripRawDigi> > digis(new edm::DetSetVector<SiStripRawDigi>);
149 
150  //if necessary, create container for event counters
151  std::unique_ptr< std::vector<uint32_t> > pTotalCounts(new std::vector<uint32_t>);
152  std::unique_ptr< std::vector<uint32_t> > pL1ACounts(new std::vector<uint32_t>);
153  //and for run number
154  std::unique_ptr<uint32_t> pGlobalRun(new uint32_t);
155  //create digis
156  // Using FED IDs...
157  unpacker_->createDigis(*lCabling,
158  *buffers,
159  digis.get(),
160  fed_ids_,
161  pTotalCounts.get(),
162  pL1ACounts.get(),
163  pGlobalRun.get()
164  );
165 
166  // Add digis to event
167  if (storeScopeRawDigis_) event.put(std::move(digis), "ScopeRawDigis" );
168 
169  //add counters to event
170  if (storeCounters_) {
171  event.put(std::move(pTotalCounts), "TotalEventCount");
172  event.put(std::move(pL1ACounts), "L1ACount");
173  }
174 
175  //add global run to the event
176  event.put(std::move(pGlobalRun), "GlobalRunNumber");
177 
178  } // end of SpyUnpackerModule::produce method.
179 
180 
181 } // end of sistrip namespace
182 
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:17
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
A plug-in module that takes a FEDRawDataCollection as input from the Event and creates EDProducts con...
#define nullptr
const bool allowIncompleteEvents_
Allow inconsistent (by event count, APV address) event storage.
sistrip classes
const bool storeCounters_
True = store L1ID and TotalEventCount by FED key.
#define LogTrace(id)
const edm::InputTag productLabel_
The product label of the FEDRawDataCollection input.
const SiStripFedCabling * getCabling(const edm::EventSetup &)
Updates the cabling object from the DB.
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...
HLT enums.
sistrip::SpyUnpackerModule SiStripSpyUnpackerModule
def move(src, dest)
Definition: eostools.py:510
Definition: event.py:1