File indexing completed on 2024-04-06 12:25:20
0001 #include "FWCore/Framework/interface/Frameworkfwd.h"
0002 #include "FWCore/Framework/interface/global/EDProducer.h"
0003
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/Framework/interface/MakerMacros.h"
0006
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0010 #include "FWCore/Utilities/interface/EDGetToken.h"
0011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0012
0013 #include "RecoTracker/PixelTrackFitting/interface/PixelTrackFilter.h"
0014 #include "RecoHI/HiTracking/interface/HIPixelTrackFilter.h"
0015 #include "DataFormats/SiPixelCluster/interface/SiPixelClusterShapeCache.h"
0016 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0017 #include "RecoTracker/Record/interface/CkfComponentsRecord.h"
0018
0019 class HIPixelTrackFilterProducer : public edm::global::EDProducer<> {
0020 public:
0021 explicit HIPixelTrackFilterProducer(const edm::ParameterSet& iConfig);
0022 ~HIPixelTrackFilterProducer() override;
0023
0024 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0025
0026 private:
0027 void produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const override;
0028
0029 edm::EDGetTokenT<SiPixelClusterShapeCache> theClusterShapeCacheToken;
0030 edm::EDGetTokenT<reco::VertexCollection> theVertexCollectionToken;
0031 edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> theTrackerToken;
0032 edm::ESGetToken<ClusterShapeHitFilter, CkfComponentsRecord> theShapeToken;
0033 edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> theTopoToken;
0034 double theTIPMax, theNSigmaTipMaxTolerance;
0035 double theLIPMax, theNSigmaLipMaxTolerance;
0036 double theChi2Max, thePtMin, thePtMax;
0037 bool useClusterShape;
0038 };
0039
0040 HIPixelTrackFilterProducer::HIPixelTrackFilterProducer(const edm::ParameterSet& iConfig)
0041 : theClusterShapeCacheToken(
0042 consumes<SiPixelClusterShapeCache>(iConfig.getParameter<edm::InputTag>("clusterShapeCacheSrc"))),
0043 theVertexCollectionToken(
0044 consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("VertexCollection"))),
0045 theTrackerToken(esConsumes()),
0046 theShapeToken(esConsumes(edm::ESInputTag("", "ClusterShapeHitFilter"))),
0047 theTopoToken(esConsumes()),
0048 theTIPMax(iConfig.getParameter<double>("tipMax")),
0049 theNSigmaTipMaxTolerance(iConfig.getParameter<double>("nSigmaTipMaxTolerance")),
0050 theLIPMax(iConfig.getParameter<double>("lipMax")),
0051 theNSigmaLipMaxTolerance(iConfig.getParameter<double>("nSigmaLipMaxTolerance")),
0052 theChi2Max(iConfig.getParameter<double>("chi2")),
0053 thePtMin(iConfig.getParameter<double>("ptMin")),
0054 thePtMax(iConfig.getParameter<double>("ptMax")),
0055 useClusterShape(iConfig.getParameter<bool>("useClusterShape")) {
0056 produces<PixelTrackFilter>();
0057 }
0058
0059 void HIPixelTrackFilterProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0060 edm::ParameterSetDescription desc;
0061
0062 desc.add<edm::InputTag>("clusterShapeCacheSrc", edm::InputTag("siPixelClusterShapeCache"));
0063 desc.add<edm::InputTag>("VertexCollection", edm::InputTag("hiSelectedPixelVertex"));
0064 desc.add<double>("ptMin", 1.5);
0065 desc.add<double>("ptMax", 999999.);
0066 desc.add<double>("tipMax", 0);
0067 desc.add<double>("nSigmaTipMaxTolerance", 6.0);
0068 desc.add<double>("lipMax", 0.3);
0069 desc.add<double>("nSigmaLipMaxTolerance", 0);
0070 desc.add<double>("chi2", 1000);
0071 desc.add<bool>("useClusterShape", false);
0072
0073 descriptions.add("hiPixelTrackFilter", desc);
0074 }
0075
0076 HIPixelTrackFilterProducer::~HIPixelTrackFilterProducer() {}
0077
0078 void HIPixelTrackFilterProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0079 edm::Handle<SiPixelClusterShapeCache> cache;
0080 iEvent.getByToken(theClusterShapeCacheToken, cache);
0081
0082 edm::Handle<reco::VertexCollection> vc;
0083 iEvent.getByToken(theVertexCollectionToken, vc);
0084 const reco::VertexCollection* vertices = vc.product();
0085
0086 if (!vertices->empty()) {
0087 edm::LogInfo("HeavyIonVertexing") << "[HIPixelTrackFilterProducer] Pixel track selection based on best vertex"
0088 << "\n vz = " << vertices->begin()->z()
0089 << "\n vz sigma = " << vertices->begin()->zError();
0090 } else {
0091 edm::EDConsumerBase::Labels labels;
0092 labelsForToken(theVertexCollectionToken, labels);
0093
0094 edm::LogError("HeavyIonVertexing")
0095 << "No vertex found in collection '" << labels.module << "'";
0096 }
0097
0098 auto impl = std::make_unique<HIPixelTrackFilter>(cache.product(),
0099 thePtMin,
0100 thePtMax,
0101 &iSetup.getData(theTrackerToken),
0102 &iSetup.getData(theShapeToken),
0103 &iSetup.getData(theTopoToken),
0104 vertices,
0105 theTIPMax,
0106 theNSigmaTipMaxTolerance,
0107 theLIPMax,
0108 theNSigmaLipMaxTolerance,
0109 theChi2Max,
0110 useClusterShape);
0111 auto prod = std::make_unique<PixelTrackFilter>(std::move(impl));
0112 iEvent.put(std::move(prod));
0113 }
0114
0115 DEFINE_FWK_MODULE(HIPixelTrackFilterProducer);