CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends
ThreeThresholdAlgorithm Class Referencefinal

#include <ThreeThresholdAlgorithm.h>

Inheritance diagram for ThreeThresholdAlgorithm:
StripClusterizerAlgorithm

Public Types

using Det = StripClusterizerAlgorithm::Det
 
using State = StripClusterizerAlgorithm::State
 
- Public Types inherited from StripClusterizerAlgorithm
typedef edmNew::DetSetVector< SiStripClusteroutput_t
 

Public Member Functions

void addFed (State &state, sistrip::FEDZSChannelUnpacker &unpacker, uint16_t ipair, std::vector< SiStripCluster > &out) const
 
void addFed (State &state, sistrip::FEDZSChannelUnpacker &unpacker, uint16_t ipair, output_t::TSFastFiller &out) const override
 
void clusterizeDetUnit (const edm::DetSet< SiStripDigi > &, output_t::TSFastFiller &) const override
 
void clusterizeDetUnit (const edmNew::DetSet< SiStripDigi > &, output_t::TSFastFiller &) const override
 
template<class digiDetSet >
void clusterizeDetUnit_ (const digiDetSet &digis, output_t::TSFastFiller &output) const
 
void stripByStripAdd (State &state, uint16_t strip, uint8_t adc, std::vector< SiStripCluster > &out) const override
 
void stripByStripAdd (State &state, uint16_t strip, uint8_t adc, output_t::TSFastFiller &out) const override
 
Det stripByStripBegin (uint32_t id) const override
 
void stripByStripEnd (State &state, std::vector< SiStripCluster > &out) const override
 
void stripByStripEnd (State &state, output_t::TSFastFiller &out) const override
 
- Public Member Functions inherited from StripClusterizerAlgorithm
virtual void addFed (Det const &det, sistrip::FEDZSChannelUnpacker &unpacker, uint16_t ipair, std::vector< SiStripCluster > &out) const
 
std::vector< uint32_t > const & allDetIds () const
 
SiStripDetCabling const * cabling () const
 
void clusterize (const edm::DetSetVector< SiStripDigi > &, output_t &) const
 
void clusterize (const edmNew::DetSetVector< SiStripDigi > &, output_t &) const
 
std::vector< const FedChannelConnection * > const & currentConnection (const Det &det) const
 
virtual void initialize (const edm::EventSetup &)
 
virtual ~StripClusterizerAlgorithm ()
 

Private Member Functions

void addToCandidate (State &state, const SiStripDigi &digi) const
 
void addToCandidate (State &state, uint16_t strip, uint8_t adc) const
 
void appendBadNeighbors (State &state) const
 
void applyGains (State &state) const
 
bool candidateAccepted (State const &state) const
 
bool candidateEnded (State const &state, const uint16_t &) const
 
void clearCandidate (State &state) const
 
template<class T >
void clusterizeDetUnit_ (const T &, output_t::TSFastFiller &) const
 
template<class T >
void endCandidate (State &state, T &) const
 
uint16_t firstStrip (State const &state) const
 
 ThreeThresholdAlgorithm (float, float, float, unsigned, unsigned, unsigned, std::string qualityLabel, bool removeApvShots, float minGoodCharge)
 

Private Attributes

float ChannelThreshold
 
float ClusterThresholdSquared
 
uint8_t MaxAdjacentBad
 
uint8_t MaxSequentialBad
 
uint8_t MaxSequentialHoles
 
float minGoodCharge
 
bool RemoveApvShots
 
float SeedThreshold
 

Friends

class StripClusterizerAlgorithmFactory
 

Additional Inherited Members

- Static Public Attributes inherited from StripClusterizerAlgorithm
static unsigned short invalidI = std::numeric_limits<unsigned short>::max()
 
- Protected Member Functions inherited from StripClusterizerAlgorithm
Det findDetId (const uint32_t) const
 
bool isModuleBad (const uint32_t &id) const
 
bool isModuleUsable (const uint32_t &id) const
 
 StripClusterizerAlgorithm ()
 
- Protected Attributes inherited from StripClusterizerAlgorithm
std::string qualityLabel
 

Detailed Description

Definition at line 6 of file ThreeThresholdAlgorithm.h.

Member Typedef Documentation

Definition at line 13 of file ThreeThresholdAlgorithm.h.

Definition at line 12 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  removeApvShots,
float  minGoodCharge 
)
private

Definition at line 11 of file ThreeThresholdAlgorithm.cc.

References clusterizeDetUnit_(), and StripClusterizerAlgorithm::qualityLabel.

Referenced by stripByStripEnd().

Member Function Documentation

void ThreeThresholdAlgorithm::addFed ( State state,
sistrip::FEDZSChannelUnpacker unpacker,
uint16_t  ipair,
std::vector< SiStripCluster > &  out 
) const
inline

Definition at line 23 of file ThreeThresholdAlgorithm.h.

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

23  {
24  while (unpacker.hasData()) {
25  stripByStripAdd(state,unpacker.sampleNumber()+ipair*256,unpacker.adc(),out);
26  unpacker++;
27  }
28  }
void stripByStripAdd(State &state, uint16_t strip, uint8_t adc, std::vector< SiStripCluster > &out) const override
void ThreeThresholdAlgorithm::addFed ( State state,
sistrip::FEDZSChannelUnpacker unpacker,
uint16_t  ipair,
output_t::TSFastFiller out 
) const
inlineoverridevirtual

Reimplemented from StripClusterizerAlgorithm.

Definition at line 31 of file ThreeThresholdAlgorithm.h.

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

31  {
32  while (unpacker.hasData()) {
33  stripByStripAdd(state, unpacker.sampleNumber()+ipair*256,unpacker.adc(),out);
34  unpacker++;
35  }
36  }
void stripByStripAdd(State &state, uint16_t strip, uint8_t adc, std::vector< SiStripCluster > &out) const override
void ThreeThresholdAlgorithm::addToCandidate ( State state,
const SiStripDigi digi 
) const
inlineprivate

Definition at line 62 of file ThreeThresholdAlgorithm.h.

References ecalMGPA::adc(), SiStripDigi::adc(), addToCandidate(), appendBadNeighbors(), applyGains(), digi_MixPreMix_cfi::strip, and SiStripDigi::strip().

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

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

Definition at line 65 of file ThreeThresholdAlgorithm.cc.

References StripClusterizerAlgorithm::State::ADCs, StripClusterizerAlgorithm::Det::bad(), StripClusterizerAlgorithm::State::candidateLacksSeed, ChannelThreshold, StripClusterizerAlgorithm::State::det(), endCandidate(), StripClusterizerAlgorithm::State::lastStrip, StripClusterizerAlgorithm::Det::noise(), digi_MixPreMix_cfi::Noise, StripClusterizerAlgorithm::State::noiseSquared, and SeedThreshold.

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

Definition at line 116 of file ThreeThresholdAlgorithm.cc.

References StripClusterizerAlgorithm::State::ADCs, StripClusterizerAlgorithm::Det::bad(), StripClusterizerAlgorithm::State::det(), firstStrip(), StripClusterizerAlgorithm::State::lastStrip, SiStripPI::max, and MaxAdjacentBad.

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

116  {
117  uint8_t max = MaxAdjacentBad;
118  while(0 < max--) {
119  if( state.det().bad( firstStrip(state)-1) ) { state.ADCs.insert( state.ADCs.begin(), 0); }
120  if( state.det().bad( state.lastStrip + 1) ) { state.ADCs.push_back(0); state.lastStrip++; }
121  }
122 }
uint16_t firstStrip(State const &state) const
void ThreeThresholdAlgorithm::applyGains ( State state) const
inlineprivate

Definition at line 101 of file ThreeThresholdAlgorithm.cc.

References ecalMGPA::adc(), StripClusterizerAlgorithm::State::ADCs, appendBadNeighbors(), ALCARECOTkAlJpsiMuMu_cff::charge, StripClusterizerAlgorithm::State::det(), firstStrip(), StripClusterizerAlgorithm::Det::gain(), createfilelist::int, and digi_MixPreMix_cfi::strip.

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

101  {
102  uint16_t strip = firstStrip(state);
103  for( auto & adc : state.ADCs) {
104 #ifdef EDM_ML_DEBUG
105  // if(adc > 255) throw InvalidChargeException( SiStripDigi(strip,adc) );
106 #endif
107  // if(adc > 253) continue; //saturated, do not scale
108  auto charge = int( float(adc)/state.det().gain(strip++) + 0.5f ); //adding 0.5 turns truncation into rounding
109  if(adc < 254) adc = ( charge > 1022 ? 255 :
110  ( charge > 253 ? 254 : charge ));
111  }
112 }
int adc(sample_type sample)
get the ADC sample (12 bits)
uint16_t firstStrip(State const &state) const
bool ThreeThresholdAlgorithm::candidateAccepted ( State const &  state) const
inlineprivate

Definition at line 93 of file ThreeThresholdAlgorithm.cc.

References StripClusterizerAlgorithm::State::ADCs, applyGains(), StripClusterizerAlgorithm::State::candidateLacksSeed, ClusterThresholdSquared, createfilelist::int, StripClusterizerAlgorithm::State::noiseSquared, and funct::pow().

Referenced by endCandidate(), and firstStrip().

93  {
94  return ( !state.candidateLacksSeed &&
95  state.noiseSquared * ClusterThresholdSquared
96  <= std::pow( float(std::accumulate(state.ADCs.begin(),state.ADCs.end(), int(0))), 2.f));
97 }
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
bool ThreeThresholdAlgorithm::candidateEnded ( State const &  state,
const uint16_t &  testStrip 
) const
inlineprivate

Definition at line 52 of file ThreeThresholdAlgorithm.cc.

References StripClusterizerAlgorithm::State::ADCs, addToCandidate(), StripClusterizerAlgorithm::Det::allBadBetween(), StripClusterizerAlgorithm::State::det(), StripClusterizerAlgorithm::State::lastStrip, MaxSequentialBad, and MaxSequentialHoles.

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

52  {
53  uint16_t holes = testStrip - state.lastStrip - 1;
54  return ( ( (!state.ADCs.empty()) & // a candidate exists, and
55  (holes > MaxSequentialHoles ) // too many holes if not all are bad strips, and
56  ) &&
57  ( holes > MaxSequentialBad || // (too many bad strips anyway, or
58  !state.det().allBadBetween( state.lastStrip, testStrip ) // not all holes are bad strips)
59  )
60  );
61 }
void ThreeThresholdAlgorithm::clearCandidate ( State state) const
inlineprivate

Definition at line 61 of file ThreeThresholdAlgorithm.h.

References StripClusterizerAlgorithm::State::ADCs, StripClusterizerAlgorithm::State::candidateLacksSeed, and StripClusterizerAlgorithm::State::noiseSquared.

Referenced by endCandidate().

61 { state.candidateLacksSeed = true; state.noiseSquared = 0; state.ADCs.clear();}
void ThreeThresholdAlgorithm::clusterizeDetUnit ( const edm::DetSet< SiStripDigi > &  digis,
output_t::TSFastFiller output 
) const
overridevirtual

Implements StripClusterizerAlgorithm.

Definition at line 125 of file ThreeThresholdAlgorithm.cc.

References clusterizeDetUnit_().

125 {clusterizeDetUnit_(digis,output);}
void clusterizeDetUnit_(const T &, output_t::TSFastFiller &) const
void ThreeThresholdAlgorithm::clusterizeDetUnit ( const edmNew::DetSet< SiStripDigi > &  digis,
output_t::TSFastFiller output 
) const
overridevirtual

Implements StripClusterizerAlgorithm.

Definition at line 126 of file ThreeThresholdAlgorithm.cc.

References clusterizeDetUnit_(), and stripByStripBegin().

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

Definition at line 21 of file ThreeThresholdAlgorithm.cc.

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

21  {
22  if(isModuleBad(digis.detId())) return;
23 
24  auto const & det = findDetId( digis.detId());
25  if (!det.valid()) return;
26 
27 #ifdef EDM_ML_DEBUG
28  if(!isModuleUsable(digis.detId() ))
29  edm::LogWarning("ThreeThresholdAlgorithm") << " id " << digis.detId() << " not usable???" << std::endl;
30 #endif
31 
32 
33  typename digiDetSet::const_iterator
34  scan( digis.begin() ),
35  end( digis.end() );
36 
37  SiStripApvShotCleaner ApvCleaner;
38  if(RemoveApvShots){
39  ApvCleaner.clean(digis,scan,end);
40  }
41 
42  State state(det);
43  while( scan != end ) {
44  while( scan != end && !candidateEnded(state, scan->strip() ) )
45  addToCandidate( state, *scan++);
46  endCandidate(state, output);
47  }
48 }
bool isModuleBad(const uint32_t &id) const
void endCandidate(State &state, T &) const
#define end
Definition: vmac.h:37
bool candidateEnded(State const &state, const uint16_t &) const
void addToCandidate(State &state, const SiStripDigi &digi) const
bool isModuleUsable(const uint32_t &id) const
Det findDetId(const uint32_t) const
State
Definition: hltDiff.cc:288
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::TSFastFiller  
) const
private
template<class T >
void ThreeThresholdAlgorithm::endCandidate ( State state,
T out 
) const
inlineprivate

Definition at line 81 of file ThreeThresholdAlgorithm.cc.

References StripClusterizerAlgorithm::State::ADCs, appendBadNeighbors(), applyGains(), candidateAccepted(), siStripClusterTools::chargePerCM(), clearCandidate(), StripClusterizerAlgorithm::State::det(), StripClusterizerAlgorithm::Det::detId, firstStrip(), and minGoodCharge.

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

81  {
82  if(candidateAccepted(state)) {
83  applyGains(state);
84  appendBadNeighbors(state);
85  if(siStripClusterTools::chargePerCM(state.det().detId, state.ADCs.begin(), state.ADCs.end()) > minGoodCharge)
86  out.push_back(SiStripCluster(firstStrip(state), state.ADCs.begin(), state.ADCs.end()));
87  }
88  clearCandidate(state);
89 }
float chargePerCM(DetId detid, Iter a, Iter b)
bool candidateAccepted(State const &state) const
void clearCandidate(State &state) const
void appendBadNeighbors(State &state) const
void applyGains(State &state) const
uint16_t firstStrip(State const &state) const
uint16_t ThreeThresholdAlgorithm::firstStrip ( State const &  state) const
inlineprivate
void ThreeThresholdAlgorithm::stripByStripAdd ( State state,
uint16_t  strip,
uint8_t  adc,
std::vector< SiStripCluster > &  out 
) const
overridevirtual

Reimplemented from StripClusterizerAlgorithm.

Definition at line 136 of file ThreeThresholdAlgorithm.cc.

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

Referenced by addFed(), and stripByStripBegin().

136  {
137  if(candidateEnded(state,strip)) endCandidate(state,out);
139 }
int adc(sample_type sample)
get the ADC sample (12 bits)
void endCandidate(State &state, T &) const
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
Definition: SiStripDigi.h:12
bool candidateEnded(State const &state, const uint16_t &) const
void addToCandidate(State &state, const SiStripDigi &digi) const
void ThreeThresholdAlgorithm::stripByStripAdd ( State state,
uint16_t  strip,
uint8_t  adc,
output_t::TSFastFiller out 
) const
inlineoverridevirtual

Reimplemented from StripClusterizerAlgorithm.

Definition at line 38 of file ThreeThresholdAlgorithm.h.

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

38  {
39  if(candidateEnded(state, strip)) endCandidate(state, out);
40  addToCandidate(state, strip,adc);
41  }
int adc(sample_type sample)
get the ADC sample (12 bits)
void endCandidate(State &state, T &) const
bool candidateEnded(State const &state, const uint16_t &) const
void addToCandidate(State &state, const SiStripDigi &digi) const
StripClusterizerAlgorithm::Det ThreeThresholdAlgorithm::stripByStripBegin ( uint32_t  id) const
overridevirtual

Implements StripClusterizerAlgorithm.

Definition at line 130 of file ThreeThresholdAlgorithm.cc.

References StripClusterizerAlgorithm::findDetId(), and stripByStripAdd().

Referenced by clusterizeDetUnit().

130  {
131  return findDetId( id );
132 }
Det findDetId(const uint32_t) const
void ThreeThresholdAlgorithm::stripByStripEnd ( State state,
std::vector< SiStripCluster > &  out 
) const
overridevirtual

Reimplemented from StripClusterizerAlgorithm.

Definition at line 143 of file ThreeThresholdAlgorithm.cc.

References endCandidate().

Referenced by stripByStripAdd().

143  {
144  endCandidate(state, out);
145 }
void endCandidate(State &state, T &) const
void ThreeThresholdAlgorithm::stripByStripEnd ( State state,
output_t::TSFastFiller out 
) const
inlineoverridevirtual

Friends And Related Function Documentation

friend class StripClusterizerAlgorithmFactory
friend

Definition at line 8 of file ThreeThresholdAlgorithm.h.

Member Data Documentation

float ThreeThresholdAlgorithm::ChannelThreshold
private

Definition at line 67 of file ThreeThresholdAlgorithm.h.

Referenced by addToCandidate().

float ThreeThresholdAlgorithm::ClusterThresholdSquared
private

Definition at line 67 of file ThreeThresholdAlgorithm.h.

Referenced by candidateAccepted().

uint8_t ThreeThresholdAlgorithm::MaxAdjacentBad
private

Definition at line 68 of file ThreeThresholdAlgorithm.h.

Referenced by appendBadNeighbors().

uint8_t ThreeThresholdAlgorithm::MaxSequentialBad
private

Definition at line 68 of file ThreeThresholdAlgorithm.h.

Referenced by candidateEnded().

uint8_t ThreeThresholdAlgorithm::MaxSequentialHoles
private

Definition at line 68 of file ThreeThresholdAlgorithm.h.

Referenced by candidateEnded().

float ThreeThresholdAlgorithm::minGoodCharge
private

Definition at line 70 of file ThreeThresholdAlgorithm.h.

Referenced by endCandidate(), and stripByStripEnd().

bool ThreeThresholdAlgorithm::RemoveApvShots
private

Definition at line 69 of file ThreeThresholdAlgorithm.h.

Referenced by clusterizeDetUnit_().

float ThreeThresholdAlgorithm::SeedThreshold
private

Definition at line 67 of file ThreeThresholdAlgorithm.h.

Referenced by addToCandidate().