CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GeomDetCompatibilityChecker.cc
Go to the documentation of this file.
3 
5 
6 //#define STAT_TSB
7 
8 #ifdef STAT_TSB
9 #include<iostream>
10 #endif
11 
12 namespace{
13 
14  struct Stat {
15 
16  struct Nop { Nop(int=0){} Nop& operator=(int){return *this;} void operator++(int){}};
17 #ifdef STAT_TSB
18  using VAR=long long;
19 #else
20  using VAR=Nop;
21 #endif
22  VAR ntot=0;
23  VAR nf1=0;
24  VAR nf2=0;
25 
26  VAR ns1=0;
27  VAR ns2=0;
28  VAR ns11=0;
29  VAR ns21=0;
30 
31  VAR nth=0;
32  VAR nle=0;
33 
34 
35  //Geom checker 1337311 84696 634946 20369 259701 241266 18435 614128
36  // 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
37  // 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
38  // 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
39  // 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
40  // Geom checker 214,884,027 6,756,424 54,479,049 7,059,696 78,135,883 18443999 1124058 158,174,933 17153503
41  // Geom checker 453,155,905 14,054,554 79,733,432 14,837,002 163,414,609 0 0 324,629,999 0
42 #ifdef STAT_TSB
43  ~Stat() { std::cout << "Geom checker " << ntot<<' '<< nf1<<' '<< nf2 <<' '<< ns1<< ' '<< ns2 << ' ' << ns11 << ' '<< ns21 << ' ' << nth << ' ' << nle <<std::endl;}
44 #endif
45  };
46 
47  [[cms::thread_safe]] Stat stat; // for production purpose it is thread safe
48 
49 }
50 
51 std::pair<bool, TrajectoryStateOnSurface>
53  const TrajectoryStateOnSurface& tsos,
54  const Propagator& prop,
55  const MeasurementEstimator& est) {
56  stat.ntot++;
57 
58  auto const sagCut = est.maxSagitta();
59  auto const minTol2 = est.minTolerance2();
60 
61  // std::cout << "param " << sagCut << ' ' << minTol2 << std::endl;
62 
63  /*
64  auto err2 = tsos.curvilinearError().matrix()(3,3);
65  auto largeErr = err2> 0.1*tolerance2;
66  if (largeErr) stat.nle++;
67  */
68 
69  bool isIn = false;
70  float sagitta=99999999;
71  bool close = false;
72  if likely(sagCut>0) {
73  // linear approximation
74  auto const & plane = theDet->specificSurface();
76  auto path = crossing.pathLength(plane);
77  isIn = path.first;
78  if unlikely(!path.first) stat.ns1++;
79  else {
80  auto gpos = GlobalPoint(crossing.position(path.second));
81  auto tpath2 = (gpos-tsos.globalPosition()).perp2();
82  // sagitta = d^2*c/2
83  sagitta = 0.5f*std::abs(tpath2*tsos.globalParameters().transverseCurvature());
84  close = sagitta<sagCut;
85  if (close) {
86  stat.nth++;
87  auto pos = plane.toLocal(GlobalPoint(crossing.position(path.second)));
88  // auto toll = LocalError(tolerance2,0,tolerance2);
89  auto tollL2 = std::max(sagitta*sagitta,minTol2);
90  auto toll = LocalError(tollL2,0,tollL2);
91  isIn = plane.bounds().inside(pos,toll);
92  if (!isIn) { stat.ns2++;
93  return std::make_pair( false,TrajectoryStateOnSurface());
94  }
95  }
96  }
97  }
98 
99  // precise propagation
100  TrajectoryStateOnSurface && propSt = prop.propagate( tsos, theDet->specificSurface());
101  if unlikely ( !propSt.isValid()) { stat.nf1++; return std::make_pair( false, std::move(propSt));}
102 
103 
104  auto es = est.estimate( propSt, theDet->specificSurface());
105  if (!es) stat.nf2++;
106  if (close && (!isIn) && (!es) ) stat.ns11++;
107  if (close && es &&(!isIn)) { stat.ns21++; } // std::cout << sagitta << std::endl;}
108  return std::make_pair( es, std::move(propSt));
109 
110 }
111 
float minTolerance2() const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
GlobalPoint globalPosition() const
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:151
#define unlikely(x)
#define likely(x)
static std::pair< bool, TrajectoryStateOnSurface > isCompatible(const GeomDet *theDet, const TrajectoryStateOnSurface &ts, const Propagator &prop, const MeasurementEstimator &est)
def move
Definition: eostools.py:510
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual HitReturnType estimate(const TrajectoryStateOnSurface &ts, const TrackingRecHit &hit) const =0
const GlobalTrajectoryParameters & globalParameters() const
T perp2() const
Squared magnitude of transverse component.
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:53
GlobalVector globalMomentum() const
tuple cout
Definition: gather_cfg.py:145
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:56
const Plane & specificSurface() const
Same as surface(), kept for backward compatibility.
Definition: GeomDet.h:43