CMS 3D CMS Logo

TemplatedVertexArbitrator.h
Go to the documentation of this file.
1 #ifndef TemplatedVertexArbitrator_h
2 #define TemplatedVertexArbitrator_h
3 #include <memory>
4 #include <set>
5 
10 
17 
24 
30 
36 
40 
42 
43 //#define VTXDEBUG
44 
45 const unsigned int nTracks(const reco::Vertex &sv) { return sv.nTracks(); }
46 const unsigned int nTracks(const reco::VertexCompositePtrCandidate &sv) { return sv.numberOfSourceCandidatePtrs(); }
47 
48 template <class InputContainer, class VTX>
50 public:
51  typedef std::vector<VTX> Product;
53 
56  pdesc.add<edm::InputTag>("beamSpot", edm::InputTag("offlineBeamSpot"));
57  pdesc.add<edm::InputTag>("primaryVertices", edm::InputTag("offlinePrimaryVertices"));
59  pdesc.add<edm::InputTag>("tracks", edm::InputTag("generalTracks"));
60  pdesc.add<edm::InputTag>("secondaryVertices", edm::InputTag("vertexMerger"));
62  pdesc.add<edm::InputTag>("tracks", edm::InputTag("particleFlow"));
63  pdesc.add<edm::InputTag>("secondaryVertices", edm::InputTag("candidateVertexMerger"));
64  } else {
65  pdesc.add<edm::InputTag>("tracks", edm::InputTag("generalTracks"));
66  pdesc.add<edm::InputTag>("secondaryVertices", edm::InputTag("vertexMerger"));
67  }
68  pdesc.add<double>("dLenFraction", 0.333);
69  pdesc.add<double>("dRCut", 0.4);
70  pdesc.add<double>("distCut", 0.04);
71  pdesc.add<double>("sigCut", 5.0);
72  pdesc.add<double>("fitterSigmacut", 3.0);
73  pdesc.add<double>("fitterTini", 256);
74  pdesc.add<double>("fitterRatio", 0.25);
75  pdesc.add<int>("trackMinLayers", 4);
76  pdesc.add<double>("trackMinPt", 0.4);
77  pdesc.add<int>("trackMinPixels", 1);
78  pdesc.add<double>("maxTimeSignificance", 3.5);
80  cdesc.add("trackVertexArbitratorDefault", pdesc);
82  cdesc.add("candidateVertexArbitratorDefault", pdesc);
83  } else {
84  cdesc.addDefault(pdesc);
85  }
86  }
87 
88  void produce(edm::Event &event, const edm::EventSetup &es) override;
89 
90 private:
91  bool trackFilter(const reco::TrackRef &track) const;
92 
98  std::unique_ptr<TrackVertexArbitration<VTX> > theArbitrator;
99 };
100 
101 template <class InputContainer, class VTX>
103  token_primaryVertex = consumes<reco::VertexCollection>(params.getParameter<edm::InputTag>("primaryVertices"));
104  token_secondaryVertex = consumes<Product>(params.getParameter<edm::InputTag>("secondaryVertices"));
105  token_beamSpot = consumes<reco::BeamSpot>(params.getParameter<edm::InputTag>("beamSpot"));
106  token_tracks = consumes<InputContainer>(params.getParameter<edm::InputTag>("tracks"));
107  token_trackBuilder =
108  esConsumes<TransientTrackBuilder, TransientTrackRecord>(edm::ESInputTag("", "TransientTrackBuilder"));
109  produces<Product>();
110  theArbitrator.reset(new TrackVertexArbitration<VTX>(params));
111 }
112 
113 template <class InputContainer, class VTX>
115  using namespace reco;
116 
118  event.getByToken(token_secondaryVertex, secondaryVertices);
119  Product theSecVertexColl = *(secondaryVertices.product());
120 
122  event.getByToken(token_primaryVertex, primaryVertices);
123 
124  auto recoVertices = std::make_unique<Product>();
125  if (!primaryVertices->empty()) {
126  const reco::Vertex &pv = (*primaryVertices)[0];
127 
129  event.getByToken(token_tracks, tracks);
130 
131  edm::ESHandle<TransientTrackBuilder> trackBuilder = es.getHandle(token_trackBuilder);
132 
134  event.getByToken(token_beamSpot, beamSpot);
135 
136  std::vector<TransientTrack> selectedTracks;
137  for (typename InputContainer::const_iterator track = tracks->begin(); track != tracks->end(); ++track) {
138  selectedTracks.push_back(tthelpers::buildTT(tracks, trackBuilder, track - tracks->begin()));
139  }
140 
141  // const edm::RefVector< TrackCollection > tracksForArbitration= selectedTracks;
142  Product theRecoVertices = theArbitrator->trackVertexArbitrator(beamSpot, pv, selectedTracks, theSecVertexColl);
143 
144  for (unsigned int ivtx = 0; ivtx < theRecoVertices.size(); ivtx++) {
145  if (!(nTracks(theRecoVertices[ivtx]) > 1))
146  continue;
147  recoVertices->push_back(theRecoVertices[ivtx]);
148  }
149  }
150  event.put(std::move(recoVertices));
151 }
152 
153 #endif
nTracks
const unsigned int nTracks(const reco::Vertex &sv)
Definition: TemplatedVertexArbitrator.h:45
Handle.h
TemplatedVertexArbitrator::trackFilter
bool trackFilter(const reco::TrackRef &track) const
edm::ESInputTag
Definition: ESInputTag.h:87
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
pwdgSkimBPark_cfi.beamSpot
beamSpot
Definition: pwdgSkimBPark_cfi.py:5
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
TemplatedVertexArbitrator::token_trackBuilder
edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > token_trackBuilder
Definition: TemplatedVertexArbitrator.h:97
KalmanVertexTrackCompatibilityEstimator.h
TTHelpers.h
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
TrackVertexArbitration
Definition: TrackVertexArbitration.h:54
edm::EDGetTokenT< reco::VertexCollection >
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
EDProducer.h
TemplatedVertexArbitrator::token_primaryVertex
edm::EDGetTokenT< reco::VertexCollection > token_primaryVertex
Definition: TemplatedVertexArbitrator.h:93
TemplatedVertexArbitrator
Definition: TemplatedVertexArbitrator.h:49
VertexDistance3D.h
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
TransientTrack.h
edm::Handle
Definition: AssociativeIterator.h:50
ESGetToken.h
reco::VertexCompositePtrCandidate
Definition: VertexCompositePtrCandidate.h:16
edm::Ref< TrackCollection >
TemplatedVertexArbitrator::token_beamSpot
edm::EDGetTokenT< reco::BeamSpot > token_beamSpot
Definition: TemplatedVertexArbitrator.h:96
TemplatedVertexArbitrator::produce
void produce(edm::Event &event, const edm::EventSetup &es) override
Definition: TemplatedVertexArbitrator.h:114
MakerMacros.h
Track.h
TrackFwd.h
BeamSpot.h
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
pfDeepBoostedJetPreprocessParams_cfi.sv
sv
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:352
edm::ESHandle< TransientTrackBuilder >
TemplatedVertexArbitrator::theArbitrator
std::unique_ptr< TrackVertexArbitration< VTX > > theArbitrator
Definition: TemplatedVertexArbitrator.h:98
VertexCompositePtrCandidate.h
TemplatedVertexArbitrator::token_tracks
edm::EDGetTokenT< InputContainer > token_tracks
Definition: TemplatedVertexArbitrator.h:95
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
Vertex.h
TrackVertexArbitration.h
TransientTrackBuilder.h
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:159
deltaR.h
tthelpers::buildTT
reco::TransientTrack buildTT(edm::Handle< reco::TrackCollection > &tracks, edm::ESHandle< TransientTrackBuilder > &trackbuilder, unsigned int k)
Definition: TTHelpers.h:10
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
ConfigurableVertexReconstructor.h
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
edm::stream::EDProducer
Definition: EDProducer.h:38
TemplatedVertexArbitrator::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &cdesc)
Definition: TemplatedVertexArbitrator.h:54
KalmanVertexUpdator.h
KalmanVertexSmoother.h
HLT_FULL_cff.secondaryVertices
secondaryVertices
Definition: HLT_FULL_cff.py:51966
edm::EventSetup
Definition: EventSetup.h:58
TransientTrackRecord.h
edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord >
TemplatedVertexArbitrator::Product
std::vector< VTX > Product
Definition: TemplatedVertexArbitrator.h:51
InputTag.h
VertexFwd.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
IPTools.h
relativeConstraints.value
value
Definition: relativeConstraints.py:53
TemplatedVertexArbitrator::token_secondaryVertex
edm::EDGetTokenT< Product > token_secondaryVertex
Definition: TemplatedVertexArbitrator.h:94
ParameterSet.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
AdaptiveVertexFitter.h
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
TemplatedVertexArbitrator::TemplatedVertexArbitrator
TemplatedVertexArbitrator(const edm::ParameterSet &params)
Definition: TemplatedVertexArbitrator.h:102
HLT_FULL_cff.primaryVertices
primaryVertices
Definition: HLT_FULL_cff.py:51943
edm::InputTag
Definition: InputTag.h:15
reco::Vertex
Definition: Vertex.h:35
TrackCollections2monitor_cff.selectedTracks
selectedTracks
Definition: TrackCollections2monitor_cff.py:32