CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCFakeDBCrosstalk.h
Go to the documentation of this file.
1 #ifndef _CSCFAKEDBCROSSTALK_H
2 #define _CSCFAKEDBCROSSTALK_H
3 
4 #include <memory>
13 
15 
19 #include <boost/shared_ptr.hpp>
20 
22  public:
25 
26  inline static CSCDBCrosstalk * prefillDBCrosstalk();
27 
28  typedef boost::shared_ptr<CSCDBCrosstalk> Pointer;
29 
31 
32  private:
33  // ----------member data ---------------------------
36 
37 };
38 
39 #include<fstream>
40 #include<vector>
41 #include<iostream>
42 
43 // to workaround plugin library
45 {
46  int seed;
47  long int M;
48  float mean,min, minchi;
49  int ii,jj,iii,jjj;
50  const int MAX_SIZE = 217728; //or 252288 for ME4/2 chambers
51  const int SLOPE_FACTOR=10000000;
52  const int INTERCEPT_FACTOR=100000;
53 
54  CSCDBCrosstalk * cndbcrosstalk = new CSCDBCrosstalk();
55  cndbcrosstalk->crosstalk.resize(MAX_SIZE);
56 
57  seed = 10000;
58  srand(seed);
59  mean=-0.0009, min=0.035, minchi=1.5, M=1000;
60  ii=0,jj=0,iii=0,jjj=0;
61 
62  cndbcrosstalk->factor_slope = int (SLOPE_FACTOR);
63  cndbcrosstalk->factor_intercept = int (INTERCEPT_FACTOR);
64 
65  for(int i=0; i<MAX_SIZE;i++){
66  cndbcrosstalk->crosstalk[i].xtalk_slope_right = (short int) ((-((double)rand()/((double)(RAND_MAX)+(double)(1)))/10000+mean)*SLOPE_FACTOR+0.5);
67  cndbcrosstalk->crosstalk[i].xtalk_intercept_right= (short int) ((((double)rand()/((double)(RAND_MAX)+(double)(1)))/100+min)*INTERCEPT_FACTOR+0.5);
68  cndbcrosstalk->crosstalk[i].xtalk_slope_left= (short int) ((-((double)rand()/((double)(RAND_MAX)+(double)(1)))/10000+mean)*SLOPE_FACTOR+0.5);
69  cndbcrosstalk->crosstalk[i].xtalk_intercept_left=(short int) ((((double)rand()/((double)(RAND_MAX)+(double)(1)))/100+min)*INTERCEPT_FACTOR+0.5);
70 
71 
72  //80 strips per chamber
73  if(i<34561 && i%80==0){
74  cndbcrosstalk->crosstalk[i].xtalk_slope_left=0;
75  cndbcrosstalk->crosstalk[i].xtalk_intercept_left=0;
76  }
77 
78  if(i!=0 && i<34561 && (i+1)%80==0){
79  cndbcrosstalk->crosstalk[i].xtalk_slope_right=0;
80  cndbcrosstalk->crosstalk[i].xtalk_intercept_right=0;
81  }
82 
83  //64 strips per chamber
84  if(i>34560 && i<48385 && i%64==0){
85  cndbcrosstalk->crosstalk[i].xtalk_slope_left=0;
86  cndbcrosstalk->crosstalk[i].xtalk_intercept_left=0;
87  }
88 
89  if(i>34560 && i<48385 && (i+1)%64==0){
90  cndbcrosstalk->crosstalk[i].xtalk_slope_right=0;
91  cndbcrosstalk->crosstalk[i].xtalk_intercept_right=0;
92  }
93 
94  //80 strips per chamber again
95  if(i>48384 && i<143425){
96  ii++;
97  if(i>48384 && i<143425 && ii%80==0){
98  cndbcrosstalk->crosstalk[i].xtalk_slope_left=0;
99  cndbcrosstalk->crosstalk[i].xtalk_intercept_left=0;
100  }
101  }
102 
103  if(i>48384 && i<143425){
104  jj++;
105  if(i>48384 && i<143425 && (jj+1)%80==0){
106  cndbcrosstalk->crosstalk[i].xtalk_slope_right=0;
107  cndbcrosstalk->crosstalk[i].xtalk_intercept_right=0;
108  }
109  }
110 
111  //64 strips per chamber again
112  if(i>143424 && i<157249 &&i%64==0){
113  cndbcrosstalk->crosstalk[i].xtalk_slope_left=0;
114  cndbcrosstalk->crosstalk[i].xtalk_intercept_left=0;
115  }
116 
117  if(i>143424 && i<157249 && (i+1)%64==0){
118  cndbcrosstalk->crosstalk[i].xtalk_slope_right=0;
119  cndbcrosstalk->crosstalk[i].xtalk_intercept_right=0;
120  }
121 
122 
123  //80 strips per chamber last time
124  if(i>157248){
125  iii++;
126  if(i>157248 && iii%80==0){
127  cndbcrosstalk->crosstalk[i].xtalk_slope_left=0;
128  cndbcrosstalk->crosstalk[i].xtalk_intercept_left=0;
129  }
130  }
131 
132  if(i>157248){
133  jjj++;
134  if(i>157248 && (jjj+1)%80==0){
135  cndbcrosstalk->crosstalk[i].xtalk_slope_right=0;
136  cndbcrosstalk->crosstalk[i].xtalk_intercept_right=0;
137  }
138  }
139  }
140  return cndbcrosstalk;
141 }
142 
143 #endif
144 
145 
146 
147 
148 
int i
Definition: DBlmapReader.cc:9
static CSCDBCrosstalk * prefillDBCrosstalk()
#define min(a, b)
Definition: mlp_lapack.h:161
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &)
boost::shared_ptr< CSCDBCrosstalk > Pointer
CSCFakeDBCrosstalk(const edm::ParameterSet &)
Pointer produceDBCrosstalk(const CSCDBCrosstalkRcd &)
Signal rand(Signal arg)
Definition: vlib.cc:442
CrosstalkContainer crosstalk