CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripSpyDigiConverterModule.cc
Go to the documentation of this file.
1 #include <string>
2 #include <memory>
3 #include <vector>
4 #include <utility>
5 #include "boost/cstdint.hpp"
6 
14 
19 
22 
23 class SiStripFedCabling;
24 
34 namespace sistrip {
35 
37  {
38  public:
41  virtual void beginRun( edm::Run&, const edm::EventSetup& );
42  virtual void produce( edm::Event&, const edm::EventSetup& );
43 
44  private:
46  const bool storeAPVAddress_;
50  const uint32_t expectedHeaderBit_;
51 
52  //utilities for cabling etc...
54  };
55 
56 } // end of sistrip namespace.
57 
58 
59 
60 namespace sistrip {
61 
63  productLabel_(pset.getParameter<edm::InputTag>("InputProductLabel")),
64  storeAPVAddress_(pset.getParameter<bool>("StoreAPVAddress")),
65  storePayloadDigis_(pset.getParameter<bool>("StorePayloadDigis")),
66  storeReorderedDigis_(pset.getParameter<bool>("StoreReorderedDigis")),
67  storeModuleDigis_(pset.getParameter<bool>("StoreModuleDigis")),
68  discardDigisWithAPVAddressError_(pset.getParameter<bool>("DiscardDigisWithWrongAPVAddress")),
69  expectedHeaderBit_(pset.getParameter<uint32_t>("ExpectedPositionOfFirstHeaderBit"))
70  {
71  if ( edm::isDebugEnabled() ) {
72  LogTrace("SiStripSpyDigiConverter")
73  << "[sistrip::SpyDigiConverterModule::" << __func__ << "]"
74  << " Constructing object...";
75  }
76 
77  if (storePayloadDigis_) produces< edm::DetSetVector<SiStripRawDigi> >("Payload");
78  if (storeReorderedDigis_) produces< edm::DetSetVector<SiStripRawDigi> >("Reordered");
79  if (storeModuleDigis_) produces< edm::DetSetVector<SiStripRawDigi> >("VirginRaw");
80 
81  if (storeAPVAddress_) {
82  produces< std::vector<uint32_t> >("APVAddress");
83  //produces<uint8_t>("APVAddress");
84  }
85 
86 
87  frameQuality_.minDigiRange = static_cast<uint16_t>(pset.getParameter<uint32_t>("MinDigiRange"));
88  frameQuality_.maxDigiRange = static_cast<uint16_t>(pset.getParameter<uint32_t>("MaxDigiRange"));
89  frameQuality_.minZeroLight = static_cast<uint16_t>(pset.getParameter<uint32_t>("MinZeroLight"));
90  frameQuality_.maxZeroLight = static_cast<uint16_t>(pset.getParameter<uint32_t>("MaxZeroLight"));
91  frameQuality_.minTickHeight = static_cast<uint16_t>(pset.getParameter<uint32_t>("MinTickHeight"));
92  frameQuality_.maxTickHeight = static_cast<uint16_t>(pset.getParameter<uint32_t>("MaxTickHeight"));
93 
94 
95  } // end of constructor.
96 
97 
99  if ( edm::isDebugEnabled() ) {
100  LogTrace("SiStripSpyDigiConverter")
101  << "[sistrip::SpyDigiConverterModule::" << __func__ << "]"
102  << " Destructing object...";
103  }
104  } // end of destructor.
105 
106 
108 
109  }
110 
118 
119  static bool lFirstEvent = true;
120 
121  const SiStripFedCabling* lCabling = utility_.getCabling( setup );
122 
124 
125  //retrieve the scope mode digis
127  event.getByLabel(productLabel_, scopeDigisHandle);
128 
129  //32-bit to accomodate known CMSSW container
130  std::auto_ptr< std::vector<uint32_t> > pAPVAddresses(new std::vector<uint32_t>);
131 
132  std::auto_ptr<sistrip::SpyDigiConverter::DSVRawDigis> payloadDigis, reorderedDigis, moduleDigis;
133 
134  //get the majority value for expected position of first header bit
135  //from first event, compare to expected one, else output warning.
136  if (lFirstEvent){
137  uint16_t lFirstHeaderBit;
138  sistrip::SpyUtilities::getMajorityHeader(scopeDigisHandle.product(),lFirstHeaderBit);
139 
140  if (lFirstHeaderBit != static_cast<uint16_t>(expectedHeaderBit_)) {
141  edm::LogWarning("") << " -- Majority position for firstHeaderBit in first event ("
142  << lFirstHeaderBit
143  << ") is not where expected: "
144  << static_cast<uint16_t>(expectedHeaderBit_)
145  << std::endl;
146  }
147 
148  }
149 
150 
151 
152  //extract frame digis and APV addresses
153  payloadDigis = sistrip::SpyDigiConverter::extractPayloadDigis(scopeDigisHandle.product(),
154  pAPVAddresses.get(),
156  frameQuality_,
157  static_cast<uint16_t>(expectedHeaderBit_));
158 
159  // Reorder
161  reorderedDigis = sistrip::SpyDigiConverter::reorderDigis(payloadDigis.get());
162  }
163 
164  // Merge into modules
165  if (storeModuleDigis_) {
166  moduleDigis = sistrip::SpyDigiConverter::mergeModuleChannels(reorderedDigis.get(), *lCabling);
167  }
168 
169  //add to event
170  if (storePayloadDigis_) event.put(payloadDigis,"Payload");
171  if (storeReorderedDigis_) event.put(reorderedDigis,"Reordered");
172  if (storeModuleDigis_) event.put(moduleDigis,"VirginRaw");
173  if (storeAPVAddress_) {
174  event.put(pAPVAddresses, "APVAddress");
175  }
176 
177 
178  lFirstEvent = false;
179 
180  } // end of SpyDigiConverter::produce method.
181 
182 } // end of sistrip namespace.
183 
184 
T getParameter(std::string const &) const
bool isDebugEnabled()
sistrip::SpyDigiConverterModule SiStripSpyDigiConverterModule
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
static std::auto_ptr< DSVRawDigis > mergeModuleChannels(const DSVRawDigis *inputPhysicalOrderChannelDigis, const SiStripFedCabling &cabling)
static std::auto_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.
virtual void produce(edm::Event &, const edm::EventSetup &)
static std::auto_ptr< DSVRawDigis > reorderDigis(const DSVRawDigis *inputPayloadDigis)
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
const bool storeAPVAddress_
True = store APVE address for each channel.
#define LogTrace(id)
const SiStripFedCabling * getCabling(const edm::EventSetup &)
Updates the cabling object from the DB.
T const * product() const
Definition: Handle.h:74
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
sistrip::SpyUtilities::FrameQuality frameQuality_
virtual void beginRun(edm::Run &, const edm::EventSetup &)
static void getMajorityHeader(const edm::DetSetVector< SiStripRawDigi > *aInputDigis, uint16_t &firstHeaderBit, bool printResult=true)
SpyDigiConverterModule(const edm::ParameterSet &)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
Definition: Run.h:33
A plug-in module that takes the spy channel scope mode digis as input from the Event and creates EDPr...