Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:26:53

0001 #include "FastSimulation/TrackingRecHitProducer/interface/TrackingRecHitAlgorithm.h"
0002 #include "FastSimulation/TrackingRecHitProducer/interface/TrackingRecHitAlgorithmFactory.h"
0003 #include "FastSimulation/TrackingRecHitProducer/interface/TrackingRecHitProduct.h"
0004 
0005 #include "DataFormats/DetId/interface/DetId.h"
0006 #include "SimDataFormats/TrackingHit/interface/PSimHit.h"
0007 #include "DataFormats/TrackerRecHit2D/interface/FastSingleTrackerRecHit.h"
0008 
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 
0011 #include <string>
0012 #include <iostream>
0013 
0014 class TrackingRecHitNoSmearingPlugin : public TrackingRecHitAlgorithm {
0015 private:
0016   double _errorXX;
0017   double _errorXY;
0018   double _errorYY;
0019 
0020 public:
0021   TrackingRecHitNoSmearingPlugin(const std::string& name,
0022                                  const edm::ParameterSet& config,
0023                                  edm::ConsumesCollector& consumesCollector)
0024       : TrackingRecHitAlgorithm(name, config, consumesCollector),
0025         _errorXX(0.001 * 0.001),
0026         _errorXY(0.0),
0027         _errorYY(0.001 * 0.001) {
0028     if (config.exists("errorXX")) {
0029       _errorXX = config.getParameter<double>("errorXX");
0030     }
0031 
0032     if (config.exists("errorXY")) {
0033       _errorXY = config.getParameter<double>("errorXY");
0034     }
0035 
0036     if (config.exists("errorYY")) {
0037       _errorYY = config.getParameter<double>("errorYY");
0038     }
0039   }
0040 
0041   TrackingRecHitProductPtr process(TrackingRecHitProductPtr product) const override {
0042     for (const std::pair<unsigned int, const PSimHit*>& simHitIdPair : product->getSimHitIdPairs()) {
0043       const PSimHit* simHit = simHitIdPair.second;
0044       const Local3DPoint& position = simHit->localPosition();
0045       LocalError error(_errorXX, _errorXY, _errorYY);
0046       const GeomDet* geomDet = getTrackerGeometry().idToDetUnit(product->getDetId());
0047 
0048       //TODO: this is only a minimal example
0049       FastSingleTrackerRecHit recHit(
0050           position,  //const LocalPoint &
0051           error,     //const LocalError &
0052           *geomDet,  //GeomDet const &idet
0053           fastTrackerRecHitType::
0054               siPixel  // since this is a dummy class anyway: pretend all hits are pixel hits (only effect: hits are defined in 2D (?))
0055       );
0056       product->addRecHit(recHit, {simHitIdPair});
0057     }
0058 
0059     return product;
0060   }
0061 };
0062 
0063 DEFINE_EDM_PLUGIN(TrackingRecHitAlgorithmFactory, TrackingRecHitNoSmearingPlugin, "TrackingRecHitNoSmearingPlugin");