Skip to content

Commit

Permalink
Merge pull request #2466 from VinInn/StripCluster
Browse files Browse the repository at this point in the history
Reco speedup -- Strip cluster
  • Loading branch information
ktf committed Feb 20, 2014
2 parents cc24212 + 07c15cc commit e6e0c50
Show file tree
Hide file tree
Showing 48 changed files with 1,544 additions and 213 deletions.
2 changes: 2 additions & 0 deletions CalibFormats/SiStripObjects/interface/SiStripDetCabling.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class SiStripDetCabling
uint32_t undetectedNumber(const std::string & subDet, const uint16_t layer) const { return detNumber(subDet, layer, 2); }
inline const SiStripFedCabling * fedCabling() const {return fedCabling_;}

std::map< uint32_t, std::vector<int> > const & connected() const { return connected_;}

private:
SiStripDetCabling(const SiStripDetCabling&); // stop default
const SiStripDetCabling& operator=(const SiStripDetCabling&); // stop default
Expand Down
11 changes: 6 additions & 5 deletions CalibFormats/SiStripObjects/interface/SiStripGain.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
class SiStripGain
{
public:
SiStripGain() {};
virtual ~SiStripGain() {};
SiStripGain() {}

/// Kept for compatibility
inline SiStripGain(const SiStripApvGain& apvgain, const double & factor) :
Expand All @@ -64,9 +63,11 @@ class SiStripGain
// getters
// For the product of all apvGains
// -------------------------------
const SiStripApvGain::Range getRange(const uint32_t& detID) const;
float getStripGain(const uint16_t& strip, const SiStripApvGain::Range& range) const;
float getApvGain(const uint16_t& apv, const SiStripApvGain::Range& range) const;
const SiStripApvGain::Range getRange(uint32_t detID) const { return apvgain_->getRange(detID);}
SiStripApvGain::Range getRangeByPos(unsigned short pos) const { return apvgain_->getRangeByPos(pos);}
static float getStripGain(const uint16_t& strip, const SiStripApvGain::Range& range) { return SiStripApvGain::getStripGain(strip, range);}
static float getApvGain(const uint16_t& apv, const SiStripApvGain::Range& range) { return SiStripApvGain::getApvGain(apv, range); }


// For a specific apvGain
// ----------------------
Expand Down
8 changes: 7 additions & 1 deletion CalibFormats/SiStripObjects/interface/SiStripQuality.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@
#include "CondFormats/RunInfo/interface/RunInfo.h"
#include <vector>

#include "FWCore/Utilities/interface/GCC11Compatibility.h"

class SiStripDetCabling;
class SiStripDetInfoFileReader;

class SiStripQuality: public SiStripBadStrip {
class SiStripQuality GCC11_FINAL : public SiStripBadStrip {

public:

Expand Down Expand Up @@ -121,6 +123,10 @@ class SiStripQuality: public SiStripBadStrip {
inline void setPrintDebugOutput(const bool printDebug) { printDebug_ = printDebug; }
inline void setUseEmptyRunInfo(const bool useEmptyRunInfo) { useEmptyRunInfo_ = useEmptyRunInfo; }


SiStripDetCabling const * cabling() const { return SiStripDetCabling_;}


private:

void compact(std::vector<unsigned int>&,std::vector<unsigned int>&,unsigned short&);
Expand Down
3 changes: 2 additions & 1 deletion CalibFormats/SiStripObjects/interface/SiStripRegionCabling.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class SiStripRegionCabling {
enum Layer {TIBLAYERS = 4, TOBLAYERS = 6, TIDLAYERS = 3, TECLAYERS = 9, ALLLAYERS = 10};

/** Cabling typedefs */
typedef std::map< uint32_t, std::vector<FedChannelConnection> > ElementCabling;
typedef std::pair< uint32_t, std::vector<FedChannelConnection> > Element;
typedef std::vector< Element > ElementCabling;
typedef std::vector< ElementCabling > WedgeCabling;
typedef std::vector< WedgeCabling > RegionCabling;
typedef std::vector< RegionCabling > Cabling;
Expand Down
22 changes: 2 additions & 20 deletions CalibFormats/SiStripObjects/src/SiStripGain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,7 @@ void SiStripGain::fillNewGain(const SiStripApvGain * apvgain, const double & fac
apvgainAutoPtr_.reset(newApvGain);
}

float SiStripGain::getStripGain(const uint16_t& strip, const SiStripApvGain::Range& range) const
{
if( apvgain_ == 0 ) {
edm::LogError("SiStripGain::getStripGain") << "ERROR: no gain available. Returning gain = 1." << std::endl;
return 1.;
}
return( apvgain_->getStripGain(strip, range) );
}


float SiStripGain::getStripGain(const uint16_t& strip, const SiStripApvGain::Range& range, const uint32_t index) const
{
Expand All @@ -101,14 +94,7 @@ float SiStripGain::getStripGain(const uint16_t& strip, const SiStripApvGain::Ran
return 1.;
}

float SiStripGain::getApvGain(const uint16_t& apv, const SiStripApvGain::Range& range) const
{
if( apvgain_ == 0 ) {
edm::LogError("SiStripGain::getApvGain") << "ERROR: no gain available. Returning gain = 1." << std::endl;
return 1.;
}
return( apvgain_->getApvGain(apv, range) );
}


float SiStripGain::getApvGain(const uint16_t& apv, const SiStripApvGain::Range& range, const uint32_t index) const
{
Expand All @@ -125,10 +111,6 @@ void SiStripGain::getDetIds(std::vector<uint32_t>& DetIds_) const
return apvgain_->getDetIds(DetIds_);
}

const SiStripApvGain::Range SiStripGain::getRange(const uint32_t& DetId) const
{
return apvgain_->getRange(DetId);
}

const SiStripApvGain::Range SiStripGain::getRange(const uint32_t& DetId, const uint32_t index) const
{
Expand Down
2 changes: 1 addition & 1 deletion CalibFormats/SiStripObjects/src/SiStripQuality.cc
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ bool SiStripQuality::IsStripBad(const Range& range, const short& strip) const
SiStripBadStrip::data fs;
for(SiStripBadStrip::ContainerIterator it=range.first;it!=range.second;++it){
fs=decode(*it);
if ( fs.firstStrip<=strip && strip<fs.firstStrip+fs.range ){
if ( (fs.firstStrip<=strip) & (strip<fs.firstStrip+fs.range) ){
result=true;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ std::auto_ptr<SiStripRegionCabling> SiStripRegionConnectivity::produceRegionCabl
std::vector<const FedChannelConnection *>::iterator jconn = conns.end();

//Update region cabling map
regioncabling[reg][subdet][layer][idet->first].resize(conns.size());
regioncabling[reg][subdet][layer].push_back(SiStripRegionCabling::Element());
auto & elem = regioncabling[reg][subdet][layer].back();
elem.first=idet->first; elem.second.resize(conns.size());
for ( ; iconn != jconn; ++iconn ) {
if ( ((*iconn) != 0) && ((*iconn)->apvPairNumber() < conns.size()) ) {
regioncabling[reg][subdet][layer][idet->first][(*iconn)->apvPairNumber()] = **iconn;
elem.second[(*iconn)->apvPairNumber()] = **iconn;
}
}
}
Expand Down
20 changes: 14 additions & 6 deletions CondFormats/SiStripObjects/interface/SiStripApvGain.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include<map>
#include<iostream>
#include<boost/cstdint.hpp>

#include "FWCore/MessageLogger/interface/MessageLogger.h"
/**
* Stores the information of the gain for each apv using four vectors <br>
* A vector<unsigned int> (v_detids) stores the detId. <br>
Expand Down Expand Up @@ -43,8 +43,8 @@ class SiStripApvGain {
ContainerIterator getLastElement(RegistryConstIterator& idet){return v_begin+*(iend_begin+(idet-detid_begin));}
};

SiStripApvGain(){};
~SiStripApvGain(){};
SiStripApvGain(){}
~SiStripApvGain(){}

RegistryPointers getRegistryPointers() const {
RegistryPointers p;
Expand All @@ -62,11 +62,19 @@ class SiStripApvGain {


bool put(const uint32_t& detID, Range input);
const Range getRange(const uint32_t& detID) const;
const Range getRange(const uint32_t detID) const;
Range getRangeByPos(unsigned short pos) const;
void getDetIds(std::vector<uint32_t>& DetIds_) const;

float getStripGain (const uint16_t& strip, const Range& range) const;
float getApvGain (const uint16_t& apv, const Range& range) const;

#ifdef EDM_ML_DEBUG
static float getStripGain (const uint16_t& strip, const Range& range);
static float getApvGain (const uint16_t& apv, const Range& range);
#else
static float getStripGain (uint16_t strip, const Range& range) {uint16_t apv = strip/128; return *(range.first+apv);}
static float getApvGain (uint16_t apv, const Range& range) {return *(range.first+apv);}
#endif


void printDebug(std::stringstream & ss) const;
void printSummary(std::stringstream & ss) const;
Expand Down
3 changes: 2 additions & 1 deletion CondFormats/SiStripObjects/interface/SiStripBadStrip.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class SiStripBadStrip {

bool put(const uint32_t& detID,const InputVector& vect){return put(detID,Range(vect.begin(),vect.end()));}
bool put(const uint32_t& detID,Range input);
const Range getRange(const uint32_t& detID) const;
const Range getRange(const uint32_t detID) const;
Range getRangeByPos(unsigned short pos) const;
void getDetIds(std::vector<uint32_t>& DetIds_) const;
void printSummary(std::stringstream & ss) const;
void printDebug(std::stringstream & ss) const;
Expand Down
23 changes: 20 additions & 3 deletions CondFormats/SiStripObjects/interface/SiStripNoises.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
#define SiStripNoises_h

#include<vector>
#include<map>
#include<utility>
#include<iostream>
#include<boost/cstdint.hpp>

#include<cassert>
#include<cstring>

/**
* Stores the noise value for all the strips. <br>
* The values are encoded from a vector<uint16_t> to a vector<unsigned char> <br>
Expand Down Expand Up @@ -48,7 +51,8 @@ class SiStripNoises
~SiStripNoises(){}

bool put(const uint32_t& detID,const InputVector &input);
const Range getRange(const uint32_t& detID) const;
const Range getRange(const uint32_t detID) const;
Range getRangeByPos(unsigned short pos) const;
void getDetIds(std::vector<uint32_t>& DetIds_) const;

ContainerIterator getDataVectorBegin() const {return v_noises.begin();}
Expand All @@ -60,7 +64,12 @@ class SiStripNoises
return 0.1f*float(decode(strip,range));
}

#ifdef EDM_ML_DEBUG
static float getNoise(uint16_t strip, const Range& range);
#else
static float getNoise(uint16_t strip, const Range& range) { return getNoiseFast(strip,range);}
#endif


void allNoises (std::vector<float> & noises, const Range& range) const;
void setData(float noise_, InputVector& vped);
Expand Down Expand Up @@ -106,11 +115,19 @@ inline uint16_t SiStripNoises::decode (uint16_t strip, const Range& range) {

uint32_t lowBit = strip * BITS_PER_STRIP;
uint8_t firstByteBit = (lowBit & 7);//module 8

uint16_t vin = uint16_t(*(data-lowBit/8)) | (uint16_t(*(data-lowBit/8-1))<<8);
vin = vin >> firstByteBit; vin &= 0x1FF;
return vin;

/*
uint8_t firstByteNBits = 8 - firstByteBit;
uint8_t firstByteMask = 0xffu << firstByteBit;
uint8_t secondByteMask = ~(0xffu << (BITS_PER_STRIP - firstByteNBits));
uint16_t value = ((uint16_t(*(data-lowBit/8 )) & firstByteMask) >> firstByteBit) | ((uint16_t(*(data-lowBit/8-1)) & secondByteMask) << firstByteNBits);
if(vin!=value) std::cout << vin << ',' <<value << std::endl;
*/
/*
if(strip < 25){
std::cout << "***************DECODE*********************"<<"\n"
Expand All @@ -128,7 +145,7 @@ inline uint16_t SiStripNoises::decode (uint16_t strip, const Range& range) {
<< std::endl;
}
*/
return value;
//return value;
}


Expand Down
21 changes: 17 additions & 4 deletions CondFormats/SiStripObjects/src/SiStripApvGain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,37 @@ bool SiStripApvGain::put(const uint32_t& DetId, Range input) {
return true;
}

const SiStripApvGain::Range SiStripApvGain::getRange(const uint32_t& DetId) const {
const SiStripApvGain::Range SiStripApvGain::getRange(const uint32_t DetId) const {
// get SiStripApvGain Range of DetId
RegistryConstIterator p = std::lower_bound(v_detids.begin(),v_detids.end(),DetId);
if (p==v_detids.end() || *p!=DetId)
return SiStripApvGain::Range(v_gains.end(),v_gains.end());
else{
unsigned int pd= p-v_detids.begin();
unsigned int ibegin = *(v_ibegin.begin()+pd);
unsigned int iend = *(v_iend.begin()+pd);
unsigned int iend = *(v_iend.begin()+pd);
__builtin_prefetch((&v_gains.front())+ibegin);
return SiStripApvGain::Range(v_gains.begin()+ibegin,v_gains.begin()+iend);
}
}

SiStripApvGain::Range SiStripApvGain::getRangeByPos(unsigned short pos) const {
if (pos>v_detids.size()) return Range(v_gains.end(),v_gains.end());
unsigned int ibegin = *(v_ibegin.begin()+pos);
unsigned int iend = *(v_iend.begin()+pos);
__builtin_prefetch((&v_gains.front())+ibegin);
return SiStripApvGain::Range(v_gains.begin()+ibegin,v_gains.begin()+iend);
}


void SiStripApvGain::getDetIds(std::vector<uint32_t>& DetIds_) const {
// returns vector of DetIds in map
// DetIds_=v_detids;
DetIds_.insert(DetIds_.begin(),v_detids.begin(),v_detids.end());
}

float SiStripApvGain::getStripGain(const uint16_t& strip, const Range& range) const {
#ifdef EDM_ML_DEBUG
float SiStripApvGain::getStripGain(const uint16_t& strip, const Range& range) {
uint16_t apv = (uint16_t) (strip/128);
if (apv>=range.second-range.first){
throw cms::Exception("CorruptedData")
Expand All @@ -58,7 +69,7 @@ float SiStripApvGain::getStripGain(const uint16_t& strip, const Range& range) co

}

float SiStripApvGain::getApvGain(const uint16_t& apv, const Range& range) const {
float SiStripApvGain::getApvGain(const uint16_t& apv, const Range& range) {
if (apv>=range.second-range.first){
throw cms::Exception("CorruptedData")
<< "[SiStripApvGain::getApvGain] looking for SiStripApvGain for an apv out of range: apv " << apv << std::endl;
Expand All @@ -68,6 +79,8 @@ float SiStripApvGain::getApvGain(const uint16_t& apv, const Range& range) const

return *(range.first+apv);
}
#endif


void SiStripApvGain::printDebug(std::stringstream & ss) const
{
Expand Down
17 changes: 15 additions & 2 deletions CondFormats/SiStripObjects/src/SiStripBadStrip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,27 @@ bool SiStripBadStrip::put(const uint32_t& DetId, Range input) {
return true;
}

const SiStripBadStrip::Range SiStripBadStrip::getRange(const uint32_t& DetId) const {
const SiStripBadStrip::Range SiStripBadStrip::getRange(const uint32_t DetId) const {
// get SiStripBadStrip Range of DetId

RegistryIterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiStripBadStrip::StrictWeakOrdering());
if (p==indexes.end()|| p->detid!=DetId)
return SiStripBadStrip::Range(v_badstrips.end(),v_badstrips.end());
else
else {
__builtin_prefetch((&v_badstrips.front())+p->ibegin);
__builtin_prefetch((&v_badstrips.front())+p->ibegin+24);
__builtin_prefetch((&v_badstrips.front())+p->iend-24);
return SiStripBadStrip::Range(v_badstrips.begin()+p->ibegin,v_badstrips.begin()+p->iend);
}
}

SiStripBadStrip::Range SiStripBadStrip::getRangeByPos(unsigned short pos) const {
if (pos>indexes.size()) return Range(v_badstrips.end(),v_badstrips.end());
auto p = indexes.begin()+pos;
__builtin_prefetch((&v_badstrips.front())+p->ibegin);
__builtin_prefetch((&v_badstrips.front())+p->ibegin+24);
__builtin_prefetch((&v_badstrips.front())+p->iend-24);
return Range(v_badstrips.begin()+p->ibegin,v_badstrips.begin()+p->iend);
}


Expand Down
Loading

0 comments on commit e6e0c50

Please sign in to comment.