Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:47:34

0001 #include <fstream>
0002 
0003 #include "CalibMuon/CSCCalibration/interface/CSCFakeCrosstalkConditions.h"
0004 
0005 CSCcrosstalk *CSCFakeCrosstalkConditions::prefillCrosstalk() {
0006   const CSCDetId &detId = CSCDetId();
0007   CSCcrosstalk *cncrosstalk = new CSCcrosstalk();
0008 
0009   int max_istrip, id_layer, max_ring, max_cham;
0010   seed = 10000;
0011   srand(seed);
0012   mean = -0.0009, min = 0.035, minchi = 1.5, M = 1000;
0013 
0014   // endcap=1 to 2,station=1 to 4, ring=1 to 4,chamber=1 to 36,layer=1 to 6
0015   for (int iendcap = detId.minEndcapId(); iendcap <= detId.maxEndcapId(); iendcap++) {
0016     for (int istation = detId.minStationId(); istation <= detId.maxStationId(); istation++) {
0017       max_ring = detId.maxRingId();
0018       // station 4 ring 4 not there(36 chambers*2 missing)
0019       // 3 rings max this way of counting (ME1a & b)
0020       if (istation == 1)
0021         max_ring = 3;
0022       if (istation == 2)
0023         max_ring = 2;
0024       if (istation == 3)
0025         max_ring = 2;
0026       if (istation == 4)
0027         max_ring = 1;
0028 
0029       for (int iring = detId.minRingId(); iring <= max_ring; iring++) {
0030         max_istrip = 80;
0031         max_cham = detId.maxChamberId();
0032         if (istation == 1 && iring == 1)
0033           max_cham = 36;
0034         if (istation == 1 && iring == 2)
0035           max_cham = 36;
0036         if (istation == 1 && iring == 3)
0037           max_cham = 36;
0038         if (istation == 2 && iring == 1)
0039           max_cham = 18;
0040         if (istation == 2 && iring == 2)
0041           max_cham = 36;
0042         if (istation == 3 && iring == 1)
0043           max_cham = 18;
0044         if (istation == 3 && iring == 2)
0045           max_cham = 36;
0046         if (istation == 4 && iring == 1)
0047           max_cham = 18;
0048         // station 1 ring 3 has 64 strips per layer instead of 80(minus & plus
0049         // side!!!)
0050 
0051         for (int ichamber = detId.minChamberId(); ichamber <= max_cham; ichamber++) {
0052           for (int ilayer = detId.minLayerId(); ilayer <= detId.maxLayerId(); ilayer++) {
0053             // station 1 ring 3 has 64 strips per layer instead of 80
0054             if (istation == 1 && iring == 3)
0055               max_istrip = 64;
0056 
0057             std::vector<CSCcrosstalk::Item> itemvector;
0058             itemvector.resize(max_istrip);
0059             id_layer = 100000 * iendcap + 10000 * istation + 1000 * iring + 10 * ichamber + ilayer;
0060 
0061             for (int istrip = 0; istrip < max_istrip; istrip++) {
0062               // create fake values
0063               itemvector[istrip].xtalk_slope_right =
0064                   -((double)rand() / ((double)(RAND_MAX) + (double)(1))) / 10000 + mean;
0065               itemvector[istrip].xtalk_intercept_right =
0066                   ((double)rand() / ((double)(RAND_MAX) + (double)(1))) / 100 + min;
0067               itemvector[istrip].xtalk_chi2_right = ((double)rand() / ((double)(RAND_MAX) + (double)(1))) + minchi;
0068               itemvector[istrip].xtalk_slope_left =
0069                   -((double)rand() / ((double)(RAND_MAX) + (double)(1))) / 10000 + mean;
0070               itemvector[istrip].xtalk_intercept_left =
0071                   ((double)rand() / ((double)(RAND_MAX) + (double)(1))) / 100 + min;
0072               itemvector[istrip].xtalk_chi2_left = ((double)rand() / ((double)(RAND_MAX) + (double)(1))) + minchi;
0073               cncrosstalk->crosstalk[id_layer] = itemvector;
0074 
0075               if (istrip == 0) {
0076                 itemvector[istrip].xtalk_slope_right =
0077                     -((double)rand() / ((double)(RAND_MAX) + (double)(1))) / 10000 + mean;
0078                 itemvector[istrip].xtalk_intercept_right =
0079                     ((double)rand() / ((double)(RAND_MAX) + (double)(1))) / 100 + min;
0080                 itemvector[istrip].xtalk_chi2_right = ((double)rand() / ((double)(RAND_MAX) + (double)(1))) + minchi;
0081                 itemvector[istrip].xtalk_slope_left = 0.0;
0082                 itemvector[istrip].xtalk_intercept_left = 0.0;
0083                 itemvector[istrip].xtalk_chi2_left = 0.0;
0084                 cncrosstalk->crosstalk[id_layer] = itemvector;
0085               }
0086 
0087               if (istrip == 79) {
0088                 itemvector[istrip].xtalk_slope_right = 0.0;
0089                 itemvector[istrip].xtalk_intercept_right = 0.0;
0090                 itemvector[istrip].xtalk_chi2_right = 0.0;
0091                 itemvector[istrip].xtalk_slope_left =
0092                     -((double)rand() / ((double)(RAND_MAX) + (double)(1))) / 10000 + mean;
0093                 itemvector[istrip].xtalk_intercept_left =
0094                     ((double)rand() / ((double)(RAND_MAX) + (double)(1))) / 100 + min;
0095                 itemvector[istrip].xtalk_chi2_left = ((double)rand() / ((double)(RAND_MAX) + (double)(1))) + minchi;
0096                 cncrosstalk->crosstalk[id_layer] = itemvector;
0097               }
0098             }
0099           }
0100         }
0101       }
0102     }
0103   }
0104   return cncrosstalk;
0105 }
0106 
0107 CSCFakeCrosstalkConditions::CSCFakeCrosstalkConditions(const edm::ParameterSet &iConfig) {
0108   // the following line is needed to tell the framework what
0109   // data is being produced
0110   setWhatProduced(this, &CSCFakeCrosstalkConditions::produceCrosstalk);
0111   findingRecord<CSCcrosstalkRcd>();
0112   // now do what ever other initialization is needed
0113 }
0114 
0115 CSCFakeCrosstalkConditions::~CSCFakeCrosstalkConditions() {
0116   // do anything here that needs to be done at desctruction time
0117   // (e.g. close files, deallocate resources etc.)
0118 }
0119 
0120 //
0121 // member functions
0122 //
0123 
0124 // ------------ method called to produce the data  ------------
0125 CSCFakeCrosstalkConditions::ReturnType CSCFakeCrosstalkConditions::produceCrosstalk(const CSCcrosstalkRcd &iRecord) {
0126   return CSCFakeCrosstalkConditions::ReturnType(prefillCrosstalk());
0127 }
0128 
0129 void CSCFakeCrosstalkConditions::setIntervalFor(const edm::eventsetup::EventSetupRecordKey &,
0130                                                 const edm::IOVSyncValue &,
0131                                                 edm::ValidityInterval &oValidity) {
0132   oValidity = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime());
0133 }