File indexing completed on 2023-05-10 03:53:26
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #include "CalibTracker/SiPixelESProducers/interface/SiPixelFakeGainForHLTESSource.h"
0022 #include "CalibTracker/SiPixelESProducers/interface/SiPixelDetInfoFileReader.h"
0023 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0024 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0025 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0026
0027
0028
0029 SiPixelFakeGainForHLTESSource::SiPixelFakeGainForHLTESSource(const edm::ParameterSet& conf_)
0030 : fp_(conf_.getParameter<edm::FileInPath>("file")) {
0031 edm::LogInfo("SiPixelFakeGainForHLTESSource::SiPixelFakeGainForHLTESSource");
0032
0033
0034 setWhatProduced(this);
0035 findingRecord<SiPixelGainCalibrationForHLTRcd>();
0036 }
0037
0038 SiPixelFakeGainForHLTESSource::~SiPixelFakeGainForHLTESSource() {
0039
0040
0041 }
0042
0043 std::unique_ptr<SiPixelGainCalibrationForHLT> SiPixelFakeGainForHLTESSource::produce(
0044 const SiPixelGainCalibrationForHLTRcd&) {
0045 using namespace edm::es;
0046 SiPixelGainCalibrationForHLT* obj = new SiPixelGainCalibrationForHLT(25., 30., 2., 3.);
0047 SiPixelDetInfoFileReader reader(fp_.fullPath());
0048 const std::vector<uint32_t>& DetIds = reader.getAllDetIds();
0049
0050
0051 for (std::vector<uint32_t>::const_iterator detit = DetIds.begin(); detit != DetIds.end(); detit++) {
0052 std::vector<char> theSiPixelGainCalibration;
0053 const std::pair<int, int>& detUnitDimensions = reader.getDetUnitDimensions(*detit);
0054
0055
0056
0057 for (int i = 0; i < detUnitDimensions.first; i++) {
0058 float totalGain = 0.0;
0059 float totalPed = 0.0;
0060 float totalEntries = 0.0;
0061 for (int j = 0; j < detUnitDimensions.second; j++) {
0062 totalGain += 2.8;
0063 totalPed += 28.2;
0064 totalEntries++;
0065 if ((j + 1) % 80 == 0) {
0066 float gain = totalGain / totalEntries;
0067 float ped = totalPed / totalEntries;
0068
0069 obj->setData(ped, gain, theSiPixelGainCalibration);
0070 totalGain = 0.;
0071 totalPed = 0.;
0072 totalEntries = 0.;
0073 }
0074 }
0075 }
0076
0077
0078
0079 SiPixelGainCalibrationForHLT::Range range(theSiPixelGainCalibration.begin(), theSiPixelGainCalibration.end());
0080 int nCols = detUnitDimensions.first;
0081 if (!obj->put(*detit, range, nCols))
0082 edm::LogError("SiPixelFakeGainForHLTESSource")
0083 << "[SiPixelFakeGainForHLTESSource::produce] detid already exists" << std::endl;
0084 }
0085
0086
0087 return std::unique_ptr<SiPixelGainCalibrationForHLT>(obj);
0088 }
0089
0090 void SiPixelFakeGainForHLTESSource::setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
0091 const edm::IOVSyncValue& iosv,
0092 edm::ValidityInterval& oValidity) {
0093 edm::ValidityInterval infinity(iosv.beginOfTime(), iosv.endOfTime());
0094 oValidity = infinity;
0095 }