CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/CalibMuon/CSCCalibration/plugins/CSCFakeGainsConditions.cc

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