CMS 3D CMS Logo

SiPixelFakeGainOfflineESSource.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CalibTracker/SiPixelGainESProducers
4 // Class: SiPixelFakeGainOfflineESSource
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  ~SiPixelFakeGainOfflineESSource() override = default;
46 
47  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
48 
49  virtual std::unique_ptr<SiPixelGainCalibrationOffline> produce(const SiPixelGainCalibrationOfflineRcd&);
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("SiPixelFakeGainOfflineESSource::SiPixelFakeGainOfflineESSource");
66  //the following line is needed to tell the framework what
67  // data is being produced
68  setWhatProduced(this);
69  findingRecord<SiPixelGainCalibrationOfflineRcd>();
70 }
71 
72 std::unique_ptr<SiPixelGainCalibrationOffline> SiPixelFakeGainOfflineESSource::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> theSiPixelGainCalibrationOffline;
82  const std::pair<int, int>& detUnitDimensions = reader.getDetUnitDimensions(*detit);
83 
84  // Loop over columns and rows
85  for (int i = 0; i < detUnitDimensions.first; i++) {
86  float totalGain = 0.0;
87  float totalEntries = 0.0;
88  for (int j = 0; j < detUnitDimensions.second; j++) {
89  totalGain += 2.8;
90  float ped = 28.2;
91  totalEntries += 1.0;
92  obj->setDataPedestal(ped, theSiPixelGainCalibrationOffline);
93  if ((j + 1) % 80 == 0) //compute the gain average after each ROC
94  {
95  float gain = totalGain / totalEntries;
96  obj->setDataGain(gain, 80, theSiPixelGainCalibrationOffline);
97  totalGain = 0;
98  totalEntries = 0.0;
99  }
100  }
101  }
102 
103  //std::cout << "detid " << (*detit) << std::endl;
104 
105  SiPixelGainCalibrationOffline::Range range(theSiPixelGainCalibrationOffline.begin(),
106  theSiPixelGainCalibrationOffline.end());
107  // the 80 in the line below represents the number of columns averaged over.
108  if (!obj->put(*detit, range, detUnitDimensions.first))
109  edm::LogError("SiPixelFakeGainOfflineESSource")
110  << "[SiPixelFakeGainOfflineESSource::produce] detid already exists" << std::endl;
111  }
112 
113  //
114  return std::unique_ptr<SiPixelGainCalibrationOffline>(obj);
115 }
116 
118  const edm::IOVSyncValue& iosv,
119  edm::ValidityInterval& oValidity) {
121  oValidity = infinity;
122 }
123 
126  desc.add<edm::FileInPath>("file", edm::FileInPath("CalibTracker/SiPixelESProducers/data/PixelSkimmedGeometry.txt"));
127  descriptions.addWithDefaultLabel(desc);
128 }
129 
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
~SiPixelFakeGainOfflineESSource() override=default
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
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:92
SiPixelFakeGainOfflineESSource(const edm::ParameterSet &)
HLT enums.
virtual std::unique_ptr< SiPixelGainCalibrationOffline > produce(const SiPixelGainCalibrationOfflineRcd &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const std::string & fullPath() const
Definition: FileInPath.cc:144