Skip to content

Commit

Permalink
Revert "Implement suggestions for CMSSW_14_1_X PR cms-sw#45665 (#137)"
Browse files Browse the repository at this point in the history
This reverts commit 7ea653e.
  • Loading branch information
pfs authored Aug 27, 2024
1 parent 7ea653e commit 0c0c0b2
Show file tree
Hide file tree
Showing 35 changed files with 891 additions and 204 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ namespace hgcalrechit {

// Generate structure of channel-level arrays (SoA) layout with RecHit dataformat
GENERATE_SOA_LAYOUT(HGCalCalibParamSoALayout,
//SOA_SCALAR(HGCalMappingModuleIndexer, map), // dense idx map: now redundant & NOT thread safe !?
SOA_COLUMN(float, ADC_ped), // ADC pedestals, O(91)
SOA_COLUMN(float, Noise), // noise, O(3)
SOA_COLUMN(float, CM_slope), // common mode slope, O(0.25)
SOA_COLUMN(float, CM_ped), // common mode pedestal (offset), O(92)
SOA_COLUMN(float, BXm1_slope), // leakage correction from previous bunch, O(0.0)
//SOA_COLUMN(float, BXm1_ped), // redundant
SOA_COLUMN(float, ADCtofC), // ADC conversion to charge (fC), depends on gain (80, 160, 320 fC)
SOA_COLUMN(float, TOTtofC), // TOT conversion to charge (fC), depends on gain (80, 160, 320 fC)
SOA_COLUMN(float, TOT_ped), // TOT pedestal (offset), O(9.0)
Expand All @@ -38,6 +40,7 @@ namespace hgcalrechit {

// Generate structure of ROC-level arrays (SoA) layout with RecHit dataformat
GENERATE_SOA_LAYOUT(HGCalConfigParamSoALayout,
//SOA_SCALAR(HGCalMappingModuleIndexer, map), // dense idx map: now redundant & NOT thread safe !?
SOA_COLUMN(uint8_t, gain) // for ADC to charge (fC) conversion (80, 160, 320 fC)
)
using HGCalConfigParamSoA = HGCalConfigParamSoALayout<>;
Expand Down
14 changes: 7 additions & 7 deletions CondFormats/HGCalObjects/interface/HGCalConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <vector>

// @short configuration for ECON eRX (one half of HGROC)
struct HGCalROCConfig {
struct HGCalROCConfig_t {
uint32_t charMode; // characterization mode; determines data fields in ROC dataframe
uint8_t gain; // pre-amp gain used (1: 80 fC, 2: 160 fC, 4: 320 fC)
//uint32_t clockPhase; // fine adjustment of the phase within the 40 MHz
Expand All @@ -19,32 +19,32 @@ struct HGCalROCConfig {
};

// @short configuration for ECON-D module
struct HGCalECONDConfig {
struct HGCalECONDConfig_t {
//std::string typecode;
uint32_t headerMarker; // begin of event marker/identifier for ECON-D
uint32_t passThrough; //pass through mode (this is just as check as it'll be in the ECON-D header anyway)
std::vector<HGCalROCConfig> rocs;
std::vector<HGCalROCConfig_t> rocs;
COND_SERIALIZABLE;
};

// @short configuration for FED
struct HGCalFedConfig {
struct HGCalFedConfig_t {
bool mismatchPassthroughMode; // ignore ECON-D packet mismatches
uint32_t cbHeaderMarker; // begin of event marker/identifier for capture block
uint32_t slinkHeaderMarker; // begin of event marker/identifier for S-link
//uint32_t delay; // delay
std::vector<HGCalECONDConfig> econds;
std::vector<HGCalECONDConfig_t> econds;
COND_SERIALIZABLE;
};

/**
* @short Main HGCal configuration with a tree structure of vectors of
* HGCalFedConfig/HGCalECONDConfig/HGCalROCConfig structs as follows:
* HGCalFedConfig_t/HGCalECONDConfig_t/HGCalROCConfig_t structs as follows:
% config.feds[dense_fed_idx].econds[dense_econd_idx].rocs[dense_eRx_idx]
**/
class HGCalConfiguration {
public:
std::vector<HGCalFedConfig> feds;
std::vector<HGCalFedConfig_t> feds;
//friend std::ostream& operator<< (std::ostream&, const HGCalConfiguration&);

private:
Expand Down
41 changes: 20 additions & 21 deletions CondFormats/HGCalObjects/interface/HGCalMappingModuleIndexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
#include <cstdint>
#include <vector>
#include <map>
#include <algorithm> // for std::min
#include <utility> // for std::pair, std::make_pair
#include <iterator> // for std::next and std::advance
#include <utility> // for std::pair, std::make_pair
#include <algorithm>

#include "DataFormats/HGCalDigi/interface/HGCalElectronicsId.h"
#include "CondFormats/Serialization/interface/Serializable.h"
Expand All @@ -20,7 +19,7 @@
as the 12 capture blocks may not all be used and the each capture block may also be under-utilized
a lookup table is used to hold the compact index
*/
struct HGCalFEDReadoutSequence {
struct HGCalFEDReadoutSequence_t {
uint32_t id;
///>look-up table (capture block, econd idx) -> internal dense index
std::vector<int> moduleLUT_;
Expand Down Expand Up @@ -58,7 +57,7 @@ class HGCalMappingModuleIndexer {
if (fedid >= fedReadoutSequences_.size()) {
fedReadoutSequences_.resize(fedid + 1);
}
HGCalFEDReadoutSequence& frs = fedReadoutSequences_[fedid];
HGCalFEDReadoutSequence_t& frs = fedReadoutSequences_[fedid];
frs.id = fedid;

//assign position, resize if needed, and fill the type code
Expand Down Expand Up @@ -233,22 +232,22 @@ class HGCalMappingModuleIndexer {
return getIndexForModuleData(fedid, modid, 0, 0);
};
std::pair<uint32_t, uint32_t> getIndexForFedAndModule(std::string const& typecode) const {
auto it = typecodeMap_.find(typecode);
if (it == typecodeMap_.end()) { // did not find key
std::size_t nmax = 100; // maximum number of keys to print
auto maxit = typecodeMap_.begin(); // limit printout to prevent gigantic print out
std::advance(maxit, std::min(typecodeMap_.size(), nmax));
std::string allkeys = std::accumulate(
std::next(typecodeMap_.begin()), maxit, typecodeMap_.begin()->first, [](const std::string& a, const auto& b) {
return a + ',' + b.first;
});
if (typecodeMap_.size() > nmax)
allkeys += ", ...";
throw cms::Exception("HGCalMappingModuleIndexer")
<< "Could not find typecode '" << typecode << "' in map (size=" << typecodeMap_.size()
<< ")! Found the following modules (from the module locator file): " << allkeys;
if (typecodeMap_.find(typecode) == typecodeMap_.end()) { // did not find key
edm::LogWarning("HGCalMappingModuleIndexer")
<< "Could not find typecode " << typecode << " in map (size=" << typecodeMap_.size()
<< ")! Found following modules:";
int i = 1;
for (auto it = typecodeMap_.begin(); it != typecodeMap_.end(); it++) {
std::cout << it->first << (it != typecodeMap_.end() ? ", " : "") << std::endl;
if (i <= 100) {
std::cout << " ..." << std::endl;
break;
} // stop sooner to avoid gigantic printout
i++;
}
//return {0,0};
}
return it->second; // (fedid,modid)
return typecodeMap_.at(typecode); // (fedid,modid)
};

/**
Expand Down Expand Up @@ -291,7 +290,7 @@ class HGCalMappingModuleIndexer {
///< internal indexer
HGCalDenseIndexerBase modFedIndexer_;
///< the sequence of FED readout sequence descriptors
std::vector<HGCalFEDReadoutSequence> fedReadoutSequences_;
std::vector<HGCalFEDReadoutSequence_t> fedReadoutSequences_;
///< global counters for types of modules, number of e-Rx and words
std::vector<uint32_t> globalTypesCounter_, globalTypesNErx_, globalTypesNWords_;
///< base offsets to apply per module type with different granularity : module, e-Rx, channel data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace hgcal {
SOA_COLUMN(int, plane),
SOA_COLUMN(int, i1),
SOA_COLUMN(int, i2),
SOA_COLUMN(uint8_t, irot),
SOA_COLUMN(char, irot),
SOA_COLUMN(int, celltype),
SOA_COLUMN(uint16_t, typeidx),
SOA_COLUMN(uint16_t, fedid),
Expand Down
8 changes: 4 additions & 4 deletions CondFormats/HGCalObjects/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<field name="di_" mapping="blob"/>
</class>

<class name="HGCalFEDReadoutSequence" class_version="0">
<class name="HGCalFEDReadoutSequence_t" class_version="0">
<field name="readoutTypes_" mapping="blob"/>
<field name="modOffsets_" mapping="blob"/>
<field name="erxOffsets_" mapping="blob"/>
Expand All @@ -30,18 +30,18 @@
<field name="feds" mapping="blob"/>
</class>

<class name="HGCalFedConfig" class_version="0">
<class name="HGCalFedConfig_t" class_version="0">
<field name="passthroughMode" mapping="blob"/>
<field name="cbHeaderMarker" mapping="blob"/>
<field name="slinkHeaderMarker" mapping="blob"/>
<field name="delay" mapping="blob"/>
</class>

<class name="HGCalECONDConfig" class_version="0">
<class name="HGCalECONDConfig_t" class_version="0">
<field name="headerMarker" mapping="blob"/>
</class>

<class name="HGCalROCConfig" class_version="0">
<class name="HGCalROCConfig_t" class_version="0">
<field name="charMode" mapping="blob"/>
<field name="clockPhase" mapping="blob"/>
<field name="L1AcceptOffset" mapping="blob"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ int main() {
//dense indexers
testSerialization<HGCalDenseIndexerBase>();
testSerialization<HGCalMappingCellIndexer>();
testSerialization<HGCalFEDReadoutSequence>();
testSerialization<HGCalFEDReadoutSequence_t>();
testSerialization<HGCalMappingModuleIndexer>();

return 0;
Expand Down
2 changes: 1 addition & 1 deletion DataFormats/HGCalDigi/interface/HGCROCChannelDataFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class HGCROCChannelDataFrame {
uint32_t raw() const { return value_; }
bool tc() const { return flag2(); }
bool tp() const { return flag1(); }
uint8_t tctp() const { return (tc() << 1) | tp(); }
uint16_t tctp() const { return (tc() << 1) | tp(); }
uint16_t adc(bool charMode = false) const { return charMode ? packet3() : (tc() ? 0 : packet2()); }
uint16_t adcm1(bool charMode = false) const { return charMode ? 0 : packet3(); }
uint16_t tot(bool charMode = false) const {
Expand Down
2 changes: 2 additions & 0 deletions DataFormats/HGCalDigi/interface/HGCalDigiSoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace hgcaldigi {

// Generate structure of arrays (SoA) layout with Digi dataformat
GENERATE_SOA_LAYOUT(HGCalDigiSoALayout,
// columns: one value per element
//SOA_COLUMN(uint32_t, electronicsId), // redundant since common dense indexing
SOA_COLUMN(uint8_t, tctp),
SOA_COLUMN(uint16_t, adcm1),
SOA_COLUMN(uint16_t, adc),
Expand Down
33 changes: 17 additions & 16 deletions DataFormats/HGCalDigi/interface/HGCalECONDPacketInfoSoA.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef DataFormats_HGCalDigi_interface_HGCalECONDPacketInfoSoA_h
#define DataFormats_HGCalDigi_interface_HGCalECONDPacketInfoSoA_h

#include <cstdint> // for uint8_t

#include <Eigen/Core>
#include <Eigen/Dense>

Expand All @@ -11,26 +9,29 @@
#include "DataFormats/SoATemplate/interface/SoAView.h"

namespace hgcaldigi {

// enum for getting ECONDFlag
namespace ECONDFlag {
constexpr uint8_t BITT_POS = 0, BITM_POS = 1, EBO_POS = 2, EBO_MASK = 0b11, HT_POS = 4, HT_MASK = 0b11,
BITE_POS = 6, BITS_POS = 7;
} // namespace ECONDFlag

enum ECONDFlag {
BITT_POS = 0,
BITM_POS = 1,
EBO_POS = 2,
EBO_MASK = 0b11,
HT_POS = 4,
HT_MASK = 0b11,
BITE_POS = 6,
BITS_POS = 7
};
// functions to parse ECONDFlag
inline bool truncatedFlag(uint8_t econdFlag) { return ((econdFlag >> hgcaldigi::ECONDFlag::BITT_POS) & 0b1); }
inline bool matchFlag(uint8_t econdFlag) { return ((econdFlag >> hgcaldigi::ECONDFlag::BITM_POS) & 0b1); }
inline uint8_t eboFlag(uint8_t econdFlag) {
bool truncatedFlag(uint8_t econdFlag) { return ((econdFlag >> hgcaldigi::ECONDFlag::BITT_POS) & 0b1); }
bool matchFlag(uint8_t econdFlag) { return ((econdFlag >> hgcaldigi::ECONDFlag::BITM_POS) & 0b1); }
uint8_t eboFlag(uint8_t econdFlag) {
return ((econdFlag >> hgcaldigi::ECONDFlag::EBO_POS) & hgcaldigi::ECONDFlag::EBO_MASK);
}
inline uint8_t htFlag(uint8_t econdFlag) {
uint8_t htFlag(uint8_t econdFlag) {
return ((econdFlag >> hgcaldigi::ECONDFlag::HT_POS) & hgcaldigi::ECONDFlag::HT_MASK);
}
inline bool expectedFlag(uint8_t econdFlag) { return ((econdFlag >> hgcaldigi::ECONDFlag::BITE_POS) & 0b1); }
inline bool StatFlag(uint8_t econdFlag) { return ((econdFlag >> hgcaldigi::ECONDFlag::BITS_POS) & 0b1); }

// generate structure of arrays (SoA) layout with Digi dataformat
bool expectedFlag(uint8_t econdFlag) { return ((econdFlag >> hgcaldigi::ECONDFlag::BITE_POS) & 0b1); }
bool StatFlag(uint8_t econdFlag) { return ((econdFlag >> hgcaldigi::ECONDFlag::BITS_POS) & 0b1); }
// Generate structure of arrays (SoA) layout with Digi dataformat
GENERATE_SOA_LAYOUT(HGCalECONDPacketInfoSoALayout,
// Capture block information:
// 0b000: Normal packet
Expand Down
60 changes: 60 additions & 0 deletions DataFormats/HGCalDigi/interface/HGCalFlaggedECONDInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#ifndef DataFormats_HGCalDigis_HGCalFlaggedECONDInfo_h
#define DataFormats_HGCalDigis_HGCalFlaggedECONDInfo_h

#include <vector>

class HGCalFlaggedECONDInfo {
public:
/**
@short flags in the capture block header pertaining an ECON-D
*/
enum CBFlagTypes {
PAYLOADTOOLARGE = 1,
CRCERROR = 2,
EVENTIDMISMATCH = 3,
FSMTIMEOUT = 4,
BCorORBITIDMISMATCH = 5,
MAINBUFFEROVERFLOW = 6,
INACTIVEINPUT = 7
};

/**
@short flags in the ECON-D header
*/
enum FlagTypes {
CBSTATUS = 1,
HTBITS = 2,
EBOBITS = 4,
MATCHBIT = 8,
TRUNCATED = 16,
WRONGHEADERMARKER = 32,
PAYLOADOVERFLOWS = 64,
PAYLOADMISMATCHES = 128,
UNEXPECTEDTRUNCATED = 256
};

HGCalFlaggedECONDInfo() : HGCalFlaggedECONDInfo(0, 0, 0, 0, 0) {}
HGCalFlaggedECONDInfo(uint32_t loc, uint32_t cbflagbits, uint32_t flagbits, uint32_t id, uint32_t pl)
: iword(loc), cbflags(cbflagbits), flags(flagbits), eleid(id), payload(pl) {}
HGCalFlaggedECONDInfo(const HGCalFlaggedECONDInfo &t)
: HGCalFlaggedECONDInfo(t.iword, t.cbflags, t.flags, t.eleid, t.payload) {}

void setPayload(uint32_t v) { payload = v; }
void addFlag(FlagTypes f) { flags += f; }
void addToFlag(uint32_t v) { flags += v; }
bool cbFlag() { return flags & 0x1; };
bool htFlag() { return (flags >> 1) & 0x1; };
bool eboFlag() { return (flags >> 2) & 0x1; };
bool matchFlag() { return (flags >> 3) & 0x1; };
bool truncatedFlag() { return (flags >> 4) & 0x1; };
bool wrongHeaderMarker() { return (flags >> 5) & 0x1; };
bool payloadOverflows() { return (flags >> 6) & 0x1; };
bool payloadMismatches() { return (flags >> 7) & 0x1; };
bool unexpectedTruncated() { return (flags >> 8) & 0x1; };

uint32_t iword, cbflags, flags, eleid, payload;
};

typedef std::vector<HGCalFlaggedECONDInfo> HGCalFlaggedECONDInfoCollection;

#endif
Loading

0 comments on commit 0c0c0b2

Please sign in to comment.