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

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

Definition at line 29 of file HcalItemCollById.h.

Constructor & Destructor Documentation

template<typename Item>
HcalItemCollById< Item >::HcalItemCollById ( )
inline
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.

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();
49  if (maxIndex != HcalIndexLookup::InvalidIndex && maxIndex >= coll_.size())
50  throw cms::Exception(
51  "In HcalItemCollById constructor:"
52  " collection and lookup table are inconsistent");
53 
55  }
HcalItemColl< Item > coll_
HcalIndexLookup lookup_
unsigned largestIndex() const
void validateCode(unsigned transformCode)
std::shared_ptr< Item > default_
static const unsigned InvalidIndex
template<typename Item>
HcalItemCollById< Item >::~HcalItemCollById ( )
inlineoverride

Definition at line 57 of file HcalItemCollById.h.

57 {}

Member Function Documentation

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

Definition at line 90 of file HcalItemCollById.h.

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
template<typename Item>
const Item* HcalItemCollById< Item >::get ( const HcalDetId id) const
inline
template<typename Item>
const Item* HcalItemCollById< Item >::getByIndex ( const unsigned  index) const
inline

Definition at line 77 of file HcalItemCollById.h.

Referenced by HcalItemCollById< HFPhase1PMTData >::at(), and HcalItemCollById< HFPhase1PMTData >::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_
template<typename Item>
const Item* HcalItemCollById< Item >::getDefault ( ) const
inline

Definition at line 66 of file HcalItemCollById.h.

66 { return default_.get(); }
std::shared_ptr< Item > default_
template<typename Item>
unsigned HcalItemCollById< Item >::getIndex ( const HcalDetId id) const
inline

Definition at line 69 of file HcalItemCollById.h.

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

69  {
71  }
HcalIndexLookup lookup_
unsigned find(unsigned detId) const
unsigned transform(const HcalDetId &id, unsigned transformCode)
template<typename Item>
bool HcalItemCollById< Item >::isEqual ( const AbsHcalAlgoData other) const
inlineoverrideprotectedvirtual

Implements AbsHcalAlgoData.

Definition at line 98 of file HcalItemCollById.h.

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;
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_
template<typename Item>
template<class Archive >
void HcalItemCollById< Item >::serialize ( Archive &  ar,
unsigned   
)
inlineprivate

Definition at line 126 of file HcalItemCollById.h.

126  {
128  }
HcalItemColl< Item > coll_
HcalIndexLookup lookup_
std::shared_ptr< Item > default_
template<typename Item>
void HcalItemCollById< Item >::setDefault ( std::unique_ptr< Item >  f)
inline

Definition at line 60 of file HcalItemCollById.h.

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_
template<typename Item>
std::size_t HcalItemCollById< Item >::size ( void  ) const
inline

Definition at line 63 of file HcalItemCollById.h.

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

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

Friends And Related Function Documentation

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

Definition at line 123 of file HcalItemCollById.h.

Member Data Documentation

template<typename Item>
HcalItemColl<Item> HcalItemCollById< Item >::coll_
private
template<typename Item>
std::shared_ptr<Item> HcalItemCollById< Item >::default_
private
template<typename Item>
HcalIndexLookup HcalItemCollById< Item >::lookup_
private
template<typename Item>
uint32_t HcalItemCollById< Item >::transformCode_
private