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 | 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

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

Definition at line 52 of file CastorCondObjectContainer.h.

53 {
54 }
template<class Item >
CastorCondObjectContainer< Item >::~CastorCondObjectContainer ( )

Definition at line 57 of file CastorCondObjectContainer.h.

58 {
59 }

Member Function Documentation

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

Definition at line 110 of file CastorCondObjectContainer.h.

References Exception, cmsHarvester::index, and summarizeEdmComparisonLogfiles::success.

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

Definition at line 99 of file CastorCondObjectContainer.h.

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

Definition at line 134 of file CastorCondObjectContainer.h.

References i.

Referenced by CastorDbService::buildCalibrations(), and CastorDbService::buildCalibWidths().

135 {
136  std::vector<DetId> channels;
137  Item emptyItem;
138  for (unsigned int i=0; i<CASTORcontainer.size(); i++)
139  {
140  if (emptyItem.rawId() != CASTORcontainer.at(i).rawId() )
141  channels.push_back( DetId(CASTORcontainer.at(i).rawId()) );
142  }
143 
144  return channels;
145 }
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 74 of file CastorCondObjectContainer.h.

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

Referenced by CastorDbService::getCastorChannelStatus(), CastorDbService::getGain(), CastorDbService::getGainWidth(), CastorDbService::getPedestal(), and CastorDbService::getPedestalWidth().

75 {
76  const Item* cell = NULL;
77  HcalCastorDetId myId(fId);
78 
80  unsigned int index = hashed_id(fId);
81 
82  if (index < CASTORcontainer.size())
83  cell = &(CASTORcontainer.at(index) );
84  }
85 
86 
87  if ((!cell) || (cell->rawId() != fId ) ) {
88  if (throwOnFail) {
89  throw cms::Exception ("Conditions not found")
90  << "Unavailable Conditions of type " << myname() << " for cell " << myId;
91  } else {
92  cell=0;
93  }
94  }
95  return cell;
96 }
#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 149 of file CastorCondObjectContainer.h.

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

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

Definition at line 62 of file CastorCondObjectContainer.h.

References i, and HcalCastorDetId::kSizeForDenseIndexing.

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

Definition at line 38 of file CastorCondObjectContainer.h.

38 {return (std::string)"Castor Undefined";}
template<class Item>
template<class Archive >
void CastorCondObjectContainer< Item >::serialize ( Archive &  ar,
const unsigned int  version 
)
private

Friends And Related Function Documentation

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

Definition at line 46 of file CastorCondObjectContainer.h.

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

Definition at line 46 of file CastorCondObjectContainer.h.

Member Data Documentation

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

Definition at line 44 of file CastorCondObjectContainer.h.