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