test
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.
3 
5 {
6 }
7 
9 {
10 }
11 
12 void
14 {
15  HcalCholeskyMatrix emptyItem;
16 
17  if (fId.det()==DetId::Hcal) {
18  switch (HcalSubdetector(fId.subdetId())) {
19  case(HcalBarrel) : for (unsigned int i=0; i<sizeFor(fId); i++) HBcontainer.push_back(emptyItem); break;
20  case(HcalEndcap) : for (unsigned int i=0; i<sizeFor(fId); i++) HEcontainer.push_back(emptyItem); break;
21  case(HcalOuter) : for (unsigned int i=0; i<sizeFor(fId); i++) HOcontainer.push_back(emptyItem); break;
22  case(HcalForward) : for (unsigned int i=0; i<sizeFor(fId); i++) HFcontainer.push_back(emptyItem); break;
23  default: break;
24  }
25  }
26 }
27 
28 
29 const HcalCholeskyMatrix*
30 HcalCholeskyMatrices::getValues(DetId fId, bool throwOnFail) const
31 {
32  unsigned int index = indexFor(fId);
33  const HcalCholeskyMatrix* cell = NULL;
34  if (index<0xFFFFFFFFu) {
35  if (fId.det()==DetId::Hcal) {
36  switch (HcalSubdetector(fId.subdetId())) {
37  case(HcalBarrel) : if (index < HBcontainer.size()) cell = &(HBcontainer.at(index) );
38  case(HcalEndcap) : if (index < HEcontainer.size()) cell = &(HEcontainer.at(index) );
39  case(HcalForward) : if (index < HFcontainer.size()) cell = &(HFcontainer.at(index) );
40  case(HcalOuter) : if (index < HOcontainer.size()) cell = &(HOcontainer.at(index) );
41  default: break;
42  }
43  }
44  }
45 
46  // HcalCholeskyMatrix emptyHcalCholeskyMatrix;
47  // if (cell->rawId() == emptyHcalCholeskyMatrix.rawId() )
48  if ((!cell) || (!hcalEqualDetId(cell,fId))) {
49 // (fId.det()==DetId::Hcal && HcalDetId(cell->rawId()) != HcalDetId(fId)) ||
50 // (fId.det()==DetId::Calo && fId.subdetId()==HcalZDCDetId::SubdetectorId && HcalZDCDetId(cell->rawId()) != HcalZDCDetId(fId)) ||
51 // (fId.det()!=DetId::Hcal && (fId.det()==DetId::Calo && fId.subdetId()!=HcalZDCDetId::SubdetectorId) && (cell->rawId() != fId))) {
52  if (throwOnFail) {
53  throw cms::Exception ("Conditions not found")
54  << "Unavailable Conditions of type " << myname() << " for cell " << fId.rawId();
55  } else {
56  cell=0;
57  }
58  }
59  return cell;
60 }
61 
62 const bool
64 {
65 
66  const HcalCholeskyMatrix* cell = getValues(fId,false);
67 
68  // HcalCholeskyMatrix emptyHcalCholeskyMatrix;
69  if (cell)
70  if (!hcalEqualDetId(cell,fId))
71 // (fId.det()==DetId::Hcal && HcalDetId(cell->rawId()) == HcalDetId(fId)) ||
72 // (fId.det()==DetId::Calo && fId.subdetId()==HcalZDCDetId::SubdetectorId && HcalZDCDetId(cell->rawId()) == HcalZDCDetId(fId)) ||
73 // (fId.det()!=DetId::Hcal && (fId.det()==DetId::Calo && fId.subdetId()!=HcalZDCDetId::SubdetectorId) && (cell->rawId() == fId)))
74  return true;
75 
76  return false;
77 }
78 
79 bool
81 {
82  bool success = false;
83  DetId fId(myItem.rawId());
84  unsigned int index=indexFor(fId);
85 
86  HcalCholeskyMatrix* cell = NULL;
87 
88  if (index<0xFFFFFFFu) {
89  if (fId.det()==DetId::Hcal) {
90  switch (HcalSubdetector(fId.subdetId())) {
91  case(HcalBarrel) : if (!HBcontainer.size() ) initContainer(fId);
92  if (index < HBcontainer.size()) cell = &(HBcontainer.at(index) ); break;
93  case(HcalEndcap) : if (!HEcontainer.size() ) initContainer(fId);
94  if (index < HEcontainer.size()) cell = &(HEcontainer.at(index) ); break;
95  case(HcalForward) : if (!HFcontainer.size() ) initContainer(fId);
96  if (index < HFcontainer.size()) cell = &(HFcontainer.at(index) ); break;
97  case(HcalOuter) : if (!HOcontainer.size() ) initContainer(fId);
98  if (index < HOcontainer.size()) cell = &(HOcontainer.at(index) ); break;
99  default: break;
100  }
101  }
102  }
103 
104  if (cell!=0) {
105  (*cell)=myItem;
106  success = true;
107  }
108 
109  if (!success)
110  throw cms::Exception ("Filling of conditions failed")
111  << " no valid filling possible for Conditions of type " << myname() << " for DetId " << fId.rawId();
112  return success;
113 }
114 
115 std::vector<DetId>
117 {
118  std::vector<DetId> channels;
119  HcalCholeskyMatrix emptyHcalCholeskyMatrix;
120  for (unsigned int i=0; i<HBcontainer.size(); i++) {
121  if (emptyHcalCholeskyMatrix.rawId() != HBcontainer.at(i).rawId() )
122  channels.push_back( DetId(HBcontainer.at(i).rawId()) );
123  }
124  for (unsigned int i=0; i<HEcontainer.size(); i++) {
125  if (emptyHcalCholeskyMatrix.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  if (emptyHcalCholeskyMatrix.rawId() != HOcontainer.at(i).rawId() )
130  channels.push_back( DetId(HOcontainer.at(i).rawId()) );
131  }
132  for (unsigned int i=0; i<HFcontainer.size(); i++) {
133  if (emptyHcalCholeskyMatrix.rawId() != HFcontainer.at(i).rawId() )
134  channels.push_back( DetId(HFcontainer.at(i).rawId()) );
135  }
136  return channels;
137 }
138 
const bool exists(DetId fId) const
bool hcalEqualDetId(Item *cell, const DetId &fId)
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