CMS 3D CMS Logo

SiPixelFakeGainOfflineESSource.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiPixelFakeGainOfflineESSource
4 // Class: SiPixelFakeGainOfflineESSource
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("SiPixelFakeGainOfflineESSource::SiPixelFakeGainOfflineESSource");
32  //the following line is needed to tell the framework what
33  // data is being produced
34  setWhatProduced(this);
35  findingRecord<SiPixelGainCalibrationOfflineRcd>();
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<SiPixelGainCalibrationOffline> SiPixelFakeGainOfflineESSource::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> theSiPixelGainCalibrationOffline;
53  const std::pair<int, int>& detUnitDimensions = reader.getDetUnitDimensions(*detit);
54 
55  // Loop over columns and rows
56  for (int i = 0; i < detUnitDimensions.first; i++) {
57  float totalGain = 0.0;
58  float totalEntries = 0.0;
59  for (int j = 0; j < detUnitDimensions.second; j++) {
60  totalGain += 2.8;
61  float ped = 28.2;
62  totalEntries += 1.0;
63  obj->setDataPedestal(ped, theSiPixelGainCalibrationOffline);
64  if ((j + 1) % 80 == 0) //compute the gain average after each ROC
65  {
66  float gain = totalGain / totalEntries;
67  obj->setDataGain(gain, 80, theSiPixelGainCalibrationOffline);
68  totalGain = 0;
69  totalEntries = 0.0;
70  }
71  }
72  }
73 
74  //std::cout << "detid " << (*detit) << std::endl;
75 
76  SiPixelGainCalibrationOffline::Range range(theSiPixelGainCalibrationOffline.begin(),
77  theSiPixelGainCalibrationOffline.end());
78  // the 80 in the line below represents the number of columns averaged over.
79  if (!obj->put(*detit, range, detUnitDimensions.first))
80  edm::LogError("SiPixelFakeGainOfflineESSource")
81  << "[SiPixelFakeGainOfflineESSource::produce] detid already exists" << std::endl;
82  }
83 
84  //
85  return std::unique_ptr<SiPixelGainCalibrationOffline>(obj);
86 }
87 
89  const edm::IOVSyncValue& iosv,
90  edm::ValidityInterval& oValidity) {
92  oValidity = infinity;
93 }
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
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
std::pair< ContainerIterator, ContainerIterator > Range
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
const double infinity
Log< level::Info, false > LogInfo
SiPixelFakeGainOfflineESSource(const edm::ParameterSet &)
HLT enums.
virtual std::unique_ptr< SiPixelGainCalibrationOffline > produce(const SiPixelGainCalibrationOfflineRcd &)