CMS 3D CMS Logo

SiPixelFakeGainForHLTESSource.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CalibTracker/SiPixelGainForHLTESProducers
4 // Class: SiPixelFakeGainForHLTESSource
5 //
13 //
14 // Original Author: Vincenzo Chiochia
15 // Created: Tue 8 12:31:25 CEST 2007
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
37 
38 //
39 // class decleration
40 //
41 
43 public:
45  ~SiPixelFakeGainForHLTESSource() override = default;
46 
47  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
48 
49  virtual std::unique_ptr<SiPixelGainCalibrationForHLT> produce(const SiPixelGainCalibrationForHLTRcd&);
50 
51 protected:
53  const edm::IOVSyncValue&,
54  edm::ValidityInterval&) override;
55 
56 private:
58 };
59 
60 //
61 // constructors and destructor
62 //
64  : fp_(conf_.getParameter<edm::FileInPath>("file")) {
65  edm::LogInfo("SiPixelFakeGainForHLTESSource::SiPixelFakeGainForHLTESSource");
66  //the following line is needed to tell the framework what
67  // data is being produced
68  setWhatProduced(this);
69  findingRecord<SiPixelGainCalibrationForHLTRcd>();
70 }
71 
72 std::unique_ptr<SiPixelGainCalibrationForHLT> SiPixelFakeGainForHLTESSource::produce(
74  using namespace edm::es;
77  const std::vector<uint32_t>& DetIds = reader.getAllDetIds();
78 
79  // Loop over detectors
80  for (std::vector<uint32_t>::const_iterator detit = DetIds.begin(); detit != DetIds.end(); detit++) {
81  std::vector<char> theSiPixelGainCalibration;
82  const std::pair<int, int>& detUnitDimensions = reader.getDetUnitDimensions(*detit);
83 
84  // Loop over columns and rows
85 
86  for (int i = 0; i < detUnitDimensions.first; i++) {
87  float totalGain = 0.0;
88  float totalPed = 0.0;
89  float totalEntries = 0.0;
90  for (int j = 0; j < detUnitDimensions.second; j++) {
91  totalGain += 2.8;
92  totalPed += 28.2;
93  totalEntries++;
94  if ((j + 1) % 80 == 0) {
95  float gain = totalGain / totalEntries;
96  float ped = totalPed / totalEntries;
97 
98  obj->setData(ped, gain, theSiPixelGainCalibration);
99  totalGain = 0.;
100  totalPed = 0.;
101  totalEntries = 0.;
102  }
103  }
104  }
105 
106  //std::cout << "detid " << (*detit) << std::endl;
107 
108  SiPixelGainCalibrationForHLT::Range range(theSiPixelGainCalibration.begin(), theSiPixelGainCalibration.end());
109  int nCols = detUnitDimensions.first;
110  if (!obj->put(*detit, range, nCols))
111  edm::LogError("SiPixelFakeGainForHLTESSource")
112  << "[SiPixelFakeGainForHLTESSource::produce] detid already exists" << std::endl;
113  }
114 
115  //
116  return std::unique_ptr<SiPixelGainCalibrationForHLT>(obj);
117 }
118 
120  const edm::IOVSyncValue& iosv,
121  edm::ValidityInterval& oValidity) {
123  oValidity = infinity;
124 }
125 
128  desc.add<edm::FileInPath>("file", edm::FileInPath("CalibTracker/SiPixelESProducers/data/PixelSkimmedGeometry.txt"));
129  descriptions.addWithDefaultLabel(desc);
130 }
131 
~SiPixelFakeGainForHLTESSource() override=default
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:166
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
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
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:92
virtual std::unique_ptr< SiPixelGainCalibrationForHLT > produce(const SiPixelGainCalibrationForHLTRcd &)
HLT enums.
const std::string & fullPath() const
Definition: FileInPath.cc:144
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
SiPixelFakeGainForHLTESSource(const edm::ParameterSet &)