CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
PixelClusterShapeSeedComparitor Class Reference
Inheritance diagram for PixelClusterShapeSeedComparitor:
SeedComparitor

Public Member Functions

bool compatible (const SeedingHitSet &hits) const override
 
bool compatible (const TrajectoryStateOnSurface &, SeedingHitSet::ConstRecHitPointer hit) const override
 
bool compatible (const SeedingHitSet &hits, const GlobalTrajectoryParameters &helixStateAtVertex, const FastHelix &helix) const override
 
void init (const edm::Event &ev, const edm::EventSetup &es) override
 
 PixelClusterShapeSeedComparitor (const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)
 
 ~PixelClusterShapeSeedComparitor () override
 
- Public Member Functions inherited from SeedComparitor
virtual ~SeedComparitor ()
 

Private Member Functions

bool compatibleHit (const TrackingRecHit &hit, const GlobalVector &direction) const
 

Private Attributes

const ClusterShapeHitFilterclusterShapeHitFilter_
 
const edm::ESGetToken< ClusterShapeHitFilter, CkfComponentsRecordclusterShapeHitFilterESToken_
 
const bool filterAtHelixStage_
 
std::string filterName_
 
const bool filterPixelHits_
 
const bool filterStripHits_
 
const SiPixelClusterShapeCachepixelClusterShapeCache_
 
edm::EDGetTokenT< SiPixelClusterShapeCachepixelClusterShapeCacheToken_
 

Detailed Description

Definition at line 26 of file ClusterShapeSeedComparitor.cc.

Constructor & Destructor Documentation

◆ PixelClusterShapeSeedComparitor()

PixelClusterShapeSeedComparitor::PixelClusterShapeSeedComparitor ( const edm::ParameterSet cfg,
edm::ConsumesCollector iC 
)

Definition at line 49 of file ClusterShapeSeedComparitor.cc.

References looper::cfg, edm::ConsumesCollector::consumes(), filterPixelHits_, and pixelClusterShapeCacheToken_.

51  : filterName_(cfg.getParameter<std::string>("ClusterShapeHitFilterName")),
53  pixelClusterShapeCache_(nullptr),
54  filterAtHelixStage_(cfg.getParameter<bool>("FilterAtHelixStage")),
55  filterPixelHits_(cfg.getParameter<bool>("FilterPixelHits")),
56  filterStripHits_(cfg.getParameter<bool>("FilterStripHits")) {
57  if (filterPixelHits_) {
59  iC.consumes<SiPixelClusterShapeCache>(cfg.getParameter<edm::InputTag>("ClusterShapeCacheSrc"));
60  }
61 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< SiPixelClusterShapeCache > pixelClusterShapeCacheToken_
const edm::ESGetToken< ClusterShapeHitFilter, CkfComponentsRecord > clusterShapeHitFilterESToken_
const SiPixelClusterShapeCache * pixelClusterShapeCache_

◆ ~PixelClusterShapeSeedComparitor()

PixelClusterShapeSeedComparitor::~PixelClusterShapeSeedComparitor ( )
override

Definition at line 63 of file ClusterShapeSeedComparitor.cc.

63 {}

Member Function Documentation

◆ compatible() [1/3]

bool PixelClusterShapeSeedComparitor::compatible ( const SeedingHitSet hits) const
inlineoverridevirtual

Implements SeedComparitor.

Definition at line 31 of file ClusterShapeSeedComparitor.cc.

31 { return true; }

◆ compatible() [2/3]

bool PixelClusterShapeSeedComparitor::compatible ( const TrajectoryStateOnSurface tsos,
SeedingHitSet::ConstRecHitPointer  hit 
) const
overridevirtual

Implements SeedComparitor.

Definition at line 74 of file ClusterShapeSeedComparitor.cc.

References cms::cuda::assert(), compatibleHit(), filterAtHelixStage_, TrajectoryStateOnSurface::globalDirection(), and TrajectoryStateOnSurface::isValid().

75  {
77  return true;
78  assert(hit->isValid() && tsos.isValid());
79  return compatibleHit(*hit, tsos.globalDirection());
80 }
bool compatibleHit(const TrackingRecHit &hit, const GlobalVector &direction) const
assert(be >=bs)
GlobalVector globalDirection() const

◆ compatible() [3/3]

bool PixelClusterShapeSeedComparitor::compatible ( const SeedingHitSet hits,
const GlobalTrajectoryParameters helixStateAtVertex,
const FastHelix helix 
) const
overridevirtual

Implements SeedComparitor.

Definition at line 82 of file ClusterShapeSeedComparitor.cc.

References FastHelix::circle(), compatibleHit(), filterAtHelixStage_, hfClusterShapes_cfi::hits, mps_fire::i, FastCircle::isLine(), FastHelix::isValid(), GlobalTrajectoryParameters::momentum(), create_idmaps::n, perp2(), GlobalTrajectoryParameters::position(), mathSSE::sqrt(), bphysicsOniaDQM_cfi::vertex, PV3DBase< T, PVType, FrameType >::x(), FastCircle::x0(), testProducerWithPsetDescEmpty_cfi::x1, PV3DBase< T, PVType, FrameType >::y(), FastCircle::y0(), testProducerWithPsetDescEmpty_cfi::y1, and PV3DBase< T, PVType, FrameType >::z().

84  {
86  return true;
87 
88  if (!helix.isValid() //check still if it's a straight line, which are OK
89  && !helix.circle().isLine()) //complain if it's not even a straight line
90  edm::LogWarning("InvalidHelix") << "PixelClusterShapeSeedComparitor helix is not valid, result is bad";
91 
92  float xc = helix.circle().x0(), yc = helix.circle().y0();
93 
94  GlobalPoint vertex = helixStateAtVertex.position();
95  GlobalVector momvtx = helixStateAtVertex.momentum();
96  float x0 = vertex.x(), y0 = vertex.y();
97  for (unsigned int i = 0, n = hits.size(); i < n; ++i) {
98  auto const &hit = *hits[i];
99  GlobalPoint pos = hit.globalPosition();
100  float x1 = pos.x(), y1 = pos.y(), dx1 = x1 - xc, dy1 = y1 - yc;
101 
102  // now figure out the proper tangent vector
103  float perpx = -dy1, perpy = dx1;
104  if (perpx * (x1 - x0) + perpy * (y1 - y0) < 0) {
105  perpy = -perpy;
106  perpx = -perpx;
107  }
108 
109  // now normalize (perpx, perpy, 1.0) to momentum (px, py, pz)
110  float perp2 = perpx * perpx + perpy * perpy;
111  float pmom2 = momvtx.x() * momvtx.x() + momvtx.y() * momvtx.y(), momz2 = momvtx.z() * momvtx.z(),
112  mom2 = pmom2 + momz2;
113  float perpscale = sqrt(pmom2 / mom2 / perp2), zscale = sqrt((1 - pmom2 / mom2));
114  GlobalVector gdir(perpx * perpscale, perpy * perpscale, (momvtx.z() > 0 ? zscale : -zscale));
115 
116  if (!compatibleHit(hit, gdir)) {
117  return false; // not yet
118  }
119  }
120  return true;
121 }
bool compatibleHit(const TrackingRecHit &hit, const GlobalVector &direction) const
T z() const
Definition: PV3DBase.h:61
bool isValid() const
Definition: FastHelix.h:57
const FastCircle & circle() const
Definition: FastHelix.h:61
T perp2() const
Squared magnitude of transverse component.
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
T sqrt(T t)
Definition: SSEVec.h:23
double y0() const
Definition: FastCircle.h:45
bool isLine() const
Definition: FastCircle.h:51
double x0() const
Definition: FastCircle.h:43

◆ compatibleHit()

bool PixelClusterShapeSeedComparitor::compatibleHit ( const TrackingRecHit hit,
const GlobalVector direction 
) const
private

Definition at line 123 of file ClusterShapeSeedComparitor.cc.

References cms::cuda::assert(), clusterShapeHitFilter_, Exception, filterPixelHits_, filterStripHits_, ClusterShapeHitFilter::isCompatible(), SiStripMatchedRecHit2D::monoCluster(), SiStripMatchedRecHit2D::monoId(), ProjectedSiStripRecHit2D::originalHit(), pixelClusterShapeCache_, rpcPointValidation_cfi::recHit, SiStripMatchedRecHit2D::stereoCluster(), and SiStripMatchedRecHit2D::stereoId().

Referenced by compatible().

123  {
124  if (hit.geographicalId().subdetId() <= 2) {
125  if (!filterPixelHits_)
126  return true;
127  const SiPixelRecHit *pixhit = dynamic_cast<const SiPixelRecHit *>(&hit);
128  if (pixhit == nullptr)
129  throw cms::Exception("LogicError", "Found a valid hit on the pixel detector which is not a SiPixelRecHit\n");
130  //printf("Cheching hi hit on detid %10d, local direction is x = %9.6f, y = %9.6f, z = %9.6f\n", hit.geographicalId().rawId(), direction.x(), direction.y(), direction.z());
131  return clusterShapeHitFilter_->isCompatible(*pixhit, direction, *pixelClusterShapeCache_);
132  } else {
133  if (!filterStripHits_)
134  return true;
135  const std::type_info &tid = typeid(*&hit);
136  if (tid == typeid(SiStripMatchedRecHit2D)) {
137  const SiStripMatchedRecHit2D *matchedHit = dynamic_cast<const SiStripMatchedRecHit2D *>(&hit);
138  assert(matchedHit != nullptr);
139  return (
140  clusterShapeHitFilter_->isCompatible(DetId(matchedHit->monoId()), matchedHit->monoCluster(), direction) &&
141  clusterShapeHitFilter_->isCompatible(DetId(matchedHit->stereoId()), matchedHit->stereoCluster(), direction));
142  } else if (tid == typeid(SiStripRecHit2D)) {
143  const SiStripRecHit2D *recHit = dynamic_cast<const SiStripRecHit2D *>(&hit);
144  assert(recHit != nullptr);
145  return clusterShapeHitFilter_->isCompatible(*recHit, direction);
146  } else if (tid == typeid(ProjectedSiStripRecHit2D)) {
147  const ProjectedSiStripRecHit2D *precHit = dynamic_cast<const ProjectedSiStripRecHit2D *>(&hit);
148  assert(precHit != nullptr);
149  return clusterShapeHitFilter_->isCompatible(precHit->originalHit(), direction);
150  } else {
151  //printf("Questo e' un %s, che ci fo?\n", tid.name());
152  return true;
153  }
154  }
155 }
unsigned int stereoId() const
assert(be >=bs)
bool isCompatible(const SiPixelRecHit &recHit, const LocalVector &ldir, const SiPixelClusterShapeCache &clusterShapeCache, PixelData const *pd=nullptr) const
SiStripCluster const & monoCluster() const
Definition: DetId.h:17
unsigned int monoId() const
SiStripCluster const & stereoCluster() const
SiStripRecHit2D originalHit() const
const ClusterShapeHitFilter * clusterShapeHitFilter_
const SiPixelClusterShapeCache * pixelClusterShapeCache_
Our base class.
Definition: SiPixelRecHit.h:23

◆ init()

void PixelClusterShapeSeedComparitor::init ( const edm::Event ev,
const edm::EventSetup es 
)
overridevirtual

Implements SeedComparitor.

Definition at line 65 of file ClusterShapeSeedComparitor.cc.

References clusterShapeHitFilter_, clusterShapeHitFilterESToken_, makeMEIFBenchmarkPlots::ev, filterPixelHits_, edm::EventSetup::getData(), pixelClusterShapeCache_, pixelClusterShapeCacheToken_, and edm::Handle< T >::product().

65  {
67  if (filterPixelHits_) {
69  ev.getByToken(pixelClusterShapeCacheToken_, hcache);
71  }
72 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
T const * product() const
Definition: Handle.h:70
edm::EDGetTokenT< SiPixelClusterShapeCache > pixelClusterShapeCacheToken_
const edm::ESGetToken< ClusterShapeHitFilter, CkfComponentsRecord > clusterShapeHitFilterESToken_
const ClusterShapeHitFilter * clusterShapeHitFilter_
const SiPixelClusterShapeCache * pixelClusterShapeCache_

Member Data Documentation

◆ clusterShapeHitFilter_

const ClusterShapeHitFilter* PixelClusterShapeSeedComparitor::clusterShapeHitFilter_
private

Definition at line 42 of file ClusterShapeSeedComparitor.cc.

Referenced by compatibleHit(), and init().

◆ clusterShapeHitFilterESToken_

const edm::ESGetToken<ClusterShapeHitFilter, CkfComponentsRecord> PixelClusterShapeSeedComparitor::clusterShapeHitFilterESToken_
private

Definition at line 41 of file ClusterShapeSeedComparitor.cc.

Referenced by init().

◆ filterAtHelixStage_

const bool PixelClusterShapeSeedComparitor::filterAtHelixStage_
private

Definition at line 45 of file ClusterShapeSeedComparitor.cc.

Referenced by compatible().

◆ filterName_

std::string PixelClusterShapeSeedComparitor::filterName_
private

Definition at line 40 of file ClusterShapeSeedComparitor.cc.

◆ filterPixelHits_

const bool PixelClusterShapeSeedComparitor::filterPixelHits_
private

◆ filterStripHits_

const bool PixelClusterShapeSeedComparitor::filterStripHits_
private

Definition at line 46 of file ClusterShapeSeedComparitor.cc.

Referenced by compatibleHit().

◆ pixelClusterShapeCache_

const SiPixelClusterShapeCache* PixelClusterShapeSeedComparitor::pixelClusterShapeCache_
private

Definition at line 44 of file ClusterShapeSeedComparitor.cc.

Referenced by compatibleHit(), and init().

◆ pixelClusterShapeCacheToken_

edm::EDGetTokenT<SiPixelClusterShapeCache> PixelClusterShapeSeedComparitor::pixelClusterShapeCacheToken_
private

Definition at line 43 of file ClusterShapeSeedComparitor.cc.

Referenced by init(), and PixelClusterShapeSeedComparitor().