CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes
StripClusterizerAlgorithm Class Referenceabstract

#include <StripClusterizerAlgorithm.h>

Inheritance diagram for StripClusterizerAlgorithm:
OldThreeThresholdAlgorithm ThreeThresholdAlgorithm

Classes

struct  Index
 
struct  InvalidChargeException
 

Public Types

typedef edmNew::DetSetVector
< SiStripCluster
output_t
 

Public Member Functions

virtual void addFed (sistrip::FEDZSChannelUnpacker &unpacker, uint16_t ipair, std::vector< SiStripCluster > &out)
 
virtual void addFed (sistrip::FEDZSChannelUnpacker &unpacker, uint16_t ipair, output_t::FastFiller &out)
 
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 &)
 
virtual void clusterizeDetUnit (const edm::DetSet< SiStripDigi > &, output_t::FastFiller &)=0
 
virtual void clusterizeDetUnit (const edmNew::DetSet< SiStripDigi > &, output_t::FastFiller &)=0
 
std::vector< const
FedChannelConnection * > const & 
currentConnection () const
 
virtual void initialize (const edm::EventSetup &)
 
virtual void stripByStripAdd (uint16_t strip, uint8_t adc, std::vector< SiStripCluster > &out)
 
virtual void stripByStripAdd (uint16_t strip, uint8_t adc, output_t::FastFiller &out)
 
virtual bool stripByStripBegin (uint32_t id)=0
 
virtual void stripByStripEnd (std::vector< SiStripCluster > &out)
 
virtual void stripByStripEnd (output_t::FastFiller &out)
 
virtual ~StripClusterizerAlgorithm ()
 

Protected Member Functions

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

bool _setDetId
 
std::string qualityLabel
 

Private Member Functions

template<class T >
void clusterize_ (const T &input, output_t &output)
 

Private Attributes

std::vector< std::vector
< const FedChannelConnection * > > 
connections
 
uint32_t detId =0
 
std::vector< uint32_t > detIds
 
uint32_t gain_cache_id
 
edm::ESHandle< SiStripGaingainHandle
 
SiStripApvGain::Range gainRange
 
unsigned short ind =invalidI
 
std::vector< Indexindices
 
uint32_t noise_cache_id
 
edm::ESHandle< SiStripNoisesnoiseHandle
 
SiStripNoises::Range noiseRange
 
uint32_t quality_cache_id
 
edm::ESHandle< SiStripQualityqualityHandle
 
SiStripQuality::Range qualityRange
 
SiStripDetCabling const * theCabling = nullptr
 

Static Private Attributes

static constexpr unsigned short invalidI = std::numeric_limits<unsigned short>::max()
 

Detailed Description

Definition at line 19 of file StripClusterizerAlgorithm.h.

Member Typedef Documentation

Definition at line 27 of file StripClusterizerAlgorithm.h.

Constructor & Destructor Documentation

virtual StripClusterizerAlgorithm::~StripClusterizerAlgorithm ( )
inlinevirtual

Definition at line 23 of file StripClusterizerAlgorithm.h.

23 {}
StripClusterizerAlgorithm::StripClusterizerAlgorithm ( )
inlineprotected

Member Function Documentation

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

Reimplemented in ThreeThresholdAlgorithm.

Definition at line 36 of file StripClusterizerAlgorithm.h.

Referenced by sistrip::RawToClustersLazyUnpacker::fill().

36 {}
virtual void StripClusterizerAlgorithm::addFed ( sistrip::FEDZSChannelUnpacker unpacker,
uint16_t  ipair,
output_t::FastFiller out 
)
inlinevirtual

Reimplemented in ThreeThresholdAlgorithm.

Definition at line 40 of file StripClusterizerAlgorithm.h.

40 {}
bool StripClusterizerAlgorithm::allBadBetween ( uint16_t  L,
const uint16_t &  R 
) const
inlineprotected

Definition at line 63 of file StripClusterizerAlgorithm.h.

References bad(), and dttmaxenums::R.

Referenced by ThreeThresholdAlgorithm::candidateEnded().

63 { while( ++L < R && bad(L) ); return L == R; }
bool bad(const uint16_t &strip) const
std::vector<uint32_t> const& StripClusterizerAlgorithm::allDetIds ( ) const
inline

Definition at line 49 of file StripClusterizerAlgorithm.h.

References detIds.

49 { return detIds;}
std::vector< uint32_t > detIds
bool StripClusterizerAlgorithm::bad ( const uint16_t &  strip) const
inlineprotected

Definition at line 60 of file StripClusterizerAlgorithm.h.

References qualityHandle, and qualityRange.

Referenced by ThreeThresholdAlgorithm::addToCandidate(), allBadBetween(), and ThreeThresholdAlgorithm::appendBadNeighbors().

60 { return qualityHandle->IsStripBad( qualityRange, strip ); }
edm::ESHandle< SiStripQuality > qualityHandle
SiStripQuality::Range qualityRange
SiStripDetCabling const* StripClusterizerAlgorithm::cabling ( ) const
inline

Definition at line 48 of file StripClusterizerAlgorithm.h.

References theCabling.

Referenced by initialize().

48 { return theCabling;}
SiStripDetCabling const * theCabling
void StripClusterizerAlgorithm::clusterize ( const edm::DetSetVector< SiStripDigi > &  input,
output_t output 
)

Definition at line 191 of file StripClusterizerAlgorithm.cc.

References clusterize_().

191 {clusterize_(input, output);}
void clusterize_(const T &input, output_t &output)
void StripClusterizerAlgorithm::clusterize ( const edmNew::DetSetVector< SiStripDigi > &  input,
output_t output 
)

Definition at line 192 of file StripClusterizerAlgorithm.cc.

References clusterize_().

192 {clusterize_(input, output);}
void clusterize_(const T &input, output_t &output)
template<class T >
void StripClusterizerAlgorithm::clusterize_ ( const T input,
output_t output 
)
inlineprivate

Definition at line 70 of file StripClusterizerAlgorithm.h.

References clusterizeDetUnit(), and alignCSCRings::ff.

Referenced by clusterize().

70  {
71  for(typename T::const_iterator it = input.begin(); it!=input.end(); it++) {
72  output_t::FastFiller ff(output, it->detId());
73  clusterizeDetUnit(*it, ff);
74  if(ff.empty()) ff.abort();
75  }
76  }
static std::string const input
Definition: EdmProvDump.cc:44
virtual void clusterizeDetUnit(const edm::DetSet< SiStripDigi > &, output_t::FastFiller &)=0
virtual void StripClusterizerAlgorithm::clusterizeDetUnit ( const edm::DetSet< SiStripDigi > &  ,
output_t::FastFiller  
)
pure virtual

Implemented in ThreeThresholdAlgorithm.

Referenced by clusterize_().

virtual void StripClusterizerAlgorithm::clusterizeDetUnit ( const edmNew::DetSet< SiStripDigi > &  ,
output_t::FastFiller  
)
pure virtual

Implemented in ThreeThresholdAlgorithm.

std::vector<const FedChannelConnection *> const& StripClusterizerAlgorithm::currentConnection ( ) const
inline

Definition at line 50 of file StripClusterizerAlgorithm.h.

References connections, and ind.

50 { return connections[ind]; }
std::vector< std::vector< const FedChannelConnection * > > connections
uint32_t StripClusterizerAlgorithm::currentId ( )
inlineprotected

Definition at line 56 of file StripClusterizerAlgorithm.h.

References detId.

Referenced by ThreeThresholdAlgorithm::endCandidate().

float StripClusterizerAlgorithm::gain ( const uint16_t &  strip) const
inlineprotected

Definition at line 59 of file StripClusterizerAlgorithm.h.

References gainRange, and SiStripGain::getStripGain().

Referenced by ThreeThresholdAlgorithm::applyGains().

59 { return SiStripGain::getStripGain( strip, gainRange ); }
static float getStripGain(const uint16_t &strip, const SiStripApvGain::Range &range)
Definition: SiStripGain.h:68
void StripClusterizerAlgorithm::initialize ( const edm::EventSetup es)
virtual

Reimplemented in OldThreeThresholdAlgorithm.

Definition at line 25 of file StripClusterizerAlgorithm.cc.

References trackerHits::c, cabling(), results_mgr::conn, SiStripDetCabling::connected(), connections, COUT, detId, detIds, gain_cache_id, gainHandle, gainRange, edm::EventSetup::get(), SiStripDetCabling::getDetCabling(), i, ind, indices, invalidI, isModuleBad(), j, gen::k, mod(), noise_cache_id, noiseHandle, noiseRange, quality_cache_id, qualityHandle, qualityLabel, qualityRange, and theCabling.

25  {
26  uint32_t n_cache_id = es.get<SiStripNoisesRcd>().cacheIdentifier();
27  uint32_t g_cache_id = es.get<SiStripGainRcd>().cacheIdentifier();
28  uint32_t q_cache_id = es.get<SiStripQualityRcd>().cacheIdentifier();
29 
30  bool mod=false;
31  if(g_cache_id != gain_cache_id) {
32  es.get<SiStripGainRcd>().get( gainHandle );
33  gain_cache_id = g_cache_id;
34  mod=true;
35  }
36  if(n_cache_id != noise_cache_id) {
37  es.get<SiStripNoisesRcd>().get( noiseHandle );
38  noise_cache_id = n_cache_id;
39  mod=true;
40  }
41  if(q_cache_id != quality_cache_id) {
43  quality_cache_id = q_cache_id;
44  mod=true;
45  }
46 
47  if (mod) {
48  // redo indexing!
49  theCabling = qualityHandle->cabling();
50  assert(theCabling);
51  auto const & conn = cabling()->connected();
52  COUT << "cabling " << conn.size() << std::endl;
53  detIds.clear();
54  detIds.reserve(conn.size());
55  for (auto const & c : conn) { if (!isModuleBad(c.first)) detIds.push_back(c.first);}
56  indices.clear();
57  indices.resize(detIds.size());
58  COUT << "good detIds " << detIds.size() << std::endl;
59 
60  if (0==detIds.size()) {
61  ind=0; detId=0; return;
62  }
63 
64  {
65  connections.clear();
66  connections.resize(detIds.size());
67  //connections (slow, not a big deal)
68  auto const & conns = cabling()->getDetCabling();
69  for (auto i=0U; i<detIds.size(); ++i) {
70  auto c = conns.find(detIds[i]);
71  if (c!=conns.end()) connections[i]=(*c).second;
72  }
73 
74 
75  }
76 
77 
78  { // quality
79  std::vector<uint32_t> dum; qualityHandle->getDetIds(dum);
80  assert(dum.size()<invalidI);
81  unsigned short j=0, i=0;
82  while (i<dum.size() && j<detIds.size()) {
83  if (dum[i]<detIds[j]) ++i;
84  else if (detIds[j]<dum[i]) {indices[j].qi=invalidI; ++j;}
85  else {
86  indices[j].qi=i; ++i; ++j;
87  }
88  }
89  unsigned int nn=0;
90  for(auto k=0U; k<detIds.size();++k) { if (indices[k].qi<invalidI) {++nn; assert(dum[indices[k].qi]==detIds[k]);}}
91  assert(nn<=dum.size());
92  COUT << "quality " << dum.size() << " " <<nn<< std::endl;
93  }
94  { //noise
95  std::vector<uint32_t> dum; noiseHandle->getDetIds(dum);
96  assert(dum.size()<invalidI);
97  unsigned short j=0, i=0;
98  while (i<dum.size() && j<detIds.size()) {
99  if (dum[i]<detIds[j]) ++i;
100  else if (detIds[j]<dum[i]) {indices[j].ni=invalidI; ++j;}
101  else {
102  indices[j].ni=i; ++i; ++j;
103  }
104  }
105  unsigned int nn=0;
106  for(auto k=0U; k<detIds.size();++k) { if (indices[k].ni<invalidI) {++nn; assert(dum[indices[k].ni]==detIds[k]);}}
107  assert(nn<=dum.size());
108  COUT << "noise " << dum.size() << " " <<nn<< std::endl;
109  }
110  { //gain
111  std::vector<uint32_t> dum; gainHandle->getDetIds(dum);
112  assert(dum.size()<invalidI);
113  unsigned short j=0, i=0;
114  while (i<dum.size() && j<detIds.size()) {
115  if (dum[i]<detIds[j]) ++i;
116  else if (detIds[j]<dum[i]) {indices[j].gi=invalidI; ++j;}
117  else {
118  indices[j].gi=i; ++i; ++j;
119  }
120  }
121  unsigned int nn=0;
122  for(auto k=0U; k<detIds.size();++k) { if (indices[k].gi<invalidI) {++nn; assert(dum[indices[k].gi]==detIds[k]);}}
123  assert(nn<=dum.size());
124  COUT << "gain " << dum.size() << " " <<nn<< std::endl;
125  }
126  }
127 
128  if (0==detIds.size()) {
129  ind=0; detId=0; return;
130  }
131 
132  // initalize first det
133  ind = 0;
134  detId = detIds[ind];
135 
136  noiseRange = noiseHandle->getRangeByPos(indices[ind].ni);
137  gainRange = gainHandle->getRangeByPos(indices[ind].gi);
138  qualityRange = qualityHandle->getRangeByPos(indices[ind].qi);
139 
140 }
int i
Definition: DBlmapReader.cc:9
edm::ESHandle< SiStripQuality > qualityHandle
edm::ESHandle< SiStripGain > gainHandle
SiStripQuality::Range qualityRange
bool isModuleBad(const uint32_t &id) const
edm::ESHandle< SiStripNoises > noiseHandle
#define COUT
std::vector< std::vector< const FedChannelConnection * > > connections
int j
Definition: DBlmapReader.cc:9
SiStripDetCabling const * theCabling
int k[5][pyjets_maxn]
const std::map< uint32_t, std::vector< const FedChannelConnection * > > & getDetCabling() const
const T & get() const
Definition: EventSetup.h:55
SiStripDetCabling const * cabling() const
static constexpr unsigned short invalidI
std::map< uint32_t, std::vector< int > > const & connected() const
std::vector< uint32_t > detIds
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
tuple conn
Definition: results_mgr.py:53
bool StripClusterizerAlgorithm::isModuleBad ( const uint32_t &  id) const
inlineprotected

Definition at line 61 of file StripClusterizerAlgorithm.h.

References qualityHandle.

Referenced by ThreeThresholdAlgorithm::clusterizeDetUnit_(), and initialize().

61 { return qualityHandle->IsModuleBad( id ); }
edm::ESHandle< SiStripQuality > qualityHandle
bool StripClusterizerAlgorithm::isModuleUsable ( const uint32_t &  id) const
inlineprotected

Definition at line 62 of file StripClusterizerAlgorithm.h.

References qualityHandle.

Referenced by ThreeThresholdAlgorithm::clusterizeDetUnit_(), and ThreeThresholdAlgorithm::stripByStripBegin().

62 { return qualityHandle->IsModuleUsable( id ); }
edm::ESHandle< SiStripQuality > qualityHandle
float StripClusterizerAlgorithm::noise ( const uint16_t &  strip) const
inlineprotected

Definition at line 58 of file StripClusterizerAlgorithm.h.

References SiStripNoises::getNoise(), and noiseRange.

Referenced by ThreeThresholdAlgorithm::addToCandidate().

58 { return SiStripNoises::getNoise( strip, noiseRange ); }
static float getNoise(uint16_t strip, const Range &range)
Definition: SiStripNoises.h:70
bool StripClusterizerAlgorithm::setDetId ( const uint32_t  id)
protected

Definition at line 144 of file StripClusterizerAlgorithm.cc.

References b, detId, detIds, alignCSCRings::e, gainHandle, gainRange, ind, indices, noiseHandle, noiseRange, AlCaHLTBitMon_ParallelJobs::p, qualityHandle, qualityRange, and unlikely.

Referenced by ThreeThresholdAlgorithm::clusterizeDetUnit_(), OldThreeThresholdAlgorithm::OldThreeThresholdAlgorithm(), ThreeThresholdAlgorithm::stripByStripBegin(), and ThreeThresholdAlgorithm::ThreeThresholdAlgorithm().

144  {
145  if (id==detId) return true; // rare....
146  // priority to sequential scan
147  if (id==detIds[ind+1]) {
148  ++ind;
149  } else if unlikely( (id>detId) & (id<detIds[ind+1]) ) {
150  /*
151  edm::LogWarning("StripClusterizerAlgorithm")
152  <<"id " << id << " not connected. this is impossible on data "
153  << "old id " << detId << std::endl;
154  */
155  return false;
156  } else{
157  auto b = detIds.begin();
158  auto e = detIds.end();
159  if (id>detId) b+=ind;
160  else e=b+ind;
161  auto p = std::lower_bound(b,e,id);
162  if (p==e || id!=(*p)) {
163 #ifdef NOT_ON_MONTECARLO
164  edm::LogWarning("StripClusterizerAlgorithm")
165  <<"id " << id << " not connected. this is impossible on data "
166  << "old id " << detId << std::endl;
167 #endif
168  return false;
169  }
170  ind = p-detIds.begin();
171  }
172 
173  detId = id;
174  noiseRange = noiseHandle->getRangeByPos(indices[ind].ni);
175  gainRange = gainHandle->getRangeByPos(indices[ind].gi);
176  qualityRange = qualityHandle->getRangeByPos(indices[ind].qi);
177 
178 #ifdef EDM_ML_DEBUG
179  assert(detIds[ind]==detId);
180  auto oldg = gainHandle->getRange(id);
181  assert(oldg==gainRange);
182  auto oldn = noiseHandle->getRange(id);
183  assert(oldn==noiseRange);
184  auto oldq = qualityHandle->getRange(id);
185  assert(oldq==qualityRange);
186 #endif
187 
188  return true;
189 }
edm::ESHandle< SiStripQuality > qualityHandle
edm::ESHandle< SiStripGain > gainHandle
SiStripQuality::Range qualityRange
edm::ESHandle< SiStripNoises > noiseHandle
#define unlikely(x)
Definition: Likely.h:21
double b
Definition: hdecay.h:120
std::vector< uint32_t > detIds
virtual void StripClusterizerAlgorithm::stripByStripAdd ( uint16_t  strip,
uint8_t  adc,
std::vector< SiStripCluster > &  out 
)
inlinevirtual

Reimplemented in ThreeThresholdAlgorithm.

Definition at line 37 of file StripClusterizerAlgorithm.h.

Referenced by sistrip::RawToClustersLazyUnpacker::fill().

37 {}
virtual void StripClusterizerAlgorithm::stripByStripAdd ( uint16_t  strip,
uint8_t  adc,
output_t::FastFiller out 
)
inlinevirtual

Reimplemented in ThreeThresholdAlgorithm.

Definition at line 41 of file StripClusterizerAlgorithm.h.

41 {}
virtual bool StripClusterizerAlgorithm::stripByStripBegin ( uint32_t  id)
pure virtual
virtual void StripClusterizerAlgorithm::stripByStripEnd ( std::vector< SiStripCluster > &  out)
inlinevirtual

Reimplemented in ThreeThresholdAlgorithm.

Definition at line 38 of file StripClusterizerAlgorithm.h.

Referenced by sistrip::RawToClustersLazyUnpacker::fill().

38 {}
virtual void StripClusterizerAlgorithm::stripByStripEnd ( output_t::FastFiller out)
inlinevirtual

Reimplemented in ThreeThresholdAlgorithm.

Definition at line 42 of file StripClusterizerAlgorithm.h.

42 {}

Member Data Documentation

bool StripClusterizerAlgorithm::_setDetId
protected
std::vector<std::vector<const FedChannelConnection *> > StripClusterizerAlgorithm::connections
private

Definition at line 86 of file StripClusterizerAlgorithm.h.

Referenced by currentConnection(), and initialize().

uint32_t StripClusterizerAlgorithm::detId =0
private

Definition at line 95 of file StripClusterizerAlgorithm.h.

Referenced by currentId(), initialize(), and setDetId().

std::vector<uint32_t> StripClusterizerAlgorithm::detIds
private

Definition at line 85 of file StripClusterizerAlgorithm.h.

Referenced by allDetIds(), initialize(), and setDetId().

uint32_t StripClusterizerAlgorithm::gain_cache_id
private

Definition at line 95 of file StripClusterizerAlgorithm.h.

Referenced by initialize().

edm::ESHandle<SiStripGain> StripClusterizerAlgorithm::gainHandle
private

Definition at line 91 of file StripClusterizerAlgorithm.h.

Referenced by initialize(), and setDetId().

SiStripApvGain::Range StripClusterizerAlgorithm::gainRange
private

Definition at line 88 of file StripClusterizerAlgorithm.h.

Referenced by gain(), initialize(), and setDetId().

unsigned short StripClusterizerAlgorithm::ind =invalidI
private

Definition at line 96 of file StripClusterizerAlgorithm.h.

Referenced by currentConnection(), initialize(), and setDetId().

std::vector<Index> StripClusterizerAlgorithm::indices
private

Definition at line 87 of file StripClusterizerAlgorithm.h.

Referenced by initialize(), and setDetId().

constexpr unsigned short StripClusterizerAlgorithm::invalidI = std::numeric_limits<unsigned short>::max()
staticprivate

Definition at line 78 of file StripClusterizerAlgorithm.h.

Referenced by initialize().

uint32_t StripClusterizerAlgorithm::noise_cache_id
private

Definition at line 95 of file StripClusterizerAlgorithm.h.

Referenced by initialize().

edm::ESHandle<SiStripNoises> StripClusterizerAlgorithm::noiseHandle
private

Definition at line 92 of file StripClusterizerAlgorithm.h.

Referenced by initialize(), and setDetId().

SiStripNoises::Range StripClusterizerAlgorithm::noiseRange
private

Definition at line 89 of file StripClusterizerAlgorithm.h.

Referenced by initialize(), noise(), and setDetId().

uint32_t StripClusterizerAlgorithm::quality_cache_id
private

Definition at line 95 of file StripClusterizerAlgorithm.h.

Referenced by initialize().

edm::ESHandle<SiStripQuality> StripClusterizerAlgorithm::qualityHandle
private

Definition at line 93 of file StripClusterizerAlgorithm.h.

Referenced by bad(), initialize(), isModuleBad(), isModuleUsable(), and setDetId().

std::string StripClusterizerAlgorithm::qualityLabel
protected
SiStripQuality::Range StripClusterizerAlgorithm::qualityRange
private

Definition at line 90 of file StripClusterizerAlgorithm.h.

Referenced by bad(), initialize(), and setDetId().

SiStripDetCabling const* StripClusterizerAlgorithm::theCabling = nullptr
private

Definition at line 94 of file StripClusterizerAlgorithm.h.

Referenced by cabling(), and initialize().