CMS 3D CMS Logo

VertexProducer.cc
Go to the documentation of this file.
15 
16 using namespace l1tVertexFinder;
17 using namespace std;
18 
20  : l1TracksToken_(consumes<TTTrackCollectionView>(iConfig.getParameter<edm::InputTag>("l1TracksInputTag"))),
22  outputCollectionName_(iConfig.getParameter<std::string>("l1VertexCollectionName")),
23  settings_(AlgoSettings(iConfig)) {
24  // Get configuration parameters
25 
26  switch (settings_.vx_algo()) {
27  case Algorithm::fastHisto:
28  edm::LogInfo("VertexProducer") << "VertexProducer::Finding vertices using the fastHisto binning algorithm";
29  break;
30  case Algorithm::fastHistoEmulation:
31  edm::LogInfo("VertexProducer")
32  << "VertexProducer::Finding vertices using the emulation version of the fastHisto binning algorithm";
33  break;
34  case Algorithm::fastHistoLooseAssociation:
35  edm::LogInfo("VertexProducer")
36  << "VertexProducer::Finding vertices using the fastHistoLooseAssociation binning algorithm";
37  break;
38  case Algorithm::GapClustering:
39  edm::LogInfo("VertexProducer") << "VertexProducer::Finding vertices using a gap clustering algorithm";
40  break;
41  case Algorithm::agglomerativeHierarchical:
42  edm::LogInfo("VertexProducer") << "VertexProducer::Finding vertices using a Simple Merge Clustering algorithm";
43  break;
44  case Algorithm::DBSCAN:
45  edm::LogInfo("VertexProducer") << "VertexProducer::Finding vertices using a DBSCAN algorithm";
46  break;
47  case Algorithm::PVR:
48  edm::LogInfo("VertexProducer") << "VertexProducer::Finding vertices using a PVR algorithm";
49  break;
50  case Algorithm::adaptiveVertexReconstruction:
51  edm::LogInfo("VertexProducer")
52  << "VertexProducer::Finding vertices using an AdaptiveVertexReconstruction algorithm";
53  break;
54  case Algorithm::HPV:
55  edm::LogInfo("VertexProducer") << "VertexProducer::Finding vertices using a Highest Pt Vertex algorithm";
56  break;
57  case Algorithm::Kmeans:
58  edm::LogInfo("VertexProducer") << "VertexProducer::Finding vertices using a kmeans algorithm";
59  break;
60  }
61 
62  //--- Define EDM output to be written to file (if required)
63  if (settings_.vx_algo() == Algorithm::fastHistoEmulation) {
64  produces<l1t::VertexWordCollection>(outputCollectionName_ + "Emulation");
65  } else {
66  produces<l1t::VertexCollection>(outputCollectionName_);
67  }
68 }
69 
72  iEvent.getByToken(l1TracksToken_, l1TracksHandle);
73 
74  std::vector<l1tVertexFinder::L1Track> l1Tracks;
75  l1Tracks.reserve(l1TracksHandle->size());
76  if (settings_.debug() > 1) {
77  edm::LogInfo("VertexProducer") << "produce::Processing " << l1TracksHandle->size() << " tracks";
78  }
79  for (const auto& track : l1TracksHandle->ptrs()) {
80  auto l1track = L1Track(track);
81  // Check the minimum pT of the tracks
82  // This is left here because it represents the smallest pT to be sent by the track finding boards
83  // This has less to do with the algorithms than the constraints of what will be sent to the vertexing algorithm
84  if (l1track.pt() >= settings_.vx_TrackMinPt()) {
85  l1Tracks.push_back(l1track);
86  } else {
87  if (settings_.debug() > 2) {
88  edm::LogInfo("VertexProducer") << "produce::Removing track with too low of a pt (" << l1track.pt() << ")\n"
89  << " word = " << l1track.getTTTrackPtr()->getTrackWord().to_string(2);
90  }
91  }
92  }
93  if (settings_.debug() > 1) {
94  edm::LogInfo("VertexProducer") << "produce::Processing " << l1Tracks.size() << " tracks after minimum pt cut of"
95  << settings_.vx_TrackMinPt() << " GeV";
96  }
97 
98  VertexFinder vf(l1Tracks, settings_);
99 
100  switch (settings_.vx_algo()) {
101  case Algorithm::fastHisto: {
102  const TrackerTopology& tTopo = iSetup.getData(tTopoToken);
103  vf.fastHisto(&tTopo);
104  break;
105  }
106  case Algorithm::fastHistoEmulation:
107  vf.fastHistoEmulation();
108  break;
109  case Algorithm::fastHistoLooseAssociation:
111  break;
112  case Algorithm::GapClustering:
113  vf.GapClustering();
114  break;
115  case Algorithm::agglomerativeHierarchical:
117  break;
118  case Algorithm::DBSCAN:
119  vf.DBSCAN();
120  break;
121  case Algorithm::PVR:
122  vf.PVR();
123  break;
124  case Algorithm::adaptiveVertexReconstruction:
126  break;
127  case Algorithm::HPV:
128  vf.HPV();
129  break;
130  case Algorithm::Kmeans:
131  vf.Kmeans();
132  break;
133  }
134 
135  vf.sortVerticesInPt();
136  vf.findPrimaryVertex();
137 
138  // //=== Store output EDM track and hardware stub collections.
139  if (settings_.vx_algo() == Algorithm::fastHistoEmulation) {
140  std::unique_ptr<l1t::VertexWordCollection> product_emulation =
141  std::make_unique<l1t::VertexWordCollection>(vf.verticesEmulation().begin(), vf.verticesEmulation().end());
142  iEvent.put(std::move(product_emulation), outputCollectionName_ + "Emulation");
143  } else {
144  std::unique_ptr<l1t::VertexCollection> product(new std::vector<l1t::Vertex>());
145  for (const auto& vtx : vf.vertices()) {
146  product->emplace_back(vtx.vertex());
147  }
148  iEvent.put(std::move(product), outputCollectionName_);
149  }
150 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
void fastHistoLooseAssociation()
High pT Vertex Algorithm.
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
void GapClustering()
Gap Clustering Algorithm.
Definition: VertexFinder.cc:65
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void agglomerativeHierarchicalClustering()
Simple Merge Algorithm.
const std::string outputCollectionName_
void adaptiveVertexReconstruction()
Adaptive Vertex Reconstruction algorithm.
int iEvent
Definition: GenABIO.cc:224
void findPrimaryVertex()
Find the primary vertex.
void fastHisto(const TrackerTopology *tTopo)
Histogramming algorithm.
const std::vector< RecoVertex<> > & vertices() const
Returns the z positions of the reconstructed primary vertices.
Definition: VertexFinder.h:73
bool getData(T &iHolder) const
Definition: EventSetup.h:122
void sortVerticesInPt()
Sort vertices in pT.
VertexProducer(const edm::ParameterSet &)
Log< level::Info, false > LogInfo
void PVR()
Find maximum distance in two clusters of tracks.
void fastHistoEmulation()
Histogramming algorithm (emulation)
void HPV()
High pT Vertex Algorithm.
TTTrack< Ref_Phase2TrackerDigi_ > L1Track
Definition: L1Track.h:8
HLT enums.
void Kmeans()
Kmeans Algorithm.
const l1t::VertexWordCollection & verticesEmulation() const
Returns the emulation primary vertices.
Definition: VertexFinder.h:75
Algorithm vx_algo() const
Definition: AlgoSettings.h:34
void DBSCAN()
DBSCAN algorithm.
def move(src, dest)
Definition: eostools.py:511
l1tVertexFinder::AlgoSettings settings_