CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/DataFormats/SiStripCluster/src/SiStripCluster.cc

Go to the documentation of this file.
00001 
00002 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
00003 
00004 SiStripCluster::SiStripCluster( uint32_t detid, const SiStripDigiRange& range) :
00005   //detId_(detid),
00006   detId_(0),
00007   firstStrip_(range.first->strip()),
00008   error_x(-99999.9)
00009 {
00010 
00011   amplitudes_.reserve( range.second - range.first);
00012   
00013   uint16_t lastStrip=0;
00014   bool firstInloop = true;
00015   for (SiStripDigiIter i=range.first; i!=range.second; i++) {
00016     
00018     if (!firstInloop && i->strip() != lastStrip + 1) {
00019       for (int j=0; j < i->strip()-(lastStrip+1); j++) {
00020         amplitudes_.push_back( 0);
00021       }
00022     }
00023     lastStrip = i->strip();
00024     firstInloop = false;
00025     
00026     amplitudes_.push_back(i->adc()); 
00027   }
00028 }
00029 
00030 SiStripCluster::SiStripCluster(const uint32_t& detid, 
00031                                const uint16_t& firstStrip, 
00032                                std::vector<uint16_t>::const_iterator begin, 
00033                                std::vector<uint16_t>::const_iterator end) :
00034 
00035   //  detId_(detid),
00036   detId_(0),
00037   firstStrip_(firstStrip),
00038   amplitudes_(begin,end),
00039 
00040   // ggiurgiu@fnal.gov, 01/05/12
00041   // Initialize the split cluster errors to un-physical values.
00042   // The CPE will check these errors and if they are not un-physical,
00043   // it will recognize the clusters as split and assign these (increased)
00044   // errors to the corresponding rechit.
00045   error_x(-99999.9)
00046 {}
00047 
00048 float SiStripCluster::barycenter() const{
00049   int sumx = 0;
00050   int suma = 0;
00051   size_t asize = amplitudes_.size();
00052   for (size_t i=0;i<asize;++i) {
00053     sumx += (firstStrip_+i)*(amplitudes_[i]);
00054     suma += amplitudes_[i];
00055   }
00056   
00057   // strip centers are offcet by half pitch w.r.t. strip numbers,
00058   // so one has to add 0.5 to get the correct barycenter position
00059   return sumx / static_cast<float>(suma) + 0.5;
00060 }