35 #define COUT std::cout << "VI " 37 #define COUT LogDebug("") 42 std::unique_ptr<sistrip::FEDBuffer>
buffer;
52 <<
"[ClustersFromRawProducer::" << __func__ <<
"]" << st_buffer <<
" for FED ID " <<
fedId;
57 const auto st_chan =
buffer->findChannels();
61 <<
"Exception caught when creating FEDBuffer object for FED " <<
fedId <<
": " << st_chan;
69 <<
"Exception caught when creating FEDBuffer object for FED " <<
fedId <<
": FED Buffer check fails";
93 bool idoAPVEmulatorCheck,
95 bool hybridZeroSuppressed)
100 doAPVEmulatorCheck(idoAPVEmulatorCheck),
102 hybridZeroSuppressed_(hybridZeroSuppressed) {
103 incTot(
clusterizer.conditions().allDetIds().size());
108 ~ClusterFiller()
override { printStat(); }
113 std::unique_ptr<sistrip::FEDBuffer> buffers[1024];
114 std::atomic<sistrip::FEDBuffer*>
done[1024];
123 bool doAPVEmulatorCheck;
126 bool hybridZeroSuppressed_;
130 Stat() : totDet(0), detReady(0), detSet(0), detAct(0), detNoZ(0), detAbrt(0), totClus(0) {}
131 std::atomic<int> totDet;
132 std::atomic<int> detReady;
133 std::atomic<int> detSet;
134 std::atomic<int> detAct;
135 std::atomic<int> detNoZ;
136 std::atomic<int> detAbrt;
137 std::atomic<int> totClus;
142 void incTot(
int n)
const {
stat.totDet =
n; }
143 void incReady()
const {
stat.detReady++; }
144 void incSet()
const {
stat.detSet++; }
145 void incAct()
const {
stat.detAct++; }
146 void incNoZ()
const {
stat.detNoZ++; }
147 void incAbrt()
const {
stat.detAbrt++; }
148 void incClus(
int n)
const {
stat.totClus +=
n; }
149 void printStat()
const {
150 COUT <<
"VI clusters " <<
stat.totDet <<
',' <<
stat.detReady <<
',' <<
stat.detSet <<
',' <<
stat.detAct <<
',' 151 <<
stat.detNoZ <<
',' <<
stat.detAbrt <<
',' <<
stat.totClus << std::endl;
155 static void zeroStat() {}
156 static void incTot(
int) {}
157 static void incReady() {}
158 static void incSet() {}
159 static void incAct() {}
160 static void incNoZ() {}
161 static void incAbrt() {}
162 static void incClus(
int) {}
163 static void printStat() {}
175 consumesCollector())),
178 legacy_(conf.existsAs<
bool>(
"LegacyUnpacker") ? conf.getParameter<
bool>(
"LegacyUnpacker") :
false),
181 produces<edmNew::DetSetVector<SiStripCluster> >();
193 std::unique_ptr<edmNew::DetSetVector<SiStripCluster> >
output(
203 output->reserve(15000, 24 * 10000);
208 COUT <<
output->dataSize() <<
" clusters from " <<
output->size() <<
" modules" << std::endl;
225 std::unique_ptr<SiStripRawProcessingAlgorithms>
rawAlgos_;
238 (*clusterizer_).initialize(es);
239 (*rawAlgos_).initialize(es);
246 for (
auto idet :
clusterizer_->conditions().allDetIds()) {
258 class StripByStripAdder {
260 typedef std::output_iterator_tag iterator_category;
262 typedef void difference_type;
263 typedef void pointer;
272 clusterizer_.stripByStripAdd(state_, digi.
strip(), digi.
adc(), record_);
276 StripByStripAdder&
operator*() {
return *
this; }
277 StripByStripAdder& operator++() {
return *
this; }
278 StripByStripAdder& operator++(
int) {
return *
this; }
286 template <
typename Container>
287 class ADC_back_inserter {
292 c_.push_back(digi.
adc());
295 ADC_back_inserter&
operator*() {
return *
this; }
296 ADC_back_inserter& operator++() {
return *
this; }
297 ADC_back_inserter& operator++(
int) {
return *
this; }
310 COUT <<
"filling " << idet << std::endl;
312 auto const& det =
clusterizer.stripByStripBegin(idet);
348 buffer->setLegacyMode(legacy_);
351 const uint8_t fedCh =
conn->fedCh();
355 std::ostringstream
ss;
356 ss <<
"Problem unpacking channel " << fedCh <<
" on FED " <<
fedId;
363 uint16_t ipair =
conn->apvPairNumber();
373 const uint8_t pCode = (isNonLite ?
buffer->packetCode(legacy_, fedCh) : 0);
375 if LIKELY (!hybridZeroSuppressed_) {
377 buffer->channel(fedCh), perStripAdder, ipair * 256, isNonLite,
mode, legacy_, lmode, pCode);
379 const uint32_t
id =
conn->detId();
383 buffer->channel(fedCh), std::back_inserter(unpDigis), ipair * 256, isNonLite,
mode, legacy_, lmode, pCode);
386 rawAlgos.suppressHybridData(unpDigis, suppDigis, ipair * 2);
392 <<
"Unordered clusters for channel " << fedCh <<
" on FED " <<
fedId <<
": " <<
toString(st_ch);
398 std::vector<int16_t> digis;
400 buffer->channel(fedCh), ADC_back_inserter(digis),
buffer->channel(fedCh).packetCode());
403 uint32_t
id =
conn->detId();
408 uint16_t firstAPV = ipair * 2;
409 rawAlgos.suppressVirginRawData(
id, firstAPV, digis, zsdigis);
410 for (
const auto digi : zsdigis) {
415 std::vector<int16_t> digis;
419 uint32_t
id =
conn->detId();
423 uint16_t firstAPV = ipair * 2;
424 rawAlgos.suppressProcessedRawData(
id, firstAPV, digis, zsdigis);
431 <<
"[ClustersFromRawProducer::" << __func__ <<
"]" 432 <<
" FEDRawData readout mode " <<
mode <<
" from FED id " <<
fedId <<
" not supported.";
436 <<
"[ClustersFromRawProducer::" << __func__ <<
"]" <<
toString(st_ch) <<
" from FED id " <<
fedId 437 <<
" channel " << fedCh;
456 COUT <<
"filled " <<
record.size() << std::endl;
458 COUT <<
cl.firstStrip() <<
',' <<
cl.amplitudes().size() << std::endl;
T getParameter(std::string const &) const
StatusCode unpackZeroSuppressed(const FEDChannel &channel, OUT &&out, uint16_t stripStart, bool isNonLite, FEDReadoutMode mode, bool legacy=false, FEDLegacyReadoutMode lmode=READOUT_MODE_LEGACY_INVALID, uint8_t packetCode=0)
void run(const FEDRawDataCollection &rawColl, edmNew::DetSetVector< SiStripCluster > &output)
def create(alignables, pedeDump, additionalData, outputFile, config)
static const char mlRawToCluster_[]
#define DEFINE_FWK_MODULE(type)
void initialize(const edm::EventSetup &es)
Log< level::Error, false > LogError
std::string toString(fedchannelunpacker::StatusCode status)
const SiStripClusterizerConditions & conditions() const
const uint16_t & strip() const
const uint16_t & adc() const
bool isProcessedRaw(FEDReadoutMode mode, bool legacy=false, FEDLegacyReadoutMode lmode=READOUT_MODE_LEGACY_INVALID)
void produce(edm::Event &ev, const edm::EventSetup &es) override
Container::value_type value_type
bool isVirginRaw(FEDReadoutMode mode, bool legacy=false, FEDLegacyReadoutMode lmode=READOUT_MODE_LEGACY_INVALID)
StatusCode unpackVirginRaw(const FEDChannel &channel, OUT &&out, uint8_t packetCode)
std::unique_ptr< StripClusterizerAlgorithm > clusterizer_
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
bool isZeroSuppressed(FEDReadoutMode mode, bool legacy=false, FEDLegacyReadoutMode lmode=READOUT_MODE_LEGACY_INVALID)
SiStripClusterizerFromRaw(const edm::ParameterSet &conf)
bool isNonLiteZS(FEDReadoutMode mode, bool legacy=false, FEDLegacyReadoutMode lmode=READOUT_MODE_LEGACY_INVALID)
FEDBufferStatusCode preconstructCheckFEDBuffer(const FEDRawData &fedBuffer, bool allowBadBuffer=false)
MatrixMeschach operator*(const MatrixMeschach &mat1, const MatrixMeschach &mat2)
Log< level::Warning, false > LogWarning
collection_type::const_iterator const_iterator
A Digi for the silicon strip detector, containing only adc information, and suitable for storing raw ...
bool hybridZeroSuppressed_
std::unique_ptr< SiStripRawProcessingAlgorithms > rawAlgos_
edm::AssociationVector< reco::JetRefBaseProd, Values > Container
edm::EDGetTokenT< FEDRawDataCollection > productToken_
StatusCode unpackProcessedRaw(const FEDChannel &channel, OUT &&out)