CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SiStripSpyDigiConverterModule.cc
Go to the documentation of this file.
1 #include <string>
2 #include <memory>
3 #include <vector>
4 #include <utility>
5 
14 
20 
23 
33 namespace sistrip {
34 
36  public:
38  ~SpyDigiConverterModule() override;
39  void produce(edm::Event&, const edm::EventSetup&) override;
40 
41  private:
44  const bool storeAPVAddress_;
48  const uint32_t expectedHeaderBit_;
49 
50  //utilities for cabling etc...
54  void updateFedCabling(const SiStripFedCablingRcd& rcd);
55  };
56 
57 } // namespace sistrip
58 
59 namespace sistrip {
60 
62  : productLabel_(pset.getParameter<edm::InputTag>("InputProductLabel")),
63  storeAPVAddress_(pset.getParameter<bool>("StoreAPVAddress")),
64  storePayloadDigis_(pset.getParameter<bool>("StorePayloadDigis")),
65  storeReorderedDigis_(pset.getParameter<bool>("StoreReorderedDigis")),
66  storeModuleDigis_(pset.getParameter<bool>("StoreModuleDigis")),
67  discardDigisWithAPVAddressError_(pset.getParameter<bool>("DiscardDigisWithWrongAPVAddress")),
68  expectedHeaderBit_(pset.getParameter<uint32_t>("ExpectedPositionOfFirstHeaderBit")),
69  fedCablingToken_(esConsumes<>()),
70  cablingWatcher_(this, &sistrip::SpyDigiConverterModule::updateFedCabling) {
71  productToken_ = consumes<sistrip::SpyDigiConverter::DSVRawDigis>(productLabel_);
72  if (edm::isDebugEnabled()) {
73  LogTrace("SiStripSpyDigiConverter") << "[sistrip::SpyDigiConverterModule::" << __func__ << "]"
74  << " Constructing object...";
75  }
76 
78  produces<edm::DetSetVector<SiStripRawDigi> >("SpyPayload");
80  produces<edm::DetSetVector<SiStripRawDigi> >("SpyReordered");
82  produces<edm::DetSetVector<SiStripRawDigi> >("SpyVirginRaw");
83 
84  if (storeAPVAddress_) {
85  produces<std::vector<uint32_t> >("APVAddress");
86  //produces<uint8_t>("APVAddress");
87  }
88 
89  frameQuality_.minDigiRange = static_cast<uint16_t>(pset.getParameter<uint32_t>("MinDigiRange"));
90  frameQuality_.maxDigiRange = static_cast<uint16_t>(pset.getParameter<uint32_t>("MaxDigiRange"));
91  frameQuality_.minZeroLight = static_cast<uint16_t>(pset.getParameter<uint32_t>("MinZeroLight"));
92  frameQuality_.maxZeroLight = static_cast<uint16_t>(pset.getParameter<uint32_t>("MaxZeroLight"));
93  frameQuality_.minTickHeight = static_cast<uint16_t>(pset.getParameter<uint32_t>("MinTickHeight"));
94  frameQuality_.maxTickHeight = static_cast<uint16_t>(pset.getParameter<uint32_t>("MaxTickHeight"));
95 
96  } // end of constructor.
97 
99  if (edm::isDebugEnabled()) {
100  LogTrace("SiStripSpyDigiConverter") << "[sistrip::SpyDigiConverterModule::" << __func__ << "]"
101  << " Destructing object...";
102  }
103  } // end of destructor.
104 
107  }
108 
116  static bool lFirstEvent = true;
117 
118  cablingWatcher_.check(setup);
119 
121  return;
122 
123  //retrieve the scope mode digis
125  event.getByToken(productToken_, scopeDigisHandle);
126 
127  //32-bit to accomodate known CMSSW container
128  std::unique_ptr<std::vector<uint32_t> > pAPVAddresses(new std::vector<uint32_t>);
129 
130  std::unique_ptr<sistrip::SpyDigiConverter::DSVRawDigis> payloadDigis, reorderedDigis, moduleDigis;
131 
132  //get the majority value for expected position of first header bit
133  //from first event, compare to expected one, else output warning.
134  if (lFirstEvent) {
135  uint16_t lFirstHeaderBit;
136  sistrip::SpyUtilities::getMajorityHeader(scopeDigisHandle.product(), lFirstHeaderBit);
137 
138  if (lFirstHeaderBit != static_cast<uint16_t>(expectedHeaderBit_)) {
139  edm::LogWarning("") << " -- Majority position for firstHeaderBit in first event (" << lFirstHeaderBit
140  << ") is not where expected: " << static_cast<uint16_t>(expectedHeaderBit_) << std::endl;
141  }
142  }
143 
144  //extract frame digis and APV addresses
145  payloadDigis = sistrip::SpyDigiConverter::extractPayloadDigis(scopeDigisHandle.product(),
146  pAPVAddresses.get(),
149  static_cast<uint16_t>(expectedHeaderBit_));
150 
151  // Reorder
153  reorderedDigis = sistrip::SpyDigiConverter::reorderDigis(payloadDigis.get());
154  }
155 
156  // Merge into modules
157  if (storeModuleDigis_) {
158  moduleDigis = sistrip::SpyDigiConverter::mergeModuleChannels(reorderedDigis.get(), *fedCabling_);
159  }
160 
161  //add to event
162  if (storePayloadDigis_)
163  event.put(std::move(payloadDigis), "SpyPayload");
165  event.put(std::move(reorderedDigis), "SpyReordered");
166  if (storeModuleDigis_)
167  event.put(std::move(moduleDigis), "SpyVirginRaw");
168  if (storeAPVAddress_) {
169  event.put(std::move(pAPVAddresses), "APVAddress");
170  }
171 
172  lFirstEvent = false;
173 
174  } // end of SpyDigiConverter::produce method.
175 
176 } // namespace sistrip
177 
179 #include <cstdint>
bool isDebugEnabled()
void produce(edm::Event &, const edm::EventSetup &) override
sistrip::SpyDigiConverterModule SiStripSpyDigiConverterModule
static std::unique_ptr< DSVRawDigis > reorderDigis(const DSVRawDigis *inputPayloadDigis)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ESGetToken< SiStripFedCabling, SiStripFedCablingRcd > fedCablingToken_
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
#define LogTrace(id)
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.
edm::EDGetTokenT< sistrip::SpyDigiConverter::DSVRawDigis > productToken_
void getMajorityHeader(const edm::DetSetVector< SiStripRawDigi > *aInputDigis, uint16_t &firstHeaderBit, bool printResult=true)
def move
Definition: eostools.py:511
edm::ESWatcher< SiStripFedCablingRcd > cablingWatcher_
static std::unique_ptr< DSVRawDigis > mergeModuleChannels(const DSVRawDigis *inputPhysicalOrderChannelDigis, const SiStripFedCabling &cabling)
const bool storeAPVAddress_
True = store APVE address for each channel.
void updateFedCabling(const SiStripFedCablingRcd &rcd)
T const * product() const
Definition: Handle.h:70
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
sistrip::SpyUtilities::FrameQuality frameQuality_
Log< level::Warning, false > LogWarning
SpyDigiConverterModule(const edm::ParameterSet &)
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
A plug-in module that takes the spy channel scope mode digis as input from the Event and creates EDPr...