39 #define COUT std::cout << "VI " 41 #define COUT LogDebug("") 46 std::unique_ptr<sistrip::FEDBuffer>
buffer;
56 <<
"[ClustersFromRawProducer::" << __func__ <<
"]" << st_buffer <<
" for FED ID " <<
fedId;
61 const auto st_chan =
buffer->findChannels();
65 <<
"Exception caught when creating FEDBuffer object for FED " <<
fedId <<
": " << st_chan;
73 <<
"Exception caught when creating FEDBuffer object for FED " <<
fedId <<
": FED Buffer check fails";
97 bool idoAPVEmulatorCheck,
99 bool hybridZeroSuppressed)
104 doAPVEmulatorCheck(idoAPVEmulatorCheck),
106 hybridZeroSuppressed_(hybridZeroSuppressed) {
107 incTot(
clusterizer.conditions().allDetIds().size());
112 ~ClusterFiller()
override { printStat(); }
118 mutable std::atomic<sistrip::FEDBuffer*>
done[1024];
127 bool doAPVEmulatorCheck;
130 bool hybridZeroSuppressed_;
134 Stat() : totDet(0), detReady(0), detSet(0), detAct(0), detNoZ(0), detAbrt(0), totClus(0) {}
135 std::atomic<int> totDet;
136 std::atomic<int> detReady;
137 std::atomic<int> detSet;
138 std::atomic<int> detAct;
139 std::atomic<int> detNoZ;
140 std::atomic<int> detAbrt;
141 std::atomic<int> totClus;
146 void incTot(
int n)
const {
stat.totDet =
n; }
147 void incReady()
const {
stat.detReady++; }
148 void incSet()
const {
stat.detSet++; }
149 void incAct()
const {
stat.detAct++; }
150 void incNoZ()
const {
stat.detNoZ++; }
151 void incAbrt()
const {
stat.detAbrt++; }
152 void incClus(
int n)
const {
stat.totClus +=
n; }
153 void printStat()
const {
154 COUT <<
"VI clusters " <<
stat.totDet <<
',' <<
stat.detReady <<
',' <<
stat.detSet <<
',' <<
stat.detAct <<
',' 155 <<
stat.detNoZ <<
',' <<
stat.detAbrt <<
',' <<
stat.totClus << std::endl;
159 static void zeroStat() {}
160 static void incTot(
int) {}
161 static void incReady() {}
162 static void incSet() {}
163 static void incAct() {}
164 static void incNoZ() {}
165 static void incAbrt() {}
166 static void incClus(
int) {}
167 static void printStat() {}
179 consumesCollector())),
181 legacy_(conf.getParameter<
bool>(
"LegacyUnpacker")),
184 produces<edmNew::DetSetVector<SiStripCluster> >();
196 std::unique_ptr<edmNew::DetSetVector<SiStripCluster> >
output(
206 output->reserve(15000, 24 * 10000);
211 COUT <<
output->dataSize() <<
" clusters from " <<
output->size() <<
" modules" << std::endl;
230 std::unique_ptr<SiStripRawProcessingAlgorithms>
rawAlgos_;
244 desc.add(
"onDemand",
true);
245 desc.add(
"DoAPVEmulatorCheck",
true);
246 desc.add(
"LegacyUnpacker",
false);
247 desc.add(
"HybridZeroSuppressed",
false);
264 (*clusterizer_).initialize(es);
265 (*rawAlgos_).initialize(es);
272 for (
auto idet :
clusterizer_->conditions().allDetIds()) {
283 class StripByStripAdder {
285 typedef std::output_iterator_tag iterator_category;
287 typedef void difference_type;
288 typedef void pointer;
297 clusterizer_.stripByStripAdd(state_, digi.
strip(), digi.
adc(), record_);
301 StripByStripAdder&
operator*() {
return *
this; }
302 StripByStripAdder&
operator++() {
return *
this; }
303 StripByStripAdder&
operator++(
int) {
return *
this; }
311 template <
typename Container>
312 class ADC_back_inserter {
317 c_.push_back(digi.
adc());
320 ADC_back_inserter&
operator*() {
return *
this; }
321 ADC_back_inserter&
operator++() {
return *
this; }
322 ADC_back_inserter&
operator++(
int) {
return *
this; }
335 COUT <<
"filling " << idet << std::endl;
337 auto const& det =
clusterizer.stripByStripBegin(idet);
373 buffer->setLegacyMode(legacy_);
376 const uint8_t fedCh =
conn->fedCh();
380 std::ostringstream
ss;
381 ss <<
"Problem unpacking channel " << fedCh <<
" on FED " <<
fedId;
388 uint16_t ipair =
conn->apvPairNumber();
398 const uint8_t pCode = (isNonLite ?
buffer->packetCode(legacy_, fedCh) : 0);
400 if LIKELY (!hybridZeroSuppressed_) {
402 buffer->channel(fedCh), perStripAdder, ipair * 256, isNonLite,
mode, legacy_, lmode, pCode);
404 const uint32_t
id =
conn->detId();
408 buffer->channel(fedCh), std::back_inserter(unpDigis), ipair * 256, isNonLite,
mode, legacy_, lmode, pCode);
411 unsigned int detId = suppDigis.id;
413 rawAlgos.suppressHybridData(maxNStrips, unpDigis, suppDigis, ipair * 2);
414 std::copy(std::begin(suppDigis), std::end(suppDigis), perStripAdder);
419 <<
"Unordered clusters for channel " << fedCh <<
" on FED " <<
fedId <<
": " <<
toString(st_ch);
425 std::vector<int16_t> digis;
427 buffer->channel(fedCh), ADC_back_inserter(digis),
buffer->channel(fedCh).packetCode());
430 uint32_t
id =
conn->detId();
435 uint16_t firstAPV = ipair * 2;
436 rawAlgos.suppressVirginRawData(
id, firstAPV, digis, zsdigis);
437 for (
const auto digi : zsdigis) {
442 std::vector<int16_t> digis;
446 uint32_t
id =
conn->detId();
450 uint16_t firstAPV = ipair * 2;
451 rawAlgos.suppressProcessedRawData(
id, firstAPV, digis, zsdigis);
458 <<
"[ClustersFromRawProducer::" << __func__ <<
"]" 459 <<
" FEDRawData readout mode " <<
mode <<
" from FED id " <<
fedId <<
" not supported.";
463 <<
"[ClustersFromRawProducer::" << __func__ <<
"]" <<
toString(st_ch) <<
" from FED id " <<
fedId 464 <<
" channel " << fedCh;
483 COUT <<
"filled " <<
record.size() << std::endl;
485 COUT <<
cl.firstStrip() <<
',' <<
cl.amplitudes().size() << std::endl;
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
T getParameter(std::string const &) const
Basic3DVector & operator=(const Basic3DVector &)=default
Assignment operator.
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_[]
constexpr Process operator++(Process p)
void initialize(const edm::EventSetup &es)
static void fillDescriptions(edm::ParameterSetDescription &algorithms)
Log< level::Error, false > LogError
friend class TSFastFiller
std::string toString(fedchannelunpacker::StatusCode status)
const SiStripClusterizerConditions & conditions() const
unsigned int numberOfAPVs() 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
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Container::value_type value_type
#define CMS_THREAD_GUARD(_var_)
bool isVirginRaw(FEDReadoutMode mode, bool legacy=false, FEDLegacyReadoutMode lmode=READOUT_MODE_LEGACY_INVALID)
#define DEFINE_FWK_MODULE(type)
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
Detector identifier class for the strip tracker.
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)
static void fillDescriptions(edm::ParameterSetDescription &clusterizer)
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)
virtual void fill(typename DetSetVector< T >::TSFastFiller &) const =0