CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/CalibTracker/SiPixelESProducers/plugins/SiPixelFakeGainESSource.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    SiPixelFakeGainESSource
00004 // Class:      SiPixelFakeGainESSource
00005 // 
00013 //
00014 // Original Author:  Vincenzo Chiochia
00015 //         Created:  Fri Apr 27 12:31:25 CEST 2007
00016 // $Id: SiPixelFakeGainESSource.cc,v 1.6 2008/02/11 15:23:38 friis Exp $
00017 //
00018 //
00019 
00020 // user include files
00021 
00022 #include "CalibTracker/SiPixelESProducers/interface/SiPixelFakeGainESSource.h"
00023 #include "CalibTracker/SiPixelESProducers/interface/SiPixelDetInfoFileReader.h"
00024 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00025 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00026 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00027 //
00028 // constructors and destructor
00029 //
00030 SiPixelFakeGainESSource::SiPixelFakeGainESSource(const edm::ParameterSet& conf_) :
00031   fp_(conf_.getParameter<edm::FileInPath>("file"))
00032 {
00033  edm::LogInfo("SiPixelFakeGainESSource::SiPixelFakeGainESSource");
00034   //the following line is needed to tell the framework what
00035   // data is being produced
00036   setWhatProduced(this);
00037   findingRecord<SiPixelGainCalibrationRcd>();
00038 }
00039 
00040 SiPixelFakeGainESSource::~SiPixelFakeGainESSource()
00041 {
00042  
00043    // do anything here that needs to be done at desctruction time
00044    // (e.g. close files, deallocate resources etc.)
00045 
00046 }
00047 
00048 std::auto_ptr<SiPixelGainCalibration> SiPixelFakeGainESSource::produce(const SiPixelGainCalibrationRcd & )
00049 {
00050 
00051    using namespace edm::es;
00052    unsigned int nmodules = 0;
00053    uint32_t nchannels = 0;
00054    SiPixelGainCalibration * obj = new SiPixelGainCalibration(25.,30., 2.,3.);
00055    SiPixelDetInfoFileReader reader(fp_.fullPath());
00056    const std::vector<uint32_t> DetIds = reader.getAllDetIds();
00057 
00058    // Loop over detectors
00059    for(std::vector<uint32_t>::const_iterator detit=DetIds.begin(); detit!=DetIds.end(); detit++) {
00060      nmodules++;
00061      std::vector<char> theSiPixelGainCalibration;
00062      const std::pair<int, int> & detUnitDimensions = reader.getDetUnitDimensions(*detit);
00063 
00064      // Loop over columns and rows
00065      for(int i=0; i<detUnitDimensions.first; i++) {
00066        for(int j=0; j<detUnitDimensions.second; j++) {
00067          nchannels++;
00068          float gain =  2.8;
00069          float ped  = 28.2;      
00070          obj->setData(ped, gain , theSiPixelGainCalibration);    
00071        }
00072      }
00073 
00074      //std::cout << "detid " << (*detit) << std::endl;
00075 
00076      SiPixelGainCalibration::Range range(theSiPixelGainCalibration.begin(),theSiPixelGainCalibration.end());
00077      if( !obj->put(*detit,range,detUnitDimensions.first) )
00078        edm::LogError("SiPixelFakeGainESSource")<<"[SiPixelFakeGainESSource::produce] detid already exists"<<std::endl;
00079    }
00080 
00081    //std::cout << "Modules = " << nmodules << " Channels " << nchannels << std::endl;
00082    
00083 
00084    // 
00085    return std::auto_ptr<SiPixelGainCalibration>(obj);
00086 
00087 
00088 }
00089 
00090 void SiPixelFakeGainESSource::setIntervalFor( const edm::eventsetup::EventSetupRecordKey&, 
00091                                                 const edm::IOVSyncValue& iosv, 
00092                                                 edm::ValidityInterval& oValidity ) {
00093   edm::ValidityInterval infinity( iosv.beginOfTime(), iosv.endOfTime() );
00094   oValidity = infinity;  
00095 }