CMS 3D CMS Logo

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), firstStrip_(range.first->strip())
00006 {
00007 
00008   amplitudes_.reserve( range.second - range.first);
00009   
00010   uint16_t lastStrip=0;
00011   bool firstInloop = true;
00012   for (SiStripDigiIter i=range.first; i!=range.second; i++) {
00013     
00015     if (!firstInloop && i->strip() != lastStrip + 1) {
00016       for (int j=0; j < i->strip()-(lastStrip+1); j++) {
00017         amplitudes_.push_back( 0);
00018       }
00019     }
00020     lastStrip = i->strip();
00021     firstInloop = false;
00022     
00023     amplitudes_.push_back(i->adc()); 
00024   }
00025 }
00026 
00027 SiStripCluster::SiStripCluster(const uint32_t& detid, 
00028                                const uint16_t& firstStrip, 
00029                                std::vector<uint16_t>::const_iterator begin, 
00030                                std::vector<uint16_t>::const_iterator end) :
00031 
00032   detId_(detid),
00033   firstStrip_(firstStrip),
00034   amplitudes_()
00035 {
00036   amplitudes_.reserve(end-begin);
00037   std::vector<uint16_t>::const_iterator idigi = begin;
00038   for (;idigi!=end;idigi++) {
00039     amplitudes_.push_back(*idigi);
00040   }
00041 }
00042 
00043 float SiStripCluster::barycenter() const{
00044   int sumx = 0;
00045   int suma = 0;
00046   size_t asize = amplitudes_.size();
00047   for (size_t i=0;i<asize;++i) {
00048     sumx += (firstStrip_+i)*(amplitudes_[i]);
00049     suma += amplitudes_[i];
00050   }
00051   
00052   // strip centers are offcet by half pitch w.r.t. strip numbers,
00053   // so one has to add 0.5 to get the correct barycenter position
00054   return sumx / static_cast<float>(suma) + 0.5;
00055 }

Generated on Tue Jun 9 17:31:43 2009 for CMSSW by  doxygen 1.5.4