Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:14:29

0001 // -*- C++ -*-
0002 //
0003 // Package:    SiPixelFakeGainESSource
0004 // Class:      SiPixelFakeGainESSource
0005 //
0006 /**\class SiPixelFakeGainESSource SiPixelFakeGainESSource.h CalibTracker/SiPixelESProducer/src/SiPixelFakeGainESSource.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Vincenzo Chiochia
0015 //         Created:  Fri Apr 27 12:31:25 CEST 2007
0016 //
0017 //
0018 
0019 // user include files
0020 
0021 #include "CalibTracker/SiPixelESProducers/interface/SiPixelFakeGainESSource.h"
0022 #include "CalibTracker/SiPixelESProducers/interface/SiPixelDetInfoFileReader.h"
0023 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0024 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0025 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0026 //
0027 // constructors and destructor
0028 //
0029 SiPixelFakeGainESSource::SiPixelFakeGainESSource(const edm::ParameterSet& conf_)
0030     : fp_(conf_.getParameter<edm::FileInPath>("file")) {
0031   edm::LogInfo("SiPixelFakeGainESSource::SiPixelFakeGainESSource");
0032   //the following line is needed to tell the framework what
0033   // data is being produced
0034   setWhatProduced(this);
0035   findingRecord<SiPixelGainCalibrationRcd>();
0036 }
0037 
0038 SiPixelFakeGainESSource::~SiPixelFakeGainESSource() {
0039   // do anything here that needs to be done at desctruction time
0040   // (e.g. close files, deallocate resources etc.)
0041 }
0042 
0043 std::unique_ptr<SiPixelGainCalibration> SiPixelFakeGainESSource::produce(const SiPixelGainCalibrationRcd&) {
0044   using namespace edm::es;
0045   unsigned int nmodules = 0;
0046   uint32_t nchannels = 0;
0047   SiPixelGainCalibration* obj = new SiPixelGainCalibration(25., 30., 2., 3.);
0048   SiPixelDetInfoFileReader reader(fp_.fullPath());
0049   const std::vector<uint32_t>& DetIds = reader.getAllDetIds();
0050 
0051   // Loop over detectors
0052   for (std::vector<uint32_t>::const_iterator detit = DetIds.begin(); detit != DetIds.end(); detit++) {
0053     nmodules++;
0054     std::vector<char> theSiPixelGainCalibration;
0055     const std::pair<int, int>& detUnitDimensions = reader.getDetUnitDimensions(*detit);
0056 
0057     // Loop over columns and rows
0058     for (int i = 0; i < detUnitDimensions.first; i++) {
0059       for (int j = 0; j < detUnitDimensions.second; j++) {
0060         nchannels++;
0061         float gain = 2.8;
0062         float ped = 28.2;
0063         obj->setData(ped, gain, theSiPixelGainCalibration);
0064       }
0065     }
0066 
0067     //std::cout << "detid " << (*detit) << std::endl;
0068 
0069     SiPixelGainCalibration::Range range(theSiPixelGainCalibration.begin(), theSiPixelGainCalibration.end());
0070     if (!obj->put(*detit, range, detUnitDimensions.first))
0071       edm::LogError("SiPixelFakeGainESSource")
0072           << "[SiPixelFakeGainESSource::produce] detid already exists" << std::endl;
0073   }
0074 
0075   //std::cout << "Modules = " << nmodules << " Channels " << nchannels << std::endl;
0076 
0077   //
0078   return std::unique_ptr<SiPixelGainCalibration>(obj);
0079 }
0080 
0081 void SiPixelFakeGainESSource::setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
0082                                              const edm::IOVSyncValue& iosv,
0083                                              edm::ValidityInterval& oValidity) {
0084   edm::ValidityInterval infinity(iosv.beginOfTime(), iosv.endOfTime());
0085   oValidity = infinity;
0086 }