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;
56 buffer = std::make_unique<sistrip::FEDBuffer>(rawData);
57 const auto st_chan = buffer->findChannels();
61 <<
"Exception caught when creating FEDBuffer object for FED " << fedId <<
": " << st_chan;
66 if UNLIKELY (!buffer->doChecks(
false)) {
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() {}
171 :
onDemand(conf.getParameter<bool>(
"onDemand")),
175 consumesCollector())),
176 doAPVEmulatorCheck_(conf.existsAs<bool>(
"DoAPVEmulatorCheck") ? conf.getParameter<bool>(
"DoAPVEmulatorCheck")
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;
269 : clusterizer_(clusterizer), state_(state), record_(record) {}
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; }
308 auto idet = record.
id();
310 COUT <<
"filling " << idet << std::endl;
312 auto const& det =
clusterizer.stripByStripBegin(idet);
334 buffer = fillBuffer(
fedId, rawColl).release();
339 if (
done[
fedId].compare_exchange_strong(exp, buffer))
340 buffers[
fedId].reset(buffer);
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();
369 using namespace sistrip;
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;
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;
448 << record.
id() <<
' ' << record.
size();
456 COUT <<
"filled " << record.
size() << std::endl;
457 for (
auto const&
cl : record)
458 COUT <<
cl.firstStrip() <<
',' <<
cl.amplitudes().size() << std::endl;
459 incClus(record.size());
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
const edm::EventSetup & c
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)
static const char mlRawToCluster_[]
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
FEDReadoutMode readoutMode() const
void reserve(size_type s)
void initialize(const edm::EventSetup &es)
Exp< T >::type exp(const T &t)
Log< level::Error, false > LogError
std::string toString(fedchannelunpacker::StatusCode status)
void setLegacyMode(bool legacy)
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
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
const uint16_t & strip() const
FEDLegacyReadoutMode legacyReadoutMode() const
if(conf_.getParameter< bool >("UseStripCablingDB"))
bool isVirginRaw(FEDReadoutMode mode, bool legacy=false, FEDLegacyReadoutMode lmode=READOUT_MODE_LEGACY_INVALID)
StatusCode unpackVirginRaw(const FEDChannel &channel, OUT &&out, uint8_t packetCode)
uint8_t packetCode(bool legacy=false, const uint8_t internalFEDChannelNum=0) const
std::unique_ptr< StripClusterizerAlgorithm > clusterizer_
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
bool channelGood(const uint8_t internalFEDannelNum, const bool doAPVeCheck) const
const FEDChannel & channel(const uint8_t internalFEDChannelNum) const
const SiStripClusterizerConditions & conditions() const
void fill(std::map< std::string, TH1 * > &h, const std::string &s, double x)
bool isZeroSuppressed(FEDReadoutMode mode, bool legacy=false, FEDLegacyReadoutMode lmode=READOUT_MODE_LEGACY_INVALID)
T getParameter(std::string const &) const
uint8_t packetCode() const
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
const uint16_t & adc() const
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)