CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
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 ()
 

Private Attributes

std::vector< Item > CASTORcontainer
 

Detailed Description

template<class Item>
class CastorCondObjectContainer< Item >

Definition at line 14 of file CastorCondObjectContainer.h.

Constructor & Destructor Documentation

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

Definition at line 48 of file CastorCondObjectContainer.h.

49 {
50 }
template<class Item >
CastorCondObjectContainer< Item >::~CastorCondObjectContainer ( )

Definition at line 53 of file CastorCondObjectContainer.h.

54 {
55 }

Member Function Documentation

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

Definition at line 106 of file CastorCondObjectContainer.h.

References edm::hlt::Exception, getHLTprescales::index, and summarizeEdmComparisonLogfiles::success.

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

107 {
108  unsigned long myRawId = myItem.rawId();
109  HcalCastorDetId myId(myRawId);
110  unsigned int index = hashed_id(myId);
111  bool success = false;
112 
113 
114  if (CASTORcontainer.empty() ) initContainer();
115  if (index < CASTORcontainer.size())
116  {
117  CASTORcontainer.at(index) = myItem;
118  success = true;
119  }
120 
121 
122  if (!success)
123  throw cms::Exception ("Filling of conditions failed")
124  << " no valid filling possible for Conditions of type " << myname() << " for DetId " << myId;
125 
126  return success;
127 }
unsigned int hashed_id(DetId fId) const
template<class Item >
const bool CastorCondObjectContainer< Item >::exists ( DetId  fId) const

Definition at line 95 of file CastorCondObjectContainer.h.

96 {
97  const Item* cell = getValues(fId,false);
98  if (cell)
99  // if (cell->rawId() != emptyItem.rawId() )
100  if (cell->rawId() == fId )
101  return true;
102  return false;
103 }
const Item * getValues(DetId fId, bool throwOnFail=true) const
template<class Item >
std::vector< DetId > CastorCondObjectContainer< Item >::getAllChannels ( ) const

Definition at line 130 of file CastorCondObjectContainer.h.

References i.

Referenced by CastorDbService::buildCalibrations(), CastorDbService::buildCalibWidths(), CastorPedestalAnalysis::CastorPedVal(), and CastorDbXml::dumpObject().

131 {
132  std::vector<DetId> channels;
133  Item emptyItem;
134  for (unsigned int i=0; i<CASTORcontainer.size(); i++)
135  {
136  if (emptyItem.rawId() != CASTORcontainer.at(i).rawId() )
137  channels.push_back( DetId(CASTORcontainer.at(i).rawId()) );
138  }
139 
140  return channels;
141 }
int i
Definition: DBlmapReader.cc:9
Definition: DetId.h:18
template<class Item >
const Item * CastorCondObjectContainer< Item >::getValues ( DetId  fId,
bool  throwOnFail = true 
) const

Definition at line 70 of file CastorCondObjectContainer.h.

References DetId::Calo, DetId::det(), edm::hlt::Exception, getHLTprescales::index, NULL, HcalCastorDetId::SubdetectorId, and DetId::subdetId().

Referenced by CastorPedestalAnalysis::CastorPedVal(), CastorDbXml::dumpObject(), CastorDbService::getCastorChannelStatus(), CastorDbService::getGain(), CastorDbService::getGainWidth(), CastorDbService::getPedestal(), and CastorDbService::getPedestalWidth().

71 {
72  const Item* cell = NULL;
73  HcalCastorDetId myId(fId);
74 
76  unsigned int index = hashed_id(fId);
77 
78  if (index < CASTORcontainer.size())
79  cell = &(CASTORcontainer.at(index) );
80  }
81 
82 
83  if ((!cell) || (cell->rawId() != fId ) ) {
84  if (throwOnFail) {
85  throw cms::Exception ("Conditions not found")
86  << "Unavailable Conditions of type " << myname() << " for cell " << myId;
87  } else {
88  cell=0;
89  }
90  }
91  return cell;
92 }
#define NULL
Definition: scimark2.h:8
unsigned int hashed_id(DetId fId) const
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
static const int SubdetectorId
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
template<class Item >
unsigned int CastorCondObjectContainer< Item >::hashed_id ( DetId  fId) const
private

Definition at line 145 of file CastorCondObjectContainer.h.

References getHLTprescales::index, HcalCastorDetId::module(), HcalCastorDetId::sector(), and HcalCastorDetId::zside().

145  {
146  // the historical packing from HcalGeneric is different from HcalCastorDetId, so we clone the old packing here.
147  HcalCastorDetId tid(fId);
148  int zside = tid.zside();
149  int sector = tid.sector();
150  int module = tid.module();
151  static const int CASTORhalf=224;
152 
153  int index = 14*(sector-1) + (module-1);
154  if (zside == -1) index += CASTORhalf;
155 
156  return index;
157 }
module()
Definition: vlib.cc:994
Definition: vlib.h:208
template<class Item >
void CastorCondObjectContainer< Item >::initContainer ( )
private

Definition at line 58 of file CastorCondObjectContainer.h.

References i, and HcalCastorDetId::kSizeForDenseIndexing.

59 {
60  Item emptyItem;
61 
62  if (CASTORcontainer.empty())
64  CASTORcontainer.push_back(emptyItem);
65 
66 }
int i
Definition: DBlmapReader.cc:9
template<class Item>
std::string CastorCondObjectContainer< Item >::myname ( ) const
inline

Definition at line 36 of file CastorCondObjectContainer.h.

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

Member Data Documentation

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

Definition at line 42 of file CastorCondObjectContainer.h.