Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:58:21

0001 
0002 #include "CalibMuon/CSCCalibration/interface/CSCFakeGainsConditions.h"
0003 
0004 CSCGains *CSCFakeGainsConditions::prefillGains() {
0005   CSCGains *cngains = new CSCGains();
0006   const CSCDetId &detId = CSCDetId();
0007 
0008   int max_istrip, id_layer, max_ring, max_cham;
0009   seed = 10000;
0010   srand(seed);
0011   mean = 6.8, min = -10.0, minchi = 1.0, M = 1000;
0012 
0013   // endcap=1 to 2,station=1 to 4, ring=1 to 4,chamber=1 to 36,layer=1 to 6
0014 
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 
0049         for (int ichamber = detId.minChamberId(); ichamber <= max_cham; ichamber++) {
0050           for (int ilayer = detId.minLayerId(); ilayer <= detId.maxLayerId(); ilayer++) {
0051             // station 1 ring 3 has 64 strips per layer instead of 80
0052             if (istation == 1 && iring == 3)
0053               max_istrip = 64;
0054 
0055             std::vector<CSCGains::Item> itemvector;
0056             itemvector.resize(max_istrip);
0057             id_layer = 100000 * iendcap + 10000 * istation + 1000 * iring + 10 * ichamber + ilayer;
0058 
0059             for (int istrip = 0; istrip < max_istrip; istrip++) {
0060               // itemvector[istrip].gain_slope    = 7.55;
0061               // itemvector[istrip].gain_intercept= -10.00;
0062               // itemvector[istrip].gain_chi2     = 2.00;
0063               itemvector[istrip].gain_slope = ((double)rand() / ((double)(RAND_MAX) + (double)(1))) + mean;
0064               itemvector[istrip].gain_intercept = ((double)rand() / ((double)(RAND_MAX) + (double)(1))) + min;
0065               itemvector[istrip].gain_chi2 = ((double)rand() / ((double)(RAND_MAX) + (double)(1))) + minchi;
0066               cngains->gains[id_layer] = itemvector;
0067             }
0068           }
0069         }
0070       }
0071     }
0072   }
0073   return cngains;
0074 }
0075 
0076 CSCFakeGainsConditions::CSCFakeGainsConditions(const edm::ParameterSet &iConfig) {
0077   // the following line is needed to tell the framework what
0078   // data is being produced
0079   setWhatProduced(this, &CSCFakeGainsConditions::produceGains);
0080   findingRecord<CSCGainsRcd>();
0081   // now do what ever other initialization is needed
0082 }
0083 
0084 CSCFakeGainsConditions::~CSCFakeGainsConditions() {
0085   // do anything here that needs to be done at desctruction time
0086   // (e.g. close files, deallocate resources etc.)
0087 }
0088 
0089 //
0090 // member functions
0091 //
0092 
0093 // ------------ method called to produce the data  ------------
0094 CSCFakeGainsConditions::ReturnType CSCFakeGainsConditions::produceGains(const CSCGainsRcd &iRecord) {
0095   return CSCFakeGainsConditions::ReturnType(prefillGains());
0096 }
0097 
0098 void CSCFakeGainsConditions::setIntervalFor(const edm::eventsetup::EventSetupRecordKey &,
0099                                             const edm::IOVSyncValue &,
0100                                             edm::ValidityInterval &oValidity) {
0101   oValidity = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime());
0102 }