CMS 3D CMS Logo

ClusterFP420.cc
Go to the documentation of this file.
1 // File: ClusterFP420.cc
3 // Date: 12.2006
4 // Description: ClusterFP420 for FP420
5 // Modifications:
9 #include <iostream>
10 #include <cmath>
11 using namespace std;
12 
13 //#define mydigidebug10
14 //#define mydigidebug11
15 
16 //static float const_ps1s2[3] = {0.050,.0139,0.0045};// pitch, sigma_1channelCluster, sigma_2channelsCluster - Narrow , mm
17 //static float constW_ps1s2[3] = {0.400,.0920,0.0280};// pitch, sigma_1channelCluster, sigma_2channelsCluster - Wide , mm
18 
19 static float const const_ps1s2[3] = {
20  0.050, .0135, 0.0086}; // pitch, sigma_1channelCluster, sigma_2channelsCluster - Narrow , mm
21 static float const constW_ps1s2[3] = {
22  0.400, .1149, 0.0648}; // pitch, sigma_1channelCluster, sigma_2channelsCluster - Wide , mm
23 
24 // sense of xytype here is X or Y type planes. Now we are working with X only, i.e. xytype=2
25 ClusterFP420::ClusterFP420(unsigned int detid, unsigned int xytype, const HDigiFP420Range& range, float& cog, float& err)
26  : detId_(detid),
27  firstStrip_(range.first->strip())
28 // detId_(detid), xytype_(xytype), firstStrip_(range.first->strip())
29 {
30  // For the range of strips in cluster assign adc(,its numbers i->strip()) calculate cog...
31  // strip :
32 #ifdef mydigidebug11
33  std::cout << "===================================== firstStrip = " << firstStrip_ << std::endl;
34  std::cout << "==range.first->strip() = " << range.first->strip() << std::endl;
35  std::cout << "==range.second->strip() = " << range.second->strip() << std::endl;
36 #endif
37 
38  amplitudes_.reserve(range.second - range.first);
39 
40  int striprange = 0;
41  float sumx = 0.;
42  float sumxx = 0.;
43  float sumy = 0.;
44  float sumyy = 0.;
45  int suma = 0;
46 
47  // int lastStrip = -1;
48  for (HDigiFP420Iter i = range.first; i != range.second; i++) {
49  striprange++;
50 #ifdef mydigidebug11
51  std::cout << " current striprange = " << striprange << std::endl;
52 #endif
53  /*
55  if (i!=ibeg && (difNarr(xytype,i,i-1) > 1 || difWide(xytype,i,i-1) > 1) ){
56  if (lastStrip>0 && i->strip() != lastStrip + 1) {
57  for (int j=0; j < i->strip()-(lastStrip+1); j++) {
58  amplitudes_.push_back( 0);
59  }
60  }
61  lastStrip = i->strip();
62 */
63  short amp = i->adc(); // FIXME: gain correction here
64 
65 #ifdef mydigidebug11
66  std::cout << " current strip = " << i->strip() << " amp = " << amp << std::endl;
67 #endif
68 
69  amplitudes_.push_back(amp);
70  if (xytype == 1) {
71  sumx += i->stripH() * amp;
72  sumy += i->stripHW() * amp;
73  suma += amp;
74  sumxx += (i->stripH()) * (i->stripH()) * amp;
75  sumyy += (i->stripHW()) * (i->stripHW()) * amp;
76  } else if (xytype == 2) {
77  sumx += i->stripV() * amp;
78  sumy += i->stripVW() * amp;
79  suma += amp;
80  sumxx += (i->stripV()) * (i->stripV()) * amp;
81  sumyy += (i->stripVW()) * (i->stripVW()) * amp;
82  } else {
83  std::cout << " ClusterFP420: wrong xytype = " << xytype << std::endl;
84  }
85 
86 #ifdef mydigidebug11
87  std::cout << " current sumx = " << sumx << std::endl;
88  std::cout << " current sumy = " << sumy << std::endl;
89  std::cout << " current suma = " << suma << std::endl;
90  std::cout << " current barycenter = " << (sumx / static_cast<float>(suma)) << std::endl;
91  std::cout << " current barycenterW= " << (sumy / static_cast<float>(suma)) << std::endl;
92 #endif
93  } //for i
94 
95  if (suma != 0) {
96  barycenter_ = sumx / static_cast<float>(suma);
97  barycerror_ = sumxx / static_cast<float>(suma);
99 #ifdef mydigidebug11
100  std::cout << "barycerror_ = " << barycerror_ << "barycenter_ = " << barycenter_ << std::endl;
101 #endif
102  barycenterW_ = sumy / static_cast<float>(suma);
103  barycerrorW_ = sumyy / static_cast<float>(suma);
105 #ifdef mydigidebug11
106  std::cout << "barycerrorW_ = " << barycerrorW_ << "barycenterW_ = " << barycenterW_ << std::endl;
107 #endif
108  } else {
109  barycenter_ = 1000000.;
110  barycerror_ = 1000000.;
111  barycenterW_ = 1000000.;
112  barycerrorW_ = 1000000.;
113  }
114 
118  cog = barycenter_; // cog for Narrow pixels only
119 
120 #ifdef mydigidebug11
121  std::cout << "AT end: barycenter_ = " << barycenter_ << std::endl;
122  std::cout << "AT end: striprange = " << striprange << std::endl;
123 #endif
124 
125  /*
126 
127  float sumx0 = 0.;
128  float sumxx = 0.;
129  lastStrip = -1;
130  for (HDigiFP420Iter i=range.first; i!=range.second; i++) {
131 #ifdef mydigidebug11
132  std::cout << " current striprange = " << striprange << std::endl;
133 #endif
135  if (lastStrip>0 && i->strip() != lastStrip + 1) {
136  for (int j=0; j < i->strip()-(lastStrip+1); j++) {
137  amplitudes_.push_back( 0);
138  }
139  }
140  lastStrip = i->strip();
141 
142  short amp = i->adc(); // FIXME: gain correction here
143 
144 #ifdef mydigidebug11
145  std::cout << " current strip = " << i->strip() << " amp = " << amp << std::endl;
146 #endif
147 
148  sumx0 += (i->strip()-cog)*amp;
149  sumxx += (i->strip()-cog) * (i->strip()-cog) * amp;
150 
151 
152 #ifdef mydigidebug11
153  std::cout << " 2 current sumx0 = " << sumx0 << std::endl;
154  std::cout << " 2 current sumxx = " << sumxx << std::endl;
155 #endif
156  } //for
157 
158 
159  if(suma != 0) {
160  sumx0 = sumx0 / static_cast<float>(suma) ;
161  sumxx = sumxx / static_cast<float>(suma);
162 
163  //barycerror_ = fabs(sumxx - sumx0*sumx0) ;
164 
165  //barycerror_ = (sumxx - sumx0*sumx0) ;
166  //barycerror_ *= barycerror_ ;
167 
168  barycerror_ = sumxx ;
169 
170  }
171  else{
172  barycerror_ = 1000000. ;
173  }
174 
175 */
176 
177 #ifdef mydigidebug10
178  std::cout << "pitchcommon = " << const_ps1s2[0] << " sigma1= " << const_ps1s2[1] << " sigma2= " << const_ps1s2[2]
179  << std::endl;
180 #endif
181 
182  //
183  if (barycerror_ == 0.0) {
184  barycerror_ = const_ps1s2[1] / const_ps1s2[0]; //
185  } else {
186  barycerror_ = const_ps1s2[2] / const_ps1s2[0]; //
187  }
189  //
190  if (barycerrorW_ == 0.0) {
192  } else {
194  }
196  //
197 
198 #ifdef mydigidebug11
199  std::cout << "barycerror_ = " << barycerror_ << "barycerrorW_ = " << barycerrorW_ << std::endl;
200 #endif
201 
202  // change by hands:
203 
204  // number of station
205  int mysn0 = 2;
206 
207  // number of planes
208  int mypn0 = 5; // number of superplanes
209 
210  // number of station
211  int myrn0 = 6; // 6 possible sensors in superlayer
212 
213  // comment: detID = theFP420NumberingScheme->FP420NumberingScheme::packMYIndex(rn0, pn0, sn0, det, zside, sector, zmodule);
214  // unpack from detId_:
215 
216  int sScale = myrn0 * mypn0, dScale = myrn0 * mypn0 * mysn0;
217 
218  int det = (detId_ - 1) / dScale + 1;
219  int sector = (detId_ - 1 - dScale * (det - 1)) / sScale + 1;
220 
221 #ifdef mydigidebug11
222  std::cout << "sector = " << sector << " det= " << det << std::endl;
223 #endif
224 
225  // unpack from detId_ (OLD):
226  // int sScale = 2*mypn0;
227  //int sector = (detId_-1)/sScale + 1 ;
228 
229  float a = 0.00001;
230 
232  if (mysn0 == 2) {
233  if (sector == 2) {
234  a = 0.0026 + ((0.0075 - 0.0026) / 7.) * (mypn0 - 2); // at 8 m in mm
235  }
236  }
238  else if (mysn0 == 3) {
239  if (sector == 2) {
240  a = 0.0011 + ((0.0030 - 0.0011) / 7.) * (mypn0 - 2); // at 4 m in mm
241  } else if (sector == 3) {
242  a = 0.0022 + ((0.0068 - 0.0022) / 7.) * (mypn0 - 2); // at 8 m in mm
243  }
244  } else if (mysn0 == 4) {
245  if (sector == 2) {
246  a = 0.0009 + ((0.0024 - 0.0009) / 7.) * (mypn0 - 2); // at 2.7 m in mm
247  } else if (sector == 3) {
248  a = 0.0018 + ((0.0050 - 0.0018) / 7.) * (mypn0 - 2); // at 5.4 m in mm
249  } else if (sector == 4) {
250  a = 0.0026 + ((0.0075 - 0.0026) / 7.) * (mypn0 - 2); // at 8.1 m in mm
251  }
252  }
253 
254  // barycerror_+=a*a;
255  // barycerrorW_+=a*a;
256  barycerror_ += a * a / const_ps1s2[0] / const_ps1s2[0];
257  barycerrorW_ += a * a / constW_ps1s2[0] / constW_ps1s2[0];
258 
259  /*
260 
261  if(detId_ < 21) {
262  float a = 0.0001*(int((detId_-1)/2.)+1)/pitchall;
263  barycerror_+=a*a;
264  }
265  else if(detId_ < 41) {
266  float a = 0.0001*(int((detId_-21)/2.)+1)/pitchall;
267  a +=0.0036; // 2.5 m
268  // a +=0.0052; // 4 m
269  // a +=0.0131;// 8. m
270  barycerror_+=a*a;
271  }
272  else if(detId_ < 61) {
273  float a = 0.0001*(int((detId_-41)/2.)+1)/pitchall;
274  a +=0.0069;// 5 m 0.0059
275  // a +=0.0101;// 8. m
276  // a +=0.0241;// 16. m
277  barycerror_+=a*a;
278  }
279  else if(detId_ < 81) {
280  float a = 0.0001*(int((detId_-61)/2.)+1)/pitchall;
281  a +=0.0131;// 7.5 m 0.0111
282  // a +=0.0151;// 12. m
283  // a +=0.0301;// 24. m
284  barycerror_+=a*a;
285  }
286 */
287 #ifdef mydigidebug11
288  std::cout << "AT end: barycerror_ = " << barycerror_ << std::endl;
289 #endif
290 
292  err = barycerror_;
293 
295 
296 #ifdef mydigidebug11
297  std::cout << "AT end: err = " << err << " detId_= " << detId_ << std::endl;
298 #endif
299 }
ClusterFP420::ClusterFP420
ClusterFP420()
Definition: ClusterFP420.h:13
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
mps_fire.i
i
Definition: mps_fire.py:428
ClusterFP420::HDigiFP420Iter
std::vector< HDigiFP420 >::const_iterator HDigiFP420Iter
Definition: ClusterFP420.h:9
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
constW_ps1s2
static const float constW_ps1s2[3]
Definition: ClusterFP420.cc:21
ClusterFP420::firstStrip_
short firstStrip_
Definition: ClusterFP420.h:39
ClusterFP420::barycerror_
float barycerror_
Definition: ClusterFP420.h:42
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
ClusterFP420::barycenter_
float barycenter_
Definition: ClusterFP420.h:41
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
a
double a
Definition: hdecay.h:119
ClusterFP420::HDigiFP420Range
std::pair< HDigiFP420Iter, HDigiFP420Iter > HDigiFP420Range
Definition: ClusterFP420.h:10
submitPVResolutionJobs.err
err
Definition: submitPVResolutionJobs.py:85
ClusterFP420.h
std
Definition: JetResolutionObject.h:76
ClusterFP420::barycenterW_
float barycenterW_
Definition: ClusterFP420.h:43
ClusterFP420::detId_
unsigned int detId_
Definition: ClusterFP420.h:37
ClusterFP420::amplitudes_
std::vector< short > amplitudes_
Definition: ClusterFP420.h:40
HDigiFP420.h
ClusterFP420::barycerrorW_
float barycerrorW_
Definition: ClusterFP420.h:44
const_ps1s2
static const float const_ps1s2[3]
Definition: ClusterFP420.cc:19