35 #define COUT std::cout << "VI "
37 #define COUT LogDebug("")
42 std::unique_ptr<sistrip::FEDBuffer>
buffer;
53 <<
"[ClustersFromRawProducer::" << __func__ <<
"]" << st_buffer <<
" for FED ID " <<
fedId;
58 const auto st_chan =
buffer->findChannels();
63 <<
"Exception caught when creating FEDBuffer object for FED " <<
fedId <<
": " << st_chan;
72 <<
"Exception caught when creating FEDBuffer object for FED " <<
fedId <<
": FED Buffer check fails";
96 bool idoAPVEmulatorCheck,
98 bool hybridZeroSuppressed)
102 doAPVEmulatorCheck(idoAPVEmulatorCheck),
104 hybridZeroSuppressed_(hybridZeroSuppressed) {
110 ~ClusterFiller()
override { printStat(); }
115 std::unique_ptr<sistrip::FEDBuffer> buffers[1024];
116 std::atomic<sistrip::FEDBuffer*>
done[1024];
124 bool doAPVEmulatorCheck;
127 bool hybridZeroSuppressed_;
131 Stat() : totDet(0), detReady(0), detSet(0), detAct(0), detNoZ(0), detAbrt(0), totClus(0) {}
132 std::atomic<int> totDet;
133 std::atomic<int> detReady;
134 std::atomic<int> detSet;
135 std::atomic<int> detAct;
136 std::atomic<int> detNoZ;
137 std::atomic<int> detAbrt;
138 std::atomic<int> totClus;
143 void incTot(
int n)
const {
stat.totDet =
n; }
144 void incReady()
const {
stat.detReady++; }
145 void incSet()
const {
stat.detSet++; }
146 void incAct()
const {
stat.detAct++; }
147 void incNoZ()
const {
stat.detNoZ++; }
148 void incAbrt()
const {
stat.detAbrt++; }
149 void incClus(
int n)
const {
stat.totClus +=
n; }
150 void printStat()
const {
151 COUT <<
"VI clusters " <<
stat.totDet <<
',' <<
stat.detReady <<
',' <<
stat.detSet <<
',' <<
stat.detAct <<
','
152 <<
stat.detNoZ <<
',' <<
stat.detAbrt <<
',' <<
stat.totClus << std::endl;
156 static void zeroStat() {}
157 static void incTot(
int) {}
158 static void incReady() {}
159 static void incSet() {}
160 static void incAct() {}
161 static void incNoZ() {}
162 static void incAbrt() {}
163 static void incClus(
int) {}
164 static void printStat() {}
178 legacy_(conf.existsAs<
bool>(
"LegacyUnpacker") ? conf.getParameter<
bool>(
"LegacyUnpacker") :
false),
181 produces<edmNew::DetSetVector<SiStripCluster> >();
195 std::unique_ptr<edmNew::DetSetVector<SiStripCluster> >
output(
205 output->reserve(15000, 24 * 10000);
210 COUT <<
output->dataSize() <<
" clusters from " <<
output->size() <<
" modules" << std::endl;
229 std::unique_ptr<SiStripRawProcessingAlgorithms>
rawAlgos_;
242 (*clusterizer_).initialize(es);
243 cabling_ = (*clusterizer_).cabling();
244 (*rawAlgos_).initialize(es);
263 class StripByStripAdder {
265 typedef std::output_iterator_tag iterator_category;
267 typedef void difference_type;
268 typedef void pointer;
277 clusterizer_.stripByStripAdd(state_, digi.
strip(), digi.
adc(), record_);
281 StripByStripAdder&
operator*() {
return *
this; }
282 StripByStripAdder& operator++() {
return *
this; }
283 StripByStripAdder& operator++(
int) {
return *
this; }
291 template <
typename Container>
292 class ADC_back_inserter {
297 c_.push_back(digi.
adc());
300 ADC_back_inserter&
operator*() {
return *
this; }
301 ADC_back_inserter& operator++() {
return *
this; }
302 ADC_back_inserter& operator++(
int) {
return *
this; }
315 COUT <<
"filling " << idet << std::endl;
317 auto const& det =
clusterizer.stripByStripBegin(idet);
352 buffer->setLegacyMode(legacy_);
355 const uint8_t fedCh =
conn->fedCh();
360 std::ostringstream
ss;
361 ss <<
"Problem unpacking channel " << fedCh <<
" on FED " <<
fedId;
368 uint16_t ipair =
conn->apvPairNumber();
379 const uint8_t pCode = (isNonLite ?
buffer->packetCode(legacy_, fedCh) : 0);
382 LIKELY(!hybridZeroSuppressed_) {
384 buffer->channel(fedCh), perStripAdder, ipair * 256, isNonLite,
mode, legacy_, lmode, pCode);
387 const uint32_t
id =
conn->detId();
391 std::back_inserter(unpDigis),
400 rawAlgos.suppressHybridData(unpDigis, suppDigis, ipair * 2);
406 <<
"Unordered clusters for channel " << fedCh <<
" on FED " <<
fedId <<
": " <<
toString(st_ch);
413 std::vector<int16_t> digis;
415 buffer->channel(fedCh), ADC_back_inserter(digis),
buffer->channel(fedCh).packetCode());
418 uint32_t
id =
conn->detId();
423 uint16_t firstAPV = ipair * 2;
424 rawAlgos.suppressVirginRawData(
id, firstAPV, digis, zsdigis);
425 for (
const auto digi : zsdigis) {
430 std::vector<int16_t> digis;
434 uint32_t
id =
conn->detId();
438 uint16_t firstAPV = ipair * 2;
439 rawAlgos.suppressProcessedRawData(
id, firstAPV, digis, zsdigis);
446 <<
"[ClustersFromRawProducer::" << __func__ <<
"]"
447 <<
" FEDRawData readout mode " <<
mode <<
" from FED id " <<
fedId <<
" not supported.";
451 <<
"[ClustersFromRawProducer::" << __func__ <<
"]" <<
toString(st_ch) <<
" from FED id " <<
fedId
452 <<
" channel " << fedCh;
471 COUT <<
"filled " <<
record.size() << std::endl;
473 COUT <<
cl.firstStrip() <<
',' <<
cl.amplitudes().size() << std::endl;