CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ClusterShapeSeedComparitor.cc
Go to the documentation of this file.
14 #include <cstdio>
15 #include <cassert>
16 
18  public:
21  virtual void init(const edm::EventSetup& es) ;
22  virtual bool compatible(const SeedingHitSet &hits, const TrackingRegion & region) const { return true; }
23  virtual bool compatible(const TrajectorySeed &seed) const { return true; }
24  virtual bool compatible(const TrajectoryStateOnSurface &,
26  virtual bool compatible(const SeedingHitSet &hits,
27  const GlobalTrajectoryParameters &helixStateAtVertex,
28  const FastHelix &helix,
29  const TrackingRegion & region) const ;
30  virtual bool compatible(const SeedingHitSet &hits,
31  const GlobalTrajectoryParameters &straightLineStateAtVertex,
32  const TrackingRegion & region) const ;
33 
34  private:
35  bool compatibleHit(const TransientTrackingRecHit &hit, const GlobalVector &direction) const ;
36 
37  std::string filterName_;
41 };
42 
43 
45  filterName_(cfg.getParameter<std::string>("ClusterShapeHitFilterName")),
46  filterAtHelixStage_(cfg.getParameter<bool>("FilterAtHelixStage")),
47  filterPixelHits_(cfg.getParameter<bool>("FilterPixelHits")),
48  filterStripHits_(cfg.getParameter<bool>("FilterStripHits"))
49 {
50 }
51 
53 {
54 }
55 
56 void
59 }
60 
61 
62 bool
65 {
66  if (filterAtHelixStage_) return true;
67  assert(hit->isValid() && tsos.isValid());
68  return compatibleHit(*hit, tsos.globalDirection());
69 }
70 
71 bool
73  const GlobalTrajectoryParameters &straightLineStateAtVertex,
74  const TrackingRegion & region) const
75 {
76  return true;
77 }
78 
79 bool
81  const GlobalTrajectoryParameters &helixStateAtVertex,
82  const FastHelix &helix,
83  const TrackingRegion & region) const
84 {
85  if (!filterAtHelixStage_) return true;
86  float xc = helix.circle().x0(), yc = helix.circle().y0();
87 
88  GlobalPoint vertex = helixStateAtVertex.position();
89  GlobalVector momvtx = helixStateAtVertex.momentum();
90  float x0 = vertex.x(), y0 = vertex.y();
91  for (unsigned int i = 0, n = hits.size(); i < n; ++i) {
92  const TransientTrackingRecHit &hit = *hits[i];
94  float x1 = pos.x(), y1 = pos.y(), dx1 = x1 - xc, dy1 = y1 - yc;
95 
96  // now figure out the proper tangent vector
97  float perpx = -dy1, perpy = dx1;
98  if (perpx * (x1-x0) + perpy * (y1 - y0) < 0) {
99  perpy = -perpy; perpx = -perpx;
100  }
101 
102  // now normalize (perpx, perpy, 1.0) to momentum (px, py, pz)
103  float perp2 = perpx*perpx + perpy*perpy;
104  float pmom2 = momvtx.x()*momvtx.x() + momvtx.y()*momvtx.y(), momz2 = momvtx.z()*momvtx.z(), mom2 = pmom2 + momz2;
105  float perpscale = sqrt(pmom2/mom2 / perp2), zscale = sqrt((1-pmom2/mom2));
106  GlobalVector gdir(perpx*perpscale, perpy*perpscale, (momvtx.z() > 0 ? zscale : -zscale));
107 
108  if (!compatibleHit(hit, gdir)) {
109  return false; // not yet
110  }
111  }
112  return true;
113 }
114 
115 bool
117 {
118  if (hit.geographicalId().subdetId() <= 2) {
119  if (!filterPixelHits_) return true;
120  const SiPixelRecHit *pixhit = dynamic_cast<const SiPixelRecHit *>(hit.hit());
121  if (pixhit == 0) throw cms::Exception("LogicError", "Found a valid hit on the pixel detector which is not a SiPixelRecHit\n");
122  //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());
123  return filterHandle_->isCompatible(*pixhit, direction);
124  } else {
125  if (!filterStripHits_) return true;
126  const std::type_info &tid = typeid(*hit.hit());
127  if (tid == typeid(SiStripMatchedRecHit2D)) {
128  const SiStripMatchedRecHit2D* matchedHit = dynamic_cast<const SiStripMatchedRecHit2D *>(hit.hit());
129  assert(matchedHit != 0);
130  return (filterHandle_->isCompatible(DetId(matchedHit->monoId()), matchedHit->monoCluster(), direction) &&
131  filterHandle_->isCompatible(DetId(matchedHit->stereoId()), matchedHit->stereoCluster(), direction));
132  } else if (tid == typeid(SiStripRecHit2D)) {
133  const SiStripRecHit2D* recHit = dynamic_cast<const SiStripRecHit2D *>(hit.hit());
134  assert(recHit != 0);
135  return filterHandle_->isCompatible(*recHit, direction);
136  } else if (tid == typeid(ProjectedSiStripRecHit2D)) {
137  const ProjectedSiStripRecHit2D* precHit = dynamic_cast<const ProjectedSiStripRecHit2D *>(hit.hit());
138  assert(precHit != 0);
139  return filterHandle_->isCompatible(precHit->originalHit(), direction);
140  } else {
141  //printf("Questo e' un %s, che ci fo?\n", tid.name());
142  return true;
143  }
144  }
145 }
146 
147 DEFINE_EDM_PLUGIN(SeedComparitorFactory, PixelClusterShapeSeedComparitor, "PixelClusterShapeSeedComparitor");
int i
Definition: DBlmapReader.cc:9
double x0() const
Definition: FastCircle.h:50
T y() const
Definition: PV3DBase.h:62
virtual const TrackingRecHit * hit() const =0
edm::ESHandle< ClusterShapeHitFilter > filterHandle_
const FastCircle & circle() const
Definition: FastHelix.h:81
virtual void init(const edm::EventSetup &es)
T sqrt(T t)
Definition: SSEVec.h:46
T z() const
Definition: PV3DBase.h:63
PixelClusterShapeSeedComparitor(const edm::ParameterSet &cfg)
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
Definition: DetId.h:20
const T & get() const
Definition: EventSetup.h:55
T perp2() const
Squared magnitude of transverse component.
bool compatibleHit(const TransientTrackingRecHit &hit, const GlobalVector &direction) const
double y0() const
Definition: FastCircle.h:52
virtual GlobalPoint globalPosition() const
virtual bool compatible(const TrajectorySeed &seed) const
unsigned int size() const
Definition: SeedingHitSet.h:31
#define DEFINE_EDM_PLUGIN(factory, type, name)
DetId geographicalId() const
T x() const
Definition: PV3DBase.h:61
const SiStripRecHit2D & originalHit() const
GlobalVector globalDirection() const
Pixel Reconstructed Hit.
virtual bool compatible(const SeedingHitSet &hits, const TrackingRegion &region) const