CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends
HcalItemCollById< Item > Class Template Reference

#include <HcalItemCollById.h>

Inheritance diagram for HcalItemCollById< Item >:
AbsHcalAlgoData

Public Types

typedef Item value_type
 

Public Member Functions

const Item & at (const HcalDetId &id) const
 
const Item * get (const HcalDetId &id) const
 
const Item * getByIndex (const unsigned index) const
 
const Item * getDefault () const
 
unsigned getIndex (const HcalDetId &id) const
 
 HcalItemCollById ()
 
 HcalItemCollById (const HcalItemColl< Item > &coll, const HcalIndexLookup &indexLookupTable, const unsigned detIdTransformCode, std::unique_ptr< Item > defaultItem)
 
void setDefault (std::unique_ptr< Item > f)
 
std::size_t size () const
 
 ~HcalItemCollById () override
 
- Public Member Functions inherited from AbsHcalAlgoData
bool operator!= (const AbsHcalAlgoData &r) const
 
bool operator== (const AbsHcalAlgoData &r) const
 
virtual ~AbsHcalAlgoData ()
 

Protected Member Functions

bool isEqual (const AbsHcalAlgoData &other) const override
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar, unsigned)
 

Private Attributes

HcalItemColl< Item > coll_
 
std::shared_ptr< Item > default_
 
HcalIndexLookup lookup_
 
uint32_t transformCode_
 

Friends

class boost::serialization::access
 

Detailed Description

template<typename Item>
class HcalItemCollById< Item >

Definition at line 27 of file HcalItemCollById.h.

Member Typedef Documentation

◆ value_type

template<typename Item >
typedef Item HcalItemCollById< Item >::value_type

Definition at line 29 of file HcalItemCollById.h.

Constructor & Destructor Documentation

◆ HcalItemCollById() [1/2]

template<typename Item >
HcalItemCollById< Item >::HcalItemCollById ( )
inline

◆ HcalItemCollById() [2/2]

template<typename Item >
HcalItemCollById< Item >::HcalItemCollById ( const HcalItemColl< Item > &  coll,
const HcalIndexLookup indexLookupTable,
const unsigned  detIdTransformCode,
std::unique_ptr< Item >  defaultItem 
)
inline

Definition at line 35 of file HcalItemCollById.h.

References HcalItemCollById< Item >::coll_, HcalIndexLookup::hasDuplicateIds(), HcalIndexLookup::InvalidIndex, HcalIndexLookup::largestIndex(), HcalItemCollById< Item >::lookup_, ApeEstimator_cff::maxIndex, HcalItemCollById< Item >::transformCode_, and HcalDetIdTransform::validateCode().

39  : coll_(coll), lookup_(indexLookupTable), default_(defaultItem.release()), transformCode_(detIdTransformCode) {
40  // Check that the lookup table is valid for this application
42  throw cms::Exception(
43  "In HcalItemCollById constructor:"
44  " invalid lookup table");
45 
46  // Check that the lookup table is consistent with the size
47  // of the collection
48  const unsigned maxIndex = lookup_.largestIndex();
50  throw cms::Exception(
51  "In HcalItemCollById constructor:"
52  " collection and lookup table are inconsistent");
53 
55  }
unsigned largestIndex() const
HcalItemColl< Item > coll_
HcalIndexLookup lookup_
void validateCode(unsigned transformCode)
std::shared_ptr< Item > default_
static const unsigned InvalidIndex

◆ ~HcalItemCollById()

template<typename Item >
HcalItemCollById< Item >::~HcalItemCollById ( )
inlineoverride

Definition at line 57 of file HcalItemCollById.h.

57 {}

Member Function Documentation

◆ at()

template<typename Item >
const Item& HcalItemCollById< Item >::at ( const HcalDetId id) const
inline

Definition at line 90 of file HcalItemCollById.h.

References Exception, HcalItemCollById< Item >::getByIndex(), and HcalItemCollById< Item >::getIndex().

Referenced by HFFlexibleTimeCheck::reconstruct().

90  {
91  const Item* ptr = getByIndex(getIndex(id));
92  if (ptr == nullptr)
93  throw cms::Exception("In HcalItemCollById::at: invalid detector id");
94  return *ptr;
95  }
unsigned getIndex(const HcalDetId &id) const
const Item * getByIndex(const unsigned index) const

◆ get()

template<typename Item >
const Item* HcalItemCollById< Item >::get ( const HcalDetId id) const
inline

◆ getByIndex()

template<typename Item >
const Item* HcalItemCollById< Item >::getByIndex ( const unsigned  index) const
inline

Definition at line 77 of file HcalItemCollById.h.

References HcalItemCollById< Item >::coll_, and HcalItemCollById< Item >::default_.

Referenced by HcalItemCollById< Item >::at(), and HcalItemCollById< Item >::get().

77  {
78  if (index < coll_.size())
79  return coll_.get(index);
80  else
81  return default_.get();
82  }
HcalItemColl< Item > coll_
std::shared_ptr< Item > default_

◆ getDefault()

template<typename Item >
const Item* HcalItemCollById< Item >::getDefault ( ) const
inline

Definition at line 66 of file HcalItemCollById.h.

References HcalItemCollById< Item >::default_.

66 { return default_.get(); }
std::shared_ptr< Item > default_

◆ getIndex()

template<typename Item >
unsigned HcalItemCollById< Item >::getIndex ( const HcalDetId id) const
inline

Definition at line 69 of file HcalItemCollById.h.

References HcalIndexLookup::find(), HcalItemCollById< Item >::lookup_, HcalDetIdTransform::transform(), and HcalItemCollById< Item >::transformCode_.

Referenced by HcalItemCollById< Item >::at(), and HcalItemCollById< Item >::get().

69  {
71  }
HcalIndexLookup lookup_
unsigned find(unsigned detId) const
unsigned transform(const HcalDetId &id, unsigned transformCode)

◆ isEqual()

template<typename Item >
bool HcalItemCollById< Item >::isEqual ( const AbsHcalAlgoData other) const
inlineoverrideprotectedvirtual

Implements AbsHcalAlgoData.

Definition at line 98 of file HcalItemCollById.h.

References HcalItemCollById< Item >::coll_, HcalItemCollById< Item >::default_, HcalItemCollById< Item >::lookup_, trackingPlots::other, alignCSCRings::r, and HcalItemCollById< Item >::transformCode_.

98  {
99  const HcalItemCollById& r = static_cast<const HcalItemCollById&>(other);
100  if (coll_ != r.coll_)
101  return false;
102  if (lookup_ != r.lookup_)
103  return false;
104  if (transformCode_ != r.transformCode_)
105  return false;
106  // The default may or may not be there
107  const bool ld = default_.get();
108  const bool rd = r.default_.get();
109  if (ld != rd)
110  return false;
111  if (ld)
112  if (!(*default_ == *r.default_))
113  return false;
114  return true;
115  }
HcalItemColl< Item > coll_
HcalIndexLookup lookup_
std::shared_ptr< Item > default_

◆ serialize()

template<typename Item >
template<class Archive >
void HcalItemCollById< Item >::serialize ( Archive &  ar,
unsigned   
)
inlineprivate

◆ setDefault()

template<typename Item >
void HcalItemCollById< Item >::setDefault ( std::unique_ptr< Item >  f)
inline

Definition at line 60 of file HcalItemCollById.h.

References HcalItemCollById< Item >::default_, and f.

Referenced by VarParsing.VarParsing::__setattr__(), VarParsing.VarParsing::parseArguments(), and VarParsing.VarParsing::setType().

60 { default_ = std::shared_ptr<Item>(f.release()); }
double f[11][100]
std::shared_ptr< Item > default_

◆ size()

template<typename Item >
std::size_t HcalItemCollById< Item >::size ( void  ) const
inline

Definition at line 63 of file HcalItemCollById.h.

References HcalItemCollById< Item >::coll_.

Referenced by ntupleDataFormat._Collection::__iter__(), and ntupleDataFormat._Collection::__len__().

63 { return coll_.size(); }
HcalItemColl< Item > coll_

Friends And Related Function Documentation

◆ boost::serialization::access

template<typename Item >
friend class boost::serialization::access
friend

Definition at line 123 of file HcalItemCollById.h.

Member Data Documentation

◆ coll_

template<typename Item >
HcalItemColl<Item> HcalItemCollById< Item >::coll_
private

◆ default_

template<typename Item >
std::shared_ptr<Item> HcalItemCollById< Item >::default_
private

◆ lookup_

template<typename Item >
HcalIndexLookup HcalItemCollById< Item >::lookup_
private

◆ transformCode_

template<typename Item >
uint32_t HcalItemCollById< Item >::transformCode_
private