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 &, 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...
 
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 getMuons (const edm::Event &, edm::Handle< RecoMuons > &) const
 Get RECO muons. More...
 
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 matchMuons (TrackRefs::const_iterator &, const edm::Handle< RecoMuons > &) const
 Matches tracks to RECO muons. More...
 
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_
 
edm::InputTag electronIds_
 
edm::InputTag electrons_
 
int jetSplitMerge_
 
edm::InputTag jetTracksAtCalo_
 
edm::InputTag jetTracksAtVertex_
 
const jpt::Map leakage_
 
double maxEta_
 
double muonMass_
 
edm::InputTag muons_
 
jpt::Efficiency not_used {response_, efficiency_, leakage_}
 
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 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< reco::VertexCollectioninput_pvCollection_token_
 
edm::EDGetTokenT< RecoElectronIdsinput_reco_elec_ids_token_
 
edm::EDGetTokenT< RecoElectronsinput_reco_elecs_token_
 
edm::EDGetTokenT< RecoMuonsinut_reco_muons_token_
 

Detailed Description

Jet energy correction algorithm using tracks.

Definition at line 168 of file JetPlusTrackCorrector.h.

Member Typedef Documentation

Definition at line 274 of file JetPlusTrackCorrector.h.

Definition at line 179 of file JetPlusTrackCorrector.h.

Definition at line 180 of file JetPlusTrackCorrector.h.

Definition at line 181 of file JetPlusTrackCorrector.h.

Definition at line 273 of file JetPlusTrackCorrector.h.

Definition at line 272 of file JetPlusTrackCorrector.h.

Get reponses.

Definition at line 271 of file JetPlusTrackCorrector.h.

Definition at line 275 of file JetPlusTrackCorrector.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 22 of file JetPlusTrackCorrector.cc.

References electronIds_, electrons_, edm::ParameterSet::getParameter(), input_jetTracksAtCalo_token_, input_jetTracksAtVertex_token_, input_pvCollection_token_, input_reco_elec_ids_token_, input_reco_elecs_token_, inut_reco_muons_token_, jetSplitMerge_, jetTracksAtCalo_, jetTracksAtVertex_, muons_, srcPVs_, contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, useEff_, useElecs_, useInConeTracks_, useMuons_, useOutOfConeTracks_, useOutOfVertexTracks_, usePions_, useTrackQuality_, vecResponse_, vectorial_, and verbose_.

23  : verbose_(pset.getParameter<bool>("Verbose")),
24  vectorial_(pset.getParameter<bool>("VectorialCorrection")),
25  vecResponse_(pset.getParameter<bool>("UseResponseInVecCorr")),
26  useInConeTracks_(pset.getParameter<bool>("UseInConeTracks")),
27  useOutOfConeTracks_(pset.getParameter<bool>("UseOutOfConeTracks")),
28  useOutOfVertexTracks_(pset.getParameter<bool>("UseOutOfVertexTracks")),
29  usePions_(pset.getParameter<bool>("UsePions")),
30  useEff_(pset.getParameter<bool>("UseEfficiency")),
31  useMuons_(pset.getParameter<bool>("UseMuons")),
32  useElecs_(pset.getParameter<bool>("UseElectrons")),
33  useTrackQuality_(pset.getParameter<bool>("UseTrackQuality")),
34  jetTracksAtVertex_(pset.getParameter<edm::InputTag>("JetTracksAssociationAtVertex")),
35  jetTracksAtCalo_(pset.getParameter<edm::InputTag>("JetTracksAssociationAtCaloFace")),
36  jetSplitMerge_(pset.getParameter<int>("JetSplitMerge")),
37  srcPVs_(pset.getParameter<edm::InputTag>("srcPVs")),
38  ptErrorQuality_(pset.getParameter<double>("PtErrorQuality")),
39  dzVertexCut_(pset.getParameter<double>("DzVertexCut")),
40  muons_(pset.getParameter<edm::InputTag>("Muons")),
41  electrons_(pset.getParameter<edm::InputTag>("Electrons")),
42  electronIds_(pset.getParameter<edm::InputTag>("ElectronIds")),
43  trackQuality_(reco::TrackBase::qualityByName(pset.getParameter<std::string>("TrackQuality"))),
44  response_(Map(pset.getParameter<std::string>("ResponseMap"), verbose_)),
45  efficiency_(Map(pset.getParameter<std::string>("EfficiencyMap"), verbose_)),
46  leakage_(Map(pset.getParameter<std::string>("LeakageMap"), verbose_)),
47  pionMass_(0.140),
48  muonMass_(0.105),
49  elecMass_(0.000511),
50  maxEta_(pset.getParameter<double>("MaxJetEta")) {
51  if (verbose_) {
52  std::stringstream ss;
53  ss << "[JetPlusTrackCorrector::" << __func__ << "] Configuration for JPT corrector: " << std::endl
54  << " Particles" << std::endl
55  << " UsePions : " << (usePions_ ? "true" : "false") << std::endl
56  << " UseMuons : " << (useMuons_ ? "true" : "false") << std::endl
57  << " UseElecs : " << (useElecs_ ? "true" : "false") << std::endl
58  << " Corrections" << std::endl
59  << " UseInConeTracks : " << (useInConeTracks_ ? "true" : "false") << std::endl
60  << " UseOutOfConeTracks : " << (useOutOfConeTracks_ ? "true" : "false") << std::endl
61  << " UseOutOfVertexTracks : " << (useOutOfVertexTracks_ ? "true" : "false") << std::endl
62  << " ResponseMap : " << pset.getParameter<std::string>("ResponseMap") << std::endl
63  << " Efficiency" << std::endl
64  << " UsePionEfficiency : " << (useEff_ ? "true" : "false") << std::endl
65  << " EfficiencyMap : " << pset.getParameter<std::string>("EfficiencyMap") << std::endl
66  << " LeakageMap : " << pset.getParameter<std::string>("LeakageMap") << std::endl
67  << " Tracks" << std::endl
68  << " JetTracksAtVertex : " << jetTracksAtVertex_ << std::endl
69  << " JetTracksAtCalo : " << jetTracksAtCalo_ << std::endl
70  << " JetSplitMerge : " << jetSplitMerge_ << std::endl
71  << " UseTrackQuality : " << (useTrackQuality_ ? "true" : "false") << std::endl
72  << " Collections" << std::endl
73  << " Muons : " << muons_ << std::endl
74  << " Electrons : " << electrons_ << std::endl
75  << " Vectorial" << std::endl
76  << " UseTracksAndResponse : " << ((vectorial_ && vecResponse_) ? "true" : "false") << std::endl
77  << " UseTracksOnly : " << ((vectorial_ && !vecResponse_) ? "true" : "false");
78  edm::LogInfo("JetPlusTrackCorrector") << ss.str();
79  }
80 
82  std::stringstream ss;
83  ss << "[JetPlusTrackCorrector::" << __func__ << "]"
84  << " You are using JPT algorithm in a non-standard way!" << std::endl
85  << " UseInConeTracks : " << (useInConeTracks_ ? "true" : "false") << std::endl
86  << " UseOutOfConeTracks : " << (useOutOfConeTracks_ ? "true" : "false") << std::endl
87  << " UseOutOfVertexTracks : " << (useOutOfVertexTracks_ ? "true" : "false");
88  edm::LogWarning("JetPlusTrackCorrector") << ss.str();
89  }
90 
97 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< RecoMuons > inut_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::ValueMap< float > RecoElectronIds
edm::EDGetTokenT< RecoElectronIds > input_reco_elec_ids_token_
edm::EDGetTokenT< RecoElectrons > input_reco_elecs_token_
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:126
reco::TrackBase::TrackQuality trackQuality_
edm::EDGetTokenT< reco::JetTracksAssociation::Container > input_jetTracksAtCalo_token_
edm::EDGetTokenT< reco::JetTracksAssociation::Container > input_jetTracksAtVertex_token_
reco::MuonCollection RecoMuons
Get reponses.
edm::EDGetTokenT< reco::VertexCollection > input_pvCollection_token_
JetPlusTrackCorrector::~JetPlusTrackCorrector ( )
virtual

Destructor.

Definition at line 101 of file JetPlusTrackCorrector.cc.

101 { ; }
JetPlusTrackCorrector::JetPlusTrackCorrector ( )
inlineprotected

Default constructor.

Definition at line 364 of file JetPlusTrackCorrector.h.

364 { ; }

Member Function Documentation

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 842 of file JetPlusTrackCorrector.cc.

References jpt::Efficiency::addE(), edm::RefVector< C, T, F >::begin(), correction(), edm::RefVector< C, T, F >::empty(), edm::RefVector< C, T, F >::end(), HCALHighEnergyHPDFilter_cfi::energy, PVValHelper::eta, jpt::Map::etaBin(), LEDCalibrationChannels::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, jpt::Map::value(), vecResponse_, vectorial_, and verbose_.

849  {
850  // Correction to be applied to jet 4-momentum
851  P4 correction;
852 
853  /*
854  std::cout<<" >>>>> Jet "<<jet.pt()<<" "<<jet.eta()<<" "<<jet.phi()<<" Number of tracks "<<tracks.size()<<" Pions? "<<is_pion<<" InVert "<<in_cone_at_vertex<<
855  " InCalo "<<in_cone_at_calo_face<<std::endl;
856 
857  std::cout<<" calculateCorr Start::Corrections for jet "<< theResponseOfChargedWithEff <<" "<<
858  theResponseOfChargedWithoutEff <<" "<<
859  theSumPtWithEff <<" "<<
860  theSumPtWithoutEff <<" "<<
861  theSumEnergyWithEff <<" "<<
862  theSumEnergyWithoutEff <<std::endl;
863 */
864 
865  // Reset efficiency container
866  eff.reset();
867 
868  double theSumResp = 0;
869  double theSumPt = 0;
870  double theSumEnergy = 0;
871 
872  // Iterate through tracks
873  if (!tracks.empty()) {
874  TrackRefs::iterator itrk = tracks.begin();
875  TrackRefs::iterator jtrk = tracks.end();
876 
877  for (; itrk != jtrk; ++itrk) {
878  // Ignore high-pt tracks (only when in-cone and not a mip)
879  if (in_cone_at_calo_face && is_pion && (*itrk)->pt() >= 50.) {
880  continue;
881  }
882 
883  // Inner track 4-momentum
884  P4 inner;
885  if (vectorial_ && vecResponse_) {
886  inner = PtEtaPhiM((*itrk)->pt(), (*itrk)->eta(), (*itrk)->phi(), mass);
887  } else {
888  double energy = sqrt((*itrk)->px() * (*itrk)->px() + (*itrk)->py() * (*itrk)->py() +
889  (*itrk)->pz() * (*itrk)->pz() + mass * mass);
890  inner = (jet.energy() > 0. ? energy / jet.energy() : 1.) * jet;
891  }
892 
893  // Add track momentum (if in-cone at vertex)
894  if (in_cone_at_vertex) {
895  correction += inner;
896  }
897 
898  // Find appropriate eta/pt bin for given track
899  double eta = fabs((*itrk)->eta());
900  double pt = fabs((*itrk)->pt());
901  uint32_t ieta = response_.etaBin(eta);
902  uint32_t ipt = response_.ptBin(pt);
903 
904  // Check bins (not for mips)
905  if (is_pion && (ieta == response_.nEtaBins() || ipt == response_.nPtBins())) {
906  continue;
907  }
908 
909  // Outer track 4-momentum
910  P4 outer;
911  if (in_cone_at_calo_face) {
912  if (vectorial_ && vecResponse_) {
913  // Build 4-momentum from outer track (SHOULD USE IMPACT POINT?!)
914  double outer_pt = (*itrk)->pt();
915  double outer_eta = (*itrk)->eta();
916  double outer_phi = (*itrk)->phi();
917  if ((*itrk)->extra().isNonnull()) {
918  outer_pt = (*itrk)->pt();
919  outer_eta = (*itrk)->outerPosition().eta(); //@@ outerMomentum().eta()
920  outer_phi = (*itrk)->outerPosition().phi(); //@@ outerMomentum().phi()
921  }
922  outer = PtEtaPhiM(outer_pt, outer_eta, outer_phi, mass);
923  // Check if mip or not
924  if (!is_pion) {
925  outer *= (outer.energy() > 0. ? mip / outer.energy() : 1.);
926  } //@@ Scale to mip energy
927  else {
928  outer *= (outer.energy() > 0. ? inner.energy() / outer.energy() : 1.);
929  } //@@ Scale to inner track energy
930  } else {
931  // Check if mip or not
932  if (!is_pion) {
933  outer = (jet.energy() > 0. ? mip / jet.energy() : 1.) * jet;
934  } //@@ Jet 4-mom scaled by mip energy
935  else {
936  outer = inner;
937  } //@@ Set to inner track 4-momentum
938  }
939  if (is_pion) {
940  outer *= response_.value(ieta, ipt);
941  } //@@ Scale by pion response
942  correction -= outer; //@@ Subtract
943 
944  // Calculate the sum of responses
945  theSumResp += response_.value(ieta, ipt);
946  }
947 
948  // Calculate the sum of pt and energies
949  theSumPt += inner.pt();
950  theSumEnergy += inner.energy();
951 
952  // Record inner track energy for pion efficiency correction
953  if (is_pion) {
954  eff.addE(ieta, ipt, inner.energy());
955  }
956 
957  // Debug
958  if (verbose_ && edm::isDebugEnabled()) {
959  std::stringstream temp;
960  temp << " Response[" << ieta << "," << ipt << "]";
961  std::stringstream ss;
962  ss << "[JetPlusTrackCorrector::" << __func__ << "]" << std::endl
963  << " Track eta / pt : " << eta << " / " << pt << std::endl
964  << temp.str() << std::setw(21 - temp.str().size()) << " : " << response_.value(ieta, ipt) << std::endl
965  << " Track momentum added : " << inner.energy() << std::endl
966  << " Response subtracted : " << outer.energy() << std::endl
967  << " Energy correction : " << correction.energy();
968  LogDebug("JetPlusTrackCorrector") << ss.str();
969  }
970 
971  } // loop through tracks
972  } // ntracks != 0
973 
974  if (in_cone_at_vertex) {
975  theResponseOfChargedWithEff += theSumResp;
976  theResponseOfChargedWithoutEff += theSumResp;
977  theSumPtWithEff += theSumPt;
978  theSumPtWithoutEff += theSumPt;
979  theSumEnergyWithEff += theSumEnergy;
980  theSumEnergyWithoutEff += theSumEnergy;
981  }
982  /*
983  std::cout<<" calculateCorr End::Corrections for jet "<< theResponseOfChargedWithEff <<" "<<
984  theResponseOfChargedWithoutEff <<" "<<
985  theSumPtWithEff <<" "<<
986  theSumPtWithoutEff <<" "<<
987  theSumEnergyWithEff <<" "<<
988  theSumEnergyWithoutEff <<std::endl;
989 */
990  return correction;
991 }
#define LogDebug(id)
math::XYZTLorentzVector P4
bool isDebugEnabled()
uint32_t nEtaBins() const
void addE(uint32_t eta_bin, uint32_t pt_bin, double energy)
uint32_t etaBin(double eta) const
T sqrt(T t)
Definition: SSEVec.h:19
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)
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 nPtBins() const
uint32_t ptBin(double pt) const
double value(uint32_t eta_bin, uint32_t pt_bin) const
math::PtEtaPhiMLorentzVectorD PtEtaPhiM
bool JetPlusTrackCorrector::canCorrect ( const reco::Jet jet) const
inline

Can jet be JPT-corrected?

Definition at line 447 of file JetPlusTrackCorrector.h.

References reco::LeafCandidate::eta().

Referenced by correction().

447 { return (fabs(jet.eta()) <= maxEta_); }
double eta() const final
momentum pseudorapidity
double JetPlusTrackCorrector::checkScale ( const P4 jet,
P4 corrected 
) const
inlineprotected

Check corrected 4-momentum does not give negative scale.

Definition at line 468 of file JetPlusTrackCorrector.h.

References metsig::jet.

Referenced by correction().

468  {
469  if (jet.energy() > 0. && (corrected.energy() / jet.energy()) < 0.) {
470  corrected = jet;
471  }
472  return corrected.energy() / jet.energy();
473 }
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 1249 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(), LEDCalibrationChannels::ieta, M_PI, jpt::Map::nEtaBins(), jpt::Map::nPtBins(), DiDispStaMuonMonitor_cfi::pt, jpt::Map::ptBin(), multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, response_, mathSSE::sqrt(), and jpt::Map::value().

1255  {
1256  double mScale = 1.;
1257  double NewResponse = fJet.energy();
1258 
1259  //std::cout<<"---JetPlusTrackCorrector::correctAA, Jet initial: NewResponse="<<NewResponse <<" et = "<<fJet.et()
1260  // <<" pt= "<<fJet.pt()<<" eta="<<fJet.eta()<<" phi="<<fJet.phi() <<" ja="<<ja
1261  // <<" trBgOutOfVertex="<<trBgOutOfVertex.size()<< " trBgOutOfCalo="<<trBgOutOfCalo.size()<<std::endl;
1262 
1263  if (trBgOutOfVertex.empty())
1264  return mScale;
1265  double EnergyOfBackgroundCharged = 0.;
1266  double ResponseOfBackgroundCharged = 0.;
1267 
1268  //
1269  // calculate the mean response
1270  //
1271  // double MeanResponseOfBackgroundCharged = 0.;
1272  // double MeanEnergyOfBackgroundCharged = 0.;
1273 
1274  //================= EnergyOfBackgroundCharged ==================>
1275  for (reco::TrackRefVector::iterator iBgtV = trBgOutOfVertex.begin(); iBgtV != trBgOutOfVertex.end(); iBgtV++) {
1276  // Temporary solution>>>>>> Remove tracks with pt>50 GeV
1277  // if( (**iBgtV).pt() >= 50. ) continue;
1278  //response_.value(ieta,ipt);
1279  double eta = fabs((**iBgtV).eta());
1280  double pt = fabs((**iBgtV).pt());
1281  uint32_t ieta = response_.etaBin(eta);
1282  uint32_t ipt = response_.ptBin(pt);
1283 
1284  if (fabs(fJet.eta() - (**iBgtV).eta()) > mConeSize)
1285  continue;
1286 
1287  // // Check bins (not for mips)
1288  // if ( ieta >= response_.nEtaBins() ) { continue; }
1289  // if ( ipt >= response_.nPtBins() ) { ipt = response_.nPtBins() - 1; }
1290 
1291  double echarBg = sqrt((**iBgtV).px() * (**iBgtV).px() + (**iBgtV).py() * (**iBgtV).py() +
1292  (**iBgtV).pz() * (**iBgtV).pz() + 0.14 * 0.14);
1293 
1294  // ResponseOfBackgroundCharged += echarBg*response_.value(ieta,ipt)/efficiency_.value(ieta,ipt);
1295 
1296  // std::cout<<" Efficiency of bg tracks "<<efficiency_.value(ieta,ipt)<<std::endl;
1297 
1298  EnergyOfBackgroundCharged += echarBg / efficiency_.value(ieta, ipt);
1299 
1300  } // Energy BG tracks
1301 
1302  //============= ResponseOfBackgroundCharged =======================>
1303 
1304  for (reco::TrackRefVector::iterator iBgtC = trBgOutOfCalo.begin(); iBgtC != trBgOutOfCalo.end(); iBgtC++) {
1305  // Temporary solution>>>>>> Remove tracks with pt>50 GeV
1306  // if( (**iBgtC).pt() >= 50. ) continue;
1307  //response_.value(ieta,ipt);
1308  double eta = fabs((**iBgtC).eta());
1309  double pt = fabs((**iBgtC).pt());
1310  uint32_t ieta = response_.etaBin(eta);
1311  uint32_t ipt = response_.ptBin(pt);
1312 
1313  if (fabs(fJet.eta() - (**iBgtC).eta()) > mConeSize)
1314  continue;
1315 
1316  // Check bins (not for mips)
1317  if (ieta >= response_.nEtaBins()) {
1318  continue;
1319  }
1320  if (ipt >= response_.nPtBins()) {
1321  ipt = response_.nPtBins() - 1;
1322  }
1323 
1324  double echarBg = sqrt((**iBgtC).px() * (**iBgtC).px() + (**iBgtC).py() * (**iBgtC).py() +
1325  (**iBgtC).pz() * (**iBgtC).pz() + 0.14 * 0.14);
1326 
1327  ResponseOfBackgroundCharged += echarBg * response_.value(ieta, ipt) / efficiency_.value(ieta, ipt);
1328 
1329  // std::cout<<" Efficiency of bg tracks "<<efficiency_.value(ieta,ipt)<<std::endl;
1330 
1331  } // Response of BG tracks
1332 
1333  //=================================================================>
1334 
1335  //=================================================================>
1336  // Look for in-out tracks
1337 
1338  double en = 0.;
1339  double px = 0.;
1340  double py = 0.;
1341  double pz = 0.;
1342 
1343  for (reco::TrackRefVector::const_iterator it = pioninout.begin(); it != pioninout.end(); it++) {
1344  // std::cout<<" Track in out, size= "<<pioninout.size()<<" p= "<<(*it)->p()<<" pt= "<<(*it)->pt()
1345  // <<" eta= "<<(*it)->eta()<<" phi= "<<(*it)->phi()<<std::endl;
1346 
1347  px += (*it)->px();
1348  py += (*it)->py();
1349  pz += (*it)->pz();
1350  en += sqrt((*it)->p() * (*it)->p() + 0.14 * 0.14);
1351  }
1352 
1353  // Look for in-in tracks
1354 
1355  double en_in = 0.;
1356  double px_in = 0.;
1357  double py_in = 0.;
1358  double pz_in = 0.;
1359 
1360  for (reco::TrackRefVector::const_iterator it = pioninin.begin(); it != pioninin.end(); it++) {
1361  // std::cout<<" Track in in, size= "<<pioninin.size()<<" p= "<<(*it)->p()<<" pt= "<<(*it)->pt()
1362  // <<" eta= "<<(*it)->eta()<<" phi= "<<(*it)->phi()<<std::endl;
1363 
1364  px_in += (*it)->px();
1365  py_in += (*it)->py();
1366  pz_in += (*it)->pz();
1367  en_in += sqrt((*it)->p() * (*it)->p() + 0.14 * 0.14);
1368  }
1369 
1370  //===================================================================>
1371 
1372  //=>
1373  // double SquareEtaRingWithoutJets = 4*(M_PI*mConeSize - mConeSize*mConeSize);
1374  double SquareEtaRingWithoutJets = ja;
1375 
1376  // std::cout<<"---SquareEtaRingWithoutJets="<<SquareEtaRingWithoutJets<<std::endl;
1377 
1378  EnergyOfBackgroundCharged = EnergyOfBackgroundCharged / SquareEtaRingWithoutJets;
1379  ResponseOfBackgroundCharged = ResponseOfBackgroundCharged / SquareEtaRingWithoutJets;
1380  // NumberOfBackgroundCharged = NumberOfBackgroundCharged/SquareEtaRingWithoutJets;
1381 
1382  EnergyOfBackgroundCharged = M_PI * mConeSize * mConeSize * EnergyOfBackgroundCharged;
1383  ResponseOfBackgroundCharged = M_PI * mConeSize * mConeSize * ResponseOfBackgroundCharged;
1384  // NumberOfBackgroundCharged = M_PI*mConeSize*mConeSize*NumberOfBackgroundCharged;
1385 
1386  NewResponse = NewResponse - EnergyOfBackgroundCharged + ResponseOfBackgroundCharged;
1387 
1388  // std::cout<<"====JetPlusTrackCorrector, Old response=fJet.energy()"<<fJet.energy()
1389  // <<" EnergyOfBackgroundCharged="<<EnergyOfBackgroundCharged
1390  // <<" ResponseOfBackgroundCharged="<<ResponseOfBackgroundCharged
1391 
1392  mScale = NewResponse / fJet.energy();
1393  if (mScale < 0.)
1394  mScale = 0.;
1395  return mScale;
1396 }
uint32_t nEtaBins() const
double eta() const final
momentum pseudorapidity
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:228
uint32_t etaBin(double eta) const
bool empty() const
Is the RefVector empty.
Definition: RefVector.h:99
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:223
T sqrt(T t)
Definition: SSEVec.h:19
double energy() const final
energy
#define M_PI
uint32_t nPtBins() const
uint32_t ptBin(double pt) const
double value(uint32_t eta_bin, uint32_t pt_bin) const
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 105 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(), PDWG_BPHSkim_cff::muons, reco::LeafCandidate::p4(), reco::LeafCandidate::phi(), pionCorrection(), reco::LeafCandidate::pt(), reco::LeafCandidate::px(), reco::LeafCandidate::py(), reco::LeafCandidate::pz(), Scenarios_cff::scale, contentValuesCheck::ss, theResponseOfChargedWithEff, theResponseOfChargedWithoutEff, theSumEnergyWithEff, theSumEnergyWithoutEff, theSumPtForBeta, theSumPtWithEff, theSumPtWithoutEff, useElecs_, useMuons_, usePions_, vecResponse_, vectorial_, and verbose_.

Referenced by calculateCorr(), and pionEfficiency().

113  {
114  // std::cout<<" JetPlusTrackCorrector::correction "<<std::endl;
115 
118  theSumPtWithEff = 0.;
119  theSumPtWithoutEff = 0.;
120  theSumEnergyWithEff = 0.;
122  theSumPtForBeta = 0.;
123 
124  // Corrected 4-momentum for jet
125  corrected = fJet.p4();
126 
127  // Match tracks to different particle types
128  validMatches = matchTracks(fJetcalo, event, setup, pions, muons, elecs);
129  if (!validMatches) {
130  return 1.;
131  }
132 
133  // Check if jet can be JPT-corrected
134  if (!canCorrect(fJet)) {
135  return 1.;
136  }
137 
138  // std::cout<<" Jet can be corrected "<<std::endl;
139 
140  // std::cout<<" Tracks are matched "<<std::endl;
141 
142  // Debug
143  if (verbose_) {
144  edm::LogInfo("JetPlusTrackCorrector") << "[JetPlusTrackCorrector::" << __func__ << "]"
145  << " Applying JPT corrections...";
146  }
147 
148  // Pion corrections (both scalar and vectorial)
149  if (usePions_) {
150  corrected += pionCorrection(fJet.p4(), pions);
151  }
152 
153  // Muon corrections (both scalar and vectorial)
154  if (useMuons_) {
155  corrected += muonCorrection(fJet.p4(), muons);
156  }
157 
158  // Electrons corrections (both scalar and vectorial)
159  if (useElecs_) {
160  corrected += elecCorrection(fJet.p4(), elecs);
161  }
162 
163  // Define jet direction using total 3-momentum of tracks (overrides above)
164  if (vectorial_ && !vecResponse_) {
165  if (fabs(corrected.eta()) < 2.) {
166  corrected = jetDirFromTracks(corrected, pions, muons, elecs);
167  }
168  }
169 
170  // Check if corrected 4-momentum gives negative scale
171  double scale = checkScale(fJet.p4(), corrected);
172 
173  // Debug
174  if (verbose_) {
175  std::stringstream ss;
176  ss << "Total correction:" << std::endl
177  << std::fixed << std::setprecision(6) << " Uncorrected (Px,Py,Pz,E) : "
178  << "(" << fJet.px() << "," << fJet.py() << "," << fJet.pz() << "," << fJet.energy() << ")" << std::endl
179  << " Corrected (Px,Py,Pz,E) : "
180  << "(" << corrected.px() << "," << corrected.py() << "," << corrected.pz() << "," << corrected.energy() << ")"
181  << std::endl
182  << " Uncorrected (Pt,Eta,Phi,M) : "
183  << "(" << fJet.pt() << "," << fJet.eta() << "," << fJet.phi() << "," << fJet.mass() << ")" << std::endl
184  << " Corrected (Pt,Eta,Phi,M) : "
185  << "(" << corrected.pt() << "," << corrected.eta() << "," << corrected.phi() << "," << corrected.mass() << ")"
186  << std::endl
187  << " Scalar correction to E : " << scale << std::endl
188  << " Scalar correction to Et : " << (fJet.et() > 0. ? corrected.Et() / fJet.et() : 1.); // << std::endl
189  edm::LogVerbatim("JetPlusTrackCorrector") << ss.str();
190  }
191 
192  // std::cout << " mScale= " << scale
193  // << " NewResponse " << corrected.energy()
194  // << " Jet energy " << fJet.energy()
195  // << " event " << event.id().event() << std::endl;
196 
197  /*
198  std::cout<<" Correction::Corrections for jet "<< theResponseOfChargedWithEff <<" "<<
199  theResponseOfChargedWithoutEff <<" "<<
200  theSumPtWithEff <<" "<<
201  theSumPtWithoutEff <<" "<<
202  theSumEnergyWithEff <<" "<<
203  theSumEnergyWithoutEff <<std::endl;
204 */
205 
206  // Return energy correction
207  return scale;
208 }
double eta() const final
momentum pseudorapidity
double px() const final
x coordinate of momentum vector
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.
double pt() const final
transverse momentum
double checkScale(const P4 &jet, P4 &corrected) const
Check corrected 4-momentum does not give negative scale.
P4 pionCorrection(const P4 &jet, const jpt::MatchedTracks &pions)
Calculates corrections to be applied using pions.
bool canCorrect(const reco::Jet &) const
Can jet be JPT-corrected?
double et() const final
transverse energy
double pz() const final
z coordinate of momentum vector
double energy() const final
energy
const LorentzVector & p4() const final
four-momentum Lorentz 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 muonCorrection(const P4 &jet, const jpt::MatchedTracks &muons)
Calculates correction to be applied using muons.
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 phi() const final
momentum azimuthal angle
double mass() const final
mass
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 433 of file JetPlusTrackCorrector.h.

References pfMETCorrectionType0_cfi::correction.

440  {
441  P4 not_used_for_scalar_correction;
442  return correction(fJet, fJetcalo, event, setup, not_used_for_scalar_correction, pions, muons, elecs, validMatches);
443 }
math::XYZTLorentzVector P4
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)
double JetPlusTrackCorrector::correction ( const reco::Jet jet) const

Correction method (not used)

Definition at line 212 of file JetPlusTrackCorrector.cc.

212  {
213  edm::LogError("JetPlusTrackCorrector") << "JetPlusTrackCorrector can be run on entire event only";
214  return 1.;
215 }
double JetPlusTrackCorrector::correction ( const P4 jet) const

Correction method (not used)

Definition at line 219 of file JetPlusTrackCorrector.cc.

219  {
220  edm::LogError("JetPlusTrackCorrector") << "JetPlusTrackCorrector can be run on entire event only";
221  return 1.;
222 }
const jpt::Map & JetPlusTrackCorrector::efficiencyMap ( ) const
inlineprotected

Definition at line 476 of file JetPlusTrackCorrector.h.

Referenced by pionCorrection().

476 { return efficiency_; }
JetPlusTrackCorrector::P4 JetPlusTrackCorrector::elecCorrection ( const P4 jet,
const jpt::MatchedTracks elecs 
) const

Calculates correction to be applied using electrons.

Definition at line 737 of file JetPlusTrackCorrector.cc.

References jpt::MatchedTracks::inVertexInCalo_, jpt::MatchedTracks::inVertexOutOfCalo_, jpt::MatchedTracks::outOfVertexInCalo_, edm::RefVector< C, T, F >::size(), contentValuesCheck::ss, and verbose_.

Referenced by correction().

737  {
738  P4 null; //@@ null 4-momentum
739 
740  if (verbose_) {
741  std::stringstream ss;
742  ss << " Electron corrections:" << std::endl
743  << " In/In : "
744  << "(" << elecs.inVertexInCalo_.size() << ") " << null.energy() << std::endl
745  << " In/Out : "
746  << "(" << elecs.inVertexOutOfCalo_.size() << ") " << null.energy() << std::endl
747  << " Out/In : "
748  << "(" << elecs.outOfVertexInCalo_.size() << ") " << null.energy();
749  edm::LogVerbatim("JetPlusTrackCorrector") << ss.str();
750  }
751 
752  return null; //@@ to be implemented
753 }
math::XYZTLorentzVector P4
reco::TrackRefVector inVertexInCalo_
reco::TrackRefVector inVertexOutOfCalo_
reco::TrackRefVector outOfVertexInCalo_
size_type size() const
Size of the RefVector.
Definition: RefVector.h:102
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 461 of file JetPlusTrackCorrector.h.

464  {
465  return calculateCorr(jet, elecs, not_used, in_cone_at_vertex, in_cone_at_calo_face, elecMass_, false, 0.);
466 }
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.
bool JetPlusTrackCorrector::eventRequired ( ) const
inline

Returns true.

Definition at line 445 of file JetPlusTrackCorrector.h.

445 { return true; }
void JetPlusTrackCorrector::excludeJta ( const reco::Jet fJet,
const JetTracksAssociations jtV0,
TrackRefs included,
const TrackRefs excluded 
) const
protected

Exclude jet-track association.

Definition at line 1215 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(), jetSplitMerge_, edm::RefVector< C, T, F >::push_back(), and PDWG_EXOHSCP_cff::tracks.

Referenced by jtaUsingEventData().

1218  {
1219  //std::cout<<" NEW2" << std::endl;
1220 
1221  tracksthis = reco::JetTracksAssociation::getValue(jtV0, fJet);
1222  if (Excl.empty())
1223  return;
1224  if (jetSplitMerge_ < 0)
1225  return;
1226 
1227  TrackRefs tracks = tracksthis;
1228  tracksthis.clear();
1229 
1230  //std::cout<<" Size of initial vector "<<tracks.size()<<" "<<fJet.et()<<" "<<fJet.eta()<<" "<<fJet.phi()<<std::endl;
1231 
1232  for (TrackRefs::iterator it = tracks.begin(); it != tracks.end(); it++) {
1233  //std::cout<<" Track at calo surface "
1234  //<<" Track "<<(**it).eta()<<" "<<(**it).phi()<<std::endl;
1235  TrackRefs::iterator itold = find(Excl.begin(), Excl.end(), (*it));
1236  if (itold == Excl.end()) {
1237  tracksthis.push_back(*it);
1238  }
1239  //else { std::cout<<"Exclude "<<(**it).eta()<<" "<<(**it).phi()<<std::endl; }
1240  }
1241 
1242  //std::cout<<" Size of calo tracks "<<tracksthis.size()<<std::endl;
1243 
1244  return;
1245 }
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
bool JetPlusTrackCorrector::failTrackQuality ( TrackRefs::const_iterator itrk) const
protected

Check on track quality.

Definition at line 558 of file JetPlusTrackCorrector.cc.

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

Referenced by matchTracks().

558  {
559  // if ( useTrackQuality_ && !(*itrk)->quality(trackQuality_) ) { return true; }
560  // else { return false; }
561 
562  bool retcode = false;
563 
564  if (useTrackQuality_ && !(*itrk)->quality(trackQuality_)) {
565  retcode = true;
566  return retcode;
567  }
568  if (((*itrk)->ptError() / (*itrk)->pt()) > ptErrorQuality_) {
569  retcode = true;
570  return retcode;
571  }
572  if (fabs((*itrk)->dz(vertex_)) > dzVertexCut_) {
573  retcode = true;
574  return retcode;
575  }
576 
577  return retcode;
578 }
reco::Particle::Point vertex_
reco::TrackBase::TrackQuality trackQuality_
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 582 of file JetPlusTrackCorrector.cc.

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

Referenced by matchTracks().

584  {
585  it = find(jet_tracks.caloFace_.begin(), jet_tracks.caloFace_.end(), *itrk);
586  if (it != jet_tracks.caloFace_.end()) {
587  return true;
588  } else {
589  return false;
590  }
591 }
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:228
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:223
reco::TrackRefVector caloFace_
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 595 of file JetPlusTrackCorrector.cc.

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

598  {
599  TrackRefs::iterator ip = find(pions.inVertexInCalo_.begin(), pions.inVertexInCalo_.end(), *itrk);
600  TrackRefs::iterator im = find(muons.inVertexInCalo_.begin(), muons.inVertexInCalo_.end(), *itrk);
601  TrackRefs::iterator ie = find(elecs.inVertexInCalo_.begin(), elecs.inVertexInCalo_.end(), *itrk);
602  if (ip == pions.inVertexInCalo_.end() && im == muons.inVertexInCalo_.end() && ie == elecs.inVertexInCalo_.end()) {
603  return false;
604  } else {
605  return true;
606  }
607 }
reco::TrackRefVector inVertexInCalo_
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:228
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:223
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 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 534 of file JetPlusTrackCorrector.cc.

References electronIds_, electrons_, edm::HandleBase::failedToGet(), input_reco_elec_ids_token_, input_reco_elecs_token_, edm::InputTag::instance(), edm::HandleBase::isValid(), edm::InputTag::label(), and edm::InputTag::process().

Referenced by matchTracks().

536  {
537  event.getByToken(input_reco_elecs_token_, reco_elecs);
538  if (!reco_elecs.isValid() || reco_elecs.failedToGet()) {
539  edm::LogError("JetPlusTrackCorrector") << "[JetPlusTrackCorrector::" << __func__ << "]"
540  << " Invalid handle to reco::GsfElectron collection"
541  << " with InputTag (label:instance:process) \"" << electrons_.label() << ":"
542  << electrons_.instance() << ":" << electrons_.process() << "\"";
543  return false;
544  }
545  event.getByToken(input_reco_elec_ids_token_, reco_elec_ids);
546  if (!reco_elec_ids.isValid() || reco_elec_ids.failedToGet()) {
547  edm::LogError("JetPlusTrackCorrector") << "[JetPlusTrackCorrector::" << __func__ << "]"
548  << " Invalid handle to reco::GsfElectron collection"
549  << " with InputTag (label:instance:process) \"" << electronIds_.label()
550  << ":" << electronIds_.instance() << ":" << electronIds_.process() << "\"";
551  return false;
552  }
553  return true;
554 }
edm::EDGetTokenT< RecoElectronIds > input_reco_elec_ids_token_
edm::EDGetTokenT< RecoElectrons > input_reco_elecs_token_
bool isValid() const
Definition: HandleBase.h:70
bool failedToGet() const
Definition: HandleBase.h:72
std::string const & label() const
Definition: InputTag.h:36
std::string const & process() const
Definition: InputTag.h:40
std::string const & instance() const
Definition: InputTag.h:37
bool JetPlusTrackCorrector::getMuons ( const edm::Event event,
edm::Handle< RecoMuons > &  reco_muons 
) const
protected

Get RECO muons.

Definition at line 349 of file JetPlusTrackCorrector.cc.

References edm::HandleBase::failedToGet(), edm::InputTag::instance(), inut_reco_muons_token_, edm::HandleBase::isValid(), edm::InputTag::label(), muons_, and edm::InputTag::process().

Referenced by matchTracks().

349  {
350  event.getByToken(inut_reco_muons_token_, reco_muons);
351  if (!reco_muons.isValid() || reco_muons.failedToGet()) {
352  edm::LogError("JetPlusTrackCorrector") << "[JetPlusTrackCorrector::" << __func__ << "]"
353  << " Invalid handle to reco::Muon collection"
354  << " with InputTag (label:instance:process) \"" << muons_.label() << ":"
355  << muons_.instance() << ":" << muons_.process() << "\"";
356  return false;
357  }
358  return true;
359 }
edm::EDGetTokenT< RecoMuons > inut_reco_muons_token_
bool isValid() const
Definition: HandleBase.h:70
bool failedToGet() const
Definition: HandleBase.h:72
std::string const & label() const
Definition: InputTag.h:36
std::string const & process() const
Definition: InputTag.h:40
std::string const & instance() const
Definition: InputTag.h:37
double JetPlusTrackCorrector::getResponseOfChargedWithEff ( )
inline

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

Definition at line 231 of file JetPlusTrackCorrector.h.

double JetPlusTrackCorrector::getResponseOfChargedWithoutEff ( )
inline

Definition at line 232 of file JetPlusTrackCorrector.h.

double JetPlusTrackCorrector::getSumEnergyWithEff ( )
inline

Definition at line 235 of file JetPlusTrackCorrector.h.

double JetPlusTrackCorrector::getSumEnergyWithoutEff ( )
inline

Definition at line 236 of file JetPlusTrackCorrector.h.

double JetPlusTrackCorrector::getSumPtForBeta ( )
inline
double JetPlusTrackCorrector::getSumPtWithEff ( )
inline

Definition at line 233 of file JetPlusTrackCorrector.h.

double JetPlusTrackCorrector::getSumPtWithoutEff ( )
inline

Definition at line 234 of file JetPlusTrackCorrector.h.

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 757 of file JetPlusTrackCorrector.cc.

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

Referenced by correction().

760  {
761  // Correction to be applied to jet 4-momentum
762  P4 corr;
763 
764  // bool tracks_present = false;
765  bool tracks_present_inin = false;
766 
767  // Correct using pions in-cone at vertex
768 
769  if (!pions.inVertexInCalo_.empty()) {
771  TrackRefs::iterator jtrk = pions.inVertexInCalo_.end();
772  for (; itrk != jtrk; ++itrk) {
773  corr += PtEtaPhiM((*itrk)->pt(), (*itrk)->eta(), (*itrk)->phi(), 0.);
774  // tracks_present = true;
775  tracks_present_inin = true;
776  }
777  }
778 
779  if (!pions.inVertexOutOfCalo_.empty()) {
782  for (; itrk != jtrk; ++itrk) {
783  corr += PtEtaPhiM((*itrk)->pt(), (*itrk)->eta(), (*itrk)->phi(), 0.);
784  // tracks_present = true;
785  }
786  }
787 
788  // Correct using muons in-cone at vertex
789 
790  if (!muons.inVertexInCalo_.empty()) {
792  TrackRefs::iterator jtrk = muons.inVertexInCalo_.end();
793  for (; itrk != jtrk; ++itrk) {
794  corr += PtEtaPhiM((*itrk)->pt(), (*itrk)->eta(), (*itrk)->phi(), 0.);
795  // tracks_present = true;
796  }
797  }
798 
799  if (!muons.inVertexOutOfCalo_.empty()) {
802  for (; itrk != jtrk; ++itrk) {
803  corr += PtEtaPhiM((*itrk)->pt(), (*itrk)->eta(), (*itrk)->phi(), 0.);
804  // tracks_present = true;
805  }
806  }
807 
808  // Correct using electrons in-cone at vertex
809 
810  if (!elecs.inVertexInCalo_.empty()) {
812  TrackRefs::iterator jtrk = elecs.inVertexInCalo_.end();
813  for (; itrk != jtrk; ++itrk) {
814  corr += PtEtaPhiM((*itrk)->pt(), (*itrk)->eta(), (*itrk)->phi(), 0.);
815  // tracks_present = true;
816  }
817  }
818 
819  if (!elecs.inVertexOutOfCalo_.empty()) {
822  for (; itrk != jtrk; ++itrk) {
823  corr += PtEtaPhiM((*itrk)->pt(), (*itrk)->eta(), (*itrk)->phi(), 0.);
824  // tracks_present = true;
825  }
826  }
827 
828  // Adjust direction if in cone tracks are present
829 
830  if (!tracks_present_inin) {
831  corr = corrected;
832  } else {
833  corr *= (corr.P() > 0. ? corrected.P() / corr.P() : 1.);
834  corr = P4(corr.px(), corr.py(), corr.pz(), corrected.energy());
835  }
836 
837  return corr;
838 }
math::XYZTLorentzVector P4
reco::TrackRefVector inVertexInCalo_
reco::TrackRefVector inVertexOutOfCalo_
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:228
bool empty() const
Is the RefVector empty.
Definition: RefVector.h:99
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:223
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
JetCorrectorParameters corr
Definition: classes.h:5
math::PtEtaPhiMLorentzVectorD PtEtaPhiM
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 259 of file JetPlusTrackCorrector.cc.

References jpt::JetTracks::clear(), edm::InputTag::instance(), jetTracksAtCalo_, jetTracksAtVertex_, jtaUsingEventData(), edm::InputTag::label(), and edm::InputTag::process().

Referenced by matchTracks().

262  {
263  // Some init
264  trks.clear();
265 
266  // Check if labels are given
267  if (!jetTracksAtVertex_.label().empty() && !jetTracksAtCalo_.label().empty()) {
268  //std::cout<<" Try to associate with splitting "<< std::endl;
269 
270  return jtaUsingEventData(fJet, event, trks);
271  } else {
272  edm::LogWarning("PatJPTCorrector") << "[JetPlusTrackCorrector::" << __func__ << "]"
273  << " Empty label for the reco::JetTracksAssociation::Containers" << std::endl
274  << " InputTag for JTA \"at vertex\" (label:instance:process) \""
275  << jetTracksAtVertex_.label() << ":" << jetTracksAtVertex_.instance() << ":"
276  << jetTracksAtVertex_.process() << "\"" << std::endl
277  << " InputTag for JTA \"at calo face\" (label:instance:process) \""
278  << jetTracksAtCalo_.label() << ":" << jetTracksAtCalo_.instance() << ":"
279  << jetTracksAtCalo_.process() << "\"";
280  return false;
281  }
282 }
std::string const & label() const
Definition: InputTag.h:36
std::string const & process() const
Definition: InputTag.h:40
bool jtaUsingEventData(const reco::Jet &, const edm::Event &, jpt::JetTracks &) const
JTA using collections from event.
std::string const & instance() const
Definition: InputTag.h:37
bool JetPlusTrackCorrector::jtaUsingEventData ( const reco::Jet fJet,
const edm::Event event,
jpt::JetTracks trks 
) const
protected

JTA using collections from event.

Definition at line 286 of file JetPlusTrackCorrector.cc.

References jpt::JetTracks::caloFace_, edm::RefVector< C, T, F >::empty(), 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(), verbose_, and jpt::JetTracks::vertex_.

Referenced by jetTrackAssociation().

286  {
287  // Get Jet-track association at Vertex
289  event.getByToken(input_jetTracksAtVertex_token_, jetTracksAtVertex);
290 
291  if (!jetTracksAtVertex.isValid() || jetTracksAtVertex.failedToGet()) {
292  if (verbose_ && edm::isDebugEnabled()) {
293  edm::LogWarning("JetPlusTrackCorrector")
294  << "[JetPlusTrackCorrector::" << __func__ << "]"
295  << " Invalid handle to reco::JetTracksAssociation::Container (for Vertex)"
296  << " with InputTag (label:instance:process) \"" << jetTracksAtVertex_.label() << ":"
297  << jetTracksAtVertex_.instance() << ":" << jetTracksAtVertex_.process() << "\"";
298  }
299  return false;
300  }
301 
302  // std::cout<<" JetPlusTrackCorrector::jtaUsingEventData::here "<<jetSplitMerge_<<std::endl;
303 
304  // Retrieve jet-tracks association for given jet
305  const reco::JetTracksAssociation::Container jtV = *(jetTracksAtVertex.product());
306  TrackRefs excluded;
307  if (jetSplitMerge_ < 0) {
309  } else {
310  rebuildJta(fJet, jtV, trks.vertex_, excluded);
311  }
312 
313  // Check if any tracks are associated to jet at vertex
314  if (trks.vertex_.empty()) {
315  return false;
316  }
317 
318  // Get Jet-track association at Calo
320  event.getByToken(input_jetTracksAtCalo_token_, jetTracksAtCalo);
321 
322  if (!jetTracksAtCalo.isValid() || jetTracksAtCalo.failedToGet()) {
323  if (verbose_ && edm::isDebugEnabled()) {
324  edm::LogWarning("JetPlusTrackCorrector")
325  << "[JetPlusTrackCorrector::" << __func__ << "]"
326  << " Invalid handle to reco::JetTracksAssociation::Container (for CaloFace)"
327  << " with InputTag (label:instance:process) \"" << jetTracksAtCalo_.label() << ":"
328  << jetTracksAtCalo_.instance() << ":" << jetTracksAtCalo_.process() << "\"";
329  }
330  return false;
331  }
332 
333  // Retrieve jet-tracks association for given jet
334  const reco::JetTracksAssociation::Container jtC = *(jetTracksAtCalo.product());
335  if (jetSplitMerge_ < 0) {
337  } else {
338  excludeJta(fJet, jtC, trks.caloFace_, excluded);
339  }
340 
341  // std::cout<<" JTA:Tracks in vertex "<<trks.vertex_.size()<<" in calo "<<trks.caloFace_.size()<<std::endl;
342 
343  // Successful
344  return true;
345 }
bool isDebugEnabled()
reco::TrackRefVector vertex_
bool empty() const
Is the RefVector empty.
Definition: RefVector.h:99
reco::TrackRefVector caloFace_
reco::TrackRefVector TrackRefs
const reco::TrackRefVector & getValue(const Container &, const reco::JetBaseRef &)
get value for the association. Throw exception if no association found
bool isValid() const
Definition: HandleBase.h:70
void rebuildJta(const reco::Jet &, const JetTracksAssociations &, TrackRefs &included, TrackRefs &excluded) const
Rebuild jet-track association.
bool failedToGet() const
Definition: HandleBase.h:72
T const * product() const
Definition: Handle.h:69
void excludeJta(const reco::Jet &, const JetTracksAssociations &, TrackRefs &included, const TrackRefs &excluded) const
Exclude jet-track association.
std::string const & label() const
Definition: InputTag.h:36
std::string const & process() const
Definition: InputTag.h:40
edm::EDGetTokenT< reco::JetTracksAssociation::Container > input_jetTracksAtCalo_token_
edm::EDGetTokenT< reco::JetTracksAssociation::Container > input_jetTracksAtVertex_token_
std::string const & instance() const
Definition: InputTag.h:37
const jpt::Map & JetPlusTrackCorrector::leakageMap ( ) const
inlineprotected

Definition at line 477 of file JetPlusTrackCorrector.h.

Referenced by pionCorrection().

477 { return leakage_; }
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 1099 of file JetPlusTrackCorrector.cc.

References funct::abs(), PbPb_ZMuSkimMuonDPG_cff::deltaR, MillePedeFileConverter_cfg::e, funct::pow(), and mathSSE::sqrt().

Referenced by matchTracks().

1101  {
1102  if (elecs->empty()) {
1103  return false;
1104  }
1105 
1106  double deltaR = 999.;
1107  double deltaRMIN = 999.;
1108 
1109  uint32_t electron_index = 0;
1110  RecoElectrons::const_iterator ielec = elecs->begin();
1111  RecoElectrons::const_iterator jelec = elecs->end();
1112  for (; ielec != jelec; ++ielec) {
1113  edm::Ref<RecoElectrons> electron_ref(elecs, electron_index);
1114  electron_index++;
1115 
1116  if ((*elec_ids)[electron_ref] < 1.e-6) {
1117  continue;
1118  } //@@ Check for null value
1119 
1120  // DR matching b/w electron and track
1121  double deltaphi = fabs(ielec->phi() - (*itrk)->momentum().phi());
1122  if (deltaphi > 6.283185308)
1123  deltaphi -= 6.283185308;
1124  if (deltaphi > 3.141592654)
1125  deltaphi = 6.283185308 - deltaphi;
1126  deltaR = abs(sqrt(pow((ielec->eta() - (*itrk)->momentum().eta()), 2) + pow(deltaphi, 2)));
1127  if (deltaR < deltaRMIN) {
1128  deltaRMIN = deltaR;
1129  }
1130  }
1131 
1132  if (deltaR < 0.02)
1133  return true;
1134  else
1135  return false;
1136 }
T sqrt(T t)
Definition: SSEVec.h:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
bool JetPlusTrackCorrector::matchMuons ( TrackRefs::const_iterator itrk,
const edm::Handle< RecoMuons > &  muons 
) const
protected

Matches tracks to RECO muons.

Definition at line 1067 of file JetPlusTrackCorrector.cc.

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

Referenced by matchTracks().

1067  {
1068  if (muons->empty()) {
1069  return false;
1070  }
1071 
1072  RecoMuons::const_iterator imuon = muons->begin();
1073  RecoMuons::const_iterator jmuon = muons->end();
1074  for (; imuon != jmuon; ++imuon) {
1075  if (imuon->innerTrack().isNull() || !muon::isGoodMuon(*imuon, muon::TMLastStationTight) ||
1076  imuon->innerTrack()->pt() < 3.0) {
1077  continue;
1078  }
1079 
1080  if (itrk->id() != imuon->innerTrack().id()) {
1081  edm::LogError("JetPlusTrackCorrector") << "[JetPlusTrackCorrector::" << __func__ << "]"
1082  << "Product id of the tracks associated to the jet " << itrk->id()
1083  << " is different from the product id of the inner track used for muons "
1084  << imuon->innerTrack().id() << "!" << std::endl
1085  << "Cannot compare tracks from different collection. Configuration Error!";
1086  return false;
1087  }
1088 
1089  if (*itrk == imuon->innerTrack()) {
1090  return true;
1091  }
1092  }
1093 
1094  return false;
1095 }
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
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 226 of file JetPlusTrackCorrector.cc.

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

Referenced by correction(), and matchTracks().

231  {
232  // Associate tracks to jet at both the Vertex and CaloFace
233  JetTracks jet_tracks;
234  bool ok = jetTrackAssociation(fJet, event, setup, jet_tracks);
235 
236  // std::cout<<"JetPlusTrackCorrector::matchTracks, JetTrackAssociation ok="<<ok<<std::endl;
237 
238  if (!ok) {
239  return false;
240  }
241 
242  // Track collections propagated to Vertex and CaloFace for "pions", muons and electrons
243  matchTracks(jet_tracks, event, pions, muons, elecs);
244 
245  // Debug
246  if (verbose_) {
247  std::stringstream ss;
248  ss << "Number of tracks:" << std::endl
249  << " In-cone at Vertex : " << jet_tracks.vertex_.size() << std::endl
250  << " In-cone at CaloFace : " << jet_tracks.caloFace_.size();
251  edm::LogVerbatim("JetPlusTrackCorrector") << ss.str();
252  }
253 
254  return true;
255 }
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_
reco::TrackRefVector caloFace_
Tracks associated to jets that are in-cone at Vertex and CaloFace.
size_type size() const
Size of the RefVector.
Definition: RefVector.h:102
virtual bool jetTrackAssociation(const reco::Jet &, const edm::Event &, const edm::EventSetup &, jpt::JetTracks &) const
Associates tracks to jets (overriden in derived class)
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 363 of file JetPlusTrackCorrector.cc.

References edm::RefVector< C, T, F >::begin(), jpt::JetTracks::caloFace_, jpt::MatchedTracks::clear(), 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(), edm::HandleBase::isValid(), LogTrace, matchElectrons(), matchMuons(), jpt::MatchedTracks::outOfVertexInCalo_, edm::RefVector< C, T, F >::push_back(), anotherprimaryvertexanalyzer_cfi::pvCollection, findQualityFiles::rr, edm::RefVector< C, T, F >::size(), contentValuesCheck::ss, theSumPtForBeta, trackQuality_, tracksInCalo(), useElecs_, useMuons_, useTrackQuality_, verbose_, jpt::JetTracks::vertex_, and vertex_.

367  {
368  // Some init
369  pions.clear();
370  muons.clear();
371  elecs.clear();
372 
373  // Need vertex for track cleaning
374 
375  vertex_ = reco::Particle::Point(0, 0, 0);
377  event.getByToken(input_pvCollection_token_, pvCollection);
378  if (pvCollection.isValid() && !pvCollection->empty())
379  vertex_ = pvCollection->begin()->position();
380 
381  // Get RECO muons
382  edm::Handle<RecoMuons> reco_muons;
383  bool found_reco_muons = true;
384  if (useMuons_) {
385  getMuons(event, reco_muons);
386  }
387 
388  // Get RECO electrons and their ids
389  edm::Handle<RecoElectrons> reco_elecs;
390  edm::Handle<RecoElectronIds> reco_elec_ids;
391  bool found_reco_elecs = true;
392  if (useElecs_) {
393  getElectrons(event, reco_elecs, reco_elec_ids);
394  }
395 
396  // Check RECO products found
397  if (!found_reco_muons || !found_reco_elecs) {
398  edm::LogError("JetPlusTrackCorrector") << "[JetPlusTrackCorrector::" << __func__ << "]"
399  << " Unable to access RECO collections for muons and electrons";
400  return;
401  }
402 
403  // Identify pions/muons/electrons that are "in/in" and "in/out"
404  {
405  TrackRefs::const_iterator itrk = jet_tracks.vertex_.begin();
406  TrackRefs::const_iterator jtrk = jet_tracks.vertex_.end();
407 
408  // std::cout<<" Print theSumPtForBeta "<<theSumPtForBeta<<std::endl;
409 
410  double theSumPtForBetaOld = theSumPtForBeta;
411 
412  for (; itrk != jtrk; ++itrk) {
413  if (useTrackQuality_ && (*itrk)->quality(trackQuality_) && theSumPtForBetaOld <= 0.)
414  theSumPtForBeta += (**itrk).pt();
415  //
416  // Track either belongs to PV or do not belong to any vertex
417 
418  const reco::TrackBaseRef ttr1(*itrk);
419 
420  // std::cout<<" Size of PV "<<pvCollection->size()<<std::endl;
421 
422  int numpv = 0;
423 
424  int itrack_belong = -1;
425 
426  for (reco::VertexCollection::const_iterator iv = pvCollection->begin(); iv != pvCollection->end(); iv++) {
427  numpv++;
428  std::vector<reco::TrackBaseRef>::const_iterator rr = find((*iv).tracks_begin(), (*iv).tracks_end(), ttr1);
429  if (rr != (*iv).tracks_end()) {
430  itrack_belong++;
431  // std::cout<<" Numpv "<<numpv<<std::endl;
432  break;
433  }
434 
435  } // all vertices
436 
437  // std::cout<<" Track in PV "<<itrack_belong<<" "<<numpv<<std::endl;
438 
439  if (numpv > 1 && itrack_belong == 0) {
440  // std::cout<<" Drop track "<<std::endl;
441  continue;
442  }
443 
444  // std::cout<<" we take it "<<numpv<<" "<<itrack_belong<<std::endl;
445 
446  if (failTrackQuality(itrk)) {
447  continue;
448  }
449 
450  // std::cout<<" Track accepted "<<std::endl;
451 
452  TrackRefs::iterator it = jet_tracks.caloFace_.end();
453  bool found = findTrack(jet_tracks, itrk, it);
454 
455  // std::cout<<"JetPlusTrackCorrector::matchTracks: jet_tracks.caloFace_.size()="<<jet_tracks.caloFace_.size()
456  // <<" found = "<<found<<std::endl;
457 
458  bool is_muon = useMuons_ && matchMuons(itrk, reco_muons);
459  bool is_ele = useElecs_ && matchElectrons(itrk, reco_elecs, reco_elec_ids);
460 
461  if (found) {
462  if (is_muon) {
463  muons.inVertexInCalo_.push_back(*it);
464  } else if (is_ele) {
465  elecs.inVertexInCalo_.push_back(*it);
466  } else {
467  pions.inVertexInCalo_.push_back(*it);
468  }
469  } else {
470  if (is_muon) {
471  muons.inVertexOutOfCalo_.push_back(*itrk);
472  } else if (is_ele) {
473  elecs.inVertexOutOfCalo_.push_back(*itrk);
474  } else {
475  pions.inVertexOutOfCalo_.push_back(*itrk);
476  // std::cout<<"JetPlusTrackCorrector::matchTracks: pions.inVertexOutOfCalo_.push_back(*itrk), size="
477  // <<pions.inVertexOutOfCalo_.size() <<std::endl;
478  }
479  }
480  }
481  }
482 
483  // Identify pions/muons/electrons that are "out/in"
484  {
485  TrackRefs::iterator itrk = jet_tracks.caloFace_.begin();
486  TrackRefs::iterator jtrk = jet_tracks.caloFace_.end();
487  for (; itrk != jtrk; ++itrk) {
488  if (failTrackQuality(itrk)) {
489  continue;
490  }
491 
492  if (!tracksInCalo(pions, muons, elecs)) {
493  continue;
494  }
495 
496  bool found = findTrack(pions, muons, elecs, itrk);
497 
498  if (!found) {
499  bool is_muon = useMuons_ && matchMuons(itrk, reco_muons);
500  bool is_ele = useElecs_ && matchElectrons(itrk, reco_elecs, reco_elec_ids);
501 
502  if (is_muon) {
503  muons.outOfVertexInCalo_.push_back(*itrk);
504  } else if (is_ele) {
505  elecs.outOfVertexInCalo_.push_back(*itrk);
506  } else {
507  pions.outOfVertexInCalo_.push_back(*itrk);
508  }
509  }
510  }
511  }
512 
513  if (verbose_ && edm::isDebugEnabled()) {
514  std::stringstream ss;
515  ss << "[JetPlusTrackCorrector::" << __func__ << "] Number of tracks:" << std::endl
516  << " In-cone at Vertex and in-cone at CaloFace:" << std::endl
517  << " Pions : " << pions.inVertexInCalo_.size() << std::endl
518  << " Muons : " << muons.inVertexInCalo_.size() << std::endl
519  << " Electrons : " << elecs.inVertexInCalo_.size() << std::endl
520  << " In-cone at Vertex and out-of-cone at CaloFace:" << std::endl
521  << " Pions : " << pions.inVertexOutOfCalo_.size() << std::endl
522  << " Muons : " << muons.inVertexOutOfCalo_.size() << std::endl
523  << " Electrons : " << elecs.inVertexOutOfCalo_.size() << std::endl
524  << " Out-of-cone at Vertex and in-cone at CaloFace:" << std::endl
525  << " Pions : " << pions.outOfVertexInCalo_.size() << std::endl
526  << " Muons : " << muons.outOfVertexInCalo_.size() << std::endl
527  << " Electrons : " << elecs.outOfVertexInCalo_.size() << std::endl;
528  LogTrace("JetPlusTrackCorrector") << ss.str();
529  }
530 }
bool isDebugEnabled()
reco::TrackRefVector inVertexInCalo_
reco::TrackRefVector vertex_
reco::TrackRefVector inVertexOutOfCalo_
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:228
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:223
bool tracksInCalo(const jpt::MatchedTracks &pions, const jpt::MatchedTracks &muons, const jpt::MatchedTracks &elecs) const
Determines if any tracks in cone at CaloFace.
reco::Particle::Point vertex_
reco::TrackRefVector caloFace_
bool findTrack(const jpt::JetTracks &, TrackRefs::const_iterator &, TrackRefs::iterator &) const
Find track in JetTracks collection.
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.
bool failTrackQuality(TrackRefs::const_iterator &) const
Check on track quality.
bool isValid() const
Definition: HandleBase.h:70
#define LogTrace(id)
bool getMuons(const edm::Event &, edm::Handle< RecoMuons > &) const
Get RECO muons.
bool getElectrons(const edm::Event &, edm::Handle< RecoElectrons > &, edm::Handle< RecoElectronIds > &) const
Get RECO electrons.
reco::TrackBase::TrackQuality trackQuality_
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:67
size_type size() const
Size of the RefVector.
Definition: RefVector.h:102
edm::EDGetTokenT< reco::VertexCollection > input_pvCollection_token_
bool matchElectrons(TrackRefs::const_iterator &, const edm::Handle< RecoElectrons > &, const edm::Handle< RecoElectronIds > &) const
Matches tracks to RECO electrons.
JetPlusTrackCorrector::P4 JetPlusTrackCorrector::muonCorrection ( const P4 jet,
const jpt::MatchedTracks muons 
)

Calculates correction to be applied using muons.

Definition at line 698 of file JetPlusTrackCorrector.cc.

References jpt::MatchedTracks::inVertexInCalo_, jpt::MatchedTracks::inVertexOutOfCalo_, jpt::MatchedTracks::outOfVertexInCalo_, edm::RefVector< C, T, F >::size(), contentValuesCheck::ss, useInConeTracks_, useOutOfConeTracks_, useOutOfVertexTracks_, and verbose_.

Referenced by correction().

698  {
699  P4 corr_muons;
700 
701  P4 corr_muons_in_cone;
702  P4 corr_muons_out_of_cone;
703  P4 corr_muons_out_of_vertex;
704 
705  if (useInConeTracks_) {
706  corr_muons_in_cone = muonCorrection(jet, muons.inVertexInCalo_, true, true);
707  corr_muons += corr_muons_in_cone;
708  }
709 
710  if (useOutOfConeTracks_) {
711  corr_muons_out_of_cone = muonCorrection(jet, muons.inVertexOutOfCalo_, true, false);
712  corr_muons += corr_muons_out_of_cone;
713  }
714 
715  if (useOutOfVertexTracks_) {
716  corr_muons_out_of_vertex = muonCorrection(jet, muons.outOfVertexInCalo_, false, true);
717  corr_muons += corr_muons_out_of_vertex;
718  }
719 
720  if (verbose_) {
721  std::stringstream ss;
722  ss << " Muon corrections:" << std::endl
723  << " In/In : "
724  << "(" << muons.inVertexInCalo_.size() << ") " << corr_muons_in_cone.energy() << std::endl
725  << " In/Out : "
726  << "(" << muons.inVertexOutOfCalo_.size() << ") " << corr_muons_out_of_cone.energy() << std::endl
727  << " Out/In : "
728  << "(" << muons.outOfVertexInCalo_.size() << ") " << corr_muons_out_of_vertex.energy();
729  edm::LogVerbatim("JetPlusTrackCorrector") << ss.str();
730  }
731 
732  return corr_muons;
733 }
math::XYZTLorentzVector P4
reco::TrackRefVector inVertexInCalo_
reco::TrackRefVector inVertexOutOfCalo_
reco::TrackRefVector outOfVertexInCalo_
P4 muonCorrection(const P4 &jet, const jpt::MatchedTracks &muons)
Calculates correction to be applied using muons.
size_type size() const
Size of the RefVector.
Definition: RefVector.h:102
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 454 of file JetPlusTrackCorrector.h.

457  {
458  return calculateCorr(jet, muons, not_used, in_cone_at_vertex, in_cone_at_calo_face, muonMass_, false, 2.);
459 }
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.
JetPlusTrackCorrector::P4 JetPlusTrackCorrector::pionCorrection ( const P4 jet,
const jpt::MatchedTracks pions 
)

Calculates corrections to be applied using pions.

Definition at line 623 of file JetPlusTrackCorrector.cc.

References efficiencyMap(), jpt::MatchedTracks::inVertexInCalo_, jpt::MatchedTracks::inVertexOutOfCalo_, 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().

623  {
624  P4 corr_pions;
625  /*
626  std::cout<<" pionCorrection::Corrections for jet "<< theResponseOfChargedWithEff <<" "<<
627  theResponseOfChargedWithoutEff <<" "<<
628  theSumPtWithEff <<" "<<
629  theSumPtWithoutEff <<" "<<
630  theSumEnergyWithEff <<" "<<
631  theSumEnergyWithoutEff <<std::endl;
632 */
633 
634  // In-cone
635 
636  P4 corr_pions_in_cone;
637  P4 corr_pions_eff_in_cone;
639 
640  if (useInConeTracks_) {
641  corr_pions_in_cone = pionCorrection(jet, pions.inVertexInCalo_, in_cone, true, true);
642  corr_pions += corr_pions_in_cone;
643  if (useEff_) {
644  corr_pions_eff_in_cone = pionEfficiency(jet, in_cone, true);
645  corr_pions += corr_pions_eff_in_cone;
646  }
647  }
648 
649  // Out-of-cone
650 
651  P4 corr_pions_out_of_cone;
652  P4 corr_pions_eff_out_of_cone;
653  Efficiency out_of_cone(responseMap(), efficiencyMap(), leakageMap());
654 
655  if (useOutOfConeTracks_) {
656  corr_pions_out_of_cone = pionCorrection(jet, pions.inVertexOutOfCalo_, out_of_cone, true, false);
657  corr_pions += corr_pions_out_of_cone;
658  if (useEff_) {
659  corr_pions_eff_out_of_cone = pionEfficiency(jet, out_of_cone, false);
660  corr_pions += corr_pions_eff_out_of_cone;
661  }
662  }
663 
664  // Out-of-vertex
665 
666  P4 corr_pions_out_of_vertex;
668 
669  if (useOutOfVertexTracks_) {
670  corr_pions_out_of_vertex = pionCorrection(jet, pions.outOfVertexInCalo_, not_used, false, true);
671  corr_pions += corr_pions_out_of_vertex;
672  }
673 
674  if (verbose_) {
675  std::stringstream ss;
676  ss << " Pion corrections:" << std::endl
677  << " In/In : "
678  << "(" << pions.inVertexInCalo_.size() << ") " << corr_pions_in_cone.energy() << std::endl
679  << " In/Out : "
680  << "(" << pions.inVertexOutOfCalo_.size() << ") " << corr_pions_out_of_cone.energy() << std::endl
681  << " Out/In : "
682  << "(" << pions.outOfVertexInCalo_.size() << ") " << corr_pions_out_of_vertex.energy() << std::endl;
683  if (useEff_) {
684  ss << " Pion efficiency corrections:" << std::endl
685  << " In/In : "
686  << "(" << pions.inVertexInCalo_.size() << ") " << corr_pions_eff_in_cone.energy() << std::endl
687  << " In/Out : "
688  << "(" << pions.inVertexOutOfCalo_.size() << ") " << corr_pions_eff_out_of_cone.energy();
689  }
690  edm::LogVerbatim("JetPlusTrackCorrector") << ss.str();
691  }
692 
693  return corr_pions;
694 }
math::XYZTLorentzVector P4
const jpt::Map & responseMap() const
reco::TrackRefVector inVertexInCalo_
reco::TrackRefVector inVertexOutOfCalo_
P4 pionCorrection(const P4 &jet, const jpt::MatchedTracks &pions)
Calculates corrections to be applied using pions.
const jpt::Map & efficiencyMap() const
const jpt::Map & leakageMap() 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.
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 449 of file JetPlusTrackCorrector.h.

450  {
451  return calculateCorr(jet, pions, eff, in_cone_at_vertex, in_cone_at_calo_face, pionMass_, true, -1.);
452 }
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.
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 995 of file JetPlusTrackCorrector.cc.

References jpt::Map::binCenterEta(), jpt::Map::binCenterPt(), corr, correction(), LEDCalibrationChannels::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().

997  {
998  // Total correction to be applied
999  P4 correction;
1000 
1001  double theSumResp = 0;
1002  double theSumPt = 0;
1003  double theSumEnergy = 0;
1004 
1005  // Iterate through eta/pt bins
1006  for (uint32_t ieta = 0; ieta < response_.nEtaBins() - 1; ++ieta) {
1007  for (uint32_t ipt = 0; ipt < response_.nPtBins() - 1; ++ipt) {
1008  // Check tracks are found in this eta/pt bin
1009  if (!eff.nTrks(ieta, ipt)) {
1010  continue;
1011  }
1012 
1013  for (uint16_t ii = 0; ii < 2; ++ii) {
1014  // Check which correction should be applied
1015  double corr = 0.;
1016  if (ii == 0) {
1017  corr = eff.outOfConeCorr(ieta, ipt);
1018  } else if (ii == 1 && in_cone_at_calo_face) {
1019  corr = eff.inConeCorr(ieta, ipt);
1020  } else {
1021  continue;
1022  }
1023 
1024  // Calculate correction to be applied
1025  P4 corr_p4;
1026  if (vectorial_ && vecResponse_) {
1027  double corr_eta = response_.binCenterEta(ieta);
1028  double corr_phi = jet.phi(); //@@ jet phi!
1029  double corr_pt = response_.binCenterPt(ipt);
1030  corr_p4 =
1031  PtEtaPhiM(corr_pt, corr_eta, corr_phi, pionMass_); //@@ E^2 = p^2 + m_pion^2, |p| calc'ed from pt bin
1032  corr_p4 *= (corr_p4.energy() > 0. ? corr / corr_p4.energy() : 1.); //@@ p4 scaled up by mean energy for bin
1033  } else {
1034  corr_p4 = (jet.energy() > 0. ? corr / jet.energy() : 1.) * jet;
1035  }
1036 
1037  // Apply correction
1038  if (ii == 0) {
1039  correction += corr_p4;
1040  theSumPt += corr_p4.pt();
1041  theSumEnergy += corr_p4.energy();
1042  } //@@ Add out-of-cone
1043  else if (ii == 1) {
1044  correction -= corr_p4;
1045  theSumResp += corr_p4.energy();
1046  } //@@ Subtract in-cone
1047  }
1048  }
1049  }
1050 
1051  theResponseOfChargedWithEff += theSumResp;
1052  theSumPtWithEff += theSumPt;
1053  theSumEnergyWithEff += theSumEnergy;
1054  /*
1055  std::cout<<" Efficiency correction End::Corrections for jet "<< theResponseOfChargedWithEff <<" "<<
1056  theResponseOfChargedWithoutEff <<" "<<
1057  theSumPtWithEff <<" "<<
1058  theSumPtWithoutEff <<" "<<
1059  theSumEnergyWithEff <<" "<<
1060  theSumEnergyWithoutEff <<std::endl;
1061 */
1062  return correction;
1063 }
math::XYZTLorentzVector P4
uint32_t nEtaBins() const
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)
double binCenterPt(uint32_t) const
double outOfConeCorr(uint32_t eta_bin, uint32_t pt_bin) const
double inConeCorr(uint32_t eta_bin, uint32_t pt_bin) const
JetCorrectorParameters corr
Definition: classes.h:5
ii
Definition: cuy.py:590
uint16_t nTrks(uint32_t eta_bin, uint32_t pt_bin) const
uint32_t nPtBins() const
double binCenterEta(uint32_t) const
math::PtEtaPhiMLorentzVectorD PtEtaPhiM
void JetPlusTrackCorrector::rebuildJta ( const reco::Jet fJet,
const JetTracksAssociations jtV0,
TrackRefs included,
TrackRefs excluded 
) const
protected

Rebuild jet-track association.

Definition at line 1140 of file JetPlusTrackCorrector.cc.

References reco::JetTracksAssociation::allJets(), edm::RefVector< C, T, F >::begin(), edm::RefVector< C, T, F >::clear(), HLTMuonOfflineAnalyzer_cfi::deltaR2, edm::RefVector< C, T, F >::end(), reco::LeafCandidate::et(), reco::LeafCandidate::eta(), RemoveAddSevLevel::flag, reco::JetTracksAssociation::getValue(), cuy::ii, reco::btau::jetEta, reco::btau::jetPhi, jetSplitMerge_, reco::LeafCandidate::phi(), edm::RefVector< C, T, F >::push_back(), Scenarios_cff::scale, and PDWG_EXOHSCP_cff::tracks.

Referenced by jtaUsingEventData().

1143  {
1144  // std::cout<<" NEW1 Merge/Split schema "<<jetSplitMerge_<<std::endl;
1145 
1146  tracksthis = reco::JetTracksAssociation::getValue(jtV0, fJet);
1147 
1148  if (jetSplitMerge_ < 0)
1149  return;
1150 
1151  typedef std::vector<reco::JetBaseRef>::iterator JetBaseRefIterator;
1152  std::vector<reco::JetBaseRef> theJets = reco::JetTracksAssociation::allJets(jtV0);
1153 
1154  TrackRefs tracks = tracksthis;
1155  tracksthis.clear();
1156 
1157  // std::cout<<" Size of initial vector "<<tracks.size()<<" "<<fJet.et()<<" "<<fJet.eta()<<" "<<fJet.phi()<<std::endl;
1158 
1159  int tr = 0;
1160 
1161  double jetEta = fJet.eta();
1162  double jetPhi = fJet.phi();
1163  double jetEtIn = 1.0 / fJet.et();
1164 
1165  for (TrackRefs::iterator it = tracks.begin(); it != tracks.end(); it++) {
1166  double trkEta = (**it).eta();
1167  double trkPhi = (**it).phi();
1168  double dR2this = deltaR2(jetEta, jetPhi, trkEta, trkPhi);
1169  // double dfi = fabs(fJet.phi()-(**it).phi());
1170  // if(dfi>4.*atan(1.))dfi = 8.*atan(1.)-dfi;
1171  // double deta = fJet.eta() - (**it).eta();
1172  // double dR2check = sqrt(dfi*dfi+deta*deta);
1173 
1174  double scalethis = dR2this;
1175  if (jetSplitMerge_ == 0)
1176  scalethis = 1. * jetEtIn;
1177  if (jetSplitMerge_ == 2)
1178  scalethis = dR2this * jetEtIn;
1179  tr++;
1180  int flag = 1;
1181  for (JetBaseRefIterator ii = theJets.begin(); ii != theJets.end(); ii++) {
1182  if (&(**ii) == &fJet) {
1183  continue;
1184  }
1185  double dR2 = deltaR2((*ii)->eta(), (*ii)->phi(), trkEta, trkPhi);
1186  double scale = dR2;
1187  if (jetSplitMerge_ == 0)
1188  scale = 1. / (**ii).et();
1189  if (jetSplitMerge_ == 2)
1190  scale = dR2 / (**ii).et();
1191  if (scale < scalethis)
1192  flag = 0;
1193 
1194  if (flag == 0) {
1195  //std::cout<<" Track belong to another jet also "<<dR2<<" "<<
1196  //(*ii)->et()<<" "<<(*ii)->eta()<<" "<< (*ii)->phi()<<" Track "<<(**it).eta()<<" "<<(**it).phi()<<" "<<scalethis<<" "<<scale<<" "<<flag<<std::endl;
1197  break;
1198  }
1199  }
1200 
1201  //std::cout<<" Track "<<tr<<" "<<flag<<" "<<dR2this<<" "<<dR2check<<" Jet "<<fJet.eta()<<" "<< fJet.phi()<<" Track "<<(**it).eta()<<" "<<(**it).phi()<<std::endl;
1202  if (flag == 1) {
1203  tracksthis.push_back(*it);
1204  } else {
1205  Excl.push_back(*it);
1206  }
1207  }
1208 
1209  //std::cout<<" The new size of tracks "<<tracksthis.size()<<" Excludede "<<Excl.size()<<std::endl;
1210  return;
1211 }
double eta() const final
momentum pseudorapidity
double et() const final
transverse energy
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:590
std::vector< reco::JetBaseRef > allJets(const Container &)
fill list of all jets associated with values. Return # of jets in the list
double phi() const final
momentum azimuthal angle
const jpt::Map & JetPlusTrackCorrector::responseMap ( ) const
inlineprotected

Definition at line 475 of file JetPlusTrackCorrector.h.

Referenced by pionCorrection().

475 { return response_; }
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 611 of file JetPlusTrackCorrector.cc.

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

Referenced by matchTracks().

613  {
614  if (!pions.inVertexInCalo_.empty() || !muons.inVertexInCalo_.empty() || !elecs.inVertexInCalo_.empty()) {
615  return true;
616  } else {
617  return false;
618  }
619 }
reco::TrackRefVector inVertexInCalo_
bool empty() const
Is the RefVector empty.
Definition: RefVector.h:99
bool JetPlusTrackCorrector::vectorialCorrection ( ) const
inline

Returns value of configurable.

Definition at line 446 of file JetPlusTrackCorrector.h.

Member Data Documentation

double JetPlusTrackCorrector::dzVertexCut_
protected

Definition at line 388 of file JetPlusTrackCorrector.h.

Referenced by failTrackQuality().

const jpt::Map JetPlusTrackCorrector::efficiency_
protected

Definition at line 401 of file JetPlusTrackCorrector.h.

Referenced by correctAA().

double JetPlusTrackCorrector::elecMass_
protected

Definition at line 407 of file JetPlusTrackCorrector.h.

edm::InputTag JetPlusTrackCorrector::electronIds_
protected

Definition at line 394 of file JetPlusTrackCorrector.h.

Referenced by getElectrons(), and JetPlusTrackCorrector().

edm::InputTag JetPlusTrackCorrector::electrons_
protected

Definition at line 393 of file JetPlusTrackCorrector.h.

Referenced by getElectrons(), and JetPlusTrackCorrector().

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

Definition at line 424 of file JetPlusTrackCorrector.h.

Referenced by JetPlusTrackCorrector(), and jtaUsingEventData().

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

Definition at line 423 of file JetPlusTrackCorrector.h.

Referenced by JetPlusTrackCorrector(), and jtaUsingEventData().

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

Definition at line 426 of file JetPlusTrackCorrector.h.

Referenced by JetPlusTrackCorrector(), and matchTracks().

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

Definition at line 428 of file JetPlusTrackCorrector.h.

Referenced by getElectrons(), and JetPlusTrackCorrector().

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

Definition at line 427 of file JetPlusTrackCorrector.h.

Referenced by getElectrons(), and JetPlusTrackCorrector().

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

Definition at line 425 of file JetPlusTrackCorrector.h.

Referenced by getMuons(), and JetPlusTrackCorrector().

int JetPlusTrackCorrector::jetSplitMerge_
protected
edm::InputTag JetPlusTrackCorrector::jetTracksAtCalo_
protected
edm::InputTag JetPlusTrackCorrector::jetTracksAtVertex_
protected
const jpt::Map JetPlusTrackCorrector::leakage_
protected

Definition at line 402 of file JetPlusTrackCorrector.h.

double JetPlusTrackCorrector::maxEta_
protected

Definition at line 410 of file JetPlusTrackCorrector.h.

double JetPlusTrackCorrector::muonMass_
protected

Definition at line 406 of file JetPlusTrackCorrector.h.

edm::InputTag JetPlusTrackCorrector::muons_
protected

Definition at line 392 of file JetPlusTrackCorrector.h.

Referenced by getMuons(), and JetPlusTrackCorrector().

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

Definition at line 418 of file JetPlusTrackCorrector.h.

Referenced by pionCorrection().

double JetPlusTrackCorrector::pionMass_
protected

Definition at line 405 of file JetPlusTrackCorrector.h.

Referenced by pionEfficiency().

double JetPlusTrackCorrector::ptErrorQuality_
protected

Definition at line 387 of file JetPlusTrackCorrector.h.

Referenced by failTrackQuality().

const jpt::Map JetPlusTrackCorrector::response_
protected

Definition at line 400 of file JetPlusTrackCorrector.h.

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

edm::InputTag JetPlusTrackCorrector::srcPVs_
protected

Definition at line 386 of file JetPlusTrackCorrector.h.

Referenced by JetPlusTrackCorrector().

float JetPlusTrackCorrector::theResponseOfChargedWithEff
protected

Definition at line 411 of file JetPlusTrackCorrector.h.

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

float JetPlusTrackCorrector::theResponseOfChargedWithoutEff
protected

Definition at line 412 of file JetPlusTrackCorrector.h.

Referenced by calculateCorr(), and correction().

float JetPlusTrackCorrector::theSumEnergyWithEff
protected

Definition at line 415 of file JetPlusTrackCorrector.h.

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

float JetPlusTrackCorrector::theSumEnergyWithoutEff
protected

Definition at line 416 of file JetPlusTrackCorrector.h.

Referenced by calculateCorr(), and correction().

float JetPlusTrackCorrector::theSumPtForBeta
protected

Definition at line 417 of file JetPlusTrackCorrector.h.

Referenced by correction(), and matchTracks().

float JetPlusTrackCorrector::theSumPtWithEff
protected

Definition at line 413 of file JetPlusTrackCorrector.h.

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

float JetPlusTrackCorrector::theSumPtWithoutEff
protected

Definition at line 414 of file JetPlusTrackCorrector.h.

Referenced by calculateCorr(), and correction().

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

Definition at line 397 of file JetPlusTrackCorrector.h.

Referenced by failTrackQuality(), and matchTracks().

bool JetPlusTrackCorrector::useEff_
protected

Definition at line 377 of file JetPlusTrackCorrector.h.

Referenced by JetPlusTrackCorrector(), and pionCorrection().

bool JetPlusTrackCorrector::useElecs_
protected

Definition at line 379 of file JetPlusTrackCorrector.h.

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

bool JetPlusTrackCorrector::useInConeTracks_
protected

Definition at line 373 of file JetPlusTrackCorrector.h.

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

bool JetPlusTrackCorrector::useMuons_
protected

Definition at line 378 of file JetPlusTrackCorrector.h.

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

bool JetPlusTrackCorrector::useOutOfConeTracks_
protected

Definition at line 374 of file JetPlusTrackCorrector.h.

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

bool JetPlusTrackCorrector::useOutOfVertexTracks_
protected

Definition at line 375 of file JetPlusTrackCorrector.h.

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

bool JetPlusTrackCorrector::usePions_
protected

Definition at line 376 of file JetPlusTrackCorrector.h.

Referenced by correction(), and JetPlusTrackCorrector().

bool JetPlusTrackCorrector::useTrackQuality_
protected

Definition at line 380 of file JetPlusTrackCorrector.h.

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

bool JetPlusTrackCorrector::vecResponse_
protected
bool JetPlusTrackCorrector::vectorial_
protected
bool JetPlusTrackCorrector::verbose_
protected
reco::Particle::Point JetPlusTrackCorrector::vertex_
protected

Definition at line 389 of file JetPlusTrackCorrector.h.

Referenced by failTrackQuality(), and matchTracks().