File indexing completed on 2024-04-06 12:27:44
0001 #ifndef TauRegionalPixelSeedGenerator_h
0002 #define TauRegionalPixelSeedGenerator_h
0003
0004
0005
0006
0007 #include "FWCore/Framework/interface/Event.h"
0008 #include "FWCore/Framework/interface/EventSetup.h"
0009 #include "FWCore/Utilities/interface/InputTag.h"
0010 #include "FWCore/Framework/interface/ConsumesCollector.h"
0011 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0012 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0013 #include "DataFormats/Common/interface/Handle.h"
0014 #include "DataFormats/VertexReco/interface/Vertex.h"
0015 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0016 #include "DataFormats/TrackReco/interface/Track.h"
0017 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
0018 #include "DataFormats/Math/interface/Vector3D.h"
0019 #include "MagneticField/Engine/interface/MagneticField.h"
0020 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0021 #include "RecoTracker/Record/interface/TrackerMultipleScatteringRecord.h"
0022 #include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h"
0023 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegionProducer.h"
0024 #include "RecoTracker/TkTrackingRegions/interface/GlobalTrackingRegion.h"
0025 #include "RecoTracker/TkTrackingRegions/interface/RectangularEtaPhiTrackingRegion.h"
0026 #include "RecoTracker/MeasurementDet/interface/MeasurementTrackerEvent.h"
0027
0028 #include "Math/GenVector/VectorUtil.h"
0029 #include "Math/GenVector/PxPyPzE4D.h"
0030
0031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0032
0033 #include "DataFormats/Common/interface/Ref.h"
0034 #include "DataFormats/JetReco/interface/Jet.h"
0035
0036 class TauRegionalPixelSeedGenerator : public TrackingRegionProducer {
0037 public:
0038 explicit TauRegionalPixelSeedGenerator(const edm::ParameterSet& conf, edm::ConsumesCollector&& iC)
0039 : token_bfield(iC.esConsumes()), token_msmaker(iC.esConsumes()) {
0040 edm::LogInfo("TauRegionalPixelSeedGenerator") << "Enter the TauRegionalPixelSeedGenerator";
0041
0042 edm::ParameterSet regionPSet = conf.getParameter<edm::ParameterSet>("RegionPSet");
0043
0044 m_ptMin = regionPSet.getParameter<double>("ptMin");
0045 m_originRadius = regionPSet.getParameter<double>("originRadius");
0046 m_halfLength = regionPSet.getParameter<double>("originHalfLength");
0047 m_deltaEta = regionPSet.getParameter<double>("deltaEtaRegion");
0048 m_deltaPhi = regionPSet.getParameter<double>("deltaPhiRegion");
0049 token_jet = iC.consumes<reco::CandidateView>(regionPSet.getParameter<edm::InputTag>("JetSrc"));
0050 token_vertex = iC.consumes<reco::VertexCollection>(regionPSet.getParameter<edm::InputTag>("vertexSrc"));
0051 if (regionPSet.exists("searchOpt")) {
0052 m_searchOpt = regionPSet.getParameter<bool>("searchOpt");
0053 } else {
0054 m_searchOpt = false;
0055 }
0056 m_howToUseMeasurementTracker = RectangularEtaPhiTrackingRegion::stringToUseMeasurementTracker(
0057 regionPSet.getParameter<std::string>("howToUseMeasurementTracker"));
0058 if (m_howToUseMeasurementTracker != RectangularEtaPhiTrackingRegion::UseMeasurementTracker::kNever) {
0059
0060 edm::InputTag tag;
0061 if (regionPSet.existsAs<edm::InputTag>("measurementTrackerName")) {
0062 tag = regionPSet.getParameter<edm::InputTag>("measurementTrackerName");
0063 } else {
0064 tag = edm::InputTag(regionPSet.getParameter<std::string>("measurementTrackerName"));
0065 }
0066
0067 token_measurementTracker = iC.consumes<MeasurementTrackerEvent>(tag);
0068 }
0069 }
0070
0071 ~TauRegionalPixelSeedGenerator() override {}
0072
0073 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0074 edm::ParameterSetDescription desc;
0075
0076 desc.add<double>("ptMin", 5.0);
0077 desc.add<double>("originHalfLength", 0.2);
0078 desc.add<double>("originRadius", 0.2);
0079 desc.add<double>("deltaEtaRegion", 0.1);
0080 desc.add<double>("deltaPhiRegion", 0.1);
0081 desc.add<edm::InputTag>("JetSrc", edm::InputTag("icone5Tau1"));
0082 desc.add<edm::InputTag>("vertexSrc", edm::InputTag("pixelVertices"));
0083 desc.add<bool>("searchOpt", false);
0084
0085 desc.add<std::string>("howToUseMeasurementTracker", "ForSiStrips");
0086
0087
0088 desc.addNode(edm::ParameterDescription<edm::InputTag>(
0089 "measurementTrackerName", edm::InputTag("MeasurementTrackerEvent"), true) xor
0090 edm::ParameterDescription<std::string>("measurementTrackerName", "MeasurementTrackerEvent", true));
0091
0092
0093 edm::ParameterSetDescription descRegion;
0094 descRegion.add<edm::ParameterSetDescription>("RegionPSet", desc);
0095
0096 descriptions.add("tauRegionalPixelSeedTrackingRegions", descRegion);
0097 }
0098
0099 std::vector<std::unique_ptr<TrackingRegion> > regions(const edm::Event& e, const edm::EventSetup& es) const override {
0100 std::vector<std::unique_ptr<TrackingRegion> > result;
0101
0102
0103 double deltaZVertex, deltaRho;
0104 GlobalPoint vertex;
0105
0106 edm::Handle<reco::VertexCollection> h_vertices;
0107 e.getByToken(token_vertex, h_vertices);
0108 const reco::VertexCollection& vertices = *h_vertices;
0109 if (not vertices.empty()) {
0110
0111 GlobalPoint myTmp(vertices.at(0).position().x(), vertices.at(0).position().y(), vertices.at(0).position().z());
0112 vertex = myTmp;
0113 deltaZVertex = m_halfLength;
0114 deltaRho = m_originRadius;
0115 } else {
0116
0117 GlobalPoint myTmp(0., 0., 0.);
0118 vertex = myTmp;
0119 deltaRho = 1.;
0120 deltaZVertex = 15.;
0121 }
0122
0123
0124 edm::Handle<edm::View<reco::Candidate> > h_jets;
0125 e.getByToken(token_jet, h_jets);
0126
0127 const MeasurementTrackerEvent* measurementTracker = nullptr;
0128 if (!token_measurementTracker.isUninitialized()) {
0129 edm::Handle<MeasurementTrackerEvent> hmte;
0130 e.getByToken(token_measurementTracker, hmte);
0131 measurementTracker = hmte.product();
0132 }
0133
0134 const auto& bfield = es.getData(token_bfield);
0135 const auto& msmaker = es.getData(token_msmaker);
0136
0137 for (const reco::Candidate& myJet : *h_jets) {
0138 GlobalVector jetVector(myJet.momentum().x(), myJet.momentum().y(), myJet.momentum().z());
0139
0140 result.push_back(std::make_unique<RectangularEtaPhiTrackingRegion>(jetVector,
0141 vertex,
0142 m_ptMin,
0143 deltaRho,
0144 deltaZVertex,
0145 m_deltaEta,
0146 m_deltaPhi,
0147 bfield,
0148 &msmaker,
0149 true,
0150 m_howToUseMeasurementTracker,
0151 measurementTracker,
0152 m_searchOpt));
0153 }
0154
0155 return result;
0156 }
0157
0158 private:
0159 float m_ptMin;
0160 float m_originRadius;
0161 float m_halfLength;
0162 float m_deltaEta;
0163 float m_deltaPhi;
0164 edm::EDGetTokenT<reco::VertexCollection> token_vertex;
0165 edm::EDGetTokenT<reco::CandidateView> token_jet;
0166 edm::EDGetTokenT<MeasurementTrackerEvent> token_measurementTracker;
0167 edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> token_bfield;
0168 edm::ESGetToken<MultipleScatteringParametrisationMaker, TrackerMultipleScatteringRecord> token_msmaker;
0169 RectangularEtaPhiTrackingRegion::UseMeasurementTracker m_howToUseMeasurementTracker;
0170 bool m_searchOpt;
0171 };
0172
0173 #endif