CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/CalibMuon/CSCCalibration/plugins/CSCFakePedestalsConditions.cc

Go to the documentation of this file.
00001 
00002 #include "CalibMuon/CSCCalibration/interface/CSCFakePedestalsConditions.h"
00003 
00004 void CSCFakePedestalsConditions::prefillPedestals()
00005 {
00006   const CSCDetId& detId = CSCDetId();
00007   cnpedestals = new CSCPedestals();
00008   
00009   int max_istrip,id_layer,max_ring,max_cham;
00010   seed = 10000; 
00011   srand(seed);
00012   meanped=600.0, meanrms=1.5, M=1000;
00013 
00014   //endcap=1 to 2,station=1 to 4, ring=1 to 4,chamber=1 to 36,layer=1 to 6 
00015   
00016   for(int iendcap=detId.minEndcapId(); iendcap<=detId.maxEndcapId(); iendcap++){
00017     for(int istation=detId.minStationId() ; istation<=detId.maxStationId(); istation++){
00018       max_ring=detId.maxRingId();
00019       //station 4 ring 4 not there(36 chambers*2 missing)
00020       //3 rings max this way of counting (ME1a & b)
00021       if(istation==1)    max_ring=3;
00022       if(istation==2)    max_ring=2;
00023       if(istation==3)    max_ring=2;
00024       if(istation==4)    max_ring=1;
00025       
00026       for(int iring=detId.minRingId(); iring<=max_ring; iring++){
00027         max_istrip=80;
00028         max_cham=detId.maxChamberId();  
00029         if(istation==1 && iring==1)    max_cham=36;
00030         if(istation==1 && iring==2)    max_cham=36;
00031         if(istation==1 && iring==3)    max_cham=36;
00032         if(istation==2 && iring==1)    max_cham=18;
00033         if(istation==2 && iring==2)    max_cham=36;
00034         if(istation==3 && iring==1)    max_cham=18;
00035         if(istation==3 && iring==2)    max_cham=36;
00036         if(istation==4 && iring==1)    max_cham=18;
00037         
00038         for(int ichamber=detId.minChamberId(); ichamber<=max_cham; ichamber++){
00039           for(int ilayer=detId.minLayerId(); ilayer<=detId.maxLayerId(); ilayer++){
00040             //station 1 ring 3 has 64 strips per layer instead of 80 
00041             if(istation==1 && iring==3)   max_istrip=64;
00042             
00043             std::vector<CSCPedestals::Item> itemvector;
00044             itemvector.resize(max_istrip);
00045             id_layer = 100000*iendcap + 10000*istation + 1000*iring + 10*ichamber + ilayer;
00046             
00047             for(int istrip=0;istrip<max_istrip;istrip++){
00048               itemvector[istrip].ped=((double)rand()/((double)(RAND_MAX)+(double)(1)))*100+meanped;
00049               itemvector[istrip].rms=((double)rand()/((double)(RAND_MAX)+(double)(1)))+meanrms;
00050               cnpedestals->pedestals[id_layer]=itemvector;
00051             }
00052           }
00053         }
00054       }
00055     }
00056   }
00057 }  
00058 
00059 CSCFakePedestalsConditions::CSCFakePedestalsConditions(const edm::ParameterSet& iConfig)
00060 {
00061   //the following line is needed to tell the framework what
00062   // data is being produced
00063   prefillPedestals();
00064   setWhatProduced(this,&CSCFakePedestalsConditions::producePedestals);
00065   findingRecord<CSCPedestalsRcd>();
00066   //now do what ever other initialization is needed
00067 }
00068 
00069 
00070 CSCFakePedestalsConditions::~CSCFakePedestalsConditions()
00071 {
00072  
00073    // do anything here that needs to be done at desctruction time
00074    // (e.g. close files, deallocate resources etc.)
00075   delete cnpedestals;
00076 }
00077 
00078 
00079 //
00080 // member functions
00081 //
00082 
00083 // ------------ method called to produce the data  ------------
00084 CSCFakePedestalsConditions::ReturnType
00085 CSCFakePedestalsConditions::producePedestals(const CSCPedestalsRcd& iRecord)
00086 {
00087   return cnpedestals;
00088 }
00089 
00090  void CSCFakePedestalsConditions::setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue&,
00091  edm::ValidityInterval & oValidity)
00092  {
00093  oValidity = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(),edm::IOVSyncValue::endOfTime());
00094  
00095  }