00001 #include <memory> 00002 00003 #include "FWCore/Framework/interface/EDProducer.h" 00004 #include "FWCore/Framework/interface/Event.h" 00005 #include "FWCore/Framework/interface/EventSetup.h" 00006 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00007 #include "FWCore/Utilities/interface/InputTag.h" 00008 00009 #include "DataFormats/Common/interface/Handle.h" 00010 #include "DataFormats/VertexReco/interface/Vertex.h" 00011 #include "DataFormats/VertexReco/interface/VertexFwd.h" 00012 #include "DataFormats/JetReco/interface/Jet.h" 00013 #include "DataFormats/JetReco/interface/JetTracksAssociation.h" 00014 #include "DataFormats/JetReco/interface/JetFloatAssociation.h" 00015 00016 #include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" 00017 #include "TrackingTools/Records/interface/TransientTrackRecord.h" 00018 00019 #include "RecoJets/JetAssociationAlgorithms/interface/JetSignalVertexCompatibilityAlgo.h" 00020 00021 #include "JetSignalVertexCompatibility.h" 00022 00023 using namespace reco; 00024 00025 JetSignalVertexCompatibility::JetSignalVertexCompatibility( 00026 const edm::ParameterSet ¶ms) : 00027 algo(params.getParameter<double>("cut"), 00028 params.getParameter<double>("temperature")), 00029 jetTracksAssocLabel(params.getParameter<edm::InputTag>("jetTracksAssoc")), 00030 primaryVerticesLabel(params.getParameter<edm::InputTag>("primaryVertices")) 00031 { 00032 produces<JetFloatAssociation::Container>(); 00033 } 00034 00035 JetSignalVertexCompatibility::~JetSignalVertexCompatibility() 00036 { 00037 } 00038 00039 void JetSignalVertexCompatibility::produce(edm::Event &event, 00040 const edm::EventSetup &es) 00041 { 00042 edm::ESHandle<TransientTrackBuilder> trackBuilder; 00043 es.get<TransientTrackRecord>().get("TransientTrackBuilder", 00044 trackBuilder); 00045 00046 algo.resetEvent(trackBuilder.product()); 00047 00048 edm::Handle<JetTracksAssociationCollection> jetTracksAssoc; 00049 event.getByLabel(jetTracksAssocLabel, jetTracksAssoc); 00050 00051 edm::Handle<VertexCollection> primaryVertices; 00052 event.getByLabel(primaryVerticesLabel, primaryVertices); 00053 00054 std::auto_ptr<JetFloatAssociation::Container> result( 00055 new JetFloatAssociation::Container(jetTracksAssoc->keyProduct())); 00056 00057 for(JetTracksAssociationCollection::const_iterator iter = 00058 jetTracksAssoc->begin(); 00059 iter != jetTracksAssoc->end(); ++iter) { 00060 if (primaryVertices->empty()) 00061 (*result)[iter->first] = -1.; 00062 00063 const TrackRefVector &tracks = iter->second; 00064 std::vector<float> compatibility = 00065 algo.compatibility(*primaryVertices, tracks); 00066 00067 // the first vertex is the presumed signal vertex 00068 (*result)[iter->first] = compatibility[0]; 00069 } 00070 00071 algo.resetEvent(0); 00072 00073 event.put(result); 00074 }