CMS 3D CMS Logo

LowPtClusterShapeSeedComparitor.cc
Go to the documentation of this file.
1 #include <cmath>
2 
22 
23 namespace {
25 
26  inline float sqr(float x) { return x * x; }
27 
28  /*****************************************************************************/
29  inline float areaParallelogram(const Vector2D& a, const Vector2D& b) { return a.x() * b.y() - a.y() * b.x(); }
30 
31  /*****************************************************************************/
32 
33  inline bool getGlobalDirs(GlobalPoint const* g, GlobalVector* globalDirs) {
34  // Determine circle
35  CircleFromThreePoints circle(g[0], g[1], g[2]);
36 
37  float curvature = circle.curvature();
38  if (0.f == curvature) {
39  LogDebug("LowPtClusterShapeSeedComparitor")
40  << "the curvature is null:"
41  << "\n point1: " << g[0] << "\n point2: " << g[1] << "\n point3: " << g[2];
42  return false;
43  }
44 
45  // Get 2d points
46  Vector2D p[3];
47  Vector2D c = circle.center();
48  for (int i = 0; i != 3; i++)
49  p[i] = g[i].basicVector().xy() - c;
50 
51  float area = std::abs(areaParallelogram(p[1] - p[0], p[1]));
52 
53  float a12 = std::asin(std::min(area * curvature * curvature, 1.f));
54 
55  float slope = (g[1].z() - g[0].z()) / a12;
56 
57  // Calculate globalDirs
58 
59  float cotTheta = slope * curvature;
60  float sinTheta = 1.f / std::sqrt(1.f + sqr(cotTheta));
61  float cosTheta = cotTheta * sinTheta;
62 
63  if (areaParallelogram(p[0], p[1]) < 0)
64  sinTheta = -sinTheta;
65 
66  for (int i = 0; i != 3; i++) {
67  Vector2D vl = p[i] * (curvature * sinTheta);
68  globalDirs[i] = GlobalVector(-vl.y(), vl.x(), cosTheta);
69  }
70  return true;
71  }
72 
73  /*****************************************************************************/
74 
75  inline void getGlobalPos(const SeedingHitSet& hits, GlobalPoint* globalPoss) {
76  for (unsigned int i = 0; i != hits.size(); ++i)
77  globalPoss[i] = hits[i]->globalPosition();
78  }
79 
80 } // namespace
81 
82 /*****************************************************************************/
85  : thePixelClusterShapeCacheToken(
86  iC.consumes<SiPixelClusterShapeCache>(ps.getParameter<edm::InputTag>("clusterShapeCacheSrc"))),
87  theShapeFilterLabel_(ps.getParameter<std::string>("clusterShapeHitFilter")) {}
88 
89 /*****************************************************************************/
93 
95 }
96 
98 //(const reco::Track* track, const vector<const TrackingRecHit *> & recHits) const
99 {
100  assert(hits.size() == 3);
101 
102  const ClusterShapeHitFilter* filter = theShapeFilter.product();
103  if (filter == nullptr)
104  throw cms::Exception("LogicError") << "LowPtClusterShapeSeedComparitor: init(EventSetup) method was not called";
105 
106  // Get global positions
107  GlobalPoint globalPoss[3];
108  getGlobalPos(hits, globalPoss);
109 
110  // Get global directions
111  GlobalVector globalDirs[3];
112 
113  bool ok = getGlobalDirs(globalPoss, globalDirs);
114 
115  // Check whether shape of pixel cluster is compatible
116  // with local track direction
117 
118  if (!ok) {
119  LogDebug("LowPtClusterShapeSeedComparitor") << "curvarture 0:"
120  << "\nnHits: " << hits.size() << " will say the seed is good anyway.";
121  return true;
122  }
123 
124  for (int i = 0; i < 3; i++) {
125  const SiPixelRecHit* pixelRecHit = dynamic_cast<const SiPixelRecHit*>(hits[i]->hit());
126 
127  if (!pixelRecHit) {
128  edm::LogError("LowPtClusterShapeSeedComparitor") << "this is not a pixel cluster";
129  ok = false;
130  break;
131  }
132 
133  if (!pixelRecHit->isValid()) {
134  ok = false;
135  break;
136  }
137 
138  LogDebug("LowPtClusterShapeSeedComparitor") << "about to compute compatibility."
139  << "hit ptr: " << pixelRecHit << "global direction:" << globalDirs[i];
140 
141  if (!filter->isCompatible(*pixelRecHit, globalDirs[i], *thePixelClusterShapeCache)) {
142  LogTrace("LowPtClusterShapeSeedComparitor")
143  << " clusShape is not compatible" << HitInfo::getInfo(*hits[i]->hit(), theTTopo.product());
144 
145  ok = false;
146  break;
147  }
148  }
149 
150  return ok;
151 }
LowPtClusterShapeSeedComparitor::init
void init(const edm::Event &e, const edm::EventSetup &es) override
Definition: LowPtClusterShapeSeedComparitor.cc:90
Vector3DBase
Definition: Vector3DBase.h:8
ClusterShapeHitFilter.h
CircleFromThreePoints
Definition: CircleFromThreePoints.h:18
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
LowPtClusterShapeSeedComparitor.h
SiPixelClusterShapeCache
Definition: SiPixelClusterShapeCache.h:43
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
ESHandle.h
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
SeedingHitSet
Definition: SeedingHitSet.h:6
min
T min(T a, T b)
Definition: MathUtil.h:58
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
LowPtClusterShapeSeedComparitor::thePixelClusterShapeCache
edm::Handle< SiPixelClusterShapeCache > thePixelClusterShapeCache
Definition: LowPtClusterShapeSeedComparitor.h:38
ClusterShapeHitFilter
Definition: ClusterShapeHitFilter.h:149
sqr
int sqr(const T &t)
Definition: pfalgo_common_ref.h:9
cms::cuda::assert
assert(be >=bs)
CkfComponentsRecord.h
GlobalVector
Global3DVector GlobalVector
Definition: GlobalVector.h:10
PixelRecoUtilities::curvature
T curvature(T InversePt, const edm::EventSetup &iSetup)
Definition: PixelRecoUtilities.h:42
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
LowPtClusterShapeSeedComparitor::theShapeFilterLabel_
std::string theShapeFilterLabel_
Definition: LowPtClusterShapeSeedComparitor.h:39
SiPixelRecHit
Our base class.
Definition: SiPixelRecHit.h:23
TrackerTopology.h
LowPtClusterShapeSeedComparitor::theTTopo
edm::ESHandle< TrackerTopology > theTTopo
Definition: LowPtClusterShapeSeedComparitor.h:36
TrackingRecHit.h
TrackerTopologyRcd.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
LowPtClusterShapeSeedComparitor::thePixelClusterShapeCacheToken
edm::EDGetTokenT< SiPixelClusterShapeCache > thePixelClusterShapeCacheToken
Definition: LowPtClusterShapeSeedComparitor.h:37
CkfComponentsRecord
Definition: CkfComponentsRecord.h:22
SeedingHitSet.h
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
CircleFromThreePoints.h
Point3DBase< float, GlobalTag >
SiPixelRecHit.h
b
double b
Definition: hdecay.h:118
ALCARECOTkAlBeamHalo_cff.filter
filter
Definition: ALCARECOTkAlBeamHalo_cff.py:27
Basic2DVector< float >
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
a
double a
Definition: hdecay.h:119
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
Event.h
Vector2D
Basic2DVector< double >::MathVector Vector2D
Definition: LinkByRecHit.cc:7
LowPtClusterShapeSeedComparitor::theShapeFilter
edm::ESHandle< ClusterShapeHitFilter > theShapeFilter
something
Definition: LowPtClusterShapeSeedComparitor.h:35
edm::EventSetup
Definition: EventSetup.h:58
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
get
#define get
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
std
Definition: JetResolutionObject.h:76
LowPtClusterShapeSeedComparitor::compatible
bool compatible(const SeedingHitSet &hits) const override
Definition: LowPtClusterShapeSeedComparitor.cc:97
Basic2DVector.h
Exception
Definition: hltDiff.cc:245
genVertex_cff.x
x
Definition: genVertex_cff.py:13
GlobalVector.h
EventSetup.h
ConsumesCollector.h
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
HitInfo.h
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
ParameterSet.h
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
slope
static const double slope[3]
Definition: CastorTimeSlew.cc:6
edm::Event
Definition: Event.h:73
TrackingRecHit::isValid
bool isValid() const
Definition: TrackingRecHit.h:141
GlobalPoint.h
custom_jme_cff.area
area
Definition: custom_jme_cff.py:140
LowPtClusterShapeSeedComparitor::LowPtClusterShapeSeedComparitor
LowPtClusterShapeSeedComparitor(const edm::ParameterSet &ps, edm::ConsumesCollector &iC)
Definition: LowPtClusterShapeSeedComparitor.cc:83
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
hit
Definition: SiStripHitEffFromCalibTree.cc:88
g
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 g
Definition: Activities.doc:4
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
HitInfo::getInfo
static std::string getInfo(const DetId &id, const TrackerTopology *tTopo)
Definition: HitInfo.cc:19