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 Referencefinal

#include <ThreeThresholdAlgorithm.h>

Inheritance diagram for ThreeThresholdAlgorithm:
StripClusterizerAlgorithm

Public Member Functions

void addFed (sistrip::FEDZSChannelUnpacker &unpacker, uint16_t ipair, std::vector< SiStripCluster > &out)
 
void addFed (sistrip::FEDZSChannelUnpacker &unpacker, uint16_t ipair, output_t::FastFiller &out) override
 
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, uint8_t adc, std::vector< SiStripCluster > &out)
 
void stripByStripAdd (uint16_t strip, uint8_t adc, output_t::FastFiller &out) override
 
bool stripByStripBegin (uint32_t id)
 
void stripByStripEnd (std::vector< SiStripCluster > &out)
 
void stripByStripEnd (output_t::FastFiller &out) override
 
- Public Member Functions inherited from StripClusterizerAlgorithm
std::vector< uint32_t > const & allDetIds () const
 
SiStripDetCabling const * cabling () const
 
void clusterize (const edm::DetSetVector< SiStripDigi > &, output_t &)
 
void clusterize (const edmNew::DetSetVector< SiStripDigi > &, output_t &)
 
std::vector< const
FedChannelConnection * > const & 
currentConnection () const
 
virtual void initialize (const edm::EventSetup &)
 
virtual ~StripClusterizerAlgorithm ()
 

Private Member Functions

void addToCandidate (const SiStripDigi &digi)
 
void addToCandidate (uint16_t strip, uint8_t adc)
 
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< uint8_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 isModuleBad (const uint32_t &id) const
 
bool isModuleUsable (const uint32_t &id) const
 
float noise (const uint16_t &strip) const
 
bool 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 9 of file ThreeThresholdAlgorithm.cc.

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

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

Member Function Documentation

void ThreeThresholdAlgorithm::addFed ( sistrip::FEDZSChannelUnpacker unpacker,
uint16_t  ipair,
std::vector< SiStripCluster > &  out 
)
inlinevirtual

Reimplemented from StripClusterizerAlgorithm.

Definition at line 20 of file ThreeThresholdAlgorithm.h.

References sistrip::FEDZSChannelUnpacker::adc(), sistrip::FEDZSChannelUnpacker::hasData(), dbtoconf::out, sistrip::FEDZSChannelUnpacker::sampleNumber(), and stripByStripAdd().

20  {
21  while (unpacker.hasData()) {
22  stripByStripAdd(unpacker.sampleNumber()+ipair*256,unpacker.adc(),out);
23  unpacker++;
24  }
25  }
void stripByStripAdd(uint16_t strip, uint8_t adc, std::vector< SiStripCluster > &out)
tuple out
Definition: dbtoconf.py:99
void ThreeThresholdAlgorithm::addFed ( sistrip::FEDZSChannelUnpacker unpacker,
uint16_t  ipair,
output_t::FastFiller out 
)
inlineoverridevirtual

Reimplemented from StripClusterizerAlgorithm.

Definition at line 28 of file ThreeThresholdAlgorithm.h.

References sistrip::FEDZSChannelUnpacker::adc(), sistrip::FEDZSChannelUnpacker::hasData(), dbtoconf::out, sistrip::FEDZSChannelUnpacker::sampleNumber(), and stripByStripAdd().

28  {
29  while (unpacker.hasData()) {
30  stripByStripAdd(unpacker.sampleNumber()+ipair*256,unpacker.adc(),out);
31  unpacker++;
32  }
33  }
void stripByStripAdd(uint16_t strip, uint8_t adc, std::vector< SiStripCluster > &out)
tuple out
Definition: dbtoconf.py:99
void ThreeThresholdAlgorithm::addToCandidate ( const SiStripDigi digi)
inlineprivate

Definition at line 64 of file ThreeThresholdAlgorithm.h.

References SiStripDigi::adc(), addToCandidate(), and SiStripDigi::strip().

Referenced by addToCandidate(), clusterizeDetUnit_(), and stripByStripAdd().

64 { addToCandidate(digi.strip(),digi.adc());}
void addToCandidate(const SiStripDigi &digi)
const uint16_t & strip() const
Definition: SiStripDigi.h:40
const uint16_t & adc() const
Definition: SiStripDigi.h:41
void ThreeThresholdAlgorithm::addToCandidate ( uint16_t  strip,
uint8_t  adc 
)
inlineprivate

Definition at line 62 of file ThreeThresholdAlgorithm.cc.

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

62  {
63  float Noise = noise( strip );
64  if( adc < static_cast<uint8_t>( Noise * ChannelThreshold) || bad(strip) )
65  return;
66 
67  if(candidateLacksSeed) candidateLacksSeed = adc < static_cast<uint8_t>( Noise * SeedThreshold);
68  if(ADCs.empty()) lastStrip = strip - 1; // begin candidate
69  while( ++lastStrip < strip ) ADCs.push_back(0); // pad holes
70 
71  ADCs.push_back( adc );
72  noiseSquared += Noise*Noise;
73 }
int adc(sample_type sample)
get the ADC sample (12 bits)
bool bad(const uint16_t &strip) const
float noise(const uint16_t &strip) const
std::vector< uint8_t > ADCs
void ThreeThresholdAlgorithm::appendBadNeighbors ( )
inlineprivate

Definition at line 112 of file ThreeThresholdAlgorithm.cc.

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

Referenced by endCandidate().

112  {
113  uint8_t max = MaxAdjacentBad;
114  while(0 < max--) {
115  if( bad( firstStrip()-1) ) { ADCs.insert( ADCs.begin(), 0); }
116  if( bad( lastStrip + 1) ) { ADCs.push_back(0); lastStrip++; }
117  }
118 }
bool bad(const uint16_t &strip) const
std::vector< uint8_t > ADCs
void ThreeThresholdAlgorithm::applyGains ( )
inlineprivate

Definition at line 97 of file ThreeThresholdAlgorithm.cc.

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

Referenced by endCandidate().

97  {
98  uint16_t strip = firstStrip();
99  for( auto & adc : ADCs) {
100 #ifdef EDM_ML_DEBUG
101  if(adc > 255) throw InvalidChargeException( SiStripDigi(strip,adc) );
102 #endif
103  // if(adc > 253) continue; //saturated, do not scale
104  auto charge = int( float(adc)/gain(strip++) + 0.5f ); //adding 0.5 turns truncation into rounding
105  if(adc < 254) adc = ( charge > 1022 ? 255 :
106  ( charge > 253 ? 254 : charge ));
107  }
108 }
int adc(sample_type sample)
get the ADC sample (12 bits)
double charge(const std::vector< uint8_t > &Ampls)
double f[11][100]
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
Definition: SiStripDigi.h:12
std::vector< uint8_t > ADCs
float gain(const uint16_t &strip) const
bool ThreeThresholdAlgorithm::candidateAccepted ( ) const
inlineprivate

Definition at line 89 of file ThreeThresholdAlgorithm.cc.

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

Referenced by endCandidate().

89  {
90  return ( !candidateLacksSeed &&
92  <= std::pow( float(std::accumulate(ADCs.begin(),ADCs.end(), int(0))), 2.f));
93 }
std::vector< uint8_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 49 of file ThreeThresholdAlgorithm.cc.

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

Referenced by clusterizeDetUnit_(), and stripByStripAdd().

49  {
50  uint16_t holes = testStrip - lastStrip - 1;
51  return ( ( (!ADCs.empty()) & // a candidate exists, and
52  (holes > MaxSequentialHoles ) // too many holes if not all are bad strips, and
53  ) &&
54  ( holes > MaxSequentialBad || // (too many bad strips anyway, or
55  !allBadBetween( lastStrip, testStrip ) // not all holes are bad strips)
56  )
57  );
58 }
std::vector< uint8_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 121 of file ThreeThresholdAlgorithm.cc.

References clusterizeDetUnit_().

121 {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 122 of file ThreeThresholdAlgorithm.cc.

References clusterizeDetUnit_().

122 {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 21 of file ThreeThresholdAlgorithm.cc.

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

21  {
22  if(isModuleBad(digis.detId())) return;
23  if (!setDetId( digis.detId() )) return;
24 
25 #ifdef EDM_ML_DEBUG
26  if(!isModuleUsable(digis.detId() ))
27  LogWarning("ThreeThresholdAlgorithm") << " id " << digis.detId() << " not usable???" << std::endl;
28 #endif
29 
30 
31  typename digiDetSet::const_iterator
32  scan( digis.begin() ),
33  end( digis.end() );
34 
35  if(RemoveApvShots){
36  ApvCleaner.clean(digis,scan,end);
37  }
38 
40  while( scan != end ) {
41  while( scan != end && !candidateEnded( scan->strip() ) )
42  addToCandidate(*scan++);
44  }
45 }
bool isModuleBad(const uint32_t &id) const
void addToCandidate(const SiStripDigi &digi)
bool candidateEnded(const uint16_t &) const
SiStripApvShotCleaner ApvCleaner
#define end
Definition: vmac.h:37
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 57 of file ThreeThresholdAlgorithm.h.

References ADCs, and lastStrip.

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

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

Reimplemented from StripClusterizerAlgorithm.

Definition at line 137 of file ThreeThresholdAlgorithm.cc.

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

Referenced by addFed().

137  {
138  if(candidateEnded(strip)) endCandidate(out);
140 }
int adc(sample_type sample)
get the ADC sample (12 bits)
void addToCandidate(const SiStripDigi &digi)
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
void ThreeThresholdAlgorithm::stripByStripAdd ( uint16_t  strip,
uint8_t  adc,
output_t::FastFiller out 
)
inlineoverridevirtual

Reimplemented from StripClusterizerAlgorithm.

Definition at line 35 of file ThreeThresholdAlgorithm.h.

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

35  {
36  if(candidateEnded(strip)) endCandidate(out);
37  addToCandidate(strip,adc);
38  }
int adc(sample_type sample)
get the ADC sample (12 bits)
void addToCandidate(const SiStripDigi &digi)
bool candidateEnded(const uint16_t &) const
tuple out
Definition: dbtoconf.py:99
bool ThreeThresholdAlgorithm::stripByStripBegin ( uint32_t  id)
inlinevirtual

Implements StripClusterizerAlgorithm.

Definition at line 126 of file ThreeThresholdAlgorithm.cc.

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

126  {
127  if (!setDetId( id )) return false;
128 #ifdef EDM_ML_DEBUG
129  assert(isModuleUsable( id ));
130 #endif
131  clearCandidate();
132  return true;
133 }
bool isModuleUsable(const uint32_t &id) const
void ThreeThresholdAlgorithm::stripByStripEnd ( std::vector< SiStripCluster > &  out)
inlinevirtual

Reimplemented from StripClusterizerAlgorithm.

Definition at line 144 of file ThreeThresholdAlgorithm.cc.

References endCandidate().

144  {
145  endCandidate(out);
146 }
tuple out
Definition: dbtoconf.py:99
void ThreeThresholdAlgorithm::stripByStripEnd ( output_t::FastFiller out)
inlineoverridevirtual

Reimplemented from StripClusterizerAlgorithm.

Definition at line 40 of file ThreeThresholdAlgorithm.h.

References endCandidate().

Friends And Related Function Documentation

friend class StripClusterizerAlgorithmFactory
friend

Definition at line 8 of file ThreeThresholdAlgorithm.h.

Member Data Documentation

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

Definition at line 73 of file ThreeThresholdAlgorithm.h.

Referenced by clusterizeDetUnit_().

bool ThreeThresholdAlgorithm::candidateLacksSeed
private

Definition at line 54 of file ThreeThresholdAlgorithm.h.

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

float ThreeThresholdAlgorithm::ChannelThreshold
private

Definition at line 69 of file ThreeThresholdAlgorithm.h.

Referenced by addToCandidate().

float ThreeThresholdAlgorithm::ClusterThresholdSquared
private

Definition at line 69 of file ThreeThresholdAlgorithm.h.

Referenced by candidateAccepted().

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

Definition at line 70 of file ThreeThresholdAlgorithm.h.

Referenced by appendBadNeighbors().

uint8_t ThreeThresholdAlgorithm::MaxSequentialBad
private

Definition at line 70 of file ThreeThresholdAlgorithm.h.

Referenced by candidateEnded().

uint8_t ThreeThresholdAlgorithm::MaxSequentialHoles
private

Definition at line 70 of file ThreeThresholdAlgorithm.h.

Referenced by candidateEnded().

float ThreeThresholdAlgorithm::noiseSquared
private

Definition at line 53 of file ThreeThresholdAlgorithm.h.

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

bool ThreeThresholdAlgorithm::RemoveApvShots
private

Definition at line 71 of file ThreeThresholdAlgorithm.h.

Referenced by clusterizeDetUnit_().

float ThreeThresholdAlgorithm::SeedThreshold
private

Definition at line 69 of file ThreeThresholdAlgorithm.h.

Referenced by addToCandidate().