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