CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/CalibMuon/CSCCalibration/interface/CSCFakeDBPedestals.h

Go to the documentation of this file.
00001 #ifndef _CSCFAKEDBPEDESTALS_H
00002 #define _CSCFAKEDBPEDESTALS_H
00003 
00004 #include <memory>
00005 #include "FWCore/Framework/interface/SourceFactory.h"
00006 #include "FWCore/Framework/interface/Frameworkfwd.h"
00007 #include "FWCore/Framework/interface/ESProducer.h"
00008 #include "FWCore/Framework/interface/Event.h"
00009 #include "FWCore/Framework/interface/MakerMacros.h"
00010 #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
00011 #include "FWCore/Framework/interface/ESHandle.h"
00012 #include "FWCore/Framework/interface/EventSetup.h"
00013 
00014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00015 
00016 #include "CondFormats/CSCObjects/interface/CSCDBPedestals.h"
00017 #include "CondFormats/DataRecord/interface/CSCDBPedestalsRcd.h"
00018 #include <DataFormats/MuonDetId/interface/CSCDetId.h>
00019 #include <boost/shared_ptr.hpp>
00020 
00021 class CSCFakeDBPedestals: public edm::ESProducer, public edm::EventSetupRecordIntervalFinder  {
00022    public:
00023       CSCFakeDBPedestals(const edm::ParameterSet&);
00024       ~CSCFakeDBPedestals();
00025       
00026        inline static CSCDBPedestals * prefillDBPedestals();
00027 
00028       typedef  boost::shared_ptr<CSCDBPedestals> Pointer;
00029 
00030       Pointer produceDBPedestals(const CSCDBPedestalsRcd&);
00031 
00032    private:
00033       // ----------member data ---------------------------
00034     void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue&, edm::ValidityInterval & );
00035 
00036       Pointer cndbPedestals ;   
00037 };
00038 
00039 #include<fstream>
00040 #include<vector>
00041 #include<iostream>
00042 
00043 // to workaround plugin library
00044 inline CSCDBPedestals *  CSCFakeDBPedestals::prefillDBPedestals()
00045 {
00046   int seed;
00047   long int M;
00048   float meanped,meanrms;
00049   const int MAX_SIZE = 217728; //or 252288 for ME4/2 chambers
00050   const int PED_FACTOR=10;
00051   const int RMS_FACTOR=1000;
00052  
00053   CSCDBPedestals * cndbpedestals = new CSCDBPedestals();
00054   cndbpedestals->pedestals.resize(MAX_SIZE);
00055 
00056   seed = 10000; 
00057   srand(seed);
00058   meanped=600.0, meanrms=1.5, M=1000;
00059   cndbpedestals->factor_ped = int (PED_FACTOR);
00060   cndbpedestals->factor_rms = int (RMS_FACTOR);
00061  
00062   for(int i=0; i<MAX_SIZE;i++){
00063     cndbpedestals->pedestals[i].ped=(short int) (((double)rand()/((double)(RAND_MAX)+(double)(1)))*100+meanped*PED_FACTOR+0.5);
00064     cndbpedestals->pedestals[i].rms= (short int) (((double)rand()/((double)(RAND_MAX)+(double)(1)))+meanrms*RMS_FACTOR+0.5);
00065   }
00066   return cndbpedestals;
00067 }  
00068 
00069 #endif