CMS 3D CMS Logo

GeomDetCompatibilityChecker.cc
Go to the documentation of this file.
1 // #define STAT_TSB
2 
3 #ifdef STAT_TSB
4 #include <iostream>
5 #endif
6 
13 
14 namespace {
15 
16  struct Stat {
17  struct Nop {
18  Nop(int = 0) {}
19  Nop& operator=(int) { return *this; }
20  void operator++(int) {}
21  };
22 #ifdef STAT_TSB
23  using VAR = long long;
24 #else
25  using VAR = Nop;
26 #endif
27  VAR ntot = 0;
28  VAR nf1 = 0;
29  VAR nf2 = 0;
30 
31  VAR ns1 = 0;
32  VAR ns2 = 0;
33  VAR ns11 = 0;
34  VAR ns21 = 0;
35 
36  VAR nth = 0;
37  VAR nle = 0;
38 
39  //Geom checker 1337311 84696 634946 20369 259701 241266 18435 614128
40  // Geom checker 124,567,704 3,862,821 36,055,605 3,799,127 29,825,229 4,573,316 320,063 75,420,840
41  // Geom checker 119,618,014 2,307,939 31,142,922 2,903,245 34,673,978 5,139,741 539,152 86,847,116 18,196,497
42  // Geom checker 125,554,439 3,431,348 31,900,589 3,706,531 37,272,039 5,160,257 1,670,236 90,573,031 19,505,412
43  // Geom checker 119,583,440 2,379,307 28,357,175 2,960,173 38,977,837 6,239,242 620,636 86,726,732 9,574,902
44  // Geom checker 214,884,027 6,756,424 54,479,049 7,059,696 78,135,883 18443999 1124058 158,174,933 17153503
45  // Geom checker 453,155,905 14,054,554 79,733,432 14,837,002 163,414,609 0 0 324,629,999 0
46 #ifdef STAT_TSB
47  ~Stat() {
48  std::cout << "Geom checker " << ntot << ' ' << nf1 << ' ' << nf2 << ' ' << ns1 << ' ' << ns2 << ' ' << ns11 << ' '
49  << ns21 << ' ' << nth << ' ' << nle << std::endl;
50  }
51 #endif
52  };
53 
54  CMS_THREAD_SAFE Stat stat; // for production purpose it is thread safe
55 
56 } // namespace
57 
58 std::pair<bool, TrajectoryStateOnSurface> GeomDetCompatibilityChecker::isCompatible(const GeomDet* theDet,
59  const TrajectoryStateOnSurface& tsos,
60  const Propagator& prop,
61  const MeasurementEstimator& est) {
62  stat.ntot++;
63 
64  auto const sagCut = est.maxSagitta();
65  auto const minTol2 = est.minTolerance2();
66 
67  // std::cout << "param " << sagCut << ' ' << std::sqrt(minTol2) << std::endl;
68 
69  /*
70  auto err2 = tsos.curvilinearError().matrix()(3,3);
71  auto largeErr = err2> 0.1*tolerance2;
72  if (largeErr) stat.nle++;
73  */
74 
75  bool isIn = false;
76  float sagitta = 99999999.0f;
77  bool close = false;
78  if
79  LIKELY(sagCut > 0) {
80  // linear approximation
81  auto const& plane = theDet->specificSurface();
84  auto path = crossing.pathLength(plane);
85  isIn = path.first;
86  if
87  UNLIKELY(!path.first) stat.ns1++;
88  else {
89  auto gpos = GlobalPoint(crossing.position(path.second));
90  auto tpath2 = (gpos - tsos.globalPosition()).perp2();
91  // sagitta = d^2*c/2
92  sagitta = 0.5f * std::abs(tpath2 * tsos.globalParameters().transverseCurvature());
93  close = sagitta < sagCut;
94  LogDebug("TkDetLayer") << "GeomDetCompatibilityChecker: sagitta " << sagitta << std::endl;
95  if (close) {
96  stat.nth++;
97  auto pos = plane.toLocal(GlobalPoint(crossing.position(path.second)));
98  // auto toll = LocalError(tolerance2,0,tolerance2);
99  auto tollL2 = std::max(sagitta * sagitta, minTol2);
100  auto toll = LocalError(tollL2, 0, tollL2);
101  isIn = plane.bounds().inside(pos, toll);
102  if (!isIn) {
103  stat.ns2++;
104  LogDebug("TkDetLayer") << "GeomDetCompatibilityChecker: not in " << pos << std::endl;
105  return std::make_pair(false, TrajectoryStateOnSurface());
106  }
107  }
108  }
109  }
110 
111  // precise propagation
112  TrajectoryStateOnSurface&& propSt = prop.propagate(tsos, theDet->specificSurface());
113  if
114  UNLIKELY(!propSt.isValid()) {
115  stat.nf1++;
116  return std::make_pair(false, std::move(propSt));
117  }
118 
119  auto es = est.estimate(propSt, theDet->specificSurface());
120  if (!es)
121  stat.nf2++;
122  if (close && (!isIn) && (!es))
123  stat.ns11++;
124  if (close && es && (!isIn)) {
125  stat.ns21++;
126  } // std::cout << sagitta << std::endl;}
127  return std::make_pair(es, std::move(propSt));
128 }
Likely.h
MeasurementEstimator
Definition: MeasurementEstimator.h:19
TrajectoryStateOnSurface.h
MessageLogger.h
GeomDet
Definition: GeomDet.h:27
MeasurementEstimator::maxSagitta
float maxSagitta() const
Definition: MeasurementEstimator.h:70
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos
Definition: PixelAliasList.h:18
MeasurementEstimator::estimate
virtual HitReturnType estimate(const TrajectoryStateOnSurface &ts, const TrackingRecHit &hit) const =0
Propagator
Definition: Propagator.h:44
UNLIKELY
#define UNLIKELY(x)
Definition: Likely.h:21
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
hgcalPlots.stat
stat
Definition: hgcalPlots.py:1119
Propagator::propagationDirection
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:139
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
CMS_THREAD_SAFE
#define CMS_THREAD_SAFE
Definition: thread_safety_macros.h:4
StraightLinePlaneCrossing.h
GeomDetCompatibilityChecker::isCompatible
static std::pair< bool, TrajectoryStateOnSurface > isCompatible(const GeomDet *theDet, const TrajectoryStateOnSurface &ts, const Propagator &prop, const MeasurementEstimator &est)
Definition: GeomDetCompatibilityChecker.cc:58
MeasurementEstimator::minTolerance2
float minTolerance2() const
Definition: MeasurementEstimator.h:71
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
GlobalTrajectoryParameters::transverseCurvature
float transverseCurvature() const
Definition: GlobalTrajectoryParameters.h:89
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
LocalError
Definition: LocalError.h:12
thread_safety_macros.h
GeomDetCompatibilityChecker.h
Propagator::propagate
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
GeomDet::specificSurface
const Plane & specificSurface() const
Same as surface(), kept for backward compatibility.
Definition: GeomDet.h:40
perp2
T perp2() const
Squared magnitude of transverse component.
Definition: Basic3DVectorLD.h:130
PV3DBase::basicVector
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:53
TrajectoryStateOnSurface::globalMomentum
GlobalVector globalMomentum() const
Definition: TrajectoryStateOnSurface.h:66
eostools.move
def move(src, dest)
Definition: eostools.py:511
LIKELY
#define LIKELY(x)
Definition: Likely.h:20
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TrajectoryStateOnSurface::globalParameters
const GlobalTrajectoryParameters & globalParameters() const
Definition: TrajectoryStateOnSurface.h:64
StraightLinePlaneCrossing
Definition: StraightLinePlaneCrossing.h:14
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54