CMS 3D CMS Logo

ClusterFP420.cc

Go to the documentation of this file.
00001 
00002 // File: ClusterFP420.cc
00003 // Date: 12.2006
00004 // Description: ClusterFP420 for FP420
00005 // Modifications: 
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 //#define mydigidebug10
00014 //#define mydigidebug11
00015 
00016 //static float const_ps1s2[3] =  {0.050,.0139,0.0045};// pitch, sigma_1channel, sigma_2channels - Narrow
00017 //static float constW_ps1s2[3] = {0.400,.0920,0.0280};// pitch, sigma_1channel, sigma_2channels - Wide
00018 
00019 static float const_ps1s2[3] =  {0.050,.0135,0.0086};// pitch, sigma_1channel, sigma_2channels - Narrow
00020 static float constW_ps1s2[3] = {0.400,.1149,0.0648};// pitch, sigma_1channel, sigma_2channels - Wide
00021 
00022 // sense of zside here is X or Y type planes. Now we are working with X only, i.e. zside=2
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 //  detId_(detid), zside_(zside), firstStrip_(range.first->strip())
00027 {
00028   // For the range of strips in cluster assign adc(,its numbers i->strip()) calculate cog... 
00029   // strip   :    0-400 or 0-250
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 //  int lastStrip = -1;
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       if (i!=ibeg && (difNarr(zside,i,i-1) > 1 || difWide(zside,i,i-1) > 1)   ){
00055     if (lastStrip>0 && i->strip() != lastStrip + 1) {
00056                  for (int j=0; j < i->strip()-(lastStrip+1); j++) {
00057                    amplitudes_.push_back( 0);
00058                  }
00059     }
00060     lastStrip = i->strip();
00061 */
00062     short amp = i->adc();       // FIXME: gain correction here
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   } //for i
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_;// cog for Narrow pixels only
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   float sumx0 = 0.;
00135   float sumxx = 0.;
00136   lastStrip = -1;
00137   for (HDigiFP420Iter i=range.first; i!=range.second; i++) {
00138 #ifdef mydigidebug11
00139    std::cout << " current striprange = " << striprange << std::endl;
00140 #endif
00142     if (lastStrip>0 && i->strip() != lastStrip + 1) {
00143                  for (int j=0; j < i->strip()-(lastStrip+1); j++) {
00144                    amplitudes_.push_back( 0);
00145                  }
00146     }
00147     lastStrip = i->strip();
00148 
00149     short amp = i->adc();       // FIXME: gain correction here
00150 
00151 #ifdef mydigidebug11
00152    std::cout << " current strip = " << i->strip() << "  amp = " << amp << std::endl;
00153 #endif
00154 
00155     sumx0 += (i->strip()-cog)*amp;
00156     sumxx += (i->strip()-cog) * (i->strip()-cog) * amp;
00157 
00158 
00159 #ifdef mydigidebug11
00160    std::cout << " 2 current sumx0 = " << sumx0 << std::endl;
00161    std::cout << " 2 current sumxx = " << sumxx << std::endl;
00162 #endif
00163   } //for
00164 
00165 
00166   if(suma != 0) {
00167     sumx0 = sumx0 / static_cast<float>(suma) ;
00168     sumxx = sumxx / static_cast<float>(suma);
00169     
00170     //barycerror_ = fabs(sumxx - sumx0*sumx0) ;
00171 
00172     //barycerror_ = (sumxx - sumx0*sumx0) ;
00173     //barycerror_ *= barycerror_ ;
00174 
00175       barycerror_ = sumxx ;
00176 
00177   }
00178   else{
00179     barycerror_ = 1000000. ;
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    // change by hands:
00211 
00212         // number of station
00213         int  mysn0 = 2;
00214         
00215         // number of planes 
00216         int  mypn0 = 5;
00217 
00218 
00219 
00220 
00221 
00222 
00223 
00224   // unpack from detId_:
00225         int  sScale = 2*mypn0;
00226         //      int  zScale=2;
00227         int  sector = (detId_-1)/sScale + 1 ;
00228         //      int  zmodule = (detId_ - (sector - 1)*sScale - 1) /zScale + 1 ;
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); // 8 m 
00236               }
00237         }
00238         else if(mysn0 == 3) {
00239           if(sector==2) {
00240             a = 0.0011+((0.0030-0.0011)/7.)*(mypn0-2); // 4 m 
00241               }
00242           else if(sector==3) {
00243             a = 0.0022+((0.0068-0.0022)/7.)*(mypn0-2); // 8 m 
00244               }
00245         }
00246         else if(mysn0 == 4) {
00247           if(sector==2) {
00248             a = 0.0009+((0.0024-0.0009)/7.)*(mypn0-2); // 2.7 m 
00249               }
00250           else if(sector==3) {
00251             a = 0.0018+((0.0050-0.0018)/7.)*(mypn0-2); // 5.4 m 
00252               }
00253           else if(sector==4) {
00254             a = 0.0026+((0.0075-0.0026)/7.)*(mypn0-2); // 8.1 m 
00255               }
00256         }
00257 
00258         //      barycerror_+=a*a;
00259         //      barycerrorW_+=a*a;
00260         barycerror_+=a*a/const_ps1s2[0]/const_ps1s2[0];
00261         barycerrorW_+=a*a/constW_ps1s2[0]/constW_ps1s2[0];
00262 
00263     /*
00264 
00265   if(detId_ < 21) {
00266     float a = 0.0001*(int((detId_-1)/2.)+1)/pitchall;
00267     barycerror_+=a*a;
00268   }
00269   else if(detId_ < 41) {
00270     float a = 0.0001*(int((detId_-21)/2.)+1)/pitchall;
00271            a +=0.0036; // 2.5 m
00272     //          a +=0.0052; // 4 m
00273     //  a +=0.0131;// 8. m
00274     barycerror_+=a*a;
00275   }
00276   else if(detId_ < 61) {
00277     float a = 0.0001*(int((detId_-41)/2.)+1)/pitchall;
00278              a +=0.0069;// 5 m  0.0059
00279     //          a +=0.0101;// 8. m
00280     //  a +=0.0241;// 16. m
00281     barycerror_+=a*a;
00282   }
00283   else if(detId_ < 81) {
00284     float a = 0.0001*(int((detId_-61)/2.)+1)/pitchall;
00285           a +=0.0131;// 7.5 m   0.0111
00286     //       a +=0.0151;// 12. m
00287     //  a +=0.0301;// 24. m
00288     barycerror_+=a*a;
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 

Generated on Tue Jun 9 17:30:46 2009 for CMSSW by  doxygen 1.5.4