CMS 3D CMS Logo

SiStripRawToDigiUnpacker.h
Go to the documentation of this file.
1 
2 #ifndef EventFilter_SiStripRawToDigi_SiStripRawToDigiUnpacker_H
3 #define EventFilter_SiStripRawToDigi_SiStripRawToDigiUnpacker_H
4 
10 #include "WarningSummary.h"
11 
13 namespace sistrip {
14  class RawToClustersLazyUnpacker;
15 }
16 namespace sistrip {
17  class RawToDigiUnpacker;
18 }
19 
22 class FEDRawData;
23 class SiStripDigi;
24 class SiStripRawDigi;
26 class SiStripFedCabling;
27 
28 namespace sistrip {
29 
31  friend class RawToClustersLazyUnpacker;
32 
33  public:
36 
38  RawToDigiUnpacker(int16_t appended_bytes,
39  int16_t fed_buffer_dump_freq,
40  int16_t fed_event_dump_freq,
41  int16_t trigger_fed_id,
42  bool using_fed_key,
43  bool unpack_bad_channels,
44  bool mark_missing_feds,
45  const uint32_t errorThreshold);
46 
49 
51  void createDigis(const SiStripFedCabling&,
52  const FEDRawDataCollection&,
54  RawDigis& scope_mode,
55  RawDigis& virgin_raw,
56  RawDigis& proc_raw,
57  Digis& zero_suppr,
59  RawDigis& common_mode);
60 
62  void triggerFed(const FEDRawDataCollection&, SiStripEventSummary&, const uint32_t& event);
63 
65  void locateStartOfFedBuffer(const uint16_t& fed_id, const FEDRawData& input, FEDRawData& output);
66 
68  inline void quiet(bool);
69 
71  inline void useDaqRegister(bool);
72 
73  inline void extractCm(bool);
74 
75  inline void doFullCorruptBufferChecks(bool);
76 
77  inline void doAPVEmulatorCheck(bool);
78 
79  inline void legacy(bool);
80 
81  void printWarningSummary() const { warnings_.printSummary(); }
82 
83  private:
85  void update(
86  RawDigis& scope_mode, RawDigis& virgin_raw, RawDigis& proc_raw, Digis& zero_suppr, RawDigis& common_mode);
87 
89  RawToDigiUnpacker() = delete;
90 
92  void updateEventSummary(const sistrip::FEDBuffer&, SiStripEventSummary&);
93 
95  inline void readoutOrder(uint16_t& physical_order, uint16_t& readout_order);
96 
98  inline void physicalOrder(uint16_t& readout_order, uint16_t& physical_order);
99 
101  inline sistrip::FedBufferFormat fedBufferFormat(const uint16_t& register_value);
102 
104  inline sistrip::FedReadoutMode fedReadoutMode(const uint16_t& register_value);
105 
107  static void dumpRawData(uint16_t fed_id, const FEDRawData&, std::stringstream&);
108 
110  void handleException(std::string method_name, std::string extra_info = "");
111 
113  void cleanupWorkVectors();
114 
116  class Registry {
117  public:
119  Registry(uint32_t aDetid, uint16_t firstStrip, size_t indexInVector, uint16_t numberOfDigis)
120  : detid(aDetid), first(firstStrip), index(indexInVector), length(numberOfDigis) {}
122  bool operator<(const Registry& other) const {
123  return (detid != other.detid ? detid < other.detid : first < other.first);
124  }
126  uint32_t detid;
127  uint16_t first;
128  size_t index;
129  uint16_t length;
130  };
131 
133  int16_t headerBytes_;
136  int16_t triggerFedId_;
140 
142  uint32_t event_;
143  bool once_;
144  bool first_;
146  bool quiet_;
150  bool legacy_;
151  uint32_t errorThreshold_;
152 
154  std::vector<Registry> zs_work_registry_;
155  std::vector<Registry> virgin_work_registry_;
156  std::vector<Registry> scope_work_registry_;
157  std::vector<Registry> proc_work_registry_;
158  std::vector<Registry> cm_work_registry_;
159 
161  std::vector<SiStripDigi> zs_work_digis_;
162  std::vector<SiStripRawDigi> virgin_work_digis_;
163  std::vector<SiStripRawDigi> scope_work_digis_;
164  std::vector<SiStripRawDigi> proc_work_digis_;
165  std::vector<SiStripRawDigi> cm_work_digis_;
166 
168  };
169 } // namespace sistrip
170 
171 void sistrip::RawToDigiUnpacker::readoutOrder(uint16_t& physical_order, uint16_t& readout_order) {
172  readout_order = (4 * ((static_cast<uint16_t>((static_cast<float>(physical_order) / 8.0))) % 4) +
173  static_cast<uint16_t>(static_cast<float>(physical_order) / 32.0) + 16 * (physical_order % 8));
174 }
175 
176 void sistrip::RawToDigiUnpacker::physicalOrder(uint16_t& readout_order, uint16_t& physical_order) {
177  physical_order = ((32 * (readout_order % 4)) + (8 * static_cast<uint16_t>(static_cast<float>(readout_order) / 4.0)) -
178  (31 * static_cast<uint16_t>(static_cast<float>(readout_order) / 16.0)));
179 }
180 
182  if ((register_value & 0xF) == 0x1) {
184  } else if ((register_value & 0xF) == 0x2) {
186  } else if ((register_value & 0xF) == 0x0) {
188  } else {
190  }
191 }
192 
194  return static_cast<sistrip::FedReadoutMode>(register_value & 0xF);
195 }
196 
197 void sistrip::RawToDigiUnpacker::quiet(bool quiet) { quiet_ = quiet; }
198 
199 void sistrip::RawToDigiUnpacker::useDaqRegister(bool use) { useDaqRegister_ = use; }
200 
201 void sistrip::RawToDigiUnpacker::extractCm(bool extract_cm) { extractCm_ = extract_cm; }
202 
203 void sistrip::RawToDigiUnpacker::doFullCorruptBufferChecks(bool do_full_corrupt_buffer_checks) {
204  doFullCorruptBufferChecks_ = do_full_corrupt_buffer_checks;
205 }
206 
207 void sistrip::RawToDigiUnpacker::doAPVEmulatorCheck(bool do_APVEmulator_check) {
208  doAPVEmulatorCheck_ = do_APVEmulator_check;
209 }
210 
211 void sistrip::RawToDigiUnpacker::legacy(bool legacy) { legacy_ = legacy; }
212 
213 #endif // EventFilter_SiStripRawToDigi_SiStripRawToDigiUnpacker_H
void useDaqRegister(bool)
EventSummary update request -> not yet implemented for FEDBuffer class.
std::vector< Registry > proc_work_registry_
std::vector< SiStripDigi > zs_work_digis_
digi collections
std::vector< Registry > scope_work_registry_
std::vector< Registry > zs_work_registry_
registries
Registry(uint32_t aDetid, uint16_t firstStrip, size_t indexInVector, uint16_t numberOfDigis)
constructor
void physicalOrder(uint16_t &readout_order, uint16_t &physical_order)
order of strips
sistrip::FedBufferFormat fedBufferFormat(const uint16_t &register_value)
returns buffer format
sistrip classes
private class to register start and end index of digis in a collection
static std::string const input
Definition: EdmProvDump.cc:48
std::vector< SiStripRawDigi > virgin_work_digis_
void readoutOrder(uint16_t &physical_order, uint16_t &readout_order)
order of strips
edm::DetSetVector< SiStripRawDigi > RawDigis
std::vector< SiStripRawDigi > scope_work_digis_
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
Definition: SiStripDigi.h:12
std::vector< SiStripRawDigi > proc_work_digis_
#define dso_hidden
Definition: Visibility.h:12
std::vector< SiStripRawDigi > cm_work_digis_
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
#define update(a, b)
bool operator<(const Registry &other) const
< operator to sort registries
std::vector< Registry > cm_work_registry_
edm::DetSetVector< SiStripDigi > Digis
A Digi for the silicon strip detector, containing only adc information, and suitable for storing raw ...
std::vector< Registry > virgin_work_registry_
Definition: event.py:1
sistrip::FedReadoutMode fedReadoutMode(const uint16_t &register_value)
returns buffer readout mode