CMS 3D CMS Logo

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

#include <CastorCondObjectContainer.h>

Public Member Functions

bool addValues (const Item &myItem)
 
 CastorCondObjectContainer ()
 
const bool exists (DetId fId) const
 
std::vector< DetIdgetAllChannels () const
 
const Item * getValues (DetId fId, bool throwOnFail=true) const
 
std::string myname () const
 
 ~CastorCondObjectContainer ()
 

Private Member Functions

unsigned int hashed_id (DetId fId) const
 
void initContainer ()
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Private Attributes

std::vector< Item > CASTORcontainer
 

Friends

class boost::serialization::access
 
template<typename CondSerializationT , typename Enabled >
struct cond::serialization::access
 

Detailed Description

template<class Item>
class CastorCondObjectContainer< Item >

Definition at line 16 of file CastorCondObjectContainer.h.

Constructor & Destructor Documentation

◆ CastorCondObjectContainer()

template<class Item >
CastorCondObjectContainer< Item >::CastorCondObjectContainer ( )

Definition at line 50 of file CastorCondObjectContainer.h.

50 {}

◆ ~CastorCondObjectContainer()

template<class Item >
CastorCondObjectContainer< Item >::~CastorCondObjectContainer ( )

Definition at line 53 of file CastorCondObjectContainer.h.

53 {}

Member Function Documentation

◆ addValues()

template<class Item>
bool CastorCondObjectContainer< Item >::addValues ( const Item &  myItem)

Definition at line 98 of file CastorCondObjectContainer.h.

Referenced by CastorPedestalAnalysis::CastorPedVal(), CastorDbXml::dumpObject(), CastorDbASCIIIO::getObject(), CastorPedestalAnalysis::GetPedConst(), and CastorPedestalsAnalysis::~CastorPedestalsAnalysis().

98  {
99  unsigned long myRawId = myItem.rawId();
100  HcalCastorDetId myId(myRawId);
101  unsigned int index = hashed_id(myId);
102  bool success = false;
103 
104  if (CASTORcontainer.empty())
105  initContainer();
106  if (index < CASTORcontainer.size()) {
107  CASTORcontainer.at(index) = myItem;
108  success = true;
109  }
110 
111  if (!success)
112  throw cms::Exception("Filling of conditions failed")
113  << " no valid filling possible for Conditions of type " << myname() << " for DetId " << myId;
114 
115  return success;
116 }
unsigned int hashed_id(DetId fId) const

◆ exists()

template<class Item >
const bool CastorCondObjectContainer< Item >::exists ( DetId  fId) const

Definition at line 88 of file CastorCondObjectContainer.h.

Referenced by CastorDbASCIIIO::getObject().

88  {
89  const Item* cell = getValues(fId, false);
90  if (cell)
91  // if (cell->rawId() != emptyItem.rawId() )
92  if (cell->rawId() == fId)
93  return true;
94  return false;
95 }
const Item * getValues(DetId fId, bool throwOnFail=true) const

◆ getAllChannels()

template<class Item >
std::vector< DetId > CastorCondObjectContainer< Item >::getAllChannels ( ) const

Definition at line 119 of file CastorCondObjectContainer.h.

Referenced by CastorDbService::buildCalibrations(), CastorDbService::buildCalibWidths(), CastorPedestalAnalysis::CastorPedVal(), CastorDbXml::dumpObject(), CastorDbASCIIIO::dumpObject(), CastorDigiMonitor::getDbData(), and RecHitCorrector::produce().

119  {
120  std::vector<DetId> channels;
121  Item emptyItem;
122  for (unsigned int i = 0; i < CASTORcontainer.size(); i++) {
123  if (emptyItem.rawId() != CASTORcontainer.at(i).rawId())
124  channels.push_back(DetId(CASTORcontainer.at(i).rawId()));
125  }
126 
127  return channels;
128 }
Definition: DetId.h:17

◆ getValues()

template<class Item >
const Item * CastorCondObjectContainer< Item >::getValues ( DetId  fId,
bool  throwOnFail = true 
) const

Definition at line 65 of file CastorCondObjectContainer.h.

Referenced by CastorPedestalAnalysis::CastorPedVal(), CastorDbXml::dumpObject(), CastorDbASCIIIO::dumpObject(), CastorDbService::getCastorChannelStatus(), CastorDigiMonitor::getDbData(), CastorDbService::getGain(), CastorDbService::getGainWidth(), CastorDbService::getPedestal(), CastorDbService::getPedestalWidth(), CastorSimpleReconstructor::produce(), and RecHitCorrector::produce().

65  {
66  const Item* cell = nullptr;
67  HcalCastorDetId myId(fId);
68 
69  if (fId.det() == DetId::Calo && fId.subdetId() == HcalCastorDetId::SubdetectorId) {
70  unsigned int index = hashed_id(fId);
71 
72  if (index < CASTORcontainer.size())
73  cell = &(CASTORcontainer.at(index));
74  }
75 
76  if ((!cell) || (cell->rawId() != fId)) {
77  if (throwOnFail) {
78  throw cms::Exception("Conditions not found")
79  << "Unavailable Conditions of type " << myname() << " for cell " << myId;
80  } else {
81  cell = nullptr;
82  }
83  }
84  return cell;
85 }
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
unsigned int hashed_id(DetId fId) const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
static const int SubdetectorId

◆ hashed_id()

template<class Item >
unsigned int CastorCondObjectContainer< Item >::hashed_id ( DetId  fId) const
private

Definition at line 131 of file CastorCondObjectContainer.h.

131  {
132  // the historical packing from HcalGeneric is different from HcalCastorDetId, so we clone the old packing here.
133  HcalCastorDetId tid(fId);
134  int zside = tid.zside();
135  int sector = tid.sector();
136  int module = tid.module();
137  static const int CASTORhalf = 224;
138 
139  int index = 14 * (sector - 1) + (module - 1);
140  if (zside == -1)
141  index += CASTORhalf;
142 
143  return index;
144 }
int zside(DetId const &)

◆ initContainer()

template<class Item >
void CastorCondObjectContainer< Item >::initContainer ( )
private

Definition at line 56 of file CastorCondObjectContainer.h.

56  {
57  Item emptyItem;
58 
59  if (CASTORcontainer.empty())
60  for (int i = 0; i < HcalCastorDetId::kSizeForDenseIndexing; i++)
61  CASTORcontainer.push_back(emptyItem);
62 }
static constexpr int kSizeForDenseIndexing

◆ myname()

template<class Item>
std::string CastorCondObjectContainer< Item >::myname ( ) const
inline

Definition at line 37 of file CastorCondObjectContainer.h.

37 { return (std::string) "Castor Undefined"; }

◆ serialize()

template<class Item>
template<class Archive >
void CastorCondObjectContainer< Item >::serialize ( Archive &  ar,
const unsigned int  version 
)
private

Friends And Related Function Documentation

◆ boost::serialization::access

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

Definition at line 45 of file CastorCondObjectContainer.h.

◆ cond::serialization::access

template<class Item>
template<typename CondSerializationT , typename Enabled >
friend struct cond::serialization::access
friend

Definition at line 45 of file CastorCondObjectContainer.h.

Member Data Documentation

◆ CASTORcontainer

template<class Item>
std::vector<Item> CastorCondObjectContainer< Item >::CASTORcontainer
private

Definition at line 43 of file CastorCondObjectContainer.h.