00001 #include "CondFormats/HcalObjects/interface/HcalCholeskyMatrices.h" 00002 00003 HcalCholeskyMatrices::HcalCholeskyMatrices(const HcalTopology* topo) : HcalCondObjectContainerBase(topo) 00004 { 00005 } 00006 00007 HcalCholeskyMatrices::~HcalCholeskyMatrices() 00008 { 00009 } 00010 00011 void 00012 HcalCholeskyMatrices::initContainer(DetId fId) 00013 { 00014 HcalCholeskyMatrix emptyItem; 00015 00016 if (fId.det()==DetId::Hcal) { 00017 switch (HcalSubdetector(fId.subdetId())) { 00018 case(HcalBarrel) : for (unsigned int i=0; i<sizeFor(fId); i++) HBcontainer.push_back(emptyItem); break; 00019 case(HcalEndcap) : for (unsigned int i=0; i<sizeFor(fId); i++) HEcontainer.push_back(emptyItem); break; 00020 case(HcalOuter) : for (unsigned int i=0; i<sizeFor(fId); i++) HOcontainer.push_back(emptyItem); break; 00021 case(HcalForward) : for (unsigned int i=0; i<sizeFor(fId); i++) HFcontainer.push_back(emptyItem); break; 00022 default: break; 00023 } 00024 } 00025 } 00026 00027 00028 const HcalCholeskyMatrix* 00029 HcalCholeskyMatrices::getValues(DetId fId, bool throwOnFail) const 00030 { 00031 unsigned int index = indexFor(fId); 00032 const HcalCholeskyMatrix* cell = NULL; 00033 if (index<0xFFFFFFFFu) { 00034 if (fId.det()==DetId::Hcal) { 00035 switch (HcalSubdetector(fId.subdetId())) { 00036 case(HcalBarrel) : if (index < HBcontainer.size()) cell = &(HBcontainer.at(index) ); 00037 case(HcalEndcap) : if (index < HEcontainer.size()) cell = &(HEcontainer.at(index) ); 00038 case(HcalForward) : if (index < HFcontainer.size()) cell = &(HFcontainer.at(index) ); 00039 case(HcalOuter) : if (index < HOcontainer.size()) cell = &(HOcontainer.at(index) ); 00040 default: break; 00041 } 00042 } 00043 } 00044 00045 // HcalCholeskyMatrix emptyHcalCholeskyMatrix; 00046 // if (cell->rawId() == emptyHcalCholeskyMatrix.rawId() ) 00047 if ((!cell) || (cell->rawId() != fId ) ) { 00048 if (throwOnFail) { 00049 throw cms::Exception ("Conditions not found") 00050 << "Unavailable Conditions of type " << myname() << " for cell " << fId.rawId(); 00051 } else { 00052 cell=0; 00053 } 00054 } 00055 return cell; 00056 } 00057 00058 const bool 00059 HcalCholeskyMatrices::exists(DetId fId) const 00060 { 00061 00062 const HcalCholeskyMatrix* cell = getValues(fId,false); 00063 00064 // HcalCholeskyMatrix emptyHcalCholeskyMatrix; 00065 if (cell) 00066 // if (cell->rawId() != emptyHcalCholeskyMatrix.rawId() ) 00067 if (cell->rawId() == fId ) 00068 return true; 00069 00070 return false; 00071 } 00072 00073 bool 00074 HcalCholeskyMatrices::addValues(const HcalCholeskyMatrix& myItem) 00075 { 00076 bool success = false; 00077 DetId fId(myItem.rawId()); 00078 unsigned int index=indexFor(fId); 00079 00080 HcalCholeskyMatrix* cell = NULL; 00081 00082 if (index<0xFFFFFFFu) { 00083 if (fId.det()==DetId::Hcal) { 00084 switch (HcalSubdetector(fId.subdetId())) { 00085 case(HcalBarrel) : if (!HBcontainer.size() ) initContainer(fId); 00086 if (index < HBcontainer.size()) cell = &(HBcontainer.at(index) ); break; 00087 case(HcalEndcap) : if (!HEcontainer.size() ) initContainer(fId); 00088 if (index < HEcontainer.size()) cell = &(HEcontainer.at(index) ); break; 00089 case(HcalForward) : if (!HFcontainer.size() ) initContainer(fId); 00090 if (index < HFcontainer.size()) cell = &(HFcontainer.at(index) ); break; 00091 case(HcalOuter) : if (!HOcontainer.size() ) initContainer(fId); 00092 if (index < HOcontainer.size()) cell = &(HOcontainer.at(index) ); break; 00093 default: break; 00094 } 00095 } 00096 } 00097 00098 if (cell!=0) { 00099 (*cell)=myItem; 00100 success = true; 00101 } 00102 00103 if (!success) 00104 throw cms::Exception ("Filling of conditions failed") 00105 << " no valid filling possible for Conditions of type " << myname() << " for DetId " << fId.rawId(); 00106 return success; 00107 } 00108 00109 std::vector<DetId> 00110 HcalCholeskyMatrices::getAllChannels() const 00111 { 00112 std::vector<DetId> channels; 00113 HcalCholeskyMatrix emptyHcalCholeskyMatrix; 00114 for (unsigned int i=0; i<HBcontainer.size(); i++) 00115 { 00116 if (emptyHcalCholeskyMatrix.rawId() != HBcontainer.at(i).rawId() ) 00117 channels.push_back( DetId(HBcontainer.at(i).rawId()) ); 00118 } 00119 for (unsigned int i=0; i<HEcontainer.size(); i++) 00120 { 00121 if (emptyHcalCholeskyMatrix.rawId() != HEcontainer.at(i).rawId() ) 00122 channels.push_back( DetId(HEcontainer.at(i).rawId()) ); 00123 } 00124 for (unsigned int i=0; i<HOcontainer.size(); i++) 00125 { 00126 if (emptyHcalCholeskyMatrix.rawId() != HOcontainer.at(i).rawId() ) 00127 channels.push_back( DetId(HOcontainer.at(i).rawId()) ); 00128 } 00129 for (unsigned int i=0; i<HFcontainer.size(); i++) 00130 { 00131 if (emptyHcalCholeskyMatrix.rawId() != HFcontainer.at(i).rawId() ) 00132 channels.push_back( DetId(HFcontainer.at(i).rawId()) ); 00133 } 00134 return channels; 00135 } 00136