Skip to content
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

New FED modes handled in SiStrip unpacker #12157

Merged
merged 38 commits into from
Nov 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ed059d6
adding CMoverride modes
amagnan Apr 20, 2015
75db606
Merge branch 'import-amagnan' into HEAD
forthommel May 6, 2015
0ef27d2
New SiStrip FED modes added to be used by the unpacker ; now need to …
forthommel May 23, 2015
1e6e1ad
Forgot to add new FED modes into the data length definition for the F…
forthommel May 23, 2015
22472ee
Removed all data type (real/fake) references in the SiStrip component…
forthommel May 23, 2015
d9abb1e
Finally introduced the masking to extract the FED mode from digis
forthommel May 23, 2015
f179fd8
Proper implementation of the changes
forthommel Jun 19, 2015
7d3e3b9
Merged CMSTRACK127_unpacker from repository forthommel
quertenmont Jun 24, 2015
0523828
fix readout mode name
quertenmont Jun 24, 2015
db54583
add READOUT_MODE_ZERO_SUPPRESSED to the get8BitSample
quertenmont Jun 26, 2015
e9dd0ff
Merged CMSTRACK127_unpackerFix from repository quertenmont
quertenmont Jun 30, 2015
07bab0c
fix SiStripFEDBufferComponents for 8Bit topbot readout mode
quertenmont Jun 30, 2015
62598b3
add new mode
quertenmont Jul 1, 2015
dab7238
Merge pull request #1 from quertenmont/CMSTRACK127_unpackerFix
Jul 2, 2015
998fa82
Forgot to add a file...
forthommel Aug 27, 2015
2503b29
Preparing to move to 760
forthommel Sep 29, 2015
e85e227
Snapshot before starting any test with FED packed data
forthommel Oct 16, 2015
f69c1a5
Merge branch 'CMSTRACK127_unpacker' of https://github.com/forthommel/…
forthommel Oct 16, 2015
3c5048e
Added the ZS mode to this BS unpacker
forthommel Oct 16, 2015
2713c92
Added consumes
forthommel Oct 21, 2015
7f2a0e3
Reorganization of VR10-8 modes
forthommel Oct 22, 2015
4b24bb4
Reordering the classes ; added a new exception for invalid BS word le…
forthommel Oct 22, 2015
4cff28c
Simplification of BS unpackers
forthommel Oct 22, 2015
aa26533
Added legacy unpacking capability
forthommel Oct 23, 2015
b8095ce
Fixed the legacy mode ; simplified the data formats
forthommel Oct 23, 2015
951ab16
Masking the BS adc value to retain the actual number of bits to unpack
forthommel Oct 23, 2015
87cfea7
Improvement of the legacy unpacking part
forthommel Oct 23, 2015
9e2ebea
Default unpacker is now legacy
forthommel Oct 26, 2015
22780a3
Removing CalibTracker/Configuration from modified packages for this PR
forthommel Oct 26, 2015
686c6e8
Still some polishing before the PR
forthommel Oct 26, 2015
02cb2c3
Forgot to check the legacy state once retrieving the fed key and the …
forthommel Oct 26, 2015
02c875d
Introduced the bits shifting for ZS8 modes
forthommel Oct 27, 2015
2ecceb0
New readout modes retrieval is the default behaviour
forthommel Oct 27, 2015
73be72d
Fixed the bug preventing the updated unpacker to run on ZS lite mode
forthommel Oct 29, 2015
eb39cf2
Switching from size_t to uint16_t in the FEDBuffer construction
forthommel Nov 4, 2015
4b1f188
Moved READOUT_MODE_ZERO_SUPPRESSED_LITE8_BOTBOT_CMOVERRIDE to 0xD, an…
forthommel Nov 6, 2015
c72f60e
Added the legacy ZS fake mode into the ClustersFromRawProducer ; fill…
forthommel Nov 8, 2015
88a7214
Implemented @abaty's recipe ; looks like 140.53 is finally working
forthommel Nov 9, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 30 additions & 14 deletions DataFormats/SiStripCommon/interface/ConstantsForHardwareSystems.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,27 @@ namespace sistrip {
static const char unknownApvReadoutMode_[] = "UnknownApvReadoutMode";
static const char undefinedApvReadoutMode_[] = "UndefinedApvReadoutMode";

static const char apvPeakMode_[] = "ApvPeakMode";
static const char apvPeakMode_[] = "ApvPeakMode";
static const char apvDeconMode_[] = "ApvDeconMode";
static const char apvMultiMode_[] = "ApvMultiMode";

static const char unknownFedReadoutMode_[] = "UnknownFedReadoutMode";
static const char undefinedFedReadoutMode_[] = "UndefinedFedReadoutMode";

static const char fedScopeMode_[] = "FedScopeMode";
static const char fedVirginRaw_[] = "FedVirginRaw";
static const char fedProcRaw_[] = "FedProcessedRaw";
static const char fedZeroSuppr_[] = "FedZeroSuppressed";
static const char fedZeroSupprLite_[] = "FedZeroSupprressedLite";
static const char fedPreMixRaw_[] = "FedPreMixRaw";
static const char fedScopeMode_[] = "FedScopeMode";
static const char fedVirginRaw_[] = "FedVirginRaw";
static const char fedProcRaw_[] = "FedProcessedRaw";
static const char fedZeroSuppr_[] = "FedZeroSuppressed";
static const char fedZeroSupprCMO_[] = "FedZeroSuppressedCMOverride";
static const char fedZeroSupprLite_[] = "FedZeroSupprressedLite";
static const char fedZeroSupprLiteCMO_[] = "FedZeroSuppressedLiteCMOverride";
static const char fedZeroSupprLite8TT_[] = "FedZeroSuppressedLite8TT";
static const char fedZeroSupprLite8TTCMO_[] = "FedZeroSuppressedLite8TTCMOverride";
static const char fedZeroSupprLite8TB_[] = "FedZeroSuppressedLite8TB";
static const char fedZeroSupprLite8TBCMO_[] = "FedZeroSuppressedLite8TBCMOverride";
static const char fedZeroSupprLite8BB_[] = "FedZeroSuppressedLite8BB";
static const char fedZeroSupprLite8BBCMO_[] = "FedZeroSuppressedLite8BBCMOverride";
static const char fedPreMixRaw_[] = "FedPreMixRaw";

// -------------------- Enumerators --------------------

Expand All @@ -119,13 +127,21 @@ namespace sistrip {
};

enum FedReadoutMode { UNKNOWN_FED_READOUT_MODE = sistrip::unknown_,
UNDEFINED_FED_READOUT_MODE = sistrip::invalid_,
FED_SCOPE_MODE = 1,
FED_VIRGIN_RAW = 2,
FED_PROC_RAW = 6,
FED_ZERO_SUPPR = 10,
FED_ZERO_SUPPR_LITE = 12,
FED_PREMIX_RAW = 15
UNDEFINED_FED_READOUT_MODE = sistrip::invalid_,
FED_SCOPE_MODE = 1,
FED_VIRGIN_RAW = 2,
FED_PROC_RAW = 6,
FED_ZERO_SUPPR = 10,
//FED_ZERO_SUPPR_CMO = 4,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please cleanup commented out code

FED_ZERO_SUPPR_LITE = 3,
FED_ZERO_SUPPR_LITE_CMO = 4,
FED_ZERO_SUPPR_LITE8_TT = 12,
FED_ZERO_SUPPR_LITE8_TT_CMO = 8,
FED_ZERO_SUPPR_LITE8_TB = 5,
FED_ZERO_SUPPR_LITE8_TB_CMO = 7,
FED_ZERO_SUPPR_LITE8_BB = 9,
FED_ZERO_SUPPR_LITE8_BB_CMO = 11,
FED_PREMIX_RAW = 15
};

enum FedReadoutPath { UNKNOWN_FED_READOUT_PATH = sistrip::unknown_,
Expand Down
14 changes: 14 additions & 0 deletions DataFormats/SiStripCommon/src/SiStripEnumsAndStrings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,13 @@ std::string SiStripEnumsAndStrings::fedReadoutMode( const sistrip::FedReadoutMod
else if ( mode == sistrip::FED_PROC_RAW ) { return sistrip::fedProcRaw_; }
else if ( mode == sistrip::FED_ZERO_SUPPR ) { return sistrip::fedZeroSuppr_; }
else if ( mode == sistrip::FED_ZERO_SUPPR_LITE ) { return sistrip::fedZeroSupprLite_; }
else if ( mode == sistrip::FED_ZERO_SUPPR_LITE_CMO ) { return sistrip::fedZeroSupprLiteCMO_; }
else if ( mode == sistrip::FED_ZERO_SUPPR_LITE8_TT ) { return sistrip::fedZeroSupprLite8TT_; }
else if ( mode == sistrip::FED_ZERO_SUPPR_LITE8_TT_CMO ) { return sistrip::fedZeroSupprLite8TTCMO_; }
else if ( mode == sistrip::FED_ZERO_SUPPR_LITE8_TB ) { return sistrip::fedZeroSupprLite8TB_; }
else if ( mode == sistrip::FED_ZERO_SUPPR_LITE8_TB_CMO ) { return sistrip::fedZeroSupprLite8TBCMO_; }
else if ( mode == sistrip::FED_ZERO_SUPPR_LITE8_BB ) { return sistrip::fedZeroSupprLite8BB_; }
else if ( mode == sistrip::FED_ZERO_SUPPR_LITE8_BB_CMO ) { return sistrip::fedZeroSupprLite8BBCMO_; }
else if ( mode == sistrip::UNDEFINED_FED_READOUT_MODE ) { return sistrip::undefinedFedReadoutMode_; }
else { return sistrip::unknownFedReadoutMode_; }
}
Expand All @@ -264,6 +271,13 @@ sistrip::FedReadoutMode SiStripEnumsAndStrings::fedReadoutMode( const std::strin
else if ( mode.find( sistrip::fedProcRaw_ ) != std::string::npos ) { return sistrip::FED_PROC_RAW; }
else if ( mode.find( sistrip::fedZeroSuppr_ ) != std::string::npos ) { return sistrip::FED_ZERO_SUPPR; }
else if ( mode.find( sistrip::fedZeroSupprLite_ ) != std::string::npos ) { return sistrip::FED_ZERO_SUPPR_LITE; }
else if ( mode.find( sistrip::fedZeroSupprLiteCMO_ ) != std::string::npos ) { return sistrip::FED_ZERO_SUPPR_LITE_CMO; }
else if ( mode.find( sistrip::fedZeroSupprLite8TT_ ) != std::string::npos ) { return sistrip::FED_ZERO_SUPPR_LITE8_TT; }
else if ( mode.find( sistrip::fedZeroSupprLite8TTCMO_ ) != std::string::npos ) { return sistrip::FED_ZERO_SUPPR_LITE8_TT_CMO; }
else if ( mode.find( sistrip::fedZeroSupprLite8TB_ ) != std::string::npos ) { return sistrip::FED_ZERO_SUPPR_LITE8_TB; }
else if ( mode.find( sistrip::fedZeroSupprLite8TBCMO_ ) != std::string::npos ) { return sistrip::FED_ZERO_SUPPR_LITE8_TB_CMO; }
else if ( mode.find( sistrip::fedZeroSupprLite8BB_ ) != std::string::npos ) { return sistrip::FED_ZERO_SUPPR_LITE8_BB; }
else if ( mode.find( sistrip::fedZeroSupprLite8BBCMO_ ) != std::string::npos ) { return sistrip::FED_ZERO_SUPPR_LITE8_BB_CMO; }
else if ( mode.find( sistrip::undefinedFedReadoutMode_ ) != std::string::npos ) { return sistrip::UNDEFINED_FED_READOUT_MODE; }
else if ( mode.empty() ) { return sistrip::UNDEFINED_FED_READOUT_MODE; }
else { return sistrip::UNKNOWN_FED_READOUT_MODE; }
Expand Down
153 changes: 146 additions & 7 deletions EventFilter/SiStripRawToDigi/interface/SiStripFEDBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <memory>
#include <ostream>
#include <cstring>
#include <cmath>
#include "EventFilter/SiStripRawToDigi/interface/SiStripFEDBufferComponents.h"

#include "FWCore/Utilities/interface/GCC11Compatibility.h"
Expand All @@ -23,7 +24,7 @@ namespace sistrip {
public:
//construct from buffer
//if allowBadBuffer is set to true then exceptions will not be thrown if the channel lengths do not make sense or the event format is not recognized
FEDBuffer(const uint8_t* fedBuffer, const size_t fedBufferSize, const bool allowBadBuffer = false);
FEDBuffer(const uint8_t* fedBuffer, const uint16_t fedBufferSize, const bool allowBadBuffer = false);
virtual ~FEDBuffer();
virtual void print(std::ostream& os) const;
const FEDFEHeader* feHeader() const;
Expand All @@ -36,6 +37,7 @@ namespace sistrip {
bool fePresent(uint8_t internalFEUnitNum) const;
//check that a channel is present in data, found, on a good FE unit and has no errors flagged in status bits
virtual bool channelGood(const uint8_t internalFEDannelNum, const bool doAPVeCheck=true) const;
void setLegacyMode(bool legacy) { legacyUnpacker_ = legacy;}

//functions to check buffer. All return true if there is no problem.
//minimum checks to do before using buffer
Expand Down Expand Up @@ -70,13 +72,14 @@ namespace sistrip {
private:
uint8_t nFEUnitsPresent() const;
void findChannels();
uint8_t getCorrectPacketCode() const;
inline uint8_t getCorrectPacketCode() const { return packetCode(legacyUnpacker_); }
uint16_t calculateFEUnitLength(const uint8_t internalFEUnitNumber) const;
std::auto_ptr<FEDFEHeader> feHeader_;
const uint8_t* payloadPointer_;
uint16_t payloadLength_;
uint8_t validChannels_;
bool fePresent_[FEUNITS_PER_FED];
bool legacyUnpacker_;
};

//class for unpacking data from ZS FED channels
Expand All @@ -95,14 +98,14 @@ namespace sistrip {
FEDZSChannelUnpacker& operator ++ (int);
private:
//pointer to beginning of FED or FE data, offset of start of channel payload in data and length of channel payload
FEDZSChannelUnpacker(const uint8_t* payload, const size_t channelPayloadOffset, const int16_t channelPayloadLength, const size_t offsetIncrement=1);
FEDZSChannelUnpacker(const uint8_t* payload, const uint16_t channelPayloadOffset, const int16_t channelPayloadLength, const uint16_t offsetIncrement=1);
void readNewClusterInfo();
static void throwBadChannelLength(const uint16_t length);
void throwBadClusterLength();
static void throwUnorderedData(const uint8_t currentStrip, const uint8_t firstStripOfNewCluster);
const uint8_t* data_;
size_t currentOffset_;
size_t offsetIncrement_;
uint16_t currentOffset_;
uint16_t offsetIncrement_;
uint8_t currentStrip_;
uint8_t valuesLeftInCluster_;
uint16_t channelPayloadOffset_;
Expand All @@ -125,11 +128,44 @@ namespace sistrip {
private:
static void throwBadChannelLength(const uint16_t length);
const uint8_t* data_;
size_t currentOffset_;
uint16_t currentOffset_;
uint8_t currentStrip_;
uint16_t valuesLeft_;
};

//class for unpacking data from any FED channels with a non-integer words bits stripping mode
class FEDBSChannelUnpacker
{
public:
static FEDBSChannelUnpacker virginRawModeUnpacker(const FEDChannel& channel, uint16_t num_bits);
static FEDBSChannelUnpacker zeroSuppressedModeUnpacker(const FEDChannel& channel, uint16_t num_bits);
static FEDBSChannelUnpacker zeroSuppressedLiteModeUnpacker(const FEDChannel& channel, uint16_t num_bits);
FEDBSChannelUnpacker();
uint8_t sampleNumber() const;
uint16_t adc() const;
bool hasData() const;
FEDBSChannelUnpacker& operator ++ ();
FEDBSChannelUnpacker& operator ++ (int);
private:
//pointer to beginning of FED or FE data, offset of start of channel payload in data and length of channel payload
FEDBSChannelUnpacker(const uint8_t* payload, const uint16_t channelPayloadOffset, const int16_t channelPayloadLength, const uint16_t offsetIncrement, bool useZS);
void readNewClusterInfo();
static void throwBadChannelLength(const uint16_t length);
static void throwBadWordLength(const uint16_t word_length);
static void throwUnorderedData(const uint8_t currentStrip, const uint8_t firstStripOfNewCluster);
const uint8_t* data_;
uint16_t oldWordOffset_;
uint16_t currentWordOffset_;
uint16_t currentBitOffset_;
uint16_t currentLocalBitOffset_;
uint16_t bitOffsetIncrement_;
uint8_t currentStrip_;
uint16_t channelPayloadOffset_;
uint16_t channelPayloadLength_;
bool useZS_;
uint8_t valuesLeftInCluster_;
};

//
// Inline function definitions
//
Expand Down Expand Up @@ -165,6 +201,109 @@ namespace sistrip {
{
return checkStatusBits(internalFEDChannelNum(internalFEUnitNum,internalChannelNum));
}

//FEDBSChannelUnpacker

inline FEDBSChannelUnpacker::FEDBSChannelUnpacker()
: data_(NULL),
oldWordOffset_(0), currentWordOffset_(0),
currentBitOffset_(0), currentLocalBitOffset_(0),
bitOffsetIncrement_(10),
currentStrip_(0),
channelPayloadOffset_(0), channelPayloadLength_(0),
useZS_(false), valuesLeftInCluster_(0)
{ }

inline FEDBSChannelUnpacker::FEDBSChannelUnpacker(const uint8_t* payload, const uint16_t channelPayloadOffset, const int16_t channelPayloadLength, const uint16_t offsetIncrement, bool useZS)
: data_(payload),
oldWordOffset_(0), currentWordOffset_(channelPayloadOffset),
currentBitOffset_(0), currentLocalBitOffset_(0),
bitOffsetIncrement_(offsetIncrement),
channelPayloadOffset_(channelPayloadOffset),
channelPayloadLength_(channelPayloadLength),
useZS_(useZS), valuesLeftInCluster_(0)
{
if (bitOffsetIncrement_>16) throwBadWordLength(bitOffsetIncrement_); // more than 2 words... still to be implemented
}

inline FEDBSChannelUnpacker FEDBSChannelUnpacker::virginRawModeUnpacker(const FEDChannel& channel, uint16_t num_bits)
{
uint16_t length = channel.length();
if (length & 0xF000) throwBadChannelLength(length);
if (num_bits<=0 or num_bits>16) throwBadWordLength(num_bits);
FEDBSChannelUnpacker result(channel.data(), channel.offset()+3, length-3, num_bits, false);
return result;
}

inline FEDBSChannelUnpacker FEDBSChannelUnpacker::zeroSuppressedModeUnpacker(const FEDChannel& channel, uint16_t num_bits)
{
uint16_t length = channel.length();
if (length & 0xF000) throwBadChannelLength(length);
FEDBSChannelUnpacker result(channel.data(), channel.offset()+7, length-7, num_bits, true);
return result;
}

inline FEDBSChannelUnpacker FEDBSChannelUnpacker::zeroSuppressedLiteModeUnpacker(const FEDChannel& channel, uint16_t num_bits)
{
uint16_t length = channel.length();
if (length & 0xF000) throwBadChannelLength(length);
FEDBSChannelUnpacker result(channel.data(), channel.offset()+2, length-2, num_bits, true);
return result;
}

inline uint8_t FEDBSChannelUnpacker::sampleNumber() const
{
return currentStrip_;
}

inline uint16_t FEDBSChannelUnpacker::adc() const
{
uint16_t bits_missing = (bitOffsetIncrement_-8)+currentLocalBitOffset_;
uint16_t adc = (data_[currentWordOffset_^7]<<bits_missing);
if (currentWordOffset_>oldWordOffset_) {
adc += ( (data_[(currentWordOffset_+1)^7]>>(8-bits_missing)) );
}
return (adc&((1<<bitOffsetIncrement_)-1));
}

inline bool FEDBSChannelUnpacker::hasData() const
{
return (currentWordOffset_<channelPayloadOffset_+channelPayloadLength_);
}

inline FEDBSChannelUnpacker& FEDBSChannelUnpacker::operator ++ ()
{
oldWordOffset_ = currentWordOffset_;
currentBitOffset_ += bitOffsetIncrement_;
currentLocalBitOffset_ += bitOffsetIncrement_;
while (currentLocalBitOffset_>=8) {
currentWordOffset_++;
currentLocalBitOffset_ -= 8;
}
if (useZS_) {
if (valuesLeftInCluster_) { currentStrip_++; valuesLeftInCluster_--; }
else {
if (hasData()) {
const uint8_t oldStrip = currentStrip_;
readNewClusterInfo();
if ( !(currentStrip_ > oldStrip) ) throwUnorderedData(oldStrip,currentStrip_);
}
}
} else { currentStrip_++; }
return (*this);
}

inline FEDBSChannelUnpacker& FEDBSChannelUnpacker::operator ++ (int)
{
++(*this); return *this;
}

inline void FEDBSChannelUnpacker::readNewClusterInfo()
{
currentStrip_ = data_[(currentWordOffset_++)^7];
valuesLeftInCluster_ = data_[(currentWordOffset_++)^7]-1;
}


//FEDRawChannelUnpacker

Expand Down Expand Up @@ -215,7 +354,7 @@ namespace sistrip {
channelPayloadLength_(0)
{ }

inline FEDZSChannelUnpacker::FEDZSChannelUnpacker(const uint8_t* payload, const size_t channelPayloadOffset, const int16_t channelPayloadLength, const size_t offsetIncrement)
inline FEDZSChannelUnpacker::FEDZSChannelUnpacker(const uint8_t* payload, const uint16_t channelPayloadOffset, const int16_t channelPayloadLength, const uint16_t offsetIncrement)
: data_(payload),
currentOffset_(channelPayloadOffset),
offsetIncrement_(offsetIncrement),
Expand Down