diff --git a/DataFormats/SiPixelDigi/interface/PixelDigi.h b/DataFormats/SiPixelDigi/interface/PixelDigi.h index af41ca0ce24e7..cca8a5ab5433a 100644 --- a/DataFormats/SiPixelDigi/interface/PixelDigi.h +++ b/DataFormats/SiPixelDigi/interface/PixelDigi.h @@ -11,89 +11,94 @@ * Persistent digi for the Pixels. */ -class PixelDigi { -public: - typedef unsigned int PackedDigiType; - typedef unsigned int ChannelType; +namespace io_v1 { + class PixelDigi { + public: + typedef unsigned int PackedDigiType; + typedef unsigned int ChannelType; - explicit PixelDigi(PackedDigiType packed_value) : theData(packed_value) {} + explicit PixelDigi(PackedDigiType packed_value) : theData(packed_value) {} - PixelDigi(int row, int col, int adc) { init(row, col, adc); } - PixelDigi(int row, int col, int adc, int flag) { init(row, col, adc, flag); } + PixelDigi(int row, int col, int adc) { init(row, col, adc); } + PixelDigi(int row, int col, int adc, int flag) { init(row, col, adc, flag); } - PixelDigi(int chan, int adc) { - std::pair rc = channelToPixel(chan); - init(rc.first, rc.second, adc); - } + PixelDigi(int chan, int adc) { + std::pair rc = channelToPixel(chan); + init(rc.first, rc.second, adc); + } - PixelDigi() : theData(0) {} + PixelDigi() : theData(0) {} - void init(int row, int col, int adc, int flag = 0) { + void init(int row, int col, int adc, int flag = 0) { #ifdef FIXME_DEBUG - // This check is for the maximal row or col number that can be packed - // in a PixelDigi. The actual number of rows or columns in a detector - // may be smaller! - // it is done much better in Raw2Digi... - if (row < 0 || row > PixelChannelIdentifier::thePacking.max_row || col < 0 || - col > PixelChannelIdentifier::thePacking.max_column) { - std::cout << "PixelDigi constructor: row or column out packing range " << row << ' ' << col << std::endl; - } + // This check is for the maximal row or col number that can be packed + // in a PixelDigi. The actual number of rows or columns in a detector + // may be smaller! + // it is done much better in Raw2Digi... + if (row < 0 || row > PixelChannelIdentifier::thePacking.max_row || col < 0 || + col > PixelChannelIdentifier::thePacking.max_column) { + std::cout << "PixelDigi constructor: row or column out packing range " << row << ' ' << col << std::endl; + } #endif - // Set adc to max_adc in case of overflow - adc = (adc > PixelChannelIdentifier::thePacking.max_adc) ? PixelChannelIdentifier::thePacking.max_adc - : std::max(adc, 0); - - theData = (row << PixelChannelIdentifier::thePacking.row_shift) | - (col << PixelChannelIdentifier::thePacking.column_shift) | - (adc << PixelChannelIdentifier::thePacking.adc_shift) | - (flag << PixelChannelIdentifier::thePacking.flag_shift); - } + // Set adc to max_adc in case of overflow + adc = (adc > PixelChannelIdentifier::thePacking.max_adc) ? PixelChannelIdentifier::thePacking.max_adc + : std::max(adc, 0); - // Access to digi information - int row() const { - return (theData >> PixelChannelIdentifier::thePacking.row_shift) & PixelChannelIdentifier::thePacking.row_mask; - } - int column() const { - return (theData >> PixelChannelIdentifier::thePacking.column_shift) & - PixelChannelIdentifier::thePacking.column_mask; - } - int flag() const { - return (theData >> PixelChannelIdentifier::thePacking.flag_shift) & PixelChannelIdentifier::thePacking.flag_mask; - } - unsigned short adc() const { - return (theData >> PixelChannelIdentifier::thePacking.adc_shift) & PixelChannelIdentifier::thePacking.adc_mask; - } - PackedDigiType packedData() const { return theData; } + theData = (row << PixelChannelIdentifier::thePacking.row_shift) | + (col << PixelChannelIdentifier::thePacking.column_shift) | + (adc << PixelChannelIdentifier::thePacking.adc_shift) | + (flag << PixelChannelIdentifier::thePacking.flag_shift); + } - static std::pair channelToPixel(int ch) { - int row = (ch >> PixelChannelIdentifier::thePacking.column_width) & PixelChannelIdentifier::thePacking.row_mask; - int col = ch & PixelChannelIdentifier::thePacking.column_mask; - return std::pair(row, col); - } + // Access to digi information + int row() const { + return (theData >> PixelChannelIdentifier::thePacking.row_shift) & PixelChannelIdentifier::thePacking.row_mask; + } + int column() const { + return (theData >> PixelChannelIdentifier::thePacking.column_shift) & + PixelChannelIdentifier::thePacking.column_mask; + } + int flag() const { + return (theData >> PixelChannelIdentifier::thePacking.flag_shift) & PixelChannelIdentifier::thePacking.flag_mask; + } + unsigned short adc() const { + return (theData >> PixelChannelIdentifier::thePacking.adc_shift) & PixelChannelIdentifier::thePacking.adc_mask; + } + PackedDigiType packedData() const { return theData; } - static int pixelToChannel(int row, int col) { return (row << PixelChannelIdentifier::thePacking.column_width) | col; } + static std::pair channelToPixel(int ch) { + int row = (ch >> PixelChannelIdentifier::thePacking.column_width) & PixelChannelIdentifier::thePacking.row_mask; + int col = ch & PixelChannelIdentifier::thePacking.column_mask; + return std::pair(row, col); + } - int channel() const { return PixelChannelIdentifier::pixelToChannel(row(), column()); } + static int pixelToChannel(int row, int col) { + return (row << PixelChannelIdentifier::thePacking.column_width) | col; + } -private: - PackedDigiType theData; -}; + int channel() const { return PixelChannelIdentifier::pixelToChannel(row(), column()); } -// Comparison operators + private: + PackedDigiType theData; + }; -//inline bool operator<( const PixelDigi& one, const PixelDigi& other) { -// return one.channel() < other.channel(); -//} + // Comparison operators -inline bool operator<(const PixelDigi& one, const PixelDigi& other) { - return (one.packedData() & PixelChannelIdentifier::thePacking.rowcol_mask) < - (other.packedData() & PixelChannelIdentifier::thePacking.rowcol_mask); -} + //inline bool operator<( const PixelDigi& one, const PixelDigi& other) { + // return one.channel() < other.channel(); + //} + inline bool operator<(const PixelDigi& one, const PixelDigi& other) { + return (one.packedData() & PixelChannelIdentifier::thePacking.rowcol_mask) < + (other.packedData() & PixelChannelIdentifier::thePacking.rowcol_mask); + } +} // namespace io_v1 #include -inline std::ostream& operator<<(std::ostream& o, const PixelDigi& digi) { - return o << " " << digi.channel() << " " << digi.adc(); -} - +namespace io_v1 { + inline std::ostream& operator<<(std::ostream& o, const PixelDigi& digi) { + return o << " " << digi.channel() << " " << digi.adc(); + } +} // namespace io_v1 +using PixelDigi = io_v1::PixelDigi; #endif diff --git a/DataFormats/SiPixelDigi/interface/PixelDigiCollection.h b/DataFormats/SiPixelDigi/interface/PixelDigiCollection.h index 64a8af962fa83..1114fec370e83 100644 --- a/DataFormats/SiPixelDigi/interface/PixelDigiCollection.h +++ b/DataFormats/SiPixelDigi/interface/PixelDigiCollection.h @@ -6,23 +6,26 @@ #include #include -class PixelDigiCollection { -public: - typedef std::vector::const_iterator ContainerIterator; - typedef std::pair Range; - typedef std::pair IndexRange; - typedef std::map Registry; - typedef std::map::const_iterator RegistryIterator; +namespace io_v1 { + class PixelDigiCollection { + public: + typedef std::vector::const_iterator ContainerIterator; + typedef std::pair Range; + typedef std::pair IndexRange; + typedef std::map Registry; + typedef std::map::const_iterator RegistryIterator; - PixelDigiCollection() {} + PixelDigiCollection() {} - void put(Range input, unsigned int detID); - const Range get(unsigned int detID) const; - const std::vector detIDs() const; + void put(Range input, unsigned int detID); + const Range get(unsigned int detID) const; + const std::vector detIDs() const; -private: - std::vector container_; - Registry map_; -}; + private: + std::vector container_; + Registry map_; + }; +} // namespace io_v1 +using PixelDigiCollection = io_v1::PixelDigiCollection; #endif // TRACKINGOBJECTS_PIXELDIGICOLLECTION_H diff --git a/DataFormats/SiPixelDigi/interface/PixelDigiFwd.h b/DataFormats/SiPixelDigi/interface/PixelDigiFwd.h index 36896c86c7f9e..2686fde81641b 100644 --- a/DataFormats/SiPixelDigi/interface/PixelDigiFwd.h +++ b/DataFormats/SiPixelDigi/interface/PixelDigiFwd.h @@ -1,6 +1,9 @@ #ifndef DataFormats_SiPixelDigi_PixelDigiFwd_h #define DataFormats_SiPixelDigi_PixelDigiFwd_h -class PixelDigi; +namespace io_v1 { + class PixelDigi; +} +using PixelDigi = io_v1::PixelDigi; #endif diff --git a/DataFormats/SiPixelDigi/src/PixelDigiCollection.cc b/DataFormats/SiPixelDigi/src/PixelDigiCollection.cc index 7a2b26f180400..87248a3f3c6af 100644 --- a/DataFormats/SiPixelDigi/src/PixelDigiCollection.cc +++ b/DataFormats/SiPixelDigi/src/PixelDigiCollection.cc @@ -2,67 +2,69 @@ #include #include -void PixelDigiCollection::put(Range input, unsigned int detID) { - // put in Digis of detID +namespace io_v1 { + void PixelDigiCollection::put(Range input, unsigned int detID) { + // put in Digis of detID - // store size of vector before put - IndexRange inputRange; + // store size of vector before put + IndexRange inputRange; - // put in PixelDigis from input - bool first = true; + // put in PixelDigis from input + bool first = true; - // fill input in temporary vector for sorting - std::vector temporary; - PixelDigiCollection::ContainerIterator sort_begin = input.first; - PixelDigiCollection::ContainerIterator sort_end = input.second; - for (; sort_begin != sort_end; ++sort_begin) { - temporary.push_back(*sort_begin); - } - std::sort(temporary.begin(), temporary.end()); + // fill input in temporary vector for sorting + std::vector temporary; + PixelDigiCollection::ContainerIterator sort_begin = input.first; + PixelDigiCollection::ContainerIterator sort_end = input.second; + for (; sort_begin != sort_end; ++sort_begin) { + temporary.push_back(*sort_begin); + } + std::sort(temporary.begin(), temporary.end()); - // iterators over input - PixelDigiCollection::ContainerIterator begin = temporary.begin(); - PixelDigiCollection::ContainerIterator end = temporary.end(); - for (; begin != end; ++begin) { - container_.push_back(*begin); - if (first) { - inputRange.first = container_.size() - 1; - first = false; + // iterators over input + PixelDigiCollection::ContainerIterator begin = temporary.begin(); + PixelDigiCollection::ContainerIterator end = temporary.end(); + for (; begin != end; ++begin) { + container_.push_back(*begin); + if (first) { + inputRange.first = container_.size() - 1; + first = false; + } } + inputRange.second = container_.size() - 1; + + // fill map + map_[detID] = inputRange; } - inputRange.second = container_.size() - 1; - // fill map - map_[detID] = inputRange; -} + const PixelDigiCollection::Range PixelDigiCollection::get(unsigned int detID) const { + // get Digis of detID + + auto found = map_.find(detID); + PixelDigiCollection::IndexRange returnIndexRange{}; + if (found != map_.end()) { + returnIndexRange = found->second; + } -const PixelDigiCollection::Range PixelDigiCollection::get(unsigned int detID) const { - // get Digis of detID + PixelDigiCollection::Range returnRange; + returnRange.first = container_.begin() + returnIndexRange.first; + returnRange.second = container_.begin() + returnIndexRange.second + 1; - auto found = map_.find(detID); - PixelDigiCollection::IndexRange returnIndexRange{}; - if (found != map_.end()) { - returnIndexRange = found->second; + return returnRange; } - PixelDigiCollection::Range returnRange; - returnRange.first = container_.begin() + returnIndexRange.first; - returnRange.second = container_.begin() + returnIndexRange.second + 1; - - return returnRange; -} + const std::vector PixelDigiCollection::detIDs() const { + // returns vector of detIDs in map -const std::vector PixelDigiCollection::detIDs() const { - // returns vector of detIDs in map + PixelDigiCollection::RegistryIterator begin = map_.begin(); + PixelDigiCollection::RegistryIterator end = map_.end(); - PixelDigiCollection::RegistryIterator begin = map_.begin(); - PixelDigiCollection::RegistryIterator end = map_.end(); + std::vector output; - std::vector output; + for (; begin != end; ++begin) { + output.push_back(begin->first); + } - for (; begin != end; ++begin) { - output.push_back(begin->first); + return output; } - - return output; -} +} // namespace io_v1 diff --git a/DataFormats/SiPixelDigi/src/classes_def.xml b/DataFormats/SiPixelDigi/src/classes_def.xml index de7779a5c00ea..210b4cb5ce222 100755 --- a/DataFormats/SiPixelDigi/src/classes_def.xml +++ b/DataFormats/SiPixelDigi/src/classes_def.xml @@ -1,28 +1,28 @@ - - + + - - + + - - - - - - - - + + + + + + + + - - + + - - + + - - + + @@ -35,8 +35,8 @@ - - + +