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 zside, 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(zside == 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(zside == 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 zside = " << zside << 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
00220
00221
00222
00223
00224
00225 int sScale = 2*mypn0;
00226
00227 int sector = (detId_-1)/sScale + 1 ;
00228
00230 float a = 0.00001;
00231
00232
00233 if(mysn0 == 2) {
00234 if(sector==2) {
00235 a = 0.0026+((0.0075-0.0026)/7.)*(mypn0-2);
00236 }
00237 }
00238 else if(mysn0 == 3) {
00239 if(sector==2) {
00240 a = 0.0011+((0.0030-0.0011)/7.)*(mypn0-2);
00241 }
00242 else if(sector==3) {
00243 a = 0.0022+((0.0068-0.0022)/7.)*(mypn0-2);
00244 }
00245 }
00246 else if(mysn0 == 4) {
00247 if(sector==2) {
00248 a = 0.0009+((0.0024-0.0009)/7.)*(mypn0-2);
00249 }
00250 else if(sector==3) {
00251 a = 0.0018+((0.0050-0.0018)/7.)*(mypn0-2);
00252 }
00253 else if(sector==4) {
00254 a = 0.0026+((0.0075-0.0026)/7.)*(mypn0-2);
00255 }
00256 }
00257
00258
00259
00260 barycerror_+=a*a/const_ps1s2[0]/const_ps1s2[0];
00261 barycerrorW_+=a*a/constW_ps1s2[0]/constW_ps1s2[0];
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291 #ifdef mydigidebug11
00292 std::cout << "AT end: barycerror_ = " << barycerror_ << std::endl;
00293 #endif
00294
00295 barycerror_ = sqrt( barycerror_ );
00296 err = barycerror_;
00297
00298 barycerrorW_ = sqrt( barycerrorW_ );
00299
00300
00301 #ifdef mydigidebug11
00302 std::cout << "AT end: err = " << err<< " detId_= " << detId_ << std::endl;
00303 #endif
00304
00305 }
00306