CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
ThreeThresholdAlgorithm Class Reference

#include <ThreeThresholdAlgorithm.h>

Inheritance diagram for ThreeThresholdAlgorithm:
StripClusterizerAlgorithm

Public Member Functions

void clusterizeDetUnit (const edm::DetSet< SiStripDigi > &, output_t::FastFiller &)
 
void clusterizeDetUnit (const edmNew::DetSet< SiStripDigi > &, output_t::FastFiller &)
 
template<class digiDetSet >
void clusterizeDetUnit_ (const digiDetSet &digis, output_t::FastFiller &output)
 
void stripByStripAdd (uint16_t strip, uint16_t adc, std::vector< SiStripCluster > &out)
 
bool stripByStripBegin (uint32_t id)
 
void stripByStripEnd (std::vector< SiStripCluster > &out)
 
- Public Member Functions inherited from StripClusterizerAlgorithm
void clusterize (const edm::DetSetVector< SiStripDigi > &, output_t &)
 
void clusterize (const edmNew::DetSetVector< SiStripDigi > &, output_t &)
 
virtual void initialize (const edm::EventSetup &)
 
virtual ~StripClusterizerAlgorithm ()
 

Private Member Functions

void addToCandidate (const SiStripDigi &)
 
void appendBadNeighbors ()
 
void applyGains ()
 
bool candidateAccepted () const
 
bool candidateEnded (const uint16_t &) const
 
void clearCandidate ()
 
template<class T >
void clusterizeDetUnit_ (const T &, output_t::FastFiller &)
 
template<class T >
void endCandidate (T &)
 
uint16_t firstStrip () const
 
 ThreeThresholdAlgorithm (float, float, float, unsigned, unsigned, unsigned, std::string qualityLabel, bool setDetId, bool removeApvShots=false)
 

Private Attributes

std::vector< uint16_t > ADCs
 
SiStripApvShotCleaner ApvCleaner
 
bool candidateLacksSeed
 
float ChannelThreshold
 
float ClusterThresholdSquared
 
uint16_t lastStrip
 
uint8_t MaxAdjacentBad
 
uint8_t MaxSequentialBad
 
uint8_t MaxSequentialHoles
 
float noiseSquared
 
bool RemoveApvShots
 
float SeedThreshold
 

Friends

class StripClusterizerAlgorithmFactory
 

Additional Inherited Members

- Public Types inherited from StripClusterizerAlgorithm
typedef edmNew::DetSetVector
< SiStripCluster
output_t
 
- Protected Member Functions inherited from StripClusterizerAlgorithm
bool allBadBetween (uint16_t L, const uint16_t &R) const
 
bool bad (const uint16_t &strip) const
 
uint32_t currentId ()
 
float gain (const uint16_t &strip) const
 
bool isModuleUsable (const uint32_t &id) const
 
float noise (const uint16_t &strip) const
 
virtual void setDetId (const uint32_t)
 
 StripClusterizerAlgorithm ()
 
- Protected Attributes inherited from StripClusterizerAlgorithm
bool _setDetId
 
std::string qualityLabel
 

Detailed Description

Definition at line 6 of file ThreeThresholdAlgorithm.h.

Constructor & Destructor Documentation

ThreeThresholdAlgorithm::ThreeThresholdAlgorithm ( float  chan,
float  seed,
float  cluster,
unsigned  holes,
unsigned  bad,
unsigned  adj,
std::string  qualityLabel,
bool  setDetId,
bool  removeApvShots = false 
)
private

Definition at line 8 of file ThreeThresholdAlgorithm.cc.

References StripClusterizerAlgorithm::_setDetId, ADCs, StripClusterizerAlgorithm::qualityLabel, and StripClusterizerAlgorithm::setDetId().

10  : ChannelThreshold( chan ), SeedThreshold( seed ), ClusterThresholdSquared( cluster*cluster ),
11  MaxSequentialHoles( holes ), MaxSequentialBad( bad ), MaxAdjacentBad( adj ), RemoveApvShots(removeApvShots) {
13  qualityLabel = (qL);
14  ADCs.reserve(128);
15 }
bool bad(const uint16_t &strip) const
std::vector< uint16_t > ADCs
virtual void setDetId(const uint32_t)

Member Function Documentation

void ThreeThresholdAlgorithm::addToCandidate ( const SiStripDigi digi)
inlineprivate

Definition at line 52 of file ThreeThresholdAlgorithm.cc.

References SiStripDigi::adc(), ADCs, StripClusterizerAlgorithm::bad(), candidateLacksSeed, ChannelThreshold, lastStrip, StripClusterizerAlgorithm::noise(), noiseSquared, SeedThreshold, and SiStripDigi::strip().

Referenced by clusterizeDetUnit_(), and stripByStripAdd().

52  {
53  float Noise = noise( digi.strip() );
54  if( bad(digi.strip()) || digi.adc() < static_cast<uint16_t>( Noise * ChannelThreshold))
55  return;
56 
57  if(candidateLacksSeed) candidateLacksSeed = digi.adc() < static_cast<uint16_t>( Noise * SeedThreshold);
58  if(ADCs.empty()) lastStrip = digi.strip() - 1; // begin candidate
59  while( ++lastStrip < digi.strip() ) ADCs.push_back(0); // pad holes
60 
61  ADCs.push_back( digi.adc() );
62  noiseSquared += Noise*Noise;
63 }
bool bad(const uint16_t &strip) const
float noise(const uint16_t &strip) const
const uint16_t & strip() const
Definition: SiStripDigi.h:40
std::vector< uint16_t > ADCs
const uint16_t & adc() const
Definition: SiStripDigi.h:41
void ThreeThresholdAlgorithm::appendBadNeighbors ( )
inlineprivate

Definition at line 101 of file ThreeThresholdAlgorithm.cc.

References ADCs, StripClusterizerAlgorithm::bad(), firstStrip(), lastStrip, max(), and MaxAdjacentBad.

Referenced by endCandidate().

101  {
102  uint8_t max = MaxAdjacentBad;
103  while(0 < max--) {
104  if( bad( firstStrip()-1) ) { ADCs.insert( ADCs.begin(), 0); }
105  if( bad( lastStrip + 1) ) { ADCs.push_back(0); lastStrip++; }
106  }
107 }
bool bad(const uint16_t &strip) const
const T & max(const T &a, const T &b)
std::vector< uint16_t > ADCs
void ThreeThresholdAlgorithm::applyGains ( )
inlineprivate

Definition at line 88 of file ThreeThresholdAlgorithm.cc.

References ecalMGPA::adc(), ADCs, DeDxDiscriminatorTools::charge(), firstStrip(), StripClusterizerAlgorithm::gain(), and strip().

Referenced by endCandidate().

88  {
89  uint16_t strip = firstStrip();
90  for( std::vector<uint16_t>::iterator adc = ADCs.begin(); adc != ADCs.end(); adc++) {
91  if(*adc > 255) throw InvalidChargeException( SiStripDigi(strip,*adc) );
92  if(*adc > 253) continue; //saturated, do not scale
93  uint16_t charge = static_cast<uint16_t>( *adc/gain(strip++) + 0.5 ); //adding 0.5 turns truncation into rounding
94  *adc = ( charge > 1022 ? 255 :
95  ( charge > 253 ? 254 : charge ));
96  }
97 }
int adc(sample_type sample)
get the ADC sample (12 bits)
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
double charge(const std::vector< uint8_t > &Ampls)
std::vector< uint16_t > ADCs
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
Definition: SiStripDigi.h:12
float gain(const uint16_t &strip) const
bool ThreeThresholdAlgorithm::candidateAccepted ( ) const
inlineprivate

Definition at line 80 of file ThreeThresholdAlgorithm.cc.

References ADCs, candidateLacksSeed, ClusterThresholdSquared, noiseSquared, and funct::pow().

Referenced by endCandidate().

80  {
81  return ( !candidateLacksSeed &&
83  <= std::pow( std::accumulate(ADCs.begin(),ADCs.end(),float(0)), 2));
84 }
std::vector< uint16_t > ADCs
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
bool ThreeThresholdAlgorithm::candidateEnded ( const uint16_t &  testStrip) const
inlineprivate

Definition at line 42 of file ThreeThresholdAlgorithm.cc.

References ADCs, StripClusterizerAlgorithm::allBadBetween(), lastStrip, MaxSequentialBad, and MaxSequentialHoles.

Referenced by clusterizeDetUnit_(), and stripByStripAdd().

42  {
43  uint16_t holes = testStrip - lastStrip - 1;
44  return ( !ADCs.empty() && // a candidate exists, and
45  holes > MaxSequentialHoles && // too many holes if not all are bad strips, and
46  ( holes > MaxSequentialBad || // (too many bad strips anyway, or
47  !allBadBetween( lastStrip, testStrip ))); // not all holes are bad strips)
48 }
std::vector< uint16_t > ADCs
bool allBadBetween(uint16_t L, const uint16_t &R) const
void ThreeThresholdAlgorithm::clearCandidate ( )
inlineprivate
void ThreeThresholdAlgorithm::clusterizeDetUnit ( const edm::DetSet< SiStripDigi > &  digis,
output_t::FastFiller output 
)
virtual

Implements StripClusterizerAlgorithm.

Definition at line 110 of file ThreeThresholdAlgorithm.cc.

References clusterizeDetUnit_().

110 {clusterizeDetUnit_(digis,output);}
void clusterizeDetUnit_(const T &, output_t::FastFiller &)
void ThreeThresholdAlgorithm::clusterizeDetUnit ( const edmNew::DetSet< SiStripDigi > &  digis,
output_t::FastFiller output 
)
virtual

Implements StripClusterizerAlgorithm.

Definition at line 111 of file ThreeThresholdAlgorithm.cc.

References clusterizeDetUnit_().

111 {clusterizeDetUnit_(digis,output);}
void clusterizeDetUnit_(const T &, output_t::FastFiller &)
template<class digiDetSet >
void ThreeThresholdAlgorithm::clusterizeDetUnit_ ( const digiDetSet &  digis,
output_t::FastFiller output 
)
inline

Definition at line 20 of file ThreeThresholdAlgorithm.cc.

References addToCandidate(), ApvCleaner, candidateEnded(), SiStripApvShotCleaner::clean(), clearCandidate(), end, endCandidate(), StripClusterizerAlgorithm::isModuleUsable(), RemoveApvShots, and StripClusterizerAlgorithm::setDetId().

20  {
21  if( !isModuleUsable( digis.detId() )) return;
22  setDetId( digis.detId() );
23 
24  typename digiDetSet::const_iterator
25  scan( digis.begin() ),
26  end( digis.end() );
27 
28  if(RemoveApvShots){
29  ApvCleaner.clean(digis,scan,end);
30  }
31 
33  while( scan != end ) {
34  while( scan != end && !candidateEnded( scan->strip() ) )
35  addToCandidate(*scan++);
37  }
38 }
void addToCandidate(const SiStripDigi &)
bool candidateEnded(const uint16_t &) const
SiStripApvShotCleaner ApvCleaner
#define end
Definition: vmac.h:38
virtual void setDetId(const uint32_t)
bool isModuleUsable(const uint32_t &id) const
bool clean(const edmNew::DetSet< SiStripDigi > &in, edmNew::DetSet< SiStripDigi >::const_iterator &scan, edmNew::DetSet< SiStripDigi >::const_iterator &end)
template<class T >
void ThreeThresholdAlgorithm::clusterizeDetUnit_ ( const T ,
output_t::FastFiller  
)
private

Referenced by clusterizeDetUnit().

template<class T >
void ThreeThresholdAlgorithm::endCandidate ( T out)
inlineprivate
uint16_t ThreeThresholdAlgorithm::firstStrip ( ) const
inlineprivate

Definition at line 32 of file ThreeThresholdAlgorithm.h.

References ADCs, and lastStrip.

Referenced by appendBadNeighbors(), applyGains(), and endCandidate().

32 {return lastStrip - ADCs.size() + 1;}
std::vector< uint16_t > ADCs
void ThreeThresholdAlgorithm::stripByStripAdd ( uint16_t  strip,
uint16_t  adc,
std::vector< SiStripCluster > &  out 
)
inlinevirtual

Implements StripClusterizerAlgorithm.

Definition at line 124 of file ThreeThresholdAlgorithm.cc.

References addToCandidate(), candidateEnded(), and endCandidate().

124  {
125  if(candidateEnded(strip))
126  endCandidate(out);
128 }
int adc(sample_type sample)
get the ADC sample (12 bits)
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
void addToCandidate(const SiStripDigi &)
bool candidateEnded(const uint16_t &) const
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
Definition: SiStripDigi.h:12
tuple out
Definition: dbtoconf.py:99
bool ThreeThresholdAlgorithm::stripByStripBegin ( uint32_t  id)
inlinevirtual

Implements StripClusterizerAlgorithm.

Definition at line 115 of file ThreeThresholdAlgorithm.cc.

References clearCandidate(), StripClusterizerAlgorithm::isModuleUsable(), and StripClusterizerAlgorithm::setDetId().

115  {
116  if( !isModuleUsable( id )) return false;
117  setDetId( id );
118  clearCandidate();
119  return true;
120 }
virtual void setDetId(const uint32_t)
bool isModuleUsable(const uint32_t &id) const
void ThreeThresholdAlgorithm::stripByStripEnd ( std::vector< SiStripCluster > &  out)
inlinevirtual

Implements StripClusterizerAlgorithm.

Definition at line 132 of file ThreeThresholdAlgorithm.cc.

References endCandidate().

132  {
133  endCandidate(out);
134 }
tuple out
Definition: dbtoconf.py:99

Friends And Related Function Documentation

friend class StripClusterizerAlgorithmFactory
friend

Definition at line 8 of file ThreeThresholdAlgorithm.h.

Member Data Documentation

std::vector<uint16_t> ThreeThresholdAlgorithm::ADCs
private
SiStripApvShotCleaner ThreeThresholdAlgorithm::ApvCleaner
private

Definition at line 47 of file ThreeThresholdAlgorithm.h.

Referenced by clusterizeDetUnit_().

bool ThreeThresholdAlgorithm::candidateLacksSeed
private

Definition at line 29 of file ThreeThresholdAlgorithm.h.

Referenced by addToCandidate(), candidateAccepted(), and clearCandidate().

float ThreeThresholdAlgorithm::ChannelThreshold
private

Definition at line 43 of file ThreeThresholdAlgorithm.h.

Referenced by addToCandidate().

float ThreeThresholdAlgorithm::ClusterThresholdSquared
private

Definition at line 43 of file ThreeThresholdAlgorithm.h.

Referenced by candidateAccepted().

uint16_t ThreeThresholdAlgorithm::lastStrip
private
uint8_t ThreeThresholdAlgorithm::MaxAdjacentBad
private

Definition at line 44 of file ThreeThresholdAlgorithm.h.

Referenced by appendBadNeighbors().

uint8_t ThreeThresholdAlgorithm::MaxSequentialBad
private

Definition at line 44 of file ThreeThresholdAlgorithm.h.

Referenced by candidateEnded().

uint8_t ThreeThresholdAlgorithm::MaxSequentialHoles
private

Definition at line 44 of file ThreeThresholdAlgorithm.h.

Referenced by candidateEnded().

float ThreeThresholdAlgorithm::noiseSquared
private

Definition at line 28 of file ThreeThresholdAlgorithm.h.

Referenced by addToCandidate(), candidateAccepted(), and clearCandidate().

bool ThreeThresholdAlgorithm::RemoveApvShots
private

Definition at line 45 of file ThreeThresholdAlgorithm.h.

Referenced by clusterizeDetUnit_().

float ThreeThresholdAlgorithm::SeedThreshold
private

Definition at line 43 of file ThreeThresholdAlgorithm.h.

Referenced by addToCandidate().