CMS 3D CMS Logo

TkStripMeasurementDet.cc
Go to the documentation of this file.
10 
11 #include <typeinfo>
14 #include <cassert>
15 
17  : MeasurementDet(gdet), index_(-1), theDetConditions(&conditions) {
18  if (dynamic_cast<const StripGeomDetUnit*>(gdet) == nullptr) {
19  throw MeasurementDetException("TkStripMeasurementDet constructed with a GeomDet which is not a StripGeomDetUnit");
20  }
21 }
22 
23 // fast check if the det contains any useful cluster
25  if
26  UNLIKELY((!isActive(data)) || isEmpty(data.stripData())) return true;
27 
28  const detset& detSet = data.stripData().detSet(index());
29  for (auto ci = detSet.begin(); ci != detSet.end(); ++ci) {
30  if (isMasked(*ci))
31  continue;
32  SiStripClusterRef cluster = detSet.makeRefTo(data.stripData().handle(), ci);
33  if (accept(cluster, data.stripClustersToSkip()))
34  return false;
35  }
36  return true;
37 }
38 
40  const MeasurementTrackerEvent& data) const {
42  if
43  UNLIKELY((!isActive(data)) || isEmpty(data.stripData())) return result;
44  const detset& detSet = data.stripData().detSet(index());
45  result.reserve(detSet.size());
46  for (new_const_iterator ci = detSet.begin(); ci != detSet.end(); ++ci) {
47  if (isMasked(*ci))
48  continue;
49  // for ( ClusterIterator ci=theClusterRange.first; ci != theClusterRange.second; ci++) {
50  SiStripClusterRef cluster = detSet.makeRefTo(data.stripData().handle(), ci);
51  if (accept(cluster, data.stripClustersToSkip()))
52  result.push_back(buildRecHit(cluster, ts));
53  else
54  LogDebug("TkStripMeasurementDet") << "skipping this str from last iteration on" << rawId()
55  << " key: " << cluster.key();
56  }
57  return result;
58 }
59 
60 // FIXME need to be merged with simpleRecHits
62  const TrajectoryStateOnSurface& stateOnThisDet,
63  const MeasurementEstimator& est,
64  const MeasurementTrackerEvent& data) const {
65  if
66  UNLIKELY((!isActive(data)) || isEmpty(data.stripData())) return false;
67  auto oldSize = result.size();
68 
69  int utraj = specificGeomDet().specificTopology().measurementPosition(stateOnThisDet.localPosition()).x();
70  const detset& detSet = data.stripData().detSet(index());
71  auto const& cpepar = cpe()->getAlgoParam(specificGeomDet(), stateOnThisDet.localParameters());
72 
73  auto rightCluster = std::find_if(
74  detSet.begin(), detSet.end(), [utraj](const SiStripCluster& hit) { return hit.firstStrip() > utraj; });
75 
76  std::vector<SiStripRecHit2D> tmp;
77  if (rightCluster != detSet.begin()) {
78  // there are hits on the left of the utraj
79  auto leftCluster = rightCluster;
80  while (--leftCluster >= detSet.begin()) {
81  SiStripClusterRef clusterref = detSet.makeRefTo(data.stripData().handle(), leftCluster);
82  bool isCompatible = filteredRecHits(clusterref, cpepar, stateOnThisDet, est, data.stripClustersToSkip(), tmp);
83  if (!isCompatible)
84  break; // exit loop on first incompatible hit
85  for (auto&& h : tmp)
86  result.push_back(new SiStripRecHit2D(std::move(h)));
87  tmp.clear();
88  }
89  }
90  for (; rightCluster != detSet.end(); rightCluster++) {
91  SiStripClusterRef clusterref = detSet.makeRefTo(data.stripData().handle(), rightCluster);
92  bool isCompatible = filteredRecHits(clusterref, cpepar, stateOnThisDet, est, data.stripClustersToSkip(), tmp);
93  if (!isCompatible)
94  break; // exit loop on first incompatible hit
95  for (auto&& h : tmp)
96  result.push_back(new SiStripRecHit2D(std::move(h)));
97  tmp.clear();
98  }
99 
100  return result.size() > oldSize;
101 }
102 
104  const MeasurementEstimator& est,
106  std::vector<SiStripRecHit2D>& result) const {
107  if
108  UNLIKELY((!isActive(data)) || isEmpty(data.stripData())) return false;
109 
110  auto oldSize = result.size();
111 
112  int utraj = specificGeomDet().specificTopology().measurementPosition(stateOnThisDet.localPosition()).x();
113  const detset& detSet = data.stripData().detSet(index());
114  auto const& cpepar = cpe()->getAlgoParam(specificGeomDet(), stateOnThisDet.localParameters());
115 
116  auto rightCluster = std::find_if(
117  detSet.begin(), detSet.end(), [utraj](const SiStripCluster& hit) { return hit.firstStrip() > utraj; });
118 
119  if (rightCluster != detSet.begin()) {
120  // there are hits on the left of the utraj
121  auto leftCluster = rightCluster;
122  while (--leftCluster >= detSet.begin()) {
123  SiStripClusterRef clusterref = detSet.makeRefTo(data.stripData().handle(), leftCluster);
124  bool isCompatible = filteredRecHits(clusterref, cpepar, stateOnThisDet, est, data.stripClustersToSkip(), result);
125  if (!isCompatible)
126  break; // exit loop on first incompatible hit
127  }
128  }
129  for (; rightCluster != detSet.end(); rightCluster++) {
130  SiStripClusterRef clusterref = detSet.makeRefTo(data.stripData().handle(), rightCluster);
131  bool isCompatible = filteredRecHits(clusterref, cpepar, stateOnThisDet, est, data.stripClustersToSkip(), result);
132  if (!isCompatible)
133  break; // exit loop on first incompatible hit
134  }
135 
136  return result.size() > oldSize;
137 }
138 
140  const MeasurementEstimator& est,
143  std::vector<float>& diffs) const {
144  if
145  UNLIKELY((!isActive(data)) || isEmpty(data.stripData())) return false;
146 
147  auto oldSize = result.size();
148  auto const& cpepar = cpe()->getAlgoParam(specificGeomDet(), stateOnThisDet.localParameters());
149 
150  int utraj = specificGeomDet().specificTopology().measurementPosition(stateOnThisDet.localPosition()).x();
151 
152  const detset& detSet = data.stripData().detSet(index());
153  auto rightCluster = std::find_if(
154  detSet.begin(), detSet.end(), [utraj](const SiStripCluster& hit) { return hit.firstStrip() > utraj; });
155 
156  if (rightCluster != detSet.begin()) {
157  // there are hits on the left of the utraj
158  auto leftCluster = rightCluster;
159  while (--leftCluster >= detSet.begin()) {
160  SiStripClusterRef clusterref = detSet.makeRefTo(data.stripData().handle(), leftCluster);
161  bool isCompatible =
162  filteredRecHits(clusterref, cpepar, stateOnThisDet, est, data.stripClustersToSkip(), result, diffs);
163  if (!isCompatible)
164  break; // exit loop on first incompatible hit
165  }
166  }
167  for (; rightCluster != detSet.end(); rightCluster++) {
168  SiStripClusterRef clusterref = detSet.makeRefTo(data.stripData().handle(), rightCluster);
169  bool isCompatible =
170  filteredRecHits(clusterref, cpepar, stateOnThisDet, est, data.stripClustersToSkip(), result, diffs);
171  if (!isCompatible)
172  break; // exit loop on first incompatible hit
173  }
174 
175  return result.size() > oldSize;
176 }
177 
179  const MeasurementEstimator& est,
181  TempMeasurements& result) const {
182  if (!isActive(data)) {
183  LogDebug("TkStripMeasurementDet") << " found an inactive module " << rawId();
184  result.add(theInactiveHit, 0.F);
185  return true;
186  }
187 
188  if (!isEmpty(data.stripData())) {
189  LogDebug("TkStripMeasurementDet") << " found hit on this module " << rawId();
191  std::vector<float> diffs;
192  if (recHits(stateOnThisDet, est, data, result.hits, result.distances))
193  return true;
194  }
195 
196  // create a TrajectoryMeasurement with an invalid RecHit and zero estimate
197 
198  if (!stateOnThisDet.hasError()) {
199  result.add(theMissingHit, 0.F);
200  return false;
201  }
202 
203  float utraj = specificGeomDet().specificTopology().measurementPosition(stateOnThisDet.localPosition()).x();
204  float uerr = sqrt(specificGeomDet()
205  .specificTopology()
206  .measurementError(stateOnThisDet.localPosition(), stateOnThisDet.localError().positionError())
207  .uu());
208  if (testStrips(utraj, uerr)) {
209  //LogDebug("TkStripMeasurementDet") << " DetID " << id_ << " empty after search, but active ";
210  result.add(theMissingHit, 0.F);
211  return false;
212  }
213 
214  //LogDebug("TkStripMeasurementDet") << " DetID " << id_ << " empty after search, and inactive ";
215  result.add(theInactiveHit, 0.F);
216  return true;
217 }
218 
221  std::vector<SiStripRecHit2D>& result) const {
222  if (isEmpty(data.stripData()) || !isActive(data))
223  return;
224 
225  const detset& detSet = data.stripData().detSet(index());
227  assert(clusters.empty());
228  for (auto const& ci : detSet) {
229  if (isMasked(ci))
230  continue;
231  if (accept(detSet.makeKeyOf(&ci), data.stripClustersToSkip()))
232  clusters.push_back(&ci);
233  else
234  LogDebug("TkStripMeasurementDet") << "skipping this str from last iteration on" << rawId()
235  << " key: " << detSet.makeKeyOf(&ci);
236  }
237  if (!clusters.empty())
239 }
240 
241 std::tuple<TkStripRecHitIter, TkStripRecHitIter> TkStripMeasurementDet::hitRange(
242  const TrajectoryStateOnSurface& ts, const MeasurementTrackerEvent& data) const {
243  if (isEmpty(data.stripData()) || !isActive(data))
244  return std::tuple<TkStripRecHitIter, TkStripRecHitIter>();
245  const detset& detSet = data.stripData().detSet(index());
246  return std::make_tuple(TkStripRecHitIter(detSet.begin(), detSet.end(), *this, ts, data),
247  TkStripRecHitIter(detSet.end(), detSet.end(), *this, ts, data));
248 }
249 
251  while (!hi.empty()) {
252  auto ci = hi.clusterI;
253  auto const& data = *hi.data;
254  if (isMasked(*ci))
255  continue;
256  SiStripClusterRef cluster = edmNew::makeRefTo(data.stripData().handle(), ci);
257  if (accept(cluster, data.stripClustersToSkip()))
258  return;
259  ++hi.clusterI;
260  }
261 }
262 
264  const GeomDetUnit& gdu(specificGeomDet());
265  auto ci = hi.clusterI;
266  auto const& data = *hi.data;
267  auto const& ltp = *hi.tsos;
268 
269  SiStripClusterRef cluster = edmNew::makeRefTo(data.stripData().handle(), ci);
270  LocalValues lv = cpe()->localParameters(*cluster, gdu, ltp);
271  return SiStripRecHit2D(lv.first, lv.second, gdu, cluster);
272 }
273 
274 bool TkStripMeasurementDet::testStrips(float utraj, float uerr) const {
275  int16_t start = (int16_t)std::max<float>(utraj - 3.f * uerr, 0);
276  int16_t end = (int16_t)std::min<float>(utraj + 3.f * uerr, totalStrips());
277 
278  if (start >= end) { // which means either end <=0 or start >= totalStrips_
279  /* LogDebug("TkStripMeasurementDet") << "Testing module " << id_ <<","<<
280  " U = " << utraj << " +/- " << uerr <<
281  "; Range [" << (utraj - 3*uerr) << ", " << (utraj + 3*uerr) << "] " <<
282  ": YOU'RE COMPLETELY OFF THE MODULE."; */
283  //return false;
284  return true; // Wolfgang thinks this way is better
285  // and solves some problems with grouped ckf
286  }
287 
288  typedef std::vector<BadStripBlock>::const_iterator BSBIT;
289 
290  int16_t bad = 0, largestBadBlock = 0;
291  for (BSBIT bsbc = badStripBlocks().begin(), bsbe = badStripBlocks().end(); bsbc != bsbe; ++bsbc) {
292  if (bsbc->last < start)
293  continue;
294  if (bsbc->first > end)
295  break;
296  int16_t thisBad = std::min(bsbc->last, end) - std::max(bsbc->first, start);
297  if (thisBad > largestBadBlock)
298  largestBadBlock = thisBad;
299  bad += thisBad;
300  }
301 
302  bool ok = (bad < (end - start)) && (uint16_t(bad) <= badStripCuts().maxBad) &&
303  (uint16_t(largestBadBlock) <= badStripCuts().maxConsecutiveBad);
304 
305  // if (bad) {
306  // edm::LogWarning("TkStripMeasurementDet") << "Testing module " << id_ <<" (subdet: "<< SiStripDetId(id_).subdetId() << ")" <<
307  // " U = " << utraj << " +/- " << uerr <<
308  // "; Range [" << (utraj - 3*uerr) << ", " << (utraj + 3*uerr) << "] " <<
309  // "= [" << start << "," << end << "]" <<
310  // " total strips:" << (end-start) << ", good:" << (end-start-bad) << ", bad:" << bad << ", largestBadBlock: " << largestBadBlock <<
311  // ". " << (ok ? "OK" : "NO");
312  // }
313  return ok;
314 }
TkStripMeasurementDet::measurements
bool measurements(const TrajectoryStateOnSurface &stateOnThisDet, const MeasurementEstimator &est, const MeasurementTrackerEvent &data, TempMeasurements &result) const override
Definition: TkStripMeasurementDet.cc:178
TrajMeasLessEstim.h
MeasurementEstimator
Definition: MeasurementEstimator.h:19
TkStripMeasurementDet::index
int index() const
Definition: TkStripMeasurementDet.h:96
TkStripMeasurementDet::totalStrips
int totalStrips() const
Definition: TkStripMeasurementDet.h:256
DynArray::value_type
T value_type
Definition: DynArray.h:12
TkStripMeasurementDet::simpleRecHits
void simpleRecHits(const TrajectoryStateOnSurface &ts, const MeasurementTrackerEvent &data, std::vector< SiStripRecHit2D > &result) const
Definition: TkStripMeasurementDet.cc:219
start
Definition: start.py:1
MessageLogger.h
TkStripMeasurementDet::rawId
unsigned int rawId() const
Definition: TkStripMeasurementDet.h:98
GeomDet
Definition: GeomDet.h:27
TkStripMeasurementDet::specificGeomDet
const StripGeomDetUnit & specificGeomDet() const
Definition: TkStripMeasurementDet.h:147
MeasurementDet::RecHitContainer
TrackingRecHit::ConstRecHitContainer RecHitContainer
Definition: MeasurementDet.h:19
StMeasurementConditionSet::BadStripCuts::maxConsecutiveBad
uint16_t maxConsecutiveBad
Definition: TkMeasurementDetSet.h:52
LocalTrajectoryError::positionError
LocalError positionError() const
Definition: LocalTrajectoryError.h:81
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
TkStripMeasurementDet::empty
bool empty(const MeasurementTrackerEvent &data) const
Definition: TkStripMeasurementDet.cc:24
min
T min(T a, T b)
Definition: MathUtil.h:58
TkStripMeasurementDet::buildRecHit
TrackingRecHit::RecHitPointer buildRecHit(const ClusterRefT &cluster, const TrajectoryStateOnSurface &ltp) const
Definition: TkStripMeasurementDet.h:150
TkStripMeasurementDet::buildSimpleRecHits
void buildSimpleRecHits(AClusters const &clusters, const MeasurementTrackerEvent &data, const detset &detSet, const TrajectoryStateOnSurface &ltp, std::vector< SiStripRecHit2D > &res) const
Definition: TkStripMeasurementDet.h:263
StMeasurementConditionSet
Definition: TkMeasurementDetSet.h:38
TkStripMeasurementDet::badStripCuts
BadStripCuts const & badStripCuts() const
Definition: TkStripMeasurementDet.h:257
edmNew::makeRefTo
edm::Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefTo(const HandleT &iHandle, typename HandleT::element_type::value_type::const_iterator itIter)
Definition: DetSetVectorNew.h:735
TkStripMeasurementDet::accept
bool accept(SiStripClusterRef const &r, const std::vector< bool > &skipClusters) const
Definition: TkStripMeasurementDet.h:277
MeasurementDetException.h
cms::cuda::assert
assert(be >=bs)
SiStripDetId.h
SiStripRecHit2D
Definition: SiStripRecHit2D.h:7
TrajectoryMeasurement.h
TkStripMeasurementDet::hit
SiStripRecHit2D hit(TkStripRecHitIter const &hi) const
Definition: TkStripMeasurementDet.cc:263
MeasurementDet
Definition: MeasurementDet.h:16
DDAxes::x
TkStripMeasurementDet::isActive
bool isActive(const MeasurementTrackerEvent &data) const override
Is this module active in reconstruction? It must be both 'setActiveThisEvent' and 'setActive'.
Definition: TkStripMeasurementDet.h:105
StripTopology.h
TkStripMeasurementDet::new_const_iterator
detset::const_iterator new_const_iterator
Definition: TkStripMeasurementDet.h:82
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
tracking::TempMeasurements
Definition: TempMeasurements.h:10
end
#define end
Definition: vmac.h:39
edm::Ref
Definition: AssociativeIterator.h:58
TSiStripRecHit2DLocalPos.h
edmNew::DetSet::size
size_type size() const
Definition: DetSetNew.h:68
F
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
UNLIKELY
#define UNLIKELY(x)
Definition: Likely.h:21
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
edmNew::DetSet::end
iterator end()
Definition: DetSetNew.h:56
MeasurementDetException
Common base class.
Definition: MeasurementDetException.h:12
TrajectoryStateOnSurface::hasError
bool hasError() const
Definition: TrajectoryStateOnSurface.h:56
TkStripMeasurementDet::LocalValues
StripClusterParameterEstimator::LocalValues LocalValues
Definition: TkStripMeasurementDet.h:76
MeasurementEstimator.h
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
TkStripMeasurementDet::cpe
const StripCPE * cpe() const
Definition: TkStripMeasurementDet.h:253
edmNew::DetSet
Definition: DetSetNew.h:22
StMeasurementConditionSet::BadStripCuts::maxBad
uint16_t maxBad
Definition: TkMeasurementDetSet.h:52
h
StripCPE::getAlgoParam
AlgoParam getAlgoParam(const GeomDetUnit &det, const LocalTrajectoryParameters &ltp) const
Definition: StripCPE.h:57
TrajectoryStateOnSurface::localParameters
const LocalTrajectoryParameters & localParameters() const
Definition: TrajectoryStateOnSurface.h:73
bsc_activity_cfg.clusters
clusters
Definition: bsc_activity_cfg.py:36
TrajectoryStateOnSurface::localPosition
LocalPoint localPosition() const
Definition: TrajectoryStateOnSurface.h:74
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
MeasurementTrackerEvent
Definition: MeasurementTrackerEvent.h:15
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
TkStripMeasurementDet.h
MeasurementDet::SimpleHitContainer
std::vector< BaseTrackerRecHit * > SimpleHitContainer
Definition: MeasurementDet.h:21
TrackInfoProducer_cfi.rechits
rechits
Definition: TrackInfoProducer_cfi.py:9
edmNew::DetSet::makeRefTo
edm::Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefTo(HandleT const &handle, const_iterator ci) const
Definition: DetSetNew.h:73
TkStripMeasurementDet::detSet
const detset & detSet(const StMeasurementDetSet &theDets) const
Definition: TkStripMeasurementDet.h:102
edmNew::DetSet::begin
iterator begin()
Definition: DetSetNew.h:54
Topology::measurementPosition
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
TkStripMeasurementDet::filteredRecHits
bool filteredRecHits(const ClusterRefT &cluster, StripCPE::AlgoParam const &cpepar, const TrajectoryStateOnSurface &ltp, const MeasurementEstimator &est, const std::vector< bool > &skipClusters, RecHitContainer &result, std::vector< float > &diffs) const
Definition: TkStripMeasurementDet.h:168
TkStripMeasurementDet::isMasked
bool isMasked(const SiStripCluster &cluster) const
Definition: TkStripMeasurementDet.h:261
TkStripMeasurementDet::testStrips
bool testStrips(float utraj, float uerr) const
return true if there are 'enough' good strips in the utraj +/- 3 uerr range.
Definition: TkStripMeasurementDet.cc:274
TkStripRecHitIter
Definition: TkStripMeasurementDet.h:32
StripCPE::localParameters
StripClusterParameterEstimator::LocalValues localParameters(const SiStripCluster &cl, const GeomDetUnit &) const override
Definition: StripCPE.cc:66
hi
Definition: HiEvtPlaneList.h:38
TkStripMeasurementDet::advance
void advance(TkStripRecHitIter &hi) const
Definition: TkStripMeasurementDet.cc:250
eostools.move
def move(src, dest)
Definition: eostools.py:511
MeasurementDet::theInactiveHit
TrackingRecHit::ConstRecHitPointer theInactiveHit
Definition: MeasurementDet.h:95
edmNew::DetSet::makeKeyOf
unsigned int makeKeyOf(const_iterator ci) const
Definition: DetSetNew.h:79
TkStripMeasurementDet::recHits
RecHitContainer recHits(const TrajectoryStateOnSurface &, const MeasurementTrackerEvent &data) const override
Definition: TkStripMeasurementDet.cc:39
TkStripMeasurementDet::hitRange
std::tuple< TkStripRecHitIter, TkStripRecHitIter > hitRange(const TrajectoryStateOnSurface &, const MeasurementTrackerEvent &data) const
Definition: TkStripMeasurementDet.cc:241
TkStripMeasurementDet::badStripBlocks
std::vector< BadStripBlock > const & badStripBlocks() const
Definition: TkStripMeasurementDet.h:240
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
edm::Ref::key
key_type key() const
Accessor for product key.
Definition: Ref.h:250
StripGeomDetUnit::specificTopology
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
Definition: StripGeomDetUnit.cc:17
TkStripMeasurementDet::isEmpty
bool isEmpty(const StMeasurementDetSet &theDets) const
Definition: TkStripMeasurementDet.h:94
mps_fire.result
result
Definition: mps_fire.py:303
command_line.start
start
Definition: command_line.py:167
TkStripMeasurementDet::TkStripMeasurementDet
TkStripMeasurementDet(const GeomDet *gdet, StMeasurementConditionSet &conditionSet)
Definition: TkStripMeasurementDet.cc:16
TrajectoryStateOnSurface::localError
const LocalTrajectoryError & localError() const
Definition: TrajectoryStateOnSurface.h:77
SiStripCluster
Definition: SiStripCluster.h:9
SiStripRecHit2D.h
MeasurementDet::theMissingHit
TrackingRecHit::ConstRecHitPointer theMissingHit
Definition: MeasurementDet.h:94
unInitDynArray
#define unInitDynArray(T, n, x)
Definition: DynArray.h:88
hit
Definition: SiStripHitEffFromCalibTree.cc:88
InvalidTransientRecHit.h