CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalCholeskyMatrices.cc
Go to the documentation of this file.
2 
4 {
5 }
6 
8 {
9 }
10 
11 void
13 {
14  HcalCholeskyMatrix emptyItem;
15 
16  if (fId.det()==DetId::Hcal) {
17  switch (HcalSubdetector(fId.subdetId())) {
18  case(HcalBarrel) : for (unsigned int i=0; i<sizeFor(fId); i++) HBcontainer.push_back(emptyItem); break;
19  case(HcalEndcap) : for (unsigned int i=0; i<sizeFor(fId); i++) HEcontainer.push_back(emptyItem); break;
20  case(HcalOuter) : for (unsigned int i=0; i<sizeFor(fId); i++) HOcontainer.push_back(emptyItem); break;
21  case(HcalForward) : for (unsigned int i=0; i<sizeFor(fId); i++) HFcontainer.push_back(emptyItem); break;
22  default: break;
23  }
24 }
25 }
26 
27 
28 const HcalCholeskyMatrix*
29 HcalCholeskyMatrices::getValues(DetId fId, bool throwOnFail) const
30 {
31  unsigned int index = indexFor(fId);
32  const HcalCholeskyMatrix* cell = NULL;
33  if (index<0xFFFFFFFFu) {
34  if (fId.det()==DetId::Hcal) {
35  switch (HcalSubdetector(fId.subdetId())) {
36  case(HcalBarrel) : if (index < HBcontainer.size()) cell = &(HBcontainer.at(index) );
37  case(HcalEndcap) : if (index < HEcontainer.size()) cell = &(HEcontainer.at(index) );
38  case(HcalForward) : if (index < HFcontainer.size()) cell = &(HFcontainer.at(index) );
39  case(HcalOuter) : if (index < HOcontainer.size()) cell = &(HOcontainer.at(index) );
40  default: break;
41  }
42  }
43  }
44 
45  // HcalCholeskyMatrix emptyHcalCholeskyMatrix;
46  // if (cell->rawId() == emptyHcalCholeskyMatrix.rawId() )
47  if ((!cell) || (cell->rawId() != fId ) ) {
48  if (throwOnFail) {
49  throw cms::Exception ("Conditions not found")
50  << "Unavailable Conditions of type " << myname() << " for cell " << fId.rawId();
51  } else {
52  cell=0;
53  }
54  }
55  return cell;
56 }
57 
58 const bool
60 {
61 
62  const HcalCholeskyMatrix* cell = getValues(fId,false);
63 
64  // HcalCholeskyMatrix emptyHcalCholeskyMatrix;
65  if (cell)
66  // if (cell->rawId() != emptyHcalCholeskyMatrix.rawId() )
67  if (cell->rawId() == fId )
68  return true;
69 
70  return false;
71 }
72 
73 bool
75 {
76  bool success = false;
77  DetId fId(myItem.rawId());
78  unsigned int index=indexFor(fId);
79 
80  HcalCholeskyMatrix* cell = NULL;
81 
82  if (index<0xFFFFFFFu) {
83  if (fId.det()==DetId::Hcal) {
84  switch (HcalSubdetector(fId.subdetId())) {
85  case(HcalBarrel) : if (!HBcontainer.size() ) initContainer(fId);
86  if (index < HBcontainer.size()) cell = &(HBcontainer.at(index) ); break;
87  case(HcalEndcap) : if (!HEcontainer.size() ) initContainer(fId);
88  if (index < HEcontainer.size()) cell = &(HEcontainer.at(index) ); break;
89  case(HcalForward) : if (!HFcontainer.size() ) initContainer(fId);
90  if (index < HFcontainer.size()) cell = &(HFcontainer.at(index) ); break;
91  case(HcalOuter) : if (!HOcontainer.size() ) initContainer(fId);
92  if (index < HOcontainer.size()) cell = &(HOcontainer.at(index) ); break;
93  default: break;
94  }
95  }
96  }
97 
98  if (cell!=0) {
99  (*cell)=myItem;
100  success = true;
101  }
102 
103  if (!success)
104  throw cms::Exception ("Filling of conditions failed")
105  << " no valid filling possible for Conditions of type " << myname() << " for DetId " << fId.rawId();
106  return success;
107 }
108 
109 std::vector<DetId>
111 {
112  std::vector<DetId> channels;
113  HcalCholeskyMatrix emptyHcalCholeskyMatrix;
114  for (unsigned int i=0; i<HBcontainer.size(); i++)
115  {
116  if (emptyHcalCholeskyMatrix.rawId() != HBcontainer.at(i).rawId() )
117  channels.push_back( DetId(HBcontainer.at(i).rawId()) );
118  }
119  for (unsigned int i=0; i<HEcontainer.size(); i++)
120  {
121  if (emptyHcalCholeskyMatrix.rawId() != HEcontainer.at(i).rawId() )
122  channels.push_back( DetId(HEcontainer.at(i).rawId()) );
123  }
124  for (unsigned int i=0; i<HOcontainer.size(); i++)
125  {
126  if (emptyHcalCholeskyMatrix.rawId() != HOcontainer.at(i).rawId() )
127  channels.push_back( DetId(HOcontainer.at(i).rawId()) );
128  }
129  for (unsigned int i=0; i<HFcontainer.size(); i++)
130  {
131  if (emptyHcalCholeskyMatrix.rawId() != HFcontainer.at(i).rawId() )
132  channels.push_back( DetId(HFcontainer.at(i).rawId()) );
133  }
134  return channels;
135 }
136 
const bool exists(DetId fId) const
int i
Definition: DBlmapReader.cc:9
unsigned int indexFor(DetId) const
std::vector< HcalCholeskyMatrix > HOcontainer
#define NULL
Definition: scimark2.h:8
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
std::vector< DetId > getAllChannels() const
unsigned int sizeFor(DetId) const
bool addValues(const HcalCholeskyMatrix &myHcalCholeskyMatrix)
HcalSubdetector
Definition: HcalAssistant.h:31
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
Definition: DetId.h:18
void initContainer(DetId fId)
std::vector< HcalCholeskyMatrix > HFcontainer
std::string myname() const
uint32_t rawId() const
std::vector< HcalCholeskyMatrix > HBcontainer
const HcalCholeskyMatrix * getValues(DetId fId, bool throwOnFail=true) const
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
std::vector< HcalCholeskyMatrix > HEcontainer