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, float minGoodCharge)
 

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 minGoodCharge
 
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,
float  minGoodCharge 
)
private

Definition at line 11 of file ThreeThresholdAlgorithm.cc.

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

13  : ChannelThreshold( chan ), SeedThreshold( seed ), ClusterThresholdSquared( cluster*cluster ),
16  qualityLabel = (qL);
17  ADCs.reserve(128);
18 
19  // this has to be initialized before the first call to candidateEnded()
20  // and this is probably a bad place to initialize it
21  lastStrip = 0;
22 }
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 68 of file ThreeThresholdAlgorithm.cc.

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

68  {
69  float Noise = noise( strip );
70  if( adc < static_cast<uint8_t>( Noise * ChannelThreshold) || bad(strip) )
71  return;
72 
73  if(candidateLacksSeed) candidateLacksSeed = adc < static_cast<uint8_t>( Noise * SeedThreshold);
74  if(ADCs.empty()) lastStrip = strip - 1; // begin candidate
75  while( ++lastStrip < strip ) ADCs.push_back(0); // pad holes
76 
77  ADCs.push_back( adc );
78  noiseSquared += Noise*Noise;
79 }
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 119 of file ThreeThresholdAlgorithm.cc.

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

Referenced by endCandidate().

119  {
120  uint8_t max = MaxAdjacentBad;
121  while(0 < max--) {
122  if( bad( firstStrip()-1) ) { ADCs.insert( ADCs.begin(), 0); }
123  if( bad( lastStrip + 1) ) { ADCs.push_back(0); lastStrip++; }
124  }
125 }
bool bad(const uint16_t &strip) const
std::vector< uint8_t > ADCs
void ThreeThresholdAlgorithm::applyGains ( )
inlineprivate

Definition at line 104 of file ThreeThresholdAlgorithm.cc.

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

Referenced by endCandidate().

104  {
105  uint16_t strip = firstStrip();
106  for( auto & adc : ADCs) {
107 #ifdef EDM_ML_DEBUG
108  if(adc > 255) throw InvalidChargeException( SiStripDigi(strip,adc) );
109 #endif
110  // if(adc > 253) continue; //saturated, do not scale
111  auto charge = int( float(adc)/gain(strip++) + 0.5f ); //adding 0.5 turns truncation into rounding
112  if(adc < 254) adc = ( charge > 1022 ? 255 :
113  ( charge > 253 ? 254 : charge ));
114  }
115 }
int adc(sample_type sample)
get the ADC sample (12 bits)
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 96 of file ThreeThresholdAlgorithm.cc.

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

Referenced by endCandidate().

96  {
97  return ( !candidateLacksSeed &&
99  <= std::pow( float(std::accumulate(ADCs.begin(),ADCs.end(), int(0))), 2.f));
100 }
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 55 of file ThreeThresholdAlgorithm.cc.

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

Referenced by clusterizeDetUnit_(), and stripByStripAdd().

55  {
56  uint16_t holes = testStrip - lastStrip - 1;
57  return ( ( (!ADCs.empty()) & // a candidate exists, and
58  (holes > MaxSequentialHoles ) // too many holes if not all are bad strips, and
59  ) &&
60  ( holes > MaxSequentialBad || // (too many bad strips anyway, or
61  !allBadBetween( lastStrip, testStrip ) // not all holes are bad strips)
62  )
63  );
64 }
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 128 of file ThreeThresholdAlgorithm.cc.

References clusterizeDetUnit_().

128 {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 129 of file ThreeThresholdAlgorithm.cc.

References clusterizeDetUnit_().

129 {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 27 of file ThreeThresholdAlgorithm.cc.

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

27  {
28  if(isModuleBad(digis.detId())) return;
29  if (!setDetId( digis.detId() )) return;
30 
31 #ifdef EDM_ML_DEBUG
32  if(!isModuleUsable(digis.detId() ))
33  LogWarning("ThreeThresholdAlgorithm") << " id " << digis.detId() << " not usable???" << std::endl;
34 #endif
35 
36 
37  typename digiDetSet::const_iterator
38  scan( digis.begin() ),
39  end( digis.end() );
40 
41  if(RemoveApvShots){
42  ApvCleaner.clean(digis,scan,end);
43  }
44 
46  while( scan != end ) {
47  while( scan != end && !candidateEnded( scan->strip() ) )
48  addToCandidate(*scan++);
50  }
51 }
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

Definition at line 84 of file ThreeThresholdAlgorithm.cc.

References ADCs, appendBadNeighbors(), applyGains(), candidateAccepted(), siStripClusterTools::chargePerCM(), clearCandidate(), StripClusterizerAlgorithm::currentId(), firstStrip(), and minGoodCharge.

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

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 144 of file ThreeThresholdAlgorithm.cc.

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

Referenced by addFed().

144  {
145  if(candidateEnded(strip)) endCandidate(out);
147 }
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 133 of file ThreeThresholdAlgorithm.cc.

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

133  {
134  if (!setDetId( id )) return false;
135 #ifdef EDM_ML_DEBUG
136  assert(isModuleUsable( id ));
137 #endif
138  clearCandidate();
139  return true;
140 }
assert(m_qm.get())
bool isModuleUsable(const uint32_t &id) const
void ThreeThresholdAlgorithm::stripByStripEnd ( std::vector< SiStripCluster > &  out)
inlinevirtual

Reimplemented from StripClusterizerAlgorithm.

Definition at line 151 of file ThreeThresholdAlgorithm.cc.

References endCandidate().

151  {
152  endCandidate(out);
153 }
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 74 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::minGoodCharge
private

Definition at line 72 of file ThreeThresholdAlgorithm.h.

Referenced by endCandidate().

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