test
CMS 3D CMS Logo

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