CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/CalibMuon/CSCCalibration/interface/CSCFakeDBCrosstalk.h

Go to the documentation of this file.
00001 #ifndef _CSCFAKEDBCROSSTALK_H
00002 #define _CSCFAKEDBCROSSTALK_H
00003 
00004 #include <memory>
00005 #include "FWCore/Framework/interface/SourceFactory.h"
00006 #include "FWCore/Framework/interface/Frameworkfwd.h"
00007 #include "FWCore/Framework/interface/ESProducer.h"
00008 #include "FWCore/Framework/interface/Event.h"
00009 #include "FWCore/Framework/interface/MakerMacros.h"
00010 #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
00011 #include "FWCore/Framework/interface/ESHandle.h"
00012 #include "FWCore/Framework/interface/EventSetup.h"
00013 
00014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00015 
00016 #include "CondFormats/CSCObjects/interface/CSCDBCrosstalk.h"
00017 #include "CondFormats/DataRecord/interface/CSCDBCrosstalkRcd.h"
00018 #include <DataFormats/MuonDetId/interface/CSCDetId.h>
00019 #include <boost/shared_ptr.hpp>
00020 
00021 class CSCFakeDBCrosstalk: public edm::ESProducer, public edm::EventSetupRecordIntervalFinder  {
00022    public:
00023       CSCFakeDBCrosstalk(const edm::ParameterSet&);
00024       ~CSCFakeDBCrosstalk();
00025 
00026       inline static CSCDBCrosstalk * prefillDBCrosstalk(); 
00027 
00028       typedef  boost::shared_ptr<CSCDBCrosstalk> Pointer;
00029 
00030       Pointer produceDBCrosstalk(const CSCDBCrosstalkRcd&);
00031 
00032    private:
00033       // ----------member data ---------------------------
00034     void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue&, edm::ValidityInterval & );
00035     Pointer cndbCrosstalk ;
00036 
00037 };
00038 
00039 #include<fstream>
00040 #include<vector>
00041 #include<iostream>
00042 
00043 // to workaround plugin library
00044 inline CSCDBCrosstalk *  CSCFakeDBCrosstalk::prefillDBCrosstalk()
00045 {
00046   int seed;
00047   long int M;
00048   float mean,min, minchi;
00049   int ii,jj,iii,jjj;
00050   const int MAX_SIZE = 217728; //or 252288 for ME4/2 chambers
00051   const int SLOPE_FACTOR=10000000;
00052   const int INTERCEPT_FACTOR=100000;
00053   
00054   CSCDBCrosstalk * cndbcrosstalk = new CSCDBCrosstalk();
00055   cndbcrosstalk->crosstalk.resize(MAX_SIZE);
00056 
00057   seed = 10000; 
00058   srand(seed);
00059   mean=-0.0009, min=0.035, minchi=1.5, M=1000;
00060   ii=0,jj=0,iii=0,jjj=0; 
00061   
00062   cndbcrosstalk->factor_slope = int (SLOPE_FACTOR);
00063   cndbcrosstalk->factor_intercept = int (INTERCEPT_FACTOR);
00064   
00065   for(int i=0; i<MAX_SIZE;i++){
00066     cndbcrosstalk->crosstalk[i].xtalk_slope_right = (short int) ((-((double)rand()/((double)(RAND_MAX)+(double)(1)))/10000+mean)*SLOPE_FACTOR+0.5);
00067     cndbcrosstalk->crosstalk[i].xtalk_intercept_right= (short int) ((((double)rand()/((double)(RAND_MAX)+(double)(1)))/100+min)*INTERCEPT_FACTOR+0.5);
00068     cndbcrosstalk->crosstalk[i].xtalk_slope_left= (short int) ((-((double)rand()/((double)(RAND_MAX)+(double)(1)))/10000+mean)*SLOPE_FACTOR+0.5);
00069     cndbcrosstalk->crosstalk[i].xtalk_intercept_left=(short int) ((((double)rand()/((double)(RAND_MAX)+(double)(1)))/100+min)*INTERCEPT_FACTOR+0.5); 
00070   
00071   
00072     //80 strips per chamber
00073     if(i<34561 && i%80==0){
00074       cndbcrosstalk->crosstalk[i].xtalk_slope_left=0;
00075       cndbcrosstalk->crosstalk[i].xtalk_intercept_left=0;
00076     }
00077     
00078     if(i!=0 && i<34561 && (i+1)%80==0){
00079       cndbcrosstalk->crosstalk[i].xtalk_slope_right=0;
00080       cndbcrosstalk->crosstalk[i].xtalk_intercept_right=0;
00081     }
00082     
00083     //64 strips per chamber
00084     if(i>34560 && i<48385 && i%64==0){
00085       cndbcrosstalk->crosstalk[i].xtalk_slope_left=0;
00086       cndbcrosstalk->crosstalk[i].xtalk_intercept_left=0;
00087     }
00088     
00089     if(i>34560 && i<48385 && (i+1)%64==0){
00090       cndbcrosstalk->crosstalk[i].xtalk_slope_right=0;
00091       cndbcrosstalk->crosstalk[i].xtalk_intercept_right=0;
00092     }
00093     
00094     //80 strips per chamber again
00095     if(i>48384 && i<143425){
00096       ii++;
00097       if(i>48384 && i<143425 && ii%80==0){
00098         cndbcrosstalk->crosstalk[i].xtalk_slope_left=0;
00099         cndbcrosstalk->crosstalk[i].xtalk_intercept_left=0;
00100       }
00101     }
00102     
00103     if(i>48384 && i<143425){
00104       jj++;
00105       if(i>48384 && i<143425 && (jj+1)%80==0){
00106         cndbcrosstalk->crosstalk[i].xtalk_slope_right=0;
00107         cndbcrosstalk->crosstalk[i].xtalk_intercept_right=0;
00108       }
00109     }
00110     
00111     //64 strips per chamber again
00112     if(i>143424 && i<157249 &&i%64==0){
00113       cndbcrosstalk->crosstalk[i].xtalk_slope_left=0;
00114       cndbcrosstalk->crosstalk[i].xtalk_intercept_left=0;
00115     }
00116     
00117     if(i>143424 && i<157249 && (i+1)%64==0){
00118       cndbcrosstalk->crosstalk[i].xtalk_slope_right=0;
00119       cndbcrosstalk->crosstalk[i].xtalk_intercept_right=0;
00120     }
00121     
00122     
00123     //80 strips per chamber last time
00124     if(i>157248){
00125       iii++;
00126       if(i>157248 && iii%80==0){
00127         cndbcrosstalk->crosstalk[i].xtalk_slope_left=0;
00128         cndbcrosstalk->crosstalk[i].xtalk_intercept_left=0;
00129       }
00130     }
00131     
00132     if(i>157248){
00133       jjj++;
00134       if(i>157248 && (jjj+1)%80==0){
00135         cndbcrosstalk->crosstalk[i].xtalk_slope_right=0;
00136         cndbcrosstalk->crosstalk[i].xtalk_intercept_right=0;
00137       }
00138     }
00139   }
00140   return cndbcrosstalk;
00141 }  
00142 
00143 #endif
00144 
00145   
00146 
00147  
00148