Skip to content

Commit

Permalink
Merge pull request #15 from gpetruc/fix_met_tails_105Xv3
Browse files Browse the repository at this point in the history
Fix met tails 105 xv3
  • Loading branch information
gpetruc authored Jun 25, 2019
2 parents e73a0ac + 0d33349 commit 63db0f1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
23 changes: 16 additions & 7 deletions L1Trigger/Phase2L1ParticleFlow/interface/DiscretePFInputs.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#if defined(__GXX_EXPERIMENTAL_CXX0X__) or defined(CMSSW)
#include <cstdint>
#include <limits>
#define L1Trigger_Phase2L1ParticleFlow_DiscretePFInputs_MORE
#else
#include <stdint.h>
Expand Down Expand Up @@ -35,11 +36,15 @@ namespace l1tpf_impl {
static constexpr float ETAPHI_SCALE = ETAPHI_FACTOR*(180./M_PI); // M_PI/180 is the size of an ECal crystal; we make a grid that is 4 times that size
static constexpr int16_t PHI_WRAP = 360*ETAPHI_FACTOR; // what is 3.14 in integer

static int16_t ptToInt16(float pt) { // avoid overflows
return std::min<float>(round(pt * CaloCluster::PT_SCALE), std::numeric_limits<int16_t>::max());
}

// filling from floating point
void fill(float pt, float emPt, float ptErr, float eta, float phi, bool em, unsigned int flags, const l1t::PFCluster *source = nullptr) {
hwPt = round(pt * CaloCluster::PT_SCALE);
hwEmPt = round(emPt * CaloCluster::PT_SCALE);
hwPtErr = round(ptErr * CaloCluster::PT_SCALE);
hwPt = CaloCluster::ptToInt16(pt);
hwEmPt = CaloCluster::ptToInt16(emPt);
hwPtErr = CaloCluster::ptToInt16(ptErr);
hwEta = round(eta * CaloCluster::ETAPHI_SCALE);
hwPhi = int16_t(round(phi * CaloCluster::ETAPHI_SCALE)) % CaloCluster::PHI_WRAP;
isEM = em;
Expand Down Expand Up @@ -79,7 +84,7 @@ namespace l1tpf_impl {

// filling from floating point
void fillInput(float pt, float eta, float phi, int charge, float dz, unsigned int flags, const l1t::PFTrack *source = nullptr) {
hwInvpt = round(1/pt * InputTrack::INVPT_SCALE);
hwInvpt = std::min<double>(round(1/pt * InputTrack::INVPT_SCALE), std::numeric_limits<uint16_t>::max());
hwVtxEta = round(eta * InputTrack::VTX_ETA_SCALE);
hwVtxPhi = round(phi * InputTrack::VTX_PHI_SCALE);
hwCharge = (charge > 0);
Expand Down Expand Up @@ -112,9 +117,13 @@ namespace l1tpf_impl {

#ifdef L1Trigger_Phase2L1ParticleFlow_DiscretePFInputs_MORE
void fillPropagated(float pt, float ptErr, float caloPtErr, float caloEta, float caloPhi, unsigned int quality, bool isMuon) {
hwPt = round(pt * CaloCluster::PT_SCALE);
hwPtErr = round(ptErr * CaloCluster::PT_SCALE);
hwCaloPtErr = round(caloPtErr * CaloCluster::PT_SCALE);
hwPt = CaloCluster::ptToInt16(pt);
hwPtErr = CaloCluster::ptToInt16(ptErr);
hwCaloPtErr = CaloCluster::ptToInt16(caloPtErr);
// saturation protection
if (hwPt == std::numeric_limits<int16_t>::max()) {
hwCaloPtErr = hwPt / 4;
}
hwEta = round(caloEta * CaloCluster::ETAPHI_SCALE);
hwPhi = int16_t(round(caloPhi * CaloCluster::ETAPHI_SCALE)) % CaloCluster::PHI_WRAP;
muonLink = isMuon;
Expand Down
8 changes: 7 additions & 1 deletion L1Trigger/Phase2L1ParticleFlow/src/PFAlgo3.cc
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,13 @@ void PFAlgo3::emcalo_algo(Region & r, const std::vector<int> & em2ntk, const std
continue;
}
float ptdiff = em.floatPt() - em2sumtkpt[iem];
float pterr = trackEmUseAlsoTrackSigma_ ? std::max<float>(em2sumtkpterr[iem],em.floatPtErr()) : em.floatPtErr();
float pterr = trackEmUseAlsoTrackSigma_ ? std::max<float>(em2sumtkpterr[iem],em.floatPtErr()) : em.floatPtErr();
// avoid "pt = inf +- inf" track to become an electron.
if (pterr > 2*em.floatPt()) {
pterr = 2*em.floatPt();
if (debug_) printf("PFAlgo3 \t EM %3d (pt %7.2f) ---> clamp pterr ---> new ptdiff %7.2f +- %7.2f\n", iem, em.floatPt(), ptdiff, pterr);
}

if (ptdiff > -ptMatchLow_*pterr) {
em.isEM = true;
em.used = true;
Expand Down

0 comments on commit 63db0f1

Please sign in to comment.