CMS 3D CMS Logo

SiStripSpyDigiConverterModule.cc
Go to the documentation of this file.
1 #include <string>
2 #include <memory>
3 #include <vector>
4 #include <utility>
5 
14 
19 
22 
23 class SiStripFedCabling;
24 
34 namespace sistrip {
35 
37  public:
39  ~SpyDigiConverterModule() override;
40  void produce(edm::Event&, const edm::EventSetup&) override;
41 
42  private:
45  const bool storeAPVAddress_;
49  const uint32_t expectedHeaderBit_;
50 
51  //utilities for cabling etc...
53  };
54 
55 } // namespace sistrip
56 
57 namespace sistrip {
58 
60  : productLabel_(pset.getParameter<edm::InputTag>("InputProductLabel")),
61  storeAPVAddress_(pset.getParameter<bool>("StoreAPVAddress")),
62  storePayloadDigis_(pset.getParameter<bool>("StorePayloadDigis")),
63  storeReorderedDigis_(pset.getParameter<bool>("StoreReorderedDigis")),
64  storeModuleDigis_(pset.getParameter<bool>("StoreModuleDigis")),
65  discardDigisWithAPVAddressError_(pset.getParameter<bool>("DiscardDigisWithWrongAPVAddress")),
66  expectedHeaderBit_(pset.getParameter<uint32_t>("ExpectedPositionOfFirstHeaderBit")) {
67  productToken_ = consumes<sistrip::SpyDigiConverter::DSVRawDigis>(productLabel_);
68  if (edm::isDebugEnabled()) {
69  LogTrace("SiStripSpyDigiConverter") << "[sistrip::SpyDigiConverterModule::" << __func__ << "]"
70  << " Constructing object...";
71  }
72 
74  produces<edm::DetSetVector<SiStripRawDigi> >("SpyPayload");
76  produces<edm::DetSetVector<SiStripRawDigi> >("SpyReordered");
78  produces<edm::DetSetVector<SiStripRawDigi> >("SpyVirginRaw");
79 
80  if (storeAPVAddress_) {
81  produces<std::vector<uint32_t> >("APVAddress");
82  //produces<uint8_t>("APVAddress");
83  }
84 
85  frameQuality_.minDigiRange = static_cast<uint16_t>(pset.getParameter<uint32_t>("MinDigiRange"));
86  frameQuality_.maxDigiRange = static_cast<uint16_t>(pset.getParameter<uint32_t>("MaxDigiRange"));
87  frameQuality_.minZeroLight = static_cast<uint16_t>(pset.getParameter<uint32_t>("MinZeroLight"));
88  frameQuality_.maxZeroLight = static_cast<uint16_t>(pset.getParameter<uint32_t>("MaxZeroLight"));
89  frameQuality_.minTickHeight = static_cast<uint16_t>(pset.getParameter<uint32_t>("MinTickHeight"));
90  frameQuality_.maxTickHeight = static_cast<uint16_t>(pset.getParameter<uint32_t>("MaxTickHeight"));
91 
92  } // end of constructor.
93 
95  if (edm::isDebugEnabled()) {
96  LogTrace("SiStripSpyDigiConverter") << "[sistrip::SpyDigiConverterModule::" << __func__ << "]"
97  << " Destructing object...";
98  }
99  } // end of destructor.
100 
108  static bool lFirstEvent = true;
109 
110  const SiStripFedCabling* lCabling = utility_.getCabling(setup);
111 
113  return;
114 
115  //retrieve the scope mode digis
117  event.getByToken(productToken_, scopeDigisHandle);
118 
119  //32-bit to accomodate known CMSSW container
120  std::unique_ptr<std::vector<uint32_t> > pAPVAddresses(new std::vector<uint32_t>);
121 
122  std::unique_ptr<sistrip::SpyDigiConverter::DSVRawDigis> payloadDigis, reorderedDigis, moduleDigis;
123 
124  //get the majority value for expected position of first header bit
125  //from first event, compare to expected one, else output warning.
126  if (lFirstEvent) {
127  uint16_t lFirstHeaderBit;
128  sistrip::SpyUtilities::getMajorityHeader(scopeDigisHandle.product(), lFirstHeaderBit);
129 
130  if (lFirstHeaderBit != static_cast<uint16_t>(expectedHeaderBit_)) {
131  edm::LogWarning("") << " -- Majority position for firstHeaderBit in first event (" << lFirstHeaderBit
132  << ") is not where expected: " << static_cast<uint16_t>(expectedHeaderBit_) << std::endl;
133  }
134  }
135 
136  //extract frame digis and APV addresses
137  payloadDigis = sistrip::SpyDigiConverter::extractPayloadDigis(scopeDigisHandle.product(),
138  pAPVAddresses.get(),
141  static_cast<uint16_t>(expectedHeaderBit_));
142 
143  // Reorder
145  reorderedDigis = sistrip::SpyDigiConverter::reorderDigis(payloadDigis.get());
146  }
147 
148  // Merge into modules
149  if (storeModuleDigis_) {
150  moduleDigis = sistrip::SpyDigiConverter::mergeModuleChannels(reorderedDigis.get(), *lCabling);
151  }
152 
153  //add to event
154  if (storePayloadDigis_)
155  event.put(std::move(payloadDigis), "SpyPayload");
157  event.put(std::move(reorderedDigis), "SpyReordered");
158  if (storeModuleDigis_)
159  event.put(std::move(moduleDigis), "SpyVirginRaw");
160  if (storeAPVAddress_) {
161  event.put(std::move(pAPVAddresses), "APVAddress");
162  }
163 
164  lFirstEvent = false;
165 
166  } // end of SpyDigiConverter::produce method.
167 
168 } // namespace sistrip
169 
171 #include <cstdint>
T getParameter(std::string const &) const
bool isDebugEnabled()
void produce(edm::Event &, const edm::EventSetup &) override
sistrip::SpyDigiConverterModule SiStripSpyDigiConverterModule
static std::unique_ptr< DSVRawDigis > reorderDigis(const DSVRawDigis *inputPayloadDigis)
sistrip classes
static std::unique_ptr< DSVRawDigis > extractPayloadDigis(const DSVRawDigis *inputScopeDigis, std::vector< uint32_t > *pAPVAddresses, const bool discardDigisWithAPVAddrErr, const sistrip::SpyUtilities::FrameQuality &aQuality, const uint16_t expectedPos)
Extract frames from the scope digis.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< sistrip::SpyDigiConverter::DSVRawDigis > productToken_
static std::unique_ptr< DSVRawDigis > mergeModuleChannels(const DSVRawDigis *inputPhysicalOrderChannelDigis, const SiStripFedCabling &cabling)
const bool storeAPVAddress_
True = store APVE address for each channel.
#define LogTrace(id)
T const * product() const
Definition: Handle.h:69
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...
sistrip::SpyUtilities::FrameQuality frameQuality_
HLT enums.
static void getMajorityHeader(const edm::DetSetVector< SiStripRawDigi > *aInputDigis, uint16_t &firstHeaderBit, bool printResult=true)
SpyDigiConverterModule(const edm::ParameterSet &)
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1
A plug-in module that takes the spy channel scope mode digis as input from the Event and creates EDPr...