CMS 3D CMS Logo

StripClusterizerAlgorithm.cc
Go to the documentation of this file.
2 
11 
12 // #define VIDEBUG
13 
14 #ifdef VIDEBUG
15 #define COUT std::cout
16 #else
17 #define COUT LogDebug("StripClusterizerAlgorithm")
18 #endif
19 
20 #include <string>
21 #include <algorithm>
22 #include <cassert>
23 
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) {
32  gain_cache_id = g_cache_id;
33  mod = true;
34  }
35  if (n_cache_id != noise_cache_id) {
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!
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 }
160 
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;
177  det.gainRange = gainHandle->getRangeByPos(indices[det.ind].gi);
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 }
195 
198 }
201 }
202 
204  : cms::Exception("Invalid Charge") {
205  std::stringstream s;
206  s << "Digi charge of " << digi.adc() << " ADC "
207  << "is out of range on strip " << digi.strip() << ". ";
208  this->append(s.str());
209 }
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
edm::DetSetVector< SiStripDigi >
SiStripGainRcd
Definition: SiStripDependentRecords.h:29
mps_fire.i
i
Definition: mps_fire.py:355
input
static const std::string input
Definition: EdmProvDump.cc:48
MessageLogger.h
StripClusterizerAlgorithm::cabling
SiStripDetCabling const * cabling() const
Definition: StripClusterizerAlgorithm.h:80
SiStripBadStrip::getRange
const Range getRange(const uint32_t detID) const
Definition: SiStripBadStrip.cc:27
StripClusterizerAlgorithm::qualityLabel
std::string qualityLabel
Definition: StripClusterizerAlgorithm.h:94
SiStripDetCabling::getDetCabling
const std::map< uint32_t, std::vector< const FedChannelConnection * > > & getDetCabling() const
Definition: SiStripDetCabling.h:33
StripClusterizerAlgorithm::clusterize_
void clusterize_(const T &input, output_t &output) const
Definition: StripClusterizerAlgorithm.h:98
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:32
StripClusterizerAlgorithm::connections
std::vector< std::vector< const FedChannelConnection * > > connections
Definition: StripClusterizerAlgorithm.h:111
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
mod
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
SiStripCommissioningClient_cfg.conn
conn
Definition: SiStripCommissioningClient_cfg.py:5
cms::cuda::assert
assert(be >=bs)
StripClusterizerAlgorithm::gain_cache_id
uint32_t gain_cache_id
Definition: StripClusterizerAlgorithm.h:117
StripClusterizerAlgorithm::quality_cache_id
uint32_t quality_cache_id
Definition: StripClusterizerAlgorithm.h:117
SiStripGainRcd.h
StripClusterizerAlgorithm::noise_cache_id
uint32_t noise_cache_id
Definition: StripClusterizerAlgorithm.h:117
SiStripNoises::getRange
const Range getRange(const uint32_t detID) const
Definition: SiStripNoises.cc:34
SiStripNoises::getDetIds
void getDetIds(std::vector< uint32_t > &DetIds_) const
Definition: SiStripNoises.cc:58
SiStripNoisesRcd
Definition: SiStripCondDataRecords.h:40
StripClusterizerAlgorithm::Det::noiseRange
SiStripNoises::Range noiseRange
Definition: StripClusterizerAlgorithm.h:37
StripClusterizerAlgorithm::Det::quality
SiStripQuality const * quality
Definition: StripClusterizerAlgorithm.h:35
StripClusterizerAlgorithm::qualityHandle
edm::ESHandle< SiStripQuality > qualityHandle
Definition: StripClusterizerAlgorithm.h:115
alignCSCRings.s
s
Definition: alignCSCRings.py:92
SiStripDetCabling.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
SiStripDetCabling::connected
const std::map< uint32_t, std::vector< int > > & connected() const
Definition: SiStripDetCabling.h:89
SiStripGain::getRangeByPos
SiStripApvGain::Range getRangeByPos(unsigned short pos) const
Definition: SiStripGain.h:72
SiStripGain::getRange
const SiStripApvGain::Range getRange(uint32_t detID) const
Definition: SiStripGain.h:71
StripClusterizerAlgorithm::Det
Definition: StripClusterizerAlgorithm.h:25
SiStripQualityRcd
Definition: SiStripDependentRecords.h:56
SiStripDigi.h
SiStripDigi::adc
const uint16_t & adc() const
Definition: SiStripDigi.h:34
StripClusterizerAlgorithm::Det::gainRange
SiStripApvGain::Range gainRange
Definition: StripClusterizerAlgorithm.h:36
SiStripGain::getDetIds
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
dqmdumpme.k
k
Definition: dqmdumpme.py:60
StripClusterizerAlgorithm::Det::ind
unsigned short ind
Definition: StripClusterizerAlgorithm.h:40
cms::Exception::append
void append(Exception const &another)
Definition: Exception.cc:153
b
double b
Definition: hdecay.h:118
StripClusterizerAlgorithm::indices
std::vector< Index > indices
Definition: StripClusterizerAlgorithm.h:112
cuda_std::lower_bound
__host__ constexpr __device__ RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
Definition: cudastdAlgorithm.h:27
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
edm::LogWarning
Definition: MessageLogger.h:141
StripClusterizerAlgorithm::findDetId
Det findDetId(const uint32_t) const
Definition: StripClusterizerAlgorithm.cc:161
SiStripDigi::strip
const uint16_t & strip() const
Definition: SiStripDigi.h:33
SiStripCluster.h
StripClusterizerAlgorithm::clusterize
void clusterize(const edm::DetSetVector< SiStripDigi > &, output_t &) const
Definition: StripClusterizerAlgorithm.cc:196
SiStripNoises::getRangeByPos
Range getRangeByPos(unsigned short pos) const
Definition: SiStripNoises.cc:48
StripClusterizerAlgorithm::Det::detId
uint32_t detId
Definition: StripClusterizerAlgorithm.h:39
Exception
StripClusterizerAlgorithm::noiseHandle
edm::ESHandle< SiStripNoises > noiseHandle
Definition: StripClusterizerAlgorithm.h:114
StripClusterizerAlgorithm::theCabling
SiStripDetCabling const * theCabling
Definition: StripClusterizerAlgorithm.h:116
StripClusterizerAlgorithm::invalidI
static constexpr unsigned short invalidI
Definition: StripClusterizerAlgorithm.h:22
SiStripBadStrip::getRangeByPos
Range getRangeByPos(unsigned short pos) const
Definition: SiStripBadStrip.cc:41
SiStripBadStrip::getDetIds
void getDetIds(std::vector< uint32_t > &DetIds_) const
Definition: SiStripBadStrip.cc:51
edm::EventSetup
Definition: EventSetup.h:57
StripClusterizerAlgorithm::detIds
std::vector< uint32_t > detIds
Definition: StripClusterizerAlgorithm.h:110
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
get
#define get
StripClusterizerAlgorithm::initialize
virtual void initialize(const edm::EventSetup &)
Definition: StripClusterizerAlgorithm.cc:24
Det
GeometricSearchDet Det
Definition: DetBelowR.h:8
groupFilesInBlocks.nn
nn
Definition: groupFilesInBlocks.py:150
edmNew::DetSetVector
Definition: DetSetNew.h:13
StripClusterizerAlgorithm::isModuleBad
bool isModuleBad(const uint32_t &id) const
Definition: StripClusterizerAlgorithm.h:91
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
StripClusterizerAlgorithm::isModuleUsable
bool isModuleUsable(const uint32_t &id) const
Definition: StripClusterizerAlgorithm.h:92
SiStripQualityRcd.h
EventSetup.h
SiStripDigi
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
Definition: SiStripDigi.h:12
SiStripNoisesRcd.h
StripClusterizerAlgorithm.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
StripClusterizerAlgorithm::gainHandle
edm::ESHandle< SiStripGain > gainHandle
Definition: StripClusterizerAlgorithm.h:113
SiStripQuality::cabling
const SiStripDetCabling * cabling() const
Definition: SiStripQuality.h:126
StripClusterizerAlgorithm::Det::qualityRange
SiStripQuality::Range qualityRange
Definition: StripClusterizerAlgorithm.h:38
StripClusterizerAlgorithm::InvalidChargeException::InvalidChargeException
InvalidChargeException(const SiStripDigi &)
Definition: StripClusterizerAlgorithm.cc:203
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
COUT
#define COUT
Definition: StripClusterizerAlgorithm.cc:17
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37