1 |
dgele |
1.1 |
#ifndef PhysicsTools_PatAlgos_interface_VertexingHelper_h
|
2 |
|
|
#define PhysicsTools_PatAlgos_interface_VertexingHelper_h
|
3 |
|
|
/**
|
4 |
|
|
\class pat::helper::VertexingHelper VertexingHelper.h "PhysicsTools/PatAlgos/interface/VertexingHelper.h"
|
5 |
|
|
\brief Produces and/or checks pat::VertexAssociation's
|
6 |
|
|
|
7 |
|
|
The VertexingHelper produces pat::VertexAssociation, or reads them from the event,
|
8 |
|
|
and can use them to select if a candidate is good or not.
|
9 |
|
|
|
10 |
|
|
\author Giovanni Petrucciani
|
11 |
|
|
\version $Id: VertexingHelper.h,v 1.1 2008/07/22 12:47:01 gpetrucc Exp $
|
12 |
|
|
*/
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
#include "DataFormats/PatCandidates/interface/Vertexing.h"
|
16 |
|
|
#include "DataFormats/Common/interface/ValueMap.h"
|
17 |
|
|
#include "PhysicsTools/PatUtils/interface/VertexAssociationSelector.h"
|
18 |
|
|
|
19 |
|
|
#include "FWCore/ParameterSet/interface/ParameterSet.h"
|
20 |
|
|
#include "FWCore/Framework/interface/Event.h"
|
21 |
|
|
|
22 |
|
|
#include "FWCore/Framework/interface/EventSetup.h"
|
23 |
|
|
#include "FWCore/Framework/interface/ESHandle.h"
|
24 |
|
|
#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
|
25 |
|
|
|
26 |
|
|
#include "PhysicsTools/UtilAlgos/interface/ParameterAdapter.h"
|
27 |
|
|
namespace reco {
|
28 |
|
|
namespace modules {
|
29 |
|
|
/// Helper struct to convert from ParameterSet to ElectronSelection
|
30 |
|
|
template<>
|
31 |
|
|
struct ParameterAdapter<pat::VertexAssociationSelector> {
|
32 |
|
|
static pat::VertexAssociationSelector make(const edm::ParameterSet & iConfig) {
|
33 |
|
|
pat::VertexAssociationSelector::Config assoconf;
|
34 |
|
|
if (iConfig.existsAs<double>("deltaZ")) assoconf.dZ = iConfig.getParameter<double>("deltaZ");
|
35 |
|
|
if (iConfig.existsAs<double>("deltaR")) assoconf.dR = iConfig.getParameter<double>("deltaR");
|
36 |
|
|
if (iConfig.existsAs<double>("sigmasZ")) assoconf.sigmasZ = iConfig.getParameter<double>("sigmasZ");
|
37 |
|
|
if (iConfig.existsAs<double>("sigmasR")) assoconf.sigmasR = iConfig.getParameter<double>("sigmasR");
|
38 |
|
|
return pat::VertexAssociationSelector(assoconf);
|
39 |
|
|
}
|
40 |
|
|
};
|
41 |
|
|
}
|
42 |
|
|
}
|
43 |
|
|
|
44 |
|
|
namespace pat { namespace helper {
|
45 |
|
|
class VertexingHelper {
|
46 |
|
|
public:
|
47 |
|
|
VertexingHelper() : enabled_(false) {}
|
48 |
|
|
VertexingHelper(const edm::ParameterSet &iConfig) ;
|
49 |
|
|
|
50 |
|
|
/// returns true if this was given a non dummy configuration
|
51 |
|
|
bool enabled() const { return enabled_; }
|
52 |
|
|
|
53 |
|
|
/// To be called for each new event, reads in the vertex collection
|
54 |
|
|
void newEvent(const edm::Event &event) ;
|
55 |
|
|
|
56 |
|
|
/// To be called for each new event, reads in the vertex collection and the tracking info
|
57 |
|
|
/// You need this if 'useTrack' is true
|
58 |
|
|
void newEvent(const edm::Event &event, const edm::EventSetup & setup) ;
|
59 |
|
|
|
60 |
|
|
/// Return true if this candidate is associated to a valid vertex
|
61 |
|
|
/// AnyCandRef should be a Ref<>, RefToBase<> or Ptr to a Candidate object
|
62 |
|
|
template<typename AnyCandRef>
|
63 |
|
|
pat::VertexAssociation operator()(const AnyCandRef &) const ;
|
64 |
|
|
|
65 |
|
|
private:
|
66 |
|
|
/// true if it has non null configuration
|
67 |
|
|
bool enabled_;
|
68 |
|
|
|
69 |
|
|
/// true if it's just reading the associations from the event
|
70 |
|
|
bool playback_;
|
71 |
|
|
|
72 |
|
|
/// selector of associations
|
73 |
|
|
pat::VertexAssociationSelector assoSelector_;
|
74 |
|
|
|
75 |
|
|
//-------- Tools for production of vertex associations -------
|
76 |
|
|
edm::InputTag vertices_;
|
77 |
|
|
edm::Handle<reco::VertexCollection > vertexHandle_;
|
78 |
|
|
/// use tracks inside candidates
|
79 |
|
|
bool useTracks_;
|
80 |
|
|
edm::ESHandle<TransientTrackBuilder> ttBuilder_;
|
81 |
|
|
|
82 |
|
|
//--------- Tools for reading vertex associations (playback mode) -----
|
83 |
|
|
edm::InputTag vertexAssociations_;
|
84 |
|
|
edm::Handle<edm::ValueMap<pat::VertexAssociation> > vertexAssoMap_;
|
85 |
|
|
|
86 |
|
|
/// Get out the track from the Candidate / RecoCandidate / PFCandidate
|
87 |
|
|
reco::TrackBaseRef getTrack_(const reco::Candidate &c) const ;
|
88 |
|
|
|
89 |
|
|
/// Try to associated this candidate to a vertex.
|
90 |
|
|
/// If no association is found passing all cuts, return a null association
|
91 |
|
|
pat::VertexAssociation associate(const reco::Candidate &) const ;
|
92 |
|
|
|
93 |
|
|
}; // class
|
94 |
|
|
|
95 |
|
|
template<typename AnyCandRef>
|
96 |
|
|
pat::VertexAssociation
|
97 |
|
|
pat::helper::VertexingHelper::operator()(const AnyCandRef &cand) const
|
98 |
|
|
{
|
99 |
|
|
if (playback_) {
|
100 |
|
|
const pat::VertexAssociation &assoc = (*vertexAssoMap_)[cand];
|
101 |
|
|
return assoSelector_(assoc) ? assoc : pat::VertexAssociation();
|
102 |
|
|
} else {
|
103 |
|
|
return associate( *cand );
|
104 |
|
|
}
|
105 |
|
|
|
106 |
|
|
}
|
107 |
|
|
|
108 |
|
|
} }
|
109 |
|
|
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
#endif
|