CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 #include <fstream>
00002 
00003 #include "CalibMuon/CSCCalibration/interface/CSCFakeCrosstalkConditions.h"
00004 
00005 void CSCFakeCrosstalkConditions::prefillCrosstalk(){
00006   
00007   const CSCDetId& detId = CSCDetId();
00008   cncrosstalk = new CSCcrosstalk();
00009   
00010   int max_istrip,id_layer,max_ring,max_cham;
00011   seed = 10000; 
00012   srand(seed);
00013   mean=-0.0009, min=0.035, minchi=1.5, M=1000;
00014  
00015   //endcap=1 to 2,station=1 to 4, ring=1 to 4,chamber=1 to 36,layer=1 to 6 
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         //station 1 ring 3 has 64 strips per layer instead of 80(minus & plus side!!!)
00038 
00039         for(int ichamber=detId.minChamberId(); ichamber<=max_cham; ichamber++){
00040 
00041           for(int ilayer=detId.minLayerId(); ilayer<=detId.maxLayerId(); ilayer++){
00042             //station 1 ring 3 has 64 strips per layer instead of 80 
00043             if(istation==1 && iring==3)   max_istrip=64;
00044             
00045             std::vector<CSCcrosstalk::Item> itemvector;
00046             itemvector.resize(max_istrip);
00047             id_layer = 100000*iendcap + 10000*istation + 1000*iring + 10*ichamber + ilayer;
00048 
00049             for(int istrip=0;istrip<max_istrip;istrip++){
00050               //create fake values
00051               itemvector[istrip].xtalk_slope_right=-((double)rand()/((double)(RAND_MAX)+(double)(1)))/10000+mean;
00052               itemvector[istrip].xtalk_intercept_right=((double)rand()/((double)(RAND_MAX)+(double)(1)))/100+min;
00053               itemvector[istrip].xtalk_chi2_right=((double)rand()/((double)(RAND_MAX)+(double)(1)))+minchi;
00054               itemvector[istrip].xtalk_slope_left=-((double)rand()/((double)(RAND_MAX)+(double)(1)))/10000+mean;
00055               itemvector[istrip].xtalk_intercept_left=((double)rand()/((double)(RAND_MAX)+(double)(1)))/100+min;
00056               itemvector[istrip].xtalk_chi2_left=((double)rand()/((double)(RAND_MAX)+(double)(1)))+minchi;
00057               cncrosstalk->crosstalk[id_layer]=itemvector;
00058 
00059               if(istrip==0){
00060                 itemvector[istrip].xtalk_slope_right=-((double)rand()/((double)(RAND_MAX)+(double)(1)))/10000+mean;
00061                 itemvector[istrip].xtalk_intercept_right=((double)rand()/((double)(RAND_MAX)+(double)(1)))/100+min;
00062                 itemvector[istrip].xtalk_chi2_right=((double)rand()/((double)(RAND_MAX)+(double)(1)))+minchi;
00063                 itemvector[istrip].xtalk_slope_left=0.0;
00064                 itemvector[istrip].xtalk_intercept_left=0.0;
00065                 itemvector[istrip].xtalk_chi2_left=0.0;
00066                 cncrosstalk->crosstalk[id_layer]=itemvector;
00067               }
00068               
00069               if(istrip==79){
00070                 itemvector[istrip].xtalk_slope_right=0.0;
00071                 itemvector[istrip].xtalk_intercept_right=0.0;
00072                 itemvector[istrip].xtalk_chi2_right=0.0;
00073                 itemvector[istrip].xtalk_slope_left=-((double)rand()/((double)(RAND_MAX)+(double)(1)))/10000+mean;
00074                 itemvector[istrip].xtalk_intercept_left=((double)rand()/((double)(RAND_MAX)+(double)(1)))/100+min;
00075                 itemvector[istrip].xtalk_chi2_left=((double)rand()/((double)(RAND_MAX)+(double)(1)))+minchi;
00076                 cncrosstalk->crosstalk[id_layer]=itemvector;
00077               }
00078             }
00079           }
00080         }
00081       }
00082     }
00083   }
00084 }
00085 
00086 
00087 CSCFakeCrosstalkConditions::CSCFakeCrosstalkConditions(const edm::ParameterSet& iConfig)
00088 {
00089   //the following line is needed to tell the framework what
00090   // data is being produced
00091   prefillCrosstalk();
00092   setWhatProduced(this,&CSCFakeCrosstalkConditions::produceCrosstalk);
00093   findingRecord<CSCcrosstalkRcd>();
00094   //now do what ever other initialization is needed
00095 }
00096 
00097 
00098 CSCFakeCrosstalkConditions::~CSCFakeCrosstalkConditions()
00099 {
00100  
00101    // do anything here that needs to be done at desctruction time
00102    // (e.g. close files, deallocate resources etc.)
00103   delete cncrosstalk;
00104 }
00105 
00106 
00107 //
00108 // member functions
00109 //
00110 
00111 // ------------ method called to produce the data  ------------
00112 CSCFakeCrosstalkConditions::ReturnType
00113 CSCFakeCrosstalkConditions::produceCrosstalk(const CSCcrosstalkRcd& iRecord)
00114 {
00115   return cncrosstalk;  
00116 }
00117 
00118  void CSCFakeCrosstalkConditions::setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue&,
00119  edm::ValidityInterval & oValidity)
00120  {
00121  oValidity = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(),edm::IOVSyncValue::endOfTime());
00122  
00123  }
00124 
00125