CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected 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) const
 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) const
 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 &)
 Constructor. More...
 
bool matchTracks (const reco::Jet &, const edm::Event &, const edm::EventSetup &, jpt::MatchedTracks &pions, jpt::MatchedTracks &muons, jpt::MatchedTracks &elecs) const
 Matches tracks to different particle types. More...
 
P4 muonCorrection (const P4 &jet, const jpt::MatchedTracks &muons) const
 Calculates correction to be applied using muons. More...
 
P4 pionCorrection (const P4 &jet, const jpt::MatchedTracks &pions) const
 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) const
 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) const
 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) const
 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) const
 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) const
 Calculates individual pion corrections. More...
 
P4 pionEfficiency (const P4 &jet, const jpt::Efficiency &, bool in_cone_at_calo_face) const
 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_
 
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_
 

Detailed Description

Jet energy correction algorithm using tracks.

Definition at line 176 of file JetPlusTrackCorrector.h.

Member Typedef Documentation

Definition at line 276 of file JetPlusTrackCorrector.h.

Definition at line 189 of file JetPlusTrackCorrector.h.

Definition at line 190 of file JetPlusTrackCorrector.h.

Definition at line 191 of file JetPlusTrackCorrector.h.

Definition at line 275 of file JetPlusTrackCorrector.h.

Definition at line 274 of file JetPlusTrackCorrector.h.

Get reponses.

Definition at line 273 of file JetPlusTrackCorrector.h.

Definition at line 277 of file JetPlusTrackCorrector.h.

Constructor & Destructor Documentation

JetPlusTrackCorrector::JetPlusTrackCorrector ( const edm::ParameterSet pset)

Constructor.

Definition at line 22 of file JetPlusTrackCorrector.cc.

References electrons_, edm::ParameterSet::getParameter(), jetSplitMerge_, jetTracksAtCalo_, jetTracksAtVertex_, muons_, 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 {
52 
53  if ( verbose_ ) {
54  std::stringstream ss;
55  ss << "[JetPlusTrackCorrector::" << __func__ << "] Configuration for JPT corrector: " << std::endl
56  << " Particles" << std::endl
57  << " UsePions : " << ( usePions_ ? "true" : "false" ) << std::endl
58  << " UseMuons : " << ( useMuons_ ? "true" : "false" ) << std::endl
59  << " UseElecs : " << ( useElecs_ ? "true" : "false" ) << std::endl
60  << " Corrections" << std::endl
61  << " UseInConeTracks : " << ( useInConeTracks_ ? "true" : "false" ) << std::endl
62  << " UseOutOfConeTracks : " << ( useOutOfConeTracks_ ? "true" : "false" ) << std::endl
63  << " UseOutOfVertexTracks : " << ( useOutOfVertexTracks_ ? "true" : "false" ) << std::endl
64  << " ResponseMap : " << pset.getParameter<std::string>("ResponseMap") << std::endl
65  << " Efficiency" << std::endl
66  << " UsePionEfficiency : " << ( useEff_ ? "true" : "false" ) << std::endl
67  << " EfficiencyMap : " << pset.getParameter<std::string>("EfficiencyMap") << std::endl
68  << " LeakageMap : " << pset.getParameter<std::string>("LeakageMap") << std::endl
69  << " Tracks" << std::endl
70  << " JetTracksAtVertex : " << jetTracksAtVertex_ << std::endl
71  << " JetTracksAtCalo : " << jetTracksAtCalo_ << std::endl
72  << " JetSplitMerge : " << jetSplitMerge_ << std::endl
73  << " UseTrackQuality : " << ( useTrackQuality_ ? "true" : "false" ) << std::endl
74  << " Collections" << std::endl
75  << " Muons : " << muons_ << std::endl
76  << " Electrons : " << electrons_ << std::endl
77  << " Vectorial" << std::endl
78  << " UseTracksAndResponse : " << ( ( vectorial_ && vecResponse_ ) ? "true" : "false" ) << std::endl
79  << " UseTracksOnly : " << ( ( vectorial_ && !vecResponse_ ) ? "true" : "false" );
80  edm::LogInfo("JetPlusTrackCorrector") << ss.str();
81  }
82 
83  if ( !useInConeTracks_ ||
86  std::stringstream ss;
87  ss << "[JetPlusTrackCorrector::" << __func__ << "]"
88  << " You are using JPT algorithm in a non-standard way!" << std::endl
89  << " UseInConeTracks : " << ( useInConeTracks_ ? "true" : "false" ) << std::endl
90  << " UseOutOfConeTracks : " << ( useOutOfConeTracks_ ? "true" : "false" ) << std::endl
91  << " UseOutOfVertexTracks : " << ( useOutOfVertexTracks_ ? "true" : "false" );
92  edm::LogWarning("JetPlusTrackCorrector") << ss.str();
93  }
94 }
T getParameter(std::string const &) const
Container class for response &amp; efficiency maps.
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:46
reco::TrackBase::TrackQuality trackQuality_
JetPlusTrackCorrector::~JetPlusTrackCorrector ( )
virtual

Destructor.

Definition at line 98 of file JetPlusTrackCorrector.cc.

98 {;}
JetPlusTrackCorrector::JetPlusTrackCorrector ( )
inlineprotected

Default constructor.

Definition at line 393 of file JetPlusTrackCorrector.h.

393 {;}

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 
) const
protected

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

Definition at line 854 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(), relval_parameters_module::energy, eta(), jpt::Map::etaBin(), SurfaceOrientation::inner, edm::isDebugEnabled(), LogDebug, scaleCards::mass, jpt::Map::nEtaBins(), jpt::Map::nPtBins(), SurfaceOrientation::outer, jpt::Map::ptBin(), jpt::Efficiency::reset(), response_, mathSSE::sqrt(), groupFilesInBlocks::temp, theResponseOfChargedWithEff, theResponseOfChargedWithoutEff, theSumEnergyWithEff, theSumEnergyWithoutEff, theSumPtWithEff, theSumPtWithoutEff, jpt::Map::value(), vecResponse_, vectorial_, and verbose_.

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

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

References reco::LeafCandidate::eta(), and maxEta_.

Referenced by correction().

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

Check corrected 4-momentum does not give negative scale.

Definition at line 492 of file JetPlusTrackCorrector.h.

References metsig::jet.

Referenced by correction().

492  {
493  if ( jet.energy() > 0. && ( corrected.energy() / jet.energy() ) < 0. ) {
494  corrected = jet;
495  }
496  return corrected.energy() / jet.energy();
497 }
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 1236 of file JetPlusTrackCorrector.cc.

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

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

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

Definition at line 102 of file JetPlusTrackCorrector.cc.

References canCorrect(), checkScale(), elecCorrection(), reco::LeafCandidate::energy(), reco::LeafCandidate::et(), reco::LeafCandidate::eta(), jetDirFromTracks(), reco::LeafCandidate::mass(), matchTracks(), muonCorrection(), patZpeak::muons, reco::LeafCandidate::p4(), reco::LeafCandidate::phi(), pionCorrection(), reco::LeafCandidate::pt(), reco::LeafCandidate::px(), reco::LeafCandidate::py(), reco::LeafCandidate::pz(), pileupReCalc_HLTpaths::scale, theResponseOfChargedWithEff, theResponseOfChargedWithoutEff, theSumEnergyWithEff, theSumEnergyWithoutEff, theSumPtForBeta, theSumPtWithEff, theSumPtWithoutEff, useElecs_, useMuons_, usePions_, vecResponse_, vectorial_, and verbose_.

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

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

Scalar correction method.

Definition at line 453 of file JetPlusTrackCorrector.h.

References correction().

459  {
460  P4 not_used_for_scalar_correction;
461  return correction( fJet, fJetcalo, event, setup, not_used_for_scalar_correction,pions,muons,elecs,validMatches );
462 }
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) const
Vectorial correction method (corrected 4-momentum passed by reference)
double JetPlusTrackCorrector::correction ( const reco::Jet jet) const

Correction method (not used)

Definition at line 215 of file JetPlusTrackCorrector.cc.

215  {
216  edm::LogError("JetPlusTrackCorrector")
217  << "JetPlusTrackCorrector can be run on entire event only";
218  return 1.;
219 }
double JetPlusTrackCorrector::correction ( const P4 jet) const

Correction method (not used)

Definition at line 223 of file JetPlusTrackCorrector.cc.

223  {
224  edm::LogError("JetPlusTrackCorrector")
225  << "JetPlusTrackCorrector can be run on entire event only";
226  return 1.;
227 }
const jpt::Map & JetPlusTrackCorrector::efficiencyMap ( ) const
inlineprotected

Definition at line 500 of file JetPlusTrackCorrector.h.

References efficiency_.

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

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

Calculates correction to be applied using electrons.

Definition at line 748 of file JetPlusTrackCorrector.cc.

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

Referenced by correction().

749  {
750 
751  P4 null; //@@ null 4-momentum
752 
753  if ( verbose_ ) {
754  std::stringstream ss;
755  ss << " Electron corrections:" << std::endl
756  << " In/In : " << "(" << elecs.inVertexInCalo_.size() << ") " << null.energy() << std::endl
757  << " In/Out : " << "(" << elecs.inVertexOutOfCalo_.size() << ") " << null.energy() << std::endl
758  << " Out/In : " << "(" << elecs.outOfVertexInCalo_.size() << ") " << null.energy();
759  edm::LogVerbatim("JetPlusTrackCorrector") << ss.str();
760  }
761 
762  return null; //@@ to be implemented
763 
764 }
math::XYZTLorentzVector P4
reco::TrackRefVector inVertexInCalo_
reco::TrackRefVector inVertexOutOfCalo_
reco::TrackRefVector outOfVertexInCalo_
size_type size() const
Size of the RefVector.
Definition: RefVector.h:89
JetPlusTrackCorrector::P4 JetPlusTrackCorrector::elecCorrection ( const P4 jet,
const TrackRefs elecs,
bool  in_cone_at_vertex,
bool  in_cone_at_calo_face 
) const
inlineprotected

Calculates individual electron corrections.

Definition at line 484 of file JetPlusTrackCorrector.h.

References calculateCorr(), efficiencyMap(), elecMass_, leakageMap(), and responseMap().

487  {
488  static jpt::Efficiency not_used( responseMap(), efficiencyMap(), leakageMap() );
489  return calculateCorr( jet, elecs, not_used, in_cone_at_vertex, in_cone_at_calo_face, elecMass_, false, 0. );
490 }
const jpt::Map & responseMap() const
const jpt::Map & efficiencyMap() const
const jpt::Map & leakageMap() const
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) const
Generic method to calculates 4-momentum correction to be applied.
Generic container class.
bool JetPlusTrackCorrector::eventRequired ( ) const
inline

Returns true.

Definition at line 464 of file JetPlusTrackCorrector.h.

464 { 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 1199 of file JetPlusTrackCorrector.cc.

References edm::RefVector< C, T, F >::begin(), edm::RefVector< C, T, F >::clear(), edm::RefVector< C, T, F >::end(), spr::find(), reco::JetTracksAssociation::getValue(), jetSplitMerge_, edm::RefVector< C, T, F >::push_back(), edm::RefVector< C, T, F >::size(), and testEve_cfg::tracks.

Referenced by jtaUsingEventData().

1202  {
1203 
1204  //std::cout<<" NEW2" << std::endl;
1205 
1206  tracksthis = reco::JetTracksAssociation::getValue(jtV0,fJet);
1207  if(Excl.size() == 0) return;
1208  if(jetSplitMerge_<0) return;
1209 
1210  TrackRefs tracks = tracksthis;
1211  tracksthis.clear();
1212 
1213  //std::cout<<" Size of initial vector "<<tracks.size()<<" "<<fJet.et()<<" "<<fJet.eta()<<" "<<fJet.phi()<<std::endl;
1214 
1215  for(TrackRefs::iterator it = tracks.begin(); it != tracks.end(); it++ )
1216  {
1217 
1218  //std::cout<<" Track at calo surface "
1219  //<<" Track "<<(**it).eta()<<" "<<(**it).phi()<<std::endl;
1220  TrackRefs::iterator itold = find(Excl.begin(),Excl.end(),(*it));
1221  if(itold == Excl.end()) {
1222  tracksthis.push_back (*it);
1223  }
1224  //else { std::cout<<"Exclude "<<(**it).eta()<<" "<<(**it).phi()<<std::endl; }
1225 
1226  }
1227 
1228  //std::cout<<" Size of calo tracks "<<tracksthis.size()<<std::endl;
1229 
1230  return;
1231 
1232 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
reco::TrackRefVector TrackRefs
refhelper::RefVectorTrait< TrackCollection, T, F >::iterator_type iterator
Definition: RefVector.h:40
const reco::TrackRefVector & getValue(const Container &, const reco::JetBaseRef &)
get value for the association. Throw exception if no association found
tuple tracks
Definition: testEve_cfg.py:39
bool JetPlusTrackCorrector::failTrackQuality ( TrackRefs::const_iterator  itrk) const
protected

Check on track quality.

Definition at line 571 of file JetPlusTrackCorrector.cc.

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

Referenced by matchTracks().

571  {
572 // if ( useTrackQuality_ && !(*itrk)->quality(trackQuality_) ) { return true; }
573 // else { return false; }
574 
575  bool retcode = false;
576 
577  if ( useTrackQuality_ && !(*itrk)->quality(trackQuality_) ) {
578  retcode = true; return retcode;
579  }
580  if(((*itrk)->ptError()/(*itrk)->pt()) > ptErrorQuality_) {
581  retcode = true; return retcode;
582  }
583  if(fabs((*itrk)->dz(vertex_)) > dzVertexCut_) {
584  retcode = true; return retcode;
585  }
586 
587  return retcode;
588 }
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 592 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().

594  {
595  it = find( jet_tracks.caloFace_.begin(),
596  jet_tracks.caloFace_.end(),
597  *itrk );
598  if ( it != jet_tracks.caloFace_.end() ) { return true; }
599  else { return false; }
600 }
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:249
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:244
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 604 of file JetPlusTrackCorrector.cc.

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

607  {
609  pions.inVertexInCalo_.end(),
610  *itrk );
612  muons.inVertexInCalo_.end(),
613  *itrk );
614  TrackRefs::iterator ie = find( elecs.inVertexInCalo_.begin(),
615  elecs.inVertexInCalo_.end(),
616  *itrk );
617  if ( ip == pions.inVertexInCalo_.end() &&
618  im == muons.inVertexInCalo_.end() &&
619  ie == elecs.inVertexInCalo_.end() ) { return false; }
620  else { return true; }
621 }
reco::TrackRefVector inVertexInCalo_
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:249
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:244
refhelper::RefVectorTrait< TrackCollection, T, F >::iterator_type iterator
Definition: RefVector.h:40
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 541 of file JetPlusTrackCorrector.cc.

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

Referenced by matchTracks().

543  {
544  event.getByLabel( electrons_, reco_elecs );
545  if ( !reco_elecs.isValid() || reco_elecs.failedToGet() ) {
546  edm::LogError("JetPlusTrackCorrector")
547  << "[JetPlusTrackCorrector::" << __func__ << "]"
548  << " Invalid handle to reco::GsfElectron collection"
549  << " with InputTag (label:instance:process) \""
550  << electrons_.label() << ":"
551  << electrons_.instance() << ":"
552  << electrons_.process() << "\"";
553  return false;
554  }
555  event.getByLabel( electronIds_, reco_elec_ids );
556  if ( !reco_elec_ids.isValid() || reco_elec_ids.failedToGet() ) {
557  edm::LogError("JetPlusTrackCorrector")
558  << "[JetPlusTrackCorrector::" << __func__ << "]"
559  << " Invalid handle to reco::GsfElectron collection"
560  << " with InputTag (label:instance:process) \""
561  << electronIds_.label() << ":"
562  << electronIds_.instance() << ":"
563  << electronIds_.process() << "\"";
564  return false;
565  }
566  return true;
567 }
bool isValid() const
Definition: HandleBase.h:76
bool failedToGet() const
Definition: HandleBase.h:80
std::string const & label() const
Definition: InputTag.h:25
std::string const & process() const
Definition: InputTag.h:29
std::string const & instance() const
Definition: InputTag.h:26
bool JetPlusTrackCorrector::getMuons ( const edm::Event event,
edm::Handle< RecoMuons > &  reco_muons 
) const
protected

Get RECO muons.

Definition at line 364 of file JetPlusTrackCorrector.cc.

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

Referenced by matchTracks().

364  {
365  event.getByLabel( muons_, reco_muons );
366  if ( !reco_muons.isValid() || reco_muons.failedToGet() ) {
367  edm::LogError("JetPlusTrackCorrector")
368  << "[JetPlusTrackCorrector::" << __func__ << "]"
369  << " Invalid handle to reco::Muon collection"
370  << " with InputTag (label:instance:process) \""
371  << muons_.label() << ":"
372  << muons_.instance() << ":"
373  << muons_.process() << "\"";
374  return false;
375  }
376  return true;
377 }
bool isValid() const
Definition: HandleBase.h:76
bool failedToGet() const
Definition: HandleBase.h:80
std::string const & label() const
Definition: InputTag.h:25
std::string const & process() const
Definition: InputTag.h:29
std::string const & instance() const
Definition: InputTag.h:26
double JetPlusTrackCorrector::getResponseOfChargedWithEff ( )
inline

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

Definition at line 231 of file JetPlusTrackCorrector.h.

References theResponseOfChargedWithEff.

double JetPlusTrackCorrector::getResponseOfChargedWithoutEff ( )
inline
double JetPlusTrackCorrector::getSumEnergyWithEff ( )
inline

Definition at line 235 of file JetPlusTrackCorrector.h.

References theSumEnergyWithEff.

double JetPlusTrackCorrector::getSumEnergyWithoutEff ( )
inline

Definition at line 236 of file JetPlusTrackCorrector.h.

References theSumEnergyWithoutEff.

double JetPlusTrackCorrector::getSumPtForBeta ( )
inline

Definition at line 237 of file JetPlusTrackCorrector.h.

References theSumPtForBeta.

double JetPlusTrackCorrector::getSumPtWithEff ( )
inline

Definition at line 233 of file JetPlusTrackCorrector.h.

References theSumPtWithEff.

double JetPlusTrackCorrector::getSumPtWithoutEff ( )
inline

Definition at line 234 of file JetPlusTrackCorrector.h.

References theSumPtWithoutEff.

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 768 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().

771  {
772 
773  // Correction to be applied to jet 4-momentum
774  P4 corr;
775 
776 // bool tracks_present = false;
777  bool tracks_present_inin = false;
778 
779  // Correct using pions in-cone at vertex
780 
781  if ( !pions.inVertexInCalo_.empty() ) {
783  TrackRefs::iterator jtrk = pions.inVertexInCalo_.end();
784  for ( ; itrk != jtrk; ++itrk ) {
785  corr += PtEtaPhiM( (*itrk)->pt(), (*itrk)->eta(), (*itrk)->phi(), 0. );
786 // tracks_present = true;
787  tracks_present_inin = true;
788  }
789  }
790 
791  if ( !pions.inVertexOutOfCalo_.empty() ) {
794  for ( ; itrk != jtrk; ++itrk ) {
795  corr += PtEtaPhiM( (*itrk)->pt(), (*itrk)->eta(), (*itrk)->phi(), 0. );
796 // tracks_present = true;
797  }
798  }
799 
800  // Correct using muons in-cone at vertex
801 
802  if ( !muons.inVertexInCalo_.empty() ) {
804  TrackRefs::iterator jtrk = muons.inVertexInCalo_.end();
805  for ( ; itrk != jtrk; ++itrk ) {
806  corr += PtEtaPhiM( (*itrk)->pt(), (*itrk)->eta(), (*itrk)->phi(), 0. );
807 // tracks_present = true;
808  }
809  }
810 
811  if ( !muons.inVertexOutOfCalo_.empty() ) {
814  for ( ; itrk != jtrk; ++itrk ) {
815  corr += PtEtaPhiM( (*itrk)->pt(), (*itrk)->eta(), (*itrk)->phi(), 0. );
816 // tracks_present = true;
817  }
818  }
819 
820  // Correct using electrons in-cone at vertex
821 
822  if ( !elecs.inVertexInCalo_.empty() ) {
824  TrackRefs::iterator jtrk = elecs.inVertexInCalo_.end();
825  for ( ; itrk != jtrk; ++itrk ) {
826  corr += PtEtaPhiM( (*itrk)->pt(), (*itrk)->eta(), (*itrk)->phi(), 0. );
827 // tracks_present = true;
828  }
829  }
830 
831  if ( !elecs.inVertexOutOfCalo_.empty() ) {
834  for ( ; itrk != jtrk; ++itrk ) {
835  corr += PtEtaPhiM( (*itrk)->pt(), (*itrk)->eta(), (*itrk)->phi(), 0. );
836 // tracks_present = true;
837  }
838  }
839 
840  // Adjust direction if in cone tracks are present
841 
842  if ( !tracks_present_inin ) { corr = corrected; }
843  else {
844  corr *= ( corr.P() > 0. ? corrected.P() / corr.P() : 1. );
845  corr = P4( corr.px(), corr.py(), corr.pz(), corrected.energy() );
846  }
847 
848  return corr;
849 
850 }
math::XYZTLorentzVector P4
reco::TrackRefVector inVertexInCalo_
reco::TrackRefVector inVertexOutOfCalo_
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:249
bool empty() const
Is the RefVector empty.
Definition: RefVector.h:86
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:244
refhelper::RefVectorTrait< TrackCollection, T, F >::iterator_type iterator
Definition: RefVector.h:40
JetCorrectorParameters corr
Definition: classes.h:9
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 264 of file JetPlusTrackCorrector.cc.

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

Referenced by matchTracks().

267  {
268 
269  // Some init
270  trks.clear();
271 
272  // Check if labels are given
273  if ( !jetTracksAtVertex_.label().empty() && !jetTracksAtCalo_.label().empty() ) {
274 
275  //std::cout<<" Try to associate with splitting "<< std::endl;
276 
277  return jtaUsingEventData( fJet, event, trks );
278  } else {
279 
280  edm::LogWarning("PatJPTCorrector")
281  << "[JetPlusTrackCorrector::" << __func__ << "]"
282  << " Empty label for the reco::JetTracksAssociation::Containers"
283  << std::endl
284  << " InputTag for JTA \"at vertex\" (label:instance:process) \""
285  << jetTracksAtVertex_.label() << ":"
286  << jetTracksAtVertex_.instance() << ":"
287  << jetTracksAtVertex_.process() << "\""
288  << std::endl
289  << " InputTag for JTA \"at calo face\" (label:instance:process) \""
290  << jetTracksAtCalo_.label() << ":"
291  << jetTracksAtCalo_.instance() << ":"
292  << jetTracksAtCalo_.process() << "\"";
293  return false;
294  }
295 
296 }
std::string const & label() const
Definition: InputTag.h:25
std::string const & process() const
Definition: InputTag.h:29
bool jtaUsingEventData(const reco::Jet &, const edm::Event &, jpt::JetTracks &) const
JTA using collections from event.
std::string const & instance() const
Definition: InputTag.h:26
bool JetPlusTrackCorrector::jtaUsingEventData ( const reco::Jet fJet,
const edm::Event event,
jpt::JetTracks trks 
) const
protected

JTA using collections from event.

Definition at line 300 of file JetPlusTrackCorrector.cc.

References jpt::JetTracks::caloFace_, edm::RefVector< C, T, F >::empty(), excludeJta(), edm::HandleBase::failedToGet(), reco::JetTracksAssociation::getValue(), 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().

302  {
303 
304  // Get Jet-track association at Vertex
306  event.getByLabel( jetTracksAtVertex_, jetTracksAtVertex );
307 
308  if ( !jetTracksAtVertex.isValid() || jetTracksAtVertex.failedToGet() ) {
309  if ( verbose_ && edm::isDebugEnabled() ) {
310  edm::LogWarning("JetPlusTrackCorrector")
311  << "[JetPlusTrackCorrector::" << __func__ << "]"
312  << " Invalid handle to reco::JetTracksAssociation::Container (for Vertex)"
313  << " with InputTag (label:instance:process) \""
314  << jetTracksAtVertex_.label() << ":"
315  << jetTracksAtVertex_.instance() << ":"
316  << jetTracksAtVertex_.process() << "\"";
317  }
318  return false;
319  }
320 
321 
322  // std::cout<<" JetPlusTrackCorrector::jtaUsingEventData::here "<<jetSplitMerge_<<std::endl;
323 
324  // Retrieve jet-tracks association for given jet
325  const reco::JetTracksAssociation::Container jtV = *( jetTracksAtVertex.product() );
326  TrackRefs excluded;
327  if ( jetSplitMerge_ < 0 ) { trks.vertex_ = reco::JetTracksAssociation::getValue( jtV, fJet ); }
328  else { rebuildJta( fJet, jtV, trks.vertex_, excluded ); }
329 
330  // Check if any tracks are associated to jet at vertex
331  if ( trks.vertex_.empty() ) { return false; }
332 
333  // Get Jet-track association at Calo
335  event.getByLabel( jetTracksAtCalo_, jetTracksAtCalo );
336 
337  if ( !jetTracksAtCalo.isValid() || jetTracksAtCalo.failedToGet() ) {
338  if ( verbose_ && edm::isDebugEnabled() ) {
339  edm::LogWarning("JetPlusTrackCorrector")
340  << "[JetPlusTrackCorrector::" << __func__ << "]"
341  << " Invalid handle to reco::JetTracksAssociation::Container (for CaloFace)"
342  << " with InputTag (label:instance:process) \""
343  << jetTracksAtCalo_.label() << ":"
344  << jetTracksAtCalo_.instance() << ":"
345  << jetTracksAtCalo_.process() << "\"";
346  }
347  return false;
348  }
349 
350  // Retrieve jet-tracks association for given jet
351  const reco::JetTracksAssociation::Container jtC = *( jetTracksAtCalo.product() );
352  if ( jetSplitMerge_ < 0 ) { trks.caloFace_ = reco::JetTracksAssociation::getValue( jtC, fJet ); }
353  else { excludeJta( fJet, jtC, trks.caloFace_, excluded ); }
354 
355 // std::cout<<" JTA:Tracks in vertex "<<trks.vertex_.size()<<" in calo "<<trks.caloFace_.size()<<std::endl;
356 
357  // Successful
358  return true;
359 
360 }
bool isDebugEnabled()
reco::TrackRefVector vertex_
bool empty() const
Is the RefVector empty.
Definition: RefVector.h:86
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:76
void rebuildJta(const reco::Jet &, const JetTracksAssociations &, TrackRefs &included, TrackRefs &excluded) const
Rebuild jet-track association.
bool failedToGet() const
Definition: HandleBase.h:80
void excludeJta(const reco::Jet &, const JetTracksAssociations &, TrackRefs &included, const TrackRefs &excluded) const
Exclude jet-track association.
T const * product() const
Definition: Handle.h:74
std::string const & label() const
Definition: InputTag.h:25
std::string const & process() const
Definition: InputTag.h:29
std::string const & instance() const
Definition: InputTag.h:26
const jpt::Map & JetPlusTrackCorrector::leakageMap ( ) const
inlineprotected

Definition at line 501 of file JetPlusTrackCorrector.h.

References leakage_.

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

501 { 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 1095 of file JetPlusTrackCorrector.cc.

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

Referenced by matchTracks().

1097  {
1098 
1099  if ( elecs->empty() ) { return false; }
1100 
1101  double deltaR = 999.;
1102  double deltaRMIN = 999.;
1103 
1104  uint32_t electron_index = 0;
1105  RecoElectrons::const_iterator ielec = elecs->begin();
1106  RecoElectrons::const_iterator jelec = elecs->end();
1107  for ( ; ielec != jelec; ++ielec ) {
1108 
1109  edm::Ref<RecoElectrons> electron_ref( elecs, electron_index );
1110  electron_index++;
1111 
1112  if ( (*elec_ids)[electron_ref] < 1.e-6 ) { continue; } //@@ Check for null value
1113 
1114  // DR matching b/w electron and track
1115  double deltaphi = fabs( ielec->phi() - (*itrk)->momentum().phi() );
1116  if ( deltaphi > 6.283185308 ) deltaphi -= 6.283185308;
1117  if ( deltaphi > 3.141592654 ) deltaphi = 6.283185308 - deltaphi;
1118  deltaR = abs( sqrt( pow( (ielec->eta() - (*itrk)->momentum().eta()), 2 ) +
1119  pow( deltaphi , 2 ) ) );
1120  if ( deltaR < deltaRMIN ) { deltaRMIN = deltaR; }
1121 
1122  }
1123 
1124  if ( deltaR < 0.02 ) return true;
1125  else return false;
1126 
1127 }
#define abs(x)
Definition: mlp_lapack.h:159
T sqrt(T t)
Definition: SSEVec.h:46
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
bool JetPlusTrackCorrector::matchMuons ( TrackRefs::const_iterator  itrk,
const edm::Handle< RecoMuons > &  muons 
) const
protected

Matches tracks to RECO muons.

Definition at line 1063 of file JetPlusTrackCorrector.cc.

References muon::isGoodMuon(), and muon::TMLastStationTight.

Referenced by matchTracks().

1064  {
1065 
1066  if ( muons->empty() ) { return false; }
1067 
1068  RecoMuons::const_iterator imuon = muons->begin();
1069  RecoMuons::const_iterator jmuon = muons->end();
1070  for ( ; imuon != jmuon; ++imuon ) {
1071 
1072  if ( imuon->innerTrack().isNull() ||
1074  imuon->innerTrack()->pt() < 3.0 ) { continue; }
1075 
1076  if ( itrk->id() != imuon->innerTrack().id() ) {
1077  edm::LogError("JetPlusTrackCorrector")
1078  << "[JetPlusTrackCorrector::" << __func__ << "]"
1079  << "Product id of the tracks associated to the jet " << itrk->id()
1080  <<" is different from the product id of the inner track used for muons " << imuon->innerTrack().id()
1081  << "!" << std::endl
1082  << "Cannot compare tracks from different collection. Configuration Error!";
1083  return false;
1084  }
1085 
1086  if ( *itrk == imuon->innerTrack() ) { return true; }
1087  }
1088 
1089  return false;
1090 
1091 }
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 
) const

Matches tracks to different particle types.

Definition at line 231 of file JetPlusTrackCorrector.cc.

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

Referenced by correction().

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

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

Definition at line 381 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(), jpt::MatchedTracks::inVertexInCalo_, jpt::MatchedTracks::inVertexOutOfCalo_, edm::isDebugEnabled(), edm::HandleBase::isValid(), LogTrace, matchElectrons(), matchMuons(), jpt::MatchedTracks::outOfVertexInCalo_, edm::RefVector< C, T, F >::push_back(), findQualityFiles::rr, edm::RefVector< C, T, F >::size(), srcPVs_, theSumPtForBeta, trackQuality_, tracksInCalo(), useElecs_, useMuons_, useTrackQuality_, verbose_, jpt::JetTracks::vertex_, and vertex_.

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

Calculates correction to be applied using muons.

Definition at line 709 of file JetPlusTrackCorrector.cc.

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

Referenced by correction().

710  {
711 
712  P4 corr_muons;
713 
714  P4 corr_muons_in_cone;
715  P4 corr_muons_out_of_cone;
716  P4 corr_muons_out_of_vertex;
717 
718  if ( useInConeTracks_ ) {
719  corr_muons_in_cone = muonCorrection( jet, muons.inVertexInCalo_, true, true );
720  corr_muons += corr_muons_in_cone;
721  }
722 
723  if ( useOutOfConeTracks_ ) {
724  corr_muons_out_of_cone = muonCorrection( jet, muons.inVertexOutOfCalo_, true, false );
725  corr_muons += corr_muons_out_of_cone;
726  }
727 
728  if ( useOutOfVertexTracks_ ) {
729  corr_muons_out_of_vertex = muonCorrection( jet, muons.outOfVertexInCalo_, false, true );
730  corr_muons += corr_muons_out_of_vertex;
731  }
732 
733  if ( verbose_ ) {
734  std::stringstream ss;
735  ss << " Muon corrections:" << std::endl
736  << " In/In : " << "(" << muons.inVertexInCalo_.size() << ") " << corr_muons_in_cone.energy() << std::endl
737  << " In/Out : " << "(" << muons.inVertexOutOfCalo_.size() << ") " << corr_muons_out_of_cone.energy() << std::endl
738  << " Out/In : " << "(" << muons.outOfVertexInCalo_.size() << ") " << corr_muons_out_of_vertex.energy();
739  edm::LogVerbatim("JetPlusTrackCorrector") << ss.str();
740  }
741 
742  return corr_muons;
743 
744 }
math::XYZTLorentzVector P4
reco::TrackRefVector inVertexInCalo_
reco::TrackRefVector inVertexOutOfCalo_
P4 muonCorrection(const P4 &jet, const jpt::MatchedTracks &muons) const
Calculates correction to be applied using muons.
reco::TrackRefVector outOfVertexInCalo_
size_type size() const
Size of the RefVector.
Definition: RefVector.h:89
JetPlusTrackCorrector::P4 JetPlusTrackCorrector::muonCorrection ( const P4 jet,
const TrackRefs muons,
bool  in_cone_at_vertex,
bool  in_cone_at_calo_face 
) const
inlineprotected

Calculates individual muons corrections.

Definition at line 476 of file JetPlusTrackCorrector.h.

References calculateCorr(), efficiencyMap(), leakageMap(), muonMass_, and responseMap().

479  {
480  static jpt::Efficiency not_used( responseMap(), efficiencyMap(), leakageMap() );
481  return calculateCorr( jet, muons, not_used, in_cone_at_vertex, in_cone_at_calo_face, muonMass_, false, 2. );
482 }
const jpt::Map & responseMap() const
const jpt::Map & efficiencyMap() const
const jpt::Map & leakageMap() const
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) const
Generic method to calculates 4-momentum correction to be applied.
tuple muons
Definition: patZpeak.py:38
Generic container class.
JetPlusTrackCorrector::P4 JetPlusTrackCorrector::pionCorrection ( const P4 jet,
const jpt::MatchedTracks pions 
) const

Calculates corrections to be applied using pions.

Definition at line 636 of file JetPlusTrackCorrector.cc.

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

Referenced by correction().

637  {
638 
639  P4 corr_pions;
640 /*
641  std::cout<<" pionCorrection::Corrections for jet "<< theResponseOfChargedWithEff <<" "<<
642  theResponseOfChargedWithoutEff <<" "<<
643  theSumPtWithEff <<" "<<
644  theSumPtWithoutEff <<" "<<
645  theSumEnergyWithEff <<" "<<
646  theSumEnergyWithoutEff <<std::endl;
647 */
648 
649  // In-cone
650 
651  P4 corr_pions_in_cone;
652  P4 corr_pions_eff_in_cone;
653  Efficiency in_cone( responseMap(), efficiencyMap(), leakageMap() );
654 
655  if ( useInConeTracks_ ) {
656  corr_pions_in_cone = pionCorrection( jet, pions.inVertexInCalo_, in_cone, true, true );
657  corr_pions += corr_pions_in_cone;
658  if ( useEff_ ) {
659  corr_pions_eff_in_cone = pionEfficiency( jet, in_cone, true );
660  corr_pions += corr_pions_eff_in_cone;
661  }
662  }
663 
664  // Out-of-cone
665 
666  P4 corr_pions_out_of_cone;
667  P4 corr_pions_eff_out_of_cone;
668  Efficiency out_of_cone( responseMap(), efficiencyMap(), leakageMap() );
669 
670  if ( useOutOfConeTracks_ ) {
671  corr_pions_out_of_cone = pionCorrection( jet, pions.inVertexOutOfCalo_, out_of_cone, true, false );
672  corr_pions += corr_pions_out_of_cone;
673  if ( useEff_ ) {
674  corr_pions_eff_out_of_cone = pionEfficiency( jet, out_of_cone, false );
675  corr_pions += corr_pions_eff_out_of_cone;
676  }
677  }
678 
679  // Out-of-vertex
680 
681  P4 corr_pions_out_of_vertex;
682  Efficiency not_used( responseMap(), efficiencyMap(), leakageMap() );
683 
684  if ( useOutOfVertexTracks_ ) {
685  corr_pions_out_of_vertex = pionCorrection( jet, pions.outOfVertexInCalo_, not_used, false, true );
686  corr_pions += corr_pions_out_of_vertex;
687  }
688 
689  if ( verbose_ ) {
690  std::stringstream ss;
691  ss << " Pion corrections:" << std::endl
692  << " In/In : " << "(" << pions.inVertexInCalo_.size() << ") " << corr_pions_in_cone.energy() << std::endl
693  << " In/Out : " << "(" << pions.inVertexOutOfCalo_.size() << ") " << corr_pions_out_of_cone.energy() << std::endl
694  << " Out/In : " << "(" << pions.outOfVertexInCalo_.size() << ") " << corr_pions_out_of_vertex.energy() << std::endl;
695  if ( useEff_ ) {
696  ss << " Pion efficiency corrections:" << std::endl
697  << " In/In : " << "(" << pions.inVertexInCalo_.size() << ") " << corr_pions_eff_in_cone.energy() << std::endl
698  << " In/Out : " << "(" << pions.inVertexOutOfCalo_.size() << ") " << corr_pions_eff_out_of_cone.energy();
699  }
700  edm::LogVerbatim("JetPlusTrackCorrector") << ss.str();
701  }
702 
703  return corr_pions;
704 
705 }
math::XYZTLorentzVector P4
const jpt::Map & responseMap() const
reco::TrackRefVector inVertexInCalo_
P4 pionCorrection(const P4 &jet, const jpt::MatchedTracks &pions) const
Calculates corrections to be applied using pions.
reco::TrackRefVector inVertexOutOfCalo_
const jpt::Map & efficiencyMap() const
P4 pionEfficiency(const P4 &jet, const jpt::Efficiency &, bool in_cone_at_calo_face) const
Correction to be applied using tracking efficiency.
const jpt::Map & leakageMap() const
reco::TrackRefVector outOfVertexInCalo_
size_type size() const
Size of the RefVector.
Definition: RefVector.h:89
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 
) const
inlineprotected

Calculates individual pion corrections.

Definition at line 468 of file JetPlusTrackCorrector.h.

References calculateCorr(), and pionMass_.

472  {
473  return calculateCorr( jet, pions, eff, in_cone_at_vertex, in_cone_at_calo_face, pionMass_, true, -1. );
474 }
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) const
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 
) const
protected

Correction to be applied using tracking efficiency.

Definition at line 999 of file JetPlusTrackCorrector.cc.

References jpt::Map::binCenterEta(), jpt::Map::binCenterPt(), corr, correction(), jpt::Efficiency::inConeCorr(), jpt::Map::nEtaBins(), jpt::Map::nPtBins(), jpt::Efficiency::nTrks(), jpt::Efficiency::outOfConeCorr(), pionMass_, response_, theResponseOfChargedWithEff, theSumEnergyWithEff, theSumPtWithEff, vecResponse_, and vectorial_.

Referenced by pionCorrection().

1001  {
1002 
1003  // Total correction to be applied
1004  P4 correction;
1005 
1006  double theSumResp = 0;
1007  double theSumPt = 0;
1008  double theSumEnergy = 0;
1009 
1010  // Iterate through eta/pt bins
1011  for ( uint32_t ieta = 0; ieta < response_.nEtaBins()-1; ++ieta ) {
1012  for ( uint32_t ipt = 0; ipt < response_.nPtBins()-1; ++ipt ) {
1013 
1014  // Check tracks are found in this eta/pt bin
1015  if ( !eff.nTrks(ieta,ipt) ) { continue; }
1016 
1017  for ( uint16_t ii = 0; ii < 2; ++ii ) {
1018 
1019  // Check which correction should be applied
1020  double corr = 0.;
1021  if ( ii == 0 ) { corr = eff.outOfConeCorr( ieta, ipt );}
1022  else if ( ii == 1 && in_cone_at_calo_face ) { corr = eff.inConeCorr( ieta, ipt );}
1023  else { continue; }
1024 
1025  // Calculate correction to be applied
1026  P4 corr_p4;
1027  if ( vectorial_ && vecResponse_ ) {
1028  double corr_eta = response_.binCenterEta(ieta);
1029  double corr_phi = jet.phi(); //@@ jet phi!
1030  double corr_pt = response_.binCenterPt(ipt);
1031  corr_p4 = 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 ) { correction += corr_p4; theSumPt += corr_p4.pt(); theSumEnergy += corr_p4.energy();} //@@ Add out-of-cone
1039  else if ( ii == 1 ) { correction -= corr_p4; theSumResp += corr_p4.energy();} //@@ Subtract in-cone
1040 
1041  }
1042 
1043  }
1044  }
1045 
1046  theResponseOfChargedWithEff += theSumResp;
1047  theSumPtWithEff += theSumPt;
1048  theSumEnergyWithEff += theSumEnergy;
1049 /*
1050  std::cout<<" Efficiency correction End::Corrections for jet "<< theResponseOfChargedWithEff <<" "<<
1051  theResponseOfChargedWithoutEff <<" "<<
1052  theSumPtWithEff <<" "<<
1053  theSumPtWithoutEff <<" "<<
1054  theSumEnergyWithEff <<" "<<
1055  theSumEnergyWithoutEff <<std::endl;
1056 */
1057  return correction;
1058 
1059 }
math::XYZTLorentzVector P4
uint32_t nEtaBins() const
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
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) const
Vectorial correction method (corrected 4-momentum passed by reference)
JetCorrectorParameters corr
Definition: classes.h:9
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 1131 of file JetPlusTrackCorrector.cc.

References reco::JetTracksAssociation::allJets(), edm::RefVector< C, T, F >::begin(), edm::RefVector< C, T, F >::clear(), Geom::deltaR2(), edm::RefVector< C, T, F >::end(), reco::LeafCandidate::et(), reco::LeafCandidate::eta(), reco::JetTracksAssociation::getValue(), reco::btau::jetEta, reco::btau::jetPhi, jetSplitMerge_, reco::LeafCandidate::phi(), edm::RefVector< C, T, F >::push_back(), pileupReCalc_HLTpaths::scale, and testEve_cfg::tracks.

Referenced by jtaUsingEventData().

1134  {
1135 
1136  // std::cout<<" NEW1 Merge/Split schema "<<jetSplitMerge_<<std::endl;
1137 
1138  tracksthis = reco::JetTracksAssociation::getValue(jtV0,fJet);
1139 
1140  if(jetSplitMerge_<0) return;
1141 
1142  typedef std::vector<reco::JetBaseRef>::iterator JetBaseRefIterator;
1143  std::vector<reco::JetBaseRef> theJets = reco::JetTracksAssociation::allJets(jtV0);
1144 
1145  TrackRefs tracks = tracksthis;
1146  tracksthis.clear();
1147 
1148 // std::cout<<" Size of initial vector "<<tracks.size()<<" "<<fJet.et()<<" "<<fJet.eta()<<" "<<fJet.phi()<<std::endl;
1149 
1150  int tr=0;
1151 
1152 
1153  double jetEta=fJet.eta();
1154  double jetPhi=fJet.phi();
1155  double jetEtIn=1.0/fJet.et();
1156 
1157  for(TrackRefs::iterator it = tracks.begin(); it != tracks.end(); it++ )
1158  {
1159  double trkEta=(**it).eta();
1160  double trkPhi=(**it).phi();
1161  double dR2this = deltaR2( jetEta, jetPhi, trkEta, trkPhi );
1162  // double dfi = fabs(fJet.phi()-(**it).phi());
1163  // if(dfi>4.*atan(1.))dfi = 8.*atan(1.)-dfi;
1164  // double deta = fJet.eta() - (**it).eta();
1165  // double dR2check = sqrt(dfi*dfi+deta*deta);
1166 
1167  double scalethis = dR2this;
1168  if(jetSplitMerge_ == 0) scalethis = 1.*jetEtIn;
1169  if(jetSplitMerge_ == 2) scalethis = dR2this*jetEtIn;
1170  tr++;
1171  int flag = 1;
1172  for(JetBaseRefIterator ii = theJets.begin(); ii != theJets.end(); ii++)
1173  {
1174  if(&(**ii) == &fJet ) {continue;}
1175  double dR2 = deltaR2( (*ii)->eta(), (*ii)->phi(), trkEta, trkPhi );
1176  double scale = dR2;
1177  if(jetSplitMerge_ == 0) scale = 1.*jetEtIn;
1178  if(jetSplitMerge_ == 2) scale = dR2*jetEtIn;
1179  if(scale < scalethis) flag = 0;
1180 
1181  if(flag == 0) {
1182  //std::cout<<" Track belong to another jet also "<<dR2<<" "<<
1183  //(*ii)->et()<<" "<<(*ii)->eta()<<" "<< (*ii)->phi()<<" Track "<<(**it).eta()<<" "<<(**it).phi()<<" "<<scalethis<<" "<<scale<<" "<<flag<<std::endl;
1184  break;
1185  }
1186  }
1187 
1188  //std::cout<<" Track "<<tr<<" "<<flag<<" "<<dR2this<<" "<<dR2check<<" Jet "<<fJet.eta()<<" "<< fJet.phi()<<" Track "<<(**it).eta()<<" "<<(**it).phi()<<std::endl;
1189  if(flag == 1) {tracksthis.push_back (*it);}else{Excl.push_back (*it);}
1190  }
1191 
1192  //std::cout<<" The new size of tracks "<<tracksthis.size()<<" Excludede "<<Excl.size()<<std::endl;
1193  return;
1194 
1195 }
long int flag
Definition: mlp_lapack.h:47
virtual double et() const
transverse energy
virtual double eta() const
momentum pseudorapidity
reco::TrackRefVector TrackRefs
refhelper::RefVectorTrait< TrackCollection, T, F >::iterator_type iterator
Definition: RefVector.h:40
const reco::TrackRefVector & getValue(const Container &, const reco::JetBaseRef &)
get value for the association. Throw exception if no association found
double deltaR2(const Vector1 &v1, const Vector2 &v2)
Definition: VectorUtil.h:78
std::vector< reco::JetBaseRef > allJets(const Container &)
fill list of all jets associated with values. Return # of jets in the list
tuple tracks
Definition: testEve_cfg.py:39
virtual double phi() const
momentum azimuthal angle
const jpt::Map & JetPlusTrackCorrector::responseMap ( ) const
inlineprotected

Definition at line 499 of file JetPlusTrackCorrector.h.

References response_.

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

499 { 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 625 of file JetPlusTrackCorrector.cc.

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

Referenced by matchTracks().

627  {
628  if ( !pions.inVertexInCalo_.empty() ||
629  !muons.inVertexInCalo_.empty() ||
630  !elecs.inVertexInCalo_.empty() ) { return true; }
631  else { return false; }
632 }
reco::TrackRefVector inVertexInCalo_
bool empty() const
Is the RefVector empty.
Definition: RefVector.h:86
bool JetPlusTrackCorrector::vectorialCorrection ( ) const
inline

Returns value of configurable.

Definition at line 465 of file JetPlusTrackCorrector.h.

References vectorial_.

465 { return vectorial_; }

Member Data Documentation

double JetPlusTrackCorrector::dzVertexCut_
protected

Definition at line 418 of file JetPlusTrackCorrector.h.

Referenced by failTrackQuality().

const jpt::Map JetPlusTrackCorrector::efficiency_
protected

Definition at line 431 of file JetPlusTrackCorrector.h.

Referenced by correctAA(), and efficiencyMap().

double JetPlusTrackCorrector::elecMass_
protected

Definition at line 437 of file JetPlusTrackCorrector.h.

Referenced by elecCorrection().

edm::InputTag JetPlusTrackCorrector::electronIds_
protected

Definition at line 424 of file JetPlusTrackCorrector.h.

Referenced by getElectrons().

edm::InputTag JetPlusTrackCorrector::electrons_
protected

Definition at line 423 of file JetPlusTrackCorrector.h.

Referenced by getElectrons(), 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 432 of file JetPlusTrackCorrector.h.

Referenced by leakageMap().

double JetPlusTrackCorrector::maxEta_
protected

Definition at line 440 of file JetPlusTrackCorrector.h.

Referenced by canCorrect().

double JetPlusTrackCorrector::muonMass_
protected

Definition at line 436 of file JetPlusTrackCorrector.h.

Referenced by muonCorrection().

edm::InputTag JetPlusTrackCorrector::muons_
protected

Definition at line 422 of file JetPlusTrackCorrector.h.

Referenced by getMuons(), and JetPlusTrackCorrector().

double JetPlusTrackCorrector::pionMass_
protected

Definition at line 435 of file JetPlusTrackCorrector.h.

Referenced by pionCorrection(), and pionEfficiency().

double JetPlusTrackCorrector::ptErrorQuality_
protected

Definition at line 417 of file JetPlusTrackCorrector.h.

Referenced by failTrackQuality().

const jpt::Map JetPlusTrackCorrector::response_
protected

Definition at line 430 of file JetPlusTrackCorrector.h.

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

edm::InputTag JetPlusTrackCorrector::srcPVs_
protected

Definition at line 416 of file JetPlusTrackCorrector.h.

Referenced by matchTracks().

float JetPlusTrackCorrector::theResponseOfChargedWithEff
mutableprotected
float JetPlusTrackCorrector::theResponseOfChargedWithoutEff
mutableprotected
float JetPlusTrackCorrector::theSumEnergyWithEff
mutableprotected
float JetPlusTrackCorrector::theSumEnergyWithoutEff
mutableprotected

Definition at line 446 of file JetPlusTrackCorrector.h.

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

float JetPlusTrackCorrector::theSumPtForBeta
mutableprotected

Definition at line 447 of file JetPlusTrackCorrector.h.

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

float JetPlusTrackCorrector::theSumPtWithEff
mutableprotected
float JetPlusTrackCorrector::theSumPtWithoutEff
mutableprotected

Definition at line 444 of file JetPlusTrackCorrector.h.

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

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

Definition at line 427 of file JetPlusTrackCorrector.h.

Referenced by failTrackQuality(), and matchTracks().

bool JetPlusTrackCorrector::useEff_
protected

Definition at line 407 of file JetPlusTrackCorrector.h.

Referenced by JetPlusTrackCorrector(), and pionCorrection().

bool JetPlusTrackCorrector::useElecs_
protected

Definition at line 409 of file JetPlusTrackCorrector.h.

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

bool JetPlusTrackCorrector::useInConeTracks_
protected

Definition at line 403 of file JetPlusTrackCorrector.h.

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

bool JetPlusTrackCorrector::useMuons_
protected

Definition at line 408 of file JetPlusTrackCorrector.h.

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

bool JetPlusTrackCorrector::useOutOfConeTracks_
protected

Definition at line 404 of file JetPlusTrackCorrector.h.

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

bool JetPlusTrackCorrector::useOutOfVertexTracks_
protected

Definition at line 405 of file JetPlusTrackCorrector.h.

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

bool JetPlusTrackCorrector::usePions_
protected

Definition at line 406 of file JetPlusTrackCorrector.h.

Referenced by correction(), and JetPlusTrackCorrector().

bool JetPlusTrackCorrector::useTrackQuality_
protected

Definition at line 410 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_
mutableprotected

Definition at line 419 of file JetPlusTrackCorrector.h.

Referenced by failTrackQuality(), and matchTracks().