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 
GeomDet
Definition: GeomDet.h:27
TrackingRecHitStripGSPlugin::_resolutionY
double _resolutionY
Definition: TrackingRecHitStripGSPlugin.cc:24
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
TrackingRecHitAlgorithm::getRandomEngine
const RandomEngineAndDistribution & getRandomEngine() const
Definition: TrackingRecHitAlgorithm.cc:56
Bounds
Definition: Bounds.h:18
TrackingRecHitProduct.h
relativeConstraints.error
error
Definition: relativeConstraints.py:53
rpcPointValidation_cfi.recHit
recHit
Definition: rpcPointValidation_cfi.py:7
Bounds::length
virtual float length() const =0
TrackerGeometry::idToDetUnit
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: TrackerGeometry.cc:183
config
Definition: config.py:1
Plane.h
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
PSimHit.h
TrackingRecHitProductPtr
std::shared_ptr< TrackingRecHitProduct > TrackingRecHitProductPtr
Definition: TrackingRecHitProduct.h:47
Bounds::inside
virtual bool inside(const Local3DPoint &) const =0
Determine if the point is inside the bounds.
rpcPointValidation_cfi.simHit
simHit
Definition: rpcPointValidation_cfi.py:24
Surface::bounds
const Bounds & bounds() const
Definition: Surface.h:87
Point3DBase< float, LocalTag >
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TrackingRecHitAlgorithm::getTrackerGeometry
const TrackerGeometry & getTrackerGeometry() const
Definition: TrackingRecHitAlgorithm.cc:42
TrackingRecHitStripGSPlugin::INV12
constexpr static double INV12
Definition: TrackingRecHitStripGSPlugin.cc:27
edm::ParameterSet
Definition: ParameterSet.h:47
LocalError
Definition: LocalError.h:12
FastSingleTrackerRecHit.h
edmplugin::PluginFactory
Definition: PluginFactory.h:34
TrackingRecHitStripGSPlugin::_resolutionX
double _resolutionX
Definition: TrackingRecHitStripGSPlugin.cc:21
FastSingleTrackerRecHit
Definition: FastSingleTrackerRecHit.h:7
TrackingRecHitStripGSPlugin::_resolutionX2
double _resolutionX2
Definition: TrackingRecHitStripGSPlugin.cc:22
TrackingRecHitStripGSPlugin::process
TrackingRecHitProductPtr process(TrackingRecHitProductPtr product) const override
Definition: TrackingRecHitStripGSPlugin.cc:50
TrackingRecHitAlgorithmFactory.h
TrackingRecHitAlgorithm.h
TrackingRecHitStripGSPlugin::_resolutionY2
double _resolutionY2
Definition: TrackingRecHitStripGSPlugin.cc:25
DetId.h
TrackingRecHitStripGSPlugin::TrackingRecHitStripGSPlugin
TrackingRecHitStripGSPlugin(const std::string &name, const edm::ParameterSet &config, edm::ConsumesCollector &consumesCollector)
Definition: TrackingRecHitStripGSPlugin.cc:30
fastTrackerRecHitType::siStrip1D
Definition: FastTrackerRecHit.h:18
Plane
Definition: Plane.h:16
TrackingRecHitAlgorithm
Definition: TrackingRecHitAlgorithm.h:26
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
ParameterSet.h
PSimHit
Definition: PSimHit.h:15
RandomEngineAndDistribution::gaussShoot
double gaussShoot(double mean=0.0, double sigma=1.0) const
Definition: RandomEngineAndDistribution.h:29
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
TrackingRecHitStripGSPlugin
Definition: TrackingRecHitStripGSPlugin.cc:19
Local3DPoint
Point3DBase< float, LocalTag > Local3DPoint
Definition: LocalPoint.h:9