New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Hybrid Format SiStrip Zero Suppression algorithm for 2018 PbPb data-taking #24339
Changes from 27 commits
19e6887
8cad752
81ab34e
12deba3
3b54574
a213776
9ac9966
32adf9c
6a7a7ac
2c125b8
2057709
9ba51d0
3650798
9b73c2d
4c641a6
6501aed
8ab873e
7a84df3
d53e07e
e8c207a
1753f31
5b135ad
67722ab
a7e98be
602e0af
27321f1
b457689
afb9e1b
b861d8c
b78adcf
bdc86e4
5aa90a2
5a2736f
f27d767
851bf68
60467c6
da5639e
3a0e15e
68d2918
0f0ef27
7374274
b5d1fb8
fa2d9ab
0eaea27
1997ef7
5d63bc2
0fad6c9
e5fec55
8f18c3d
a41cd51
2d8d495
6216658
c5b1243
6005756
7da7570
6b256d8
5fa516e
bb5576e
b3821d1
97603e4
b462d55
bcf84c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,11 +108,13 @@ namespace { | |
ClusterFiller(const FEDRawDataCollection& irawColl, | ||
StripClusterizerAlgorithm & iclusterizer, | ||
SiStripRawProcessingAlgorithms & irawAlgos, | ||
bool idoAPVEmulatorCheck): | ||
bool idoAPVEmulatorCheck, | ||
bool hybridZeroSuppressed): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indentation is off |
||
rawColl(irawColl), | ||
clusterizer(iclusterizer), | ||
rawAlgos(irawAlgos), | ||
doAPVEmulatorCheck(idoAPVEmulatorCheck){ | ||
doAPVEmulatorCheck(idoAPVEmulatorCheck), | ||
hybridZeroSuppressed_(hybridZeroSuppressed){ | ||
incTot(clusterizer.allDetIds().size()); | ||
for (auto & d : done) d=nullptr; | ||
} | ||
|
@@ -137,6 +139,8 @@ namespace { | |
|
||
// March 2012: add flag for disabling APVe check in configuration | ||
bool doAPVEmulatorCheck; | ||
|
||
bool hybridZeroSuppressed_; | ||
|
||
|
||
#ifdef VIDEBUG | ||
|
@@ -192,7 +196,8 @@ class SiStripClusterizerFromRaw final : public edm::stream::EDProducer<> { | |
cabling_(nullptr), | ||
clusterizer_(StripClusterizerAlgorithmFactory::create(conf.getParameter<edm::ParameterSet>("Clusterizer"))), | ||
rawAlgos_(SiStripRawProcessingFactory::create(conf.getParameter<edm::ParameterSet>("Algorithms"))), | ||
doAPVEmulatorCheck_(conf.existsAs<bool>("DoAPVEmulatorCheck") ? conf.getParameter<bool>("DoAPVEmulatorCheck") : true) | ||
doAPVEmulatorCheck_(conf.existsAs<bool>("DoAPVEmulatorCheck") ? conf.getParameter<bool>("DoAPVEmulatorCheck") : true), | ||
hybridZeroSuppressed_(conf.getParameter<bool>("HybridZeroSuppressed")) | ||
{ | ||
productToken_ = consumes<FEDRawDataCollection>(conf.getParameter<edm::InputTag>("ProductLabel")); | ||
produces< edmNew::DetSetVector<SiStripCluster> > (); | ||
|
@@ -218,7 +223,7 @@ class SiStripClusterizerFromRaw final : public edm::stream::EDProducer<> { | |
std::unique_ptr< edmNew::DetSetVector<SiStripCluster> > | ||
output( onDemand ? | ||
new edmNew::DetSetVector<SiStripCluster>(std::shared_ptr<edmNew::DetSetVector<SiStripCluster>::Getter>(std::make_shared<ClusterFiller>(*rawData, *clusterizer_, | ||
*rawAlgos_, doAPVEmulatorCheck_) | ||
*rawAlgos_, doAPVEmulatorCheck_, hybridZeroSuppressed_) | ||
), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. some less pedantic indentation less strictly matching each opening brace may make this more readable by fitting the code in the screen width |
||
clusterizer_->allDetIds()) | ||
: new edmNew::DetSetVector<SiStripCluster>()); | ||
|
@@ -262,6 +267,7 @@ class SiStripClusterizerFromRaw final : public edm::stream::EDProducer<> { | |
// March 2012: add flag for disabling APVe check in configuration | ||
bool doAPVEmulatorCheck_; | ||
|
||
bool hybridZeroSuppressed_; | ||
}; | ||
|
||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
|
@@ -281,7 +287,7 @@ void SiStripClusterizerFromRaw::initialize(const edm::EventSetup& es) { | |
void SiStripClusterizerFromRaw::run(const FEDRawDataCollection& rawColl, | ||
edmNew::DetSetVector<SiStripCluster> & output) { | ||
|
||
ClusterFiller filler(rawColl, *clusterizer_, *rawAlgos_, doAPVEmulatorCheck_); | ||
ClusterFiller filler(rawColl, *clusterizer_, *rawAlgos_, doAPVEmulatorCheck_, hybridZeroSuppressed_); | ||
|
||
// loop over good det in cabling | ||
for ( auto idet : clusterizer_->allDetIds()) { | ||
|
@@ -295,6 +301,91 @@ void SiStripClusterizerFromRaw::run(const FEDRawDataCollection& rawColl, | |
} // end loop over dets | ||
} | ||
|
||
namespace { | ||
template<typename OUT> | ||
OUT unpackZS(const sistrip::FEDChannel& chan, sistrip::FEDReadoutMode mode, uint16_t stripOffset, OUT out) | ||
{ | ||
using namespace sistrip; | ||
switch ( mode ) { | ||
case READOUT_MODE_ZERO_SUPPRESSED_LITE8: | ||
case READOUT_MODE_ZERO_SUPPRESSED_LITE8_CMOVERRIDE: | ||
{ auto unpacker = FEDZSChannelUnpacker::zeroSuppressedLiteModeUnpacker(chan); | ||
while (unpacker.hasData()) { *out++ = SiStripDigi(stripOffset+unpacker.sampleNumber(), unpacker.adc()); unpacker++; } | ||
} break; | ||
case READOUT_MODE_ZERO_SUPPRESSED_LITE10: | ||
case READOUT_MODE_ZERO_SUPPRESSED_LITE10_CMOVERRIDE: | ||
{ auto unpacker = FEDBSChannelUnpacker::zeroSuppressedLiteModeUnpacker(chan, 10); | ||
while (unpacker.hasData()) { *out++ = SiStripDigi(stripOffset+unpacker.sampleNumber(), unpacker.adc()); unpacker++; } | ||
} break; | ||
case READOUT_MODE_ZERO_SUPPRESSED: | ||
case READOUT_MODE_ZERO_SUPPRESSED_FAKE: | ||
{ | ||
switch ( chan.packetCode() ) { | ||
case PACKET_CODE_ZERO_SUPPRESSED: | ||
{ auto unpacker = FEDZSChannelUnpacker::zeroSuppressedModeUnpacker(chan); | ||
while (unpacker.hasData()) { *out++ = SiStripDigi(stripOffset+unpacker.sampleNumber(), unpacker.adc()); unpacker++; } | ||
} break; | ||
case PACKET_CODE_ZERO_SUPPRESSED10: | ||
{ auto unpacker = FEDBSChannelUnpacker::zeroSuppressedModeUnpacker(chan, 10); | ||
while (unpacker.hasData()) { *out++ = SiStripDigi(stripOffset+unpacker.sampleNumber(), unpacker.adc()); unpacker++; } | ||
} break; | ||
case PACKET_CODE_ZERO_SUPPRESSED8_BOTBOT: | ||
{ auto unpacker = FEDBSChannelUnpacker::zeroSuppressedModeUnpacker(chan, 8); | ||
while (unpacker.hasData()) { *out++ = SiStripDigi(stripOffset+unpacker.sampleNumber(), unpacker.adc()<<2); unpacker++; } | ||
} break; | ||
case PACKET_CODE_ZERO_SUPPRESSED8_TOPBOT: | ||
{ auto unpacker = FEDBSChannelUnpacker::zeroSuppressedModeUnpacker(chan, 8); | ||
while (unpacker.hasData()) { *out++ = SiStripDigi(stripOffset+unpacker.sampleNumber(), unpacker.adc()<<1); unpacker++; } | ||
} break; | ||
default: | ||
edm::LogWarning(mlRawToCluster_) << "[ClustersFromRawProducer::" << __func__ << "]" | ||
<< " invalid packet code " << chan.packetCode() << " for zero-suppressed."; | ||
} | ||
} break; | ||
case READOUT_MODE_ZERO_SUPPRESSED_LITE8_TOPBOT: | ||
case READOUT_MODE_ZERO_SUPPRESSED_LITE8_TOPBOT_CMOVERRIDE: | ||
{ auto unpacker = FEDZSChannelUnpacker::zeroSuppressedLiteModeUnpacker(chan); | ||
while (unpacker.hasData()) { *out++ = SiStripDigi(stripOffset+unpacker.sampleNumber(), unpacker.adc()<<1); unpacker++; } | ||
} break; | ||
case READOUT_MODE_ZERO_SUPPRESSED_LITE8_BOTBOT: | ||
case READOUT_MODE_ZERO_SUPPRESSED_LITE8_BOTBOT_CMOVERRIDE: | ||
{ auto unpacker = FEDZSChannelUnpacker::zeroSuppressedLiteModeUnpacker(chan); | ||
while (unpacker.hasData()) { *out++ = SiStripDigi(stripOffset+unpacker.sampleNumber(), unpacker.adc()<<2); unpacker++; } | ||
} break; | ||
default:; | ||
} | ||
return out; | ||
} | ||
|
||
class StripByStripAdder { | ||
public: | ||
typedef std::output_iterator_tag iterator_category; | ||
typedef void value_type; | ||
typedef void difference_type; | ||
typedef void pointer; | ||
typedef void reference; | ||
|
||
StripByStripAdder(StripClusterizerAlgorithm& clusterizer, | ||
StripClusterizerAlgorithm::State& state, | ||
StripClusterizerAlgorithm::output_t::TSFastFiller& record) | ||
: clusterizer_(clusterizer), state_(state), record_(record) {} | ||
|
||
StripByStripAdder& operator= ( SiStripDigi digi ) | ||
{ | ||
clusterizer_.stripByStripAdd(state_, digi.strip(), digi.adc(), record_); | ||
return *this; | ||
} | ||
|
||
StripByStripAdder& operator* () { return *this; } | ||
StripByStripAdder& operator++ () { return *this; } | ||
StripByStripAdder& operator++ (int) { return *this; } | ||
private: | ||
StripClusterizerAlgorithm& clusterizer_; | ||
StripClusterizerAlgorithm::State& state_; | ||
StripClusterizerAlgorithm::output_t::TSFastFiller& record_; | ||
}; | ||
} | ||
|
||
void ClusterFiller::fill(StripClusterizerAlgorithm::output_t::TSFastFiller & record) { | ||
try { // edmNew::CapacityExaustedException | ||
incReady(); | ||
|
@@ -347,118 +438,98 @@ try { // edmNew::CapacityExaustedException | |
|
||
|
||
const sistrip::FEDReadoutMode mode = buffer->readoutMode(); | ||
|
||
|
||
if LIKELY(mode == sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE10 || mode == sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8) { | ||
|
||
try { | ||
// create unpacker | ||
sistrip::FEDZSChannelUnpacker unpacker = sistrip::FEDZSChannelUnpacker::zeroSuppressedLiteModeUnpacker(buffer->channel(fedCh)); | ||
|
||
// unpack | ||
clusterizer.addFed(state,unpacker,ipair,record); | ||
/* | ||
while (unpacker.hasData()) { | ||
clusterizer.stripByStripAdd(unpacker.sampleNumber()+ipair*256,unpacker.adc(),record); | ||
unpacker++; | ||
} | ||
*/ | ||
} catch (edmNew::CapacityExaustedException const&) { | ||
throw; | ||
} catch (const cms::Exception& e) { | ||
if (edm::isDebugEnabled()) { | ||
std::ostringstream ss; | ||
ss << "Unordered clusters for channel " << fedCh << " on FED " << fedId << ": " << e.what(); | ||
edm::LogWarning(sistrip::mlRawToCluster_) << ss.str(); | ||
} | ||
continue; | ||
} | ||
} else { | ||
|
||
if (mode == sistrip::READOUT_MODE_ZERO_SUPPRESSED || mode == sistrip::READOUT_MODE_ZERO_SUPPRESSED_FAKE ) { | ||
try { | ||
// create unpacker | ||
sistrip::FEDZSChannelUnpacker unpacker = sistrip::FEDZSChannelUnpacker::zeroSuppressedModeUnpacker(buffer->channel(fedCh)); | ||
|
||
// unpack | ||
clusterizer.addFed(state,unpacker,ipair,record); | ||
/* | ||
while (unpacker.hasData()) { | ||
clusterizer.stripByStripAdd(unpacker.sampleNumber()+ipair*256,unpacker.adc(),record); | ||
unpacker++; | ||
} | ||
*/ | ||
} catch (edmNew::CapacityExaustedException const&) { | ||
throw; | ||
}catch (const cms::Exception& e) { | ||
if (edm::isDebugEnabled()) { | ||
std::ostringstream ss; | ||
ss << "Unordered clusters for channel " << fedCh << " on FED " << fedId << ": " << e.what(); | ||
edm::LogWarning(sistrip::mlRawToCluster_) << ss.str(); | ||
} | ||
continue; | ||
} | ||
} else if (mode == sistrip::READOUT_MODE_VIRGIN_RAW ) { | ||
|
||
// create unpacker | ||
sistrip::FEDRawChannelUnpacker unpacker = sistrip::FEDRawChannelUnpacker::virginRawModeUnpacker(buffer->channel(fedCh)); | ||
|
||
// unpack | ||
std::vector<int16_t> digis; | ||
while (unpacker.hasData()) { | ||
digis.push_back(unpacker.adc()); | ||
unpacker++; | ||
} | ||
|
||
//process raw | ||
uint32_t id = conn->detId(); | ||
edm::DetSet<SiStripDigi> zsdigis(id); | ||
//rawAlgos_->subtractorPed->subtract( id, ipair*256, digis); | ||
//rawAlgos_->subtractorCMN->subtract( id, digis); | ||
//rawAlgos_->suppressor->suppress( digis, zsdigis); | ||
uint16_t firstAPV = ipair*2; | ||
rawAlgos.SuppressVirginRawData(id, firstAPV,digis, zsdigis); | ||
for( edm::DetSet<SiStripDigi>::const_iterator it = zsdigis.begin(); it!=zsdigis.end(); it++) { | ||
clusterizer.stripByStripAdd(state, it->strip(), it->adc(), record); | ||
} | ||
|
||
if LIKELY( ( mode > sistrip::READOUT_MODE_VIRGIN_RAW ) && ( mode < sistrip::READOUT_MODE_SPY ) && ( mode != sistrip::READOUT_MODE_PROC_RAW ) ) { | ||
// ZS modes | ||
try { | ||
auto perStripAdder = StripByStripAdder(clusterizer, state, record); | ||
if LIKELY( ! hybridZeroSuppressed_ ) { | ||
unpackZS(buffer->channel(fedCh), mode, ipair*256, perStripAdder); | ||
} else { | ||
const uint32_t id = conn->detId(); | ||
edm::DetSet<SiStripDigi> unpDigis{id}; unpDigis.reserve(256); | ||
unpackZS(buffer->channel(fedCh), mode, ipair*256, std::back_inserter(unpDigis)); | ||
SiStripRawProcessingAlgorithms::digivector_t workRawDigis; | ||
rawAlgos.ConvertHybridDigiToRawDigiVector(unpDigis, workRawDigis); | ||
edm::DetSet<SiStripDigi> suppDigis{id}; | ||
rawAlgos.SuppressHybridData(id, ipair*2, workRawDigis, suppDigis); | ||
std::copy(std::begin(suppDigis), std::end(suppDigis), perStripAdder); | ||
} | ||
} catch (edmNew::CapacityExaustedException) { | ||
throw; | ||
} catch (const cms::Exception& e) { | ||
if (edm::isDebugEnabled()) { | ||
edm::LogWarning(sistrip::mlRawToCluster_) << "Unordered clusters for channel " << fedCh << " on FED " << fedId << ": " << e.what(); | ||
} | ||
continue; | ||
} | ||
|
||
else if (mode == sistrip::READOUT_MODE_PROC_RAW ) { | ||
|
||
// create unpacker | ||
sistrip::FEDRawChannelUnpacker unpacker = sistrip::FEDRawChannelUnpacker::procRawModeUnpacker(buffer->channel(fedCh)); | ||
|
||
// unpack | ||
std::vector<int16_t> digis; | ||
while (unpacker.hasData()) { | ||
digis.push_back(unpacker.adc()); | ||
unpacker++; | ||
} | ||
|
||
//process raw | ||
uint32_t id = conn->detId(); | ||
edm::DetSet<SiStripDigi> zsdigis(id); | ||
//rawAlgos_->subtractorCMN->subtract( id, digis); | ||
//rawAlgos_->suppressor->suppress( digis, zsdigis); | ||
uint16_t firstAPV = ipair*2; | ||
rawAlgos.SuppressProcessedRawData(id, firstAPV,digis, zsdigis); | ||
for( edm::DetSet<SiStripDigi>::const_iterator it = zsdigis.begin(); it!=zsdigis.end(); it++) { | ||
clusterizer.stripByStripAdd(state, it->strip(), it->adc(), record); | ||
} | ||
} else { | ||
edm::LogWarning(sistrip::mlRawToCluster_) | ||
<< "[ClustersFromRawProducer::" | ||
<< __func__ << "]" | ||
<< " FEDRawData readout mode " | ||
<< mode | ||
<< " from FED id " | ||
<< fedId | ||
<< " not supported."; | ||
continue; | ||
|
||
} else if ( mode == sistrip::READOUT_MODE_VIRGIN_RAW ) { | ||
|
||
std::vector<int16_t> digis; | ||
switch ( buffer->channel(fedCh).packetCode() ) { | ||
case sistrip::PACKET_CODE_VIRGIN_RAW: | ||
{ auto unpacker = sistrip::FEDRawChannelUnpacker::virginRawModeUnpacker(buffer->channel(fedCh)); | ||
while (unpacker.hasData()) { digis.push_back(unpacker.adc()); unpacker++; } | ||
} break; | ||
case sistrip::PACKET_CODE_VIRGIN_RAW10: | ||
{ auto unpacker = sistrip::FEDBSChannelUnpacker::virginRawModeUnpacker(buffer->channel(fedCh), 10); | ||
while (unpacker.hasData()) { digis.push_back(unpacker.adc()); unpacker++; } | ||
} break; | ||
case sistrip::PACKET_CODE_VIRGIN_RAW8_BOTBOT: | ||
{ auto unpacker = sistrip::FEDBSChannelUnpacker::virginRawModeUnpacker(buffer->channel(fedCh), 8); | ||
while (unpacker.hasData()) { digis.push_back(unpacker.adc()<<2); unpacker++; } | ||
} break; | ||
case sistrip::PACKET_CODE_VIRGIN_RAW8_TOPBOT: | ||
{ auto unpacker = sistrip::FEDBSChannelUnpacker::virginRawModeUnpacker(buffer->channel(fedCh), 8); | ||
while (unpacker.hasData()) { digis.push_back(unpacker.adc()<<1); unpacker++; } | ||
} break; | ||
default: | ||
edm::LogWarning(sistrip::mlRawToCluster_) << "[ClustersFromRawProducer::" << __func__ << "]" | ||
<< " invalid packet code " << buffer->channel(fedCh).packetCode() << " for virgin raw."; | ||
} | ||
//process raw | ||
uint32_t id = conn->detId(); | ||
edm::DetSet<SiStripDigi> zsdigis(id); | ||
//rawAlgos_->subtractorPed->subtract( id, ipair*256, digis); | ||
//rawAlgos_->subtractorCMN->subtract( id, digis); | ||
//rawAlgos_->suppressor->suppress( digis, zsdigis); | ||
uint16_t firstAPV = ipair*2; | ||
rawAlgos.SuppressVirginRawData(id, firstAPV,digis, zsdigis); | ||
for ( const auto digi : zsdigis ) { | ||
clusterizer.stripByStripAdd(state, digi.strip(), digi.adc(), record); | ||
} | ||
|
||
} else if ( mode == sistrip::READOUT_MODE_PROC_RAW ) { | ||
|
||
// create unpacker | ||
sistrip::FEDRawChannelUnpacker unpacker = sistrip::FEDRawChannelUnpacker::procRawModeUnpacker(buffer->channel(fedCh)); | ||
|
||
// unpack | ||
std::vector<int16_t> digis; | ||
while (unpacker.hasData()) { | ||
digis.push_back(unpacker.adc()); | ||
unpacker++; | ||
} | ||
|
||
//process raw | ||
uint32_t id = conn->detId(); | ||
edm::DetSet<SiStripDigi> zsdigis(id); | ||
//rawAlgos_->subtractorCMN->subtract( id, digis); | ||
//rawAlgos_->suppressor->suppress( digis, zsdigis); | ||
uint16_t firstAPV = ipair*2; | ||
rawAlgos.SuppressProcessedRawData(id, firstAPV,digis, zsdigis); | ||
for( edm::DetSet<SiStripDigi>::const_iterator it = zsdigis.begin(); it!=zsdigis.end(); it++) { | ||
clusterizer.stripByStripAdd(state, it->strip(), it->adc(), record); | ||
} | ||
} else { | ||
edm::LogWarning(sistrip::mlRawToCluster_) | ||
<< "[ClustersFromRawProducer::" << __func__ << "]" | ||
<< " FEDRawData readout mode " << mode << " from FED id " << fedId << " not supported."; | ||
continue; | ||
} | ||
|
||
} // end loop over conn | ||
|
||
clusterizer.stripByStripEnd(state,record); | ||
|
||
incAct(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the above the setting which reproduces the old behaviour?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, you need to call this custom function - see at the end of the file:
process = customiseForPR24339HybridFormatSiStripZS(process)