test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  {
19  if (dynamic_cast<const StripGeomDetUnit*>(gdet) == 0) {
20  throw MeasurementDetException( "TkStripMeasurementDet constructed with a GeomDet which is not a StripGeomDetUnit");
21  }
22  }
23 
24 
25 // fast check if the det contains any useful cluster
27  if unlikely( (!isActive(data)) || isEmpty(data.stripData())) return true;
28 
29  const detset & detSet = data.stripData().detSet(index());
30  for ( auto ci = detSet.begin(); ci != detSet.end(); ++ ci ) {
31  if (isMasked(*ci)) 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 
39 
42 {
44  if unlikely( (!isActive(data)) || isEmpty(data.stripData())) return result;
45  const detset & detSet = data.stripData().detSet(index());
46  result.reserve(detSet.size());
47  for ( new_const_iterator ci = detSet.begin(); ci != detSet.end(); ++ ci ) {
48  if (isMasked(*ci)) 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 LogDebug("TkStripMeasurementDet")<<"skipping this str from last iteration on"<<rawId()<<" key: "<<cluster.key();
54  }
55  return result;
56 
57 }
58 
59 
60 // FIXME need to be merged with simpleRecHits
62  const TrajectoryStateOnSurface& stateOnThisDet,
63  const MeasurementEstimator& est, const MeasurementTrackerEvent & data) const {
64  if unlikely( (!isActive(data)) || isEmpty(data.stripData())) return false;
65  auto oldSize = result.size();
66 
67  int utraj = specificGeomDet().specificTopology().measurementPosition( stateOnThisDet.localPosition()).x();
68  const detset & detSet = data.stripData().detSet(index());
69  auto const & cpepar = cpe()->getAlgoParam(specificGeomDet(),stateOnThisDet.localParameters());
70 
71  auto rightCluster =
72  std::find_if( detSet.begin(), detSet.end(), [utraj](const SiStripCluster& hit) { return hit.firstStrip() > utraj; });
73 
74 
75  std::vector<SiStripRecHit2D> tmp;
76  if ( rightCluster != detSet.begin()) {
77  // there are hits on the left of the utraj
78  auto leftCluster = rightCluster;
79  while ( --leftCluster >= detSet.begin()) {
80  SiStripClusterRef clusterref = detSet.makeRefTo( data.stripData().handle(), leftCluster);
81  bool isCompatible = filteredRecHits(clusterref, cpepar, stateOnThisDet, est, data.stripClustersToSkip(), tmp);
82  if(!isCompatible) break; // exit loop on first incompatible hit
83  for (auto && h: tmp) result.push_back(new SiStripRecHit2D(std::move(h))); tmp.clear();
84  }
85  }
86  for ( ; rightCluster != detSet.end(); rightCluster++) {
87  SiStripClusterRef clusterref = detSet.makeRefTo( data.stripData().handle(), rightCluster);
88  bool isCompatible = filteredRecHits(clusterref, cpepar, stateOnThisDet, est, data.stripClustersToSkip(), tmp);
89  if(!isCompatible) break; // exit loop on first incompatible hit
90  for (auto && h: tmp) result.push_back(new SiStripRecHit2D(std::move(h))); tmp.clear();
91  }
92 
93  return result.size()>oldSize;
94 }
95 
96 
97 
98 
101  std::vector<SiStripRecHit2D> &result) const {
102  if unlikely( (!isActive(data)) || isEmpty(data.stripData())) return false;
103 
104  auto oldSize = result.size();
105 
106  int utraj = specificGeomDet().specificTopology().measurementPosition( stateOnThisDet.localPosition()).x();
107  const detset & detSet = data.stripData().detSet(index());
108  auto const & cpepar = cpe()->getAlgoParam(specificGeomDet(),stateOnThisDet.localParameters());
109 
110  auto rightCluster =
111  std::find_if( detSet.begin(), detSet.end(), [utraj](const SiStripCluster& hit) { return hit.firstStrip() > utraj; });
112 
113  if ( rightCluster != detSet.begin()) {
114  // there are hits on the left of the utraj
115  auto leftCluster = rightCluster;
116  while ( --leftCluster >= detSet.begin()) {
117  SiStripClusterRef clusterref = detSet.makeRefTo( data.stripData().handle(), leftCluster);
118  bool isCompatible = filteredRecHits(clusterref, cpepar, stateOnThisDet, est, data.stripClustersToSkip(), result);
119  if(!isCompatible) break; // exit loop on first incompatible hit
120  }
121  }
122  for ( ; rightCluster != detSet.end(); rightCluster++) {
123  SiStripClusterRef clusterref = detSet.makeRefTo( data.stripData().handle(), rightCluster);
124  bool isCompatible = filteredRecHits(clusterref, cpepar, stateOnThisDet, est, data.stripClustersToSkip(), result);
125  if(!isCompatible) break; // exit loop on first incompatible hit
126  }
127 
128  return result.size()>oldSize;
129 }
130 
131 
132 
133 bool
135  RecHitContainer & result, std::vector<float> & diffs ) const {
136  if unlikely( (!isActive(data)) || isEmpty(data.stripData())) return false;
137 
138  auto oldSize = result.size();
139  auto const & cpepar = cpe()->getAlgoParam(specificGeomDet(),stateOnThisDet.localParameters());
140 
141  int utraj = specificGeomDet().specificTopology().measurementPosition( stateOnThisDet.localPosition()).x();
142 
143  const detset & detSet = data.stripData().detSet(index());
144  auto rightCluster =
145  std::find_if( detSet.begin(), detSet.end(), [utraj](const SiStripCluster& hit) { return hit.firstStrip() > utraj; });
146 
147  if ( rightCluster != detSet.begin()) {
148  // there are hits on the left of the utraj
149  auto leftCluster = rightCluster;
150  while ( --leftCluster >= detSet.begin()) {
151  SiStripClusterRef clusterref = detSet.makeRefTo( data.stripData().handle(), leftCluster);
152  bool isCompatible = filteredRecHits(clusterref, cpepar, stateOnThisDet, est, data.stripClustersToSkip(), result, diffs);
153  if(!isCompatible) break; // exit loop on first incompatible hit
154  }
155  }
156  for ( ; rightCluster != detSet.end(); rightCluster++) {
157  SiStripClusterRef clusterref = detSet.makeRefTo( data.stripData().handle(), rightCluster);
158  bool isCompatible = filteredRecHits(clusterref, cpepar, stateOnThisDet, est, data.stripClustersToSkip(), result,diffs);
159  if(!isCompatible) break; // exit loop on first incompatible hit
160  }
161 
162  return result.size()>oldSize;
163 }
164 
167  TempMeasurements & result) const {
168 
169  if (!isActive(data)) {
170  LogDebug("TkStripMeasurementDet")<<" found an inactive module "<<rawId();
171  result.add(theInactiveHit, 0.F);
172  return true;
173  }
174 
175  if (!isEmpty(data.stripData())){
176  LogDebug("TkStripMeasurementDet")<<" found hit on this module "<<rawId();
178  std::vector<float> diffs;
179  if (recHits(stateOnThisDet,est,data,result.hits,result.distances)) return true;
180  }
181 
182 
183  // create a TrajectoryMeasurement with an invalid RecHit and zero estimate
184 
185  if (!stateOnThisDet.hasError()) {
186  result.add(theMissingHit, 0.F);
187  return false;
188  }
189 
190  float utraj = specificGeomDet().specificTopology().measurementPosition( stateOnThisDet.localPosition()).x();
191  float uerr= sqrt(specificGeomDet().specificTopology().measurementError(stateOnThisDet.localPosition(),stateOnThisDet.localError().positionError()).uu());
192  if (testStrips(utraj,uerr)) {
193  //LogDebug("TkStripMeasurementDet") << " DetID " << id_ << " empty after search, but active ";
194  result.add(theMissingHit, 0.F);
195  return false;
196  }
197 
198  //LogDebug("TkStripMeasurementDet") << " DetID " << id_ << " empty after search, and inactive ";
199  result.add(theInactiveHit, 0.F);
200  return true;
201 
202 }
203 
204 
205 
206 
207 
208 
209 
210 void
212 {
213  if (isEmpty(data.stripData()) || !isActive(data)) return;
214 
215  const detset & detSet = data.stripData().detSet(index());
217  assert(clusters.size()==0);
218  for (auto const & ci : detSet) {
219  if (isMasked(ci)) continue;
220  if (accept(detSet.makeKeyOf(&ci), data.stripClustersToSkip()))
221  clusters.push_back(&ci);
222  else LogDebug("TkStripMeasurementDet")<<"skipping this str from last iteration on"<<rawId()<<" key: "<<detSet.makeKeyOf(&ci);
223  }
224  if (!clusters.empty()) buildSimpleRecHits(clusters, data, detSet, ts,result);
225 
226 }
227 
228 
229 
230 std::tuple<TkStripRecHitIter,TkStripRecHitIter>
232 {
233  if (isEmpty(data.stripData()) || !isActive(data)) return std::tuple<TkStripRecHitIter,TkStripRecHitIter>();
234  const detset & detSet = data.stripData().detSet(index());
235  return std::make_tuple(TkStripRecHitIter(detSet.begin(),detSet.end(),*this,ts,data),
236  TkStripRecHitIter(detSet.end(),detSet.end(),*this,ts,data)
237  );
238 }
239 
241  while (!hi.empty()) {
242  auto ci = hi.clusterI;
243  auto const & data = *hi.data;
244  if (isMasked(*ci)) continue;
245  SiStripClusterRef cluster = edmNew::makeRefTo( data.stripData().handle(), ci );
246  if (accept(cluster, data.stripClustersToSkip())) return;
247  ++hi.clusterI;
248  }
249 }
250 
252  const GeomDetUnit& gdu( specificGeomDet());
253  auto ci = hi.clusterI;
254  auto const & data = *hi.data;
255  auto const & ltp = *hi.tsos;
256 
257  SiStripClusterRef cluster = edmNew::makeRefTo( data.stripData().handle(), ci );
258  LocalValues lv = cpe()->localParameters( *cluster, gdu, ltp);
259  return SiStripRecHit2D(lv.first,lv.second, gdu, cluster);
260 }
261 
262 bool
263 TkStripMeasurementDet::testStrips(float utraj, float uerr) const {
264  int16_t start = (int16_t) std::max<float>(utraj - 3.f*uerr, 0);
265  int16_t end = (int16_t) std::min<float>(utraj + 3.f*uerr, totalStrips());
266 
267  if (start >= end) { // which means either end <=0 or start >= totalStrips_
268  /* LogDebug("TkStripMeasurementDet") << "Testing module " << id_ <<","<<
269  " U = " << utraj << " +/- " << uerr <<
270  "; Range [" << (utraj - 3*uerr) << ", " << (utraj + 3*uerr) << "] " <<
271  ": YOU'RE COMPLETELY OFF THE MODULE."; */
272  //return false;
273  return true; // Wolfgang thinks this way is better
274  // and solves some problems with grouped ckf
275  }
276 
277  typedef std::vector<BadStripBlock>::const_iterator BSBIT;
278 
279  int16_t bad = 0, largestBadBlock = 0;
280  for (BSBIT bsbc = badStripBlocks().begin(), bsbe = badStripBlocks().end(); bsbc != bsbe; ++bsbc) {
281  if (bsbc->last < start) continue;
282  if (bsbc->first > end) break;
283  int16_t thisBad = std::min(bsbc->last, end) - std::max(bsbc->first, start);
284  if (thisBad > largestBadBlock) largestBadBlock = thisBad;
285  bad += thisBad;
286  }
287 
288  bool ok = (bad < (end-start)) &&
289  (uint16_t(bad) <= badStripCuts().maxBad) &&
290  (uint16_t(largestBadBlock) <= badStripCuts().maxConsecutiveBad);
291 
292 // if (bad) {
293 // edm::LogWarning("TkStripMeasurementDet") << "Testing module " << id_ <<" (subdet: "<< SiStripDetId(id_).subdetId() << ")" <<
294 // " U = " << utraj << " +/- " << uerr <<
295 // "; Range [" << (utraj - 3*uerr) << ", " << (utraj + 3*uerr) << "] " <<
296 // "= [" << start << "," << end << "]" <<
297 // " total strips:" << (end-start) << ", good:" << (end-start-bad) << ", bad:" << bad << ", largestBadBlock: " << largestBadBlock <<
298 // ". " << (ok ? "OK" : "NO");
299 // }
300  return ok;
301 }
302 
#define LogDebug(id)
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)
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
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
const StripDetset & detSet(int i) const
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
const TrajectoryStateOnSurface * tsos
const LocalTrajectoryParameters & localParameters() const
std::tuple< TkStripRecHitIter, TkStripRecHitIter > hitRange(const TrajectoryStateOnSurface &, const MeasurementTrackerEvent &data) const
bool empty(const MeasurementTrackerEvent &data) const
StripClusterParameterEstimator::LocalValues LocalValues
assert(m_qm.get())
TkStripMeasurementDet(const GeomDet *gdet, StMeasurementConditionSet &conditionSet)
BadStripCuts const & badStripCuts() const
void simpleRecHits(const TrajectoryStateOnSurface &ts, const MeasurementTrackerEvent &data, std::vector< SiStripRecHit2D > &result) const
key_type key() const
Accessor for product key.
Definition: Ref.h:264
bool accept(SiStripClusterRef const &r, const std::vector< bool > &skipClusters) const
const StMeasurementDetSet & stripData() const
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
const std::vector< bool > & stripClustersToSkip() const
LocalError positionError() const
bool isMasked(const SiStripCluster &cluster) const
SiStripRecHit2D hit(TkStripRecHitIter const &hi) const
tuple result
Definition: mps_fire.py:84
TrackingRecHit::ConstRecHitPointer theMissingHit
const MeasurementTrackerEvent * data
#define unlikely(x)
virtual RecHitContainer recHits(const TrajectoryStateOnSurface &, const MeasurementTrackerEvent &data) const
const StripCPE * cpe() const
virtual bool measurements(const TrajectoryStateOnSurface &stateOnThisDet, const MeasurementEstimator &est, const MeasurementTrackerEvent &data, TempMeasurements &result) const
T sqrt(T t)
Definition: SSEVec.h:18
void add(ConstRecHitPointer const &h, float d)
std::vector< BadStripBlock > const & badStripBlocks() const
#define unInitDynArray(T, n, x)
Definition: DynArray.h:57
def move
Definition: eostools.py:510
double f[11][100]
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
#define end
Definition: vmac.h:37
T min(T a, T b)
Definition: MathUtil.h:58
const LocalTrajectoryError & localError() const
AlgoParam getAlgoParam(const GeomDetUnit &det, const LocalTrajectoryParameters &ltp) const
Definition: StripCPE.h:55
void advance(TkStripRecHitIter &hi) const
StripClusterParameterEstimator::LocalValues localParameters(const SiStripCluster &cl, const GeomDetUnit &) const override
Definition: StripCPE.cc:65
TrackingRecHit::RecHitPointer buildRecHit(const ClusterRefT &cluster, const TrajectoryStateOnSurface &ltp) const
TrackingRecHit::ConstRecHitPointer theInactiveHit
T value_type
Definition: DynArray.h:11
bool isActive(const MeasurementTrackerEvent &data) const
Is this module active in reconstruction? It must be both &#39;setActiveThisEvent&#39; and &#39;setActive&#39;...
const StripGeomDetUnit & specificGeomDet() const
bool isEmpty(const StMeasurementDetSet &theDets) const
new_const_iterator clusterI
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
TrackingRecHit::ConstRecHitContainer RecHitContainer
std::vector< BaseTrackerRecHit * > SimpleHitContainer
const detset & detSet(const StMeasurementDetSet &theDets) const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
iterator end()
Definition: DetSetNew.h:70
detset::const_iterator new_const_iterator
bool testStrips(float utraj, float uerr) const
return true if there are &#39;enough&#39; good strips in the utraj +/- 3 uerr range.
unsigned int rawId() const
void buildSimpleRecHits(AClusters const &clusters, const MeasurementTrackerEvent &data, const detset &detSet, const TrajectoryStateOnSurface &ltp, std::vector< SiStripRecHit2D > &res) const
edm::Handle< edmNew::DetSetVector< SiStripCluster > > & handle()
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:95
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:281
size_type size() const
Definition: DetSetNew.h:87
iterator begin()
Definition: DetSetNew.h:67