Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:59:47

0001 #include <memory>
0002 
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "FWCore/Framework/interface/EventSetup.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 #include "FWCore/Utilities/interface/InputTag.h"
0007 
0008 #include "DataFormats/Common/interface/Handle.h"
0009 #include "DataFormats/VertexReco/interface/Vertex.h"
0010 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0011 #include "DataFormats/JetReco/interface/Jet.h"
0012 #include "DataFormats/JetReco/interface/JetTracksAssociation.h"
0013 #include "DataFormats/JetReco/interface/JetFloatAssociation.h"
0014 
0015 #include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
0016 #include "TrackingTools/Records/interface/TransientTrackRecord.h"
0017 
0018 #include "RecoJets/JetAssociationAlgorithms/interface/JetSignalVertexCompatibilityAlgo.h"
0019 
0020 #include "JetSignalVertexCompatibility.h"
0021 
0022 using namespace reco;
0023 
0024 JetSignalVertexCompatibility::JetSignalVertexCompatibility(const edm::ParameterSet &params)
0025     : algo(params.getParameter<double>("cut"), params.getParameter<double>("temperature")) {
0026   jetTracksAssocToken = consumes<JetTracksAssociationCollection>(params.getParameter<edm::InputTag>("jetTracksAssoc"));
0027   primaryVerticesToken = consumes<VertexCollection>(params.getParameter<edm::InputTag>("primaryVertices"));
0028   builderToken = esConsumes(edm::ESInputTag("", "TransientTrackBuilder"));
0029   produces<JetFloatAssociation::Container>();
0030 }
0031 
0032 JetSignalVertexCompatibility::~JetSignalVertexCompatibility() {}
0033 
0034 void JetSignalVertexCompatibility::produce(edm::Event &event, const edm::EventSetup &es) {
0035   algo.resetEvent(&es.getData(builderToken));
0036 
0037   edm::Handle<JetTracksAssociationCollection> jetTracksAssoc;
0038   event.getByToken(jetTracksAssocToken, jetTracksAssoc);
0039 
0040   edm::Handle<VertexCollection> primaryVertices;
0041   event.getByToken(primaryVerticesToken, primaryVertices);
0042 
0043   auto result = std::make_unique<JetFloatAssociation::Container>(jetTracksAssoc->keyProduct());
0044 
0045   for (JetTracksAssociationCollection::const_iterator iter = jetTracksAssoc->begin(); iter != jetTracksAssoc->end();
0046        ++iter) {
0047     if (primaryVertices->empty())
0048       (*result)[iter->first] = -1.;
0049 
0050     const TrackRefVector &tracks = iter->second;
0051     std::vector<float> compatibility = algo.compatibility(*primaryVertices, tracks);
0052 
0053     // the first vertex is the presumed signal vertex
0054     (*result)[iter->first] = compatibility[0];
0055   }
0056 
0057   algo.resetEvent(nullptr);
0058 
0059   event.put(std::move(result));
0060 }