37 #define COUT std::cout << "VI " 39 #define COUT LogDebug("") 44 std::unique_ptr<sistrip::FEDBuffer>
buffer;
54 <<
"[ClustersFromRawProducer::" << __func__ <<
"]" << st_buffer <<
" for FED ID " <<
fedId;
59 const auto st_chan =
buffer->findChannels();
63 <<
"Exception caught when creating FEDBuffer object for FED " <<
fedId <<
": " << st_chan;
71 <<
"Exception caught when creating FEDBuffer object for FED " <<
fedId <<
": FED Buffer check fails";
95 bool idoAPVEmulatorCheck,
97 bool hybridZeroSuppressed)
102 doAPVEmulatorCheck(idoAPVEmulatorCheck),
104 hybridZeroSuppressed_(hybridZeroSuppressed) {
105 incTot(
clusterizer.conditions().allDetIds().size());
110 ~ClusterFiller()
override { printStat(); }
115 std::unique_ptr<sistrip::FEDBuffer> buffers[1024];
116 std::atomic<sistrip::FEDBuffer*>
done[1024];
125 bool doAPVEmulatorCheck;
128 bool hybridZeroSuppressed_;
132 Stat() : totDet(0), detReady(0), detSet(0), detAct(0), detNoZ(0), detAbrt(0), totClus(0) {}
133 std::atomic<int> totDet;
134 std::atomic<int> detReady;
135 std::atomic<int> detSet;
136 std::atomic<int> detAct;
137 std::atomic<int> detNoZ;
138 std::atomic<int> detAbrt;
139 std::atomic<int> totClus;
144 void incTot(
int n)
const {
stat.totDet =
n; }
145 void incReady()
const {
stat.detReady++; }
146 void incSet()
const {
stat.detSet++; }
147 void incAct()
const {
stat.detAct++; }
148 void incNoZ()
const {
stat.detNoZ++; }
149 void incAbrt()
const {
stat.detAbrt++; }
150 void incClus(
int n)
const {
stat.totClus +=
n; }
151 void printStat()
const {
152 COUT <<
"VI clusters " <<
stat.totDet <<
',' <<
stat.detReady <<
',' <<
stat.detSet <<
',' <<
stat.detAct <<
',' 153 <<
stat.detNoZ <<
',' <<
stat.detAbrt <<
',' <<
stat.totClus << std::endl;
157 static void zeroStat() {}
158 static void incTot(
int) {}
159 static void incReady() {}
160 static void incSet() {}
161 static void incAct() {}
162 static void incNoZ() {}
163 static void incAbrt() {}
164 static void incClus(
int) {}
165 static void printStat() {}
177 consumesCollector())),
179 legacy_(conf.getParameter<
bool>(
"LegacyUnpacker")),
182 produces<edmNew::DetSetVector<SiStripCluster> >();
194 std::unique_ptr<edmNew::DetSetVector<SiStripCluster> >
output(
204 output->reserve(15000, 24 * 10000);
209 COUT <<
output->dataSize() <<
" clusters from " <<
output->size() <<
" modules" << std::endl;
228 std::unique_ptr<SiStripRawProcessingAlgorithms>
rawAlgos_;
242 desc.add(
"onDemand",
true);
243 desc.add(
"DoAPVEmulatorCheck",
true);
244 desc.add(
"LegacyUnpacker",
false);
245 desc.add(
"HybridZeroSuppressed",
false);
262 (*clusterizer_).initialize(es);
263 (*rawAlgos_).initialize(es);
270 for (
auto idet :
clusterizer_->conditions().allDetIds()) {
281 class StripByStripAdder {
283 typedef std::output_iterator_tag iterator_category;
285 typedef void difference_type;
286 typedef void pointer;
295 clusterizer_.stripByStripAdd(state_, digi.
strip(), digi.
adc(), record_);
299 StripByStripAdder&
operator*() {
return *
this; }
300 StripByStripAdder&
operator++() {
return *
this; }
301 StripByStripAdder&
operator++(
int) {
return *
this; }
309 template <
typename Container>
310 class ADC_back_inserter {
315 c_.push_back(digi.
adc());
318 ADC_back_inserter&
operator*() {
return *
this; }
319 ADC_back_inserter&
operator++() {
return *
this; }
320 ADC_back_inserter&
operator++(
int) {
return *
this; }
333 COUT <<
"filling " << idet << std::endl;
335 auto const& det =
clusterizer.stripByStripBegin(idet);
371 buffer->setLegacyMode(legacy_);
374 const uint8_t fedCh =
conn->fedCh();
378 std::ostringstream
ss;
379 ss <<
"Problem unpacking channel " << fedCh <<
" on FED " <<
fedId;
386 uint16_t ipair =
conn->apvPairNumber();
396 const uint8_t pCode = (isNonLite ?
buffer->packetCode(legacy_, fedCh) : 0);
398 if LIKELY (!hybridZeroSuppressed_) {
400 buffer->channel(fedCh), perStripAdder, ipair * 256, isNonLite,
mode, legacy_, lmode, pCode);
402 const uint32_t
id =
conn->detId();
406 buffer->channel(fedCh), std::back_inserter(unpDigis), ipair * 256, isNonLite,
mode, legacy_, lmode, pCode);
409 rawAlgos.suppressHybridData(unpDigis, suppDigis, ipair * 2);
410 std::copy(std::begin(suppDigis), std::end(suppDigis), perStripAdder);
415 <<
"Unordered clusters for channel " << fedCh <<
" on FED " <<
fedId <<
": " <<
toString(st_ch);
421 std::vector<int16_t> digis;
423 buffer->channel(fedCh), ADC_back_inserter(digis),
buffer->channel(fedCh).packetCode());
426 uint32_t
id =
conn->detId();
431 uint16_t firstAPV = ipair * 2;
432 rawAlgos.suppressVirginRawData(
id, firstAPV, digis, zsdigis);
433 for (
const auto digi : zsdigis) {
438 std::vector<int16_t> digis;
442 uint32_t
id =
conn->detId();
446 uint16_t firstAPV = ipair * 2;
447 rawAlgos.suppressProcessedRawData(
id, firstAPV, digis, zsdigis);
454 <<
"[ClustersFromRawProducer::" << __func__ <<
"]" 455 <<
" FEDRawData readout mode " <<
mode <<
" from FED id " <<
fedId <<
" not supported.";
459 <<
"[ClustersFromRawProducer::" << __func__ <<
"]" <<
toString(st_ch) <<
" from FED id " <<
fedId 460 <<
" channel " << fedCh;
479 COUT <<
"filled " <<
record.size() << std::endl;
481 COUT <<
cl.firstStrip() <<
',' <<
cl.amplitudes().size() << std::endl;
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
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_[]
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
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
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...
virtual void fill(typename DetSetVector< T >::TSFastFiller &)=0
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)
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)