#include <CondTools/Hcal/interface/HcalQIEDataCheck.h>
Public Member Functions | |
void | analyze (const edm::Event &ev, const edm::EventSetup &es) |
HcalQIEDataCheck (edm::ParameterSet const &ps) | |
~HcalQIEDataCheck () | |
Private Attributes | |
bool | checkemapflag |
std::string | dumprefs |
std::string | dumpupdate |
std::string | outfile |
bool | validateflag |
Definition at line 38 of file HcalQIEDataCheck.h.
HcalQIEDataCheck::HcalQIEDataCheck | ( | edm::ParameterSet const & | ps | ) |
Definition at line 3 of file HcalQIEDataCheck.cc.
References checkemapflag, dumprefs, dumpupdate, edm::ParameterSet::getUntrackedParameter(), outfile, and validateflag.
00004 { 00005 outfile = ps.getUntrackedParameter<std::string>("outFile","null"); 00006 dumprefs = ps.getUntrackedParameter<std::string>("dumpRefQIEsTo","null"); 00007 dumpupdate = ps.getUntrackedParameter<std::string>("dumpUpdateQIEsTo","null"); 00008 checkemapflag = ps.getUntrackedParameter<bool>("checkEmap",false); 00009 validateflag = ps.getUntrackedParameter<bool>("validateQIEs",false); 00010 // epsilon = ps.getUntrackedParameter<double>("deltaQIE",0); 00011 }
HcalQIEDataCheck::~HcalQIEDataCheck | ( | ) |
void HcalQIEDataCheck::analyze | ( | const edm::Event & | ev, | |
const edm::EventSetup & | es | |||
) | [virtual] |
Implements edm::EDAnalyzer.
Definition at line 15 of file HcalQIEDataCheck.cc.
References HcalQIEData::addCoder(), HcalElectronicsMap::allPrecisionId(), checkemapflag, GenMuonPlsPt100GeV_cfg::cout, HcalDbASCIIIO::dumpObject(), dumprefs, dumpupdate, lat::endl(), Exception, find(), first, edm::EventSetup::get(), HcalCondObjectContainer< Item >::getAllChannels(), HcalQIEData::getCoder(), it, HcalQIECoder::offset(), outfile, edm::ESHandle< T >::product(), edm::second(), HcalQIECoder::slope(), HcalQIEData::sort(), and validateflag.
00016 { 00017 using namespace edm::eventsetup; 00018 00019 edm::ESHandle<HcalQIEData> newQIEs; 00020 es.get<HcalQIEDataRcd>().get("update",newQIEs); 00021 const HcalQIEData* myNewQIEs = newQIEs.product(); 00022 00023 edm::ESHandle<HcalQIEData> refQIEs; 00024 es.get<HcalQIEDataRcd>().get("reference",refQIEs); 00025 const HcalQIEData* myRefQIEs = refQIEs.product(); 00026 00027 edm::ESHandle<HcalElectronicsMap> refEMap; 00028 es.get<HcalElectronicsMapRcd>().get("reference",refEMap); 00029 const HcalElectronicsMap* myRefEMap = refEMap.product(); 00030 00031 if(dumpupdate.compare("null")!=0){ 00032 std::ofstream outStream(dumpupdate.c_str()); 00033 std::cout << "--- Dumping QIEs - update ---" << std::endl; 00034 HcalDbASCIIIO::dumpObject (outStream, (*myNewQIEs) ); 00035 } 00036 if(dumprefs.compare("null")!=0){ 00037 std::ofstream outStream2(dumprefs.c_str()); 00038 std::cout << "--- Dumping QIEs - reference ---" << std::endl; 00039 HcalDbASCIIIO::dumpObject (outStream2, (*myRefQIEs) ); 00040 } 00041 00042 // first get the list of all channels from the update 00043 std::vector<DetId> listNewChan = myNewQIEs->getAllChannels(); 00044 00045 HcalQIEData *resultQIEs = new HcalQIEData(); 00046 std::vector<DetId> listRefChan = myRefQIEs->getAllChannels(); 00047 std::vector<DetId>::iterator cell; 00048 00049 if(validateflag){ 00050 for (std::vector<DetId>::iterator it = listRefChan.begin(); it != listRefChan.end(); it++) 00051 { 00052 DetId mydetid = *it; 00053 cell = std::find(listNewChan.begin(), listNewChan.end(), mydetid); 00054 if (cell == listNewChan.end()) // not present in new list 00055 { 00056 throw cms::Exception("DataDoesNotMatch") << "Value not found in reference" << std::endl; 00057 } 00058 else // present in new list 00059 { 00060 00061 const HcalQIECoder* first = myNewQIEs->getCoder( mydetid ); 00062 const HcalQIECoder* second = myRefQIEs->getCoder( mydetid ); 00063 { 00064 bool failflag = false; 00065 if(first->offset(0,0) != second->offset(0,0)) failflag = true; 00066 if(first->offset(0,1) != second->offset(0,1)) failflag = true; 00067 if(first->offset(0,2) != second->offset(0,2)) failflag = true; 00068 if(first->offset(0,3) != second->offset(0,3)) failflag = true; 00069 if(first->offset(1,0) != second->offset(1,0)) failflag = true; 00070 if(first->offset(1,1) != second->offset(1,1)) failflag = true; 00071 if(first->offset(1,2) != second->offset(1,2)) failflag = true; 00072 if(first->offset(1,3) != second->offset(1,3)) failflag = true; 00073 if(first->offset(2,0) != second->offset(2,0)) failflag = true; 00074 if(first->offset(2,1) != second->offset(2,1)) failflag = true; 00075 if(first->offset(2,2) != second->offset(2,2)) failflag = true; 00076 if(first->offset(2,3) != second->offset(2,3)) failflag = true; 00077 if(first->offset(3,0) != second->offset(3,0)) failflag = true; 00078 if(first->offset(3,1) != second->offset(3,1)) failflag = true; 00079 if(first->offset(3,2) != second->offset(3,2)) failflag = true; 00080 if(first->offset(3,3) != second->offset(3,3)) failflag = true; 00081 if(first->slope(0,0) != second->slope(0,0)) failflag = true; 00082 if(first->slope(0,1) != second->slope(0,1)) failflag = true; 00083 if(first->slope(0,2) != second->slope(0,2)) failflag = true; 00084 if(first->slope(0,3) != second->slope(0,3)) failflag = true; 00085 if(first->slope(1,0) != second->slope(1,0)) failflag = true; 00086 if(first->slope(1,1) != second->slope(1,1)) failflag = true; 00087 if(first->slope(1,2) != second->slope(1,2)) failflag = true; 00088 if(first->slope(1,3) != second->slope(1,3)) failflag = true; 00089 if(first->slope(2,0) != second->slope(2,0)) failflag = true; 00090 if(first->slope(2,1) != second->slope(2,1)) failflag = true; 00091 if(first->slope(2,2) != second->slope(2,2)) failflag = true; 00092 if(first->slope(2,3) != second->slope(2,3)) failflag = true; 00093 if(first->slope(3,0) != second->slope(3,0)) failflag = true; 00094 if(first->slope(3,1) != second->slope(3,1)) failflag = true; 00095 if(first->slope(3,2) != second->slope(3,2)) failflag = true; 00096 if(first->slope(3,3) != second->slope(3,3)) failflag = true; 00097 if(failflag) throw cms::Exception("DataDoesNotMatch") << "Values are do not match"; 00098 } 00099 listNewChan.erase(cell); // fix 25.02.08 00100 } 00101 } 00102 std::cout << "These are identical" << std::endl; 00103 } 00104 00105 00106 00107 // if(epsilon!=0){ 00108 //implement compare qies -- different epsilon for slope and offset? 00109 // } 00110 00111 if(outfile.compare("null")!=0){ 00112 for (std::vector<DetId>::iterator it = listRefChan.begin(); it != listRefChan.end(); it++) 00113 { 00114 DetId mydetid = *it; 00115 cell = std::find(listNewChan.begin(), listNewChan.end(), mydetid); 00116 if (cell == listNewChan.end()) // not present in new list 00117 { 00118 const HcalQIECoder* myCoder = myRefQIEs->getCoder( mydetid ); 00119 std::cout << "o"; 00120 resultQIEs->addCoder( *myCoder ); 00121 } 00122 else // present in new list 00123 { 00124 const HcalQIECoder* myCoder = myNewQIEs->getCoder( mydetid ); 00125 std::cout << "n"; 00126 resultQIEs->addCoder( *myCoder ); 00127 listNewChan.erase(cell); // fix 25.02.08 00128 } 00129 } 00130 for (std::vector<DetId>::iterator it = listNewChan.begin(); it != listNewChan.end(); it++) // fix 25.02.08 00131 { 00132 DetId mydetid = *it; 00133 const HcalQIECoder* myCoder = myNewQIEs->getCoder( mydetid ); 00134 std::cout << "N"; 00135 resultQIEs->addCoder( *myCoder ); 00136 } 00137 00138 std::ofstream outStream3(outfile.c_str()); 00139 std::cout << "--- Dumping QIEs - the combined ones ---" << std::endl; 00140 resultQIEs->sort(); 00141 HcalDbASCIIIO::dumpObject (outStream3, (*resultQIEs) ); 00142 } 00143 00144 std::cout << std::endl; 00145 if(checkemapflag){ 00146 std::vector<DetId> listResult = resultQIEs->getAllChannels(); 00147 // get the e-map list of channels 00148 std::vector<HcalGenericDetId> listEMap = myRefEMap->allPrecisionId(); 00149 for (std::vector<HcalGenericDetId>::const_iterator it = listEMap.begin(); it != listEMap.end(); it++) 00150 { 00151 DetId mydetid = DetId(it->rawId()); 00152 if (std::find(listResult.begin(), listResult.end(), mydetid ) == listResult.end() ) 00153 { 00154 std::cout << "Conditions not found for DetId = " << HcalGenericDetId(it->rawId()) << std::endl; 00155 } 00156 } 00157 } 00158 00159 }
bool HcalQIEDataCheck::checkemapflag [private] |
std::string HcalQIEDataCheck::dumprefs [private] |
std::string HcalQIEDataCheck::dumpupdate [private] |
std::string HcalQIEDataCheck::outfile [private] |
bool HcalQIEDataCheck::validateflag [private] |