CMS 3D CMS Logo

TrackingRecHitStripGSPlugin.cc
Go to the documentation of this file.
4 
9 
11 
12 #include <string>
13 #include <iostream>
14 
15 /* This plugin performs simple Gaussian smearing (GS) of the sim hit position
16  * per module. If y resolution < 0 (default) the module length/sqrt(12) is taken as uncertainty.
17  */
18 
20 private:
21  double _resolutionX;
22  double _resolutionX2;
23 
24  double _resolutionY;
25  double _resolutionY2;
26 
27  constexpr static double INV12 = 1.0 / 12.0;
28 
29 public:
32  edm::ConsumesCollector& consumesCollector)
33  : TrackingRecHitAlgorithm(name, config, consumesCollector),
34  _resolutionX(0.001),
36  _resolutionY(-1),
38 
39  {
40  if (config.exists("resolutionX")) {
41  _resolutionX = config.getParameter<double>("resolutionX");
43  }
44  if (config.exists("resolutionY")) {
45  _resolutionY = config.getParameter<double>("resolutionY");
47  }
48  }
49 
51  for (const std::pair<unsigned int, const PSimHit*>& simHitIdPair : product->getSimHitIdPairs()) {
52  const PSimHit* simHit = simHitIdPair.second;
53  const Local3DPoint& simHitPosition = simHit->localPosition();
54 
55  const GeomDet* geomDet = this->getTrackerGeometry().idToDetUnit(product->getDetId());
56  const Plane& plane = geomDet->surface();
57  const Bounds& bounds = plane.bounds();
58  const double boundY = bounds.length();
59 
60  Local3DPoint recHitPosition;
61 
62  unsigned int retry = 0;
63  do {
64  recHitPosition = Local3DPoint(simHitPosition.x() + this->getRandomEngine().gaussShoot(0.0, _resolutionX),
65  0.0,
66  0.0 //fix y & z coordinates to center of module
67  );
68 
69  // If we tried to generate thePosition, and it's out of the bounds
70  // for 10 times, then take and return the simHit's location.
71  ++retry;
72  if (retry > 10) {
73  recHitPosition = Local3DPoint(simHitPosition.x(), 0.0, 0.0 //fix y & z coordinates to center of module
74  );
75  break;
76  }
77  } while (not bounds.inside(recHitPosition));
78 
80  //xx (variance)
82  //xy (covariance)
83  0.0,
84  //take here the provided y resolution or (lenght/sqrt(12))^2
85  _resolutionY < 0.0 ? boundY * boundY * INV12 : _resolutionY2);
86 
88  product->addRecHit(recHit, {simHitIdPair});
89  }
90  return product;
91  }
92 };
93 
virtual float length() const =0
TrackingRecHitStripGSPlugin(const std::string &name, const edm::ParameterSet &config, edm::ConsumesCollector &consumesCollector)
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: config.py:1
Definition: Plane.h:16
const RandomEngineAndDistribution & getRandomEngine() const
T x() const
Definition: PV3DBase.h:59
double gaussShoot(double mean=0.0, double sigma=1.0) const
std::shared_ptr< TrackingRecHitProduct > TrackingRecHitProductPtr
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
const TrackerGeometry & getTrackerGeometry() const
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: Bounds.h:18
TrackingRecHitProductPtr process(TrackingRecHitProductPtr product) const override
const Bounds & bounds() const
Definition: Surface.h:87
Point3DBase< float, LocalTag > Local3DPoint
Definition: LocalPoint.h:9