diff --git a/DataFormats/FTLRecHit/interface/FTLCluster.h b/DataFormats/FTLRecHit/interface/FTLCluster.h index 473a856dd1498..67fa515ee0864 100644 --- a/DataFormats/FTLRecHit/interface/FTLCluster.h +++ b/DataFormats/FTLRecHit/interface/FTLCluster.h @@ -17,276 +17,278 @@ #include "DataFormats/DetId/interface/DetId.h" -class FTLCluster { -public: - typedef DetId key_type; - - class FTLHit { +namespace io_v1 { + class FTLCluster { public: - constexpr FTLHit() : x_(0), y_(0), energy_(0), time_(0), time_error_(0) {} - constexpr FTLHit(uint16_t hit_x, uint16_t hit_y, float hit_energy, float hit_time, float hit_time_error) - : x_(hit_x), y_(hit_y), energy_(hit_energy), time_(hit_time), time_error_(hit_time_error) {} - constexpr uint16_t x() { return x_; } - constexpr uint16_t y() { return y_; } - constexpr uint16_t energy() { return energy_; } - constexpr uint16_t time() { return time_; } - constexpr uint16_t time_error() { return time_error_; } - - private: - uint16_t x_; //row - uint16_t y_; //col - float energy_; - float time_; - float time_error_; - }; - - //--- Integer shift in x and y directions. - class Shift { - public: - constexpr Shift(int dx, int dy) : dx_(dx), dy_(dy) {} - constexpr Shift() : dx_(0), dy_(0) {} - constexpr int dx() const { return dx_; } - constexpr int dy() const { return dy_; } + typedef DetId key_type; + + class FTLHit { + public: + constexpr FTLHit() : x_(0), y_(0), energy_(0), time_(0), time_error_(0) {} + constexpr FTLHit(uint16_t hit_x, uint16_t hit_y, float hit_energy, float hit_time, float hit_time_error) + : x_(hit_x), y_(hit_y), energy_(hit_energy), time_(hit_time), time_error_(hit_time_error) {} + constexpr uint16_t x() { return x_; } + constexpr uint16_t y() { return y_; } + constexpr uint16_t energy() { return energy_; } + constexpr uint16_t time() { return time_; } + constexpr uint16_t time_error() { return time_error_; } + + private: + uint16_t x_; //row + uint16_t y_; //col + float energy_; + float time_; + float time_error_; + }; - private: - int dx_; - int dy_; - }; + //--- Integer shift in x and y directions. + class Shift { + public: + constexpr Shift(int dx, int dy) : dx_(dx), dy_(dy) {} + constexpr Shift() : dx_(0), dy_(0) {} + constexpr int dx() const { return dx_; } + constexpr int dy() const { return dy_; } + + private: + int dx_; + int dy_; + }; - //--- Position of a FTL Hit - class FTLHitPos { - public: - constexpr FTLHitPos() : row_(0), col_(0) {} - constexpr FTLHitPos(int row, int col) : row_(row), col_(col) {} - constexpr int row() const { return row_; } - constexpr int col() const { return col_; } - constexpr FTLHitPos operator+(const Shift& shift) const { - return FTLHitPos(row() + shift.dx(), col() + shift.dy()); - } + //--- Position of a FTL Hit + class FTLHitPos { + public: + constexpr FTLHitPos() : row_(0), col_(0) {} + constexpr FTLHitPos(int row, int col) : row_(row), col_(col) {} + constexpr int row() const { return row_; } + constexpr int col() const { return col_; } + constexpr FTLHitPos operator+(const Shift& shift) const { + return FTLHitPos(row() + shift.dx(), col() + shift.dy()); + } - private: - int row_; - int col_; - }; + private: + int row_; + int col_; + }; - static constexpr unsigned int MAXSPAN = 255; - static constexpr unsigned int MAXPOS = 2047; + static constexpr unsigned int MAXSPAN = 255; + static constexpr unsigned int MAXPOS = 2047; - /** Construct from a range of digis that form a cluster and from + /** Construct from a range of digis that form a cluster and from * a DetID. The range is assumed to be non-empty. */ - FTLCluster() {} - - FTLCluster(DetId id, - unsigned int isize, - float const* energys, - float const* times, - float const* time_errors, - uint16_t const* xpos, - uint16_t const* ypos, - uint16_t const xmin, - uint16_t const ymin) - : theid(id), - theHitOffset(2 * isize), - theHitENERGY(energys, energys + isize), - theHitTIME(times, times + isize), - theHitTIME_ERROR(time_errors, time_errors + isize) { - uint16_t maxCol = 0; - uint16_t maxRow = 0; - int maxHit = -1; - float maxEnergy = -99999; - for (unsigned int i = 0; i != isize; ++i) { - uint16_t xoffset = xpos[i] - xmin; - uint16_t yoffset = ypos[i] - ymin; - theHitOffset[i * 2] = std::min(uint16_t(MAXSPAN), xoffset); - theHitOffset[i * 2 + 1] = std::min(uint16_t(MAXSPAN), yoffset); - if (xoffset > maxRow) - maxRow = xoffset; - if (yoffset > maxCol) - maxCol = yoffset; - if (theHitENERGY[i] > maxEnergy) { - maxHit = i; - maxEnergy = theHitENERGY[i]; + FTLCluster() {} + + FTLCluster(DetId id, + unsigned int isize, + float const* energys, + float const* times, + float const* time_errors, + uint16_t const* xpos, + uint16_t const* ypos, + uint16_t const xmin, + uint16_t const ymin) + : theid(id), + theHitOffset(2 * isize), + theHitENERGY(energys, energys + isize), + theHitTIME(times, times + isize), + theHitTIME_ERROR(time_errors, time_errors + isize) { + uint16_t maxCol = 0; + uint16_t maxRow = 0; + int maxHit = -1; + float maxEnergy = -99999; + for (unsigned int i = 0; i != isize; ++i) { + uint16_t xoffset = xpos[i] - xmin; + uint16_t yoffset = ypos[i] - ymin; + theHitOffset[i * 2] = std::min(uint16_t(MAXSPAN), xoffset); + theHitOffset[i * 2 + 1] = std::min(uint16_t(MAXSPAN), yoffset); + if (xoffset > maxRow) + maxRow = xoffset; + if (yoffset > maxCol) + maxCol = yoffset; + if (theHitENERGY[i] > maxEnergy) { + maxHit = i; + maxEnergy = theHitENERGY[i]; + } } + packRow(xmin, maxRow); + packCol(ymin, maxCol); + + if (maxHit >= 0) + seed_ = std::min(uint8_t(MAXSPAN), uint8_t(maxHit)); } - packRow(xmin, maxRow); - packCol(ymin, maxCol); - if (maxHit >= 0) - seed_ = std::min(uint8_t(MAXSPAN), uint8_t(maxHit)); - } + // linear average position (barycenter) + inline float x() const { + auto x_pos = [this](unsigned int i) { return this->theHitOffset[i * 2] + minHitRow(); }; + return weighted_mean(this->theHitENERGY, x_pos); + } - // linear average position (barycenter) - inline float x() const { - auto x_pos = [this](unsigned int i) { return this->theHitOffset[i * 2] + minHitRow(); }; - return weighted_mean(this->theHitENERGY, x_pos); - } + inline float y() const { + auto y_pos = [this](unsigned int i) { return this->theHitOffset[i * 2 + 1] + minHitCol(); }; + return weighted_mean(this->theHitENERGY, y_pos); + } - inline float y() const { - auto y_pos = [this](unsigned int i) { return this->theHitOffset[i * 2 + 1] + minHitCol(); }; - return weighted_mean(this->theHitENERGY, y_pos); - } + inline float positionError(const float sigmaPos) const { + float sumW2(0.f), sumW(0.f); + for (const auto& hitW : theHitENERGY) { + sumW2 += hitW * hitW; + sumW += hitW; + } + if (sumW > 0) + return sigmaPos * std::sqrt(sumW2) / sumW; + else + return -999.f; + } - inline float positionError(const float sigmaPos) const { - float sumW2(0.f), sumW(0.f); - for (const auto& hitW : theHitENERGY) { - sumW2 += hitW * hitW; - sumW += hitW; + inline float time() const { + auto t = [this](unsigned int i) { return this->theHitTIME[i]; }; + return weighted_mean(this->theHitENERGY, t); } - if (sumW > 0) - return sigmaPos * std::sqrt(sumW2) / sumW; - else - return -999.f; - } - inline float time() const { - auto t = [this](unsigned int i) { return this->theHitTIME[i]; }; - return weighted_mean(this->theHitENERGY, t); - } + inline float timeError() const { + auto t_err = [this](unsigned int i) { return this->theHitTIME_ERROR[i]; }; + return weighted_mean_error(this->theHitENERGY, t_err); + } - inline float timeError() const { - auto t_err = [this](unsigned int i) { return this->theHitTIME_ERROR[i]; }; - return weighted_mean_error(this->theHitENERGY, t_err); - } + // Return number of hits. + inline int size() const { return theHitENERGY.size(); } - // Return number of hits. - inline int size() const { return theHitENERGY.size(); } + // Return cluster dimension in the x direction. + inline int sizeX() const { return rowSpan() + 1; } - // Return cluster dimension in the x direction. - inline int sizeX() const { return rowSpan() + 1; } + // Return cluster dimension in the y direction. + inline int sizeY() const { return colSpan() + 1; } - // Return cluster dimension in the y direction. - inline int sizeY() const { return colSpan() + 1; } + inline float energy() const { + return std::accumulate(theHitENERGY.begin(), theHitENERGY.end(), 0.f); + } // Return total cluster energy. - inline float energy() const { - return std::accumulate(theHitENERGY.begin(), theHitENERGY.end(), 0.f); - } // Return total cluster energy. + inline int minHitRow() const { return theMinHitRow; } // The min x index. + inline int maxHitRow() const { return minHitRow() + rowSpan(); } // The max x index. + inline int minHitCol() const { return theMinHitCol; } // The min y index. + inline int maxHitCol() const { return minHitCol() + colSpan(); } // The max y index. - inline int minHitRow() const { return theMinHitRow; } // The min x index. - inline int maxHitRow() const { return minHitRow() + rowSpan(); } // The max x index. - inline int minHitCol() const { return theMinHitCol; } // The min y index. - inline int maxHitCol() const { return minHitCol() + colSpan(); } // The max y index. + const std::vector& hitOffset() const { return theHitOffset; } + const std::vector& hitENERGY() const { return theHitENERGY; } + const std::vector& hitTIME() const { return theHitTIME; } + const std::vector& hitTIME_ERROR() const { return theHitTIME_ERROR; } - const std::vector& hitOffset() const { return theHitOffset; } - const std::vector& hitENERGY() const { return theHitENERGY; } - const std::vector& hitTIME() const { return theHitTIME; } - const std::vector& hitTIME_ERROR() const { return theHitTIME_ERROR; } + // infinite faster than above... + FTLHit hit(int i) const { + return FTLHit(minHitRow() + theHitOffset[i * 2], + minHitCol() + theHitOffset[i * 2 + 1], + theHitENERGY[i], + theHitTIME[i], + theHitTIME_ERROR[i]); + } - // infinite faster than above... - FTLHit hit(int i) const { - return FTLHit(minHitRow() + theHitOffset[i * 2], - minHitCol() + theHitOffset[i * 2 + 1], - theHitENERGY[i], - theHitTIME[i], - theHitTIME_ERROR[i]); - } + FTLHit seed() const { return hit(seed_); } - FTLHit seed() const { return hit(seed_); } + int colSpan() const { return theHitColSpan; } - int colSpan() const { return theHitColSpan; } + int rowSpan() const { return theHitRowSpan; } - int rowSpan() const { return theHitRowSpan; } + const DetId& id() const { return theid; } + const DetId& detid() const { return id(); } - const DetId& id() const { return theid; } - const DetId& detid() const { return id(); } + bool overflowCol() const { return overflow_(theHitColSpan); } - bool overflowCol() const { return overflow_(theHitColSpan); } + bool overflowRow() const { return overflow_(theHitRowSpan); } - bool overflowRow() const { return overflow_(theHitRowSpan); } + bool overflow() const { return overflowCol() || overflowRow(); } - bool overflow() const { return overflowCol() || overflowRow(); } + void packCol(uint16_t ymin, uint16_t yspan) { + theMinHitCol = ymin; + theHitColSpan = std::min(yspan, uint16_t(MAXSPAN)); + } + void packRow(uint16_t xmin, uint16_t xspan) { + theMinHitRow = xmin; + theHitRowSpan = std::min(xspan, uint16_t(MAXSPAN)); + } - void packCol(uint16_t ymin, uint16_t yspan) { - theMinHitCol = ymin; - theHitColSpan = std::min(yspan, uint16_t(MAXSPAN)); - } - void packRow(uint16_t xmin, uint16_t xspan) { - theMinHitRow = xmin; - theHitRowSpan = std::min(xspan, uint16_t(MAXSPAN)); - } + void setClusterPosX(float posx) { pos_x = posx; } + void setClusterErrorX(float errx) { err_x = errx; } + void setClusterErrorTime(float errtime) { err_time = errtime; } + float getClusterPosX() const { return pos_x; } + float getClusterErrorX() const { return err_x; } + float getClusterErrorTime() const { return err_time; } - void setClusterPosX(float posx) { pos_x = posx; } - void setClusterErrorX(float errx) { err_x = errx; } - void setClusterErrorTime(float errtime) { err_time = errtime; } - float getClusterPosX() const { return pos_x; } - float getClusterErrorX() const { return err_x; } - float getClusterErrorTime() const { return err_time; } - -private: - DetId theid; - - std::vector theHitOffset; - std::vector theHitENERGY; - std::vector theHitTIME; - std::vector theHitTIME_ERROR; - - uint16_t theMinHitRow = MAXPOS; // Minimum hit index in the x direction (low edge). - uint16_t theMinHitCol = MAXPOS; // Minimum hit index in the y direction (left edge). - uint8_t theHitRowSpan = 0; // Span hit index in the x direction (low edge). - uint8_t theHitColSpan = 0; // Span hit index in the y direction (left edge). - - float pos_x = -99999.9f; // For pixels with internal position information in one coordinate (i.e. BTL crystals) - float err_x = -99999.9f; // For pixels with internal position information in one coordinate (i.e. BTL crystals) - float err_time = -99999.9f; - - uint8_t seed_; - - template - float weighted_sum(const std::vector& weights, SumFunc&& sumFunc, OutFunc&& outFunc) const { - float tot = 0; - float sumW = 0; - for (unsigned int i = 0; i < weights.size(); ++i) { - tot += sumFunc(i); - sumW += weights[i]; + private: + DetId theid; + + std::vector theHitOffset; + std::vector theHitENERGY; + std::vector theHitTIME; + std::vector theHitTIME_ERROR; + + uint16_t theMinHitRow = MAXPOS; // Minimum hit index in the x direction (low edge). + uint16_t theMinHitCol = MAXPOS; // Minimum hit index in the y direction (left edge). + uint8_t theHitRowSpan = 0; // Span hit index in the x direction (low edge). + uint8_t theHitColSpan = 0; // Span hit index in the y direction (left edge). + + float pos_x = -99999.9f; // For pixels with internal position information in one coordinate (i.e. BTL crystals) + float err_x = -99999.9f; // For pixels with internal position information in one coordinate (i.e. BTL crystals) + float err_time = -99999.9f; + + uint8_t seed_; + + template + float weighted_sum(const std::vector& weights, SumFunc&& sumFunc, OutFunc&& outFunc) const { + float tot = 0; + float sumW = 0; + for (unsigned int i = 0; i < weights.size(); ++i) { + tot += sumFunc(i); + sumW += weights[i]; + } + return outFunc(tot, sumW); } - return outFunc(tot, sumW); - } - template - float weighted_mean(const std::vector& weights, Value&& value) const { - auto sumFunc = [&weights, value](unsigned int i) { return weights[i] * value(i); }; - auto outFunc = [](float x, float y) { - if (y > 0) - return (float)x / y; - else - return -999.f; - }; - return weighted_sum(weights, sumFunc, outFunc); - } + template + float weighted_mean(const std::vector& weights, Value&& value) const { + auto sumFunc = [&weights, value](unsigned int i) { return weights[i] * value(i); }; + auto outFunc = [](float x, float y) { + if (y > 0) + return (float)x / y; + else + return -999.f; + }; + return weighted_sum(weights, sumFunc, outFunc); + } - template - float weighted_mean_error(const std::vector& weights, Err&& err) const { - auto sumFunc = [&weights, err](unsigned int i) { return weights[i] * weights[i] * err(i) * err(i); }; - auto outFunc = [](float x, float y) { - if (y > 0) - return (float)sqrt(x) / y; - else - return -999.f; - }; - return weighted_sum(weights, sumFunc, outFunc); - } + template + float weighted_mean_error(const std::vector& weights, Err&& err) const { + auto sumFunc = [&weights, err](unsigned int i) { return weights[i] * weights[i] * err(i) * err(i); }; + auto outFunc = [](float x, float y) { + if (y > 0) + return (float)sqrt(x) / y; + else + return -999.f; + }; + return weighted_sum(weights, sumFunc, outFunc); + } + + static int overflow_(uint16_t span) { return span == uint16_t(MAXSPAN); } + }; - static int overflow_(uint16_t span) { return span == uint16_t(MAXSPAN); } -}; - -// Comparison operators (needed by DetSetVector & SortedCollection ) -inline bool operator<(const FTLCluster& one, const FTLCluster& other) { - if (one.detid() == other.detid()) { - if (one.minHitRow() < other.minHitRow()) { - return true; - } else if (one.minHitRow() > other.minHitRow()) { - return false; - } else if (one.minHitCol() < other.minHitCol()) { - return true; - } else { - return false; + // Comparison operators (needed by DetSetVector & SortedCollection ) + inline bool operator<(const FTLCluster& one, const FTLCluster& other) { + if (one.detid() == other.detid()) { + if (one.minHitRow() < other.minHitRow()) { + return true; + } else if (one.minHitRow() > other.minHitRow()) { + return false; + } else if (one.minHitCol() < other.minHitCol()) { + return true; + } else { + return false; + } } + return one.detid() < other.detid(); } - return one.detid() < other.detid(); -} - -inline bool operator<(const FTLCluster& one, const uint32_t& detid) { return one.detid() < detid; } -inline bool operator<(const uint32_t& detid, const FTLCluster& other) { return detid < other.detid(); } + inline bool operator<(const FTLCluster& one, const uint32_t& detid) { return one.detid() < detid; } + inline bool operator<(const uint32_t& detid, const FTLCluster& other) { return detid < other.detid(); } +} // namespace io_v1 +using FTLCluster = io_v1::FTLCluster; #endif diff --git a/DataFormats/FTLRecHit/interface/FTLRecHit.h b/DataFormats/FTLRecHit/interface/FTLRecHit.h index 1f5c793a9e32a..61b76b8eebe26 100644 --- a/DataFormats/FTLRecHit/interface/FTLRecHit.h +++ b/DataFormats/FTLRecHit/interface/FTLRecHit.h @@ -12,18 +12,19 @@ * \author Lindsey Gray */ -class FTLRecHit { -public: - typedef DetId key_type; - - // FTLEE recHit flags - enum Flags { - kGood = 0, // channel ok, the energy and time measurement are reliable - kKilled, // MC only flag: the channel is killed in the real detector - kUnknown // to ease the interface with functions returning flags. - }; - - /** bit structure of CaloRecHit::flags_ used in FTLRecHit: +namespace io_v1 { + class FTLRecHit { + public: + typedef DetId key_type; + + // FTLEE recHit flags + enum Flags { + kGood = 0, // channel ok, the energy and time measurement are reliable + kKilled, // MC only flag: the channel is killed in the real detector + kUnknown // to ease the interface with functions returning flags. + }; + + /** bit structure of CaloRecHit::flags_ used in FTLRecHit: * * | 32 | 31...25 | 24...12 | 11...5 | 4...1 | * | | | | | @@ -34,79 +35,80 @@ class FTLRecHit { * +--> spare ( 1 bit ) */ - FTLRecHit(); - // by default a recHit is greated with no flag - FTLRecHit(const DetId& id, - uint8_t row, - uint8_t column, - float energy, - float time, - float timeError, - float position, - float positionError, - uint32_t flagBits = 0); - - FTLRecHit(const DetId& id, - float energy, - float time, - float timeError, - float position, - float positionError, - uint32_t flagBits = 0); - - /// get the id - - float energy() const { return energy_; } - void setEnergy(float energy) { energy_ = energy; } - - const DetId& id() const { return id_; } - const DetId& detid() const { return id(); } - - const MTDDetId mtdId() const { return MTDDetId(id_); } - - int row() const { return row_; } - int column() const { return column_; } - - float time() const { return time_; } - void setTime(float time) { time_ = time; } - - float position() const { return position_; } - void setPosition(float position) { position_ = position; } - - bool isTimeValid() const; - bool isTimeErrorValid() const; - - float timeError() const { return timeError_; } - void setTimeError(float err) { timeError_ = err; } - - float positionError() const { return positionError_; } - void setPositionError(float poserr) { positionError_ = poserr; } - - /// set the flags (from Flags or ESFlags) - void setFlag(int flag) { flagBits_ |= (0x1 << flag); } - void unsetFlag(int flag) { flagBits_ &= ~(0x1 << flag); } - - /// check if the flag is true - bool checkFlag(int flag) const { return flagBits_ & (0x1 << flag); } - - /// check if one of the flags in a set is true - bool checkFlags(const std::vector& flagsvec) const; - -private: - DetId id_; - float energy_; - float time_; - float timeError_; - /// position is the distance from the center of the bar to hit - float position_; - float positionError_; - uint8_t row_; - uint8_t column_; - - /// store rechit condition (see Flags enum) in a bit-wise way - unsigned char flagBits_; -}; - -std::ostream& operator<<(std::ostream& s, const FTLRecHit& hit); + FTLRecHit(); + // by default a recHit is greated with no flag + FTLRecHit(const DetId& id, + uint8_t row, + uint8_t column, + float energy, + float time, + float timeError, + float position, + float positionError, + uint32_t flagBits = 0); + + FTLRecHit(const DetId& id, + float energy, + float time, + float timeError, + float position, + float positionError, + uint32_t flagBits = 0); + + /// get the id + + float energy() const { return energy_; } + void setEnergy(float energy) { energy_ = energy; } + + const DetId& id() const { return id_; } + const DetId& detid() const { return id(); } + + const MTDDetId mtdId() const { return MTDDetId(id_); } + + int row() const { return row_; } + int column() const { return column_; } + + float time() const { return time_; } + void setTime(float time) { time_ = time; } + + float position() const { return position_; } + void setPosition(float position) { position_ = position; } + + bool isTimeValid() const; + bool isTimeErrorValid() const; + + float timeError() const { return timeError_; } + void setTimeError(float err) { timeError_ = err; } + + float positionError() const { return positionError_; } + void setPositionError(float poserr) { positionError_ = poserr; } + + /// set the flags (from Flags or ESFlags) + void setFlag(int flag) { flagBits_ |= (0x1 << flag); } + void unsetFlag(int flag) { flagBits_ &= ~(0x1 << flag); } + + /// check if the flag is true + bool checkFlag(int flag) const { return flagBits_ & (0x1 << flag); } + + /// check if one of the flags in a set is true + bool checkFlags(const std::vector& flagsvec) const; + + private: + DetId id_; + float energy_; + float time_; + float timeError_; + /// position is the distance from the center of the bar to hit + float position_; + float positionError_; + uint8_t row_; + uint8_t column_; + + /// store rechit condition (see Flags enum) in a bit-wise way + unsigned char flagBits_; + }; + std::ostream& operator<<(std::ostream& s, const FTLRecHit& hit); +} // namespace io_v1 +using FTLRecHit = io_v1::FTLRecHit; #endif diff --git a/DataFormats/FTLRecHit/interface/FTLRecHitComparison.h b/DataFormats/FTLRecHit/interface/FTLRecHitComparison.h index 7595e5f3cffbb..e457df78a41ea 100644 --- a/DataFormats/FTLRecHit/interface/FTLRecHitComparison.h +++ b/DataFormats/FTLRecHit/interface/FTLRecHitComparison.h @@ -5,15 +5,16 @@ //ordering capability mandatory for lazy getter framework // Comparison operators -inline bool operator<(const FTLRecHit& one, const FTLRecHit& other) { - if (one.detid() == other.detid()) { - return one.energy() < other.energy(); +namespace io_v1 { + inline bool operator<(const FTLRecHit& one, const FTLRecHit& other) { + if (one.detid() == other.detid()) { + return one.energy() < other.energy(); + } + return one.detid() < other.detid(); } - return one.detid() < other.detid(); -} -inline bool operator<(const FTLRecHit& one, const uint32_t& detid) { return one.detid() < detid; } - -inline bool operator<(const uint32_t& detid, const FTLRecHit& other) { return detid < other.detid(); } + inline bool operator<(const FTLRecHit& one, const uint32_t& detid) { return one.detid() < detid; } + inline bool operator<(const uint32_t& detid, const FTLRecHit& other) { return detid < other.detid(); } +} // namespace io_v1 #endif diff --git a/DataFormats/FTLRecHit/interface/FTLUncalibratedRecHit.h b/DataFormats/FTLRecHit/interface/FTLUncalibratedRecHit.h index 5a5396c893295..47c2f1b9b539c 100644 --- a/DataFormats/FTLRecHit/interface/FTLUncalibratedRecHit.h +++ b/DataFormats/FTLRecHit/interface/FTLUncalibratedRecHit.h @@ -4,75 +4,77 @@ #include #include "DataFormats/DetId/interface/DetId.h" -class FTLUncalibratedRecHit { -public: - typedef DetId key_type; +namespace io_v1 { + class FTLUncalibratedRecHit { + public: + typedef DetId key_type; - enum Flags { - kGood = -1, // channel is good (mutually exclusive with other states) setFlagBit(kGood) reset flags_ to zero - kPoorReco, // channel has been badly reconstructed (e.g. bad shape, bad chi2 etc.) - kSaturated, // saturated channel - kOutOfTime // channel out of time - }; - - FTLUncalibratedRecHit(); - FTLUncalibratedRecHit(const DetId& detId, - uint8_t row, - uint8_t column, - std::pair ampl, - std::pair time, - float timeError, - float position, - float positionError, - unsigned char flags = 0); - FTLUncalibratedRecHit(const DetId& detId, - std::pair ampl, - std::pair time, - float timeError, - float position, - float positionError, - unsigned char flags = 0); + enum Flags { + kGood = -1, // channel is good (mutually exclusive with other states) setFlagBit(kGood) reset flags_ to zero + kPoorReco, // channel has been badly reconstructed (e.g. bad shape, bad chi2 etc.) + kSaturated, // saturated channel + kOutOfTime // channel out of time + }; - ~FTLUncalibratedRecHit() = default; - std::pair amplitude() const { return amplitude_; } - std::pair time() const { return time_; } - float position() const { return position_; } + FTLUncalibratedRecHit(); + FTLUncalibratedRecHit(const DetId& detId, + uint8_t row, + uint8_t column, + std::pair ampl, + std::pair time, + float timeError, + float position, + float positionError, + unsigned char flags = 0); + FTLUncalibratedRecHit(const DetId& detId, + std::pair ampl, + std::pair time, + float timeError, + float position, + float positionError, + unsigned char flags = 0); - float timeError() const { return timeError_; } - float positionError() const { return positionError_; } + ~FTLUncalibratedRecHit() = default; + std::pair amplitude() const { return amplitude_; } + std::pair time() const { return time_; } + float position() const { return position_; } - unsigned char flags() const { return flags_; }; + float timeError() const { return timeError_; } + float positionError() const { return positionError_; } - DetId id() const { return id_; } - int row() const { return row_; } - int column() const { return column_; } + unsigned char flags() const { return flags_; }; - void setAmplitude(std::pair amplitude) { amplitude_ = amplitude; } - void setTime(std::pair time) { time_ = time; } + DetId id() const { return id_; } + int row() const { return row_; } + int column() const { return column_; } - void setTimeError(float timeErr) { timeError_ = timeErr; } - void setId(DetId id) { id_ = id; } - void setFlagBit(Flags flag); - bool checkFlag(Flags flag) const; + void setAmplitude(std::pair amplitude) { amplitude_ = amplitude; } + void setTime(std::pair time) { time_ = time; } - void setPosition(float position) { position_ = position; } - void setPositionError(float positionErr) { positionError_ = positionErr; } + void setTimeError(float timeErr) { timeError_ = timeErr; } + void setId(DetId id) { id_ = id; } + void setFlagBit(Flags flag); + bool checkFlag(Flags flag) const; - bool isTimeValid() const; - bool isTimeErrorValid() const; + void setPosition(float position) { position_ = position; } + void setPositionError(float positionErr) { positionError_ = positionErr; } - bool isSaturated() const; + bool isTimeValid() const; + bool isTimeErrorValid() const; -private: - std::pair amplitude_; - std::pair time_; - float timeError_; - float position_; /// distance from the center of the bar to the hit - float positionError_; - DetId id_; - uint8_t row_; - uint8_t column_; - unsigned char flags_; -}; + bool isSaturated() const; + private: + std::pair amplitude_; + std::pair time_; + float timeError_; + float position_; /// distance from the center of the bar to the hit + float positionError_; + DetId id_; + uint8_t row_; + uint8_t column_; + unsigned char flags_; + }; +} // namespace io_v1 +using FTLUncalibratedRecHit = io_v1::FTLUncalibratedRecHit; #endif diff --git a/DataFormats/FTLRecHit/src/FTLRecHit.cc b/DataFormats/FTLRecHit/src/FTLRecHit.cc index dfa5d2bbce188..6d3dcb1ac60d3 100644 --- a/DataFormats/FTLRecHit/src/FTLRecHit.cc +++ b/DataFormats/FTLRecHit/src/FTLRecHit.cc @@ -6,62 +6,63 @@ namespace { constexpr float timereso_max = 10000; } +namespace io_v1 { + FTLRecHit::FTLRecHit() + : FTLRecHit(DetId(), 0, 0, -1.f, -1.f, -1.f, -1.f, -1.f, std::numeric_limits::max()) {} -FTLRecHit::FTLRecHit() - : FTLRecHit(DetId(), 0, 0, -1.f, -1.f, -1.f, -1.f, -1.f, std::numeric_limits::max()) {} + FTLRecHit::FTLRecHit(const DetId& id, + uint8_t row, + uint8_t column, + float energy, + float time, + float timeError, + float position, + float positionError, + uint32_t flagBits) + : id_(id), + energy_(energy), + time_(time), + timeError_(timeError), + position_(position), + positionError_(positionError), + row_(row), + column_(column), + flagBits_(flagBits) {} -FTLRecHit::FTLRecHit(const DetId& id, - uint8_t row, - uint8_t column, - float energy, - float time, - float timeError, - float position, - float positionError, - uint32_t flagBits) - : id_(id), - energy_(energy), - time_(time), - timeError_(timeError), - position_(position), - positionError_(positionError), - row_(row), - column_(column), - flagBits_(flagBits) {} + FTLRecHit::FTLRecHit( + const DetId& id, float energy, float time, float timeError, float position, float positionError, uint32_t flagBits) + : FTLRecHit(id, 0, 0, energy, time, timeError, position, positionError, flagBits) {} -FTLRecHit::FTLRecHit( - const DetId& id, float energy, float time, float timeError, float position, float positionError, uint32_t flagBits) - : FTLRecHit(id, 0, 0, energy, time, timeError, position, positionError, flagBits) {} + bool FTLRecHit::isTimeValid() const { + if (timeError() < 0) + return false; + else + return true; + } + + bool FTLRecHit::isTimeErrorValid() const { + if (!isTimeValid()) + return false; + if (timeError() >= timereso_max) + return false; -bool FTLRecHit::isTimeValid() const { - if (timeError() < 0) - return false; - else return true; -} + } -bool FTLRecHit::isTimeErrorValid() const { - if (!isTimeValid()) - return false; - if (timeError() >= timereso_max) + /// check if one of the flags in a set is true + bool FTLRecHit::checkFlags(const std::vector& flagsvec) const { + for (std::vector::const_iterator flagPtr = flagsvec.begin(); flagPtr != flagsvec.end(); + ++flagPtr) { // check if one of the flags is up + if (checkFlag(*flagPtr)) + return true; + } return false; - - return true; -} - -/// check if one of the flags in a set is true -bool FTLRecHit::checkFlags(const std::vector& flagsvec) const { - for (std::vector::const_iterator flagPtr = flagsvec.begin(); flagPtr != flagsvec.end(); - ++flagPtr) { // check if one of the flags is up - if (checkFlag(*flagPtr)) - return true; } - return false; -} -std::ostream& operator<<(std::ostream& s, const FTLRecHit& hit) { - if (hit.detid().det() == DetId::Forward && hit.detid().subdetId() == FastTime) - return s << MTDDetId(hit.detid()) << ": " << hit.energy() << " GeV, " << hit.time() << " ns"; - else - return s << "FTLRecHit undefined subdetector"; -} + std::ostream& operator<<(std::ostream& s, const FTLRecHit& hit) { + if (hit.detid().det() == DetId::Forward && hit.detid().subdetId() == FastTime) + return s << MTDDetId(hit.detid()) << ": " << hit.energy() << " GeV, " << hit.time() << " ns"; + else + return s << "FTLRecHit undefined subdetector"; + } +} // namespace io_v1 diff --git a/DataFormats/FTLRecHit/src/classes_def.xml b/DataFormats/FTLRecHit/src/classes_def.xml index 3e786d54f51f4..74529afef6df1 100644 --- a/DataFormats/FTLRecHit/src/classes_def.xml +++ b/DataFormats/FTLRecHit/src/classes_def.xml @@ -1,58 +1,53 @@ - - - - + + - + - - - - + + - + - - - + + - + - + - - - - - - - - + + + + + + + + - - - + + + - - - + + + - + diff --git a/SimDataFormats/Associations/src/classes_def.xml b/SimDataFormats/Associations/src/classes_def.xml index 0879ec09c1856..836d04470800a 100644 --- a/SimDataFormats/Associations/src/classes_def.xml +++ b/SimDataFormats/Associations/src/classes_def.xml @@ -261,13 +261,13 @@ - + - +