CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SiPixelFakeGainESSource.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiPixelFakeGainESSource
4 // Class: SiPixelFakeGainESSource
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("SiPixelFakeGainESSource::SiPixelFakeGainESSource");
32  //the following line is needed to tell the framework what
33  // data is being produced
34  setWhatProduced(this);
35  findingRecord<SiPixelGainCalibrationRcd>();
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<SiPixelGainCalibration> SiPixelFakeGainESSource::produce(const SiPixelGainCalibrationRcd&) {
44  using namespace edm::es;
45  unsigned int nmodules = 0;
46  uint32_t nchannels = 0;
47  SiPixelGainCalibration* obj = new SiPixelGainCalibration(25., 30., 2., 3.);
49  const std::vector<uint32_t>& DetIds = reader.getAllDetIds();
50 
51  // Loop over detectors
52  for (std::vector<uint32_t>::const_iterator detit = DetIds.begin(); detit != DetIds.end(); detit++) {
53  nmodules++;
54  std::vector<char> theSiPixelGainCalibration;
55  const std::pair<int, int>& detUnitDimensions = reader.getDetUnitDimensions(*detit);
56 
57  // Loop over columns and rows
58  for (int i = 0; i < detUnitDimensions.first; i++) {
59  for (int j = 0; j < detUnitDimensions.second; j++) {
60  nchannels++;
61  float gain = 2.8;
62  float ped = 28.2;
63  obj->setData(ped, gain, theSiPixelGainCalibration);
64  }
65  }
66 
67  //std::cout << "detid " << (*detit) << std::endl;
68 
69  SiPixelGainCalibration::Range range(theSiPixelGainCalibration.begin(), theSiPixelGainCalibration.end());
70  if (!obj->put(*detit, range, detUnitDimensions.first))
71  edm::LogError("SiPixelFakeGainESSource")
72  << "[SiPixelFakeGainESSource::produce] detid already exists" << std::endl;
73  }
74 
75  //std::cout << "Modules = " << nmodules << " Channels " << nchannels << std::endl;
76 
77  //
78  return std::unique_ptr<SiPixelGainCalibration>(obj);
79 }
80 
82  const edm::IOVSyncValue& iosv,
83  edm::ValidityInterval& oValidity) {
85  oValidity = infinity;
86 }
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
SiPixelFakeGainESSource(const edm::ParameterSet &)
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
const uint16_t range(const Frame &aFrame)
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
const double infinity
tuple reader
Definition: DQM.py:105
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
Log< level::Info, false > LogInfo
std::pair< ContainerIterator, ContainerIterator > Range
virtual std::unique_ptr< SiPixelGainCalibration > produce(const SiPixelGainCalibrationRcd &)
std::string fullPath() const
Definition: FileInPath.cc:161