CMS 3D CMS Logo

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