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>
Handle.h
electrons_cff.bool
bool
Definition: electrons_cff.py:393
SiStripSpyDigiConverter.h
MessageLogger.h
SiStripSpyDigiConverterModule
sistrip::SpyDigiConverterModule SiStripSpyDigiConverterModule
Definition: SiStripSpyDigiConverterModule.cc:172
edm::Handle::product
T const * product() const
Definition: Handle.h:70
EDProducer.h
ESHandle.h
sistrip::SpyDigiConverterModule::storeAPVAddress_
const bool storeAPVAddress_
True = store APVE address for each channel.
Definition: SiStripSpyDigiConverterModule.cc:45
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
SiStripRawDigi.h
sistrip::SpyUtilities::FrameQuality
Definition: SiStripSpyUtilities.h:37
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
SiStripFedCabling.h
sistrip::SpyDigiConverterModule::frameQuality_
sistrip::SpyUtilities::FrameQuality frameQuality_
Definition: SiStripSpyDigiConverterModule.cc:47
SiStripFedCabling
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses,...
Definition: SiStripFedCabling.h:25
edm::Handle
Definition: AssociativeIterator.h:50
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
SiStripSpyUtilities.h
sistrip::SpyDigiConverterModule::utility_
SpyUtilities utility_
Definition: SiStripSpyDigiConverterModule.cc:52
sistrip::SpyDigiConverter::extractPayloadDigis
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.
Definition: SiStripSpyDigiConverter.cc:25
sistrip::SpyDigiConverterModule::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: SiStripSpyDigiConverterModule.cc:107
sistrip::SpyDigiConverterModule::productToken_
edm::EDGetTokenT< sistrip::SpyDigiConverter::DSVRawDigis > productToken_
Definition: SiStripSpyDigiConverterModule.cc:44
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
sistrip::SpyDigiConverter::reorderDigis
static std::unique_ptr< DSVRawDigis > reorderDigis(const DSVRawDigis *inputPayloadDigis)
Definition: SiStripSpyDigiConverter.cc:177
sistrip::SpyUtilities
Definition: SiStripSpyUtilities.h:24
sistrip::SpyDigiConverterModule::~SpyDigiConverterModule
~SpyDigiConverterModule() override
Definition: SiStripSpyDigiConverterModule.cc:94
sistrip::SpyDigiConverterModule::storePayloadDigis_
const bool storePayloadDigis_
Definition: SiStripSpyDigiConverterModule.cc:46
SiStripSpyDigiConverterModule
A plug-in module that takes the spy channel scope mode digis as input from the Event and creates EDPr...
EDGetToken.h
sistrip::SpyDigiConverterModule::productLabel_
const edm::InputTag productLabel_
Definition: SiStripSpyDigiConverterModule.cc:43
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
sistrip::SpyDigiConverterModule::SpyDigiConverterModule
SpyDigiConverterModule(const edm::ParameterSet &)
Definition: SiStripSpyDigiConverterModule.cc:59
sistrip::SpyDigiConverter::mergeModuleChannels
static std::unique_ptr< DSVRawDigis > mergeModuleChannels(const DSVRawDigis *inputPhysicalOrderChannelDigis, const SiStripFedCabling &cabling)
Definition: SiStripSpyDigiConverter.cc:203
sistrip::SpyDigiConverterModule::storeReorderedDigis_
const bool storeReorderedDigis_
Definition: SiStripSpyDigiConverterModule.cc:46
edm::EventSetup
Definition: EventSetup.h:57
sistrip::SpyDigiConverterModule::storeModuleDigis_
const bool storeModuleDigis_
Definition: SiStripSpyDigiConverterModule.cc:46
DetSetVector.h
sistrip::SpyUtilities::FrameQuality::maxTickHeight
uint16_t maxTickHeight
Definition: SiStripSpyUtilities.h:43
sistrip::SpyUtilities::FrameQuality::minZeroLight
uint16_t minZeroLight
Definition: SiStripSpyUtilities.h:40
InputTag.h
sistrip::SpyUtilities::getCabling
const SiStripFedCabling * getCabling(const edm::EventSetup &)
Updates the cabling object from the DB.
Definition: SiStripSpyUtilities.cc:37
eostools.move
def move(src, dest)
Definition: eostools.py:511
sistrip::SpyUtilities::FrameQuality::minDigiRange
uint16_t minDigiRange
Definition: SiStripSpyUtilities.h:38
sistrip::SpyDigiConverterModule::expectedHeaderBit_
const uint32_t expectedHeaderBit_
Definition: SiStripSpyDigiConverterModule.cc:49
sistrip::SpyUtilities::getMajorityHeader
static void getMajorityHeader(const edm::DetSetVector< SiStripRawDigi > *aInputDigis, uint16_t &firstHeaderBit, bool printResult=true)
Definition: SiStripSpyUtilities.cc:195
EventSetup.h
edm::EDProducer
Definition: EDProducer.h:35
edm::isDebugEnabled
bool isDebugEnabled()
Definition: MessageLogger.cc:12
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
ParameterSet.h
sistrip
sistrip classes
Definition: SiStripQualityHelpers.h:14
sistrip::SpyDigiConverterModule
Definition: SiStripSpyDigiConverterModule.cc:36
sistrip::SpyUtilities::FrameQuality::maxZeroLight
uint16_t maxZeroLight
Definition: SiStripSpyUtilities.h:41
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
sistrip::SpyUtilities::FrameQuality::maxDigiRange
uint16_t maxDigiRange
Definition: SiStripSpyUtilities.h:39
sistrip::SpyDigiConverterModule::discardDigisWithAPVAddressError_
const bool discardDigisWithAPVAddressError_
Definition: SiStripSpyDigiConverterModule.cc:48
edm::InputTag
Definition: InputTag.h:15
sistrip::SpyUtilities::FrameQuality::minTickHeight
uint16_t minTickHeight
Definition: SiStripSpyUtilities.h:42
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27