10 int old_chamber_id,old_strip,new_chamber_id,new_strip;
11 float old_gainslope,old_intercpt, old_chisq;
12 std::vector<int> old_cham_id;
13 std::vector<int> old_strips;
14 std::vector<float> old_slope;
15 std::vector<float> old_intercept;
16 std::vector<float> old_chi2;
17 float new_gainslope,new_intercpt, new_chisq;
18 std::vector<int> new_cham_id;
19 std::vector<int> new_strips;
20 std::vector<float> new_slope;
21 std::vector<float> new_intercept;
22 std::vector<float> new_chi2;
27 int max_istrip,id_layer,max_ring,max_cham;
28 unsigned int old_nrlines=0;
29 unsigned int new_nrlines=0;
32 mean=6.8, min=-10.0, minchi=1.0;
34 std::ifstream olddata;
37 std::cerr <<
"Error: old_gains.dat -> no such file!"<< std::endl;
41 while (!olddata.eof() ) {
42 olddata >> old_chamber_id >> old_strip >> old_gainslope >> old_intercpt >> old_chisq ;
43 old_cham_id.push_back(old_chamber_id);
44 old_strips.push_back(old_strip);
45 old_slope.push_back(old_gainslope);
46 old_intercept.push_back(old_intercpt);
47 old_chi2.push_back(old_chisq);
52 std::ifstream newdata;
55 std::cerr <<
"Error: new_gains.txt -> no such file!"<< std::endl;
59 while (!newdata.eof() ) {
60 newdata >> new_chamber_id >> new_strip >> new_gainslope >> new_intercpt >> new_chisq ;
61 new_cham_id.push_back(new_chamber_id);
62 new_strips.push_back(new_strip);
63 new_slope.push_back(new_gainslope);
64 new_intercept.push_back(new_intercpt);
65 new_chi2.push_back(new_chisq);
77 if(istation==1) max_ring=3;
78 if(istation==2) max_ring=2;
79 if(istation==3) max_ring=2;
80 if(istation==4) max_ring=1;
82 for(
int iring=detId.
minRingId(); iring<=max_ring; iring++){
85 if(istation==1 && iring==1) max_cham=36;
86 if(istation==1 && iring==2) max_cham=36;
87 if(istation==1 && iring==3) max_cham=36;
88 if(istation==2 && iring==1) max_cham=18;
89 if(istation==2 && iring==2) max_cham=36;
90 if(istation==3 && iring==1) max_cham=18;
91 if(istation==3 && iring==2) max_cham=36;
92 if(istation==4 && iring==1) max_cham=18;
94 for(
int ichamber=detId.
minChamberId(); ichamber<=max_cham; ichamber++){
97 if(istation==1 && iring==3) max_istrip=64;
99 std::vector<CSCGains::Item> itemvector;
100 itemvector.resize(max_istrip);
101 id_layer = 100000*iendcap + 10000*istation + 1000*iring + 10*ichamber + ilayer;
103 for(
int istrip=0;istrip<max_istrip;istrip++){
104 itemvector[istrip].gain_slope=((double)
rand()/((double)(RAND_MAX)+(double)(1)))+
mean;
105 itemvector[istrip].gain_intercept=((double)
rand()/((double)(RAND_MAX)+(double)(1)))+
min;
106 itemvector[istrip].gain_chi2=((double)
rand()/((double)(RAND_MAX)+(double)(1)))+minchi;
107 cngains->
gains[id_layer]=itemvector;
117 std::vector<CSCGains::Item> itemvector;
118 itemvector.resize(80);
120 for(
unsigned int mystrip=0; mystrip<old_nrlines-1; mystrip++){
121 if(old_strips[mystrip]==0) istrip = 0;
122 itemvector[istrip].gain_slope=old_slope[mystrip];
123 itemvector[istrip].gain_intercept=old_intercept[mystrip];
124 itemvector[istrip].gain_chi2=old_chi2[mystrip];
125 cngains->
gains[old_cham_id[mystrip]]=itemvector;
130 itemvector.resize(64);
131 for(
unsigned int mystrip=0; mystrip<old_nrlines-1; mystrip++){
132 if(old_strips[mystrip]==0) istrip = 0;
133 if(old_cham_id[mystrip] >= 113000 && old_cham_id[mystrip] <= 113999){
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;
142 itemvector.resize(64);
143 for(
unsigned int mystrip=0; mystrip<old_nrlines-1; mystrip++){
144 if(old_strips[mystrip]==0) istrip = 0;
145 if(old_cham_id[mystrip] >= 213000 && old_cham_id[mystrip] <= 213999){
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;
155 itemvector.resize(80);
156 for(
unsigned int mystrip=0; mystrip<new_nrlines-1; mystrip++){
157 if(new_strips[mystrip]==0) istrip = 0;
158 itemvector[istrip].gain_slope=new_slope[mystrip];
159 itemvector[istrip].gain_intercept=new_intercept[mystrip];
160 itemvector[istrip].gain_chi2=new_chi2[mystrip];
161 cngains->
gains[new_cham_id[mystrip]]=itemvector;
165 itemvector.resize(64);
166 for(
unsigned int mystrip=0; mystrip<new_nrlines-1; mystrip++){
167 if(new_strips[mystrip]==0) istrip = 0;
168 if(new_cham_id[mystrip] >= 113000 && new_cham_id[mystrip] <= 113999){
169 itemvector[istrip].gain_slope=new_slope[mystrip];
170 itemvector[istrip].gain_intercept=new_intercept[mystrip];
171 itemvector[istrip].gain_chi2=new_chi2[mystrip];
172 cngains->
gains[new_cham_id[mystrip]]=itemvector;
177 itemvector.resize(64);
178 for(
unsigned int mystrip=0; mystrip<new_nrlines-1; mystrip++){
179 if(new_strips[mystrip]==0) istrip = 0;
180 if(new_cham_id[mystrip] >= 213000 && new_cham_id[mystrip] <= 213999){
181 itemvector[istrip].gain_slope=new_slope[mystrip];
182 itemvector[istrip].gain_intercept=new_intercept[mystrip];
183 itemvector[istrip].gain_chi2=new_chi2[mystrip];
184 cngains->
gains[new_cham_id[mystrip]]=itemvector;
197 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 int maxStationId()
static int minChamberId()
static CSCGains * prefillGains()
static const IOVSyncValue & beginOfTime()
static int minStationId()
static int maxChamberId()
ReturnType produceGains(const CSCGainsRcd &)
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override