CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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
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  virtual ~SpyUnpackerModule();
62  virtual 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")),
96  unpacker_(NULL)
97  {
98  productToken_ = consumes<FEDRawDataCollection>(productLabel_);
99 
100  if ((fed_ids_.size()==0)) {
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.getByLabel( productLabel_, buffers );
146  event.getByToken( productToken_, buffers );
147 
148  //create container for digis
149  std::auto_ptr< edm::DetSetVector<SiStripRawDigi> > digis(new edm::DetSetVector<SiStripRawDigi>);
150 
151  //if necessary, create container for event counters
152  std::auto_ptr< std::vector<uint32_t> > pTotalCounts(new std::vector<uint32_t>);
153  std::auto_ptr< std::vector<uint32_t> > pL1ACounts(new std::vector<uint32_t>);
154  //and for run number
155  std::auto_ptr<uint32_t> pGlobalRun(new uint32_t);
156  //create digis
157  // Using FED IDs...
158  unpacker_->createDigis(*lCabling,
159  *buffers,
160  digis.get(),
161  fed_ids_,
162  pTotalCounts.get(),
163  pL1ACounts.get(),
164  pGlobalRun.get()
165  );
166 
167  // Add digis to event
168  if (storeScopeRawDigis_) event.put( digis, "ScopeRawDigis" );
169 
170  //add counters to event
171  if (storeCounters_) {
172  event.put(pTotalCounts, "TotalEventCount");
173  event.put(pL1ACounts, "L1ACount");
174  }
175 
176  //add global run to the event
177  event.put(pGlobalRun, "GlobalRunNumber");
178 
179  } // end of SpyUnpackerModule::produce method.
180 
181 
182 } // end of sistrip namespace
183 
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
#define NULL
Definition: scimark2.h:8
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.
const bool storeCounters_
True = store L1ID and TotalEventCount by FED key.
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
#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...
virtual void produce(edm::Event &, const edm::EventSetup &) override
Scope mode digis and event counter producer. Retrieves cabling map from EventSetup and FEDRawDataColl...
sistrip::SpyUnpackerModule SiStripSpyUnpackerModule
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")