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_
 
boost::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 30 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 37 of file HcalItemCollById.h.

41  : coll_(coll),
42  lookup_(indexLookupTable),
43  default_(defaultItem.release()),
44  transformCode_(detIdTransformCode)
45  {
46  // Check that the lookup table is valid for this application
48  throw cms::Exception("In HcalItemCollById constructor:"
49  " invalid lookup table");
50 
51  // Check that the lookup table is consistent with the size
52  // of the collection
53  const unsigned maxIndex = lookup_.largestIndex();
54  if (maxIndex != HcalIndexLookup::InvalidIndex &&
55  maxIndex >= coll_.size())
56  throw cms::Exception("In HcalItemCollById constructor:"
57  " collection and lookup table are inconsistent");
58 
60  }
HcalItemColl< Item > coll_
HcalIndexLookup lookup_
boost::shared_ptr< Item > default_
unsigned largestIndex() const
void validateCode(unsigned transformCode)
static const unsigned InvalidIndex
template<typename Item>
HcalItemCollById< Item >::~HcalItemCollById ( )
inlineoverride

Definition at line 62 of file HcalItemCollById.h.

62 {}

Member Function Documentation

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

Definition at line 95 of file HcalItemCollById.h.

Referenced by HFFlexibleTimeCheck::reconstruct().

96  {
97  const Item* ptr = getByIndex(getIndex(id));
98  if (ptr == nullptr) throw cms::Exception(
99  "In HcalItemCollById::at: invalid detector id");
100  return *ptr;
101  }
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 82 of file HcalItemCollById.h.

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

83  {
84  if (index < coll_.size()) return coll_.get(index);
85  else return default_.get();
86  }
HcalItemColl< Item > coll_
boost::shared_ptr< Item > default_
template<typename Item>
const Item* HcalItemCollById< Item >::getDefault ( ) const
inline

Definition at line 72 of file HcalItemCollById.h.

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

Definition at line 75 of file HcalItemCollById.h.

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

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 104 of file HcalItemCollById.h.

105  {
106  const HcalItemCollById& r =
107  static_cast<const HcalItemCollById&>(other);
108  if (coll_ != r.coll_)
109  return false;
110  if (lookup_ != r.lookup_)
111  return false;
113  return false;
114  // The default may or may not be there
115  const bool ld = default_.get();
116  const bool rd = r.default_.get();
117  if (ld != rd)
118  return false;
119  if (ld)
120  if (!(*default_ == *r.default_))
121  return false;
122  return true;
123  }
HcalItemColl< Item > coll_
HcalIndexLookup lookup_
boost::shared_ptr< Item > default_
template<typename Item>
template<class Archive >
void HcalItemCollById< Item >::serialize ( Archive &  ar,
unsigned   
)
inlineprivate

Definition at line 134 of file HcalItemCollById.h.

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

Definition at line 65 of file HcalItemCollById.h.

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

66  {default_ = boost::shared_ptr<Item>(f.release());}
boost::shared_ptr< Item > default_
double f[11][100]
template<typename Item>
std::size_t HcalItemCollById< Item >::size ( void  ) const
inline

Definition at line 69 of file HcalItemCollById.h.

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

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

Friends And Related Function Documentation

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

Definition at line 131 of file HcalItemCollById.h.

Member Data Documentation

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