1 #ifndef _CSCCROSSTALKDBCONDITIONS_H
2 #define _CSCCROSSTALKDBCONDITIONS_H
49 const int MAX_SIZE = 252288;
50 const int SLOPE_FACTOR=10000000;
51 const int INTERCEPT_FACTOR=100000;
52 const int MAX_SHORT= 32767;
55 int db_index,new_index;
56 float db_slope_right,db_slope_left,db_intercept_right;
57 float db_intercept_left;
58 std::vector<int> db_index_id;
59 std::vector<float> db_slope_r;
60 std::vector<float> db_intercept_r;
61 std::vector<float> db_slope_l;
62 std::vector<float> db_intercept_l;
63 float new_slope_right,new_slope_left,new_intercept_right;
64 float new_intercept_left;
65 std::vector<int> new_index_id;
66 std::vector<float> new_slope_r;
67 std::vector<float> new_intercept_r;
68 std::vector<float> new_slope_l;
69 std::vector<float> new_intercept_l;
78 std::cerr <<
"Error: old_dbxtalk.dat -> no such file!"<< std::endl;
82 while (!dbdata.eof() ) {
83 dbdata >> db_index >> db_slope_right >> db_intercept_right >> db_slope_left >> db_intercept_left ;
84 db_index_id.push_back(db_index);
85 db_slope_r.push_back(db_slope_right);
86 db_slope_l.push_back(db_slope_left);
87 db_intercept_r.push_back(db_intercept_right);
88 db_intercept_l.push_back(db_intercept_left);
93 std::ifstream newdata;
96 std::cerr <<
"Error: xtalk.dat -> no such file!"<< std::endl;
100 while (!newdata.eof() ) {
101 newdata >> new_index >> new_slope_right >> new_intercept_right >> new_slope_left >> new_intercept_left;
102 new_index_id.push_back(new_index);
103 new_slope_r.push_back(new_slope_right);
104 new_slope_l.push_back(new_slope_left);
105 new_intercept_r.push_back(new_intercept_right);
106 new_intercept_l.push_back(new_intercept_left);
112 itemvector.resize(MAX_SIZE);
116 for(
int i=0;
i<MAX_SIZE;++
i){
117 itemvector[
i].xtalk_slope_right=(
short int) (db_slope_r[
i]*SLOPE_FACTOR+0.5);
118 itemvector[
i].xtalk_intercept_right= (
short int) (db_intercept_r[
i]*INTERCEPT_FACTOR+0.5);
119 itemvector[
i].xtalk_slope_left= (
short int) (db_slope_l[
i]*SLOPE_FACTOR+0.5);
120 itemvector[
i].xtalk_intercept_left= (
short int) (db_intercept_l[
i]*INTERCEPT_FACTOR+0.5);
123 for(
int i=0;
i<MAX_SIZE;++
i){
124 counter=db_index_id[
i];
125 for (
unsigned int k=0;
k<new_index_id.size()-1;
k++){
126 if(counter==new_index_id[
k]){
127 if ((
short int) (fabs(new_slope_r[k]*SLOPE_FACTOR+0.5))<MAX_SHORT) itemvector[counter].xtalk_slope_right= int (new_slope_r[k]*SLOPE_FACTOR+0.5);
128 if ((
short int) (fabs(new_intercept_r[k]*INTERCEPT_FACTOR+0.5))<MAX_SHORT) itemvector[counter].xtalk_intercept_right= int (new_intercept_r[k]*INTERCEPT_FACTOR+0.5);
129 if ((
short int) (fabs(new_slope_l[k]*SLOPE_FACTOR+0.5))<MAX_SHORT) itemvector[counter].xtalk_slope_left= int (new_slope_l[k]*SLOPE_FACTOR+0.5);
130 if ((
short int) (fabs(new_intercept_l[k]*INTERCEPT_FACTOR+0.5))<MAX_SHORT) itemvector[counter].xtalk_intercept_left= int (new_intercept_l[k]*INTERCEPT_FACTOR+0.5);
131 itemvector[
i] = itemvector[counter];
137 itemvector[counter].xtalk_slope_right = int (db_slope_r[
i]);
138 itemvector[counter].xtalk_slope_left = int (db_slope_l[i]);
139 itemvector[counter].xtalk_intercept_right = int (db_intercept_r[i]);
140 itemvector[counter].xtalk_intercept_left = int (db_intercept_l[i]);
144 return cndbcrosstalk;
CSCCrosstalkDBConditions(const edm::ParameterSet &)
ReturnType produceDBCrosstalk(const CSCDBCrosstalkRcd &)
static CSCDBCrosstalk * prefillDBCrosstalk()
CSCDBCrosstalk * cndbCrosstalk
std::vector< Item > CrosstalkContainer
~CSCCrosstalkDBConditions()
const CSCDBCrosstalk * ReturnType
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &)
CrosstalkContainer crosstalk