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/CSCFakePedestalsConditions.h"
0003 
0004 CSCPedestals *CSCFakePedestalsConditions::prefillPedestals() {
0005   const CSCDetId &detId = CSCDetId();
0006   CSCPedestals *cnpedestals = new CSCPedestals();
0007 
0008   int max_istrip, id_layer, max_ring, max_cham;
0009   seed = 10000;
0010   srand(seed);
0011   meanped = 600.0, meanrms = 1.5, 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<CSCPedestals::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].ped = ((double)rand() / ((double)(RAND_MAX) + (double)(1))) * 100 + meanped;
0061               itemvector[istrip].rms = ((double)rand() / ((double)(RAND_MAX) + (double)(1))) + meanrms;
0062               cnpedestals->pedestals[id_layer] = itemvector;
0063             }
0064           }
0065         }
0066       }
0067     }
0068   }
0069   return cnpedestals;
0070 }
0071 
0072 CSCFakePedestalsConditions::CSCFakePedestalsConditions(const edm::ParameterSet &iConfig) {
0073   // the following line is needed to tell the framework what
0074   // data is being produced
0075   setWhatProduced(this, &CSCFakePedestalsConditions::producePedestals);
0076   findingRecord<CSCPedestalsRcd>();
0077   // now do what ever other initialization is needed
0078 }
0079 
0080 CSCFakePedestalsConditions::~CSCFakePedestalsConditions() {
0081   // do anything here that needs to be done at desctruction time
0082   // (e.g. close files, deallocate resources etc.)
0083 }
0084 
0085 //
0086 // member functions
0087 //
0088 
0089 // ------------ method called to produce the data  ------------
0090 CSCFakePedestalsConditions::ReturnType CSCFakePedestalsConditions::producePedestals(const CSCPedestalsRcd &iRecord) {
0091   return CSCFakePedestalsConditions::ReturnType(prefillPedestals());
0092 }
0093 
0094 void CSCFakePedestalsConditions::setIntervalFor(const edm::eventsetup::EventSetupRecordKey &,
0095                                                 const edm::IOVSyncValue &,
0096                                                 edm::ValidityInterval &oValidity) {
0097   oValidity = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime());
0098 }