test
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) || (!hcalEqualDetId(cell,fId))) {
54 // (fId.det()==DetId::Hcal && HcalDetId(cell->rawId()) != HcalDetId(fId)) ||
55 // (fId.det()==DetId::Calo && fId.subdetId()==HcalZDCDetId::SubdetectorId && HcalZDCDetId(cell->rawId()) != HcalZDCDetId(fId)) ||
56 // (fId.det()!=DetId::Hcal && (fId.det()==DetId::Calo && fId.subdetId()!=HcalZDCDetId::SubdetectorId) && (cell->rawId() != fId))) {
57  if (throwOnFail) {
58  throw cms::Exception ("Conditions not found")
59  << "Unavailable Conditions of type " << myname() << " for cell " << fId.rawId();
60  } else {
61  cell=0;
62  }
63  }
64  return cell;
65 }
66 
67 const bool
69 {
70  const HcalCovarianceMatrix* cell = getValues(fId,false);
71 
72  // HcalCovarianceMatrix emptyHcalCovarianceMatrix;
73  if (cell)
74  if (hcalEqualDetId(cell,fId))
75 // (fId.det()==DetId::Hcal && HcalDetId(cell->rawId()) == HcalDetId(fId)) ||
76 // (fId.det()==DetId::Calo && fId.subdetId()==HcalZDCDetId::SubdetectorId && HcalZDCDetId(cell->rawId()) == HcalZDCDetId(fId)) ||
77 // (fId.det()!=DetId::Hcal && (fId.det()==DetId::Calo && fId.subdetId()!=HcalZDCDetId::SubdetectorId) && (cell->rawId() == fId)))
78  return true;
79 
80  return false;
81 }
82 
83 bool
85 {
86  unsigned int index=0;
87  bool success = false;
88  HcalCovarianceMatrix* cell=0;
89  DetId fId(myHcalCovarianceMatrix.rawId());
90 
91  if (index<0xFFFFFFFu) {
92  if (fId.det()==DetId::Hcal) {
93  switch (HcalSubdetector(fId.subdetId())) {
94  case(HcalBarrel) : if (!HBcontainer.size() ) initContainer(fId);
95  if (index < HBcontainer.size()) cell = &(HBcontainer.at(index) ); break;
96  case(HcalEndcap) : if (!HEcontainer.size() ) initContainer(fId);
97  if (index < HEcontainer.size()) cell = &(HEcontainer.at(index) ); break;
98  case(HcalForward) : if (!HFcontainer.size() ) initContainer(fId);
99  if (index < HFcontainer.size()) cell = &(HFcontainer.at(index) ); break;
100  case(HcalOuter) : if (!HOcontainer.size() ) initContainer(fId);
101  if (index < HOcontainer.size()) cell = &(HOcontainer.at(index) ); break;
102  default: break;
103  }
104  }
105  }
106  if (cell) {
107  *cell=myHcalCovarianceMatrix;
108  success = true;
109  }
110 
111 
112  if (!success)
113  throw cms::Exception ("Filling of conditions failed")
114  << " no valid filling possible for Conditions of type " << myname() << " for DetId " << fId.rawId();
115  return success;
116 }
117 
118 std::vector<DetId>
120 {
121  std::vector<DetId> channels;
122  HcalCovarianceMatrix emptyHcalCovarianceMatrix;
123  for (unsigned int i=0; i<HBcontainer.size(); i++) {
124  if (emptyHcalCovarianceMatrix.rawId() != HBcontainer.at(i).rawId() )
125  channels.push_back( DetId(HBcontainer.at(i).rawId()) );
126  }
127  for (unsigned int i=0; i<HEcontainer.size(); i++) {
128  if (emptyHcalCovarianceMatrix.rawId() != HEcontainer.at(i).rawId() )
129  channels.push_back( DetId(HEcontainer.at(i).rawId()) );
130  }
131  for (unsigned int i=0; i<HOcontainer.size(); i++) {
132  if (emptyHcalCovarianceMatrix.rawId() != HOcontainer.at(i).rawId() )
133  channels.push_back( DetId(HOcontainer.at(i).rawId()) );
134  }
135  for (unsigned int i=0; i<HFcontainer.size(); i++) {
136  if (emptyHcalCovarianceMatrix.rawId() != HFcontainer.at(i).rawId() )
137  channels.push_back( DetId(HFcontainer.at(i).rawId()) );
138  }
139  return channels;
140 }
bool hcalEqualDetId(Item *cell, const DetId &fId)
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