CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
l1ct::L1EGPuppiIsoAlgo Class Reference

#include <L1EGPuppiIsoAlgo.h>

Public Member Functions

 L1EGPuppiIsoAlgo (const L1EGPuppiIsoAlgoConfig &config)
 
 L1EGPuppiIsoAlgo (const edm::ParameterSet &pSet)
 
void run (const EGIsoObjsEmu &l1EGs, const PuppiObjs &l1PFCands, EGIsoObjsEmu &outL1EGs, z0_t z0=0) const
 
void run (EGIsoObjsEmu &l1EGs, const PuppiObjs &l1PFCands, z0_t z0=0) const
 
void run (EGIsoEleObjsEmu &l1Eles, const PuppiObjs &l1PFCands) const
 
virtual ~L1EGPuppiIsoAlgo ()=default
 

Private Member Functions

iso_t calcIso (const EGIsoObj &l1EG, std::list< const PuppiObj *> &workPFCands, z0_t z0=0) const
 

Private Attributes

const L1EGPuppiIsoAlgoConfig config_
 

Detailed Description

Definition at line 45 of file L1EGPuppiIsoAlgo.h.

Constructor & Destructor Documentation

◆ L1EGPuppiIsoAlgo() [1/2]

l1ct::L1EGPuppiIsoAlgo::L1EGPuppiIsoAlgo ( const L1EGPuppiIsoAlgoConfig config)
inline

Definition at line 47 of file L1EGPuppiIsoAlgo.h.

47 : config_(config) {}
const L1EGPuppiIsoAlgoConfig config_
Definition: config.py:1

◆ L1EGPuppiIsoAlgo() [2/2]

L1EGPuppiIsoAlgo::L1EGPuppiIsoAlgo ( const edm::ParameterSet pSet)

Definition at line 5 of file L1EGPuppiIsoAlgo.cc.

6  : config_(pSet.getParameter<std::string>("pfIsoType"),
7  pSet.getParameter<double>("pfPtMin"),
8  pSet.getParameter<double>("dZ"),
9  pSet.getParameter<double>("dRMin"),
10  pSet.getParameter<double>("dRMax"),
11  pSet.getParameter<bool>("pfCandReuse")) {}
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const L1EGPuppiIsoAlgoConfig config_

◆ ~L1EGPuppiIsoAlgo()

virtual l1ct::L1EGPuppiIsoAlgo::~L1EGPuppiIsoAlgo ( )
virtualdefault

Member Function Documentation

◆ calcIso()

iso_t L1EGPuppiIsoAlgo::calcIso ( const EGIsoObj l1EG,
std::list< const PuppiObj *> &  workPFCands,
z0_t  z0 = 0 
) const
private

Definition at line 98 of file L1EGPuppiIsoAlgo.cc.

References config_, ALPAKA_ACCELERATOR_NAMESPACE::dR2(), l1ct::dr2_int(), l1ct::L1EGPuppiIsoAlgoConfig::dRMin2_, PVValHelper::dz, l1ct::L1EGPuppiIsoAlgoConfig::dZMax_, l1trig_cff::hwPt, triggerObjects_cff::l1EG, l1ct::L1EGPuppiIsoAlgoConfig::pfCandReuse_, l1ct::L1EGPuppiIsoAlgoConfig::ptMin_, and TtFullHadEvtBuilder_cfi::sumPt.

Referenced by run().

98  {
99  iso_t sumPt = 0;
100 
101  auto pfIt = workPFCands.cbegin();
102  while (pfIt != workPFCands.cend()) {
103  // use the PF candidate pT if it is within the cone and optional dz cut for charged PF candidates
104  const auto workPFCand = *pfIt;
105  z0_t pfCandZ0 = 0;
106  if (workPFCand->hwId.charged()) {
107  pfCandZ0 = workPFCand->hwZ0();
108  }
109 
110  // calculate dz
111  ap_int<z0_t::width + 1> dz = z0 - pfCandZ0;
112  if (dz < 0) {
113  dz = -dz;
114  }
115 
116  if (workPFCand->intCharge() == 0 || (workPFCand->intCharge() != 0 && dz < config_.dZMax_)) {
117  const auto dR2 = dr2_int(l1EG.hwEta, l1EG.hwPhi, workPFCand->hwEta, workPFCand->hwPhi);
118  if (dR2 >= config_.dRMin2_ && dR2 < config_.dRMax2_ && workPFCand->hwPt >= config_.ptMin_) {
119  sumPt += workPFCand->hwPt;
120  // remove the candidate from the collection if the module is configured to not reuse them
121  if (!config_.pfCandReuse_) {
122  // this returns an iterator to the next element already so no need to increase here
123  pfIt = workPFCands.erase(pfIt);
124  continue;
125  }
126  }
127  }
128  ++pfIt;
129  }
130 
131  return sumPt;
132 }
int dr2_int(eta_t eta1, phi_t phi1, eta_t eta2, phi_t phi2)
Definition: datatypes.h:220
const L1EGPuppiIsoAlgoConfig config_
ALPAKA_FN_ACC static ALPAKA_FN_INLINE float dR2(Position4 pos1, Position4 pos2)
ap_ufixed< 11, 9, AP_TRN, AP_SAT > iso_t
Definition: datatypes.h:40
ap_int< 10 > z0_t
Definition: datatypes.h:21
ap_int< z0_t::width+1 > dZMax_

◆ run() [1/3]

void L1EGPuppiIsoAlgo::run ( const EGIsoObjsEmu l1EGs,
const PuppiObjs l1PFCands,
EGIsoObjsEmu outL1EGs,
z0_t  z0 = 0 
) const

Definition at line 13 of file L1EGPuppiIsoAlgo.cc.

References calcIso(), config_, genparticles_cff::iso, l1ct::L1EGPuppiIsoAlgoConfig::kPFIso, triggerObjects_cff::l1EG, and l1ct::L1EGPuppiIsoAlgoConfig::pfIsoType_.

Referenced by L1TCtL2EgProducer::produce().

16  {
17  outL1EGs.reserve(l1EGs.size());
18 
19  // make a list of pointers to PF candidates
20  // the pointer will be removed from the list once the candidate has been used and the the module is configured to to so
21  std::list<const PuppiObj*> workPFCands;
22  std::list<const PuppiObj*> workPFCandsPV;
23  for (const auto& l1PFCand : l1PFCands) {
24  workPFCands.emplace_back(&l1PFCand);
25  workPFCandsPV.emplace_back(&l1PFCand);
26  }
27 
28  for (const auto& l1EG : l1EGs) {
29  auto outL1EG(l1EG);
30  iso_t iso = 0;
31  iso_t isoPV = 0;
32  if (!workPFCands.empty()) {
33  iso = calcIso(l1EG, workPFCands);
34  isoPV = calcIso(l1EG, workPFCandsPV, z0);
35  }
36 
38  outL1EG.setHwIso(EGIsoObjEmu::IsoType::PfIso, iso);
39  outL1EG.setHwIso(EGIsoObjEmu::IsoType::PfIsoPV, isoPV);
40  } else {
41  outL1EG.setHwIso(EGIsoObjEmu::IsoType::PuppiIso, iso);
42  outL1EG.setHwIso(EGIsoObjEmu::IsoType::PuppiIsoPV, isoPV);
43  }
44  outL1EGs.emplace_back(outL1EG);
45  }
46 }
const L1EGPuppiIsoAlgoConfig config_
ap_ufixed< 11, 9, AP_TRN, AP_SAT > iso_t
Definition: datatypes.h:40
iso_t calcIso(const EGIsoObj &l1EG, std::list< const PuppiObj *> &workPFCands, z0_t z0=0) const

◆ run() [2/3]

void L1EGPuppiIsoAlgo::run ( EGIsoObjsEmu l1EGs,
const PuppiObjs l1PFCands,
z0_t  z0 = 0 
) const

Definition at line 48 of file L1EGPuppiIsoAlgo.cc.

References calcIso(), config_, genparticles_cff::iso, l1ct::L1EGPuppiIsoAlgoConfig::kPFIso, triggerObjects_cff::l1EG, and l1ct::L1EGPuppiIsoAlgoConfig::pfIsoType_.

48  {
49  // make a list of pointers to PF candidates
50  // the pointer will be removed from the list once the candidate has been used and the the module is configured to to so
51  std::list<const PuppiObj*> workPFCands;
52  std::list<const PuppiObj*> workPFCandsPV;
53  for (const auto& l1PFCand : l1PFCands) {
54  workPFCands.emplace_back(&l1PFCand);
55  workPFCandsPV.emplace_back(&l1PFCand);
56  }
57 
58  for (auto& l1EG : l1EGs) {
59  iso_t iso = 0;
60  iso_t isoPV = 0;
61  if (!workPFCands.empty()) {
62  iso = calcIso(l1EG, workPFCands);
63  isoPV = calcIso(l1EG, workPFCandsPV, z0);
64  }
65 
67  l1EG.setHwIso(EGIsoObjEmu::IsoType::PfIso, iso);
68  l1EG.setHwIso(EGIsoObjEmu::IsoType::PfIsoPV, isoPV);
69  } else {
70  l1EG.setHwIso(EGIsoObjEmu::IsoType::PuppiIso, iso);
71  l1EG.setHwIso(EGIsoObjEmu::IsoType::PuppiIsoPV, isoPV);
72  }
73  }
74 }
const L1EGPuppiIsoAlgoConfig config_
ap_ufixed< 11, 9, AP_TRN, AP_SAT > iso_t
Definition: datatypes.h:40
iso_t calcIso(const EGIsoObj &l1EG, std::list< const PuppiObj *> &workPFCands, z0_t z0=0) const

◆ run() [3/3]

void L1EGPuppiIsoAlgo::run ( EGIsoEleObjsEmu l1Eles,
const PuppiObjs l1PFCands 
) const

Definition at line 76 of file L1EGPuppiIsoAlgo.cc.

References calcIso(), config_, genparticles_cff::iso, l1ct::L1EGPuppiIsoAlgoConfig::kPFIso, and l1ct::L1EGPuppiIsoAlgoConfig::pfIsoType_.

76  {
77  // make a list of pointers to PF candidates
78  // the pointer will be removed from the list once the candidate has been used and the the module is configured to to so
79  std::list<const PuppiObj*> workPFCands;
80  for (const auto& l1PFCand : l1PFCands) {
81  workPFCands.emplace_back(&l1PFCand);
82  }
83 
84  for (auto& l1Ele : l1Eles) {
85  iso_t iso = 0;
86  if (!workPFCands.empty()) {
87  iso = calcIso(l1Ele, workPFCands);
88  }
89 
91  l1Ele.setHwIso(EGIsoEleObjEmu::IsoType::PfIso, iso);
92  } else {
93  l1Ele.setHwIso(EGIsoEleObjEmu::IsoType::PuppiIso, iso);
94  }
95  }
96 }
const L1EGPuppiIsoAlgoConfig config_
ap_ufixed< 11, 9, AP_TRN, AP_SAT > iso_t
Definition: datatypes.h:40
iso_t calcIso(const EGIsoObj &l1EG, std::list< const PuppiObj *> &workPFCands, z0_t z0=0) const

Member Data Documentation

◆ config_

const L1EGPuppiIsoAlgoConfig l1ct::L1EGPuppiIsoAlgo::config_
private

Definition at line 58 of file L1EGPuppiIsoAlgo.h.

Referenced by calcIso(), and run().