Go to the documentation of this file.00001 #include <fstream>
00002
00003 #include "CalibMuon/CSCCalibration/interface/CSCNoiseMatrixConditions.h"
00004
00005 CSCNoiseMatrix * CSCNoiseMatrixConditions::prefillNoiseMatrix(){
00006
00007 int old_chamber_id,old_strip,new_chamber_id,new_strip;
00008 float old_elm33,old_elm34, old_elm44, old_elm35, old_elm45, old_elm55;
00009 float old_elm46, old_elm56, old_elm66, old_elm57, old_elm67, old_elm77;
00010 std::vector<int> old_cham_id;
00011 std::vector<int> old_strips;
00012 std::vector<float> old_elem33;
00013 std::vector<float> old_elem34;
00014 std::vector<float> old_elem44;
00015 std::vector<float> old_elem45;
00016 std::vector<float> old_elem35;
00017 std::vector<float> old_elem55;
00018 std::vector<float> old_elem46;
00019 std::vector<float> old_elem56;
00020 std::vector<float> old_elem66;
00021 std::vector<float> old_elem57;
00022 std::vector<float> old_elem67;
00023 std::vector<float> old_elem77;
00024
00025
00026 float new_elm33,new_elm34, new_elm44, new_elm35, new_elm45, new_elm55;
00027 float new_elm46, new_elm56, new_elm66, new_elm57, new_elm67, new_elm77;
00028 std::vector<int> new_cham_id;
00029 std::vector<int> new_strips;
00030 std::vector<float> new_elem33;
00031 std::vector<float> new_elem34;
00032 std::vector<float> new_elem44;
00033 std::vector<float> new_elem45;
00034 std::vector<float> new_elem35;
00035 std::vector<float> new_elem55;
00036 std::vector<float> new_elem46;
00037 std::vector<float> new_elem56;
00038 std::vector<float> new_elem66;
00039 std::vector<float> new_elem57;
00040 std::vector<float> new_elem67;
00041 std::vector<float> new_elem77;
00042
00043 const CSCDetId& detId = CSCDetId();
00044 CSCNoiseMatrix * cnmatrix = new CSCNoiseMatrix();
00045
00046 int max_istrip,id_layer,max_ring,max_cham;
00047 unsigned int old_nrlines=0;
00048 unsigned int new_nrlines=0;
00049
00050 std::ifstream olddata;
00051 olddata.open("old_matrix.dat",std::ios::in);
00052 if(!olddata) {
00053 std::cerr <<"Error: old_matrix.dat -> no such file!"<< std::endl;
00054 exit(1);
00055 }
00056
00057 while (!olddata.eof() ) {
00058 olddata >> old_chamber_id >> old_strip >> old_elm33 >> old_elm34 >> old_elm44 >> old_elm35 >> old_elm45 >> old_elm55 >> old_elm46 >> old_elm56 >> old_elm66 >> old_elm57 >> old_elm67 >> old_elm77;
00059 old_cham_id.push_back(old_chamber_id);
00060 old_strips.push_back(old_strip);
00061 old_elem33.push_back(old_elm33);
00062 old_elem34.push_back(old_elm34);
00063 old_elem44.push_back(old_elm44);
00064 old_elem35.push_back(old_elm35);
00065 old_elem45.push_back(old_elm45);
00066 old_elem55.push_back(old_elm55);
00067 old_elem46.push_back(old_elm46);
00068 old_elem56.push_back(old_elm56);
00069 old_elem66.push_back(old_elm66);
00070 old_elem57.push_back(old_elm57);
00071 old_elem67.push_back(old_elm67);
00072 old_elem77.push_back(old_elm77);
00073
00074 old_nrlines++;
00075 }
00076 olddata.close();
00077
00078 std::ifstream newdata;
00079 newdata.open("new_matrix.txt",std::ios::in);
00080 if(!newdata) {
00081 std::cerr <<"Error: new_matrix.txt -> no such file!"<< std::endl;
00082 exit(1);
00083 }
00084
00085 while (!newdata.eof() ) {
00086 newdata >> new_chamber_id >> new_strip >> new_elm33 >> new_elm34 >> new_elm44 >> new_elm35 >> new_elm45 >> new_elm55 >> new_elm46 >> new_elm56 >> new_elm66 >> new_elm57 >> new_elm67 >> new_elm77 ;
00087 new_cham_id.push_back(new_chamber_id);
00088 new_strips.push_back(new_strip);
00089 new_elem33.push_back(new_elm33);
00090 new_elem34.push_back(new_elm34);
00091 new_elem44.push_back(new_elm44);
00092 new_elem35.push_back(new_elm35);
00093 new_elem45.push_back(new_elm45);
00094 new_elem55.push_back(new_elm55);
00095 new_elem46.push_back(new_elm46);
00096 new_elem56.push_back(new_elm56);
00097 new_elem66.push_back(new_elm66);
00098 new_elem57.push_back(new_elm57);
00099 new_elem67.push_back(new_elm67);
00100 new_elem77.push_back(new_elm77);
00101 new_nrlines++;
00102 }
00103 newdata.close();
00104
00105
00106
00107
00108
00109 for(int iendcap=detId.minEndcapId(); iendcap<=detId.maxEndcapId(); iendcap++){
00110 for(int istation=detId.minStationId() ; istation<=detId.maxStationId(); istation++){
00111 max_ring=detId.maxRingId();
00112
00113
00114 if(istation==1) max_ring=3;
00115 if(istation==2) max_ring=2;
00116 if(istation==3) max_ring=2;
00117 if(istation==4) max_ring=1;
00118
00119 for(int iring=detId.minRingId(); iring<=max_ring; iring++){
00120 max_istrip=80;
00121 max_cham=detId.maxChamberId();
00122 if(istation==1 && iring==1) max_cham=36;
00123 if(istation==1 && iring==2) max_cham=36;
00124 if(istation==1 && iring==3) max_cham=36;
00125 if(istation==2 && iring==1) max_cham=18;
00126 if(istation==2 && iring==2) max_cham=36;
00127 if(istation==3 && iring==1) max_cham=18;
00128 if(istation==3 && iring==2) max_cham=36;
00129 if(istation==4 && iring==1) max_cham=18;
00130
00131 for(int ichamber=detId.minChamberId(); ichamber<=max_cham; ichamber++){
00132 for(int ilayer=detId.minLayerId(); ilayer<=detId.maxLayerId(); ilayer++){
00133
00134 if(istation==1 && iring==3) max_istrip=64;
00135
00136 std::vector<CSCNoiseMatrix::Item> itemvector;
00137 itemvector.resize(max_istrip);
00138 id_layer = 100000*iendcap + 10000*istation + 1000*iring + 10*ichamber + ilayer;
00139
00140 for(int istrip=0;istrip<max_istrip;istrip++){
00141
00142 if(istation==1 && iring==1){
00143 itemvector[istrip].elem33 = 7.86675;
00144 itemvector[istrip].elem34 = 2.07075;
00145 itemvector[istrip].elem44 = 6.93875;
00146 itemvector[istrip].elem35 = 1.42525;
00147 itemvector[istrip].elem45 = 2.51025;
00148 itemvector[istrip].elem55 = 7.93975;
00149 itemvector[istrip].elem46 = 0.94725;
00150 itemvector[istrip].elem56 = 2.39275;
00151 itemvector[istrip].elem66 = 6.46475;
00152 itemvector[istrip].elem57 = 1.86325;
00153 itemvector[istrip].elem67 = 2.08025;
00154 itemvector[istrip].elem77 = 6.67975;
00155 cnmatrix->matrix[id_layer]=itemvector;
00156 }
00157
00158 if(istation==1 && iring==2){
00159 itemvector[istrip].elem33 = 9.118;
00160 itemvector[istrip].elem34 = 3.884;
00161 itemvector[istrip].elem44 = 7.771;
00162 itemvector[istrip].elem35 = 1.8225;
00163 itemvector[istrip].elem45 = 3.7505;
00164 itemvector[istrip].elem55 = 8.597;
00165 itemvector[istrip].elem46 = 1.651;
00166 itemvector[istrip].elem56 = 2.5225;
00167 itemvector[istrip].elem66 = 6.583;
00168 itemvector[istrip].elem57 = 1.5055;
00169 itemvector[istrip].elem67 = 2.733;
00170 itemvector[istrip].elem77 = 6.988;
00171 cnmatrix->matrix[id_layer]=itemvector;
00172 }
00173
00174 if(istation==1 && iring==3){
00175 itemvector[istrip].elem33 = 9.5245;
00176 itemvector[istrip].elem34 = 3.2415;
00177 itemvector[istrip].elem44 = 7.6265;
00178 itemvector[istrip].elem35 = 1.7225;
00179 itemvector[istrip].elem45 = 3.6075;
00180 itemvector[istrip].elem55 = 8.7275;
00181 itemvector[istrip].elem46 = 1.663;
00182 itemvector[istrip].elem56 = 2.592;
00183 itemvector[istrip].elem66 = 7.5685;
00184 itemvector[istrip].elem57 = 1.7905;
00185 itemvector[istrip].elem67 = 2.409;
00186 itemvector[istrip].elem77 = 7.1495;
00187 cnmatrix->matrix[id_layer]=itemvector;
00188 }
00189
00190 if(istation==2 && iring==1){
00191 itemvector[istrip].elem33 = 9.06825;
00192 itemvector[istrip].elem34 = 3.32025;
00193 itemvector[istrip].elem44 = 7.52925;
00194 itemvector[istrip].elem35 = 3.66125;
00195 itemvector[istrip].elem45 = 3.39125;
00196 itemvector[istrip].elem55 = 9.97625;
00197 itemvector[istrip].elem46 = 1.32725;
00198 itemvector[istrip].elem56 = 3.99025;
00199 itemvector[istrip].elem66 = 8.10125;
00200 itemvector[istrip].elem57 = 2.56456;
00201 itemvector[istrip].elem67 = 2.96625;
00202 itemvector[istrip].elem77 = 7.30925;
00203 cnmatrix->matrix[id_layer]=itemvector;
00204 }
00205
00206 if(istation==2 &&iring==2){
00207 itemvector[istrip].elem33 = 16.7442;
00208 itemvector[istrip].elem34 = 7.96925;
00209 itemvector[istrip].elem44 = 14.1643;
00210 itemvector[istrip].elem35 = 4.67975;
00211 itemvector[istrip].elem45 = 8.44075;
00212 itemvector[istrip].elem55 = 17.2243;
00213 itemvector[istrip].elem46 = 3.68575;
00214 itemvector[istrip].elem56 = 7.48825;
00215 itemvector[istrip].elem66 = 14.4902;
00216 itemvector[istrip].elem57 = 4.4482;
00217 itemvector[istrip].elem67 = 6.47875;
00218 itemvector[istrip].elem77 = 14.6733;
00219 cnmatrix->matrix[id_layer]=itemvector;
00220 }
00221
00222 if(istation==3 && iring==1){
00223 itemvector[istrip].elem33 = 9.3495;
00224 itemvector[istrip].elem34 = 3.529;
00225 itemvector[istrip].elem44 = 7.8715;
00226 itemvector[istrip].elem35 = 3.8155;
00227 itemvector[istrip].elem45 = 3.858;
00228 itemvector[istrip].elem55 = 10.8205;
00229 itemvector[istrip].elem46 = 1.8585;
00230 itemvector[istrip].elem56 = 4.445;
00231 itemvector[istrip].elem66 = 8.0175;
00232 itemvector[istrip].elem57 = 3.29479;
00233 itemvector[istrip].elem67 = 3.625;
00234 itemvector[istrip].elem77 = 8.3895;
00235 cnmatrix->matrix[id_layer]=itemvector;
00236 }
00237
00238 if(istation==3 && iring==2){
00239 itemvector[istrip].elem33 = 13.6193;
00240 itemvector[istrip].elem34 = 5.91025;
00241 itemvector[istrip].elem44 = 11.3842;
00242 itemvector[istrip].elem35 = 3.31775;
00243 itemvector[istrip].elem45 = 5.69775;
00244 itemvector[istrip].elem55 = 11.6652;
00245 itemvector[istrip].elem46 = 2.46175;
00246 itemvector[istrip].elem56 = 4.48325;
00247 itemvector[istrip].elem66 = 9.95725;
00248 itemvector[istrip].elem57 = 2.10561;
00249 itemvector[istrip].elem67 = 4.04625;
00250 itemvector[istrip].elem77 = 9.51625;
00251 cnmatrix->matrix[id_layer]=itemvector;
00252 }
00253
00254 if(istation==4 && iring==1){
00255 itemvector[istrip].elem33 = 10.0;
00256 itemvector[istrip].elem34 = 4.0;
00257 itemvector[istrip].elem44 = 10.0;
00258 itemvector[istrip].elem35 = 3.0;
00259 itemvector[istrip].elem45 = 8.0;
00260 itemvector[istrip].elem55 = 10.0;
00261 itemvector[istrip].elem46 = 2.0;
00262 itemvector[istrip].elem56 = 5.0;
00263 itemvector[istrip].elem66 = 10.0;
00264 itemvector[istrip].elem57 = 3.0;
00265 itemvector[istrip].elem67 = 4.0;
00266 itemvector[istrip].elem77 = 10.0;
00267 cnmatrix->matrix[id_layer]=itemvector;
00268 }
00269 }
00270 }
00271 }
00272 }
00273 }
00274 }
00275
00276
00277 int istrip = 0;
00278 std::vector<CSCNoiseMatrix::Item> itemvector;
00279 itemvector.resize(80);
00280
00281 for(unsigned int mystrip=0; mystrip<old_nrlines-1; mystrip++){
00282 if(old_strips[mystrip]==0) istrip = 0;
00283 itemvector[istrip].elem33 = old_elem33[mystrip];
00284 itemvector[istrip].elem34 = old_elem34[mystrip];
00285 itemvector[istrip].elem44 = old_elem44[mystrip];
00286 itemvector[istrip].elem35 = old_elem35[mystrip];
00287 itemvector[istrip].elem45 = old_elem45[mystrip];
00288 itemvector[istrip].elem55 = old_elem55[mystrip];
00289 itemvector[istrip].elem46 = old_elem46[mystrip];
00290 itemvector[istrip].elem56 = old_elem56[mystrip];
00291 itemvector[istrip].elem66 = old_elem66[mystrip];
00292 itemvector[istrip].elem57 = old_elem57[mystrip];
00293 itemvector[istrip].elem67 = old_elem67[mystrip];
00294 itemvector[istrip].elem77 = old_elem77[mystrip];
00295 cnmatrix->matrix[old_cham_id[mystrip]]=itemvector;
00296 istrip++;
00297 }
00298
00299
00300 itemvector.resize(64);
00301 for(unsigned int mystrip=0; mystrip<old_nrlines-1; mystrip++){
00302 if(old_strips[mystrip]==0) istrip = 0;
00303 if(old_cham_id[mystrip] >= 113000 && old_cham_id[mystrip] <= 113999){
00304 itemvector[istrip].elem33 = old_elem33[mystrip];
00305 itemvector[istrip].elem34 = old_elem34[mystrip];
00306 itemvector[istrip].elem44 = old_elem44[mystrip];
00307 itemvector[istrip].elem35 = old_elem35[mystrip];
00308 itemvector[istrip].elem45 = old_elem45[mystrip];
00309 itemvector[istrip].elem55 = old_elem55[mystrip];
00310 itemvector[istrip].elem46 = old_elem46[mystrip];
00311 itemvector[istrip].elem56 = old_elem56[mystrip];
00312 itemvector[istrip].elem66 = old_elem66[mystrip];
00313 itemvector[istrip].elem57 = old_elem57[mystrip];
00314 itemvector[istrip].elem67 = old_elem67[mystrip];
00315 itemvector[istrip].elem77 = old_elem77[mystrip];
00316 cnmatrix->matrix[old_cham_id[mystrip]]=itemvector;
00317 istrip++;
00318 }
00319 }
00320
00321 itemvector.resize(64);
00322 for(unsigned int mystrip=0; mystrip<old_nrlines-1; mystrip++){
00323 if(old_strips[mystrip]==0) istrip = 0;
00324 if(old_cham_id[mystrip] >= 213000 && old_cham_id[mystrip] <= 213999){
00325 itemvector[istrip].elem33 = old_elem33[mystrip];
00326 itemvector[istrip].elem34 = old_elem34[mystrip];
00327 itemvector[istrip].elem44 = old_elem44[mystrip];
00328 itemvector[istrip].elem35 = old_elem35[mystrip];
00329 itemvector[istrip].elem45 = old_elem45[mystrip];
00330 itemvector[istrip].elem55 = old_elem55[mystrip];
00331 itemvector[istrip].elem46 = old_elem46[mystrip];
00332 itemvector[istrip].elem56 = old_elem56[mystrip];
00333 itemvector[istrip].elem66 = old_elem66[mystrip];
00334 itemvector[istrip].elem57 = old_elem57[mystrip];
00335 itemvector[istrip].elem67 = old_elem67[mystrip];
00336 itemvector[istrip].elem77 = old_elem77[mystrip];
00337 cnmatrix->matrix[old_cham_id[mystrip]]=itemvector;
00338 istrip++;
00339 }
00340 }
00341
00342
00343 itemvector.resize(80);
00344 for(unsigned int mystrip=0; mystrip<new_nrlines-1; mystrip++){
00345 if(new_strips[mystrip]==0) istrip = 0;
00346 itemvector[istrip].elem33 = new_elem33[mystrip];
00347 itemvector[istrip].elem34 = new_elem34[mystrip];
00348 itemvector[istrip].elem44 = new_elem44[mystrip];
00349 itemvector[istrip].elem35 = new_elem35[mystrip];
00350 itemvector[istrip].elem45 = new_elem45[mystrip];
00351 itemvector[istrip].elem55 = new_elem55[mystrip];
00352 itemvector[istrip].elem46 = new_elem46[mystrip];
00353 itemvector[istrip].elem56 = new_elem56[mystrip];
00354 itemvector[istrip].elem66 = new_elem66[mystrip];
00355 itemvector[istrip].elem57 = new_elem57[mystrip];
00356 itemvector[istrip].elem67 = new_elem67[mystrip];
00357 itemvector[istrip].elem77 = new_elem77[mystrip];
00358 cnmatrix->matrix[new_cham_id[mystrip]]=itemvector;
00359 istrip++;
00360 }
00361
00362 itemvector.resize(64);
00363 for(unsigned int mystrip=0; mystrip<new_nrlines-1; mystrip++){
00364 if(new_strips[mystrip]==0) istrip = 0;
00365 if(new_cham_id[mystrip] >= 113000 && new_cham_id[mystrip] <= 113999){
00366 itemvector[istrip].elem33 = new_elem33[mystrip];
00367 itemvector[istrip].elem34 = new_elem34[mystrip];
00368 itemvector[istrip].elem44 = new_elem44[mystrip];
00369 itemvector[istrip].elem35 = new_elem35[mystrip];
00370 itemvector[istrip].elem45 = new_elem45[mystrip];
00371 itemvector[istrip].elem55 = new_elem55[mystrip];
00372 itemvector[istrip].elem46 = new_elem46[mystrip];
00373 itemvector[istrip].elem56 = new_elem56[mystrip];
00374 itemvector[istrip].elem66 = new_elem66[mystrip];
00375 itemvector[istrip].elem57 = new_elem57[mystrip];
00376 itemvector[istrip].elem67 = new_elem67[mystrip];
00377 itemvector[istrip].elem77 = new_elem77[mystrip];
00378 cnmatrix->matrix[new_cham_id[mystrip]]=itemvector;
00379 istrip++;
00380 }
00381 }
00382
00383 itemvector.resize(64);
00384 for(unsigned int mystrip=0; mystrip<new_nrlines-1; mystrip++){
00385 if(new_strips[mystrip]==0) istrip = 0;
00386 if(new_cham_id[mystrip] >= 213000 && new_cham_id[mystrip] <= 213999){
00387 itemvector[istrip].elem33 = new_elem33[mystrip];
00388 itemvector[istrip].elem34 = new_elem34[mystrip];
00389 itemvector[istrip].elem44 = new_elem44[mystrip];
00390 itemvector[istrip].elem35 = new_elem35[mystrip];
00391 itemvector[istrip].elem45 = new_elem45[mystrip];
00392 itemvector[istrip].elem55 = new_elem55[mystrip];
00393 itemvector[istrip].elem46 = new_elem46[mystrip];
00394 itemvector[istrip].elem56 = new_elem56[mystrip];
00395 itemvector[istrip].elem66 = new_elem66[mystrip];
00396 itemvector[istrip].elem57 = new_elem57[mystrip];
00397 itemvector[istrip].elem67 = new_elem67[mystrip];
00398 itemvector[istrip].elem77 = new_elem77[mystrip];
00399 cnmatrix->matrix[new_cham_id[mystrip]]=itemvector;
00400 istrip++;
00401 }
00402 }
00403 return cnmatrix;
00404
00405 }
00406
00407 CSCNoiseMatrixConditions::CSCNoiseMatrixConditions(const edm::ParameterSet& iConfig)
00408 {
00409
00410
00411 cnMatrix = prefillNoiseMatrix();
00412
00413 setWhatProduced(this,&CSCNoiseMatrixConditions::produceNoiseMatrix);
00414 findingRecord<CSCNoiseMatrixRcd>();
00415
00416 }
00417
00418
00419 CSCNoiseMatrixConditions::~CSCNoiseMatrixConditions()
00420 {
00421
00422
00423
00424 delete cnMatrix;
00425 }
00426
00427
00428
00429
00430
00431
00432
00433 CSCNoiseMatrixConditions::ReturnType
00434 CSCNoiseMatrixConditions::produceNoiseMatrix(const CSCNoiseMatrixRcd& iRecord)
00435 {
00436
00437 CSCNoiseMatrix* mydata=new CSCNoiseMatrix( *cnMatrix );
00438
00439 return mydata;
00440
00441 }
00442
00443 void CSCNoiseMatrixConditions::setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue&,
00444 edm::ValidityInterval & oValidity)
00445 {
00446 oValidity = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(),edm::IOVSyncValue::endOfTime());
00447
00448 }