-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml --- r: 77439 b: "refs/heads/CMSSW_7_1_X" c: 755178d h: "refs/heads/CMSSW_7_1_X" i: 77437: f92dc26 77435: 8736f69 77431: a03c93f 77423: 60b5394 77407: 87bd514 77375: f5b6e89 77311: 327d0c5 v: v3
- Loading branch information
Burt Betchart
committed
Nov 9, 2009
1 parent
28ef2a3
commit 57247fc
Showing
3 changed files
with
232 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
--- | ||
refs/heads/gh-pages: 09c786f70121f131b3715aaf3464996502bbeb7e | ||
"refs/heads/CMSSW_7_1_X": a57216bb27c1d92d2a22d2b670ed4969c7379869 | ||
"refs/heads/CMSSW_7_1_X": 755178d9b46ddd0bc67e35d50d0ff874b1fce9ef |
68 changes: 68 additions & 0 deletions
68
trunk/RecoLocalTracker/SiStripClusterizer/interface/SiStripClusterInfo.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#ifndef SISTRIPCLUSTERIZER_SISTRIPCLUSTERINFO_H | ||
#define SISTRIPCLUSTERIZER_SISTRIPCLUSTERINFO_H | ||
|
||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/Framework/interface/ESHandle.h" | ||
#include "DataFormats/SiStripCluster/interface/SiStripCluster.h" | ||
#include <numeric> | ||
|
||
class SiStripNoises; | ||
class SiStripGain; | ||
class SiStripQuality; | ||
|
||
|
||
class SiStripClusterInfo { | ||
|
||
public: | ||
|
||
SiStripClusterInfo(const SiStripCluster& cluster, | ||
const edm::EventSetup& es, | ||
std::string qualityLabel=""); | ||
|
||
const SiStripCluster * cluster() const {return cluster_ptr;} | ||
|
||
uint32_t detId() const {return cluster()->geographicalId();} | ||
uint16_t width() const {return cluster()->amplitudes().size();} | ||
uint16_t firstStrip() const {return cluster()->firstStrip();} | ||
float baryStrip() const {return cluster()->barycenter();} | ||
uint16_t maxStrip() const {return firstStrip() + maxIndex();} | ||
float variance() const; | ||
|
||
const std::vector<uint8_t>& stripCharges() const {return cluster()->amplitudes();} | ||
std::vector<float> stripGains() const; | ||
std::vector<float> stripNoises() const; | ||
std::vector<float> stripNoisesRescaledByGain() const; | ||
std::vector<bool> stripQualitiesBad() const; | ||
|
||
uint16_t charge() const {return accumulate( stripCharges().begin(), stripCharges().end(), uint16_t(0));} | ||
uint8_t maxCharge() const {return * max_element(stripCharges().begin(), stripCharges().end());} | ||
uint16_t maxIndex() const {return max_element(stripCharges().begin(), stripCharges().end()) - stripCharges().begin();} | ||
std::pair<uint16_t,uint16_t> chargeLR() const; | ||
|
||
float noise() const { return calculate_noise(stripNoises());} | ||
float noiseRescaledByGain() const { return calculate_noise(stripNoisesRescaledByGain());} | ||
|
||
float signalOverNoise() const { return charge()/noiseRescaledByGain(); } | ||
|
||
bool IsAnythingBad() const; | ||
bool IsApvBad() const; | ||
bool IsFiberBad() const; | ||
bool IsModuleBad() const; | ||
bool IsModuleUsable() const; | ||
|
||
std::vector<SiStripCluster> reclusterize(const edm::ParameterSet&) const; | ||
|
||
private: | ||
|
||
float calculate_noise(const std::vector<float>&) const; | ||
|
||
const SiStripCluster* cluster_ptr; | ||
const edm::EventSetup& es; | ||
edm::ESHandle<SiStripNoises> noiseHandle; | ||
edm::ESHandle<SiStripGain> gainHandle; | ||
edm::ESHandle<SiStripQuality> qualityHandle; | ||
std::string qualityLabel; | ||
|
||
}; | ||
|
||
#endif |
163 changes: 163 additions & 0 deletions
163
trunk/RecoLocalTracker/SiStripClusterizer/src/SiStripClusterInfo.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
#include "RecoLocalTracker/SiStripClusterizer/interface/SiStripClusterInfo.h" | ||
|
||
#include "CondFormats/DataRecord/interface/SiStripNoisesRcd.h" | ||
#include "CalibTracker/Records/interface/SiStripGainRcd.h" | ||
#include "CalibTracker/Records/interface/SiStripQualityRcd.h" | ||
#include "FWCore/Framework/interface/EventSetup.h" | ||
#include "RecoLocalTracker/SiStripClusterizer/interface/StripClusterizerAlgorithmFactory.h" | ||
#include "RecoLocalTracker/SiStripClusterizer/interface/StripClusterizerAlgorithm.h" | ||
#include <cmath> | ||
|
||
SiStripClusterInfo::SiStripClusterInfo(const SiStripCluster& cluster, | ||
const edm::EventSetup& setup, | ||
std::string quality) | ||
: cluster_ptr(&cluster), | ||
es(setup), | ||
qualityLabel(quality) { | ||
es.get<SiStripNoisesRcd>().get(noiseHandle); | ||
es.get<SiStripGainRcd>().get(gainHandle); | ||
es.get<SiStripQualityRcd>().get(qualityLabel,qualityHandle); | ||
} | ||
|
||
std::pair<uint16_t,uint16_t > SiStripClusterInfo:: | ||
chargeLR() const { | ||
std::vector<uint8_t>::const_iterator | ||
begin( stripCharges().begin() ), | ||
end( stripCharges().end() ), | ||
max; max = max_element(begin,end); | ||
return std::make_pair( accumulate(begin, max, uint16_t(0) ), | ||
accumulate(max+1, end, uint16_t(0) ) ); | ||
} | ||
|
||
|
||
float SiStripClusterInfo:: | ||
variance() const { | ||
float q(0), x1(0), x2(0); | ||
for(std::vector<uint8_t>::const_iterator | ||
begin(stripCharges().begin()), end(stripCharges().end()), it(begin); | ||
it!=end; ++it) { | ||
unsigned i = it-begin; | ||
q += (*it); | ||
x1 += (*it) * (i+0.5); | ||
x2 += (*it) * (i*i+i+1./3); | ||
} | ||
return (x2 - x1*x1/q ) / q; | ||
} | ||
|
||
std::vector<float> SiStripClusterInfo:: | ||
stripNoisesRescaledByGain() const { | ||
std::vector<float> noises = stripNoises(); | ||
std::vector<float> gains = stripGains(); | ||
transform(noises.begin(), noises.end(), gains.begin(), | ||
noises.begin(), | ||
std::divides<double>()); | ||
return noises; | ||
} | ||
|
||
std::vector<float> SiStripClusterInfo:: | ||
stripNoises() const { | ||
SiStripNoises::Range detNoiseRange = noiseHandle->getRange(cluster()->geographicalId()); | ||
|
||
std::vector<float> noises; | ||
for(size_t i=0; i < width(); i++){ | ||
noises.push_back( noiseHandle->getNoise( firstStrip()+i, detNoiseRange) ); | ||
} | ||
return noises; | ||
} | ||
|
||
std::vector<float> SiStripClusterInfo:: | ||
stripGains() const { | ||
SiStripApvGain::Range detGainRange = gainHandle->getRange(cluster()->geographicalId()); | ||
|
||
std::vector<float> gains; | ||
for(size_t i=0; i< width(); i++){ | ||
gains.push_back( gainHandle->getStripGain( firstStrip()+i, detGainRange) ); | ||
} | ||
return gains; | ||
} | ||
|
||
std::vector<bool> SiStripClusterInfo:: | ||
stripQualitiesBad() const { | ||
std::vector<bool> isBad; | ||
for(int i=0; i< width(); i++) { | ||
isBad.push_back( qualityHandle->IsStripBad( cluster()->geographicalId(), | ||
firstStrip()+i) ); | ||
} | ||
return isBad; | ||
} | ||
|
||
float SiStripClusterInfo:: | ||
calculate_noise(const std::vector<float>& noise) const { | ||
float noiseSumInQuadrature = 0; | ||
int numberStripsOverThreshold = 0; | ||
for(int i=0;i<width();i++) { | ||
if(stripCharges().at(i)!=0) { | ||
noiseSumInQuadrature += noise.at(i) * noise.at(i); | ||
numberStripsOverThreshold++; | ||
} | ||
} | ||
return std::sqrt( noiseSumInQuadrature / numberStripsOverThreshold ); | ||
} | ||
|
||
|
||
bool SiStripClusterInfo:: | ||
IsAnythingBad() const { | ||
std::vector<bool> stripBad = stripQualitiesBad(); | ||
return | ||
IsApvBad() || | ||
IsFiberBad() || | ||
IsModuleBad() || | ||
accumulate(stripBad.begin(), stripBad.end(), | ||
false, | ||
std::logical_or<bool>()); | ||
} | ||
|
||
bool SiStripClusterInfo:: | ||
IsApvBad() const { | ||
return | ||
qualityHandle->IsApvBad( cluster()->geographicalId(), firstStrip()/128 ) || | ||
qualityHandle->IsApvBad( cluster()->geographicalId(), (firstStrip()+width())/128 ) ; | ||
} | ||
|
||
bool SiStripClusterInfo:: | ||
IsFiberBad() const { | ||
return | ||
qualityHandle->IsFiberBad( cluster()->geographicalId(), firstStrip()/256 ) || | ||
qualityHandle->IsFiberBad( cluster()->geographicalId(), (firstStrip()+width())/256 ) ; | ||
} | ||
|
||
bool SiStripClusterInfo:: | ||
IsModuleBad() const { | ||
return qualityHandle->IsModuleBad( cluster()->geographicalId() ); | ||
} | ||
|
||
bool SiStripClusterInfo:: | ||
IsModuleUsable() const { | ||
return qualityHandle->IsModuleUsable( cluster()->geographicalId() ); | ||
} | ||
|
||
std::vector<SiStripCluster> SiStripClusterInfo:: | ||
reclusterize(const edm::ParameterSet& conf) const { | ||
|
||
std::vector<SiStripCluster> clusters; | ||
|
||
std::vector<uint8_t> charges = stripCharges(); | ||
std::vector<float> gains = stripGains(); | ||
for(unsigned i=0; i < charges.size(); i++) | ||
charges[i] = (charges[i] < 254) | ||
? static_cast<uint8_t>(charges[i] * gains[i]) | ||
: charges[i]; | ||
|
||
std::auto_ptr<StripClusterizerAlgorithm> | ||
algorithm = StripClusterizerAlgorithmFactory::create(conf); | ||
algorithm->initialize(es); | ||
|
||
if( algorithm->stripByStripBegin( detId() )) { | ||
for(unsigned i = 0; i<width(); i++) | ||
algorithm->stripByStripAdd( firstStrip()+i, charges[i], clusters ); | ||
algorithm->stripByStripEnd( clusters ); | ||
} | ||
|
||
return clusters; | ||
} | ||
|