File indexing completed on 2024-04-06 12:11:25
0001 #include "FastSimulation/TrackingRecHitProducer/interface/TrackingRecHitAlgorithm.h"
0002
0003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/Framework/interface/EventSetup.h"
0006 #include "FWCore/Framework/interface/ConsumesCollector.h"
0007 #include "FWCore/ServiceRegistry/interface/Service.h"
0008 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
0009
0010 #include "DataFormats/DetId/interface/DetId.h"
0011 #include "DataFormats/TrackerRecHit2D/interface/FastSingleTrackerRecHit.h"
0012
0013 #include "SimDataFormats/TrackingHit/interface/PSimHit.h"
0014
0015 #include "FastSimulation/TrackingRecHitProducer/interface/TrackingRecHitProduct.h"
0016
0017 #include "FWCore/Utilities/interface/Exception.h"
0018
0019 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0020
0021 TrackingRecHitAlgorithm::TrackingRecHitAlgorithm(const std::string& name,
0022 const edm::ParameterSet& config,
0023 edm::ConsumesCollector& consumesCollector)
0024 : _name(name),
0025 _selectionString(config.getParameter<std::string>("select")),
0026 _trackerTopology(nullptr),
0027 _trackerGeometry(nullptr),
0028 _misalignedTrackerGeometry(nullptr),
0029 trackerTopologyESToken_(consumesCollector.esConsumes()),
0030 trackerGeometryESToken_(consumesCollector.esConsumes()),
0031 misalignedTrackerGeometryESToken_(consumesCollector.esConsumes(edm::ESInputTag("", "MisAligned"))),
0032 _randomEngine(nullptr) {}
0033
0034 const TrackerTopology& TrackingRecHitAlgorithm::getTrackerTopology() const {
0035 if (!_trackerTopology) {
0036 throw cms::Exception("TrackingRecHitAlgorithm ") << _name << ": TrackerTopology not defined";
0037 }
0038 return *_trackerTopology;
0039 }
0040
0041 const TrackerGeometry& TrackingRecHitAlgorithm::getTrackerGeometry() const {
0042 if (!_trackerGeometry) {
0043 throw cms::Exception("TrackingRecHitAlgorithm ") << _name << ": TrackerGeometry not defined";
0044 }
0045 return *_trackerGeometry;
0046 }
0047
0048 const TrackerGeometry& TrackingRecHitAlgorithm::getMisalignedGeometry() const {
0049 if (!_misalignedTrackerGeometry) {
0050 throw cms::Exception("TrackingRecHitAlgorithm ") << _name << ": MisalignedGeometry not defined";
0051 }
0052 return *_misalignedTrackerGeometry;
0053 }
0054
0055 const RandomEngineAndDistribution& TrackingRecHitAlgorithm::getRandomEngine() const {
0056 if (!_randomEngine) {
0057 throw cms::Exception("TrackingRecHitAlgorithm ") << _name << ": RandomEngineAndDistribution not defined";
0058 }
0059 return *_randomEngine;
0060 }
0061
0062 void TrackingRecHitAlgorithm::beginStream(const edm::StreamID& id) {
0063 _randomEngine = std::make_shared<RandomEngineAndDistribution>(id);
0064 }
0065
0066 void TrackingRecHitAlgorithm::beginRun(edm::Run const& run,
0067 const edm::EventSetup& eventSetup,
0068 const SiPixelTemplateDBObject* pixelTemplateDBObjectPtr,
0069 const std::vector<SiPixelTemplateStore>& tempStoreRef) {
0070
0071 }
0072
0073 void TrackingRecHitAlgorithm::beginEvent(edm::Event& event, const edm::EventSetup& eventSetup) {
0074 _trackerTopology = &eventSetup.getData(trackerTopologyESToken_);
0075 _trackerGeometry = &eventSetup.getData(trackerGeometryESToken_);
0076 _misalignedTrackerGeometry = &eventSetup.getData(misalignedTrackerGeometryESToken_);
0077 }
0078
0079 TrackingRecHitProductPtr TrackingRecHitAlgorithm::process(TrackingRecHitProductPtr product) const { return product; }
0080
0081 void TrackingRecHitAlgorithm::endEvent(edm::Event& event, const edm::EventSetup& eventSetup) {
0082
0083 _trackerGeometry = nullptr;
0084 _trackerTopology = nullptr;
0085 _misalignedTrackerGeometry = nullptr;
0086 }
0087
0088 void TrackingRecHitAlgorithm::endStream() { _randomEngine.reset(); }
0089
0090 TrackingRecHitAlgorithm::~TrackingRecHitAlgorithm() {}