CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalCovarianceMatrices.cc
Go to the documentation of this file.
2 
3 
5 {
6 }
7 
9 {
10 }
11 
12 void
13 HcalCovarianceMatrices::initContainer(int container, bool h2mode_)
14 {
15  HcalCovarianceMatrix emptyHcalCovarianceMatrix;
16 
17  switch (container)
18  {
20  for (int i=0; i<(2*HcalGenericDetId::HBhalf); i++) HBcontainer.push_back(emptyHcalCovarianceMatrix); break;
22  if (!h2mode_) for (int i=0; i<(2*HcalGenericDetId::HEhalf); i++) HEcontainer.push_back(emptyHcalCovarianceMatrix);
23  else for (int i=0; i<(2*HcalGenericDetId::HEhalfh2mode); i++) HEcontainer.push_back(emptyHcalCovarianceMatrix);
24  break;
26  for (int i=0; i<(2*HcalGenericDetId::HOhalf); i++) HOcontainer.push_back(emptyHcalCovarianceMatrix); break;
28  for (int i=0; i<(2*HcalGenericDetId::HFhalf); i++) HFcontainer.push_back(emptyHcalCovarianceMatrix); break;
29  default: break;
30  }
31 }
32 
33 
36 {
37  HcalGenericDetId myId(fId);
38  bool h2mode_ = (HEcontainer.size()==(2*HcalGenericDetId::HEhalfh2mode));
39 
40  int index = myId.hashedId(h2mode_);
41  // std::cout << "::::: getting values at index " << index << ", DetId " << myId << std::endl;
42  unsigned int index1 = abs(index); // b/c I'm fed up with compiler warnings about comparison betw. signed and unsigned int
43 
44  const HcalCovarianceMatrix* cell = NULL;
45  if (index >= 0)
46  switch (myId.genericSubdet() ) {
48  if (index1 < HBcontainer.size())
49  cell = &(HBcontainer.at(index1) );
50  break;
52  if (index1 < HEcontainer.size())
53  cell = &(HEcontainer.at(index1) );
54  break;
56  if (index1 < HOcontainer.size())
57  cell = &(HOcontainer.at(index1) );
58  break;
60  if (index1 < HFcontainer.size())
61  cell = &(HFcontainer.at(index1) );
62  break;
63  default: break;
64  }
65 
66  // HcalCovarianceMatrix emptyHcalCovarianceMatrix;
67  // if (cell->rawId() == emptyHcalCovarianceMatrix.rawId() )
68  if ((!cell) || (cell->rawId() != fId ) )
69  throw cms::Exception ("Conditions not found")
70  << "Unavailable Conditions of type " << myname() << " for cell " << myId;
71  return cell;
72 }
73 
74 const bool
76 {
77  HcalGenericDetId myId(fId);
78  bool h2mode_ = (HEcontainer.size()==(2*HcalGenericDetId::HEhalfh2mode));
79 
80  int index = myId.hashedId(h2mode_);
81  if (index < 0) return false;
82  unsigned int index1 = abs(index); // b/c I'm fed up with compiler warnings about comparison betw. signed and unsigned int
83  const HcalCovarianceMatrix* cell = NULL;
84  switch (myId.genericSubdet() ) {
86  if (index1 < HBcontainer.size()) cell = &(HBcontainer.at(index1) );
87  break;
89  if (index1 < HEcontainer.size()) cell = &(HEcontainer.at(index1) );
90  break;
92  if (index1 < HOcontainer.size()) cell = &(HOcontainer.at(index1) );
93  break;
95  if (index1 < HFcontainer.size()) cell = &(HFcontainer.at(index1) );
96  break;
97  default: return false; break;
98  }
99 
100  // HcalCovarianceMatrix emptyHcalCovarianceMatrix;
101  if (cell)
102  // if (cell->rawId() != emptyHcalCovarianceMatrix.rawId() )
103  if (cell->rawId() == fId )
104  return true;
105 
106  return false;
107 }
108 
109 bool
110 HcalCovarianceMatrices::addValues(const HcalCovarianceMatrix& myHcalCovarianceMatrix, bool h2mode_)
111 {
112  unsigned long myRawId = myHcalCovarianceMatrix.rawId();
113  HcalGenericDetId myId(myRawId);
114  int index = myId.hashedId(h2mode_);
115  bool success = false;
116  if (index < 0) success = false;
117  unsigned int index1 = abs(index); // b/c I'm fed up with compiler warnings about comparison betw. signed and unsigned int
118 
119  switch (myId.genericSubdet() ) {
121  if (!HBcontainer.size() ) initContainer(myId.genericSubdet() );
122  if (index1 < HBcontainer.size())
123  {
124  HBcontainer.at(index1) = myHcalCovarianceMatrix;
125  success = true;
126  }
127  break;
129  if (!HEcontainer.size() ) initContainer(myId.genericSubdet(), h2mode_ );
130  if (index1 < HEcontainer.size())
131  {
132  HEcontainer.at(index1) = myHcalCovarianceMatrix;
133  success = true;
134  }
135  break;
137  if (!HOcontainer.size() ) initContainer(myId.genericSubdet() );
138  if (index1 < HOcontainer.size())
139  {
140  HOcontainer.at(index1) = myHcalCovarianceMatrix;
141  success = true;
142  }
143  break;
145  if (!HFcontainer.size() ) initContainer(myId.genericSubdet() );
146  if (index1 < HFcontainer.size())
147  {
148  HFcontainer.at(index1) = myHcalCovarianceMatrix;
149  success = true;
150  }
151  break;
152  default: break;
153  }
154 
155  if (!success)
156  throw cms::Exception ("Filling of conditions failed")
157  << " no valid filling possible for Conditions of type " << myname() << " for DetId " << myId;
158  return success;
159 }
160 
161 std::vector<DetId>
163 {
164  std::vector<DetId> channels;
165  HcalCovarianceMatrix emptyHcalCovarianceMatrix;
166  for (unsigned int i=0; i<HBcontainer.size(); i++)
167  {
168  if (emptyHcalCovarianceMatrix.rawId() != HBcontainer.at(i).rawId() )
169  channels.push_back( DetId(HBcontainer.at(i).rawId()) );
170  }
171  for (unsigned int i=0; i<HEcontainer.size(); i++)
172  {
173  if (emptyHcalCovarianceMatrix.rawId() != HEcontainer.at(i).rawId() )
174  channels.push_back( DetId(HEcontainer.at(i).rawId()) );
175  }
176  for (unsigned int i=0; i<HOcontainer.size(); i++)
177  {
178  if (emptyHcalCovarianceMatrix.rawId() != HOcontainer.at(i).rawId() )
179  channels.push_back( DetId(HOcontainer.at(i).rawId()) );
180  }
181  for (unsigned int i=0; i<HFcontainer.size(); i++)
182  {
183  if (emptyHcalCovarianceMatrix.rawId() != HFcontainer.at(i).rawId() )
184  channels.push_back( DetId(HFcontainer.at(i).rawId()) );
185  }
186  return channels;
187 }
int i
Definition: DBlmapReader.cc:9
int hashedId(bool h2mode_=false) const
uint32_t rawId() const
#define abs(x)
Definition: mlp_lapack.h:159
#define NULL
Definition: scimark2.h:8
std::vector< HcalCovarianceMatrix > HFcontainer
std::vector< HcalCovarianceMatrix > HBcontainer
bool addValues(const HcalCovarianceMatrix &myHcalCovarianceMatrix, bool h2mode_=false)
std::vector< DetId > getAllChannels() const
void initContainer(int container, bool h2mode_=false)
const HcalCovarianceMatrix * getValues(DetId fId) const
Definition: DetId.h:20
const bool exists(DetId fId) const
std::vector< HcalCovarianceMatrix > HOcontainer
HcalGenericSubdetector genericSubdet() const
std::string myname() const
std::vector< HcalCovarianceMatrix > HEcontainer