Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Package:    SiPixelFakeGainForHLTESSource
0004 // Class:      SiPixelFakeGainForHLTESSource
0005 //
0006 /**\class SiPixelFakeGainForHLTESSource SiPixelFakeGainForHLTESSource.h CalibTracker/SiPixelESProducer/src/SiPixelFakeGainForHLTESSource.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/SiPixelFakeGainForHLTESSource.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 SiPixelFakeGainForHLTESSource::SiPixelFakeGainForHLTESSource(const edm::ParameterSet& conf_)
0030     : fp_(conf_.getParameter<edm::FileInPath>("file")) {
0031   edm::LogInfo("SiPixelFakeGainForHLTESSource::SiPixelFakeGainForHLTESSource");
0032   //the following line is needed to tell the framework what
0033   // data is being produced
0034   setWhatProduced(this);
0035   findingRecord<SiPixelGainCalibrationForHLTRcd>();
0036 }
0037 
0038 SiPixelFakeGainForHLTESSource::~SiPixelFakeGainForHLTESSource() {
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<SiPixelGainCalibrationForHLT> SiPixelFakeGainForHLTESSource::produce(
0044     const SiPixelGainCalibrationForHLTRcd&) {
0045   using namespace edm::es;
0046   unsigned int nmodules = 0;
0047   uint32_t nchannels = 0;
0048   SiPixelGainCalibrationForHLT* obj = new SiPixelGainCalibrationForHLT(25., 30., 2., 3.);
0049   SiPixelDetInfoFileReader reader(fp_.fullPath());
0050   const std::vector<uint32_t>& DetIds = reader.getAllDetIds();
0051 
0052   // Loop over detectors
0053   for (std::vector<uint32_t>::const_iterator detit = DetIds.begin(); detit != DetIds.end(); detit++) {
0054     nmodules++;
0055     std::vector<char> theSiPixelGainCalibration;
0056     const std::pair<int, int>& detUnitDimensions = reader.getDetUnitDimensions(*detit);
0057 
0058     // Loop over columns and rows
0059 
0060     for (int i = 0; i < detUnitDimensions.first; i++) {
0061       float totalGain = 0.0;
0062       float totalPed = 0.0;
0063       float totalEntries = 0.0;
0064       for (int j = 0; j < detUnitDimensions.second; j++) {
0065         nchannels++;
0066         totalGain += 2.8;
0067         totalPed += 28.2;
0068         totalEntries++;
0069         if ((j + 1) % 80 == 0) {
0070           float gain = totalGain / totalEntries;
0071           float ped = totalPed / totalEntries;
0072 
0073           obj->setData(ped, gain, theSiPixelGainCalibration);
0074           totalGain = 0.;
0075           totalPed = 0.;
0076           totalEntries = 0.;
0077         }
0078       }
0079     }
0080 
0081     //std::cout << "detid " << (*detit) << std::endl;
0082 
0083     SiPixelGainCalibrationForHLT::Range range(theSiPixelGainCalibration.begin(), theSiPixelGainCalibration.end());
0084     int nCols = detUnitDimensions.first;
0085     if (!obj->put(*detit, range, nCols))
0086       edm::LogError("SiPixelFakeGainForHLTESSource")
0087           << "[SiPixelFakeGainForHLTESSource::produce] detid already exists" << std::endl;
0088   }
0089 
0090   //std::cout << "Modules = " << nmodules << " Channels " << nchannels << std::endl;
0091 
0092   //
0093   return std::unique_ptr<SiPixelGainCalibrationForHLT>(obj);
0094 }
0095 
0096 void SiPixelFakeGainForHLTESSource::setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
0097                                                    const edm::IOVSyncValue& iosv,
0098                                                    edm::ValidityInterval& oValidity) {
0099   edm::ValidityInterval infinity(iosv.beginOfTime(), iosv.endOfTime());
0100   oValidity = infinity;
0101 }