CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
StripClusterizerAlgorithm Class Referenceabstract

#include <StripClusterizerAlgorithm.h>

Inheritance diagram for StripClusterizerAlgorithm:
ThreeThresholdAlgorithm

Classes

struct  Det
 
struct  Index
 
struct  InvalidChargeException
 
struct  State
 

Public Types

typedef edmNew::DetSetVector< SiStripClusteroutput_t
 

Public Member Functions

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

Static Public Attributes

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

Protected Member Functions

Det findDetId (const uint32_t) const
 
bool isModuleBad (const uint32_t &id) const
 
bool isModuleUsable (const uint32_t &id) const
 
 StripClusterizerAlgorithm ()
 

Protected Attributes

std::string qualityLabel
 

Private Member Functions

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

Private Attributes

std::vector< std::vector< const FedChannelConnection * > > connections
 
std::vector< uint32_t > detIds
 
uint32_t gain_cache_id
 
edm::ESHandle< SiStripGaingainHandle
 
std::vector< Indexindices
 
uint32_t noise_cache_id
 
edm::ESHandle< SiStripNoisesnoiseHandle
 
uint32_t quality_cache_id
 
edm::ESHandle< SiStripQualityqualityHandle
 
SiStripDetCabling const * theCabling = 0
 

Detailed Description

Definition at line 20 of file StripClusterizerAlgorithm.h.

Member Typedef Documentation

Definition at line 60 of file StripClusterizerAlgorithm.h.

Constructor & Destructor Documentation

virtual StripClusterizerAlgorithm::~StripClusterizerAlgorithm ( )
inlinevirtual

Definition at line 56 of file StripClusterizerAlgorithm.h.

References initialize().

56 {}
StripClusterizerAlgorithm::StripClusterizerAlgorithm ( )
inlineprotected

Member Function Documentation

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

Definition at line 69 of file StripClusterizerAlgorithm.h.

Referenced by ThreeThresholdAlgorithm::addFed().

72  {}
virtual void StripClusterizerAlgorithm::addFed ( State state,
sistrip::FEDZSChannelUnpacker unpacker,
uint16_t  ipair,
output_t::TSFastFiller out 
) const
inlinevirtual

Reimplemented in ThreeThresholdAlgorithm.

Definition at line 76 of file StripClusterizerAlgorithm.h.

79  {}
std::vector<uint32_t> const& StripClusterizerAlgorithm::allDetIds ( ) const
inline

Definition at line 89 of file StripClusterizerAlgorithm.h.

89 { return detIds; }
SiStripDetCabling const* StripClusterizerAlgorithm::cabling ( ) const
inline

Definition at line 88 of file StripClusterizerAlgorithm.h.

Referenced by initialize().

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

Definition at line 196 of file StripClusterizerAlgorithm.cc.

References clusterize_().

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

Definition at line 199 of file StripClusterizerAlgorithm.cc.

References clusterize_().

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

Definition at line 106 of file StripClusterizerAlgorithm.h.

References alignCSCRings::ff.

Referenced by clusterize().

106  {
107  for (typename T::const_iterator it = input.begin(); it != input.end(); it++) {
108  output_t::TSFastFiller ff(output, it->detId());
109  clusterizeDetUnit(*it, ff);
110  if (ff.empty())
111  ff.abort();
112  }
113  }
virtual void clusterizeDetUnit(const edm::DetSet< SiStripDigi > &, output_t::TSFastFiller &) const =0
friend class TSFastFiller
static std::string const input
Definition: EdmProvDump.cc:48
virtual void StripClusterizerAlgorithm::clusterizeDetUnit ( const edm::DetSet< SiStripDigi > &  ,
output_t::TSFastFiller  
) const
pure virtual

Implemented in ThreeThresholdAlgorithm.

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

Implemented in ThreeThresholdAlgorithm.

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

Definition at line 91 of file StripClusterizerAlgorithm.h.

References StripClusterizerAlgorithm::Det::ind.

91  {
92  return connections[det.ind];
93  }
std::vector< std::vector< const FedChannelConnection * > > connections
StripClusterizerAlgorithm::Det StripClusterizerAlgorithm::findDetId ( const uint32_t  id) const
protected

Definition at line 161 of file StripClusterizerAlgorithm.cc.

References b, StripClusterizerAlgorithm::Det::detId, detIds, MillePedeFileConverter_cfg::e, gainHandle, StripClusterizerAlgorithm::Det::gainRange, SiStripNoises::getRange(), SiStripBadStrip::getRange(), SiStripGain::getRange(), SiStripNoises::getRangeByPos(), SiStripBadStrip::getRangeByPos(), SiStripGain::getRangeByPos(), triggerObjects_cff::id, StripClusterizerAlgorithm::Det::ind, indices, isModuleUsable(), noiseHandle, StripClusterizerAlgorithm::Det::noiseRange, AlCaHLTBitMon_ParallelJobs::p, edm::ESHandle< T >::product(), StripClusterizerAlgorithm::Det::quality, qualityHandle, and StripClusterizerAlgorithm::Det::qualityRange.

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

161  {
162  auto b = detIds.begin();
163  auto e = detIds.end();
164  auto p = std::lower_bound(b, e, id);
165  if (p == e || id != (*p)) {
166 #ifdef NOT_ON_MONTECARLO
167  edm::LogWarning("StripClusterizerAlgorithm") << "id " << id << " not connected. this is impossible on data "
168  << "old id " << detId << std::endl;
169 #endif
170  return Det();
171  }
172  Det det;
173  det.ind = p - detIds.begin();
174 
175  det.detId = id;
176  det.noiseRange = noiseHandle->getRangeByPos(indices[det.ind].ni);
177  det.gainRange = gainHandle->getRangeByPos(indices[det.ind].gi);
178  det.qualityRange = qualityHandle->getRangeByPos(indices[det.ind].qi);
179  det.quality = qualityHandle.product();
180 
181 #ifdef EDM_ML_DEBUG
182  assert(detIds[det.ind] == det.detId);
183  auto oldg = gainHandle->getRange(id);
184  assert(oldg == det.gainRange);
185  auto oldn = noiseHandle->getRange(id);
186  assert(oldn == det.noiseRange);
187  auto oldq = qualityHandle->getRange(id);
188  assert(oldq == det.qualityRange);
189 #endif
190 #ifdef EDM_ML_DEBUG
191  assert(isModuleUsable(id));
192 #endif
193  return det;
194 }
edm::ESHandle< SiStripQuality > qualityHandle
edm::ESHandle< SiStripGain > gainHandle
Range getRangeByPos(unsigned short pos) const
GeometricSearchDet Det
Definition: DetBelowR.h:8
edm::ESHandle< SiStripNoises > noiseHandle
bool isModuleUsable(const uint32_t &id) const
double b
Definition: hdecay.h:118
SiStripApvGain::Range getRangeByPos(unsigned short pos) const
Definition: SiStripGain.h:72
const Range getRange(const uint32_t detID) const
Range getRangeByPos(unsigned short pos) const
const Range getRange(const uint32_t detID) const
T const * product() const
Definition: ESHandle.h:86
const SiStripApvGain::Range getRange(uint32_t detID) const
Definition: SiStripGain.h:71
void StripClusterizerAlgorithm::initialize ( const edm::EventSetup es)
virtual

Definition at line 24 of file StripClusterizerAlgorithm.cc.

References HltBtagPostValidation_cff::c, cabling(), SiStripQuality::cabling(), SiStripCommissioningClient_cfg::conn, SiStripDetCabling::connected(), connections, COUT, detIds, gain_cache_id, gainHandle, edm::EventSetup::get(), SiStripDetCabling::getDetCabling(), SiStripNoises::getDetIds(), SiStripBadStrip::getDetIds(), SiStripGain::getDetIds(), mps_fire::i, indices, invalidI, isModuleBad(), dqmiolumiharvest::j, dqmdumpme::k, mod(), groupFilesInBlocks::nn, noise_cache_id, noiseHandle, quality_cache_id, qualityHandle, qualityLabel, theCabling, and mitigatedMETSequence_cff::U.

24  {
25  uint32_t n_cache_id = es.get<SiStripNoisesRcd>().cacheIdentifier();
26  uint32_t g_cache_id = es.get<SiStripGainRcd>().cacheIdentifier();
27  uint32_t q_cache_id = es.get<SiStripQualityRcd>().cacheIdentifier();
28 
29  bool mod = false;
30  if (g_cache_id != gain_cache_id) {
31  es.get<SiStripGainRcd>().get(gainHandle);
32  gain_cache_id = g_cache_id;
33  mod = true;
34  }
35  if (n_cache_id != noise_cache_id) {
36  es.get<SiStripNoisesRcd>().get(noiseHandle);
37  noise_cache_id = n_cache_id;
38  mod = true;
39  }
40  if (q_cache_id != quality_cache_id) {
42  quality_cache_id = q_cache_id;
43  mod = true;
44  }
45 
46  if (mod) {
47  // redo indexing!
49  assert(theCabling);
50  auto const& conn = cabling()->connected();
51  COUT << "cabling " << conn.size() << std::endl;
52  detIds.clear();
53  detIds.reserve(conn.size());
54  for (auto const& c : conn) {
55  if (!isModuleBad(c.first))
56  detIds.push_back(c.first);
57  }
58  indices.clear();
59  indices.resize(detIds.size());
60  COUT << "good detIds " << detIds.size() << std::endl;
61 
62  if (detIds.empty())
63  return;
64 
65  {
66  connections.clear();
67  connections.resize(detIds.size());
68  //connections (slow, not a big deal)
69  auto const& conns = cabling()->getDetCabling();
70  for (auto i = 0U; i < detIds.size(); ++i) {
71  auto c = conns.find(detIds[i]);
72  if (c != conns.end())
73  connections[i] = (*c).second;
74  }
75  }
76 
77  { // quality
78  std::vector<uint32_t> 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])
84  ++i;
85  else if (detIds[j] < dum[i]) {
86  indices[j].qi = invalidI;
87  ++j;
88  } else {
89  indices[j].qi = i;
90  ++i;
91  ++j;
92  }
93  }
94  unsigned int nn = 0;
95  for (auto k = 0U; k < detIds.size(); ++k) {
96  if (indices[k].qi < invalidI) {
97  ++nn;
98  assert(dum[indices[k].qi] == detIds[k]);
99  }
100  }
101  assert(nn <= dum.size());
102  COUT << "quality " << dum.size() << " " << nn << std::endl;
103  }
104  { //noise
105  std::vector<uint32_t> dum;
106  noiseHandle->getDetIds(dum);
107  assert(dum.size() < invalidI);
108  unsigned short j = 0, i = 0;
109  while (i < dum.size() && j < detIds.size()) {
110  if (dum[i] < detIds[j])
111  ++i;
112  else if (detIds[j] < dum[i]) {
113  indices[j].ni = invalidI;
114  ++j;
115  } else {
116  indices[j].ni = i;
117  ++i;
118  ++j;
119  }
120  }
121  unsigned int nn = 0;
122  for (auto k = 0U; k < detIds.size(); ++k) {
123  if (indices[k].ni < invalidI) {
124  ++nn;
125  assert(dum[indices[k].ni] == detIds[k]);
126  }
127  }
128  assert(nn <= dum.size());
129  COUT << "noise " << dum.size() << " " << nn << std::endl;
130  }
131  { //gain
132  std::vector<uint32_t> dum;
133  gainHandle->getDetIds(dum);
134  assert(dum.size() < invalidI);
135  unsigned short j = 0, i = 0;
136  while (i < dum.size() && j < detIds.size()) {
137  if (dum[i] < detIds[j])
138  ++i;
139  else if (detIds[j] < dum[i]) {
140  indices[j].gi = invalidI;
141  ++j;
142  } else {
143  indices[j].gi = i;
144  ++i;
145  ++j;
146  }
147  }
148  unsigned int nn = 0;
149  for (auto k = 0U; k < detIds.size(); ++k) {
150  if (indices[k].gi < invalidI) {
151  ++nn;
152  assert(dum[indices[k].gi] == detIds[k]);
153  }
154  }
155  assert(nn <= dum.size());
156  COUT << "gain " << dum.size() << " " << nn << std::endl;
157  }
158  }
159 }
edm::ESHandle< SiStripQuality > qualityHandle
void getDetIds(std::vector< uint32_t > &DetIds_) const
const std::map< uint32_t, std::vector< const FedChannelConnection * > > & getDetCabling() const
std::map< uint32_t, std::vector< int > > const & connected() const
edm::ESHandle< SiStripGain > gainHandle
bool isModuleBad(const uint32_t &id) const
edm::ESHandle< SiStripNoises > noiseHandle
#define COUT
std::vector< std::vector< const FedChannelConnection * > > connections
SiStripDetCabling const * cabling() const
void getDetIds(std::vector< uint32_t > &DetIds_) const
ATTENTION: we assume the detIds are the same as those from the first gain.
Definition: SiStripGain.cc:102
SiStripDetCabling const * theCabling
void getDetIds(std::vector< uint32_t > &DetIds_) const
SiStripDetCabling const * cabling() const
T get() const
Definition: EventSetup.h:73
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
bool StripClusterizerAlgorithm::isModuleBad ( const uint32_t &  id) const
inlineprotected

Definition at line 99 of file StripClusterizerAlgorithm.h.

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

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

Definition at line 100 of file StripClusterizerAlgorithm.h.

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

100 { return qualityHandle->IsModuleUsable(id); }
edm::ESHandle< SiStripQuality > qualityHandle
bool IsModuleUsable(const uint32_t &detid) const
virtual void StripClusterizerAlgorithm::stripByStripAdd ( State state,
uint16_t  strip,
uint8_t  adc,
std::vector< SiStripCluster > &  out 
) const
inlinevirtual

Reimplemented in ThreeThresholdAlgorithm.

Definition at line 73 of file StripClusterizerAlgorithm.h.

73 {}
virtual void StripClusterizerAlgorithm::stripByStripAdd ( State state,
uint16_t  strip,
uint8_t  adc,
output_t::TSFastFiller out 
) const
inlinevirtual

Reimplemented in ThreeThresholdAlgorithm.

Definition at line 80 of file StripClusterizerAlgorithm.h.

80 {}
virtual Det StripClusterizerAlgorithm::stripByStripBegin ( uint32_t  id) const
pure virtual

Implemented in ThreeThresholdAlgorithm.

virtual void StripClusterizerAlgorithm::stripByStripEnd ( State state,
std::vector< SiStripCluster > &  out 
) const
inlinevirtual

Reimplemented in ThreeThresholdAlgorithm.

Definition at line 74 of file StripClusterizerAlgorithm.h.

74 {}
virtual void StripClusterizerAlgorithm::stripByStripEnd ( State state,
output_t::TSFastFiller out 
) const
inlinevirtual

Reimplemented in ThreeThresholdAlgorithm.

Definition at line 81 of file StripClusterizerAlgorithm.h.

81 {}

Member Data Documentation

std::vector<std::vector<const FedChannelConnection*> > StripClusterizerAlgorithm::connections
private

Definition at line 119 of file StripClusterizerAlgorithm.h.

Referenced by initialize().

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

Definition at line 118 of file StripClusterizerAlgorithm.h.

Referenced by findDetId(), and initialize().

uint32_t StripClusterizerAlgorithm::gain_cache_id
private

Definition at line 125 of file StripClusterizerAlgorithm.h.

Referenced by initialize().

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

Definition at line 121 of file StripClusterizerAlgorithm.h.

Referenced by findDetId(), and initialize().

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

Definition at line 120 of file StripClusterizerAlgorithm.h.

Referenced by findDetId(), and initialize().

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

Definition at line 22 of file StripClusterizerAlgorithm.h.

Referenced by initialize().

uint32_t StripClusterizerAlgorithm::noise_cache_id
private

Definition at line 125 of file StripClusterizerAlgorithm.h.

Referenced by initialize().

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

Definition at line 122 of file StripClusterizerAlgorithm.h.

Referenced by findDetId(), and initialize().

uint32_t StripClusterizerAlgorithm::quality_cache_id
private

Definition at line 125 of file StripClusterizerAlgorithm.h.

Referenced by initialize().

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

Definition at line 123 of file StripClusterizerAlgorithm.h.

Referenced by findDetId(), and initialize().

std::string StripClusterizerAlgorithm::qualityLabel
protected
SiStripDetCabling const* StripClusterizerAlgorithm::theCabling = 0
private

Definition at line 124 of file StripClusterizerAlgorithm.h.

Referenced by initialize().