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 19 of file StripClusterizerAlgorithm.h.

Member Typedef Documentation

Definition at line 57 of file StripClusterizerAlgorithm.h.

Constructor & Destructor Documentation

virtual StripClusterizerAlgorithm::~StripClusterizerAlgorithm ( )
inlinevirtual

Definition at line 52 of file StripClusterizerAlgorithm.h.

References initialize().

52 {}
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 66 of file StripClusterizerAlgorithm.h.

Referenced by ThreeThresholdAlgorithm::addFed().

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

Reimplemented in ThreeThresholdAlgorithm.

Definition at line 70 of file StripClusterizerAlgorithm.h.

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

Definition at line 79 of file StripClusterizerAlgorithm.h.

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

Definition at line 78 of file StripClusterizerAlgorithm.h.

Referenced by initialize().

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

Definition at line 166 of file StripClusterizerAlgorithm.cc.

References clusterize_().

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

Definition at line 95 of file StripClusterizerAlgorithm.h.

References alignCSCRings::ff.

Referenced by clusterize().

95  {
96  for(typename T::const_iterator it = input.begin(); it!=input.end(); it++) {
97  output_t::TSFastFiller ff(output, it->detId());
98  clusterizeDetUnit(*it, ff);
99  if(ff.empty()) ff.abort();
100  }
101  }
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 81 of file StripClusterizerAlgorithm.h.

References StripClusterizerAlgorithm::Det::ind.

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

Definition at line 130 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(), pfDeepBoostedJetPreprocessParams_cfi::lower_bound, noiseHandle, StripClusterizerAlgorithm::Det::noiseRange, AlCaHLTBitMon_ParallelJobs::p, edm::ESHandle< T >::product(), StripClusterizerAlgorithm::Det::quality, qualityHandle, and StripClusterizerAlgorithm::Det::qualityRange.

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

130  {
131  auto b = detIds.begin();
132  auto e = detIds.end();
133  auto p = std::lower_bound(b,e,id);
134  if (p==e || id!=(*p)) {
135 #ifdef NOT_ON_MONTECARLO
136  edm::LogWarning("StripClusterizerAlgorithm")
137  <<"id " << id << " not connected. this is impossible on data "
138  << "old id " << detId << std::endl;
139 #endif
140  return Det();
141  }
142  Det det;
143  det.ind = p-detIds.begin();
144 
145  det.detId = id;
146  det.noiseRange = noiseHandle->getRangeByPos(indices[det.ind].ni);
147  det.gainRange = gainHandle->getRangeByPos(indices[det.ind].gi);
148  det.qualityRange = qualityHandle->getRangeByPos(indices[det.ind].qi);
149  det.quality = qualityHandle.product();
150 
151 #ifdef EDM_ML_DEBUG
152  assert(detIds[det.ind]==det.detId);
153  auto oldg = gainHandle->getRange(id);
154  assert(oldg==det.gainRange);
155  auto oldn = noiseHandle->getRange(id);
156  assert(oldn==det.noiseRange);
157  auto oldq = qualityHandle->getRange(id);
158  assert(oldq==det.qualityRange);
159 #endif
160 #ifdef EDM_ML_DEBUG
161  assert(isModuleUsable( id ));
162 #endif
163  return det;
164 }
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:120
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 25 of file StripClusterizerAlgorithm.cc.

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

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!
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 (detIds.empty()) return;
61 
62  {
63  connections.clear();
64  connections.resize(detIds.size());
65  //connections (slow, not a big deal)
66  auto const & conns = cabling()->getDetCabling();
67  for (auto i=0U; i<detIds.size(); ++i) {
68  auto c = conns.find(detIds[i]);
69  if (c!=conns.end()) connections[i]=(*c).second;
70  }
71 
72 
73  }
74 
75 
76  { // quality
77  std::vector<uint32_t> dum; qualityHandle->getDetIds(dum);
78  assert(dum.size()<invalidI);
79  unsigned short j=0, i=0;
80  while (i<dum.size() && j<detIds.size()) {
81  if (dum[i]<detIds[j]) ++i;
82  else if (detIds[j]<dum[i]) {indices[j].qi=invalidI; ++j;}
83  else {
84  indices[j].qi=i; ++i; ++j;
85  }
86  }
87  unsigned int nn=0;
88  for(auto k=0U; k<detIds.size();++k) { if (indices[k].qi<invalidI) {++nn; assert(dum[indices[k].qi]==detIds[k]);}}
89  assert(nn<=dum.size());
90  COUT << "quality " << dum.size() << " " <<nn<< std::endl;
91  }
92  { //noise
93  std::vector<uint32_t> dum; noiseHandle->getDetIds(dum);
94  assert(dum.size()<invalidI);
95  unsigned short j=0, i=0;
96  while (i<dum.size() && j<detIds.size()) {
97  if (dum[i]<detIds[j]) ++i;
98  else if (detIds[j]<dum[i]) {indices[j].ni=invalidI; ++j;}
99  else {
100  indices[j].ni=i; ++i; ++j;
101  }
102  }
103  unsigned int nn=0;
104  for(auto k=0U; k<detIds.size();++k) { if (indices[k].ni<invalidI) {++nn; assert(dum[indices[k].ni]==detIds[k]);}}
105  assert(nn<=dum.size());
106  COUT << "noise " << dum.size() << " " <<nn<< std::endl;
107  }
108  { //gain
109  std::vector<uint32_t> dum; gainHandle->getDetIds(dum);
110  assert(dum.size()<invalidI);
111  unsigned short j=0, i=0;
112  while (i<dum.size() && j<detIds.size()) {
113  if (dum[i]<detIds[j]) ++i;
114  else if (detIds[j]<dum[i]) {indices[j].gi=invalidI; ++j;}
115  else {
116  indices[j].gi=i; ++i; ++j;
117  }
118  }
119  unsigned int nn=0;
120  for(auto k=0U; k<detIds.size();++k) { if (indices[k].gi<invalidI) {++nn; assert(dum[indices[k].gi]==detIds[k]);}}
121  assert(nn<=dum.size());
122  COUT << "gain " << dum.size() << " " <<nn<< std::endl;
123  }
124  }
125 
126 }
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
int k[5][pyjets_maxn]
void getDetIds(std::vector< uint32_t > &DetIds_) const
SiStripDetCabling const * cabling() const
T get() const
Definition: EventSetup.h:71
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
bool StripClusterizerAlgorithm::isModuleBad ( const uint32_t &  id) const
inlineprotected

Definition at line 88 of file StripClusterizerAlgorithm.h.

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

88 { 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 89 of file StripClusterizerAlgorithm.h.

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

89 { 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 67 of file StripClusterizerAlgorithm.h.

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

Reimplemented in ThreeThresholdAlgorithm.

Definition at line 71 of file StripClusterizerAlgorithm.h.

71 {}
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 68 of file StripClusterizerAlgorithm.h.

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

Reimplemented in ThreeThresholdAlgorithm.

Definition at line 72 of file StripClusterizerAlgorithm.h.

72 {}

Member Data Documentation

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

Definition at line 110 of file StripClusterizerAlgorithm.h.

Referenced by initialize().

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

Definition at line 109 of file StripClusterizerAlgorithm.h.

Referenced by findDetId(), and initialize().

uint32_t StripClusterizerAlgorithm::gain_cache_id
private

Definition at line 116 of file StripClusterizerAlgorithm.h.

Referenced by initialize().

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

Definition at line 112 of file StripClusterizerAlgorithm.h.

Referenced by findDetId(), and initialize().

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

Definition at line 111 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 116 of file StripClusterizerAlgorithm.h.

Referenced by initialize().

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

Definition at line 113 of file StripClusterizerAlgorithm.h.

Referenced by findDetId(), and initialize().

uint32_t StripClusterizerAlgorithm::quality_cache_id
private

Definition at line 116 of file StripClusterizerAlgorithm.h.

Referenced by initialize().

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

Definition at line 114 of file StripClusterizerAlgorithm.h.

Referenced by findDetId(), and initialize().

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

Definition at line 115 of file StripClusterizerAlgorithm.h.

Referenced by initialize().