Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 71 additions & 67 deletions DataFormats/CTPPSDigi/interface/CTPPSDiamondDigi.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,76 +13,80 @@
#include <cstdint>
#include "DataFormats/CTPPSDigi/interface/HPTDCErrorFlags.h"

class CTPPSDiamondDigi {
public:
CTPPSDiamondDigi(
unsigned int ledgt_, unsigned int tedgt_, unsigned int threvolt, bool mhit_, unsigned short hptdcerror_);
CTPPSDiamondDigi();
~CTPPSDiamondDigi() {}

/// Digis are equal if they are have same ledt and tedt, threshold voltage, multihit flag, hptdcerror flags
bool operator==(const CTPPSDiamondDigi& digi) const;

/// Return digi values number

unsigned int leadingEdge() const { return ledgt; }

unsigned int trailingEdge() const { return tedgt; }

unsigned int thresholdVoltage() const { return threvolt; }

bool multipleHit() const { return mhit; }

HPTDCErrorFlags hptdcErrorFlags() const { return hptdcerror; }

/// Set digi values
inline void setLeadingEdge(unsigned int ledgt_) { ledgt = ledgt_; }
inline void setTrailingEdge(unsigned int tedgt_) { tedgt = tedgt_; }
inline void setThresholdVoltage(unsigned int threvolt_) { threvolt = threvolt_; }
inline void setMultipleHit(bool mhit_) { mhit = mhit_; }
inline void setHPTDCErrorFlags(const HPTDCErrorFlags& hptdcerror_) { hptdcerror = hptdcerror_; }

private:
// variable represents leading edge time
unsigned int ledgt;
// variable represents trailing edge time
unsigned int tedgt;
// variable represents threshold voltage
unsigned int threvolt;
// variable represents multi-hit
bool mhit;
HPTDCErrorFlags hptdcerror;
};
namespace io_v1 {
class CTPPSDiamondDigi {
public:
CTPPSDiamondDigi(
unsigned int ledgt_, unsigned int tedgt_, unsigned int threvolt, bool mhit_, unsigned short hptdcerror_);
CTPPSDiamondDigi();
~CTPPSDiamondDigi() {}

/// Digis are equal if they are have same ledt and tedt, threshold voltage, multihit flag, hptdcerror flags
bool operator==(const CTPPSDiamondDigi& digi) const;

/// Return digi values number

unsigned int leadingEdge() const { return ledgt; }

unsigned int trailingEdge() const { return tedgt; }

unsigned int thresholdVoltage() const { return threvolt; }

bool multipleHit() const { return mhit; }

HPTDCErrorFlags hptdcErrorFlags() const { return hptdcerror; }

/// Set digi values
inline void setLeadingEdge(unsigned int ledgt_) { ledgt = ledgt_; }
inline void setTrailingEdge(unsigned int tedgt_) { tedgt = tedgt_; }
inline void setThresholdVoltage(unsigned int threvolt_) { threvolt = threvolt_; }
inline void setMultipleHit(bool mhit_) { mhit = mhit_; }
inline void setHPTDCErrorFlags(const HPTDCErrorFlags& hptdcerror_) { hptdcerror = hptdcerror_; }

private:
// variable represents leading edge time
unsigned int ledgt;
// variable represents trailing edge time
unsigned int tedgt;
// variable represents threshold voltage
unsigned int threvolt;
// variable represents multi-hit
bool mhit;
HPTDCErrorFlags hptdcerror;
};
} // namespace io_v1
using CTPPSDiamondDigi = io_v1::CTPPSDiamondDigi;

#include <iostream>

inline bool operator<(const CTPPSDiamondDigi& one, const CTPPSDiamondDigi& other) {
if (one.leadingEdge() < other.leadingEdge())
return true;
if (one.leadingEdge() > other.leadingEdge())
return false;
if (one.trailingEdge() < other.trailingEdge())
return true;
if (one.trailingEdge() > other.trailingEdge())
return false;
if (one.multipleHit() < other.multipleHit())
return true;
if (one.multipleHit() > other.multipleHit())
namespace io_v1 {
inline bool operator<(const CTPPSDiamondDigi& one, const CTPPSDiamondDigi& other) {
if (one.leadingEdge() < other.leadingEdge())
return true;
if (one.leadingEdge() > other.leadingEdge())
return false;
if (one.trailingEdge() < other.trailingEdge())
return true;
if (one.trailingEdge() > other.trailingEdge())
return false;
if (one.multipleHit() < other.multipleHit())
return true;
if (one.multipleHit() > other.multipleHit())
return false;
if (one.hptdcErrorFlags().errorFlag() < other.hptdcErrorFlags().errorFlag())
return true;
if (one.hptdcErrorFlags().errorFlag() > other.hptdcErrorFlags().errorFlag())
return false;
if (one.thresholdVoltage() < other.thresholdVoltage())
return true;
if (one.thresholdVoltage() > other.thresholdVoltage())
return false;
return false;
if (one.hptdcErrorFlags().errorFlag() < other.hptdcErrorFlags().errorFlag())
return true;
if (one.hptdcErrorFlags().errorFlag() > other.hptdcErrorFlags().errorFlag())
return false;
if (one.thresholdVoltage() < other.thresholdVoltage())
return true;
if (one.thresholdVoltage() > other.thresholdVoltage())
return false;
return false;
}

inline std::ostream& operator<<(std::ostream& o, const CTPPSDiamondDigi& digi) {
return o << " " << digi.leadingEdge() << " " << digi.trailingEdge() << " " << digi.thresholdVoltage() << " "
<< digi.multipleHit() << " " << digi.hptdcErrorFlags().errorFlag();
}
}

inline std::ostream& operator<<(std::ostream& o, const CTPPSDiamondDigi& digi) {
return o << " " << digi.leadingEdge() << " " << digi.trailingEdge() << " " << digi.thresholdVoltage() << " "
<< digi.multipleHit() << " " << digi.hptdcErrorFlags().errorFlag();
}
} // namespace io_v1
#endif
80 changes: 41 additions & 39 deletions DataFormats/CTPPSDigi/interface/CTPPSPixelDataError.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,46 @@
#include <array>
#include <cstdint>

class CTPPSPixelDataError {
public:
/// Default constructor
CTPPSPixelDataError();
/// Constructor for 32-bit error word
CTPPSPixelDataError(uint32_t errorWord32, const int errorType, int fedId);
/// Constructor with 64-bit error word and type included (header or trailer word)
CTPPSPixelDataError(uint64_t errorWord64, const int errorType, int fedId);
/// Destructor
~CTPPSPixelDataError();

/// the 32-bit word that contains the error information
inline uint32_t errorWord32() const { return errorWord32_; }
/// the 64-bit word that contains the error information
inline uint64_t errorWord64() const { return errorWord64_; }
/// the number associated with the error type (26-31 for ROC number errors, 32-33 for calibration errors)
inline int errorType() const { return errorType_; }
/// the fedId where the error occured
inline int fedId() const { return fedId_; }
/// the error message to be displayed with the error
inline const std::string& errorMessage() const {
if (errorType_ >= 25 && errorType_ <= 37)
return errorMessages_[errorType_ - 24];
return errorMessages_[0];
namespace io_v1 {
class CTPPSPixelDataError {
public:
/// Default constructor
CTPPSPixelDataError();
/// Constructor for 32-bit error word
CTPPSPixelDataError(uint32_t errorWord32, const int errorType, int fedId);
/// Constructor with 64-bit error word and type included (header or trailer word)
CTPPSPixelDataError(uint64_t errorWord64, const int errorType, int fedId);
/// Destructor
~CTPPSPixelDataError();

/// the 32-bit word that contains the error information
inline uint32_t errorWord32() const { return errorWord32_; }
/// the 64-bit word that contains the error information
inline uint64_t errorWord64() const { return errorWord64_; }
/// the number associated with the error type (26-31 for ROC number errors, 32-33 for calibration errors)
inline int errorType() const { return errorType_; }
/// the fedId where the error occured
inline int fedId() const { return fedId_; }
/// the error message to be displayed with the error
inline const std::string& errorMessage() const {
if (errorType_ >= 25 && errorType_ <= 37)
return errorMessages_[errorType_ - 24];
return errorMessages_[0];
}

private:
static const std::array<std::string, 14> errorMessages_;

uint64_t errorWord64_;
uint32_t errorWord32_;
int errorType_;
int fedId_;
};

/// Comparison operators
inline bool operator<(const CTPPSPixelDataError& one, const CTPPSPixelDataError& other) {
return one.fedId() < other.fedId();
}

private:
static const std::array<std::string, 14> errorMessages_;

uint64_t errorWord64_;
uint32_t errorWord32_;
int errorType_;
int fedId_;
};

/// Comparison operators
inline bool operator<(const CTPPSPixelDataError& one, const CTPPSPixelDataError& other) {
return one.fedId() < other.fedId();
}

} // namespace io_v1
using CTPPSPixelDataError = io_v1::CTPPSPixelDataError;
#endif
87 changes: 46 additions & 41 deletions DataFormats/CTPPSDigi/interface/CTPPSPixelDigi.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,60 +7,65 @@

#include "FWCore/Utilities/interface/Exception.h"

class CTPPSPixelDigi {
public:
CTPPSPixelDigi(int packed_value) : theData(packed_value) {}
namespace io_v1 {
class CTPPSPixelDigi {
public:
CTPPSPixelDigi(int packed_value) : theData(packed_value) {}

CTPPSPixelDigi(int row, int col, int adc) { init(row, col, adc); }
CTPPSPixelDigi(int row, int col, int adc) { init(row, col, adc); }

CTPPSPixelDigi(int chan, int adc) {
std::pair<int, int> rc = channelToPixel(chan);
init(rc.first, rc.second, adc);
}
CTPPSPixelDigi(int chan, int adc) {
std::pair<int, int> rc = channelToPixel(chan);
init(rc.first, rc.second, adc);
}

CTPPSPixelDigi() : theData(0) {}
CTPPSPixelDigi() : theData(0) {}

/// Access to digi information
int row() const { return (theData >> row_shift) & row_mask; }
int column() const { return (theData >> column_shift) & column_mask; }
unsigned short adc() const { return (theData >> adc_shift) & adc_mask; }
uint32_t packedData() const { return theData; }
/// Access to digi information
int row() const { return (theData >> row_shift) & row_mask; }
int column() const { return (theData >> column_shift) & column_mask; }
unsigned short adc() const { return (theData >> adc_shift) & adc_mask; }
uint32_t packedData() const { return theData; }

static std::pair<int, int> channelToPixel(int ch) {
int row = (ch >> column_width_ch) & row_mask_ch;
int col = ch & column_mask_ch;
return std::pair<int, int>(row, col);
}
static std::pair<int, int> channelToPixel(int ch) {
int row = (ch >> column_width_ch) & row_mask_ch;
int col = ch & column_mask_ch;
return std::pair<int, int>(row, col);
}

static int pixelToChannel(int row, int col) { return (row << column_width_ch) | col; }
static int pixelToChannel(int row, int col) { return (row << column_width_ch) | col; }

int channel() const { return pixelToChannel(row(), column()); }
int channel() const { return pixelToChannel(row(), column()); }

/// const values for digi packing with bit structure: adc_bits+col_bits+row_bits
static const uint32_t row_shift, column_shift, adc_shift;
static const uint32_t row_mask, column_mask, adc_mask, rowcol_mask;
static const uint32_t row_width, column_width, adc_width;
static const uint32_t max_row, max_column, max_adc;
/// const values for digi packing with bit structure: adc_bits+col_bits+row_bits
static const uint32_t row_shift, column_shift, adc_shift;
static const uint32_t row_mask, column_mask, adc_mask, rowcol_mask;
static const uint32_t row_width, column_width, adc_width;
static const uint32_t max_row, max_column, max_adc;

/// const values for channel definition with bit structure: row_bits+col_bits
static const uint32_t column_width_ch;
static const uint32_t column_mask_ch;
static const uint32_t row_mask_ch;
/// const values for channel definition with bit structure: row_bits+col_bits
static const uint32_t column_width_ch;
static const uint32_t column_mask_ch;
static const uint32_t row_mask_ch;

private:
void init(int row, int col, int adc);
uint32_t theData;
};
private:
void init(int row, int col, int adc);
uint32_t theData;
};

/// Comparison operator
/// Comparison operator

inline bool operator<(const CTPPSPixelDigi& one, const CTPPSPixelDigi& other) {
return (one.packedData() & CTPPSPixelDigi::rowcol_mask) < (other.packedData() & CTPPSPixelDigi::rowcol_mask);
}
inline bool operator<(const CTPPSPixelDigi& one, const CTPPSPixelDigi& other) {
return (one.packedData() & CTPPSPixelDigi::rowcol_mask) < (other.packedData() & CTPPSPixelDigi::rowcol_mask);
}
} // namespace io_v1
using CTPPSPixelDigi = io_v1::CTPPSPixelDigi;

#include <iostream>
inline std::ostream& operator<<(std::ostream& o, const CTPPSPixelDigi& digi) {
return o << " " << digi.row() << " " << digi.column() << " " << digi.adc();
}
namespace io_v1 {
inline std::ostream& operator<<(std::ostream& o, const CTPPSPixelDigi& digi) {
return o << " " << digi.row() << " " << digi.column() << " " << digi.adc();
}
} // namespace io_v1

#endif
Loading