9 int old_chamber_id, old_strip, new_chamber_id, new_strip;
10 float old_gainslope, old_intercpt, old_chisq;
11 std::vector<int> old_cham_id;
12 std::vector<int> old_strips;
13 std::vector<float> old_slope;
14 std::vector<float> old_intercept;
15 std::vector<float> old_chi2;
16 float new_gainslope, new_intercpt, new_chisq;
17 std::vector<int> new_cham_id;
18 std::vector<int> new_strips;
19 std::vector<float> new_slope;
20 std::vector<float> new_intercept;
21 std::vector<float> new_chi2;
26 int max_istrip, id_layer, max_ring, max_cham;
27 unsigned int old_nrlines = 0;
28 unsigned int new_nrlines = 0;
31 mean = 6.8,
min = -10.0, minchi = 1.0;
33 std::ifstream olddata;
36 std::cerr <<
"Error: old_gains.dat -> no such file!" << std::endl;
40 while (!olddata.eof()) {
41 olddata >> old_chamber_id >> old_strip >> old_gainslope >> old_intercpt >> old_chisq;
42 old_cham_id.push_back(old_chamber_id);
43 old_strips.push_back(old_strip);
44 old_slope.push_back(old_gainslope);
45 old_intercept.push_back(old_intercpt);
46 old_chi2.push_back(old_chisq);
51 std::ifstream newdata;
54 std::cerr <<
"Error: new_gains.txt -> no such file!" << std::endl;
58 while (!newdata.eof()) {
59 newdata >> new_chamber_id >> new_strip >> new_gainslope >> new_intercpt >> new_chisq;
60 new_cham_id.push_back(new_chamber_id);
61 new_strips.push_back(new_strip);
62 new_slope.push_back(new_gainslope);
63 new_intercept.push_back(new_intercpt);
64 new_chi2.push_back(new_chisq);
70 for (
int iendcap =
detId.minEndcapId(); iendcap <=
detId.maxEndcapId(); iendcap++) {
71 for (
int istation =
detId.minStationId(); istation <=
detId.maxStationId(); istation++) {
72 max_ring =
detId.maxRingId();
84 for (
int iring =
detId.minRingId(); iring <= max_ring; iring++) {
86 max_cham =
detId.maxChamberId();
87 if (istation == 1 && iring == 1)
89 if (istation == 1 && iring == 2)
91 if (istation == 1 && iring == 3)
93 if (istation == 2 && iring == 1)
95 if (istation == 2 && iring == 2)
97 if (istation == 3 && iring == 1)
99 if (istation == 3 && iring == 2)
101 if (istation == 4 && iring == 1)
104 for (
int ichamber =
detId.minChamberId(); ichamber <= max_cham; ichamber++) {
105 for (
int ilayer =
detId.minLayerId(); ilayer <=
detId.maxLayerId(); ilayer++) {
107 if (istation == 1 && iring == 3)
110 std::vector<CSCGains::Item> itemvector;
111 itemvector.resize(max_istrip);
112 id_layer = 100000 * iendcap + 10000 * istation + 1000 * iring + 10 * ichamber + ilayer;
114 for (
int istrip = 0; istrip < max_istrip; istrip++) {
115 itemvector[istrip].gain_slope = ((double)rand() / ((double)(RAND_MAX) + (double)(1))) +
mean;
116 itemvector[istrip].gain_intercept = ((double)rand() / ((double)(RAND_MAX) + (double)(1))) +
min;
117 itemvector[istrip].gain_chi2 = ((double)rand() / ((double)(RAND_MAX) + (double)(1))) + minchi;
118 cngains->
gains[id_layer] = itemvector;
128 std::vector<CSCGains::Item> itemvector;
129 itemvector.resize(80);
131 for (
unsigned int mystrip = 0; mystrip < old_nrlines - 1; mystrip++) {
132 if (old_strips[mystrip] == 0)
134 itemvector[istrip].gain_slope = old_slope[mystrip];
135 itemvector[istrip].gain_intercept = old_intercept[mystrip];
136 itemvector[istrip].gain_chi2 = old_chi2[mystrip];
137 cngains->
gains[old_cham_id[mystrip]] = itemvector;
141 itemvector.resize(64);
142 for (
unsigned int mystrip = 0; mystrip < old_nrlines - 1; mystrip++) {
143 if (old_strips[mystrip] == 0)
145 if (old_cham_id[mystrip] >= 113000 && old_cham_id[mystrip] <= 113999) {
146 itemvector[istrip].gain_slope = old_slope[mystrip];
147 itemvector[istrip].gain_intercept = old_intercept[mystrip];
148 itemvector[istrip].gain_chi2 = old_chi2[mystrip];
149 cngains->
gains[old_cham_id[mystrip]] = itemvector;
154 itemvector.resize(64);
155 for (
unsigned int mystrip = 0; mystrip < old_nrlines - 1; mystrip++) {
156 if (old_strips[mystrip] == 0)
158 if (old_cham_id[mystrip] >= 213000 && old_cham_id[mystrip] <= 213999) {
159 itemvector[istrip].gain_slope = old_slope[mystrip];
160 itemvector[istrip].gain_intercept = old_intercept[mystrip];
161 itemvector[istrip].gain_chi2 = old_chi2[mystrip];
162 cngains->
gains[old_cham_id[mystrip]] = itemvector;
168 itemvector.resize(80);
169 for (
unsigned int mystrip = 0; mystrip < new_nrlines - 1; mystrip++) {
170 if (new_strips[mystrip] == 0)
172 itemvector[istrip].gain_slope = new_slope[mystrip];
173 itemvector[istrip].gain_intercept = new_intercept[mystrip];
174 itemvector[istrip].gain_chi2 = new_chi2[mystrip];
175 cngains->
gains[new_cham_id[mystrip]] = itemvector;
179 itemvector.resize(64);
180 for (
unsigned int mystrip = 0; mystrip < new_nrlines - 1; mystrip++) {
181 if (new_strips[mystrip] == 0)
183 if (new_cham_id[mystrip] >= 113000 && new_cham_id[mystrip] <= 113999) {
184 itemvector[istrip].gain_slope = new_slope[mystrip];
185 itemvector[istrip].gain_intercept = new_intercept[mystrip];
186 itemvector[istrip].gain_chi2 = new_chi2[mystrip];
187 cngains->
gains[new_cham_id[mystrip]] = itemvector;
192 itemvector.resize(64);
193 for (
unsigned int mystrip = 0; mystrip < new_nrlines - 1; mystrip++) {
194 if (new_strips[mystrip] == 0)
196 if (new_cham_id[mystrip] >= 213000 && new_cham_id[mystrip] <= 213999) {
197 itemvector[istrip].gain_slope = new_slope[mystrip];
198 itemvector[istrip].gain_intercept = new_intercept[mystrip];
199 itemvector[istrip].gain_chi2 = new_chi2[mystrip];
200 cngains->
gains[new_cham_id[mystrip]] = itemvector;
211 findingRecord<CSCGainsRcd>();
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
CSCGainsConditions(const edm::ParameterSet &)
~CSCGainsConditions() override
static const IOVSyncValue & endOfTime()
std::pair< Time_t, Time_t > ValidityInterval
std::unique_ptr< CSCGains > ReturnType
static CSCGains * prefillGains()
static const IOVSyncValue & beginOfTime()
ReturnType produceGains(const CSCGainsRcd &)
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override