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
12 HcalCholeskyMatrices::initContainer(int container, bool h2mode_)
13 {
14  HcalCholeskyMatrix emptyHcalCholeskyMatrix;
15 
16  switch (container)
17  {
19  for (int i=0; i<(2*HcalGenericDetId::HBhalf); i++) HBcontainer.push_back(emptyHcalCholeskyMatrix); break;
21  if (!h2mode_) for (int i=0; i<(2*HcalGenericDetId::HEhalf); i++) HEcontainer.push_back(emptyHcalCholeskyMatrix);
22  else for (int i=0; i<(2*HcalGenericDetId::HEhalfh2mode); i++) HEcontainer.push_back(emptyHcalCholeskyMatrix);
23  break;
25  for (int i=0; i<(2*HcalGenericDetId::HOhalf); i++) HOcontainer.push_back(emptyHcalCholeskyMatrix); break;
27  for (int i=0; i<(2*HcalGenericDetId::HFhalf); i++) HFcontainer.push_back(emptyHcalCholeskyMatrix); break;
28  default: break;
29  }
30 }
31 
32 
33 const HcalCholeskyMatrix*
35 {
36  HcalGenericDetId myId(fId);
37  bool h2mode_ = (HEcontainer.size()==(2*HcalGenericDetId::HEhalfh2mode));
38 
39  int index = myId.hashedId(h2mode_);
40  // std::cout << "::::: getting values at index " << index << ", DetId " << myId << std::endl;
41  unsigned int index1 = abs(index); // b/c I'm fed up with compiler warnings about comparison betw. signed and unsigned int
42 
43  const HcalCholeskyMatrix* cell = NULL;
44  if (index >= 0)
45  switch (myId.genericSubdet() ) {
47  if (index1 < HBcontainer.size())
48  cell = &(HBcontainer.at(index1) );
49  break;
51  if (index1 < HEcontainer.size())
52  cell = &(HEcontainer.at(index1) );
53  break;
55  if (index1 < HOcontainer.size())
56  cell = &(HOcontainer.at(index1) );
57  break;
59  if (index1 < HFcontainer.size())
60  cell = &(HFcontainer.at(index1) );
61  break;
62  default: break;
63  }
64 
65  // HcalCholeskyMatrix emptyHcalCholeskyMatrix;
66  // if (cell->rawId() == emptyHcalCholeskyMatrix.rawId() )
67  if ((!cell) || (cell->rawId() != fId ) )
68  throw cms::Exception ("Conditions not found")
69  << "Unavailable Conditions of type " << myname() << " for cell " << myId;
70  return cell;
71 }
72 
73 const bool
75 {
76  HcalGenericDetId myId(fId);
77  bool h2mode_ = (HEcontainer.size()==(2*HcalGenericDetId::HEhalfh2mode));
78 
79  int index = myId.hashedId(h2mode_);
80  if (index < 0) return false;
81  unsigned int index1 = abs(index); // b/c I'm fed up with compiler warnings about comparison betw. signed and unsigned int
82  const HcalCholeskyMatrix* cell = NULL;
83  switch (myId.genericSubdet() ) {
85  if (index1 < HBcontainer.size()) cell = &(HBcontainer.at(index1) );
86  break;
88  if (index1 < HEcontainer.size()) cell = &(HEcontainer.at(index1) );
89  break;
91  if (index1 < HOcontainer.size()) cell = &(HOcontainer.at(index1) );
92  break;
94  if (index1 < HFcontainer.size()) cell = &(HFcontainer.at(index1) );
95  break;
96  default: return false; break;
97  }
98 
99  // HcalCholeskyMatrix emptyHcalCholeskyMatrix;
100  if (cell)
101  // if (cell->rawId() != emptyHcalCholeskyMatrix.rawId() )
102  if (cell->rawId() == fId )
103  return true;
104 
105  return false;
106 }
107 
108 bool
109 HcalCholeskyMatrices::addValues(const HcalCholeskyMatrix& myHcalCholeskyMatrix, bool h2mode_)
110 {
111  unsigned long myRawId = myHcalCholeskyMatrix.rawId();
112  HcalGenericDetId myId(myRawId);
113  int index = myId.hashedId(h2mode_);
114  bool success = false;
115  if (index < 0) success = false;
116  unsigned int index1 = abs(index); // b/c I'm fed up with compiler warnings about comparison betw. signed and unsigned int
117 
118  switch (myId.genericSubdet() ) {
120  if (!HBcontainer.size() ) initContainer(myId.genericSubdet() );
121  if (index1 < HBcontainer.size())
122  {
123  HBcontainer.at(index1) = myHcalCholeskyMatrix;
124  success = true;
125  }
126  break;
128  if (!HEcontainer.size() ) initContainer(myId.genericSubdet(), h2mode_ );
129  if (index1 < HEcontainer.size())
130  {
131  HEcontainer.at(index1) = myHcalCholeskyMatrix;
132  success = true;
133  }
134  break;
136  if (!HOcontainer.size() ) initContainer(myId.genericSubdet() );
137  if (index1 < HOcontainer.size())
138  {
139  HOcontainer.at(index1) = myHcalCholeskyMatrix;
140  success = true;
141  }
142  break;
144  if (!HFcontainer.size() ) initContainer(myId.genericSubdet() );
145  if (index1 < HFcontainer.size())
146  {
147  HFcontainer.at(index1) = myHcalCholeskyMatrix;
148  success = true;
149  }
150  break;
151  default: break;
152  }
153 
154  if (!success)
155  throw cms::Exception ("Filling of conditions failed")
156  << " no valid filling possible for Conditions of type " << myname() << " for DetId " << myId;
157  return success;
158 }
159 
160 std::vector<DetId>
162 {
163  std::vector<DetId> channels;
164  HcalCholeskyMatrix emptyHcalCholeskyMatrix;
165  for (unsigned int i=0; i<HBcontainer.size(); i++)
166  {
167  if (emptyHcalCholeskyMatrix.rawId() != HBcontainer.at(i).rawId() )
168  channels.push_back( DetId(HBcontainer.at(i).rawId()) );
169  }
170  for (unsigned int i=0; i<HEcontainer.size(); i++)
171  {
172  if (emptyHcalCholeskyMatrix.rawId() != HEcontainer.at(i).rawId() )
173  channels.push_back( DetId(HEcontainer.at(i).rawId()) );
174  }
175  for (unsigned int i=0; i<HOcontainer.size(); i++)
176  {
177  if (emptyHcalCholeskyMatrix.rawId() != HOcontainer.at(i).rawId() )
178  channels.push_back( DetId(HOcontainer.at(i).rawId()) );
179  }
180  for (unsigned int i=0; i<HFcontainer.size(); i++)
181  {
182  if (emptyHcalCholeskyMatrix.rawId() != HFcontainer.at(i).rawId() )
183  channels.push_back( DetId(HFcontainer.at(i).rawId()) );
184  }
185  return channels;
186 }
187 
const bool exists(DetId fId) const
int i
Definition: DBlmapReader.cc:9
int hashedId(bool h2mode_=false) const
std::vector< HcalCholeskyMatrix > HOcontainer
#define abs(x)
Definition: mlp_lapack.h:159
#define NULL
Definition: scimark2.h:8
std::vector< DetId > getAllChannels() const
void initContainer(int container, bool h2mode_=false)
bool addValues(const HcalCholeskyMatrix &myHcalCholeskyMatrix, bool h2mode_=false)
Definition: DetId.h:20
std::vector< HcalCholeskyMatrix > HFcontainer
std::string myname() const
const HcalCholeskyMatrix * getValues(DetId fId) const
uint32_t rawId() const
HcalGenericSubdetector genericSubdet() const
std::vector< HcalCholeskyMatrix > HBcontainer
std::vector< HcalCholeskyMatrix > HEcontainer