CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TkStackMeasurementDet.cc
Go to the documentation of this file.
2 
4 
5 using namespace std;
6 
8  : MeasurementDet(gdet), thePixelCPE(cpe), theLowerDet(nullptr), theUpperDet(nullptr) {}
9 
10 void TkStackMeasurementDet::init(const MeasurementDet* lowerDet, const MeasurementDet* upperDet) {
11  theLowerDet = dynamic_cast<const TkPhase2OTMeasurementDet*>(lowerDet);
12  theUpperDet = dynamic_cast<const TkPhase2OTMeasurementDet*>(upperDet);
13 
14  if ((theLowerDet == nullptr) || (theUpperDet == nullptr)) {
16  "TkStackMeasurementDet ERROR: Trying to glue a det which is not a TkPhase2OTMeasurementDet");
17  }
18 }
19 
21  const MeasurementTrackerEvent& data) const {
23 
24  if (data.phase2OTVectorHits().empty())
25  return result;
26  LogTrace("MeasurementTracker") << " is not empty";
27  if (!isActive(data))
28  return result;
29  LogTrace("MeasurementTracker") << " and is active";
30 
31  //find clusters to skip
32  const detset& lowerDetSet = data.phase2OTData().detSet(lowerDet()->index());
33  const detset& upperDetSet = data.phase2OTData().detSet(upperDet()->index());
34  std::vector<bool> skipClustersUpper(data.phase2OTClustersToSkip().empty() ? 0 : upperDetSet.size(), false);
35  std::vector<bool> skipClustersLower(data.phase2OTClustersToSkip().empty() ? 0 : lowerDetSet.size(), false);
36 
37  const Phase2TrackerCluster1D* begin = nullptr;
38  if (!data.phase2OTData().handle()->data().empty()) {
39  begin = &(data.phase2OTData().handle()->data().front());
40  }
41  if (!data.phase2OTClustersToSkip().empty()) {
42  if (!lowerDetSet.empty()) {
43  for (const_iterator cil = lowerDetSet.begin(); cil != lowerDetSet.end(); ++cil) {
44  if (cil < begin) {
45  edm::LogError("IndexMisMatch") << "TkStackMeasurementDet cannot create hit because of index mismatch.";
46  return result;
47  }
48  unsigned int indexl = cil - begin;
49  if (data.phase2OTClustersToSkip()[indexl]) {
50  int iLocalL = std::distance(lowerDetSet.begin(), cil);
51  skipClustersLower[iLocalL] = true;
52  }
53  }
54  }
55  if (!upperDetSet.empty()) {
56  for (const_iterator ciu = upperDetSet.begin(); ciu != upperDetSet.end(); ++ciu) {
57  if (ciu < begin) {
58  edm::LogError("IndexMisMatch") << "TkStackMeasurementDet cannot create hit because of index mismatch.";
59  return result;
60  }
61  unsigned int indexu = ciu - begin;
62  if (data.phase2OTClustersToSkip()[indexu]) {
63  int iLocalU = std::distance(upperDetSet.begin(), ciu);
64  skipClustersUpper[iLocalU] = true;
65  }
66  }
67  }
68  }
69  DetId detIdStack = specificGeomDet().geographicalId();
70 
71  auto iterator = data.phase2OTVectorHits().find(detIdStack);
72  if (iterator == data.phase2OTVectorHits().end())
73  return result;
74  for (const auto& vecHit : data.phase2OTVectorHits()[detIdStack]) {
75  if (!data.phase2OTClustersToSkip().empty()) {
76  if (skipClustersLower[vecHit.lowerCluster().key() - lowerDetSet.offset()])
77  continue;
78  if (skipClustersUpper[vecHit.upperCluster().key() - upperDetSet.offset()])
79  continue;
80  }
81  result.push_back(std::make_shared<VectorHit>(vecHit));
82  }
83 
84  iterator = data.phase2OTVectorHitsRej().find(detIdStack);
85  if (iterator == data.phase2OTVectorHitsRej().end())
86  return result;
87  for (const auto& vecHit : data.phase2OTVectorHitsRej()[detIdStack]) {
88  if (!data.phase2OTClustersToSkip().empty()) {
89  if (skipClustersLower[vecHit.lowerCluster().key() - lowerDetSet.offset()])
90  continue;
91  if (skipClustersUpper[vecHit.upperCluster().key() - upperDetSet.offset()])
92  continue;
93  }
94  result.push_back(std::make_shared<VectorHit>(vecHit));
95  }
96 
97  return result;
98 }
99 
101  const MeasurementEstimator& est,
103  TempMeasurements& result) const {
104  LogDebug("MeasurementTracker") << "TkStackMeasurementDet::measurements";
105 
106  if (!isActive(data)) {
107  result.add(theInactiveHit, 0.F);
108  return true;
109  }
110 
111  LogTrace("MeasurementTracker") << " is active";
112 
113  auto oldSize = result.size();
114  MeasurementDet::RecHitContainer&& allHits = recHits(stateOnThisDet, data);
115 
116  for (auto&& hit : allHits) {
117  std::pair<bool, double> diffEst = est.estimate(stateOnThisDet, *hit);
118  if (diffEst.first) {
119  LogDebug("MeasurementTracker") << "New vh added with chi2: " << diffEst.second;
120  result.add(std::move(hit), diffEst.second);
121  }
122  }
123 
124  if (result.size() > oldSize)
125  return true;
126 
127  // create a TrajectoryMeasurement with an invalid RecHit and zero estimate
128  result.add(theMissingHit, 0.F);
129  LogDebug("MeasurementTracker") << "adding missing hit";
130  return false;
131 }
TkStackMeasurementDet(const StackGeomDet *gdet, const PixelClusterParameterEstimator *cpe)
int offset() const
Definition: DetSetNew.h:62
const TkPhase2OTMeasurementDet * theLowerDet
std::size_t size() const
Log< level::Error, false > LogError
#define LogTrace(id)
tuple result
Definition: mps_fire.py:311
TrackingRecHit::ConstRecHitPointer theMissingHit
void init(const MeasurementDet *lowerDet, const MeasurementDet *upperDet)
bool isActive(const MeasurementTrackerEvent &data) const override
return TRUE if both lower and upper components are active
void add(ConstRecHitPointer const &h, float d)
const TkPhase2OTMeasurementDet * upperDet() const
bool empty() const
Definition: DetSetNew.h:70
def move
Definition: eostools.py:511
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
bool measurements(const TrajectoryStateOnSurface &stateOnThisDet, const MeasurementEstimator &est, const MeasurementTrackerEvent &data, TempMeasurements &result) const override
RecHitContainer recHits(const TrajectoryStateOnSurface &, const MeasurementTrackerEvent &data) const override
virtual HitReturnType estimate(const TrajectoryStateOnSurface &ts, const TrackingRecHit &hit) const =0
const TkPhase2OTMeasurementDet * lowerDet() const
Definition: DetId.h:17
TrackingRecHit::ConstRecHitPointer theInactiveHit
detset::const_iterator const_iterator
TrackingRecHit::ConstRecHitContainer RecHitContainer
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
iterator end()
Definition: DetSetNew.h:56
const StackGeomDet & specificGeomDet() const
tuple MeasurementTrackerEvent
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
size_type size() const
Definition: DetSetNew.h:68
#define LogDebug(id)
const TkPhase2OTMeasurementDet * theUpperDet
iterator begin()
Definition: DetSetNew.h:54