File indexing completed on 2024-04-06 11:58:20
0001 #ifndef _CSCFAKEDBCROSSTALK_H
0002 #define _CSCFAKEDBCROSSTALK_H
0003
0004 #include "FWCore/Framework/interface/ESHandle.h"
0005 #include "FWCore/Framework/interface/ESProducer.h"
0006 #include "FWCore/Framework/interface/Event.h"
0007 #include "FWCore/Framework/interface/EventSetup.h"
0008 #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
0009 #include "FWCore/Framework/interface/Frameworkfwd.h"
0010 #include "FWCore/Framework/interface/MakerMacros.h"
0011 #include "FWCore/Framework/interface/SourceFactory.h"
0012 #include <memory>
0013
0014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0015
0016 #include "CondFormats/CSCObjects/interface/CSCDBCrosstalk.h"
0017 #include "CondFormats/DataRecord/interface/CSCDBCrosstalkRcd.h"
0018 #include <DataFormats/MuonDetId/interface/CSCDetId.h>
0019
0020 class CSCFakeDBCrosstalk : public edm::ESProducer, public edm::EventSetupRecordIntervalFinder {
0021 public:
0022 CSCFakeDBCrosstalk(const edm::ParameterSet &);
0023 ~CSCFakeDBCrosstalk() override;
0024
0025 inline static CSCDBCrosstalk *prefillDBCrosstalk();
0026
0027 typedef std::unique_ptr<CSCDBCrosstalk> Pointer;
0028
0029 Pointer produceDBCrosstalk(const CSCDBCrosstalkRcd &);
0030
0031 private:
0032
0033 void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &,
0034 const edm::IOVSyncValue &,
0035 edm::ValidityInterval &) override;
0036 Pointer cndbCrosstalk;
0037 };
0038
0039 #include <fstream>
0040 #include <iostream>
0041 #include <vector>
0042
0043
0044 inline CSCDBCrosstalk *CSCFakeDBCrosstalk::prefillDBCrosstalk() {
0045 int seed;
0046 float mean, min;
0047 int ii, jj, iii, jjj;
0048 const int MAX_SIZE = 217728;
0049 const int SLOPE_FACTOR = 10000000;
0050 const int INTERCEPT_FACTOR = 100000;
0051
0052 CSCDBCrosstalk *cndbcrosstalk = new CSCDBCrosstalk();
0053 cndbcrosstalk->crosstalk.resize(MAX_SIZE);
0054
0055 seed = 10000;
0056 srand(seed);
0057 mean = -0.0009, min = 0.035;
0058 ii = 0, jj = 0, iii = 0, jjj = 0;
0059
0060 cndbcrosstalk->factor_slope = int(SLOPE_FACTOR);
0061 cndbcrosstalk->factor_intercept = int(INTERCEPT_FACTOR);
0062
0063 for (int i = 0; i < MAX_SIZE; i++) {
0064 cndbcrosstalk->crosstalk[i].xtalk_slope_right =
0065 (short int)((-((double)rand() / ((double)(RAND_MAX) + (double)(1))) / 10000 + mean) * SLOPE_FACTOR + 0.5);
0066 cndbcrosstalk->crosstalk[i].xtalk_intercept_right =
0067 (short int)((((double)rand() / ((double)(RAND_MAX) + (double)(1))) / 100 + min) * INTERCEPT_FACTOR + 0.5);
0068 cndbcrosstalk->crosstalk[i].xtalk_slope_left =
0069 (short int)((-((double)rand() / ((double)(RAND_MAX) + (double)(1))) / 10000 + mean) * SLOPE_FACTOR + 0.5);
0070 cndbcrosstalk->crosstalk[i].xtalk_intercept_left =
0071 (short int)((((double)rand() / ((double)(RAND_MAX) + (double)(1))) / 100 + min) * INTERCEPT_FACTOR + 0.5);
0072
0073
0074 if (i < 34561 && i % 80 == 0) {
0075 cndbcrosstalk->crosstalk[i].xtalk_slope_left = 0;
0076 cndbcrosstalk->crosstalk[i].xtalk_intercept_left = 0;
0077 }
0078
0079 if (i != 0 && i < 34561 && (i + 1) % 80 == 0) {
0080 cndbcrosstalk->crosstalk[i].xtalk_slope_right = 0;
0081 cndbcrosstalk->crosstalk[i].xtalk_intercept_right = 0;
0082 }
0083
0084
0085 if (i > 34560 && i < 48385 && i % 64 == 0) {
0086 cndbcrosstalk->crosstalk[i].xtalk_slope_left = 0;
0087 cndbcrosstalk->crosstalk[i].xtalk_intercept_left = 0;
0088 }
0089
0090 if (i > 34560 && i < 48385 && (i + 1) % 64 == 0) {
0091 cndbcrosstalk->crosstalk[i].xtalk_slope_right = 0;
0092 cndbcrosstalk->crosstalk[i].xtalk_intercept_right = 0;
0093 }
0094
0095
0096 if (i > 48384 && i < 143425) {
0097 ii++;
0098 if (i > 48384 && i < 143425 && ii % 80 == 0) {
0099 cndbcrosstalk->crosstalk[i].xtalk_slope_left = 0;
0100 cndbcrosstalk->crosstalk[i].xtalk_intercept_left = 0;
0101 }
0102 }
0103
0104 if (i > 48384 && i < 143425) {
0105 jj++;
0106 if (i > 48384 && i < 143425 && (jj + 1) % 80 == 0) {
0107 cndbcrosstalk->crosstalk[i].xtalk_slope_right = 0;
0108 cndbcrosstalk->crosstalk[i].xtalk_intercept_right = 0;
0109 }
0110 }
0111
0112
0113 if (i > 143424 && i < 157249 && i % 64 == 0) {
0114 cndbcrosstalk->crosstalk[i].xtalk_slope_left = 0;
0115 cndbcrosstalk->crosstalk[i].xtalk_intercept_left = 0;
0116 }
0117
0118 if (i > 143424 && i < 157249 && (i + 1) % 64 == 0) {
0119 cndbcrosstalk->crosstalk[i].xtalk_slope_right = 0;
0120 cndbcrosstalk->crosstalk[i].xtalk_intercept_right = 0;
0121 }
0122
0123
0124 if (i > 157248) {
0125 iii++;
0126 if (i > 157248 && iii % 80 == 0) {
0127 cndbcrosstalk->crosstalk[i].xtalk_slope_left = 0;
0128 cndbcrosstalk->crosstalk[i].xtalk_intercept_left = 0;
0129 }
0130 }
0131
0132 if (i > 157248) {
0133 jjj++;
0134 if (i > 157248 && (jjj + 1) % 80 == 0) {
0135 cndbcrosstalk->crosstalk[i].xtalk_slope_right = 0;
0136 cndbcrosstalk->crosstalk[i].xtalk_intercept_right = 0;
0137 }
0138 }
0139 }
0140 return cndbcrosstalk;
0141 }
0142
0143 #endif