00001
00002
00003
00011
00012
00013
00014
00015
00016
00017
00018 #include <iostream>
00019 #include <fstream>
00020
00021 #include "CalibTracker/SiPixelErrorEstimation/interface/PxCPEdbReader.h"
00022 #include "CondFormats/SiPixelObjects/interface/SiPixelCPEParmErrors.h"
00023 #include "CondFormats/DataRecord/interface/SiPixelCPEParmErrorsRcd.h"
00024 #include "CondTools/SiPixel/interface/SiPixelDBErrorParametrization.h"
00025
00026 #include "FWCore/Framework/interface/ESHandle.h"
00027 #include "FWCore/Framework/interface/EventSetup.h"
00028
00029 PxCPEdbReader::PxCPEdbReader(const edm::ParameterSet& iConfig)
00030 {
00031 }
00032
00033 PxCPEdbReader::~PxCPEdbReader()
00034 {
00035 }
00036
00037 void
00038 PxCPEdbReader::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00039 {
00040 }
00041
00042 void
00043 PxCPEdbReader::beginJob(const edm::EventSetup& setup)
00044 {
00045 edm::ESHandle<SiPixelCPEParmErrors> errorsH;
00046 setup.get<SiPixelCPEParmErrorsRcd>().get(errorsH);
00047
00048 const SiPixelCPEParmErrors::DbVector & errors = errorsH->errors();
00049 const SiPixelCPEParmErrors::DbBinSizeVector & errors_Bin_Size = errorsH->errorsBinSize();
00050
00051 SiPixelCPEParmErrors::DbEntry Entry;
00052
00053 std::cout << "Testing integrity of the database" << std::endl;
00054 for (unsigned int count=0; count < errors.size(); ++count) {
00055 Entry = errors[count];
00056 std::cout
00057 << Entry.bias << " "
00058 << Entry.pix_height << " "
00059 << Entry.ave_Qclus << " "
00060 << Entry.sigma << " "
00061 << Entry.rms << std::endl;
00062 }
00063
00064 std::cout << "\n\nTesting Random Access" << std::endl;
00065 std::cout << "For Part = 2, Size = 2, alpha = 4 , beta = 3: Sigma = 0.000371" << std::endl;
00066 unsigned int part = 2;
00067 unsigned int size = 2;
00068 unsigned int alpha = 4;
00069 unsigned int beta = 3;
00070 unsigned int index = 0;
00071
00072 index = errors_Bin_Size[part-1].partBin_size + errors_Bin_Size[part-1].sizeBin_size * size + errors_Bin_Size[part-1].alphaBin_size * alpha + errors_Bin_Size[part-1].betaBin_size * beta;
00073
00074 Entry = errors[index];
00075 std::cout
00076 << Entry.bias << " "
00077 << Entry.pix_height << " "
00078 << Entry.ave_Qclus << " "
00079 << Entry.sigma << " "
00080 << Entry.rms << std::endl;
00081
00082 SiPixelDBErrorParametrization theErrorGetter;
00083
00084 theErrorGetter.setDBAccess(setup);
00085
00086 std::pair<float,float> dbentry;
00087
00088 dbentry = theErrorGetter.getError(GeomDetEnumerators::PixelBarrel, 3, 3, 1.57, 2.72, true, true);
00089
00090 std::cout << "\n\nFor Barrel, size x = 3, size y =3, alpha = 1.57, beta = 2.72\n"
00091 << "By hand the indices should be for bx and by respectively: 346, 99\n"
00092 << "And the errors should be 0.000342 and 0.003106\nThey are: "
00093 << dbentry.first << " " << dbentry.second << std::endl;
00094
00095
00096 }
00097
00098 void
00099 PxCPEdbReader::endJob()
00100 {
00101 }