Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-01 22:40:59

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