00001 #ifndef _CSCFAKEDBGAINS_H 00002 #define _CSCFAKEDBGAINS_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/CSCDBGains.h" 00017 #include "CondFormats/DataRecord/interface/CSCDBGainsRcd.h" 00018 #include <DataFormats/MuonDetId/interface/CSCDetId.h> 00019 00020 #include <boost/shared_ptr.hpp> 00021 00022 class CSCFakeDBGains: public edm::ESProducer, public edm::EventSetupRecordIntervalFinder { 00023 public: 00024 CSCFakeDBGains(const edm::ParameterSet&); 00025 ~CSCFakeDBGains(); 00026 00027 inline static CSCDBGains* prefillDBGains(); 00028 00029 typedef boost::shared_ptr<CSCDBGains> Pointer; 00030 Pointer produceDBGains(const CSCDBGainsRcd&); 00031 00032 private: 00033 void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue&, edm::ValidityInterval & ); 00034 00035 // member data 00036 Pointer cndbGains ; 00037 00038 }; 00039 00040 #include<fstream> 00041 #include<vector> 00042 #include<iostream> 00043 00044 // to workaround plugin library 00045 inline CSCDBGains* CSCFakeDBGains::prefillDBGains() 00046 { 00047 int seed; 00048 long int M; 00049 float mean,min, minchi; 00050 const int MAX_SIZE = 217728; //or 252288 for ME4/2 chambers 00051 const int FACTOR=1000; 00052 00053 CSCDBGains* cndbgains = new CSCDBGains(); 00054 cndbgains->gains.resize(MAX_SIZE); 00055 00056 seed = 10000; 00057 srand(seed); 00058 mean=6.8, min=-10.0, minchi=1.0, M=1000; 00059 cndbgains->factor_gain = int (FACTOR); 00060 00061 for(int i=0; i<MAX_SIZE;i++){ 00062 cndbgains->gains[i].gain_slope= (short int) (((double)rand()/((double)(RAND_MAX)+(double)(1)))+mean*FACTOR+0.5); 00063 } 00064 return cndbgains; 00065 } 00066 00067 #endif