Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:59:33

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