CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Attributes
JetPlusTrackCorrector Class Reference

Jet energy correction algorithm using tracks. More...

#include <JetPlusTrackCorrector.h>

Public Types

typedef math::XYZTLorentzVector P4
 
typedef math::PtEtaPhiELorentzVectorD PtEtaPhiE
 
typedef math::PtEtaPhiMLorentzVectorD PtEtaPhiM
 

Public Member Functions

bool canCorrect (const reco::Jet &) const
 Can jet be JPT-corrected? More...
 
double correctAA (const reco::Jet &, const reco::TrackRefVector &, double &, const reco::TrackRefVector &, const reco::TrackRefVector &, double, const reco::TrackRefVector &) const
 For AA - correct in tracker. More...
 
double correction (const reco::Jet &, const reco::Jet &, const edm::Event &, const edm::EventSetup &, P4 &, jpt::MatchedTracks &pions, jpt::MatchedTracks &muons, jpt::MatchedTracks &elecs, bool &validMatches)
 Vectorial correction method (corrected 4-momentum passed by reference) More...
 
double correction (const reco::Jet &, const reco::Jet &, const edm::Event &, const edm::EventSetup &, const reco::TrackRefVector &tracksinvert, const reco::TrackRefVector &tracksincalo, P4 &, jpt::MatchedTracks &pions, jpt::MatchedTracks &muons, jpt::MatchedTracks &elecs)
 
double correction (const reco::Jet &, const reco::Jet &, const edm::Event &, const edm::EventSetup &, jpt::MatchedTracks &pions, jpt::MatchedTracks &muons, jpt::MatchedTracks &elecs, bool &validMatches)
 Scalar correction method. More...
 
double correction (const reco::Jet &) const
 Correction method (not used) More...
 
double correction (const P4 &) const
 Correction method (not used) More...
 
P4 elecCorrection (const P4 &jet, const jpt::MatchedTracks &elecs) const
 Calculates correction to be applied using electrons. More...
 
bool eventRequired () const
 Returns true. More...
 
double getResponseOfChargedWithEff ()
 Get responses/sumPT/SumEnergy with and without Efficiency correction. More...
 
double getResponseOfChargedWithoutEff ()
 
double getSumEnergyWithEff ()
 
double getSumEnergyWithoutEff ()
 
double getSumPtForBeta ()
 
double getSumPtWithEff ()
 
double getSumPtWithoutEff ()
 
 JetPlusTrackCorrector (const edm::ParameterSet &iPS, edm::ConsumesCollector &&iC)
 Constructor. More...
 
bool matchTracks (const reco::Jet &, const edm::Event &, const edm::EventSetup &, jpt::MatchedTracks &pions, jpt::MatchedTracks &muons, jpt::MatchedTracks &elecs)
 Matches tracks to different particle types. More...
 
void matchTracks (const reco::Jet &, const edm::Event &, const edm::EventSetup &, const reco::TrackRefVector &tracksinvert, const reco::TrackRefVector &tracksincalo, jpt::MatchedTracks &pions, jpt::MatchedTracks &muons, jpt::MatchedTracks &elecs)
 
P4 muonCorrection (const P4 &jet, const jpt::MatchedTracks &muons)
 Calculates correction to be applied using muons. More...
 
P4 pionCorrection (const P4 &jet, const jpt::MatchedTracks &pions)
 Calculates corrections to be applied using pions. More...
 
bool vectorialCorrection () const
 Returns value of configurable. More...
 
virtual ~JetPlusTrackCorrector ()
 Destructor. More...
 

Protected Types

typedef reco::JetTracksAssociation::Container JetTracksAssociations
 
typedef edm::ValueMap< float > RecoElectronIds
 
typedef reco::GsfElectronCollection RecoElectrons
 
typedef reco::MuonCollection RecoMuons
 Get reponses. More...
 
typedef reco::TrackRefVector TrackRefs
 

Protected Member Functions

P4 calculateCorr (const P4 &jet, const TrackRefs &, jpt::Efficiency &, bool in_cone_at_vertex, bool in_cone_at_calo_face, double mass, bool is_pion, double mip)
 Generic method to calculates 4-momentum correction to be applied. More...
 
double checkScale (const P4 &jet, P4 &corrected) const
 Check corrected 4-momentum does not give negative scale. More...
 
const jpt::MapefficiencyMap () const
 
P4 elecCorrection (const P4 &jet, const TrackRefs &elecs, bool in_cone_at_vertex, bool in_cone_at_calo_face)
 Calculates individual electron corrections. More...
 
void excludeJta (const reco::Jet &, const JetTracksAssociations &, TrackRefs &included, const TrackRefs &excluded) const
 Exclude jet-track association. More...
 
bool failTrackQuality (TrackRefs::const_iterator &) const
 Check on track quality. More...
 
bool findTrack (const jpt::JetTracks &, TrackRefs::const_iterator &, TrackRefs::iterator &) const
 Find track in JetTracks collection. More...
 
bool findTrack (const jpt::MatchedTracks &pions, const jpt::MatchedTracks &muons, const jpt::MatchedTracks &electrons, TrackRefs::const_iterator &) const
 Find track in MatchedTracks collections. More...
 
bool getElectrons (const edm::Event &, edm::Handle< RecoElectrons > &, edm::Handle< RecoElectronIds > &) const
 Get RECO electrons. More...
 
bool getElectrons (const edm::Event &, edm::Handle< pat::ElectronCollection > &) const
 
bool getMuons (const edm::Event &, edm::Handle< RecoMuons > &) const
 Get RECO muons. More...
 
bool getMuons (const edm::Event &, edm::Handle< pat::MuonCollection > &) const
 
P4 jetDirFromTracks (const P4 &jet, const jpt::MatchedTracks &pions, const jpt::MatchedTracks &muons, const jpt::MatchedTracks &elecs) const
 Calculates vectorial correction using total track 3-momentum. More...
 
 JetPlusTrackCorrector ()
 Default constructor. More...
 
virtual bool jetTrackAssociation (const reco::Jet &, const edm::Event &, const edm::EventSetup &, jpt::JetTracks &) const
 Associates tracks to jets (overriden in derived class) More...
 
bool jtaUsingEventData (const reco::Jet &, const edm::Event &, jpt::JetTracks &) const
 JTA using collections from event. More...
 
const jpt::MapleakageMap () const
 
bool matchElectrons (TrackRefs::const_iterator &, const edm::Handle< RecoElectrons > &, const edm::Handle< RecoElectronIds > &) const
 Matches tracks to RECO electrons. More...
 
bool matchElectrons (TrackRefs::const_iterator &, const edm::Handle< pat::ElectronCollection > &) const
 
bool matchMuons (TrackRefs::const_iterator &, const edm::Handle< RecoMuons > &) const
 Matches tracks to RECO muons. More...
 
bool matchMuons (TrackRefs::const_iterator &, const edm::Handle< pat::MuonCollection > &) const
 
virtual void matchTracks (const jpt::JetTracks &, const edm::Event &, jpt::MatchedTracks &pions, jpt::MatchedTracks &muons, jpt::MatchedTracks &elecs)
 Matches tracks to different particle types (overriden in derived class) More...
 
P4 muonCorrection (const P4 &jet, const TrackRefs &muons, bool in_cone_at_vertex, bool in_cone_at_calo_face)
 Calculates individual muons corrections. More...
 
P4 pionCorrection (const P4 &jet, const TrackRefs &pions, jpt::Efficiency &, bool in_cone_at_vertex, bool in_cone_at_calo_face)
 Calculates individual pion corrections. More...
 
P4 pionEfficiency (const P4 &jet, const jpt::Efficiency &, bool in_cone_at_calo_face)
 Correction to be applied using tracking efficiency. More...
 
void rebuildJta (const reco::Jet &, const JetTracksAssociations &, TrackRefs &included, TrackRefs &excluded) const
 Rebuild jet-track association. More...
 
const jpt::MapresponseMap () const
 
bool tracksInCalo (const jpt::MatchedTracks &pions, const jpt::MatchedTracks &muons, const jpt::MatchedTracks &elecs) const
 Determines if any tracks in cone at CaloFace. More...
 

Protected Attributes

double dzVertexCut_
 
const jpt::Map efficiency_
 
double elecMass_
 
double electronDRmatch_
 
edm::InputTag electronIds_
 
edm::InputTag electrons_
 
int jetSplitMerge_
 
edm::InputTag jetTracksAtCalo_
 
edm::InputTag jetTracksAtVertex_
 
const jpt::Map leakage_
 
double maxEta_
 
double muonEtamatch_
 
double muonMass_
 
double muonPhimatch_
 
double muonPtmatch_
 
edm::InputTag muons_
 
jpt::Efficiency not_used {response_, efficiency_, leakage_}
 
edm::InputTag patelectrons_
 
edm::InputTag patmuons_
 
double pionMass_
 
double ptErrorQuality_
 
const jpt::Map response_
 
edm::InputTag srcPVs_
 
float theResponseOfChargedWithEff
 
float theResponseOfChargedWithoutEff
 
float theSumEnergyWithEff
 
float theSumEnergyWithoutEff
 
float theSumPtForBeta
 
float theSumPtWithEff
 
float theSumPtWithoutEff
 
reco::TrackBase::TrackQuality trackQuality_
 
bool useEff_
 
bool useElecs_
 
bool useInConeTracks_
 
bool useMuons_
 
bool useOutOfConeTracks_
 
bool useOutOfVertexTracks_
 
bool usePAT_
 
bool usePions_
 
bool useTrackQuality_
 
bool vecResponse_
 
bool vectorial_
 
bool verbose_
 
reco::Particle::Point vertex_
 

Private Attributes

edm::EDGetTokenT< reco::JetTracksAssociation::Containerinput_jetTracksAtCalo_token_
 
edm::EDGetTokenT< reco::JetTracksAssociation::Containerinput_jetTracksAtVertex_token_
 
edm::EDGetTokenT< pat::ElectronCollectioninput_pat_elecs_token_
 
edm::EDGetTokenT< pat::MuonCollectioninput_pat_muons_token_
 
edm::EDGetTokenT< reco::VertexCollectioninput_pvCollection_token_
 
edm::EDGetTokenT< RecoElectronIdsinput_reco_elec_ids_token_
 
edm::EDGetTokenT< RecoElectronsinput_reco_elecs_token_
 
edm::EDGetTokenT< RecoMuonsinput_reco_muons_token_
 

Detailed Description

Jet energy correction algorithm using tracks.

Definition at line 171 of file JetPlusTrackCorrector.h.

Member Typedef Documentation

◆ JetTracksAssociations

Definition at line 296 of file JetPlusTrackCorrector.h.

◆ P4

Definition at line 182 of file JetPlusTrackCorrector.h.

◆ PtEtaPhiE

Definition at line 183 of file JetPlusTrackCorrector.h.

◆ PtEtaPhiM

Definition at line 184 of file JetPlusTrackCorrector.h.

◆ RecoElectronIds

Definition at line 295 of file JetPlusTrackCorrector.h.

◆ RecoElectrons

Definition at line 294 of file JetPlusTrackCorrector.h.

◆ RecoMuons

Get reponses.

Definition at line 293 of file JetPlusTrackCorrector.h.

◆ TrackRefs

Definition at line 297 of file JetPlusTrackCorrector.h.

Constructor & Destructor Documentation

◆ JetPlusTrackCorrector() [1/2]

JetPlusTrackCorrector::JetPlusTrackCorrector ( const edm::ParameterSet iPS,
edm::ConsumesCollector &&  iC 
)

Constructor.

Definition at line 24 of file JetPlusTrackCorrector.cc.

References electronIds_, electrons_, input_jetTracksAtCalo_token_, input_jetTracksAtVertex_token_, input_pat_elecs_token_, input_pat_muons_token_, input_pvCollection_token_, input_reco_elec_ids_token_, input_reco_elecs_token_, input_reco_muons_token_, jetSplitMerge_, jetTracksAtCalo_, jetTracksAtVertex_, muons_, patelectrons_, patmuons_, muonDTDigis_cfi::pset, srcPVs_, contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, useEff_, useElecs_, useInConeTracks_, useMuons_, useOutOfConeTracks_, useOutOfVertexTracks_, usePAT_, usePions_, useTrackQuality_, vecResponse_, vectorial_, and verbose_.

25  : verbose_(pset.getParameter<bool>("Verbose")),
26  usePAT_(pset.getParameter<bool>("UsePAT")),
27  vectorial_(pset.getParameter<bool>("VectorialCorrection")),
28  vecResponse_(pset.getParameter<bool>("UseResponseInVecCorr")),
29  useInConeTracks_(pset.getParameter<bool>("UseInConeTracks")),
30  useOutOfConeTracks_(pset.getParameter<bool>("UseOutOfConeTracks")),
31  useOutOfVertexTracks_(pset.getParameter<bool>("UseOutOfVertexTracks")),
32  usePions_(pset.getParameter<bool>("UsePions")),
33  useEff_(pset.getParameter<bool>("UseEfficiency")),
34  useMuons_(pset.getParameter<bool>("UseMuons")),
35  useElecs_(pset.getParameter<bool>("UseElectrons")),
36  useTrackQuality_(pset.getParameter<bool>("UseTrackQuality")),
37  jetTracksAtVertex_(pset.getParameter<edm::InputTag>("JetTracksAssociationAtVertex")),
38  jetTracksAtCalo_(pset.getParameter<edm::InputTag>("JetTracksAssociationAtCaloFace")),
39  jetSplitMerge_(pset.getParameter<int>("JetSplitMerge")),
40  srcPVs_(pset.getParameter<edm::InputTag>("srcPVs")),
41  ptErrorQuality_(pset.getParameter<double>("PtErrorQuality")),
42  dzVertexCut_(pset.getParameter<double>("DzVertexCut")),
43  muons_(pset.getParameter<edm::InputTag>("Muons")),
44  electrons_(pset.getParameter<edm::InputTag>("Electrons")),
45  electronIds_(pset.getParameter<edm::InputTag>("ElectronIds")),
46  patmuons_(pset.getParameter<edm::InputTag>("PatMuons")),
47  patelectrons_(pset.getParameter<edm::InputTag>("PatElectrons")),
48  trackQuality_(reco::TrackBase::qualityByName(pset.getParameter<std::string>("TrackQuality"))),
49  response_(Map(pset.getParameter<std::string>("ResponseMap"), verbose_)),
50  efficiency_(Map(pset.getParameter<std::string>("EfficiencyMap"), verbose_)),
51  leakage_(Map(pset.getParameter<std::string>("LeakageMap"), verbose_)),
52  muonPtmatch_(pset.getParameter<double>("muonPtmatch")),
53  muonEtamatch_(pset.getParameter<double>("muonEtamatch")),
54  muonPhimatch_(pset.getParameter<double>("muonPhimatch")),
55  electronDRmatch_(pset.getParameter<double>("electronDRmatch")),
56  pionMass_(0.140),
57  muonMass_(0.105),
58  elecMass_(0.000511),
59  maxEta_(pset.getParameter<double>("MaxJetEta")) {
60  if (verbose_) {
61  std::stringstream ss;
62  ss << "[JetPlusTrackCorrector::" << __func__ << "] Configuration for JPT corrector: " << std::endl
63  << " Particles" << std::endl
64  << " UsePions : " << (usePions_ ? "true" : "false") << std::endl
65  << " UseMuons : " << (useMuons_ ? "true" : "false") << std::endl
66  << " UseElecs : " << (useElecs_ ? "true" : "false") << std::endl
67  << " Corrections" << std::endl
68  << " UseInConeTracks : " << (useInConeTracks_ ? "true" : "false") << std::endl
69  << " UseOutOfConeTracks : " << (useOutOfConeTracks_ ? "true" : "false") << std::endl
70  << " UseOutOfVertexTracks : " << (useOutOfVertexTracks_ ? "true" : "false") << std::endl
71  << " ResponseMap : " << pset.getParameter<std::string>("ResponseMap") << std::endl
72  << " Efficiency" << std::endl
73  << " UsePionEfficiency : " << (useEff_ ? "true" : "false") << std::endl
74  << " EfficiencyMap : " << pset.getParameter<std::string>("EfficiencyMap") << std::endl
75  << " LeakageMap : " << pset.getParameter<std::string>("LeakageMap") << std::endl
76  << " Tracks" << std::endl
77  << " JetTracksAtVertex : " << jetTracksAtVertex_ << std::endl
78  << " JetTracksAtCalo : " << jetTracksAtCalo_ << std::endl
79  << " JetSplitMerge : " << jetSplitMerge_ << std::endl
80  << " UseTrackQuality : " << (useTrackQuality_ ? "true" : "false") << std::endl
81  << " Collections" << std::endl
82  << " Muons : " << muons_ << std::endl
83  << " Electrons : " << electrons_ << std::endl
84  << " Vectorial" << std::endl
85  << " UseTracksAndResponse : " << ((vectorial_ && vecResponse_) ? "true" : "false") << std::endl
86  << " UseTracksOnly : " << ((vectorial_ && !vecResponse_) ? "true" : "false");
87  edm::LogInfo("JetPlusTrackCorrector") << ss.str();
88  }
89 
91  std::stringstream ss;
92  ss << "[JetPlusTrackCorrector::" << __func__ << "]"
93  << " You are using JPT algorithm in a non-standard way!" << std::endl
94  << " UseInConeTracks : " << (useInConeTracks_ ? "true" : "false") << std::endl
95  << " UseOutOfConeTracks : " << (useOutOfConeTracks_ ? "true" : "false") << std::endl
96  << " UseOutOfVertexTracks : " << (useOutOfVertexTracks_ ? "true" : "false");
97  edm::LogWarning("JetPlusTrackCorrector") << ss.str();
98  }
99 
103 
107  if (usePAT_) {
110  }
111 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< RecoMuons > input_reco_muons_token_
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
reco::GsfElectronCollection RecoElectrons
Container class for response & efficiency maps.
edm::EDGetTokenT< pat::ElectronCollection > input_pat_elecs_token_
edm::ValueMap< float > RecoElectronIds
edm::EDGetTokenT< RecoElectronIds > input_reco_elec_ids_token_
edm::EDGetTokenT< RecoElectrons > input_reco_elecs_token_
std::vector< Electron > ElectronCollection
Definition: Electron.h:36
Log< level::Info, false > LogInfo
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:126
edm::EDGetTokenT< pat::MuonCollection > input_pat_muons_token_
reco::TrackBase::TrackQuality trackQuality_
std::vector< Muon > MuonCollection
Definition: Muon.h:35
edm::EDGetTokenT< reco::JetTracksAssociation::Container > input_jetTracksAtCalo_token_
Log< level::Warning, false > LogWarning
edm::EDGetTokenT< reco::JetTracksAssociation::Container > input_jetTracksAtVertex_token_
reco::MuonCollection RecoMuons
Get reponses.
edm::EDGetTokenT< reco::VertexCollection > input_pvCollection_token_

◆ ~JetPlusTrackCorrector()

JetPlusTrackCorrector::~JetPlusTrackCorrector ( )
virtual

Destructor.

Definition at line 115 of file JetPlusTrackCorrector.cc.

115 { ; }

◆ JetPlusTrackCorrector() [2/2]

JetPlusTrackCorrector::JetPlusTrackCorrector ( )
inlineprotected

Default constructor.

Definition at line 392 of file JetPlusTrackCorrector.h.

392 { ; }

Member Function Documentation

◆ calculateCorr()

JetPlusTrackCorrector::P4 JetPlusTrackCorrector::calculateCorr ( const P4 jet,
const TrackRefs tracks,
jpt::Efficiency eff,
bool  in_cone_at_vertex,
bool  in_cone_at_calo_face,
double  mass,
bool  is_pion,
double  mip 
)
protected

Generic method to calculates 4-momentum correction to be applied.

Definition at line 879 of file JetPlusTrackCorrector.cc.

References jpt::Efficiency::addE(), correction(), hcalRecHitTable_cff::energy, PVValHelper::eta, jpt::Map::etaBin(), hcalRecHitTable_cff::ieta, SurfaceOrientation::inner, edm::isDebugEnabled(), metsig::jet, LogDebug, EgHLTOffHistBins_cfi::mass, jpt::Map::nEtaBins(), jpt::Map::nPtBins(), SurfaceOrientation::outer, DiDispStaMuonMonitor_cfi::pt, jpt::Map::ptBin(), jpt::Efficiency::reset(), response_, mathSSE::sqrt(), contentValuesCheck::ss, groupFilesInBlocks::temp, theResponseOfChargedWithEff, theResponseOfChargedWithoutEff, theSumEnergyWithEff, theSumEnergyWithoutEff, theSumPtWithEff, theSumPtWithoutEff, DiMuonV_cfg::tracks, jpt::Map::value(), vecResponse_, vectorial_, and verbose_.

Referenced by elecCorrection(), muonCorrection(), and pionCorrection().

886  {
887  // Correction to be applied to jet 4-momentum
888  P4 correction;
889 
890  // Reset efficiency container
891  eff.reset();
892 
893  double theSumResp = 0;
894  double theSumPt = 0;
895  double theSumEnergy = 0;
896 
897  // Iterate through tracks
898  if (!tracks.empty()) {
899  TrackRefs::iterator itrk = tracks.begin();
900  TrackRefs::iterator jtrk = tracks.end();
901 
902  for (; itrk != jtrk; ++itrk) {
903  // Ignore high-pt tracks (only when in-cone and not a mip)
904  if (in_cone_at_calo_face && is_pion && (*itrk)->pt() >= 50.) {
905  continue;
906  }
907 
908  // Inner track 4-momentum
909  P4 inner;
910  if (vectorial_ && vecResponse_) {
911  inner = PtEtaPhiM((*itrk)->pt(), (*itrk)->eta(), (*itrk)->phi(), mass);
912  } else {
913  double energy = sqrt((*itrk)->px() * (*itrk)->px() + (*itrk)->py() * (*itrk)->py() +
914  (*itrk)->pz() * (*itrk)->pz() + mass * mass);
915  inner = (jet.energy() > 0. ? energy / jet.energy() : 1.) * jet;
916  }
917 
918  // Add track momentum (if in-cone at vertex)
919  if (in_cone_at_vertex) {
920  correction += inner;
921  }
922 
923  // Find appropriate eta/pt bin for given track
924  double eta = fabs((*itrk)->eta());
925  double pt = fabs((*itrk)->pt());
926  uint32_t ieta = response_.etaBin(eta);
927  uint32_t ipt = response_.ptBin(pt);
928 
929  // Check bins (not for mips)
930  if (is_pion && (ieta == response_.nEtaBins() || ipt == response_.nPtBins())) {
931  continue;
932  }
933 
934  // Outer track 4-momentum
935  P4 outer;
936  if (in_cone_at_calo_face) {
937  if (vectorial_ && vecResponse_) {
938  // Build 4-momentum from outer track (SHOULD USE IMPACT POINT?!)
939  double outer_pt = (*itrk)->pt();
940  double outer_eta = (*itrk)->eta();
941  double outer_phi = (*itrk)->phi();
942  if ((*itrk)->extra().isNonnull()) {
943  outer_pt = (*itrk)->pt();
944  outer_eta = (*itrk)->outerPosition().eta(); //@@ outerMomentum().eta()
945  outer_phi = (*itrk)->outerPosition().phi(); //@@ outerMomentum().phi()
946  }
947  outer = PtEtaPhiM(outer_pt, outer_eta, outer_phi, mass);
948  // Check if mip or not
949  if (!is_pion) {
950  outer *= (outer.energy() > 0. ? mip / outer.energy() : 1.);
951  } //@@ Scale to mip energy
952  else {
953  outer *= (outer.energy() > 0. ? inner.energy() / outer.energy() : 1.);
954  } //@@ Scale to inner track energy
955  } else {
956  // Check if mip or not
957  if (!is_pion) {
958  outer = (jet.energy() > 0. ? mip / jet.energy() : 1.) * jet;
959  } //@@ Jet 4-mom scaled by mip energy
960  else {
961  outer = inner;
962  } //@@ Set to inner track 4-momentum
963  }
964  if (is_pion) {
965  outer *= response_.value(ieta, ipt);
966  } //@@ Scale by pion response
967  correction -= outer; //@@ Subtract
968 
969  // Calculate the sum of responses
970  theSumResp += response_.value(ieta, ipt);
971  }
972 
973  // Calculate the sum of pt and energies
974  theSumPt += inner.pt();
975  theSumEnergy += inner.energy();
976 
977  // Record inner track energy for pion efficiency correction
978  if (is_pion) {
979  eff.addE(ieta, ipt, inner.energy());
980  }
981 
982  // Debug
983  if (verbose_ && edm::isDebugEnabled()) {
984  std::stringstream temp;
985  temp << " Response[" << ieta << "," << ipt << "]";
986  std::stringstream ss;
987  ss << "[JetPlusTrackCorrector::" << __func__ << "]" << std::endl
988  << " Track eta / pt : " << eta << " / " << pt << std::endl
989  << temp.str() << std::setw(21 - temp.str().size()) << " : " << response_.value(ieta, ipt) << std::endl
990  << " Track momentum added : " << inner.energy() << std::endl
991  << " Response subtracted : " << outer.energy() << std::endl
992  << " Energy correction : " << correction.energy();
993  LogDebug("JetPlusTrackCorrector") << ss.str();
994  }
995 
996  } // loop through tracks
997  } // ntracks != 0
998 
999  if (in_cone_at_vertex) {
1000  theResponseOfChargedWithEff += theSumResp;
1001  theResponseOfChargedWithoutEff += theSumResp;
1002  theSumPtWithEff += theSumPt;
1003  theSumPtWithoutEff += theSumPt;
1004  theSumEnergyWithEff += theSumEnergy;
1005  theSumEnergyWithoutEff += theSumEnergy;
1006  }
1007  return correction;
1008 }
math::XYZTLorentzVector P4
bool isDebugEnabled()
uint32_t nPtBins() const
void addE(uint32_t eta_bin, uint32_t pt_bin, double energy)
double value(uint32_t eta_bin, uint32_t pt_bin) const
uint32_t etaBin(double eta) const
T sqrt(T t)
Definition: SSEVec.h:23
double correction(const reco::Jet &, const reco::Jet &, const edm::Event &, const edm::EventSetup &, P4 &, jpt::MatchedTracks &pions, jpt::MatchedTracks &muons, jpt::MatchedTracks &elecs, bool &validMatches)
Vectorial correction method (corrected 4-momentum passed by reference)
uint32_t nEtaBins() const
refhelper::RefVectorTrait< TrackCollection, typename refhelper::ValueTrait< TrackCollection >::value, typename refhelper::FindTrait< TrackCollection, typename refhelper::ValueTrait< TrackCollection >::value >::value >::iterator_type iterator
Definition: RefVector.h:37
uint32_t ptBin(double pt) const
math::PtEtaPhiMLorentzVectorD PtEtaPhiM
#define LogDebug(id)

◆ canCorrect()

bool JetPlusTrackCorrector::canCorrect ( const reco::Jet jet) const
inline

Can jet be JPT-corrected?

Definition at line 486 of file JetPlusTrackCorrector.h.

References metsig::jet, and maxEta_.

Referenced by correction().

486 { return (fabs(jet.eta()) <= maxEta_); }

◆ checkScale()

double JetPlusTrackCorrector::checkScale ( const P4 jet,
P4 corrected 
) const
inlineprotected

Check corrected 4-momentum does not give negative scale.

Definition at line 507 of file JetPlusTrackCorrector.h.

References metsig::jet.

Referenced by correction().

507  {
508  if (jet.energy() > 0. && (corrected.energy() / jet.energy()) < 0.) {
509  corrected = jet;
510  }
511  return corrected.energy() / jet.energy();
512 }

◆ correctAA()

double JetPlusTrackCorrector::correctAA ( const reco::Jet fJet,
const reco::TrackRefVector trBgOutOfVertex,
double &  mConeSize,
const reco::TrackRefVector pioninin,
const reco::TrackRefVector pioninout,
double  ja,
const reco::TrackRefVector trBgOutOfCalo 
) const

For AA - correct in tracker.

Definition at line 1260 of file JetPlusTrackCorrector.cc.

References edm::RefVector< C, T, F >::begin(), efficiency_, edm::RefVector< C, T, F >::empty(), edm::RefVector< C, T, F >::end(), reco::LeafCandidate::energy(), PVValHelper::eta, reco::LeafCandidate::eta(), jpt::Map::etaBin(), hcalRecHitTable_cff::ieta, M_PI, jpt::Map::nEtaBins(), jpt::Map::nPtBins(), DiDispStaMuonMonitor_cfi::pt, jpt::Map::ptBin(), response_, mathSSE::sqrt(), and jpt::Map::value().

1266  {
1267  double mScale = 1.;
1268  double NewResponse = fJet.energy();
1269 
1270  if (trBgOutOfVertex.empty())
1271  return mScale;
1272  double EnergyOfBackgroundCharged = 0.;
1273  double ResponseOfBackgroundCharged = 0.;
1274 
1275  //
1276  // calculate the mean response
1277  //
1278 
1279  //================= EnergyOfBackgroundCharged ==================>
1280  for (reco::TrackRefVector::iterator iBgtV = trBgOutOfVertex.begin(); iBgtV != trBgOutOfVertex.end(); iBgtV++) {
1281  double eta = fabs((**iBgtV).eta());
1282  double pt = fabs((**iBgtV).pt());
1283  uint32_t ieta = response_.etaBin(eta);
1284  uint32_t ipt = response_.ptBin(pt);
1285 
1286  if (fabs(fJet.eta() - (**iBgtV).eta()) > mConeSize)
1287  continue;
1288 
1289  double echarBg = sqrt((**iBgtV).px() * (**iBgtV).px() + (**iBgtV).py() * (**iBgtV).py() +
1290  (**iBgtV).pz() * (**iBgtV).pz() + 0.14 * 0.14);
1291 
1292  EnergyOfBackgroundCharged += echarBg / efficiency_.value(ieta, ipt);
1293 
1294  } // Energy BG tracks
1295 
1296  //============= ResponseOfBackgroundCharged =======================>
1297 
1298  for (reco::TrackRefVector::iterator iBgtC = trBgOutOfCalo.begin(); iBgtC != trBgOutOfCalo.end(); iBgtC++) {
1299  double eta = fabs((**iBgtC).eta());
1300  double pt = fabs((**iBgtC).pt());
1301  uint32_t ieta = response_.etaBin(eta);
1302  uint32_t ipt = response_.ptBin(pt);
1303 
1304  if (fabs(fJet.eta() - (**iBgtC).eta()) > mConeSize)
1305  continue;
1306 
1307  // Check bins (not for mips)
1308  if (ieta >= response_.nEtaBins()) {
1309  continue;
1310  }
1311  if (ipt >= response_.nPtBins()) {
1312  ipt = response_.nPtBins() - 1;
1313  }
1314 
1315  double echarBg = sqrt((**iBgtC).px() * (**iBgtC).px() + (**iBgtC).py() * (**iBgtC).py() +
1316  (**iBgtC).pz() * (**iBgtC).pz() + 0.14 * 0.14);
1317 
1318  ResponseOfBackgroundCharged += echarBg * response_.value(ieta, ipt) / efficiency_.value(ieta, ipt);
1319 
1320  } // Response of BG tracks
1321 
1322  //=================================================================>
1323 
1324  /*
1325  //=================================================================>
1326  // Look for in-out tracks
1327 
1328  double en = 0.;
1329  double px = 0.;
1330  double py = 0.;
1331  double pz = 0.;
1332 
1333  for (reco::TrackRefVector::const_iterator it = pioninout.begin(); it != pioninout.end(); it++) {
1334  px += (*it)->px();
1335  py += (*it)->py();
1336  pz += (*it)->pz();
1337  en += sqrt((*it)->p() * (*it)->p() + 0.14 * 0.14);
1338  }
1339 
1340  // Look for in-in tracks
1341 
1342  double en_in = 0.;
1343  double px_in = 0.;
1344  double py_in = 0.;
1345  double pz_in = 0.;
1346 
1347  for (reco::TrackRefVector::const_iterator it = pioninin.begin(); it != pioninin.end(); it++) {
1348  px_in += (*it)->px();
1349  py_in += (*it)->py();
1350  pz_in += (*it)->pz();
1351  en_in += sqrt((*it)->p() * (*it)->p() + 0.14 * 0.14);
1352  }
1353 
1354  //===================================================================>
1355 
1356  //=>
1357 */
1358  double SquareEtaRingWithoutJets = ja;
1359 
1360  EnergyOfBackgroundCharged = EnergyOfBackgroundCharged / SquareEtaRingWithoutJets;
1361  ResponseOfBackgroundCharged = ResponseOfBackgroundCharged / SquareEtaRingWithoutJets;
1362 
1363  EnergyOfBackgroundCharged = M_PI * mConeSize * mConeSize * EnergyOfBackgroundCharged;
1364  ResponseOfBackgroundCharged = M_PI * mConeSize * mConeSize * ResponseOfBackgroundCharged;
1365 
1366  NewResponse = NewResponse - EnergyOfBackgroundCharged + ResponseOfBackgroundCharged;
1367 
1368  mScale = NewResponse / fJet.energy();
1369  if (mScale < 0.)
1370  mScale = 0.;
1371  return mScale;
1372 }
bool empty() const
Is the RefVector empty.
Definition: RefVector.h:99
uint32_t nPtBins() const
double value(uint32_t eta_bin, uint32_t pt_bin) const
uint32_t etaBin(double eta) const
T sqrt(T t)
Definition: SSEVec.h:23
uint32_t nEtaBins() const
#define M_PI
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:228
uint32_t ptBin(double pt) const
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:223
double energy() const final
energy
double eta() const final
momentum pseudorapidity

◆ correction() [1/5]

double JetPlusTrackCorrector::correction ( const reco::Jet fJet,
const reco::Jet fJetcalo,
const edm::Event event,
const edm::EventSetup setup,
P4 corrected,
jpt::MatchedTracks pions,
jpt::MatchedTracks muons,
jpt::MatchedTracks elecs,
bool &  validMatches 
)

Vectorial correction method (corrected 4-momentum passed by reference)

Definition at line 151 of file JetPlusTrackCorrector.cc.

References canCorrect(), checkScale(), elecCorrection(), singleTopDQM_cfi::elecs, reco::LeafCandidate::energy(), reco::LeafCandidate::et(), reco::LeafCandidate::eta(), alignBH_cfg::fixed, jetDirFromTracks(), reco::LeafCandidate::mass(), matchTracks(), muonCorrection(), DiMuonV_cfg::muons, reco::LeafCandidate::p4(), reco::LeafCandidate::phi(), pionCorrection(), reco::LeafCandidate::pt(), reco::LeafCandidate::px(), reco::LeafCandidate::py(), reco::LeafCandidate::pz(), l1tEGammaCrystalsEmulatorProducer_cfi::scale, singleTopDQM_cfi::setup, contentValuesCheck::ss, theResponseOfChargedWithEff, theResponseOfChargedWithoutEff, theSumEnergyWithEff, theSumEnergyWithoutEff, theSumPtForBeta, theSumPtWithEff, theSumPtWithoutEff, useElecs_, useMuons_, usePions_, vecResponse_, vectorial_, and verbose_.

Referenced by calculateCorr(), correction(), and pionEfficiency().

159  {
162  theSumPtWithEff = 0.;
163  theSumPtWithoutEff = 0.;
164  theSumEnergyWithEff = 0.;
166  theSumPtForBeta = 0.;
167 
168  // Corrected 4-momentum for jet
169  corrected = fJet.p4();
170 
171  // Match tracks to different particle types
172  validMatches = matchTracks(fJetcalo, event, setup, pions, muons, elecs);
173  if (!validMatches) {
174  return 1.;
175  }
176 
177  // Check if jet can be JPT-corrected
178  if (!canCorrect(fJet)) {
179  return 1.;
180  }
181 
182  // Debug
183  if (verbose_) {
184  edm::LogInfo("JetPlusTrackCorrector") << "[JetPlusTrackCorrector::" << __func__ << "]"
185  << " Applying JPT corrections...";
186  }
187 
188  // Pion corrections (both scalar and vectorial)
189  if (usePions_) {
190  corrected += pionCorrection(fJet.p4(), pions);
191  }
192 
193  // Muon corrections (both scalar and vectorial)
194  if (useMuons_) {
195  corrected += muonCorrection(fJet.p4(), muons);
196  }
197 
198  // Electrons corrections (both scalar and vectorial)
199  if (useElecs_) {
200  corrected += elecCorrection(fJet.p4(), elecs);
201  }
202 
203  // Define jet direction using total 3-momentum of tracks (overrides above)
204  if (vectorial_ && !vecResponse_) {
205  if (fabs(corrected.eta()) < 2.) {
206  corrected = jetDirFromTracks(corrected, pions, muons, elecs);
207  }
208  }
209 
210  // Check if corrected 4-momentum gives negative scale
211  double scale = checkScale(fJet.p4(), corrected);
212 
213  // Debug
214  if (verbose_) {
215  std::stringstream ss;
216  ss << "Total correction:" << std::endl
217  << std::fixed << std::setprecision(6) << " Uncorrected (Px,Py,Pz,E) : "
218  << "(" << fJet.px() << "," << fJet.py() << "," << fJet.pz() << "," << fJet.energy() << ")" << std::endl
219  << " Corrected (Px,Py,Pz,E) : "
220  << "(" << corrected.px() << "," << corrected.py() << "," << corrected.pz() << "," << corrected.energy() << ")"
221  << std::endl
222  << " Uncorrected (Pt,Eta,Phi,M) : "
223  << "(" << fJet.pt() << "," << fJet.eta() << "," << fJet.phi() << "," << fJet.mass() << ")" << std::endl
224  << " Corrected (Pt,Eta,Phi,M) : "
225  << "(" << corrected.pt() << "," << corrected.eta() << "," << corrected.phi() << "," << corrected.mass() << ")"
226  << std::endl
227  << " Scalar correction to E : " << scale << std::endl
228  << " Scalar correction to Et : " << (fJet.et() > 0. ? corrected.Et() / fJet.et() : 1.); // << std::endl
229  edm::LogVerbatim("JetPlusTrackCorrector") << ss.str();
230  }
231 
232  // Return energy correction
233  return scale;
234 }
Log< level::Info, true > LogVerbatim
bool canCorrect(const reco::Jet &) const
Can jet be JPT-corrected?
double pz() const final
z coordinate of momentum vector
double pt() const final
transverse momentum
bool matchTracks(const reco::Jet &, const edm::Event &, const edm::EventSetup &, jpt::MatchedTracks &pions, jpt::MatchedTracks &muons, jpt::MatchedTracks &elecs)
Matches tracks to different particle types.
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
const LorentzVector & p4() const final
four-momentum Lorentz vector
P4 pionCorrection(const P4 &jet, const jpt::MatchedTracks &pions)
Calculates corrections to be applied using pions.
double px() const final
x coordinate of momentum vector
P4 elecCorrection(const P4 &jet, const jpt::MatchedTracks &elecs) const
Calculates correction to be applied using electrons.
double py() const final
y coordinate of momentum vector
P4 jetDirFromTracks(const P4 &jet, const jpt::MatchedTracks &pions, const jpt::MatchedTracks &muons, const jpt::MatchedTracks &elecs) const
Calculates vectorial correction using total track 3-momentum.
double checkScale(const P4 &jet, P4 &corrected) const
Check corrected 4-momentum does not give negative scale.
Log< level::Info, false > LogInfo
P4 muonCorrection(const P4 &jet, const jpt::MatchedTracks &muons)
Calculates correction to be applied using muons.
double et() const final
transverse energy
double mass() const final
mass
double phi() const final
momentum azimuthal angle
Definition: event.py:1
double energy() const final
energy
double eta() const final
momentum pseudorapidity

◆ correction() [2/5]

double JetPlusTrackCorrector::correction ( const reco::Jet fJet,
const reco::Jet fJetcalo,
const edm::Event event,
const edm::EventSetup setup,
const reco::TrackRefVector tracksinvert,
const reco::TrackRefVector tracksincalo,
P4 corrected,
jpt::MatchedTracks pions,
jpt::MatchedTracks muons,
jpt::MatchedTracks elecs 
)

Definition at line 119 of file JetPlusTrackCorrector.cc.

References checkScale(), elecCorrection(), singleTopDQM_cfi::elecs, matchTracks(), muonCorrection(), DiMuonV_cfg::muons, reco::LeafCandidate::p4(), pionCorrection(), l1tEGammaCrystalsEmulatorProducer_cfi::scale, singleTopDQM_cfi::setup, useElecs_, useMuons_, usePAT_, and usePions_.

128  {
129  double scale = 1.;
130  corrected = fJet.p4();
131  matchTracks(fJetcalo, event, setup, tracksinvert, tracksincalo, pions, muons, elecs);
132  if (!usePAT_) {
133  if (usePions_) {
134  corrected += pionCorrection(fJet.p4(), pions);
135  }
136  if (useMuons_) {
137  corrected += muonCorrection(fJet.p4(), muons);
138  }
139  if (useElecs_) {
140  corrected += elecCorrection(fJet.p4(), elecs);
141  }
142  } else {
143  corrected += fJetcalo.p4();
144  }
145  scale = checkScale(fJet.p4(), corrected);
146  return scale;
147 }
bool matchTracks(const reco::Jet &, const edm::Event &, const edm::EventSetup &, jpt::MatchedTracks &pions, jpt::MatchedTracks &muons, jpt::MatchedTracks &elecs)
Matches tracks to different particle types.
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
const LorentzVector & p4() const final
four-momentum Lorentz vector
P4 pionCorrection(const P4 &jet, const jpt::MatchedTracks &pions)
Calculates corrections to be applied using pions.
P4 elecCorrection(const P4 &jet, const jpt::MatchedTracks &elecs) const
Calculates correction to be applied using electrons.
double checkScale(const P4 &jet, P4 &corrected) const
Check corrected 4-momentum does not give negative scale.
P4 muonCorrection(const P4 &jet, const jpt::MatchedTracks &muons)
Calculates correction to be applied using muons.
Definition: event.py:1

◆ correction() [3/5]

double JetPlusTrackCorrector::correction ( const reco::Jet fJet,
const reco::Jet fJetcalo,
const edm::Event event,
const edm::EventSetup setup,
jpt::MatchedTracks pions,
jpt::MatchedTracks muons,
jpt::MatchedTracks elecs,
bool &  validMatches 
)
inline

Scalar correction method.

Definition at line 472 of file JetPlusTrackCorrector.h.

References correction(), singleTopDQM_cfi::elecs, DiMuonV_cfg::muons, and singleTopDQM_cfi::setup.

479  {
480  P4 not_used_for_scalar_correction;
481  return correction(fJet, fJetcalo, event, setup, not_used_for_scalar_correction, pions, muons, elecs, validMatches);
482 }
math::XYZTLorentzVector P4
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
double correction(const reco::Jet &, const reco::Jet &, const edm::Event &, const edm::EventSetup &, P4 &, jpt::MatchedTracks &pions, jpt::MatchedTracks &muons, jpt::MatchedTracks &elecs, bool &validMatches)
Vectorial correction method (corrected 4-momentum passed by reference)
Definition: event.py:1

◆ correction() [4/5]

double JetPlusTrackCorrector::correction ( const reco::Jet jet) const

Correction method (not used)

Definition at line 238 of file JetPlusTrackCorrector.cc.

238  {
239  edm::LogError("JetPlusTrackCorrector") << "JetPlusTrackCorrector can be run on entire event only";
240  return 1.;
241 }
Log< level::Error, false > LogError

◆ correction() [5/5]

double JetPlusTrackCorrector::correction ( const P4 jet) const

Correction method (not used)

Definition at line 245 of file JetPlusTrackCorrector.cc.

245  {
246  edm::LogError("JetPlusTrackCorrector") << "JetPlusTrackCorrector can be run on entire event only";
247  return 1.;
248 }
Log< level::Error, false > LogError

◆ efficiencyMap()

const jpt::Map & JetPlusTrackCorrector::efficiencyMap ( ) const
inlineprotected

Definition at line 515 of file JetPlusTrackCorrector.h.

References efficiency_.

Referenced by pionCorrection().

515 { return efficiency_; }

◆ elecCorrection() [1/2]

JetPlusTrackCorrector::P4 JetPlusTrackCorrector::elecCorrection ( const P4 jet,
const jpt::MatchedTracks elecs 
) const

Calculates correction to be applied using electrons.

Definition at line 776 of file JetPlusTrackCorrector.cc.

References singleTopDQM_cfi::elecs, contentValuesCheck::ss, and verbose_.

Referenced by correction().

776  {
777  P4 null; //@@ null 4-momentum
778 
779  if (verbose_) {
780  std::stringstream ss;
781  ss << " Electron corrections:" << std::endl
782  << " In/In : "
783  << "(" << elecs.inVertexInCalo_.size() << ") " << null.energy() << std::endl
784  << " In/Out : "
785  << "(" << elecs.inVertexOutOfCalo_.size() << ") " << null.energy() << std::endl
786  << " Out/In : "
787  << "(" << elecs.outOfVertexInCalo_.size() << ") " << null.energy();
788  edm::LogVerbatim("JetPlusTrackCorrector") << ss.str();
789  }
790 
791  return null; //@@ to be implemented
792 }
math::XYZTLorentzVector P4
Log< level::Info, true > LogVerbatim

◆ elecCorrection() [2/2]

JetPlusTrackCorrector::P4 JetPlusTrackCorrector::elecCorrection ( const P4 jet,
const TrackRefs elecs,
bool  in_cone_at_vertex,
bool  in_cone_at_calo_face 
)
inlineprotected

Calculates individual electron corrections.

Definition at line 500 of file JetPlusTrackCorrector.h.

References calculateCorr(), elecMass_, singleTopDQM_cfi::elecs, metsig::jet, and not_used.

503  {
504  return calculateCorr(jet, elecs, not_used, in_cone_at_vertex, in_cone_at_calo_face, elecMass_, false, 0.);
505 }
P4 calculateCorr(const P4 &jet, const TrackRefs &, jpt::Efficiency &, bool in_cone_at_vertex, bool in_cone_at_calo_face, double mass, bool is_pion, double mip)
Generic method to calculates 4-momentum correction to be applied.

◆ eventRequired()

bool JetPlusTrackCorrector::eventRequired ( ) const
inline

Returns true.

Definition at line 484 of file JetPlusTrackCorrector.h.

484 { return true; }

◆ excludeJta()

void JetPlusTrackCorrector::excludeJta ( const reco::Jet fJet,
const JetTracksAssociations jtV0,
TrackRefs included,
const TrackRefs excluded 
) const
protected

Exclude jet-track association.

Definition at line 1235 of file JetPlusTrackCorrector.cc.

References edm::RefVector< C, T, F >::begin(), edm::RefVector< C, T, F >::clear(), edm::RefVector< C, T, F >::empty(), edm::RefVector< C, T, F >::end(), spr::find(), reco::JetTracksAssociation::getValue(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, jetSplitMerge_, edm::RefVector< C, T, F >::push_back(), and DiMuonV_cfg::tracks.

Referenced by jtaUsingEventData().

1238  {
1239  tracksthis = reco::JetTracksAssociation::getValue(jtV0, fJet);
1240  if (Excl.empty())
1241  return;
1242  if (jetSplitMerge_ < 0)
1243  return;
1244 
1245  TrackRefs tracks = tracksthis;
1246  tracksthis.clear();
1247 
1248  for (TrackRefs::iterator it = tracks.begin(); it != tracks.end(); it++) {
1249  TrackRefs::iterator itold = find(Excl.begin(), Excl.end(), (*it));
1250  if (itold == Excl.end()) {
1251  tracksthis.push_back(*it);
1252  }
1253  }
1254 
1255  return;
1256 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
reco::TrackRefVector TrackRefs
refhelper::RefVectorTrait< TrackCollection, typename refhelper::ValueTrait< TrackCollection >::value, typename refhelper::FindTrait< TrackCollection, typename refhelper::ValueTrait< TrackCollection >::value >::value >::iterator_type iterator
Definition: RefVector.h:37
const reco::TrackRefVector & getValue(const Container &, const reco::JetBaseRef &)
get value for the association. Throw exception if no association found

◆ failTrackQuality()

bool JetPlusTrackCorrector::failTrackQuality ( TrackRefs::const_iterator itrk) const
protected

Check on track quality.

Definition at line 608 of file JetPlusTrackCorrector.cc.

References dzVertexCut_, ptErrorQuality_, trackQuality_, useTrackQuality_, and vertex_.

Referenced by matchTracks().

608  {
609  bool retcode = false;
610 
611  if (useTrackQuality_ && !(*itrk)->quality(trackQuality_)) {
612  retcode = true;
613  return retcode;
614  }
615  if (((*itrk)->ptError() / (*itrk)->pt()) > ptErrorQuality_) {
616  retcode = true;
617  return retcode;
618  }
619  if (fabs((*itrk)->dz(vertex_)) > dzVertexCut_) {
620  retcode = true;
621  return retcode;
622  }
623 
624  return retcode;
625 }
reco::Particle::Point vertex_
reco::TrackBase::TrackQuality trackQuality_

◆ findTrack() [1/2]

bool JetPlusTrackCorrector::findTrack ( const jpt::JetTracks jet_tracks,
TrackRefs::const_iterator itrk,
TrackRefs::iterator it 
) const
protected

Find track in JetTracks collection.

Definition at line 629 of file JetPlusTrackCorrector.cc.

References edm::RefVector< C, T, F >::begin(), jpt::JetTracks::caloFace_, edm::RefVector< C, T, F >::end(), spr::find(), and ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it.

Referenced by matchTracks().

631  {
632  it = find(jet_tracks.caloFace_.begin(), jet_tracks.caloFace_.end(), *itrk);
633  if (it != jet_tracks.caloFace_.end()) {
634  return true;
635  } else {
636  return false;
637  }
638 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
reco::TrackRefVector caloFace_
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:228
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:223

◆ findTrack() [2/2]

bool JetPlusTrackCorrector::findTrack ( const jpt::MatchedTracks pions,
const jpt::MatchedTracks muons,
const jpt::MatchedTracks electrons,
TrackRefs::const_iterator itrk 
) const
protected

Find track in MatchedTracks collections.

Definition at line 642 of file JetPlusTrackCorrector.cc.

References edm::RefVector< C, T, F >::begin(), singleTopDQM_cfi::elecs, edm::RefVector< C, T, F >::end(), spr::find(), jpt::MatchedTracks::inVertexInCalo_, and DiMuonV_cfg::muons.

645  {
646  TrackRefs::iterator ip = find(pions.inVertexInCalo_.begin(), pions.inVertexInCalo_.end(), *itrk);
647  TrackRefs::iterator im = find(muons.inVertexInCalo_.begin(), muons.inVertexInCalo_.end(), *itrk);
648  TrackRefs::iterator ie = find(elecs.inVertexInCalo_.begin(), elecs.inVertexInCalo_.end(), *itrk);
649  if (ip == pions.inVertexInCalo_.end() && im == muons.inVertexInCalo_.end() && ie == elecs.inVertexInCalo_.end()) {
650  return false;
651  } else {
652  return true;
653  }
654 }
reco::TrackRefVector inVertexInCalo_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
refhelper::RefVectorTrait< TrackCollection, typename refhelper::ValueTrait< TrackCollection >::value, typename refhelper::FindTrait< TrackCollection, typename refhelper::ValueTrait< TrackCollection >::value >::value >::iterator_type iterator
Definition: RefVector.h:37
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:228
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:223

◆ getElectrons() [1/2]

bool JetPlusTrackCorrector::getElectrons ( const edm::Event event,
edm::Handle< RecoElectrons > &  reco_elecs,
edm::Handle< RecoElectronIds > &  reco_elec_ids 
) const
protected

Get RECO electrons.

Definition at line 592 of file JetPlusTrackCorrector.cc.

References input_reco_elec_ids_token_, and input_reco_elecs_token_.

Referenced by matchTracks().

594  {
595  event.getByToken(input_reco_elecs_token_, reco_elecs);
596  event.getByToken(input_reco_elec_ids_token_, reco_elec_ids);
597  return true;
598 }
edm::EDGetTokenT< RecoElectronIds > input_reco_elec_ids_token_
edm::EDGetTokenT< RecoElectrons > input_reco_elecs_token_

◆ getElectrons() [2/2]

bool JetPlusTrackCorrector::getElectrons ( const edm::Event event,
edm::Handle< pat::ElectronCollection > &  pat_elecs 
) const
protected

Definition at line 600 of file JetPlusTrackCorrector.cc.

References input_pat_elecs_token_.

601  {
602  event.getByToken(input_pat_elecs_token_, pat_elecs);
603  return true;
604 }
edm::EDGetTokenT< pat::ElectronCollection > input_pat_elecs_token_

◆ getMuons() [1/2]

bool JetPlusTrackCorrector::getMuons ( const edm::Event event,
edm::Handle< RecoMuons > &  reco_muons 
) const
protected

Get RECO muons.

Definition at line 385 of file JetPlusTrackCorrector.cc.

References input_reco_muons_token_.

Referenced by matchTracks().

385  {
386  event.getByToken(input_reco_muons_token_, reco_muons);
387  return true;
388 }
edm::EDGetTokenT< RecoMuons > input_reco_muons_token_

◆ getMuons() [2/2]

bool JetPlusTrackCorrector::getMuons ( const edm::Event ,
edm::Handle< pat::MuonCollection > &   
) const
protected

◆ getResponseOfChargedWithEff()

double JetPlusTrackCorrector::getResponseOfChargedWithEff ( )
inline

Get responses/sumPT/SumEnergy with and without Efficiency correction.

Definition at line 244 of file JetPlusTrackCorrector.h.

References theResponseOfChargedWithEff.

◆ getResponseOfChargedWithoutEff()

double JetPlusTrackCorrector::getResponseOfChargedWithoutEff ( )
inline

◆ getSumEnergyWithEff()

double JetPlusTrackCorrector::getSumEnergyWithEff ( )
inline

Definition at line 248 of file JetPlusTrackCorrector.h.

References theSumEnergyWithEff.

◆ getSumEnergyWithoutEff()

double JetPlusTrackCorrector::getSumEnergyWithoutEff ( )
inline

Definition at line 249 of file JetPlusTrackCorrector.h.

References theSumEnergyWithoutEff.

◆ getSumPtForBeta()

double JetPlusTrackCorrector::getSumPtForBeta ( )
inline

Definition at line 250 of file JetPlusTrackCorrector.h.

References theSumPtForBeta.

◆ getSumPtWithEff()

double JetPlusTrackCorrector::getSumPtWithEff ( )
inline

Definition at line 246 of file JetPlusTrackCorrector.h.

References theSumPtWithEff.

◆ getSumPtWithoutEff()

double JetPlusTrackCorrector::getSumPtWithoutEff ( )
inline

Definition at line 247 of file JetPlusTrackCorrector.h.

References theSumPtWithoutEff.

◆ jetDirFromTracks()

JetPlusTrackCorrector::P4 JetPlusTrackCorrector::jetDirFromTracks ( const P4 jet,
const jpt::MatchedTracks pions,
const jpt::MatchedTracks muons,
const jpt::MatchedTracks elecs 
) const
protected

Calculates vectorial correction using total track 3-momentum.

Definition at line 796 of file JetPlusTrackCorrector.cc.

References edm::RefVector< C, T, F >::begin(), alignCSCRings::corr, singleTopDQM_cfi::elecs, edm::RefVector< C, T, F >::empty(), edm::RefVector< C, T, F >::end(), jpt::MatchedTracks::inVertexInCalo_, jpt::MatchedTracks::inVertexOutOfCalo_, and DiMuonV_cfg::muons.

Referenced by correction().

799  {
800  // Correction to be applied to jet 4-momentum
801  P4 corr;
802 
803  // bool tracks_present = false;
804  bool tracks_present_inin = false;
805 
806  // Correct using pions in-cone at vertex
807 
808  if (!pions.inVertexInCalo_.empty()) {
810  TrackRefs::iterator jtrk = pions.inVertexInCalo_.end();
811  for (; itrk != jtrk; ++itrk) {
812  corr += PtEtaPhiM((*itrk)->pt(), (*itrk)->eta(), (*itrk)->phi(), 0.);
813  tracks_present_inin = true;
814  }
815  }
816 
817  if (!pions.inVertexOutOfCalo_.empty()) {
820  for (; itrk != jtrk; ++itrk) {
821  corr += PtEtaPhiM((*itrk)->pt(), (*itrk)->eta(), (*itrk)->phi(), 0.);
822  }
823  }
824 
825  // Correct using muons in-cone at vertex
826 
827  if (!muons.inVertexInCalo_.empty()) {
828  TrackRefs::iterator itrk = muons.inVertexInCalo_.begin();
829  TrackRefs::iterator jtrk = muons.inVertexInCalo_.end();
830  for (; itrk != jtrk; ++itrk) {
831  corr += PtEtaPhiM((*itrk)->pt(), (*itrk)->eta(), (*itrk)->phi(), 0.);
832  // tracks_present = true;
833  }
834  }
835 
836  if (!muons.inVertexOutOfCalo_.empty()) {
837  TrackRefs::iterator itrk = muons.inVertexOutOfCalo_.begin();
838  TrackRefs::iterator jtrk = muons.inVertexOutOfCalo_.end();
839  for (; itrk != jtrk; ++itrk) {
840  corr += PtEtaPhiM((*itrk)->pt(), (*itrk)->eta(), (*itrk)->phi(), 0.);
841  // tracks_present = true;
842  }
843  }
844 
845  // Correct using electrons in-cone at vertex
846 
847  if (!elecs.inVertexInCalo_.empty()) {
848  TrackRefs::iterator itrk = elecs.inVertexInCalo_.begin();
849  TrackRefs::iterator jtrk = elecs.inVertexInCalo_.end();
850  for (; itrk != jtrk; ++itrk) {
851  corr += PtEtaPhiM((*itrk)->pt(), (*itrk)->eta(), (*itrk)->phi(), 0.);
852  // tracks_present = true;
853  }
854  }
855 
856  if (!elecs.inVertexOutOfCalo_.empty()) {
857  TrackRefs::iterator itrk = elecs.inVertexOutOfCalo_.begin();
858  TrackRefs::iterator jtrk = elecs.inVertexOutOfCalo_.end();
859  for (; itrk != jtrk; ++itrk) {
860  corr += PtEtaPhiM((*itrk)->pt(), (*itrk)->eta(), (*itrk)->phi(), 0.);
861  // tracks_present = true;
862  }
863  }
864 
865  // Adjust direction if in cone tracks are present
866 
867  if (!tracks_present_inin) {
868  corr = corrected;
869  } else {
870  corr *= (corr.P() > 0. ? corrected.P() / corr.P() : 1.);
871  corr = P4(corr.px(), corr.py(), corr.pz(), corrected.energy());
872  }
873 
874  return corr;
875 }
math::XYZTLorentzVector P4
bool empty() const
Is the RefVector empty.
Definition: RefVector.h:99
reco::TrackRefVector inVertexInCalo_
reco::TrackRefVector inVertexOutOfCalo_
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
dictionary corr
refhelper::RefVectorTrait< TrackCollection, typename refhelper::ValueTrait< TrackCollection >::value, typename refhelper::FindTrait< TrackCollection, typename refhelper::ValueTrait< TrackCollection >::value >::value >::iterator_type iterator
Definition: RefVector.h:37
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:228
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:223
math::PtEtaPhiMLorentzVectorD PtEtaPhiM

◆ jetTrackAssociation()

bool JetPlusTrackCorrector::jetTrackAssociation ( const reco::Jet fJet,
const edm::Event event,
const edm::EventSetup setup,
jpt::JetTracks trks 
) const
protectedvirtual

Associates tracks to jets (overriden in derived class)

Definition at line 299 of file JetPlusTrackCorrector.cc.

References edm::InputTag::instance(), jetTracksAtCalo_, jetTracksAtVertex_, jtaUsingEventData(), edm::InputTag::label(), edm::InputTag::process(), and hltEgammaHLTExtra_cfi::trks.

Referenced by matchTracks().

302  {
303  // Some init
304  trks.clear();
305 
306  // Check if labels are given
307  if (!jetTracksAtVertex_.label().empty() && !jetTracksAtCalo_.label().empty()) {
308  return jtaUsingEventData(fJet, event, trks);
309  } else {
310  edm::LogWarning("PatJPTCorrector") << "[JetPlusTrackCorrector::" << __func__ << "]"
311  << " Empty label for the reco::JetTracksAssociation::Containers" << std::endl
312  << " InputTag for JTA \"at vertex\" (label:instance:process) \""
313  << jetTracksAtVertex_.label() << ":" << jetTracksAtVertex_.instance() << ":"
314  << jetTracksAtVertex_.process() << "\"" << std::endl
315  << " InputTag for JTA \"at calo face\" (label:instance:process) \""
316  << jetTracksAtCalo_.label() << ":" << jetTracksAtCalo_.instance() << ":"
317  << jetTracksAtCalo_.process() << "\"";
318  return false;
319  }
320 }
std::string const & instance() const
Definition: InputTag.h:37
std::string const & label() const
Definition: InputTag.h:36
bool jtaUsingEventData(const reco::Jet &, const edm::Event &, jpt::JetTracks &) const
JTA using collections from event.
Log< level::Warning, false > LogWarning
std::string const & process() const
Definition: InputTag.h:40
Definition: event.py:1

◆ jtaUsingEventData()

bool JetPlusTrackCorrector::jtaUsingEventData ( const reco::Jet fJet,
const edm::Event event,
jpt::JetTracks trks 
) const
protected

JTA using collections from event.

Definition at line 324 of file JetPlusTrackCorrector.cc.

References excludeJta(), edm::HandleBase::failedToGet(), reco::JetTracksAssociation::getValue(), input_jetTracksAtCalo_token_, input_jetTracksAtVertex_token_, edm::InputTag::instance(), edm::isDebugEnabled(), edm::HandleBase::isValid(), jetSplitMerge_, jetTracksAtCalo_, jetTracksAtVertex_, edm::InputTag::label(), edm::InputTag::process(), edm::Handle< T >::product(), rebuildJta(), hltEgammaHLTExtra_cfi::trks, and verbose_.

Referenced by jetTrackAssociation().

324  {
325  // Get Jet-track association at Vertex
327  event.getByToken(input_jetTracksAtVertex_token_, jetTracksAtVertex);
328 
329  if (!jetTracksAtVertex.isValid() || jetTracksAtVertex.failedToGet()) {
330  if (verbose_ && edm::isDebugEnabled()) {
331  edm::LogWarning("JetPlusTrackCorrector")
332  << "[JetPlusTrackCorrector::" << __func__ << "]"
333  << " Invalid handle to reco::JetTracksAssociation::Container (for Vertex)"
334  << " with InputTag (label:instance:process) \"" << jetTracksAtVertex_.label() << ":"
335  << jetTracksAtVertex_.instance() << ":" << jetTracksAtVertex_.process() << "\"";
336  }
337  return false;
338  }
339 
340  // Retrieve jet-tracks association for given jet
341  const reco::JetTracksAssociation::Container jtV = *(jetTracksAtVertex.product());
342  TrackRefs excluded;
343  TrackRefs relocate;
344  if (jetSplitMerge_ < 0) {
345  trks.vertex_ = reco::JetTracksAssociation::getValue(jtV, fJet);
346  } else {
347  rebuildJta(fJet, jtV, trks.vertex_, excluded);
348  rebuildJta(fJet, jtV, relocate, excluded);
349  trks.vertex_ = relocate;
350  }
351 
352  // Check if any tracks are associated to jet at vertex
353  if (trks.vertex_.empty()) {
354  return false;
355  }
356 
357  // Get Jet-track association at Calo
359  event.getByToken(input_jetTracksAtCalo_token_, jetTracksAtCalo);
360 
361  if (!jetTracksAtCalo.isValid() || jetTracksAtCalo.failedToGet()) {
362  if (verbose_ && edm::isDebugEnabled()) {
363  edm::LogWarning("JetPlusTrackCorrector")
364  << "[JetPlusTrackCorrector::" << __func__ << "]"
365  << " Invalid handle to reco::JetTracksAssociation::Container (for CaloFace)"
366  << " with InputTag (label:instance:process) \"" << jetTracksAtCalo_.label() << ":"
367  << jetTracksAtCalo_.instance() << ":" << jetTracksAtCalo_.process() << "\"";
368  }
369  return false;
370  }
371 
372  // Retrieve jet-tracks association for given jet
373  const reco::JetTracksAssociation::Container jtC = *(jetTracksAtCalo.product());
374  if (jetSplitMerge_ < 0) {
375  trks.caloFace_ = reco::JetTracksAssociation::getValue(jtC, fJet);
376  } else {
377  excludeJta(fJet, jtC, trks.caloFace_, excluded);
378  }
379 
380  return true;
381 }
bool isDebugEnabled()
void rebuildJta(const reco::Jet &, const JetTracksAssociations &, TrackRefs &included, TrackRefs &excluded) const
Rebuild jet-track association.
std::string const & instance() const
Definition: InputTag.h:37
T const * product() const
Definition: Handle.h:70
std::string const & label() const
Definition: InputTag.h:36
bool failedToGet() const
Definition: HandleBase.h:72
reco::TrackRefVector TrackRefs
const reco::TrackRefVector & getValue(const Container &, const reco::JetBaseRef &)
get value for the association. Throw exception if no association found
void excludeJta(const reco::Jet &, const JetTracksAssociations &, TrackRefs &included, const TrackRefs &excluded) const
Exclude jet-track association.
bool isValid() const
Definition: HandleBase.h:70
edm::EDGetTokenT< reco::JetTracksAssociation::Container > input_jetTracksAtCalo_token_
Log< level::Warning, false > LogWarning
std::string const & process() const
Definition: InputTag.h:40
edm::EDGetTokenT< reco::JetTracksAssociation::Container > input_jetTracksAtVertex_token_

◆ leakageMap()

const jpt::Map & JetPlusTrackCorrector::leakageMap ( ) const
inlineprotected

Definition at line 516 of file JetPlusTrackCorrector.h.

References leakage_.

Referenced by pionCorrection().

516 { return leakage_; }

◆ matchElectrons() [1/2]

bool JetPlusTrackCorrector::matchElectrons ( TrackRefs::const_iterator itrk,
const edm::Handle< RecoElectrons > &  elecs,
const edm::Handle< RecoElectronIds > &  elec_ids 
) const
protected

Matches tracks to RECO electrons.

Definition at line 1126 of file JetPlusTrackCorrector.cc.

References HLTMuonOfflineAnalyzer_cfi::deltaR2, ALPAKA_ACCELERATOR_NAMESPACE::dR2(), MillePedeFileConverter_cfg::e, singleTopDQM_cfi::elecs, and electronDRmatch_.

Referenced by matchTracks().

1128  {
1129  if (elecs->empty()) {
1130  return false;
1131  }
1132 
1133  double deltaRMIN = 999.;
1134 
1135  uint32_t electron_index = 0;
1136  for (auto const& ielec : *elecs) {
1137  edm::Ref<RecoElectrons> electron_ref(elecs, electron_index);
1138  electron_index++;
1139 
1140  if ((*elec_ids)[electron_ref] < 1.e-6) {
1141  continue;
1142  } //@@ Check for null value
1143 
1144  // DR matching b/w electron and track
1145  auto dR2 = deltaR2(ielec, **itrk);
1146  if (dR2 < deltaRMIN) {
1147  deltaRMIN = dR2;
1148  }
1149  }
1150  return deltaRMIN < electronDRmatch_ * electronDRmatch_;
1151 }
ALPAKA_FN_ACC static ALPAKA_FN_INLINE float dR2(Position4 pos1, Position4 pos2)

◆ matchElectrons() [2/2]

bool JetPlusTrackCorrector::matchElectrons ( TrackRefs::const_iterator itrk,
const edm::Handle< pat::ElectronCollection > &  elecs 
) const
protected

Definition at line 1153 of file JetPlusTrackCorrector.cc.

References HLTMuonOfflineAnalyzer_cfi::deltaR2, ALPAKA_ACCELERATOR_NAMESPACE::dR2(), singleTopDQM_cfi::elecs, and electronDRmatch_.

1154  {
1155  if (elecs->empty()) {
1156  return false;
1157  }
1158 
1159  double deltaRMIN = 999.;
1160  for (auto const& ielec : *elecs) {
1161  auto dR2 = deltaR2(ielec, **itrk);
1162  if (dR2 < deltaRMIN) {
1163  deltaRMIN = dR2;
1164  }
1165  }
1166  return deltaRMIN < electronDRmatch_ * electronDRmatch_;
1167 }
ALPAKA_FN_ACC static ALPAKA_FN_INLINE float dR2(Position4 pos1, Position4 pos2)

◆ matchMuons() [1/2]

bool JetPlusTrackCorrector::matchMuons ( TrackRefs::const_iterator itrk,
const edm::Handle< RecoMuons > &  muons 
) const
protected

Matches tracks to RECO muons.

Definition at line 1076 of file JetPlusTrackCorrector.cc.

References edm::Ref< C, T, F >::id(), muon::isGoodMuon(), DiMuonV_cfg::muons, and muon::TMLastStationTight.

Referenced by matchTracks().

1076  {
1077  if (muons->empty()) {
1078  return false;
1079  }
1080 
1081  RecoMuons::const_iterator imuon = muons->begin();
1082  RecoMuons::const_iterator jmuon = muons->end();
1083  for (; imuon != jmuon; ++imuon) {
1084  if (imuon->innerTrack().isNull() || !muon::isGoodMuon(*imuon, muon::TMLastStationTight) ||
1085  imuon->innerTrack()->pt() < 3.0) {
1086  continue;
1087  }
1088 
1089  if (itrk->id() != imuon->innerTrack().id()) {
1090  edm::LogError("JetPlusTrackCorrector") << "[JetPlusTrackCorrector::" << __func__ << "]"
1091  << "Product id of the tracks associated to the jet " << itrk->id()
1092  << " is different from the product id of the inner track used for muons "
1093  << imuon->innerTrack().id() << "!" << std::endl
1094  << "Cannot compare tracks from different collection. Configuration Error!";
1095  return false;
1096  }
1097 
1098  if (*itrk == imuon->innerTrack())
1099  return true;
1100  }
1101 
1102  return false;
1103 }
Log< level::Error, false > LogError
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call

◆ matchMuons() [2/2]

bool JetPlusTrackCorrector::matchMuons ( TrackRefs::const_iterator ,
const edm::Handle< pat::MuonCollection > &   
) const
protected

◆ matchTracks() [1/3]

bool JetPlusTrackCorrector::matchTracks ( const reco::Jet fJet,
const edm::Event event,
const edm::EventSetup setup,
jpt::MatchedTracks pions,
jpt::MatchedTracks muons,
jpt::MatchedTracks elecs 
)

Matches tracks to different particle types.

Definition at line 268 of file JetPlusTrackCorrector.cc.

References jpt::JetTracks::caloFace_, singleTopDQM_cfi::elecs, jetTrackAssociation(), DiMuonV_cfg::muons, convertSQLiteXML::ok, singleTopDQM_cfi::setup, edm::RefVector< C, T, F >::size(), contentValuesCheck::ss, verbose_, and jpt::JetTracks::vertex_.

Referenced by correction().

273  {
274  // Associate tracks to jet at both the Vertex and CaloFace
275  JetTracks jet_tracks;
276  bool ok = jetTrackAssociation(fJet, event, setup, jet_tracks);
277 
278  if (!ok) {
279  return false;
280  }
281 
282  // Track collections propagated to Vertex and CaloFace for "pions", muons and electrons
283  matchTracks(jet_tracks, event, pions, muons, elecs);
284 
285  // Debug
286  if (verbose_) {
287  std::stringstream ss;
288  ss << "Number of tracks:" << std::endl
289  << " In-cone at Vertex : " << jet_tracks.vertex_.size() << std::endl
290  << " In-cone at CaloFace : " << jet_tracks.caloFace_.size();
291  edm::LogVerbatim("JetPlusTrackCorrector") << ss.str();
292  }
293 
294  return true;
295 }
Log< level::Info, true > LogVerbatim
bool matchTracks(const reco::Jet &, const edm::Event &, const edm::EventSetup &, jpt::MatchedTracks &pions, jpt::MatchedTracks &muons, jpt::MatchedTracks &elecs)
Matches tracks to different particle types.
reco::TrackRefVector vertex_
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
reco::TrackRefVector caloFace_
virtual bool jetTrackAssociation(const reco::Jet &, const edm::Event &, const edm::EventSetup &, jpt::JetTracks &) const
Associates tracks to jets (overriden in derived class)
size_type size() const
Size of the RefVector.
Definition: RefVector.h:102
Tracks associated to jets that are in-cone at Vertex and CaloFace.
Definition: event.py:1

◆ matchTracks() [2/3]

void JetPlusTrackCorrector::matchTracks ( const reco::Jet fJet,
const edm::Event event,
const edm::EventSetup setup,
const reco::TrackRefVector tracksinvert,
const reco::TrackRefVector tracksincalo,
jpt::MatchedTracks pions,
jpt::MatchedTracks muons,
jpt::MatchedTracks elecs 
)

Definition at line 252 of file JetPlusTrackCorrector.cc.

References jpt::JetTracks::caloFace_, singleTopDQM_cfi::elecs, matchTracks(), DiMuonV_cfg::muons, and jpt::JetTracks::vertex_.

Referenced by matchTracks().

259  {
260  JetTracks jet_tracks;
261  jet_tracks.vertex_ = tracksinvert;
262  jet_tracks.caloFace_ = tracksincalo;
263  matchTracks(jet_tracks, event, pions, muons, elecs);
264 
265  return;
266 }
bool matchTracks(const reco::Jet &, const edm::Event &, const edm::EventSetup &, jpt::MatchedTracks &pions, jpt::MatchedTracks &muons, jpt::MatchedTracks &elecs)
Matches tracks to different particle types.
reco::TrackRefVector vertex_
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
reco::TrackRefVector caloFace_
Tracks associated to jets that are in-cone at Vertex and CaloFace.
Definition: event.py:1

◆ matchTracks() [3/3]

void JetPlusTrackCorrector::matchTracks ( const jpt::JetTracks jet_tracks,
const edm::Event event,
jpt::MatchedTracks pions,
jpt::MatchedTracks muons,
jpt::MatchedTracks elecs 
)
protectedvirtual

Matches tracks to different particle types (overriden in derived class)

Definition at line 397 of file JetPlusTrackCorrector.cc.

References edm::RefVector< C, T, F >::begin(), jpt::JetTracks::caloFace_, jpt::MatchedTracks::clear(), singleTopDQM_cfi::elecs, edm::RefVector< C, T, F >::end(), failTrackQuality(), spr::find(), findTrack(), newFWLiteAna::found, getElectrons(), getMuons(), input_pvCollection_token_, jpt::MatchedTracks::inVertexInCalo_, jpt::MatchedTracks::inVertexOutOfCalo_, edm::isDebugEnabled(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::iv, LogTrace, matchElectrons(), matchMuons(), DiMuonV_cfg::muons, jpt::MatchedTracks::outOfVertexInCalo_, edm::RefVector< C, T, F >::push_back(), heavyFlavorDQMFirstStep_cff::pvCollection, findQualityFiles::rr, edm::RefVector< C, T, F >::size(), contentValuesCheck::ss, theSumPtForBeta, trackQuality_, tracksInCalo(), useElecs_, useMuons_, usePAT_, useTrackQuality_, verbose_, jpt::JetTracks::vertex_, and vertex_.

401  {
402  // Some init
403  pions.clear();
404  muons.clear();
405  elecs.clear();
406 
407  // Need vertex for track cleaning
408 
409  vertex_ = reco::Particle::Point(0, 0, 0);
411  event.getByToken(input_pvCollection_token_, pvCollection);
412  if (pvCollection.isValid() && !pvCollection->empty())
413  vertex_ = pvCollection->begin()->position();
414 
415  // Get RECO muons
416  edm::Handle<RecoMuons> reco_muons;
418  bool found_reco_muons = true;
419  bool found_pat_muons = true;
420  if (useMuons_) {
421  if (!usePAT_) {
422  getMuons(event, reco_muons);
423  } else {
424  getMuons(event, pat_muons);
425  found_reco_muons = false;
426  }
427  }
428 
429  // Get RECO electrons and their ids
430  edm::Handle<RecoElectrons> reco_elecs;
432  edm::Handle<RecoElectronIds> reco_elec_ids;
433  bool found_reco_elecs = true;
434  bool found_pat_elecs = true;
435  if (useElecs_) {
436  if (!usePAT_) {
437  getElectrons(event, reco_elecs, reco_elec_ids);
438  } else {
439  getElectrons(event, pat_elecs);
440  found_reco_elecs = false;
441  }
442  }
443 
444  // Check RECO products found
445  if (!found_reco_muons || !found_reco_elecs) {
446  if (!found_pat_muons || !found_pat_elecs) {
447  edm::LogError("JetPlusTrackCorrector") << "[JetPlusTrackCorrector::" << __func__ << "]"
448  << " Unable to access RECO collections for muons and electrons";
449  return;
450  }
451  }
452 
453  // Identify pions/muons/electrons that are "in/in" and "in/out"
454  {
455  TrackRefs::const_iterator itrk = jet_tracks.vertex_.begin();
456  TrackRefs::const_iterator jtrk = jet_tracks.vertex_.end();
457 
458  double theSumPtForBetaOld = theSumPtForBeta;
459 
460  for (; itrk != jtrk; ++itrk) {
461  if (useTrackQuality_ && (*itrk)->quality(trackQuality_) && theSumPtForBetaOld <= 0.)
462  theSumPtForBeta += (**itrk).pt();
463  //
464  // Track either belongs to PV or do not belong to any vertex
465 
466  const reco::TrackBaseRef ttr1(*itrk);
467 
468  int numpv = 0;
469 
470  int itrack_belong = -1;
471 
472  for (reco::VertexCollection::const_iterator iv = pvCollection->begin(); iv != pvCollection->end(); iv++) {
473  numpv++;
474  std::vector<reco::TrackBaseRef>::const_iterator rr = find((*iv).tracks_begin(), (*iv).tracks_end(), ttr1);
475  if (rr != (*iv).tracks_end()) {
476  itrack_belong++;
477  break;
478  }
479 
480  } // all vertices
481 
482  if (numpv > 1 && itrack_belong == 0) {
483  continue;
484  }
485 
486  if (failTrackQuality(itrk)) {
487  continue;
488  }
489 
490  TrackRefs::iterator it = jet_tracks.caloFace_.end();
491  bool found = findTrack(jet_tracks, itrk, it);
492  bool muaccept = false;
493  bool eleaccept = false;
494  if (found_reco_muons)
495  muaccept = matchMuons(itrk, reco_muons);
496  else if (found_pat_muons) {
497  muaccept = matchMuons(itrk, pat_muons);
498  }
499  if (found_reco_elecs)
500  eleaccept = matchElectrons(itrk, reco_elecs, reco_elec_ids);
501  else if (found_pat_elecs) {
502  eleaccept = matchElectrons(itrk, pat_elecs);
503  }
504 
505  bool is_muon = useMuons_ && muaccept;
506  bool is_ele = useElecs_ && eleaccept;
507 
508  if (found) {
509  if (is_muon) {
510  muons.inVertexInCalo_.push_back(*it);
511  } else if (is_ele) {
512  elecs.inVertexInCalo_.push_back(*it);
513  } else {
514  pions.inVertexInCalo_.push_back(*it);
515  }
516  } else {
517  if (is_muon) {
518  muons.inVertexOutOfCalo_.push_back(*itrk);
519  } else if (is_ele) {
520  elecs.inVertexOutOfCalo_.push_back(*itrk);
521  } else {
522  pions.inVertexOutOfCalo_.push_back(*itrk);
523  }
524  }
525  }
526  }
527 
528  // Identify pions/muons/electrons that are "out/in"
529  {
530  TrackRefs::iterator itrk = jet_tracks.caloFace_.begin();
531  TrackRefs::iterator jtrk = jet_tracks.caloFace_.end();
532  for (; itrk != jtrk; ++itrk) {
533  if (failTrackQuality(itrk)) {
534  continue;
535  }
536 
537  if (!tracksInCalo(pions, muons, elecs)) {
538  continue;
539  }
540 
541  bool found = findTrack(pions, muons, elecs, itrk);
542 
543  if (!found) {
544  bool muaccept = false;
545  bool eleaccept = false;
546  if (found_reco_muons)
547  muaccept = matchMuons(itrk, reco_muons);
548  else if (found_pat_muons) {
549  muaccept = matchMuons(itrk, pat_muons);
550  }
551  if (found_reco_elecs)
552  eleaccept = matchElectrons(itrk, reco_elecs, reco_elec_ids);
553  else if (found_pat_elecs) {
554  eleaccept = matchElectrons(itrk, pat_elecs);
555  }
556 
557  bool is_muon = useMuons_ && muaccept;
558  bool is_ele = useElecs_ && eleaccept;
559 
560  if (is_muon) {
561  muons.outOfVertexInCalo_.push_back(*itrk);
562  } else if (is_ele) {
563  elecs.outOfVertexInCalo_.push_back(*itrk);
564  } else {
565  pions.outOfVertexInCalo_.push_back(*itrk);
566  }
567  }
568  }
569  }
570 
571  if (verbose_ && edm::isDebugEnabled()) {
572  std::stringstream ss;
573  ss << "[JetPlusTrackCorrector::" << __func__ << "] Number of tracks:" << std::endl
574  << " In-cone at Vertex and in-cone at CaloFace:" << std::endl
575  << " Pions : " << pions.inVertexInCalo_.size() << std::endl
576  << " Muons : " << muons.inVertexInCalo_.size() << std::endl
577  << " Electrons : " << elecs.inVertexInCalo_.size() << std::endl
578  << " In-cone at Vertex and out-of-cone at CaloFace:" << std::endl
579  << " Pions : " << pions.inVertexOutOfCalo_.size() << std::endl
580  << " Muons : " << muons.inVertexOutOfCalo_.size() << std::endl
581  << " Electrons : " << elecs.inVertexOutOfCalo_.size() << std::endl
582  << " Out-of-cone at Vertex and in-cone at CaloFace:" << std::endl
583  << " Pions : " << pions.outOfVertexInCalo_.size() << std::endl
584  << " Muons : " << muons.outOfVertexInCalo_.size() << std::endl
585  << " Electrons : " << elecs.outOfVertexInCalo_.size() << std::endl;
586  LogTrace("JetPlusTrackCorrector") << ss.str();
587  }
588 }
bool isDebugEnabled()
reco::TrackRefVector inVertexInCalo_
reco::TrackRefVector vertex_
reco::TrackRefVector inVertexOutOfCalo_
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
#define LogTrace(id)
bool findTrack(const jpt::JetTracks &, TrackRefs::const_iterator &, TrackRefs::iterator &) const
Find track in JetTracks collection.
reco::Particle::Point vertex_
reco::TrackRefVector caloFace_
bool getElectrons(const edm::Event &, edm::Handle< RecoElectrons > &, edm::Handle< RecoElectronIds > &) const
Get RECO electrons.
bool matchElectrons(TrackRefs::const_iterator &, const edm::Handle< RecoElectrons > &, const edm::Handle< RecoElectronIds > &) const
Matches tracks to RECO electrons.
math::XYZPoint Point
point in the space
Definition: Particle.h:25
reco::TrackRefVector outOfVertexInCalo_
refhelper::RefVectorTrait< TrackCollection, typename refhelper::ValueTrait< TrackCollection >::value, typename refhelper::FindTrait< TrackCollection, typename refhelper::ValueTrait< TrackCollection >::value >::value >::iterator_type iterator
Definition: RefVector.h:37
bool matchMuons(TrackRefs::const_iterator &, const edm::Handle< RecoMuons > &) const
Matches tracks to RECO muons.
size_type size() const
Size of the RefVector.
Definition: RefVector.h:102
bool tracksInCalo(const jpt::MatchedTracks &pions, const jpt::MatchedTracks &muons, const jpt::MatchedTracks &elecs) const
Determines if any tracks in cone at CaloFace.
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:228
reco::TrackBase::TrackQuality trackQuality_
bool getMuons(const edm::Event &, edm::Handle< RecoMuons > &) const
Get RECO muons.
bool failTrackQuality(TrackRefs::const_iterator &) const
Check on track quality.
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:67
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:223
edm::EDGetTokenT< reco::VertexCollection > input_pvCollection_token_
Definition: event.py:1

◆ muonCorrection() [1/2]

JetPlusTrackCorrector::P4 JetPlusTrackCorrector::muonCorrection ( const P4 jet,
const jpt::MatchedTracks muons 
)

Calculates correction to be applied using muons.

Definition at line 737 of file JetPlusTrackCorrector.cc.

References metsig::jet, DiMuonV_cfg::muons, contentValuesCheck::ss, useInConeTracks_, useOutOfConeTracks_, useOutOfVertexTracks_, and verbose_.

Referenced by correction().

737  {
738  P4 corr_muons;
739 
740  P4 corr_muons_in_cone;
741  P4 corr_muons_out_of_cone;
742  P4 corr_muons_out_of_vertex;
743 
744  if (useInConeTracks_) {
745  corr_muons_in_cone = muonCorrection(jet, muons.inVertexInCalo_, true, true);
746  corr_muons += corr_muons_in_cone;
747  }
748 
749  if (useOutOfConeTracks_) {
750  corr_muons_out_of_cone = muonCorrection(jet, muons.inVertexOutOfCalo_, true, false);
751  corr_muons += corr_muons_out_of_cone;
752  }
753 
754  if (useOutOfVertexTracks_) {
755  corr_muons_out_of_vertex = muonCorrection(jet, muons.outOfVertexInCalo_, false, true);
756  corr_muons += corr_muons_out_of_vertex;
757  }
758 
759  if (verbose_) {
760  std::stringstream ss;
761  ss << " Muon corrections:" << std::endl
762  << " In/In : "
763  << "(" << muons.inVertexInCalo_.size() << ") " << corr_muons_in_cone.energy() << std::endl
764  << " In/Out : "
765  << "(" << muons.inVertexOutOfCalo_.size() << ") " << corr_muons_out_of_cone.energy() << std::endl
766  << " Out/In : "
767  << "(" << muons.outOfVertexInCalo_.size() << ") " << corr_muons_out_of_vertex.energy();
768  edm::LogVerbatim("JetPlusTrackCorrector") << ss.str();
769  }
770 
771  return corr_muons;
772 }
math::XYZTLorentzVector P4
Log< level::Info, true > LogVerbatim
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
P4 muonCorrection(const P4 &jet, const jpt::MatchedTracks &muons)
Calculates correction to be applied using muons.

◆ muonCorrection() [2/2]

JetPlusTrackCorrector::P4 JetPlusTrackCorrector::muonCorrection ( const P4 jet,
const TrackRefs muons,
bool  in_cone_at_vertex,
bool  in_cone_at_calo_face 
)
inlineprotected

Calculates individual muons corrections.

Definition at line 493 of file JetPlusTrackCorrector.h.

References calculateCorr(), metsig::jet, muonMass_, DiMuonV_cfg::muons, and not_used.

496  {
497  return calculateCorr(jet, muons, not_used, in_cone_at_vertex, in_cone_at_calo_face, muonMass_, false, 2.);
498 }
P4 calculateCorr(const P4 &jet, const TrackRefs &, jpt::Efficiency &, bool in_cone_at_vertex, bool in_cone_at_calo_face, double mass, bool is_pion, double mip)
Generic method to calculates 4-momentum correction to be applied.
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214

◆ pionCorrection() [1/2]

JetPlusTrackCorrector::P4 JetPlusTrackCorrector::pionCorrection ( const P4 jet,
const jpt::MatchedTracks pions 
)

Calculates corrections to be applied using pions.

Definition at line 670 of file JetPlusTrackCorrector.cc.

References efficiencyMap(), jpt::MatchedTracks::inVertexInCalo_, jpt::MatchedTracks::inVertexOutOfCalo_, metsig::jet, leakageMap(), not_used, jpt::MatchedTracks::outOfVertexInCalo_, pionEfficiency(), responseMap(), edm::RefVector< C, T, F >::size(), contentValuesCheck::ss, useEff_, useInConeTracks_, useOutOfConeTracks_, useOutOfVertexTracks_, and verbose_.

Referenced by correction().

670  {
671  P4 corr_pions;
672 
673  // In-cone
674 
675  P4 corr_pions_in_cone;
676  P4 corr_pions_eff_in_cone;
678 
679  if (useInConeTracks_) {
680  corr_pions_in_cone = pionCorrection(jet, pions.inVertexInCalo_, in_cone, true, true);
681  corr_pions += corr_pions_in_cone;
682  if (useEff_) {
683  corr_pions_eff_in_cone = pionEfficiency(jet, in_cone, true);
684  corr_pions += corr_pions_eff_in_cone;
685  }
686  }
687 
688  // Out-of-cone
689 
690  P4 corr_pions_out_of_cone;
691  P4 corr_pions_eff_out_of_cone;
692  Efficiency out_of_cone(responseMap(), efficiencyMap(), leakageMap());
693 
694  if (useOutOfConeTracks_) {
695  corr_pions_out_of_cone = pionCorrection(jet, pions.inVertexOutOfCalo_, out_of_cone, true, false);
696  corr_pions += corr_pions_out_of_cone;
697  if (useEff_) {
698  corr_pions_eff_out_of_cone = pionEfficiency(jet, out_of_cone, false);
699  corr_pions += corr_pions_eff_out_of_cone;
700  }
701  }
702 
703  // Out-of-vertex
704 
705  P4 corr_pions_out_of_vertex;
707 
708  if (useOutOfVertexTracks_) {
709  corr_pions_out_of_vertex = pionCorrection(jet, pions.outOfVertexInCalo_, not_used, false, true);
710  corr_pions += corr_pions_out_of_vertex;
711  }
712 
713  if (verbose_) {
714  std::stringstream ss;
715  ss << " Pion corrections:" << std::endl
716  << " In/In : "
717  << "(" << pions.inVertexInCalo_.size() << ") " << corr_pions_in_cone.energy() << std::endl
718  << " In/Out : "
719  << "(" << pions.inVertexOutOfCalo_.size() << ") " << corr_pions_out_of_cone.energy() << std::endl
720  << " Out/In : "
721  << "(" << pions.outOfVertexInCalo_.size() << ") " << corr_pions_out_of_vertex.energy() << std::endl;
722  if (useEff_) {
723  ss << " Pion efficiency corrections:" << std::endl
724  << " In/In : "
725  << "(" << pions.inVertexInCalo_.size() << ") " << corr_pions_eff_in_cone.energy() << std::endl
726  << " In/Out : "
727  << "(" << pions.inVertexOutOfCalo_.size() << ") " << corr_pions_eff_out_of_cone.energy();
728  }
729  edm::LogVerbatim("JetPlusTrackCorrector") << ss.str();
730  }
731 
732  return corr_pions;
733 }
math::XYZTLorentzVector P4
Log< level::Info, true > LogVerbatim
const jpt::Map & responseMap() const
reco::TrackRefVector inVertexInCalo_
const jpt::Map & leakageMap() const
reco::TrackRefVector inVertexOutOfCalo_
P4 pionCorrection(const P4 &jet, const jpt::MatchedTracks &pions)
Calculates corrections to be applied using pions.
const jpt::Map & efficiencyMap() const
reco::TrackRefVector outOfVertexInCalo_
P4 pionEfficiency(const P4 &jet, const jpt::Efficiency &, bool in_cone_at_calo_face)
Correction to be applied using tracking efficiency.
size_type size() const
Size of the RefVector.
Definition: RefVector.h:102
Generic container class.

◆ pionCorrection() [2/2]

JetPlusTrackCorrector::P4 JetPlusTrackCorrector::pionCorrection ( const P4 jet,
const TrackRefs pions,
jpt::Efficiency eff,
bool  in_cone_at_vertex,
bool  in_cone_at_calo_face 
)
inlineprotected

Calculates individual pion corrections.

Definition at line 488 of file JetPlusTrackCorrector.h.

References calculateCorr(), metsig::jet, and pionMass_.

489  {
490  return calculateCorr(jet, pions, eff, in_cone_at_vertex, in_cone_at_calo_face, pionMass_, true, -1.);
491 }
P4 calculateCorr(const P4 &jet, const TrackRefs &, jpt::Efficiency &, bool in_cone_at_vertex, bool in_cone_at_calo_face, double mass, bool is_pion, double mip)
Generic method to calculates 4-momentum correction to be applied.

◆ pionEfficiency()

JetPlusTrackCorrector::P4 JetPlusTrackCorrector::pionEfficiency ( const P4 jet,
const jpt::Efficiency eff,
bool  in_cone_at_calo_face 
)
protected

Correction to be applied using tracking efficiency.

Definition at line 1012 of file JetPlusTrackCorrector.cc.

References jpt::Map::binCenterEta(), jpt::Map::binCenterPt(), alignCSCRings::corr, correction(), hcalRecHitTable_cff::ieta, cuy::ii, jpt::Efficiency::inConeCorr(), metsig::jet, jpt::Map::nEtaBins(), jpt::Map::nPtBins(), jpt::Efficiency::nTrks(), jpt::Efficiency::outOfConeCorr(), pionMass_, response_, theResponseOfChargedWithEff, theSumEnergyWithEff, theSumPtWithEff, vecResponse_, and vectorial_.

Referenced by pionCorrection().

1014  {
1015  // Total correction to be applied
1016  P4 correction;
1017 
1018  double theSumResp = 0;
1019  double theSumPt = 0;
1020  double theSumEnergy = 0;
1021 
1022  // Iterate through eta/pt bins
1023  for (uint32_t ieta = 0; ieta < response_.nEtaBins() - 1; ++ieta) {
1024  for (uint32_t ipt = 0; ipt < response_.nPtBins() - 1; ++ipt) {
1025  // Check tracks are found in this eta/pt bin
1026  if (!eff.nTrks(ieta, ipt)) {
1027  continue;
1028  }
1029 
1030  for (uint16_t ii = 0; ii < 2; ++ii) {
1031  // Check which correction should be applied
1032  double corr = 0.;
1033  if (ii == 0) {
1034  corr = eff.outOfConeCorr(ieta, ipt);
1035  } else if (ii == 1 && in_cone_at_calo_face) {
1036  corr = eff.inConeCorr(ieta, ipt);
1037  } else {
1038  continue;
1039  }
1040 
1041  // Calculate correction to be applied
1042  P4 corr_p4;
1043  if (vectorial_ && vecResponse_) {
1044  double corr_eta = response_.binCenterEta(ieta);
1045  double corr_phi = jet.phi(); //@@ jet phi!
1046  double corr_pt = response_.binCenterPt(ipt);
1047  corr_p4 =
1048  PtEtaPhiM(corr_pt, corr_eta, corr_phi, pionMass_); //@@ E^2 = p^2 + m_pion^2, |p| calc'ed from pt bin
1049  corr_p4 *= (corr_p4.energy() > 0. ? corr / corr_p4.energy() : 1.); //@@ p4 scaled up by mean energy for bin
1050  } else {
1051  corr_p4 = (jet.energy() > 0. ? corr / jet.energy() : 1.) * jet;
1052  }
1053 
1054  // Apply correction
1055  if (ii == 0) {
1056  correction += corr_p4;
1057  theSumPt += corr_p4.pt();
1058  theSumEnergy += corr_p4.energy();
1059  } //@@ Add out-of-cone
1060  else if (ii == 1) {
1061  correction -= corr_p4;
1062  theSumResp += corr_p4.energy();
1063  } //@@ Subtract in-cone
1064  }
1065  }
1066  }
1067 
1068  theResponseOfChargedWithEff += theSumResp;
1069  theSumPtWithEff += theSumPt;
1070  theSumEnergyWithEff += theSumEnergy;
1071  return correction;
1072 }
math::XYZTLorentzVector P4
uint32_t nPtBins() const
double binCenterEta(uint32_t) const
dictionary corr
double correction(const reco::Jet &, const reco::Jet &, const edm::Event &, const edm::EventSetup &, P4 &, jpt::MatchedTracks &pions, jpt::MatchedTracks &muons, jpt::MatchedTracks &elecs, bool &validMatches)
Vectorial correction method (corrected 4-momentum passed by reference)
uint32_t nEtaBins() const
ii
Definition: cuy.py:589
double binCenterPt(uint32_t) const
double inConeCorr(uint32_t eta_bin, uint32_t pt_bin) const
uint16_t nTrks(uint32_t eta_bin, uint32_t pt_bin) const
double outOfConeCorr(uint32_t eta_bin, uint32_t pt_bin) const
math::PtEtaPhiMLorentzVectorD PtEtaPhiM

◆ rebuildJta()

void JetPlusTrackCorrector::rebuildJta ( const reco::Jet fJet,
const JetTracksAssociations jtV0,
TrackRefs included,
TrackRefs excluded 
) const
protected

Rebuild jet-track association.

Definition at line 1171 of file JetPlusTrackCorrector.cc.

References reco::JetTracksAssociation::allJets(), edm::RefVector< C, T, F >::clear(), HLTMuonOfflineAnalyzer_cfi::deltaR2, ALPAKA_ACCELERATOR_NAMESPACE::dR2(), reco::LeafCandidate::et(), reco::LeafCandidate::eta(), RemoveAddSevLevel::flag, reco::JetTracksAssociation::getValue(), cuy::ii, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, reco::btau::jetEta, reco::btau::jetPhi, jetSplitMerge_, reco::LeafCandidate::phi(), edm::RefVector< C, T, F >::push_back(), l1tEGammaCrystalsEmulatorProducer_cfi::scale, DiMuonV_cfg::tracks, run3scouting_cff::trkEta, and run3scouting_cff::trkPhi.

Referenced by jtaUsingEventData().

1174  {
1175  tracksthis = reco::JetTracksAssociation::getValue(jtV0, fJet);
1176 
1177  if (jetSplitMerge_ < 0)
1178  return;
1179 
1180  typedef std::vector<reco::JetBaseRef>::iterator JetBaseRefIterator;
1181  std::vector<reco::JetBaseRef> theJets = reco::JetTracksAssociation::allJets(jtV0);
1182 
1183  TrackRefs tracks = tracksthis;
1184  tracksthis.clear();
1185 
1186  double jetEta = fJet.eta();
1187  double jetPhi = fJet.phi();
1188  double jetEtIn = 1.0 / fJet.et();
1189 
1190  for (TrackRefs::iterator it = tracks.begin(); it != tracks.end(); it++) {
1191  double trkEta = (**it).eta();
1192  double trkPhi = (**it).phi();
1193  double dR2this = deltaR2(jetEta, jetPhi, trkEta, trkPhi);
1194  // double dfi = fabs(fJet.phi()-(**it).phi());
1195  // if(dfi>4.*atan(1.))dfi = 8.*atan(1.)-dfi;
1196  // double deta = fJet.eta() - (**it).eta();
1197  // double dR2check = sqrt(dfi*dfi+deta*deta);
1198 
1199  double scalethis = dR2this;
1200  if (jetSplitMerge_ == 0)
1201  scalethis = 1. * jetEtIn;
1202  if (jetSplitMerge_ == 2)
1203  scalethis = dR2this * jetEtIn;
1204  int flag = 1;
1205  for (JetBaseRefIterator ii = theJets.begin(); ii != theJets.end(); ii++) {
1206  if (&(**ii) == &fJet) {
1207  continue;
1208  }
1209  double dR2 = deltaR2((*ii)->eta(), (*ii)->phi(), trkEta, trkPhi);
1210  double scale = dR2;
1211  if (jetSplitMerge_ == 0)
1212  scale = 1. / (**ii).et();
1213  if (jetSplitMerge_ == 2)
1214  scale = dR2 / (**ii).et();
1215  if (scale < scalethis)
1216  flag = 0;
1217 
1218  if (flag == 0) {
1219  break;
1220  }
1221  }
1222 
1223  if (flag == 1) {
1224  tracksthis.push_back(*it);
1225  } else {
1226  Excl.push_back(*it);
1227  }
1228  }
1229 
1230  return;
1231 }
ALPAKA_FN_ACC static ALPAKA_FN_INLINE float dR2(Position4 pos1, Position4 pos2)
reco::TrackRefVector TrackRefs
refhelper::RefVectorTrait< TrackCollection, typename refhelper::ValueTrait< TrackCollection >::value, typename refhelper::FindTrait< TrackCollection, typename refhelper::ValueTrait< TrackCollection >::value >::value >::iterator_type iterator
Definition: RefVector.h:37
const reco::TrackRefVector & getValue(const Container &, const reco::JetBaseRef &)
get value for the association. Throw exception if no association found
ii
Definition: cuy.py:589
std::vector< reco::JetBaseRef > allJets(const Container &)
fill list of all jets associated with values. Return # of jets in the list
double et() const final
transverse energy
double phi() const final
momentum azimuthal angle
double eta() const final
momentum pseudorapidity

◆ responseMap()

const jpt::Map & JetPlusTrackCorrector::responseMap ( ) const
inlineprotected

Definition at line 514 of file JetPlusTrackCorrector.h.

References response_.

Referenced by pionCorrection().

514 { return response_; }

◆ tracksInCalo()

bool JetPlusTrackCorrector::tracksInCalo ( const jpt::MatchedTracks pions,
const jpt::MatchedTracks muons,
const jpt::MatchedTracks elecs 
) const
protected

Determines if any tracks in cone at CaloFace.

Definition at line 658 of file JetPlusTrackCorrector.cc.

References singleTopDQM_cfi::elecs, edm::RefVector< C, T, F >::empty(), jpt::MatchedTracks::inVertexInCalo_, and DiMuonV_cfg::muons.

Referenced by matchTracks().

660  {
661  if (!pions.inVertexInCalo_.empty() || !muons.inVertexInCalo_.empty() || !elecs.inVertexInCalo_.empty()) {
662  return true;
663  } else {
664  return false;
665  }
666 }
bool empty() const
Is the RefVector empty.
Definition: RefVector.h:99
reco::TrackRefVector inVertexInCalo_
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214

◆ vectorialCorrection()

bool JetPlusTrackCorrector::vectorialCorrection ( ) const
inline

Returns value of configurable.

Definition at line 485 of file JetPlusTrackCorrector.h.

References vectorial_.

Member Data Documentation

◆ dzVertexCut_

double JetPlusTrackCorrector::dzVertexCut_
protected

Definition at line 417 of file JetPlusTrackCorrector.h.

Referenced by failTrackQuality().

◆ efficiency_

const jpt::Map JetPlusTrackCorrector::efficiency_
protected

Definition at line 432 of file JetPlusTrackCorrector.h.

Referenced by correctAA(), and efficiencyMap().

◆ elecMass_

double JetPlusTrackCorrector::elecMass_
protected

Definition at line 444 of file JetPlusTrackCorrector.h.

Referenced by elecCorrection().

◆ electronDRmatch_

double JetPlusTrackCorrector::electronDRmatch_
protected

Definition at line 439 of file JetPlusTrackCorrector.h.

Referenced by matchElectrons().

◆ electronIds_

edm::InputTag JetPlusTrackCorrector::electronIds_
protected

Definition at line 423 of file JetPlusTrackCorrector.h.

Referenced by JetPlusTrackCorrector().

◆ electrons_

edm::InputTag JetPlusTrackCorrector::electrons_
protected

Definition at line 422 of file JetPlusTrackCorrector.h.

Referenced by JetPlusTrackCorrector().

◆ input_jetTracksAtCalo_token_

edm::EDGetTokenT<reco::JetTracksAssociation::Container> JetPlusTrackCorrector::input_jetTracksAtCalo_token_
private

Definition at line 461 of file JetPlusTrackCorrector.h.

Referenced by JetPlusTrackCorrector(), and jtaUsingEventData().

◆ input_jetTracksAtVertex_token_

edm::EDGetTokenT<reco::JetTracksAssociation::Container> JetPlusTrackCorrector::input_jetTracksAtVertex_token_
private

Definition at line 460 of file JetPlusTrackCorrector.h.

Referenced by JetPlusTrackCorrector(), and jtaUsingEventData().

◆ input_pat_elecs_token_

edm::EDGetTokenT<pat::ElectronCollection> JetPlusTrackCorrector::input_pat_elecs_token_
private

Definition at line 467 of file JetPlusTrackCorrector.h.

Referenced by getElectrons(), and JetPlusTrackCorrector().

◆ input_pat_muons_token_

edm::EDGetTokenT<pat::MuonCollection> JetPlusTrackCorrector::input_pat_muons_token_
private

Definition at line 466 of file JetPlusTrackCorrector.h.

Referenced by JetPlusTrackCorrector().

◆ input_pvCollection_token_

edm::EDGetTokenT<reco::VertexCollection> JetPlusTrackCorrector::input_pvCollection_token_
private

Definition at line 463 of file JetPlusTrackCorrector.h.

Referenced by JetPlusTrackCorrector(), and matchTracks().

◆ input_reco_elec_ids_token_

edm::EDGetTokenT<RecoElectronIds> JetPlusTrackCorrector::input_reco_elec_ids_token_
private

Definition at line 465 of file JetPlusTrackCorrector.h.

Referenced by getElectrons(), and JetPlusTrackCorrector().

◆ input_reco_elecs_token_

edm::EDGetTokenT<RecoElectrons> JetPlusTrackCorrector::input_reco_elecs_token_
private

Definition at line 464 of file JetPlusTrackCorrector.h.

Referenced by getElectrons(), and JetPlusTrackCorrector().

◆ input_reco_muons_token_

edm::EDGetTokenT<RecoMuons> JetPlusTrackCorrector::input_reco_muons_token_
private

Definition at line 462 of file JetPlusTrackCorrector.h.

Referenced by getMuons(), and JetPlusTrackCorrector().

◆ jetSplitMerge_

int JetPlusTrackCorrector::jetSplitMerge_
protected

◆ jetTracksAtCalo_

edm::InputTag JetPlusTrackCorrector::jetTracksAtCalo_
protected

◆ jetTracksAtVertex_

edm::InputTag JetPlusTrackCorrector::jetTracksAtVertex_
protected

◆ leakage_

const jpt::Map JetPlusTrackCorrector::leakage_
protected

Definition at line 433 of file JetPlusTrackCorrector.h.

Referenced by leakageMap().

◆ maxEta_

double JetPlusTrackCorrector::maxEta_
protected

Definition at line 447 of file JetPlusTrackCorrector.h.

Referenced by canCorrect().

◆ muonEtamatch_

double JetPlusTrackCorrector::muonEtamatch_
protected

Definition at line 437 of file JetPlusTrackCorrector.h.

◆ muonMass_

double JetPlusTrackCorrector::muonMass_
protected

Definition at line 443 of file JetPlusTrackCorrector.h.

Referenced by muonCorrection().

◆ muonPhimatch_

double JetPlusTrackCorrector::muonPhimatch_
protected

Definition at line 438 of file JetPlusTrackCorrector.h.

◆ muonPtmatch_

double JetPlusTrackCorrector::muonPtmatch_
protected

Definition at line 436 of file JetPlusTrackCorrector.h.

◆ muons_

edm::InputTag JetPlusTrackCorrector::muons_
protected

Definition at line 421 of file JetPlusTrackCorrector.h.

Referenced by JetPlusTrackCorrector().

◆ not_used

jpt::Efficiency JetPlusTrackCorrector::not_used {response_, efficiency_, leakage_}
protected

Definition at line 455 of file JetPlusTrackCorrector.h.

Referenced by elecCorrection(), muonCorrection(), and pionCorrection().

◆ patelectrons_

edm::InputTag JetPlusTrackCorrector::patelectrons_
protected

Definition at line 425 of file JetPlusTrackCorrector.h.

Referenced by JetPlusTrackCorrector().

◆ patmuons_

edm::InputTag JetPlusTrackCorrector::patmuons_
protected

Definition at line 424 of file JetPlusTrackCorrector.h.

Referenced by JetPlusTrackCorrector().

◆ pionMass_

double JetPlusTrackCorrector::pionMass_
protected

Definition at line 442 of file JetPlusTrackCorrector.h.

Referenced by pionCorrection(), and pionEfficiency().

◆ ptErrorQuality_

double JetPlusTrackCorrector::ptErrorQuality_
protected

Definition at line 416 of file JetPlusTrackCorrector.h.

Referenced by failTrackQuality().

◆ response_

const jpt::Map JetPlusTrackCorrector::response_
protected

Definition at line 431 of file JetPlusTrackCorrector.h.

Referenced by calculateCorr(), correctAA(), pionEfficiency(), and responseMap().

◆ srcPVs_

edm::InputTag JetPlusTrackCorrector::srcPVs_
protected

Definition at line 415 of file JetPlusTrackCorrector.h.

Referenced by JetPlusTrackCorrector().

◆ theResponseOfChargedWithEff

float JetPlusTrackCorrector::theResponseOfChargedWithEff
protected

◆ theResponseOfChargedWithoutEff

float JetPlusTrackCorrector::theResponseOfChargedWithoutEff
protected

◆ theSumEnergyWithEff

float JetPlusTrackCorrector::theSumEnergyWithEff
protected

◆ theSumEnergyWithoutEff

float JetPlusTrackCorrector::theSumEnergyWithoutEff
protected

Definition at line 453 of file JetPlusTrackCorrector.h.

Referenced by calculateCorr(), correction(), and getSumEnergyWithoutEff().

◆ theSumPtForBeta

float JetPlusTrackCorrector::theSumPtForBeta
protected

Definition at line 454 of file JetPlusTrackCorrector.h.

Referenced by correction(), getSumPtForBeta(), and matchTracks().

◆ theSumPtWithEff

float JetPlusTrackCorrector::theSumPtWithEff
protected

◆ theSumPtWithoutEff

float JetPlusTrackCorrector::theSumPtWithoutEff
protected

Definition at line 451 of file JetPlusTrackCorrector.h.

Referenced by calculateCorr(), correction(), and getSumPtWithoutEff().

◆ trackQuality_

reco::TrackBase::TrackQuality JetPlusTrackCorrector::trackQuality_
protected

Definition at line 428 of file JetPlusTrackCorrector.h.

Referenced by failTrackQuality(), and matchTracks().

◆ useEff_

bool JetPlusTrackCorrector::useEff_
protected

Definition at line 406 of file JetPlusTrackCorrector.h.

Referenced by JetPlusTrackCorrector(), and pionCorrection().

◆ useElecs_

bool JetPlusTrackCorrector::useElecs_
protected

Definition at line 408 of file JetPlusTrackCorrector.h.

Referenced by correction(), JetPlusTrackCorrector(), and matchTracks().

◆ useInConeTracks_

bool JetPlusTrackCorrector::useInConeTracks_
protected

Definition at line 402 of file JetPlusTrackCorrector.h.

Referenced by JetPlusTrackCorrector(), muonCorrection(), and pionCorrection().

◆ useMuons_

bool JetPlusTrackCorrector::useMuons_
protected

Definition at line 407 of file JetPlusTrackCorrector.h.

Referenced by correction(), JetPlusTrackCorrector(), and matchTracks().

◆ useOutOfConeTracks_

bool JetPlusTrackCorrector::useOutOfConeTracks_
protected

Definition at line 403 of file JetPlusTrackCorrector.h.

Referenced by JetPlusTrackCorrector(), muonCorrection(), and pionCorrection().

◆ useOutOfVertexTracks_

bool JetPlusTrackCorrector::useOutOfVertexTracks_
protected

Definition at line 404 of file JetPlusTrackCorrector.h.

Referenced by JetPlusTrackCorrector(), muonCorrection(), and pionCorrection().

◆ usePAT_

bool JetPlusTrackCorrector::usePAT_
protected

Definition at line 399 of file JetPlusTrackCorrector.h.

Referenced by correction(), JetPlusTrackCorrector(), and matchTracks().

◆ usePions_

bool JetPlusTrackCorrector::usePions_
protected

Definition at line 405 of file JetPlusTrackCorrector.h.

Referenced by correction(), and JetPlusTrackCorrector().

◆ useTrackQuality_

bool JetPlusTrackCorrector::useTrackQuality_
protected

Definition at line 409 of file JetPlusTrackCorrector.h.

Referenced by failTrackQuality(), JetPlusTrackCorrector(), and matchTracks().

◆ vecResponse_

bool JetPlusTrackCorrector::vecResponse_
protected

◆ vectorial_

bool JetPlusTrackCorrector::vectorial_
protected

◆ verbose_

bool JetPlusTrackCorrector::verbose_
protected

◆ vertex_

reco::Particle::Point JetPlusTrackCorrector::vertex_
protected

Definition at line 418 of file JetPlusTrackCorrector.h.

Referenced by failTrackQuality(), and matchTracks().