File indexing completed on 2024-04-06 12:27:50
0001
0002
0003
0004
0005
0006
0007
0008 #include "DataFormats/JetReco/interface/JetTracksAssociation.h"
0009 #include "DataFormats/TauReco/interface/PFTauTagInfo.h"
0010 #include "DataFormats/VertexReco/interface/Vertex.h"
0011 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0012
0013 #include "RecoTauTag/RecoTau/interface/PFRecoTauTagInfoAlgorithm.h"
0014
0015 #include "FWCore/Framework/interface/EventSetup.h"
0016 #include "FWCore/Framework/interface/Event.h"
0017 #include "FWCore/Framework/interface/MakerMacros.h"
0018 #include "FWCore/Framework/interface/Frameworkfwd.h"
0019 #include "FWCore/Framework/interface/global/EDProducer.h"
0020
0021 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0022 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0023
0024 #include <FWCore/ParameterSet/interface/ConfigurationDescriptions.h>
0025 #include <FWCore/ParameterSet/interface/ParameterSetDescription.h>
0026
0027 #include "CLHEP/Random/RandGauss.h"
0028
0029 #include "Math/GenVector/VectorUtil.h"
0030
0031 #include <memory>
0032
0033 using namespace reco;
0034 using namespace edm;
0035 using namespace std;
0036
0037 class PFRecoTauTagInfoProducer : public edm::global::EDProducer<> {
0038 public:
0039 explicit PFRecoTauTagInfoProducer(const edm::ParameterSet& iConfig);
0040 ~PFRecoTauTagInfoProducer() override;
0041 void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0042 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0043
0044 private:
0045 std::unique_ptr<const PFRecoTauTagInfoAlgorithm> PFRecoTauTagInfoAlgo_;
0046 edm::InputTag PFCandidateProducer_;
0047 edm::InputTag PFJetTracksAssociatorProducer_;
0048 edm::InputTag PVProducer_;
0049 double smearedPVsigmaX_;
0050 double smearedPVsigmaY_;
0051 double smearedPVsigmaZ_;
0052
0053 edm::EDGetTokenT<PFCandidateCollection> PFCandidate_token;
0054 edm::EDGetTokenT<JetTracksAssociationCollection> PFJetTracksAssociator_token;
0055 edm::EDGetTokenT<VertexCollection> PV_token;
0056 };
0057
0058 PFRecoTauTagInfoProducer::PFRecoTauTagInfoProducer(const edm::ParameterSet& iConfig) {
0059 PFCandidateProducer_ = iConfig.getParameter<edm::InputTag>("PFCandidateProducer");
0060 PFJetTracksAssociatorProducer_ = iConfig.getParameter<edm::InputTag>("PFJetTracksAssociatorProducer");
0061 PVProducer_ = iConfig.getParameter<edm::InputTag>("PVProducer");
0062 smearedPVsigmaX_ = iConfig.getParameter<double>("smearedPVsigmaX");
0063 smearedPVsigmaY_ = iConfig.getParameter<double>("smearedPVsigmaY");
0064 smearedPVsigmaZ_ = iConfig.getParameter<double>("smearedPVsigmaZ");
0065 PFRecoTauTagInfoAlgo_ = std::make_unique<PFRecoTauTagInfoAlgorithm>(iConfig);
0066 PFCandidate_token = consumes<PFCandidateCollection>(PFCandidateProducer_);
0067 PFJetTracksAssociator_token = consumes<JetTracksAssociationCollection>(PFJetTracksAssociatorProducer_);
0068 PV_token = consumes<VertexCollection>(PVProducer_);
0069 produces<PFTauTagInfoCollection>();
0070 }
0071 PFRecoTauTagInfoProducer::~PFRecoTauTagInfoProducer() {}
0072
0073 void PFRecoTauTagInfoProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0074 edm::Handle<JetTracksAssociationCollection> thePFJetTracksAssociatorCollection;
0075 iEvent.getByToken(PFJetTracksAssociator_token, thePFJetTracksAssociatorCollection);
0076
0077 edm::Handle<PFCandidateCollection> thePFCandidateCollection;
0078 iEvent.getByToken(PFCandidate_token, thePFCandidateCollection);
0079 vector<CandidatePtr> thePFCandsInTheEvent;
0080 for (unsigned int i_PFCand = 0; i_PFCand != thePFCandidateCollection->size(); i_PFCand++) {
0081 thePFCandsInTheEvent.push_back(CandidatePtr(thePFCandidateCollection, i_PFCand));
0082 }
0083
0084
0085 edm::Handle<VertexCollection> thePVs;
0086 iEvent.getByToken(PV_token, thePVs);
0087 const VertexCollection vertCollection = *(thePVs.product());
0088 math::XYZPoint V(0, 0, -1000.);
0089
0090 Vertex thePV;
0091 if (!vertCollection.empty())
0092 thePV = *(vertCollection.begin());
0093 else {
0094 Vertex::Error SimPVError;
0095 SimPVError(0, 0) = 15. * 15.;
0096 SimPVError(1, 1) = 15. * 15.;
0097 SimPVError(2, 2) = 15. * 15.;
0098 Vertex::Point SimPVPoint(0., 0., -1000.);
0099 thePV = Vertex(SimPVPoint, SimPVError, 1, 1, 1);
0100 }
0101
0102 auto resultExt = std::make_unique<PFTauTagInfoCollection>();
0103 for (JetTracksAssociationCollection::const_iterator iAssoc = thePFJetTracksAssociatorCollection->begin();
0104 iAssoc != thePFJetTracksAssociatorCollection->end();
0105 iAssoc++) {
0106 PFTauTagInfo myPFTauTagInfo = PFRecoTauTagInfoAlgo_->buildPFTauTagInfo(
0107 JetBaseRef((*iAssoc).first), thePFCandsInTheEvent, (*iAssoc).second, thePV);
0108 resultExt->push_back(myPFTauTagInfo);
0109 }
0110
0111
0112 iEvent.put(std::move(resultExt));
0113 }
0114
0115 void PFRecoTauTagInfoProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0116 {
0117
0118 edm::ParameterSetDescription desc;
0119 desc.add<int>("tkminTrackerHitsn", 3);
0120 desc.add<double>("tkminPt", 0.5);
0121 desc.add<double>("tkmaxChi2", 100.0);
0122 desc.add<double>("ChargedHadrCand_AssociationCone", 1.0);
0123 desc.add<int>("ChargedHadrCand_tkminTrackerHitsn", 3);
0124 desc.add<double>("ChargedHadrCand_tkmaxChi2", 100.0);
0125 desc.add<double>("tkPVmaxDZ", 0.2);
0126 desc.add<double>("GammaCand_EcalclusMinEt", 1.0);
0127 desc.add<int>("tkminPixelHitsn", 0);
0128 desc.add<edm::InputTag>("PVProducer", edm::InputTag("offlinePrimaryVertices"));
0129 desc.add<edm::InputTag>("PFCandidateProducer", edm::InputTag("particleFlow"));
0130 desc.add<double>("ChargedHadrCand_tkminPt", 0.5);
0131 desc.add<double>("ChargedHadrCand_tkmaxipt", 0.03);
0132 desc.add<int>("ChargedHadrCand_tkminPixelHitsn", 0);
0133 desc.add<bool>("UsePVconstraint", true);
0134 desc.add<double>("NeutrHadrCand_HcalclusMinEt", 1.0);
0135 desc.add<edm::InputTag>("PFJetTracksAssociatorProducer", edm::InputTag("insideOutJetTracksAssociatorAtVertex"));
0136 desc.add<double>("smearedPVsigmaY", 0.0015);
0137 desc.add<double>("smearedPVsigmaX", 0.0015);
0138 desc.add<double>("smearedPVsigmaZ", 0.005);
0139 desc.add<double>("ChargedHadrCand_tkPVmaxDZ", 0.2);
0140 desc.add<double>("tkmaxipt", 0.03);
0141 descriptions.add("pfRecoTauTagInfoProducerInsideOut", desc);
0142 }
0143 {
0144
0145 edm::ParameterSetDescription desc;
0146 desc.add<int>("tkminTrackerHitsn", 3);
0147 desc.add<double>("tkminPt", 0.5);
0148 desc.add<double>("tkmaxChi2", 100.0);
0149 desc.add<double>("ChargedHadrCand_AssociationCone", 0.8);
0150 desc.add<int>("ChargedHadrCand_tkminTrackerHitsn", 3);
0151 desc.add<double>("ChargedHadrCand_tkmaxChi2", 100.0);
0152 desc.add<double>("tkPVmaxDZ", 0.2);
0153 desc.add<double>("GammaCand_EcalclusMinEt", 1.0);
0154 desc.add<int>("tkminPixelHitsn", 0);
0155 desc.add<edm::InputTag>("PVProducer", edm::InputTag("offlinePrimaryVertices"));
0156 desc.add<edm::InputTag>("PFCandidateProducer", edm::InputTag("particleFlow"));
0157 desc.add<double>("ChargedHadrCand_tkminPt", 0.5);
0158 desc.add<double>("ChargedHadrCand_tkmaxipt", 0.03);
0159 desc.add<int>("ChargedHadrCand_tkminPixelHitsn", 0);
0160 desc.add<bool>("UsePVconstraint", true);
0161 desc.add<double>("NeutrHadrCand_HcalclusMinEt", 1.0);
0162 desc.add<edm::InputTag>("PFJetTracksAssociatorProducer", edm::InputTag("ak4PFJetTracksAssociatorAtVertex"));
0163 desc.add<double>("smearedPVsigmaY", 0.0015);
0164 desc.add<double>("smearedPVsigmaX", 0.0015);
0165 desc.add<double>("smearedPVsigmaZ", 0.005);
0166 desc.add<double>("ChargedHadrCand_tkPVmaxDZ", 0.2);
0167 desc.add<double>("tkmaxipt", 0.03);
0168 descriptions.add("pfRecoTauTagInfoProducer", desc);
0169 }
0170 }
0171
0172 DEFINE_FWK_MODULE(PFRecoTauTagInfoProducer);