CMS 3D CMS Logo

TkPhase2OTMeasurementDet.cc
Go to the documentation of this file.
9 
11  : MeasurementDet(gdet), index_(0), theDetConditions(&conditions) {
12  if (dynamic_cast<const PixelGeomDetUnit*>(gdet) == nullptr) {
14  "TkPhase2OTMeasurementDet constructed with a GeomDet which is not a PixelGeomDetUnit");
15  }
16 }
17 
19  const MeasurementEstimator& est,
21  TempMeasurements& result) const {
22  if (!isActive(data)) {
23  result.add(theInactiveHit, 0.F);
24  return true;
25  }
26 
27  if (recHits(stateOnThisDet, est, data, result.hits, result.distances))
28  return true;
29 
30  // create a TrajectoryMeasurement with an invalid RecHit and zero estimate
31  bool inac = hasBadComponents(stateOnThisDet, data);
32  result.add(inac ? theInactiveHit : theMissingHit, 0.F);
33  return inac;
34 }
35 
37  const MeasurementEstimator& est,
40  std::vector<float>& diffs) const {
41  if UNLIKELY ((!isActive(data)) || isEmpty(data.phase2OTData()))
42  return false;
43 
44  auto oldSize = result.size();
45 
46  const detset& detSet = data.phase2OTData().detSet(index());
47  auto begin = &(data.phase2OTData().handle()->data().front());
48  auto reject = [&](auto ci) -> bool {
49  return (!data.phase2OTClustersToSkip().empty()) && data.phase2OTClustersToSkip()[ci - begin];
50  };
51 
53  auto firstCluster = detSet.begin();
54  auto lastCluster = detSet.end();
55 
56  // do not use this as it does not account for APE...
57  // auto xyLimits = est.maximalLocalDisplacement(stateOnThisDet,fastGeomDet().specificSurface());
58  auto le = stateOnThisDet.localError().positionError();
59  LocalError lape = static_cast<TrackerGeomDet const&>(fastGeomDet()).localAlignmentError();
60  auto ye = le.yy();
61  if (lape.valid()) {
62  ye += lape.yy();
63  }
64  // 5 sigma to be on the safe side
65  ye = 5.f * std::sqrt(ye);
66  LocalVector maxD(0, ye, 0);
67  // pixel topology is rectangular: x and y are independent
68  auto ymin = specificGeomDet().specificTopology().measurementPosition(stateOnThisDet.localPosition() - maxD);
69  auto ymax = specificGeomDet().specificTopology().measurementPosition(stateOnThisDet.localPosition() + maxD);
70  int utraj = ymin.x();
71  // do not apply for iteration not cutting on propagation
72  if (est.maxSagitta() >= 0) {
73  int colMin = ymin.y();
74  int colMax = ymax.y();
75  firstCluster = std::find_if(firstCluster, detSet.end(), [colMin](const Phase2TrackerCluster1D& hit) {
76  return int(hit.column()) >= colMin;
77  });
78  lastCluster = std::find_if(
79  firstCluster, detSet.end(), [colMax](const Phase2TrackerCluster1D& hit) { return int(hit.column()) > colMax; });
80  }
81 
82  while (firstCluster != lastCluster) { // loop on each column
83  auto const col = firstCluster->column();
84  auto endCluster = std::find_if(
85  firstCluster, detSet.end(), [col](const Phase2TrackerCluster1D& hit) { return hit.column() != col; });
86  // find trajectory position in this column
87  auto rightCluster = std::find_if(
88  firstCluster, endCluster, [utraj](const Phase2TrackerCluster1D& hit) { return int(hit.firstStrip()) > utraj; });
89  // search for compatible clusters...
90  if (rightCluster != firstCluster) {
91  // there are hits on the left of the utraj
92  auto leftCluster = rightCluster;
93  while (--leftCluster >= firstCluster) {
94  if (reject(leftCluster))
95  continue;
96  Phase2TrackerCluster1DRef cluster = detSet.makeRefTo(data.phase2OTData().handle(), leftCluster);
97  auto hit = buildRecHit(cluster, stateOnThisDet.localParameters());
98  auto diffEst = est.estimate(stateOnThisDet, *hit);
99  if (!diffEst.first)
100  break; // exit loop on first incompatible hit
101  result.push_back(hit);
102  diffs.push_back(diffEst.second);
103  }
104  }
105  for (; rightCluster != endCluster; rightCluster++) {
106  if (reject(rightCluster))
107  continue;
108  Phase2TrackerCluster1DRef cluster = detSet.makeRefTo(data.phase2OTData().handle(), rightCluster);
109  auto hit = buildRecHit(cluster, stateOnThisDet.localParameters());
110  auto diffEst = est.estimate(stateOnThisDet, *hit);
111  if (!diffEst.first)
112  break; // exit loop on first incompatible hit
113  result.push_back(hit);
114  diffs.push_back(diffEst.second);
115  }
116  firstCluster = endCluster;
117  } // loop over columns
118  return result.size() > oldSize;
119 }
120 
122  const LocalTrajectoryParameters& ltp) const {
123  const PixelGeomDetUnit& gdu(specificGeomDet());
124  auto&& params = cpe()->localParameters(*cluster, gdu);
125 
126  return std::make_shared<Phase2TrackerRecHit1D>(params.first, params.second, fastGeomDet(), cluster);
127 }
128 
130  const MeasurementTrackerEvent& data) const {
132  if (isEmpty(data.phase2OTData()))
133  return result;
134  if (!isActive(data))
135  return result;
136  const Phase2TrackerCluster1D* begin = nullptr;
137  if (!data.phase2OTData().handle()->data().empty()) {
138  begin = &(data.phase2OTData().handle()->data().front());
139  }
140  const detset& detSet = data.phase2OTData().detSet(index());
141  result.reserve(detSet.size());
142  for (const_iterator ci = detSet.begin(); ci != detSet.end(); ++ci) {
143  if (ci < begin) {
144  edm::LogError("IndexMisMatch") << "TkPhase2OTMeasurementDet cannot create hit because of index mismatch.";
145  return result;
146  }
147  unsigned int index = ci - begin;
148  if (!data.phase2OTClustersToSkip().empty() && index >= data.phase2OTClustersToSkip().size()) {
149  edm::LogError("IndexMisMatch") << "TkPhase2OTMeasurementDet cannot create hit because of index mismatch. i.e "
150  << index << " >= " << data.phase2OTClustersToSkip().size();
151  return result;
152  }
153  if (data.phase2OTClustersToSkip().empty() or (not data.phase2OTClustersToSkip()[index])) {
154  Phase2TrackerCluster1DRef cluster = detSet.makeRefTo(data.phase2OTData().handle(), ci);
155  result.push_back(buildRecHit(cluster, ts.localParameters()));
156  } else {
157  LogDebug("TkPhase2OTMeasurementDet") << "skipping this cluster from last iteration on "
158  << fastGeomDet().geographicalId().rawId() << " key: " << index;
159  }
160  }
161  return result;
162 }
163 
164 //FIXME:just temporary solution for phase2!
166  const MeasurementTrackerEvent& data) const {
167  /*
168  if (badRocPositions_.empty()) return false;
169  LocalPoint lp = tsos.localPosition();
170  LocalError le = tsos.localError().positionError();
171  double dx = 3*std::sqrt(le.xx()) + theRocWidth, dy = 3*std::sqrt(le.yy()) + theRocHeight;
172  for (std::vector<LocalPoint>::const_iterator it = badRocPositions_.begin(), ed = badRocPositions_.end(); it != ed; ++it) {
173  if ( (std::abs(it->x() - lp.x()) < dx) &&
174  (std::abs(it->y() - lp.y()) < dy) ) return true;
175  }
176 */
177  return false;
178 }
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:70
const LocalTrajectoryError & localError() const
TrackingRecHit::RecHitPointer buildRecHit(const Phase2TrackerCluster1DRef &cluster, const LocalTrajectoryParameters &ltp) const
bool valid() const
Definition: LocalError.h:20
TkPhase2OTMeasurementDet(const GeomDet *gdet, Phase2OTMeasurementConditionSet &conditionSet)
const ClusterParameterEstimator< Phase2TrackerCluster1D > * cpe() const
bool measurements(const TrajectoryStateOnSurface &stateOnThisDet, const MeasurementEstimator &est, const MeasurementTrackerEvent &dat, TempMeasurements &result) const override
const LocalTrajectoryParameters & localParameters() const
Log< level::Error, false > LogError
LocalError positionError() const
bool isEmpty(const Phase2OTMeasurementDetSet &data) const
TrackingRecHit::ConstRecHitPointer theMissingHit
virtual LocalValues localParameters(const T &, const GeomDetUnit &) const =0
float yy() const
Definition: LocalError.h:24
bool hasBadComponents(const TrajectoryStateOnSurface &tsos, const MeasurementTrackerEvent &dat) const override
T sqrt(T t)
Definition: SSEVec.h:19
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
int index() const
Sets the list of bad ROCs, identified by the positions of their centers in the local coordinate frame...
bool isActive(const MeasurementTrackerEvent &data) const override
Is this module active in reconstruction? It must be both &#39;setActiveThisEvent&#39; and &#39;setActive&#39;...
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
virtual HitReturnType estimate(const TrajectoryStateOnSurface &ts, const TrackingRecHit &hit) const =0
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
std::shared_ptr< TrackingRecHit const > RecHitPointer
TrackingRecHit::ConstRecHitPointer theInactiveHit
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
const GeomDet & fastGeomDet() const
size_type size() const
Definition: DetSetNew.h:65
TrackingRecHit::ConstRecHitContainer RecHitContainer
const PixelGeomDetUnit & specificGeomDet() const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
iterator end()
Definition: DetSetNew.h:53
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
col
Definition: cuy.py:1009
#define UNLIKELY(x)
Definition: Likely.h:21
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
detset::const_iterator const_iterator
RecHitContainer recHits(const TrajectoryStateOnSurface &, const MeasurementTrackerEvent &dat) const override
#define LogDebug(id)
iterator begin()
Definition: DetSetNew.h:51