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
using Det = SiStripClusterizerConditions::Det
 
typedef edmNew::DetSetVector< SiStripClusteroutput_t
 

Public Member Functions

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
 
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
void clusterize (const edm::DetSetVector< SiStripDigi > &, output_t &) const
 
void clusterize (const edmNew::DetSetVector< SiStripDigi > &, output_t &) const
 
const SiStripClusterizerConditionsconditions () const
 
void initialize (const edm::EventSetup &es)
 
Det const & stripByStripBegin (uint32_t id) const
 
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 (const edm::ESGetToken< SiStripClusterizerConditions, SiStripClusterizerConditionsRcd > &, float, float, float, unsigned, unsigned, unsigned, unsigned, bool removeApvShots, float minGoodCharge)
 

Private Attributes

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

Friends

class StripClusterizerAlgorithmFactory
 

Additional Inherited Members

- Protected Member Functions inherited from StripClusterizerAlgorithm
 StripClusterizerAlgorithm (const edm::ESGetToken< SiStripClusterizerConditions, SiStripClusterizerConditionsRcd > &conditionsToken)
 

Detailed Description

Definition at line 6 of file ThreeThresholdAlgorithm.h.

Member Typedef Documentation

◆ Det

Definition at line 11 of file ThreeThresholdAlgorithm.h.

◆ State

Definition at line 10 of file ThreeThresholdAlgorithm.h.

Constructor & Destructor Documentation

◆ ThreeThresholdAlgorithm()

ThreeThresholdAlgorithm::ThreeThresholdAlgorithm ( const edm::ESGetToken< SiStripClusterizerConditions, SiStripClusterizerConditionsRcd > &  conditionsToken,
float  chan,
float  seed,
float  cluster,
unsigned  holes,
unsigned  bad,
unsigned  adj,
unsigned  maxClusterSize,
bool  removeApvShots,
float  minGoodCharge 
)
private

Definition at line 10 of file ThreeThresholdAlgorithm.cc.

21  : StripClusterizerAlgorithm(conditionsToken),
24  ClusterThresholdSquared(cluster * cluster),
25  MaxSequentialHoles(holes),
26  MaxSequentialBad(bad),
27  MaxAdjacentBad(adj),
29  RemoveApvShots(removeApvShots),
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
StripClusterizerAlgorithm(const edm::ESGetToken< SiStripClusterizerConditions, SiStripClusterizerConditionsRcd > &conditionsToken)

Member Function Documentation

◆ addToCandidate() [1/2]

void ThreeThresholdAlgorithm::addToCandidate ( State state,
const SiStripDigi digi 
) const
inlineprivate

Definition at line 55 of file ThreeThresholdAlgorithm.h.

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

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

55 { addToCandidate(state, digi.strip(), digi.adc()); }
void addToCandidate(State &state, const SiStripDigi &digi) const
const uint16_t & strip() const
Definition: SiStripDigi.h:33
const uint16_t & adc() const
Definition: SiStripDigi.h:34

◆ addToCandidate() [2/2]

void ThreeThresholdAlgorithm::addToCandidate ( State state,
uint16_t  strip,
uint8_t  adc 
) const
inlineprivate

Definition at line 73 of file ThreeThresholdAlgorithm.cc.

References gpuClustering::adc, ChannelThreshold, MaxClusterSize, SiStripCondTypes::Noise, SeedThreshold, nano_mu_digi_cff::strip, and gpuVertexFinder::while().

73  {
74  float Noise = state.det().noise(strip);
75  if (adc < static_cast<uint8_t>(Noise * ChannelThreshold) || state.det().bad(strip))
76  return;
77 
78  if (state.candidateLacksSeed)
79  state.candidateLacksSeed = adc < static_cast<uint8_t>(Noise * SeedThreshold);
80  if (state.ADCs.empty())
81  state.lastStrip = strip - 1; // begin candidate
82  while (++state.lastStrip < strip)
83  state.ADCs.push_back(0); // pad holes
84 
85  if (state.ADCs.size() <= MaxClusterSize)
86  state.ADCs.push_back(adc);
87  state.noiseSquared += Noise * Noise;
88 }
while(__syncthreads_or(more))
uint16_t *__restrict__ uint16_t const *__restrict__ adc

◆ appendBadNeighbors()

void ThreeThresholdAlgorithm::appendBadNeighbors ( State state) const
inlineprivate

Definition at line 122 of file ThreeThresholdAlgorithm.cc.

References firstStrip(), SiStripPI::max, and MaxAdjacentBad.

Referenced by endCandidate().

122  {
123  uint8_t max = MaxAdjacentBad;
124  while (0 < max--) {
125  if (state.det().bad(firstStrip(state) - 1)) {
126  state.ADCs.insert(state.ADCs.begin(), 0);
127  }
128  if (state.det().bad(state.lastStrip + 1)) {
129  state.ADCs.push_back(0);
130  state.lastStrip++;
131  }
132  }
133 }
uint16_t firstStrip(State const &state) const

◆ applyGains()

void ThreeThresholdAlgorithm::applyGains ( State state) const
inlineprivate

Definition at line 109 of file ThreeThresholdAlgorithm.cc.

References gpuClustering::adc, ALCARECOTkAlJpsiMuMu_cff::charge, firstStrip(), createfilelist::int, and nano_mu_digi_cff::strip.

Referenced by endCandidate().

109  {
110  uint16_t strip = firstStrip(state);
111  for (auto& adc : state.ADCs) {
112 #ifdef EDM_ML_DEBUG
113  // if(adc > 255) throw InvalidChargeException( SiStripDigi(strip,adc) );
114 #endif
115  // if(adc > 253) continue; //saturated, do not scale
116  auto charge = int(float(adc) * state.det().weight(strip++) + 0.5f); //adding 0.5 turns truncation into rounding
117  if (adc < 254)
118  adc = (charge > 1022 ? 255 : (charge > 253 ? 254 : charge));
119  }
120 }
uint16_t firstStrip(State const &state) const
uint16_t *__restrict__ uint16_t const *__restrict__ adc

◆ candidateAccepted()

bool ThreeThresholdAlgorithm::candidateAccepted ( State const &  state) const
inlineprivate

Definition at line 103 of file ThreeThresholdAlgorithm.cc.

References ClusterThresholdSquared, createfilelist::int, MaxClusterSize, and conifer::pow().

Referenced by endCandidate().

103  {
104  return (!state.candidateLacksSeed && state.ADCs.size() <= MaxClusterSize &&
105  state.noiseSquared * ClusterThresholdSquared <=
106  std::pow(float(std::accumulate(state.ADCs.begin(), state.ADCs.end(), int(0))), 2.f));
107 }
constexpr int pow(int x)
Definition: conifer.h:24

◆ candidateEnded()

bool ThreeThresholdAlgorithm::candidateEnded ( State const &  state,
const uint16_t &  testStrip 
) const
inlineprivate

Definition at line 63 of file ThreeThresholdAlgorithm.cc.

References MaxSequentialBad, and MaxSequentialHoles.

Referenced by clusterizeDetUnit_(), and stripByStripAdd().

63  {
64  uint16_t holes = testStrip - state.lastStrip - 1;
65  return (((!state.ADCs.empty()) & // a candidate exists, and
66  (holes > MaxSequentialHoles) // too many holes if not all are bad strips, and
67  ) &&
68  (holes > MaxSequentialBad || // (too many bad strips anyway, or
69  !state.det().allBadBetween(state.lastStrip, testStrip) // not all holes are bad strips)
70  ));
71 }

◆ clearCandidate()

void ThreeThresholdAlgorithm::clearCandidate ( State state) const
inlineprivate

Definition at line 50 of file ThreeThresholdAlgorithm.h.

Referenced by endCandidate().

50  {
51  state.candidateLacksSeed = true;
52  state.noiseSquared = 0;
53  state.ADCs.clear();
54  }

◆ clusterizeDetUnit() [1/2]

void ThreeThresholdAlgorithm::clusterizeDetUnit ( const edm::DetSet< SiStripDigi > &  digis,
output_t::TSFastFiller output 
) const
overridevirtual

Reimplemented from StripClusterizerAlgorithm.

Definition at line 135 of file ThreeThresholdAlgorithm.cc.

References clusterizeDetUnit_(), and convertSQLitetoXML_cfg::output.

136  {
137  clusterizeDetUnit_(digis, output);
138 }
void clusterizeDetUnit_(const T &, output_t::TSFastFiller &) const

◆ clusterizeDetUnit() [2/2]

void ThreeThresholdAlgorithm::clusterizeDetUnit ( const edmNew::DetSet< SiStripDigi > &  digis,
output_t::TSFastFiller output 
) const
overridevirtual

Reimplemented from StripClusterizerAlgorithm.

Definition at line 139 of file ThreeThresholdAlgorithm.cc.

References clusterizeDetUnit_(), and convertSQLitetoXML_cfg::output.

140  {
141  clusterizeDetUnit_(digis, output);
142 }
void clusterizeDetUnit_(const T &, output_t::TSFastFiller &) const

◆ clusterizeDetUnit_() [1/2]

template<class T >
void ThreeThresholdAlgorithm::clusterizeDetUnit_ ( const T ,
output_t::TSFastFiller  
) const
private

Referenced by clusterizeDetUnit().

◆ clusterizeDetUnit_() [2/2]

template<class digiDetSet >
void ThreeThresholdAlgorithm::clusterizeDetUnit_ ( const digiDetSet &  digis,
output_t::TSFastFiller output 
) const
inline

Definition at line 33 of file ThreeThresholdAlgorithm.cc.

References addToCandidate(), candidateEnded(), SiStripApvShotCleaner::clean(), StripClusterizerAlgorithm::conditions(), mps_fire::end, endCandidate(), convertSQLitetoXML_cfg::output, and RemoveApvShots.

33  {
34  const auto& cond = conditions();
35  if (cond.isModuleBad(digis.detId()))
36  return;
37 
38  auto const& det = cond.findDetId(digis.detId());
39  if (!det.valid())
40  return;
41 
42 #ifdef EDM_ML_DEBUG
43  if (!cond.isModuleUsable(digis.detId()))
44  edm::LogWarning("ThreeThresholdAlgorithm") << " id " << digis.detId() << " not usable???" << std::endl;
45 #endif
46 
47  typename digiDetSet::const_iterator scan(digis.begin()), end(digis.end());
48 
49  SiStripApvShotCleaner ApvCleaner;
50  if (RemoveApvShots) {
51  ApvCleaner.clean(digis, scan, end);
52  }
53 
54  output.reserve(16);
55  State state(det);
56  while (scan != end) {
57  while (scan != end && !candidateEnded(state, scan->strip()))
58  addToCandidate(state, *scan++);
60  }
61 }
void addToCandidate(State &state, const SiStripDigi &digi) const
const SiStripClusterizerConditions & conditions() const
Definition: plugin.cc:23
void endCandidate(State &state, T &) const
bool clean(const edmNew::DetSet< SiStripDigi > &in, edmNew::DetSet< SiStripDigi >::const_iterator &scan, edmNew::DetSet< SiStripDigi >::const_iterator &end)
Log< level::Warning, false > LogWarning
bool candidateEnded(State const &state, const uint16_t &) const

◆ endCandidate()

template<class T >
void ThreeThresholdAlgorithm::endCandidate ( State state,
T out 
) const
inlineprivate

Definition at line 91 of file ThreeThresholdAlgorithm.cc.

References appendBadNeighbors(), applyGains(), candidateAccepted(), siStripClusterTools::chargePerCM(), clearCandidate(), firstStrip(), MaxAdjacentBad, minGoodCharge, eostools::move(), and MillePedeFileConverter_cfg::out.

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

91  {
92  if (candidateAccepted(state)) {
94  if (MaxAdjacentBad > 0)
96  if (minGoodCharge <= 0 ||
97  siStripClusterTools::chargePerCM(state.det().detId, state.ADCs.begin(), state.ADCs.end()) > minGoodCharge)
98  out.push_back(std::move(SiStripCluster(firstStrip(state), state.ADCs.begin(), state.ADCs.end())));
99  }
101 }
float chargePerCM(DetId detid, Iter a, Iter b)
bool candidateAccepted(State const &state) const
void clearCandidate(State &state) const
void appendBadNeighbors(State &state) const
uint16_t firstStrip(State const &state) const
void applyGains(State &state) const
def move(src, dest)
Definition: eostools.py:511

◆ firstStrip()

uint16_t ThreeThresholdAlgorithm::firstStrip ( State const &  state) const
inlineprivate

Definition at line 43 of file ThreeThresholdAlgorithm.h.

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

43 { return state.lastStrip - state.ADCs.size() + 1; }

◆ stripByStripAdd() [1/2]

void ThreeThresholdAlgorithm::stripByStripAdd ( State state,
uint16_t  strip,
uint8_t  adc,
std::vector< SiStripCluster > &  out 
) const
overridevirtual

Reimplemented from StripClusterizerAlgorithm.

Definition at line 144 of file ThreeThresholdAlgorithm.cc.

References gpuClustering::adc, addToCandidate(), candidateEnded(), endCandidate(), MillePedeFileConverter_cfg::out, and nano_mu_digi_cff::strip.

147  {
148  if (candidateEnded(state, strip))
151 }
void addToCandidate(State &state, const SiStripDigi &digi) const
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
Definition: SiStripDigi.h:12
void endCandidate(State &state, T &) const
bool candidateEnded(State const &state, const uint16_t &) const
uint16_t *__restrict__ uint16_t const *__restrict__ adc

◆ stripByStripAdd() [2/2]

void ThreeThresholdAlgorithm::stripByStripAdd ( State state,
uint16_t  strip,
uint8_t  adc,
output_t::TSFastFiller out 
) const
inlineoverridevirtual

Reimplemented from StripClusterizerAlgorithm.

Definition at line 19 of file ThreeThresholdAlgorithm.h.

References gpuClustering::adc, addToCandidate(), candidateEnded(), endCandidate(), MillePedeFileConverter_cfg::out, and nano_mu_digi_cff::strip.

19  {
23  }
void addToCandidate(State &state, const SiStripDigi &digi) const
void endCandidate(State &state, T &) const
bool candidateEnded(State const &state, const uint16_t &) const
uint16_t *__restrict__ uint16_t const *__restrict__ adc

◆ stripByStripEnd() [1/2]

void ThreeThresholdAlgorithm::stripByStripEnd ( State state,
std::vector< SiStripCluster > &  out 
) const
overridevirtual

◆ stripByStripEnd() [2/2]

void ThreeThresholdAlgorithm::stripByStripEnd ( State state,
output_t::TSFastFiller out 
) const
inlineoverridevirtual

Friends And Related Function Documentation

◆ StripClusterizerAlgorithmFactory

friend class StripClusterizerAlgorithmFactory
friend

Definition at line 7 of file ThreeThresholdAlgorithm.h.

Member Data Documentation

◆ ChannelThreshold

float ThreeThresholdAlgorithm::ChannelThreshold
private

Definition at line 60 of file ThreeThresholdAlgorithm.h.

Referenced by addToCandidate().

◆ ClusterThresholdSquared

float ThreeThresholdAlgorithm::ClusterThresholdSquared
private

Definition at line 60 of file ThreeThresholdAlgorithm.h.

Referenced by candidateAccepted().

◆ MaxAdjacentBad

uint8_t ThreeThresholdAlgorithm::MaxAdjacentBad
private

Definition at line 61 of file ThreeThresholdAlgorithm.h.

Referenced by appendBadNeighbors(), and endCandidate().

◆ MaxClusterSize

unsigned ThreeThresholdAlgorithm::MaxClusterSize
private

Definition at line 62 of file ThreeThresholdAlgorithm.h.

Referenced by addToCandidate(), and candidateAccepted().

◆ MaxSequentialBad

uint8_t ThreeThresholdAlgorithm::MaxSequentialBad
private

Definition at line 61 of file ThreeThresholdAlgorithm.h.

Referenced by candidateEnded().

◆ MaxSequentialHoles

uint8_t ThreeThresholdAlgorithm::MaxSequentialHoles
private

Definition at line 61 of file ThreeThresholdAlgorithm.h.

Referenced by candidateEnded().

◆ minGoodCharge

float ThreeThresholdAlgorithm::minGoodCharge
private

Definition at line 64 of file ThreeThresholdAlgorithm.h.

Referenced by endCandidate().

◆ RemoveApvShots

bool ThreeThresholdAlgorithm::RemoveApvShots
private

Definition at line 63 of file ThreeThresholdAlgorithm.h.

Referenced by clusterizeDetUnit_().

◆ SeedThreshold

float ThreeThresholdAlgorithm::SeedThreshold
private

Definition at line 60 of file ThreeThresholdAlgorithm.h.

Referenced by addToCandidate().