38 #define COUT std::cout << "VI " 40 #define COUT LogDebug("") 45 std::unique_ptr<sistrip::FEDBuffer>
buffer;
55 <<
"[ClustersFromRawProducer::" << __func__ <<
"]" << st_buffer <<
" for FED ID " <<
fedId;
60 const auto st_chan =
buffer->findChannels();
64 <<
"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)
103 doAPVEmulatorCheck(idoAPVEmulatorCheck),
105 hybridZeroSuppressed_(hybridZeroSuppressed) {
106 incTot(
clusterizer.conditions().allDetIds().size());
111 ~ClusterFiller()
override { printStat(); }
117 mutable std::atomic<sistrip::FEDBuffer*>
done[1024];
126 bool doAPVEmulatorCheck;
129 bool hybridZeroSuppressed_;
133 Stat() : totDet(0), detReady(0), detSet(0), detAct(0), detNoZ(0), detAbrt(0), totClus(0) {}
134 std::atomic<int> totDet;
135 std::atomic<int> detReady;
136 std::atomic<int> detSet;
137 std::atomic<int> detAct;
138 std::atomic<int> detNoZ;
139 std::atomic<int> detAbrt;
140 std::atomic<int> totClus;
145 void incTot(
int n)
const {
stat.totDet =
n; }
146 void incReady()
const {
stat.detReady++; }
147 void incSet()
const {
stat.detSet++; }
148 void incAct()
const {
stat.detAct++; }
149 void incNoZ()
const {
stat.detNoZ++; }
150 void incAbrt()
const {
stat.detAbrt++; }
151 void incClus(
int n)
const {
stat.totClus +=
n; }
152 void printStat()
const {
153 COUT <<
"VI clusters " <<
stat.totDet <<
',' <<
stat.detReady <<
',' <<
stat.detSet <<
',' <<
stat.detAct <<
',' 154 <<
stat.detNoZ <<
',' <<
stat.detAbrt <<
',' <<
stat.totClus << std::endl;
158 static void zeroStat() {}
159 static void incTot(
int) {}
160 static void incReady() {}
161 static void incSet() {}
162 static void incAct() {}
163 static void incNoZ() {}
164 static void incAbrt() {}
165 static void incClus(
int) {}
166 static void printStat() {}
178 consumesCollector())),
180 legacy_(conf.getParameter<
bool>(
"LegacyUnpacker")),
183 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_;
243 desc.add(
"onDemand",
true);
244 desc.add(
"DoAPVEmulatorCheck",
true);
245 desc.add(
"LegacyUnpacker",
false);
246 desc.add(
"HybridZeroSuppressed",
false);
263 (*clusterizer_).initialize(es);
264 (*rawAlgos_).initialize(es);
271 for (
auto idet :
clusterizer_->conditions().allDetIds()) {
282 class StripByStripAdder {
284 typedef std::output_iterator_tag iterator_category;
286 typedef void difference_type;
287 typedef void pointer;
296 clusterizer_.stripByStripAdd(state_, digi.
strip(), digi.
adc(), record_);
300 StripByStripAdder&
operator*() {
return *
this; }
301 StripByStripAdder&
operator++() {
return *
this; }
302 StripByStripAdder&
operator++(
int) {
return *
this; }
310 template <
typename Container>
311 class ADC_back_inserter {
316 c_.push_back(digi.
adc());
319 ADC_back_inserter&
operator*() {
return *
this; }
320 ADC_back_inserter&
operator++() {
return *
this; }
321 ADC_back_inserter&
operator++(
int) {
return *
this; }
334 COUT <<
"filling " << idet << std::endl;
336 auto const& det =
clusterizer.stripByStripBegin(idet);
372 buffer->setLegacyMode(legacy_);
375 const uint8_t fedCh =
conn->fedCh();
379 std::ostringstream
ss;
380 ss <<
"Problem unpacking channel " << fedCh <<
" on FED " <<
fedId;
387 uint16_t ipair =
conn->apvPairNumber();
397 const uint8_t pCode = (isNonLite ?
buffer->packetCode(legacy_, fedCh) : 0);
399 if LIKELY (!hybridZeroSuppressed_) {
401 buffer->channel(fedCh), perStripAdder, ipair * 256, isNonLite,
mode, legacy_, lmode, pCode);
403 const uint32_t
id =
conn->detId();
407 buffer->channel(fedCh), std::back_inserter(unpDigis), ipair * 256, isNonLite,
mode, legacy_, lmode, pCode);
410 rawAlgos.suppressHybridData(unpDigis, suppDigis, ipair * 2);
411 std::copy(std::begin(suppDigis), std::end(suppDigis), perStripAdder);
416 <<
"Unordered clusters for channel " << fedCh <<
" on FED " <<
fedId <<
": " <<
toString(st_ch);
422 std::vector<int16_t> digis;
424 buffer->channel(fedCh), ADC_back_inserter(digis),
buffer->channel(fedCh).packetCode());
427 uint32_t
id =
conn->detId();
432 uint16_t firstAPV = ipair * 2;
433 rawAlgos.suppressVirginRawData(
id, firstAPV, digis, zsdigis);
434 for (
const auto digi : zsdigis) {
439 std::vector<int16_t> digis;
443 uint32_t
id =
conn->detId();
447 uint16_t firstAPV = ipair * 2;
448 rawAlgos.suppressProcessedRawData(
id, firstAPV, digis, zsdigis);
455 <<
"[ClustersFromRawProducer::" << __func__ <<
"]" 456 <<
" FEDRawData readout mode " <<
mode <<
" from FED id " <<
fedId <<
" not supported.";
460 <<
"[ClustersFromRawProducer::" << __func__ <<
"]" <<
toString(st_ch) <<
" from FED id " <<
fedId 461 <<
" channel " << fedCh;
480 COUT <<
"filled " <<
record.size() << std::endl;
482 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
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
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