Go to the documentation of this file.00001
00002
00003
00004
00005
00007 #include "DataFormats/FP420Cluster/interface/ClusterFP420.h"
00008 #include "DataFormats/FP420Digi/interface/HDigiFP420.h"
00009 #include <iostream>
00010 #include <cmath>
00011 using namespace std;
00012
00013
00014
00015
00016
00017
00018
00019 static float const_ps1s2[3] = {0.050,.0135,0.0086};
00020 static float constW_ps1s2[3] = {0.400,.1149,0.0648};
00021
00022
00023 ClusterFP420::ClusterFP420( unsigned int detid, unsigned int xytype, const HDigiFP420Range& range,
00024 float & cog ,float & err ) :
00025 detId_(detid), firstStrip_(range.first->strip())
00026
00027 {
00028
00029
00030 #ifdef mydigidebug11
00031 std::cout << "===================================== firstStrip = " << firstStrip_ << std::endl;
00032 std::cout << "==range.first->strip() = " << range.first->strip() << std::endl;
00033 std::cout << "==range.second->strip() = " << range.second->strip() << std::endl;
00034 #endif
00035
00036 amplitudes_.reserve( range.second - range.first);
00037
00038
00039 int striprange = 0;
00040 float sumx = 0.;
00041 float sumxx = 0.;
00042 float sumy = 0.;
00043 float sumyy = 0.;
00044 int suma = 0;
00045
00046
00047 for (HDigiFP420Iter i=range.first; i!=range.second; i++) {
00048 striprange++;
00049 #ifdef mydigidebug11
00050 std::cout << " current striprange = " << striprange << std::endl;
00051 #endif
00052
00054
00055
00056
00057
00058
00059
00060
00061
00062 short amp = i->adc();
00063
00064 #ifdef mydigidebug11
00065 std::cout << " current strip = " << i->strip() << " amp = " << amp << std::endl;
00066 #endif
00067
00068 amplitudes_.push_back(amp);
00069 if(xytype == 1) {
00070 sumx += i->stripH()*amp;
00071 sumy += i->stripHW()*amp;
00072 suma += amp;
00073 sumxx += (i->stripH()) * (i->stripH()) * amp;
00074 sumyy += (i->stripHW()) * (i->stripHW()) * amp;
00075 }
00076 else if(xytype == 2) {
00077 sumx += i->stripV()*amp;
00078 sumy += i->stripVW()*amp;
00079 suma += amp;
00080 sumxx += (i->stripV()) * (i->stripV()) * amp;
00081 sumyy += (i->stripVW()) * (i->stripVW()) * amp;
00082 }
00083 else {
00084 std::cout << " ClusterFP420: wrong xytype = " << xytype << std::endl;
00085 }
00086
00087 #ifdef mydigidebug11
00088 std::cout << " current sumx = " << sumx << std::endl;
00089 std::cout << " current sumy = " << sumy << std::endl;
00090 std::cout << " current suma = " << suma << std::endl;
00091 std::cout << " current barycenter = " << (sumx / static_cast<float>(suma) ) << std::endl;
00092 std::cout << " current barycenterW= " << (sumy / static_cast<float>(suma) ) << std::endl;
00093 #endif
00094 }
00095
00096
00097 if(suma != 0) {
00098 barycenter_ = sumx / static_cast<float>(suma) ;
00099 barycerror_ = sumxx / static_cast<float>(suma) ;
00100 barycerror_ = fabs(barycerror_ - barycenter_*barycenter_) ;
00101 #ifdef mydigidebug11
00102 std::cout << "barycerror_ = " << barycerror_ << "barycenter_ = " << barycenter_ << std::endl;
00103 #endif
00104 barycenterW_ = sumy / static_cast<float>(suma) ;
00105 barycerrorW_ = sumyy / static_cast<float>(suma) ;
00106 barycerrorW_ = fabs(barycerrorW_ - barycenterW_*barycenterW_) ;
00107 #ifdef mydigidebug11
00108 std::cout << "barycerrorW_ = " << barycerrorW_ << "barycenterW_ = " << barycenterW_ << std::endl;
00109 #endif
00110 }
00111 else{
00112 barycenter_ = 1000000. ;
00113 barycerror_ = 1000000. ;
00114 barycenterW_ = 1000000. ;
00115 barycerrorW_ = 1000000. ;
00116 }
00117
00121 cog = barycenter_;
00122
00123 #ifdef mydigidebug11
00124 std::cout << "AT end: barycenter_ = " << barycenter_ << std::endl;
00125 std::cout << "AT end: striprange = " << striprange << std::endl;
00126 #endif
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184 #ifdef mydigidebug10
00185 std::cout << "pitchcommon = " << const_ps1s2[0] << " sigma1= " << const_ps1s2[1] << " sigma2= " << const_ps1s2[2] << std::endl;
00186 #endif
00187
00188
00189 if(barycerror_ == 0.0) {
00190 barycerror_ = const_ps1s2[1]/const_ps1s2[0];
00191 }
00192 else{
00193 barycerror_ = const_ps1s2[2]/const_ps1s2[0];
00194 }
00195 barycerror_ *= barycerror_;
00196
00197 if(barycerrorW_ == 0.0) {
00198 barycerrorW_ = constW_ps1s2[1]/constW_ps1s2[0];
00199 }
00200 else{
00201 barycerrorW_ = constW_ps1s2[2]/constW_ps1s2[0];
00202 }
00203 barycerrorW_ *= barycerrorW_;
00204
00205
00206 #ifdef mydigidebug11
00207 std::cout << "barycerror_ = " << barycerror_ << "barycerrorW_ = " << barycerrorW_ << std::endl;
00208 #endif
00209
00210
00211
00212
00213 int mysn0 = 2;
00214
00215
00216 int mypn0 = 5;
00217
00218
00219 int myrn0 = 6;
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230 int sScale = myrn0*mypn0, dScale = myrn0*mypn0*mysn0;
00231
00232 int det = (detId_-1)/dScale + 1;
00233 int sector = (detId_-1- dScale*(det - 1))/sScale + 1;
00234
00235 #ifdef mydigidebug11
00236 std::cout << "sector = " << sector << " det= " << det << std::endl;
00237 #endif
00238
00239
00240
00241
00242
00243
00244
00245 float a = 0.00001;
00246
00247
00249 if(mysn0 == 2) {
00250 if(sector==2) {
00251 a = 0.0026+((0.0075-0.0026)/7.)*(mypn0-2);
00252 }
00253 }
00255 else if(mysn0 == 3) {
00256 if(sector==2) {
00257 a = 0.0011+((0.0030-0.0011)/7.)*(mypn0-2);
00258 }
00259 else if(sector==3) {
00260 a = 0.0022+((0.0068-0.0022)/7.)*(mypn0-2);
00261 }
00262 }
00263 else if(mysn0 == 4) {
00264 if(sector==2) {
00265 a = 0.0009+((0.0024-0.0009)/7.)*(mypn0-2);
00266 }
00267 else if(sector==3) {
00268 a = 0.0018+((0.0050-0.0018)/7.)*(mypn0-2);
00269 }
00270 else if(sector==4) {
00271 a = 0.0026+((0.0075-0.0026)/7.)*(mypn0-2);
00272 }
00273 }
00274
00275
00276
00277 barycerror_+=a*a/const_ps1s2[0]/const_ps1s2[0];
00278 barycerrorW_+=a*a/constW_ps1s2[0]/constW_ps1s2[0];
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308 #ifdef mydigidebug11
00309 std::cout << "AT end: barycerror_ = " << barycerror_ << std::endl;
00310 #endif
00311
00312 barycerror_ = sqrt( barycerror_ );
00313 err = barycerror_;
00314
00315 barycerrorW_ = sqrt( barycerrorW_ );
00316
00317
00318 #ifdef mydigidebug11
00319 std::cout << "AT end: err = " << err<< " detId_= " << detId_ << std::endl;
00320 #endif
00321
00322 }
00323