CMS 3D CMS Logo

PUAlgoBase.cc
Go to the documentation of this file.
2 
3 #include <TH1F.h>
4 
5 using namespace l1tpf_impl;
6 
8  : debug_(iConfig.getUntrackedParameter<int>("debug", 0)),
9  etaCharged_(iConfig.getParameter<double>("etaCharged")),
10  vtxRes_(iConfig.getParameter<double>("vtxRes")),
11  vtxAdaptiveCut_(iConfig.getParameter<bool>("vtxAdaptiveCut")) {}
12 
14 
15 void PUAlgoBase::runChargedPV(Region &r, float z0) const {
16  int16_t iZ0 = round(z0 * InputTrack::Z0_SCALE);
17  int16_t iDZ = round(1.5 * vtxRes_ * InputTrack::Z0_SCALE);
18  int16_t iDZ2 = vtxAdaptiveCut_ ? round(4.0 * vtxRes_ * InputTrack::Z0_SCALE) : iDZ;
19  for (PFParticle &p : r.pf) {
20  bool barrel = std::abs(p.track.hwVtxEta) < InputTrack::VTX_ETA_1p3;
21  if (r.relativeCoordinates)
22  barrel =
23  (std::abs(r.globalAbsEta(p.track.floatVtxEta())) < 1.3); // FIXME could make a better integer implementation
24  p.chargedPV = (p.hwId <= 1 && std::abs(p.track.hwZ0 - iZ0) < (barrel ? iDZ : iDZ2));
25  }
26 }
27 
28 void PUAlgoBase::doVertexing(std::vector<Region> &rs, VertexAlgo algo, float &pvdz) const {
29  int lNBins = int(40. / vtxRes_);
30  if (algo == VertexAlgo::TP)
31  lNBins *= 3;
32  std::unique_ptr<TH1F> h_dz(new TH1F("h_dz", "h_dz", lNBins, -20, 20));
33  if (algo != VertexAlgo::External) {
34  for (const Region &r : rs) {
35  for (const PropagatedTrack &p : r.track) {
36  if (rs.size() > 1) {
37  if (!r.fiducialLocal(p.floatVtxEta(), p.floatVtxPhi()))
38  continue; // skip duplicates
39  }
40  h_dz->Fill(p.floatDZ(), std::min(p.floatPt(), 50.f));
41  }
42  }
43  }
44  switch (algo) {
46  break;
47  case VertexAlgo::Old: {
48  int imaxbin = h_dz->GetMaximumBin();
49  pvdz = h_dz->GetXaxis()->GetBinCenter(imaxbin);
50  }; break;
51  case VertexAlgo::TP: {
52  float max = 0;
53  int bmax = -1;
54  for (int b = 1; b <= lNBins; ++b) {
55  float sum3 = h_dz->GetBinContent(b) + h_dz->GetBinContent(b + 1) + h_dz->GetBinContent(b - 1);
56  if (bmax == -1 || sum3 > max) {
57  max = sum3;
58  bmax = b;
59  }
60  }
61  pvdz = h_dz->GetXaxis()->GetBinCenter(bmax);
62  }; break;
63  }
64  int16_t iZ0 = round(pvdz * InputTrack::Z0_SCALE);
65  int16_t iDZ = round(1.5 * vtxRes_ * InputTrack::Z0_SCALE);
66  int16_t iDZ2 = vtxAdaptiveCut_ ? round(4.0 * vtxRes_ * InputTrack::Z0_SCALE) : iDZ;
67  for (Region &r : rs) {
68  for (PropagatedTrack &p : r.track) {
69  bool central = std::abs(p.hwVtxEta) < InputTrack::VTX_ETA_1p3;
70  if (r.relativeCoordinates)
71  central =
72  (std::abs(r.globalAbsEta(p.floatVtxEta())) < 1.3); // FIXME could make a better integer implementation
73  p.fromPV = (std::abs(p.hwZ0 - iZ0) < (central ? iDZ : iDZ2));
74  }
75  }
76 }
77 
78 const std::vector<std::string> &PUAlgoBase::puGlobalNames() const {
79  static const std::vector<std::string> empty_;
80  return empty_;
81 }
virtual void runChargedPV(Region &r, float z0) const
Definition: PUAlgoBase.cc:15
PUAlgoBase(const edm::ParameterSet &)
Definition: PUAlgoBase.cc:7
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double b
Definition: hdecay.h:118
virtual void doVertexing(std::vector< Region > &rs, VertexAlgo algo, float &vz) const
Definition: PUAlgoBase.cc:28
VertexAlgo
global operations
Definition: PUAlgoBase.h:15
virtual const std::vector< std::string > & puGlobalNames() const
Definition: PUAlgoBase.cc:78