CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes | Friends

ThreeThresholdAlgorithm Class Reference

#include <ThreeThresholdAlgorithm.h>

Inheritance diagram for ThreeThresholdAlgorithm:
StripClusterizerAlgorithm

List of all members.

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)

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

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]

Member Function Documentation

void ThreeThresholdAlgorithm::addToCandidate ( const SiStripDigi digi) [inline, private]

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().

                                        { 
  float Noise = noise( digi.strip() );
  if( bad(digi.strip()) || digi.adc() < static_cast<uint16_t>( Noise * ChannelThreshold))
    return;

  if(candidateLacksSeed) candidateLacksSeed  =  digi.adc() < static_cast<uint16_t>( Noise * SeedThreshold);
  if(ADCs.empty()) lastStrip = digi.strip() - 1; // begin candidate
  while( ++lastStrip < digi.strip() ) ADCs.push_back(0); // pad holes

  ADCs.push_back( digi.adc() );
  noiseSquared += Noise*Noise;
}
void ThreeThresholdAlgorithm::appendBadNeighbors ( ) [inline, private]

Definition at line 101 of file ThreeThresholdAlgorithm.cc.

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

Referenced by endCandidate().

                     {
  uint8_t max = MaxAdjacentBad;
  while(0 < max--) {
    if( bad( firstStrip()-1) ) { ADCs.insert( ADCs.begin(), 0);  }
    if( bad(  lastStrip + 1) ) { ADCs.push_back(0); lastStrip++; }
  }
}
void ThreeThresholdAlgorithm::applyGains ( ) [inline, private]

Definition at line 88 of file ThreeThresholdAlgorithm.cc.

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

Referenced by endCandidate().

             {
  uint16_t strip = firstStrip();
  for( std::vector<uint16_t>::iterator adc = ADCs.begin();  adc != ADCs.end();  adc++) {
    if(*adc > 255) throw InvalidChargeException( SiStripDigi(strip,*adc) );
    if(*adc > 253) continue; //saturated, do not scale
    uint16_t charge = static_cast<uint16_t>( *adc/gain(strip++) + 0.5 ); //adding 0.5 turns truncation into rounding
    *adc = ( charge > 1022 ? 255 : 
           ( charge >  253 ? 254 : charge ));
  }
}
bool ThreeThresholdAlgorithm::candidateAccepted ( ) const [inline, private]

Definition at line 80 of file ThreeThresholdAlgorithm.cc.

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

Referenced by endCandidate().

                          {
  return ( !candidateLacksSeed &&
           noiseSquared * ClusterThresholdSquared
           <=  std::pow( std::accumulate(ADCs.begin(),ADCs.end(),float(0)), 2));
}
bool ThreeThresholdAlgorithm::candidateEnded ( const uint16_t &  testStrip) const [inline, private]

Definition at line 42 of file ThreeThresholdAlgorithm.cc.

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

Referenced by clusterizeDetUnit_(), and stripByStripAdd().

                                                {
  uint16_t holes = testStrip - lastStrip - 1;
  return ( !ADCs.empty() &&                    // a candidate exists, and
           holes > MaxSequentialHoles &&       // too many holes if not all are bad strips, and
           ( holes > MaxSequentialBad ||       // (too many bad strips anyway, or 
             !allBadBetween( lastStrip, testStrip ))); // not all holes are bad strips)
}
void ThreeThresholdAlgorithm::clearCandidate ( ) [inline, private]

Definition at line 38 of file ThreeThresholdAlgorithm.h.

References ADCs, candidateLacksSeed, and noiseSquared.

Referenced by clusterizeDetUnit_(), endCandidate(), and stripByStripBegin().

{ candidateLacksSeed = true;  noiseSquared = 0;  ADCs.clear();}
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_().

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_().

template<class T >
void ThreeThresholdAlgorithm::clusterizeDetUnit_ ( const T ,
output_t::FastFiller  
) [private]

Referenced by clusterizeDetUnit().

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().

                                                                        {
  if( !isModuleUsable( digis.detId() )) return;
  setDetId( digis.detId() );
  
  typename digiDetSet::const_iterator  
    scan( digis.begin() ), 
    end(  digis.end() );

  if(RemoveApvShots){
    ApvCleaner.clean(digis,scan,end);
  }

  clearCandidate();
  while( scan != end ) {
    while( scan != end  && !candidateEnded( scan->strip() ) ) 
      addToCandidate(*scan++);
    endCandidate(output);
  }
}
template<class T >
void ThreeThresholdAlgorithm::endCandidate ( T out) [inline, private]
uint16_t ThreeThresholdAlgorithm::firstStrip ( ) const [inline, private]

Definition at line 32 of file ThreeThresholdAlgorithm.h.

References ADCs, and lastStrip.

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

{return lastStrip - ADCs.size() + 1;}
void ThreeThresholdAlgorithm::stripByStripAdd ( uint16_t  strip,
uint16_t  adc,
std::vector< SiStripCluster > &  out 
) [inline, virtual]
bool ThreeThresholdAlgorithm::stripByStripBegin ( uint32_t  id) [inline, virtual]
void ThreeThresholdAlgorithm::stripByStripEnd ( std::vector< SiStripCluster > &  out) [inline, virtual]

Implements StripClusterizerAlgorithm.

Definition at line 132 of file ThreeThresholdAlgorithm.cc.

References endCandidate().


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]

Definition at line 47 of file ThreeThresholdAlgorithm.h.

Referenced by clusterizeDetUnit_().

Definition at line 29 of file ThreeThresholdAlgorithm.h.

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

Definition at line 43 of file ThreeThresholdAlgorithm.h.

Referenced by addToCandidate().

Definition at line 43 of file ThreeThresholdAlgorithm.h.

Referenced by candidateAccepted().

Definition at line 44 of file ThreeThresholdAlgorithm.h.

Referenced by appendBadNeighbors().

Definition at line 44 of file ThreeThresholdAlgorithm.h.

Referenced by candidateEnded().

Definition at line 44 of file ThreeThresholdAlgorithm.h.

Referenced by candidateEnded().

Definition at line 28 of file ThreeThresholdAlgorithm.h.

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

Definition at line 45 of file ThreeThresholdAlgorithm.h.

Referenced by clusterizeDetUnit_().

Definition at line 43 of file ThreeThresholdAlgorithm.h.

Referenced by addToCandidate().