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 }
l1tpf_impl::PUAlgoBase::VertexAlgo::TP
electrons_cff.bool
bool
Definition: electrons_cff.py:366
l1tpf_impl::PUAlgoBase::VertexAlgo::Old
Reference_intrackfit_cff.barrel
list barrel
Definition: Reference_intrackfit_cff.py:37
l1tpf_impl::PropagatedTrack
Definition: DiscretePFInputs.h:119
l1tpf_impl
Definition: BitwisePFAlgo.h:8
l1tpf_impl::PUAlgoBase::vtxRes_
float vtxRes_
Definition: PUAlgoBase.h:28
l1tpf_impl::PUAlgoBase::PUAlgoBase
PUAlgoBase(const edm::ParameterSet &)
Definition: PUAlgoBase.cc:7
min
T min(T a, T b)
Definition: MathUtil.h:58
l1tpf_impl::PUAlgoBase::VertexAlgo
VertexAlgo
global operations
Definition: PUAlgoBase.h:15
l1tpf_impl::PFParticle
Definition: DiscretePFInputs.h:184
cmsdt::algo
algo
Definition: constants.h:171
l1tpf_impl::PUAlgoBase::~PUAlgoBase
virtual ~PUAlgoBase()
Definition: PUAlgoBase.cc:13
HLTMuonOfflineAnalyzer_cfi.z0
z0
Definition: HLTMuonOfflineAnalyzer_cfi.py:98
b
double b
Definition: hdecay.h:118
l1tpf_impl::PUAlgoBase::vtxAdaptiveCut_
bool vtxAdaptiveCut_
Definition: PUAlgoBase.h:29
l1tpf_impl::Region
Definition: Region.h:8
edm::ParameterSet
Definition: ParameterSet.h:47
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
ReggeGribovPartonMC_AdvancedParameters_cfi.bmax
bmax
Definition: ReggeGribovPartonMC_AdvancedParameters_cfi.py:5
l1tpf_impl::PUAlgoBase::VertexAlgo::External
createfilelist.int
int
Definition: createfilelist.py:10
l1tpf_impl::PUAlgoBase::doVertexing
virtual void doVertexing(std::vector< Region > &rs, VertexAlgo algo, float &vz) const
Definition: PUAlgoBase.cc:28
alignCSCRings.r
r
Definition: alignCSCRings.py:93
central
Definition: L1PrefiringWeightProducer.cc:40
l1tpf_impl::PUAlgoBase::runChargedPV
virtual void runChargedPV(Region &r, float z0) const
Definition: PUAlgoBase.cc:15
PUAlgoBase.h
l1tpf_impl::PUAlgoBase::puGlobalNames
virtual const std::vector< std::string > & puGlobalNames() const
Definition: PUAlgoBase.cc:78
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22