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  // Unpacking
77 
78  //utilities for cabling etc...
80 
81  }; // end of SpyUnpackerModule class.
82 
83 } // end of namespace sistrip.
84 
85 namespace sistrip {
86 
87  const char* 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")),
96  {
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() ) LogTrace(msgLb_) << "["<< __func__ << "]:" << " Constructing object...";
108 
110 
111  if (storeScopeRawDigis_) produces< edm::DetSetVector<SiStripRawDigi> >("ScopeRawDigis");
112 
113  if (storeCounters_) {
114  produces< std::vector<uint32_t> >("L1ACount");
115  produces< std::vector<uint32_t> >("TotalEventCount");
116  }
117 
118  produces<uint32_t>("GlobalRunNumber");
119 
120  } // end of SpyUnpackerModule constructor.
121 
123  if ( unpacker_ ) { delete unpacker_; }
124  if ( edm::isDebugEnabled() ) {
125  LogTrace("SiStripSpyUnpacker")
126  << "[sistrip::SpyUnpackerModule::" << __func__ << "]"
127  << " Destructing object...";
128  }
129  }
130 
138 
139 
140  const SiStripFedCabling* lCabling = utility_.getCabling( setup );
141 
142  //retrieve FED raw data (by label, which is "source" by default)
144  event.getByToken( productToken_, buffers );
145 
146  //create container for digis
147  std::unique_ptr< edm::DetSetVector<SiStripRawDigi> > digis(new edm::DetSetVector<SiStripRawDigi>);
148 
149  //if necessary, create container for event counters
150  std::unique_ptr< std::vector<uint32_t> > pTotalCounts(new std::vector<uint32_t>);
151  std::unique_ptr< std::vector<uint32_t> > pL1ACounts(new std::vector<uint32_t>);
152  //and for run number
153  std::unique_ptr<uint32_t> pGlobalRun(new uint32_t);
154  //create digis
155  // Using FED IDs...
156  unpacker_->createDigis(*lCabling,
157  *buffers,
158  digis.get(),
159  fed_ids_,
160  pTotalCounts.get(),
161  pL1ACounts.get(),
162  pGlobalRun.get()
163  );
164 
165  // Add digis to event
166  if (storeScopeRawDigis_) event.put(std::move(digis), "ScopeRawDigis" );
167 
168  //add counters to event
169  if (storeCounters_) {
170  event.put(std::move(pTotalCounts), "TotalEventCount");
171  event.put(std::move(pL1ACounts), "L1ACount");
172  }
173 
174  //add global run to the event
175  event.put(std::move(pGlobalRun), "GlobalRunNumber");
176 
177  } // end of SpyUnpackerModule::produce method.
178 
179 
180 } // end of sistrip namespace
181 
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 nullptr
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
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 DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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:511
Definition: event.py:1