Go to the documentation of this file.00001 #ifndef _CSCFAKEDBCROSSTALK_H
00002 #define _CSCFAKEDBCROSSTALK_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/CSCDBCrosstalk.h"
00017 #include "CondFormats/DataRecord/interface/CSCDBCrosstalkRcd.h"
00018 #include <DataFormats/MuonDetId/interface/CSCDetId.h>
00019 #include <boost/shared_ptr.hpp>
00020
00021 class CSCFakeDBCrosstalk: public edm::ESProducer, public edm::EventSetupRecordIntervalFinder {
00022 public:
00023 CSCFakeDBCrosstalk(const edm::ParameterSet&);
00024 ~CSCFakeDBCrosstalk();
00025
00026 inline static CSCDBCrosstalk * prefillDBCrosstalk();
00027
00028 typedef boost::shared_ptr<CSCDBCrosstalk> Pointer;
00029
00030 Pointer produceDBCrosstalk(const CSCDBCrosstalkRcd&);
00031
00032 private:
00033
00034 void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue&, edm::ValidityInterval & );
00035 Pointer cndbCrosstalk ;
00036
00037 };
00038
00039 #include<fstream>
00040 #include<vector>
00041 #include<iostream>
00042
00043
00044 inline CSCDBCrosstalk * CSCFakeDBCrosstalk::prefillDBCrosstalk()
00045 {
00046 int seed;
00047 float mean,min;
00048 int ii,jj,iii,jjj;
00049 const int MAX_SIZE = 217728;
00050 const int SLOPE_FACTOR=10000000;
00051 const int INTERCEPT_FACTOR=100000;
00052
00053 CSCDBCrosstalk * cndbcrosstalk = new CSCDBCrosstalk();
00054 cndbcrosstalk->crosstalk.resize(MAX_SIZE);
00055
00056 seed = 10000;
00057 srand(seed);
00058 mean=-0.0009, min=0.035;
00059 ii=0,jj=0,iii=0,jjj=0;
00060
00061 cndbcrosstalk->factor_slope = int (SLOPE_FACTOR);
00062 cndbcrosstalk->factor_intercept = int (INTERCEPT_FACTOR);
00063
00064 for(int i=0; i<MAX_SIZE;i++){
00065 cndbcrosstalk->crosstalk[i].xtalk_slope_right = (short int) ((-((double)rand()/((double)(RAND_MAX)+(double)(1)))/10000+mean)*SLOPE_FACTOR+0.5);
00066 cndbcrosstalk->crosstalk[i].xtalk_intercept_right= (short int) ((((double)rand()/((double)(RAND_MAX)+(double)(1)))/100+min)*INTERCEPT_FACTOR+0.5);
00067 cndbcrosstalk->crosstalk[i].xtalk_slope_left= (short int) ((-((double)rand()/((double)(RAND_MAX)+(double)(1)))/10000+mean)*SLOPE_FACTOR+0.5);
00068 cndbcrosstalk->crosstalk[i].xtalk_intercept_left=(short int) ((((double)rand()/((double)(RAND_MAX)+(double)(1)))/100+min)*INTERCEPT_FACTOR+0.5);
00069
00070
00071
00072 if(i<34561 && i%80==0){
00073 cndbcrosstalk->crosstalk[i].xtalk_slope_left=0;
00074 cndbcrosstalk->crosstalk[i].xtalk_intercept_left=0;
00075 }
00076
00077 if(i!=0 && i<34561 && (i+1)%80==0){
00078 cndbcrosstalk->crosstalk[i].xtalk_slope_right=0;
00079 cndbcrosstalk->crosstalk[i].xtalk_intercept_right=0;
00080 }
00081
00082
00083 if(i>34560 && i<48385 && i%64==0){
00084 cndbcrosstalk->crosstalk[i].xtalk_slope_left=0;
00085 cndbcrosstalk->crosstalk[i].xtalk_intercept_left=0;
00086 }
00087
00088 if(i>34560 && i<48385 && (i+1)%64==0){
00089 cndbcrosstalk->crosstalk[i].xtalk_slope_right=0;
00090 cndbcrosstalk->crosstalk[i].xtalk_intercept_right=0;
00091 }
00092
00093
00094 if(i>48384 && i<143425){
00095 ii++;
00096 if(i>48384 && i<143425 && ii%80==0){
00097 cndbcrosstalk->crosstalk[i].xtalk_slope_left=0;
00098 cndbcrosstalk->crosstalk[i].xtalk_intercept_left=0;
00099 }
00100 }
00101
00102 if(i>48384 && i<143425){
00103 jj++;
00104 if(i>48384 && i<143425 && (jj+1)%80==0){
00105 cndbcrosstalk->crosstalk[i].xtalk_slope_right=0;
00106 cndbcrosstalk->crosstalk[i].xtalk_intercept_right=0;
00107 }
00108 }
00109
00110
00111 if(i>143424 && i<157249 &&i%64==0){
00112 cndbcrosstalk->crosstalk[i].xtalk_slope_left=0;
00113 cndbcrosstalk->crosstalk[i].xtalk_intercept_left=0;
00114 }
00115
00116 if(i>143424 && i<157249 && (i+1)%64==0){
00117 cndbcrosstalk->crosstalk[i].xtalk_slope_right=0;
00118 cndbcrosstalk->crosstalk[i].xtalk_intercept_right=0;
00119 }
00120
00121
00122
00123 if(i>157248){
00124 iii++;
00125 if(i>157248 && iii%80==0){
00126 cndbcrosstalk->crosstalk[i].xtalk_slope_left=0;
00127 cndbcrosstalk->crosstalk[i].xtalk_intercept_left=0;
00128 }
00129 }
00130
00131 if(i>157248){
00132 jjj++;
00133 if(i>157248 && (jjj+1)%80==0){
00134 cndbcrosstalk->crosstalk[i].xtalk_slope_right=0;
00135 cndbcrosstalk->crosstalk[i].xtalk_intercept_right=0;
00136 }
00137 }
00138 }
00139 return cndbcrosstalk;
00140 }
00141
00142 #endif
00143
00144
00145
00146
00147