CMS 3D CMS Logo

SiPixelFakeGainForHLTESSource.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiPixelFakeGainForHLTESSource
4 // Class: SiPixelFakeGainForHLTESSource
5 //
13 //
14 // Original Author: Vincenzo Chiochia
15 // Created: Fri Apr 27 12:31:25 CEST 2007
16 //
17 //
18 
19 // user include files
20 
26 //
27 // constructors and destructor
28 //
30  : fp_(conf_.getParameter<edm::FileInPath>("file")) {
31  edm::LogInfo("SiPixelFakeGainForHLTESSource::SiPixelFakeGainForHLTESSource");
32  //the following line is needed to tell the framework what
33  // data is being produced
34  setWhatProduced(this);
35  findingRecord<SiPixelGainCalibrationForHLTRcd>();
36 }
37 
39  // do anything here that needs to be done at desctruction time
40  // (e.g. close files, deallocate resources etc.)
41 }
42 
43 std::unique_ptr<SiPixelGainCalibrationForHLT> SiPixelFakeGainForHLTESSource::produce(
45  using namespace edm::es;
48  const std::vector<uint32_t>& DetIds = reader.getAllDetIds();
49 
50  // Loop over detectors
51  for (std::vector<uint32_t>::const_iterator detit = DetIds.begin(); detit != DetIds.end(); detit++) {
52  std::vector<char> theSiPixelGainCalibration;
53  const std::pair<int, int>& detUnitDimensions = reader.getDetUnitDimensions(*detit);
54 
55  // Loop over columns and rows
56 
57  for (int i = 0; i < detUnitDimensions.first; i++) {
58  float totalGain = 0.0;
59  float totalPed = 0.0;
60  float totalEntries = 0.0;
61  for (int j = 0; j < detUnitDimensions.second; j++) {
62  totalGain += 2.8;
63  totalPed += 28.2;
64  totalEntries++;
65  if ((j + 1) % 80 == 0) {
66  float gain = totalGain / totalEntries;
67  float ped = totalPed / totalEntries;
68 
69  obj->setData(ped, gain, theSiPixelGainCalibration);
70  totalGain = 0.;
71  totalPed = 0.;
72  totalEntries = 0.;
73  }
74  }
75  }
76 
77  //std::cout << "detid " << (*detit) << std::endl;
78 
79  SiPixelGainCalibrationForHLT::Range range(theSiPixelGainCalibration.begin(), theSiPixelGainCalibration.end());
80  int nCols = detUnitDimensions.first;
81  if (!obj->put(*detit, range, nCols))
82  edm::LogError("SiPixelFakeGainForHLTESSource")
83  << "[SiPixelFakeGainForHLTESSource::produce] detid already exists" << std::endl;
84  }
85 
86  //
87  return std::unique_ptr<SiPixelGainCalibrationForHLT>(obj);
88 }
89 
91  const edm::IOVSyncValue& iosv,
92  edm::ValidityInterval& oValidity) {
94  oValidity = infinity;
95 }
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:166
std::string fullPath() const
Definition: FileInPath.cc:161
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
reader
Definition: DQM.py:105
std::pair< ContainerIterator, ContainerIterator > Range
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
const double infinity
Log< level::Info, false > LogInfo
virtual std::unique_ptr< SiPixelGainCalibrationForHLT > produce(const SiPixelGainCalibrationForHLTRcd &)
HLT enums.
SiPixelFakeGainForHLTESSource(const edm::ParameterSet &)