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
16 
17 // Needed for the FED cabling
21 
22 // Needed for the FED raw data collection
24 
25 // For the digi stuff.
28 
29 // For the unpacking object.
32 
33 // Standard includes
34 #include <memory>
35 #include <utility>
36 #include <string>
37 #include "boost/cstdint.hpp"
38 
39 namespace sistrip { class SpyUnpacker; class SpyUtilities; }
40 class SiStripFedCabling;
41 
42 using edm::LogError;
43 using edm::LogInfo;
44 
45 
46 namespace sistrip {
47 
57  {
58  public:
60  virtual ~SpyUnpackerModule();
61  virtual void produce( edm::Event&, const edm::EventSetup& ) override;
62  private:
63  static const char* msgLb_;
64 
65  // Data members
66  //--------------
67  // Configuration
68  std::vector<uint32_t> fed_ids_;
71  const bool storeCounters_;
72  const bool storeScopeRawDigis_;
73 
74  // Unpacking
76 
77  //utilities for cabling etc...
79 
80  }; // end of SpyUnpackerModule class.
81 
82 } // end of namespace sistrip.
83 
84 namespace sistrip {
85 
86  const char* SpyUnpackerModule::msgLb_ = "SiStripSpyUnpackerModule";
87 
89  fed_ids_( pset.getParameter< std::vector<uint32_t> >("FEDIDs")),
90  productLabel_(pset.getParameter<edm::InputTag>("InputProductLabel")),
91  allowIncompleteEvents_(pset.getParameter<bool>("AllowIncompleteEvents")),
92  storeCounters_(pset.getParameter<bool>("StoreCounters")),
93  storeScopeRawDigis_(pset.getParameter<bool>("StoreScopeRawDigis")),
94  unpacker_(NULL)
95  {
96 
97  if ((fed_ids_.size()==0)) {
98  LogInfo(msgLb_) << "No FED IDs specified, so will try to unpack all FEDs with data" << std::endl;
100  for ( uint32_t ifed = FEDNumbering::MINSiStripFEDID; ifed <= FEDNumbering::MAXSiStripFEDID; ifed++ ) {
101  fed_ids_.push_back( ifed );
102  }
103  } // end of FED ID specified check.
104 
105  if ( edm::isDebugEnabled() ) LogTrace(msgLb_) << "["<< __func__ << "]:" << " Constructing object...";
106 
108 
109  if (storeScopeRawDigis_) produces< edm::DetSetVector<SiStripRawDigi> >("ScopeRawDigis");
110 
111  if (storeCounters_) {
112  produces< std::vector<uint32_t> >("L1ACount");
113  produces< std::vector<uint32_t> >("TotalEventCount");
114  }
115 
116  produces<uint32_t>("GlobalRunNumber");
117 
118  } // end of SpyUnpackerModule constructor.
119 
121  if ( unpacker_ ) { delete unpacker_; }
122  if ( edm::isDebugEnabled() ) {
123  LogTrace("SiStripSpyUnpacker")
124  << "[sistrip::SpyUnpackerModule::" << __func__ << "]"
125  << " Destructing object...";
126  }
127  }
128 
136 
137 
138  const SiStripFedCabling* lCabling = utility_.getCabling( setup );
139 
140  //retrieve FED raw data (by label, which is "source" by default)
142  event.getByLabel( productLabel_, buffers );
143 
144  //create container for digis
145  std::auto_ptr< edm::DetSetVector<SiStripRawDigi> > digis(new edm::DetSetVector<SiStripRawDigi>);
146 
147  //if necessary, create container for event counters
148  std::auto_ptr< std::vector<uint32_t> > pTotalCounts(new std::vector<uint32_t>);
149  std::auto_ptr< std::vector<uint32_t> > pL1ACounts(new std::vector<uint32_t>);
150  //and for run number
151  std::auto_ptr<uint32_t> pGlobalRun(new uint32_t);
152  //create digis
153  // Using FED IDs...
154  unpacker_->createDigis(*lCabling,
155  *buffers,
156  digis.get(),
157  fed_ids_,
158  pTotalCounts.get(),
159  pL1ACounts.get(),
160  pGlobalRun.get()
161  );
162 
163  // Add digis to event
164  if (storeScopeRawDigis_) event.put( digis, "ScopeRawDigis" );
165 
166  //add counters to event
167  if (storeCounters_) {
168  event.put(pTotalCounts, "TotalEventCount");
169  event.put(pL1ACounts, "L1ACount");
170  }
171 
172  //add global run to the event
173  event.put(pGlobalRun, "GlobalRunNumber");
174 
175  } // end of SpyUnpackerModule::produce method.
176 
177 
178 } // end of sistrip namespace
179 
std::vector< uint32_t > fed_ids_
Vector of FED IDs to examine (FEDs).
bool isDebugEnabled()
SpyUnpackerModule(const edm::ParameterSet &)
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="")