1 #ifndef _CSCCROSSTALKDBCONDITIONS_H
2 #define _CSCCROSSTALKDBCONDITIONS_H
46 const int SLOPE_FACTOR = 10000000;
47 const int INTERCEPT_FACTOR = 100000;
48 const int MAX_SHORT = 32767;
51 int db_index, new_index;
52 float db_slope_right, db_slope_left, db_intercept_right;
53 float db_intercept_left;
54 std::vector<int> db_index_id;
55 std::vector<float> db_slope_r;
56 std::vector<float> db_intercept_r;
57 std::vector<float> db_slope_l;
58 std::vector<float> db_intercept_l;
59 float new_slope_right, new_slope_left, new_intercept_right;
60 float new_intercept_left;
61 std::vector<int> new_index_id;
62 std::vector<float> new_slope_r;
63 std::vector<float> new_intercept_r;
64 std::vector<float> new_slope_l;
65 std::vector<float> new_intercept_l;
74 std::cerr <<
"Error: old_dbxtalk.dat -> no such file!" << std::endl;
78 while (!dbdata.eof()) {
79 dbdata >> db_index >> db_slope_right >> db_intercept_right >> db_slope_left >> db_intercept_left;
80 db_index_id.push_back(db_index);
81 db_slope_r.push_back(db_slope_right);
82 db_slope_l.push_back(db_slope_left);
83 db_intercept_r.push_back(db_intercept_right);
84 db_intercept_l.push_back(db_intercept_left);
89 std::ifstream newdata;
92 std::cerr <<
"Error: xtalk.dat -> no such file!" << std::endl;
96 while (!newdata.eof()) {
97 newdata >> new_index >> new_slope_right >> new_intercept_right >> new_slope_left >> new_intercept_left;
98 new_index_id.push_back(new_index);
99 new_slope_r.push_back(new_slope_right);
100 new_slope_l.push_back(new_slope_left);
101 new_intercept_r.push_back(new_intercept_right);
102 new_intercept_l.push_back(new_intercept_left);
108 itemvector.resize(MAX_SIZE);
113 itemvector[
i].xtalk_slope_right = (
short int)(db_slope_r[
i] * SLOPE_FACTOR + 0.5);
114 itemvector[
i].xtalk_intercept_right = (
short int)(db_intercept_r[
i] * INTERCEPT_FACTOR + 0.5);
115 itemvector[
i].xtalk_slope_left = (
short int)(db_slope_l[
i] * SLOPE_FACTOR + 0.5);
116 itemvector[
i].xtalk_intercept_left = (
short int)(db_intercept_l[
i] * INTERCEPT_FACTOR + 0.5);
120 counter = db_index_id[
i];
121 for (
unsigned int k = 0;
k < new_index_id.size() - 1;
k++) {
122 if (counter == new_index_id[
k]) {
123 if ((
short int)(fabs(new_slope_r[k] * SLOPE_FACTOR + 0.5)) < MAX_SHORT)
124 itemvector[
counter].xtalk_slope_right = int(new_slope_r[k] * SLOPE_FACTOR + 0.5);
125 if ((
short int)(fabs(new_intercept_r[k] * INTERCEPT_FACTOR + 0.5)) < MAX_SHORT)
126 itemvector[
counter].xtalk_intercept_right = int(new_intercept_r[k] * INTERCEPT_FACTOR + 0.5);
127 if ((
short int)(fabs(new_slope_l[k] * SLOPE_FACTOR + 0.5)) < MAX_SHORT)
128 itemvector[
counter].xtalk_slope_left = int(new_slope_l[k] * SLOPE_FACTOR + 0.5);
129 if ((
short int)(fabs(new_intercept_l[k] * INTERCEPT_FACTOR + 0.5)) < MAX_SHORT)
130 itemvector[
counter].xtalk_intercept_left = int(new_intercept_l[k] * INTERCEPT_FACTOR + 0.5);
131 itemvector[
i] = itemvector[
counter];
137 if (counter > 223968) {
138 itemvector[
counter].xtalk_slope_right = int(db_slope_r[
i]);
139 itemvector[
counter].xtalk_slope_left = int(db_slope_l[i]);
140 itemvector[
counter].xtalk_intercept_right = int(db_intercept_r[i]);
141 itemvector[
counter].xtalk_intercept_left = int(db_intercept_l[i]);
145 return cndbcrosstalk;
CSCCrosstalkDBConditions(const edm::ParameterSet &)
ReturnType produceDBCrosstalk(const CSCDBCrosstalkRcd &)
static CSCDBCrosstalk * prefillDBCrosstalk()
std::vector< Item > CrosstalkContainer
std::unique_ptr< CSCDBCrosstalk > ReturnType
~CSCCrosstalkDBConditions() override
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
static std::atomic< unsigned int > counter
constexpr unsigned int MAX_SIZE
CrosstalkContainer crosstalk