CMS 3D CMS Logo

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