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 | 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_
 
jpt::Efficiency not_used efficiency_
 
double elecMass_
 
edm::InputTag electronIds_
 
edm::InputTag electrons_
 
int jetSplitMerge_
 
edm::InputTag jetTracksAtCalo_
 
edm::InputTag jetTracksAtVertex_
 
const jpt::Map leakage_
 
jpt::Efficiency not_used leakage_
 
double maxEta_
 
double muonMass_
 
edm::InputTag muons_
 
double pionMass_
 
double ptErrorQuality_
 
const jpt::Map response_
 
jpt::Efficiency not_used 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::Container
input_jetTracksAtCalo_token_
 
edm::EDGetTokenT
< reco::JetTracksAssociation::Container
input_jetTracksAtVertex_token_
 
edm::EDGetTokenT
< reco::VertexCollection
input_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 180 of file JetPlusTrackCorrector.h.

Member Typedef Documentation

Definition at line 280 of file JetPlusTrackCorrector.h.

Definition at line 193 of file JetPlusTrackCorrector.h.

Definition at line 194 of file JetPlusTrackCorrector.h.

Definition at line 195 of file JetPlusTrackCorrector.h.

Definition at line 279 of file JetPlusTrackCorrector.h.

Definition at line 278 of file JetPlusTrackCorrector.h.

Get reponses.

Definition at line 277 of file JetPlusTrackCorrector.h.

Definition at line 281 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 {
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 
101 
102 
103 }
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 &amp; 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:123
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 107 of file JetPlusTrackCorrector.cc.

107 {;}
JetPlusTrackCorrector::JetPlusTrackCorrector ( )
inlineprotected

Default constructor.

Definition at line 397 of file JetPlusTrackCorrector.h.

397 {;}

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 863 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, jpt::Map::nEtaBins(), jpt::Map::nPtBins(), SurfaceOrientation::outer, EnergyCorrector::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_.

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

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

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

Referenced by correction().

481 { 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 505 of file JetPlusTrackCorrector.h.

References metsig::jet.

Referenced by correction().

505  {
506  if ( jet.energy() > 0. && ( corrected.energy() / jet.energy() ) < 0. ) {
507  corrected = jet;
508  }
509  return corrected.energy() / jet.energy();
510 }
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 1245 of file JetPlusTrackCorrector.cc.

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

1250  {
1251 double mScale = 1.;
1252 double NewResponse = fJet.energy();
1253 
1254 //std::cout<<"---JetPlusTrackCorrector::correctAA, Jet initial: NewResponse="<<NewResponse <<" et = "<<fJet.et()
1255 // <<" pt= "<<fJet.pt()<<" eta="<<fJet.eta()<<" phi="<<fJet.phi() <<" ja="<<ja
1256 // <<" trBgOutOfVertex="<<trBgOutOfVertex.size()<< " trBgOutOfCalo="<<trBgOutOfCalo.size()<<std::endl;
1257 
1258 if( trBgOutOfVertex.size() == 0 ) return mScale;
1259  double EnergyOfBackgroundCharged = 0.;
1260  double ResponseOfBackgroundCharged = 0.;
1261  double NumberOfBackgroundChargedVertex = 0.;
1262  double NumberOfBackgroundChargedCalo = 0.;
1263 
1264 //
1265 // calculate the mean response
1266 //
1267 // double MeanResponseOfBackgroundCharged = 0.;
1268 // double MeanEnergyOfBackgroundCharged = 0.;
1269 
1270 //================= EnergyOfBackgroundCharged ==================>
1271  for( reco::TrackRefVector::iterator iBgtV = trBgOutOfVertex.begin(); iBgtV != trBgOutOfVertex.end(); iBgtV++)
1272  {
1273  // Temporary solution>>>>>> Remove tracks with pt>50 GeV
1274  // if( (**iBgtV).pt() >= 50. ) continue;
1275  //response_.value(ieta,ipt);
1276  double eta = fabs( (**iBgtV).eta() );
1277  double pt = fabs( (**iBgtV).pt() );
1278  uint32_t ieta = response_.etaBin( eta );
1279  uint32_t ipt = response_.ptBin( pt );
1280 
1281  if(fabs(fJet.eta() -(**iBgtV).eta()) > mConeSize) continue;
1282 
1283 // // Check bins (not for mips)
1284 // if ( ieta >= response_.nEtaBins() ) { continue; }
1285 // if ( ipt >= response_.nPtBins() ) { ipt = response_.nPtBins() - 1; }
1286 
1287  double echarBg=sqrt((**iBgtV).px()*(**iBgtV).px()+(**iBgtV).py()*(**iBgtV).py()+(**iBgtV).pz()*(**iBgtV).pz()+0.14*0.14);
1288 
1289 // ResponseOfBackgroundCharged += echarBg*response_.value(ieta,ipt)/efficiency_.value(ieta,ipt);
1290 
1291 // std::cout<<" Efficiency of bg tracks "<<efficiency_.value(ieta,ipt)<<std::endl;
1292 
1293  EnergyOfBackgroundCharged += echarBg/efficiency_.value(ieta,ipt);
1294 
1295  NumberOfBackgroundChargedVertex++;
1296 
1297  } // Energy BG tracks
1298 
1299 // std::cout<<" JetPlusTrackCorrector.cc, NumberOfBackgroundChargedVertex ="<<NumberOfBackgroundChargedVertex<<std::endl;
1300 
1301 //============= ResponseOfBackgroundCharged =======================>
1302 
1303  for( reco::TrackRefVector::iterator iBgtC = trBgOutOfCalo.begin(); iBgtC != trBgOutOfCalo.end(); iBgtC++)
1304  {
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) continue;
1314 
1315  // Check bins (not for mips)
1316  if ( ieta >= response_.nEtaBins() ) { continue; }
1317  if ( ipt >= response_.nPtBins() ) { ipt = response_.nPtBins() - 1; }
1318 
1319  double echarBg=sqrt((**iBgtC).px()*(**iBgtC).px()+(**iBgtC).py()*(**iBgtC).py()+(**iBgtC).pz()*(**iBgtC).pz()+0.14*0.14);
1320 
1321  ResponseOfBackgroundCharged += echarBg*response_.value(ieta,ipt)/efficiency_.value(ieta,ipt);
1322 
1323 // std::cout<<" Efficiency of bg tracks "<<efficiency_.value(ieta,ipt)<<std::endl;
1324 
1325 
1326  NumberOfBackgroundChargedCalo++;
1327 
1328  } // Response of BG tracks
1329 
1330 // std::cout<<" JetPlusTrackCorrector.cc, NumberOfBackgroundChargedCalo ="<<NumberOfBackgroundChargedCalo<<std::endl;
1331 //=================================================================>
1332 
1333 //=================================================================>
1334 // Look for in-out tracks
1335 
1336  double en = 0.;
1337  double px = 0.;
1338  double py = 0.;
1339  double pz = 0.;
1340 
1341  for(reco::TrackRefVector::const_iterator it = pioninout.begin(); it != pioninout.end(); it++) {
1342 
1343 // std::cout<<" Track in out, size= "<<pioninout.size()<<" p= "<<(*it)->p()<<" pt= "<<(*it)->pt()
1344 // <<" eta= "<<(*it)->eta()<<" phi= "<<(*it)->phi()<<std::endl;
1345 
1346  px+=(*it)->px();
1347  py+=(*it)->py();
1348  pz+=(*it)->pz();
1349  en+=sqrt((*it)->p()*(*it)->p()+0.14*0.14);
1350  }
1351 
1352 // Look for in-in tracks
1353 
1354  double en_in = 0.;
1355  double px_in = 0.;
1356  double py_in = 0.;
1357  double pz_in = 0.;
1358 
1359  for(reco::TrackRefVector::const_iterator it = pioninin.begin(); it != pioninin.end(); it++) {
1360 
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 //=>
1374 // double SquareEtaRingWithoutJets = 4*(M_PI*mConeSize - mConeSize*mConeSize);
1375  double SquareEtaRingWithoutJets = ja;
1376 
1377 // std::cout<<"---SquareEtaRingWithoutJets="<<SquareEtaRingWithoutJets<<std::endl;
1378 
1379  EnergyOfBackgroundCharged = EnergyOfBackgroundCharged/SquareEtaRingWithoutJets;
1380  ResponseOfBackgroundCharged = ResponseOfBackgroundCharged/SquareEtaRingWithoutJets;
1381  NumberOfBackgroundChargedVertex = NumberOfBackgroundChargedVertex/SquareEtaRingWithoutJets;
1382  NumberOfBackgroundChargedCalo = NumberOfBackgroundChargedCalo/SquareEtaRingWithoutJets;
1383 // NumberOfBackgroundCharged = NumberOfBackgroundCharged/SquareEtaRingWithoutJets;
1384 
1385 
1386  EnergyOfBackgroundCharged = M_PI*mConeSize*mConeSize*EnergyOfBackgroundCharged;
1387  ResponseOfBackgroundCharged = M_PI*mConeSize*mConeSize*ResponseOfBackgroundCharged;
1388  NumberOfBackgroundChargedVertex = M_PI*mConeSize*mConeSize*NumberOfBackgroundChargedVertex;
1389  NumberOfBackgroundChargedCalo = M_PI*mConeSize*mConeSize*NumberOfBackgroundChargedCalo;
1390 // NumberOfBackgroundCharged = M_PI*mConeSize*mConeSize*NumberOfBackgroundCharged;
1391 
1392 
1393  NewResponse = NewResponse - EnergyOfBackgroundCharged + ResponseOfBackgroundCharged;
1394 
1395 // std::cout<<"====JetPlusTrackCorrector, Old response=fJet.energy()"<<fJet.energy()
1396 // <<" EnergyOfBackgroundCharged="<<EnergyOfBackgroundCharged
1397 // <<" ResponseOfBackgroundCharged="<<ResponseOfBackgroundCharged
1398 // <<" NewResponse="<<NewResponse<<" NumberOfBackgroundChargedVertex="<<NumberOfBackgroundChargedVertex
1399 // <<" NumberOfBackgroundChargedCalo="<<NumberOfBackgroundChargedCalo<<std::endl;
1400 
1401  mScale = NewResponse/fJet.energy();
1402  if(mScale <0.) mScale=0.;
1403 return mScale;
1404 }
uint32_t nEtaBins() const
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:255
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:250
virtual double energy() const
energy
T sqrt(T t)
Definition: SSEVec.h:48
#define M_PI
uint32_t nPtBins() const
uint32_t ptBin(double pt) const
size_type size() const
Size of the RefVector.
Definition: RefVector.h:99
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 111 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, contentValuesCheck::ss, theResponseOfChargedWithEff, theResponseOfChargedWithoutEff, theSumEnergyWithEff, theSumEnergyWithoutEff, theSumPtForBeta, theSumPtWithEff, theSumPtWithoutEff, useElecs_, useMuons_, usePions_, vecResponse_, vectorial_, and verbose_.

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

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

Scalar correction method.

Definition at line 468 of file JetPlusTrackCorrector.h.

References correction().

474  {
475  P4 not_used_for_scalar_correction;
476  return correction( fJet, fJetcalo, event, setup, not_used_for_scalar_correction,pions,muons,elecs,validMatches );
477 }
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 224 of file JetPlusTrackCorrector.cc.

224  {
225  edm::LogError("JetPlusTrackCorrector")
226  << "JetPlusTrackCorrector can be run on entire event only";
227  return 1.;
228 }
double JetPlusTrackCorrector::correction ( const P4 jet) const

Correction method (not used)

Definition at line 232 of file JetPlusTrackCorrector.cc.

232  {
233  edm::LogError("JetPlusTrackCorrector")
234  << "JetPlusTrackCorrector can be run on entire event only";
235  return 1.;
236 }
const jpt::Map & JetPlusTrackCorrector::efficiencyMap ( ) const
inlineprotected

Definition at line 513 of file JetPlusTrackCorrector.h.

References efficiency_.

Referenced by pionCorrection().

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

Calculates correction to be applied using electrons.

Definition at line 757 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().

758  {
759 
760  P4 null; //@@ null 4-momentum
761 
762  if ( verbose_ ) {
763  std::stringstream ss;
764  ss << " Electron corrections:" << std::endl
765  << " In/In : " << "(" << elecs.inVertexInCalo_.size() << ") " << null.energy() << std::endl
766  << " In/Out : " << "(" << elecs.inVertexOutOfCalo_.size() << ") " << null.energy() << std::endl
767  << " Out/In : " << "(" << elecs.outOfVertexInCalo_.size() << ") " << null.energy();
768  edm::LogVerbatim("JetPlusTrackCorrector") << ss.str();
769  }
770 
771  return null; //@@ to be implemented
772 
773 }
math::XYZTLorentzVector P4
reco::TrackRefVector inVertexInCalo_
reco::TrackRefVector inVertexOutOfCalo_
reco::TrackRefVector outOfVertexInCalo_
size_type size() const
Size of the RefVector.
Definition: RefVector.h:99
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 498 of file JetPlusTrackCorrector.h.

References calculateCorr(), and elecMass_.

501  {
502  return calculateCorr( jet, elecs, not_used, in_cone_at_vertex, in_cone_at_calo_face, elecMass_, false, 0. );
503 }
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 479 of file JetPlusTrackCorrector.h.

479 { 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 1208 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().

1211  {
1212 
1213  //std::cout<<" NEW2" << std::endl;
1214 
1215  tracksthis = reco::JetTracksAssociation::getValue(jtV0,fJet);
1216  if(Excl.size() == 0) return;
1217  if(jetSplitMerge_<0) return;
1218 
1219  TrackRefs tracks = tracksthis;
1220  tracksthis.clear();
1221 
1222  //std::cout<<" Size of initial vector "<<tracks.size()<<" "<<fJet.et()<<" "<<fJet.eta()<<" "<<fJet.phi()<<std::endl;
1223 
1224  for(TrackRefs::iterator it = tracks.begin(); it != tracks.end(); it++ )
1225  {
1226 
1227  //std::cout<<" Track at calo surface "
1228  //<<" Track "<<(**it).eta()<<" "<<(**it).phi()<<std::endl;
1229  TrackRefs::iterator itold = find(Excl.begin(),Excl.end(),(*it));
1230  if(itold == Excl.end()) {
1231  tracksthis.push_back (*it);
1232  }
1233  //else { std::cout<<"Exclude "<<(**it).eta()<<" "<<(**it).phi()<<std::endl; }
1234 
1235  }
1236 
1237  //std::cout<<" Size of calo tracks "<<tracksthis.size()<<std::endl;
1238 
1239  return;
1240 
1241 }
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:38
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 580 of file JetPlusTrackCorrector.cc.

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

Referenced by matchTracks().

580  {
581 // if ( useTrackQuality_ && !(*itrk)->quality(trackQuality_) ) { return true; }
582 // else { return false; }
583 
584  bool retcode = false;
585 
586  if ( useTrackQuality_ && !(*itrk)->quality(trackQuality_) ) {
587  retcode = true; return retcode;
588  }
589  if(((*itrk)->ptError()/(*itrk)->pt()) > ptErrorQuality_) {
590  retcode = true; return retcode;
591  }
592  if(fabs((*itrk)->dz(vertex_)) > dzVertexCut_) {
593  retcode = true; return retcode;
594  }
595 
596  return retcode;
597 }
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 601 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().

603  {
604  it = find( jet_tracks.caloFace_.begin(),
605  jet_tracks.caloFace_.end(),
606  *itrk );
607  if ( it != jet_tracks.caloFace_.end() ) { return true; }
608  else { return false; }
609 }
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:255
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:250
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 613 of file JetPlusTrackCorrector.cc.

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

616  {
618  pions.inVertexInCalo_.end(),
619  *itrk );
621  muons.inVertexInCalo_.end(),
622  *itrk );
623  TrackRefs::iterator ie = find( elecs.inVertexInCalo_.begin(),
624  elecs.inVertexInCalo_.end(),
625  *itrk );
626  if ( ip == pions.inVertexInCalo_.end() &&
627  im == muons.inVertexInCalo_.end() &&
628  ie == elecs.inVertexInCalo_.end() ) { return false; }
629  else { return true; }
630 }
reco::TrackRefVector inVertexInCalo_
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:255
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:250
refhelper::RefVectorTrait< TrackCollection, T, F >::iterator_type iterator
Definition: RefVector.h:38
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 550 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().

552  {
553  event.getByToken(input_reco_elecs_token_, reco_elecs );
554  if ( !reco_elecs.isValid() || reco_elecs.failedToGet() ) {
555  edm::LogError("JetPlusTrackCorrector")
556  << "[JetPlusTrackCorrector::" << __func__ << "]"
557  << " Invalid handle to reco::GsfElectron collection"
558  << " with InputTag (label:instance:process) \""
559  << electrons_.label() << ":"
560  << electrons_.instance() << ":"
561  << electrons_.process() << "\"";
562  return false;
563  }
564  event.getByToken(input_reco_elec_ids_token_, reco_elec_ids );
565  if ( !reco_elec_ids.isValid() || reco_elec_ids.failedToGet() ) {
566  edm::LogError("JetPlusTrackCorrector")
567  << "[JetPlusTrackCorrector::" << __func__ << "]"
568  << " Invalid handle to reco::GsfElectron collection"
569  << " with InputTag (label:instance:process) \""
570  << electronIds_.label() << ":"
571  << electronIds_.instance() << ":"
572  << electronIds_.process() << "\"";
573  return false;
574  }
575  return true;
576 }
edm::EDGetTokenT< RecoElectronIds > input_reco_elec_ids_token_
edm::EDGetTokenT< RecoElectrons > input_reco_elecs_token_
bool isValid() const
Definition: HandleBase.h:75
bool failedToGet() const
Definition: HandleBase.h:79
std::string const & label() const
Definition: InputTag.h:43
std::string const & process() const
Definition: InputTag.h:47
std::string const & instance() const
Definition: InputTag.h:44
bool JetPlusTrackCorrector::getMuons ( const edm::Event event,
edm::Handle< RecoMuons > &  reco_muons 
) const
protected

Get RECO muons.

Definition at line 373 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().

373  {
374  event.getByToken(inut_reco_muons_token_, reco_muons );
375  if ( !reco_muons.isValid() || reco_muons.failedToGet() ) {
376  edm::LogError("JetPlusTrackCorrector")
377  << "[JetPlusTrackCorrector::" << __func__ << "]"
378  << " Invalid handle to reco::Muon collection"
379  << " with InputTag (label:instance:process) \""
380  << muons_.label() << ":"
381  << muons_.instance() << ":"
382  << muons_.process() << "\"";
383  return false;
384  }
385  return true;
386 }
edm::EDGetTokenT< RecoMuons > inut_reco_muons_token_
bool isValid() const
Definition: HandleBase.h:75
bool failedToGet() const
Definition: HandleBase.h:79
std::string const & label() const
Definition: InputTag.h:43
std::string const & process() const
Definition: InputTag.h:47
std::string const & instance() const
Definition: InputTag.h:44
double JetPlusTrackCorrector::getResponseOfChargedWithEff ( )
inline

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

Definition at line 235 of file JetPlusTrackCorrector.h.

References theResponseOfChargedWithEff.

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

Definition at line 239 of file JetPlusTrackCorrector.h.

References theSumEnergyWithEff.

double JetPlusTrackCorrector::getSumEnergyWithoutEff ( )
inline

Definition at line 240 of file JetPlusTrackCorrector.h.

References theSumEnergyWithoutEff.

double JetPlusTrackCorrector::getSumPtForBeta ( )
inline

Definition at line 241 of file JetPlusTrackCorrector.h.

References theSumPtForBeta.

double JetPlusTrackCorrector::getSumPtWithEff ( )
inline

Definition at line 237 of file JetPlusTrackCorrector.h.

References theSumPtWithEff.

double JetPlusTrackCorrector::getSumPtWithoutEff ( )
inline

Definition at line 238 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 777 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().

780  {
781 
782  // Correction to be applied to jet 4-momentum
783  P4 corr;
784 
785 // bool tracks_present = false;
786  bool tracks_present_inin = false;
787 
788  // Correct using pions in-cone at vertex
789 
790  if ( !pions.inVertexInCalo_.empty() ) {
792  TrackRefs::iterator jtrk = pions.inVertexInCalo_.end();
793  for ( ; itrk != jtrk; ++itrk ) {
794  corr += PtEtaPhiM( (*itrk)->pt(), (*itrk)->eta(), (*itrk)->phi(), 0. );
795 // tracks_present = true;
796  tracks_present_inin = true;
797  }
798  }
799 
800  if ( !pions.inVertexOutOfCalo_.empty() ) {
803  for ( ; itrk != jtrk; ++itrk ) {
804  corr += PtEtaPhiM( (*itrk)->pt(), (*itrk)->eta(), (*itrk)->phi(), 0. );
805 // tracks_present = true;
806  }
807  }
808 
809  // Correct using muons in-cone at vertex
810 
811  if ( !muons.inVertexInCalo_.empty() ) {
813  TrackRefs::iterator jtrk = muons.inVertexInCalo_.end();
814  for ( ; itrk != jtrk; ++itrk ) {
815  corr += PtEtaPhiM( (*itrk)->pt(), (*itrk)->eta(), (*itrk)->phi(), 0. );
816 // tracks_present = true;
817  }
818  }
819 
820  if ( !muons.inVertexOutOfCalo_.empty() ) {
823  for ( ; itrk != jtrk; ++itrk ) {
824  corr += PtEtaPhiM( (*itrk)->pt(), (*itrk)->eta(), (*itrk)->phi(), 0. );
825 // tracks_present = true;
826  }
827  }
828 
829  // Correct using electrons in-cone at vertex
830 
831  if ( !elecs.inVertexInCalo_.empty() ) {
833  TrackRefs::iterator jtrk = elecs.inVertexInCalo_.end();
834  for ( ; itrk != jtrk; ++itrk ) {
835  corr += PtEtaPhiM( (*itrk)->pt(), (*itrk)->eta(), (*itrk)->phi(), 0. );
836 // tracks_present = true;
837  }
838  }
839 
840  if ( !elecs.inVertexOutOfCalo_.empty() ) {
843  for ( ; itrk != jtrk; ++itrk ) {
844  corr += PtEtaPhiM( (*itrk)->pt(), (*itrk)->eta(), (*itrk)->phi(), 0. );
845 // tracks_present = true;
846  }
847  }
848 
849  // Adjust direction if in cone tracks are present
850 
851  if ( !tracks_present_inin ) { corr = corrected; }
852  else {
853  corr *= ( corr.P() > 0. ? corrected.P() / corr.P() : 1. );
854  corr = P4( corr.px(), corr.py(), corr.pz(), corrected.energy() );
855  }
856 
857  return corr;
858 
859 }
math::XYZTLorentzVector P4
reco::TrackRefVector inVertexInCalo_
reco::TrackRefVector inVertexOutOfCalo_
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:255
bool empty() const
Is the RefVector empty.
Definition: RefVector.h:96
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:250
refhelper::RefVectorTrait< TrackCollection, T, F >::iterator_type iterator
Definition: RefVector.h:38
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 273 of file JetPlusTrackCorrector.cc.

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

Referenced by matchTracks().

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

JTA using collections from event.

Definition at line 309 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().

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

Definition at line 514 of file JetPlusTrackCorrector.h.

References leakage_.

Referenced by pionCorrection().

514 { 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 1104 of file JetPlusTrackCorrector.cc.

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

Referenced by matchTracks().

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

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

Referenced by matchTracks().

1073  {
1074 
1075  if ( muons->empty() ) { return false; }
1076 
1077  RecoMuons::const_iterator imuon = muons->begin();
1078  RecoMuons::const_iterator jmuon = muons->end();
1079  for ( ; imuon != jmuon; ++imuon ) {
1080 
1081  if ( imuon->innerTrack().isNull() ||
1083  imuon->innerTrack()->pt() < 3.0 ) { continue; }
1084 
1085  if ( itrk->id() != imuon->innerTrack().id() ) {
1086  edm::LogError("JetPlusTrackCorrector")
1087  << "[JetPlusTrackCorrector::" << __func__ << "]"
1088  << "Product id of the tracks associated to the jet " << itrk->id()
1089  <<" is different from the product id of the inner track used for muons " << imuon->innerTrack().id()
1090  << "!" << std::endl
1091  << "Cannot compare tracks from different collection. Configuration Error!";
1092  return false;
1093  }
1094 
1095  if ( *itrk == imuon->innerTrack() ) { return true; }
1096  }
1097 
1098  return false;
1099 
1100 }
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 240 of file JetPlusTrackCorrector.cc.

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

Referenced by correction().

245  {
246 
247  // Associate tracks to jet at both the Vertex and CaloFace
248  JetTracks jet_tracks;
249  bool ok = jetTrackAssociation( fJet, event, setup, jet_tracks );
250 
251  // std::cout<<"JetPlusTrackCorrector::matchTracks, JetTrackAssociation ok="<<ok<<std::endl;
252 
253  if ( !ok ) { return false; }
254 
255  // Track collections propagated to Vertex and CaloFace for "pions", muons and electrons
256  matchTracks( jet_tracks, event, pions, muons, elecs );
257 
258  // Debug
259  if ( verbose_ ) {
260  std::stringstream ss;
261  ss << "Number of tracks:" << std::endl
262  << " In-cone at Vertex : " << jet_tracks.vertex_.size() << std::endl
263  << " In-cone at CaloFace : " << jet_tracks.caloFace_.size();
264  edm::LogVerbatim("JetPlusTrackCorrector") << ss.str();
265  }
266 
267  return true;
268 
269 }
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:99
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 390 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(), findQualityFiles::rr, edm::RefVector< C, T, F >::size(), contentValuesCheck::ss, theSumPtForBeta, trackQuality_, tracksInCalo(), useElecs_, useMuons_, useTrackQuality_, verbose_, jpt::JetTracks::vertex_, and vertex_.

394  {
395 
396  // Some init
397  pions.clear();
398  muons.clear();
399  elecs.clear();
400 
401  // Need vertex for track cleaning
402 
405  event.getByToken(input_pvCollection_token_, pvCollection);
406  if ( pvCollection.isValid() && pvCollection->size()>0 ) vertex_=pvCollection->begin()->position();
407 
408  // Get RECO muons
409  edm::Handle<RecoMuons> reco_muons;
410  bool found_reco_muons = true;
411  if ( useMuons_ ) { getMuons( event, reco_muons ); }
412 
413  // Get RECO electrons and their ids
414  edm::Handle<RecoElectrons> reco_elecs;
415  edm::Handle<RecoElectronIds> reco_elec_ids;
416  bool found_reco_elecs = true;
417  if ( useElecs_ ) { getElectrons( event, reco_elecs, reco_elec_ids ); }
418 
419  // Check RECO products found
420  if ( !found_reco_muons || !found_reco_elecs ) {
421  edm::LogError("JetPlusTrackCorrector")
422  << "[JetPlusTrackCorrector::" << __func__ << "]"
423  << " Unable to access RECO collections for muons and electrons";
424  return;
425  }
426 
427  // Identify pions/muons/electrons that are "in/in" and "in/out"
428  {
429  TrackRefs::const_iterator itrk = jet_tracks.vertex_.begin();
430  TrackRefs::const_iterator jtrk = jet_tracks.vertex_.end();
431 
432 // std::cout<<" Print theSumPtForBeta "<<theSumPtForBeta<<std::endl;
433 
434  double theSumPtForBetaOld = theSumPtForBeta;
435 
436  for ( ; itrk != jtrk; ++itrk ) {
437 
438  if ( useTrackQuality_ && (*itrk)->quality(trackQuality_) && theSumPtForBetaOld<=0. )
439  theSumPtForBeta += (**itrk).pt();
440 //
441 // Track either belongs to PV or do not belong to any vertex
442 
443  const reco::TrackBaseRef ttr1(*itrk);
444 
445 // std::cout<<" Size of PV "<<pvCollection->size()<<std::endl;
446 
447  int numpv=0;
448 
449  int itrack_belong = -1;
450 
451  for( reco::VertexCollection::const_iterator iv = pvCollection->begin(); iv != pvCollection->end(); iv++) {
452  numpv++;
453  std::vector<reco::TrackBaseRef>::const_iterator rr =
454  find((*iv).tracks_begin(),
455  (*iv).tracks_end(),
456  ttr1);
457  if( rr != (*iv).tracks_end() ) {
458  itrack_belong++;
459  // std::cout<<" Numpv "<<numpv<<std::endl;
460  break;
461  }
462 
463  } // all vertices
464 
465 // std::cout<<" Track in PV "<<itrack_belong<<" "<<numpv<<std::endl;
466 
467  if( numpv > 1 && itrack_belong == 0 ) {
468  // std::cout<<" Drop track "<<std::endl;
469  continue;
470  }
471 
472  // std::cout<<" we take it "<<numpv<<" "<<itrack_belong<<std::endl;
473 
474  if ( failTrackQuality(itrk) ) { continue; }
475 
476 // std::cout<<" Track accepted "<<std::endl;
477 
478  TrackRefs::iterator it = jet_tracks.caloFace_.end();
479  bool found = findTrack( jet_tracks, itrk, it );
480 
481 // std::cout<<"JetPlusTrackCorrector::matchTracks: jet_tracks.caloFace_.size()="<<jet_tracks.caloFace_.size()
482 // <<" found = "<<found<<std::endl;
483 
484  bool is_muon = useMuons_ && matchMuons( itrk, reco_muons );
485  bool is_ele = useElecs_ && matchElectrons( itrk, reco_elecs, reco_elec_ids );
486 
487  if ( found ) {
488  if ( is_muon ) { muons.inVertexInCalo_.push_back(*it); }
489  else if ( is_ele ) { elecs.inVertexInCalo_.push_back(*it); }
490  else { pions.inVertexInCalo_.push_back(*it); }
491  } else {
492  if ( is_muon ) { muons.inVertexOutOfCalo_.push_back(*itrk); }
493  else if ( is_ele ) { elecs.inVertexOutOfCalo_.push_back(*itrk); }
494  else {
495  pions.inVertexOutOfCalo_.push_back(*itrk);
496 // std::cout<<"JetPlusTrackCorrector::matchTracks: pions.inVertexOutOfCalo_.push_back(*itrk), size="
497 // <<pions.inVertexOutOfCalo_.size() <<std::endl;
498  }
499  }
500  }
501  }
502 
503  // Identify pions/muons/electrons that are "out/in"
504  {
505  TrackRefs::iterator itrk = jet_tracks.caloFace_.begin();
506  TrackRefs::iterator jtrk = jet_tracks.caloFace_.end();
507  for ( ; itrk != jtrk; ++itrk ) {
508 
509  if ( failTrackQuality(itrk) ) { continue; }
510 
511  if ( !tracksInCalo( pions, muons, elecs ) ) { continue; }
512 
513  bool found = findTrack( pions, muons, elecs, itrk );
514 
515  if ( !found ) {
516 
517  bool is_muon = useMuons_ && matchMuons( itrk, reco_muons );
518  bool is_ele = useElecs_ && matchElectrons( itrk, reco_elecs, reco_elec_ids );
519 
520  if ( is_muon ) { muons.outOfVertexInCalo_.push_back(*itrk); }
521  else if ( is_ele ) { elecs.outOfVertexInCalo_.push_back(*itrk); }
522  else { pions.outOfVertexInCalo_.push_back(*itrk); }
523 
524  }
525  }
526  }
527 
528  if ( verbose_ && edm::isDebugEnabled() ) {
529  std::stringstream ss;
530  ss << "[JetPlusTrackCorrector::" << __func__ << "] Number of tracks:" << std::endl
531  << " In-cone at Vertex and in-cone at CaloFace:" << std::endl
532  << " Pions : " << pions.inVertexInCalo_.size() << std::endl
533  << " Muons : " << muons.inVertexInCalo_.size() << std::endl
534  << " Electrons : " << elecs.inVertexInCalo_.size() << std::endl
535  << " In-cone at Vertex and out-of-cone at CaloFace:" << std::endl
536  << " Pions : " << pions.inVertexOutOfCalo_.size() << std::endl
537  << " Muons : " << muons.inVertexOutOfCalo_.size() << std::endl
538  << " Electrons : " << elecs.inVertexOutOfCalo_.size() << std::endl
539  << " Out-of-cone at Vertex and in-cone at CaloFace:" << std::endl
540  << " Pions : " << pions.outOfVertexInCalo_.size() << std::endl
541  << " Muons : " << muons.outOfVertexInCalo_.size() << std::endl
542  << " Electrons : " << elecs.outOfVertexInCalo_.size() << std::endl;
543  LogTrace("JetPlusTrackCorrector") << ss.str();
544  }
545 
546 }
bool isDebugEnabled()
reco::TrackRefVector inVertexInCalo_
reco::TrackRefVector vertex_
reco::TrackRefVector inVertexOutOfCalo_
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:255
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:250
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, T, F >::iterator_type iterator
Definition: RefVector.h:38
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:75
#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&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:62
size_type size() const
Size of the RefVector.
Definition: RefVector.h:99
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 718 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().

719  {
720 
721  P4 corr_muons;
722 
723  P4 corr_muons_in_cone;
724  P4 corr_muons_out_of_cone;
725  P4 corr_muons_out_of_vertex;
726 
727  if ( useInConeTracks_ ) {
728  corr_muons_in_cone = muonCorrection( jet, muons.inVertexInCalo_, true, true );
729  corr_muons += corr_muons_in_cone;
730  }
731 
732  if ( useOutOfConeTracks_ ) {
733  corr_muons_out_of_cone = muonCorrection( jet, muons.inVertexOutOfCalo_, true, false );
734  corr_muons += corr_muons_out_of_cone;
735  }
736 
737  if ( useOutOfVertexTracks_ ) {
738  corr_muons_out_of_vertex = muonCorrection( jet, muons.outOfVertexInCalo_, false, true );
739  corr_muons += corr_muons_out_of_vertex;
740  }
741 
742  if ( verbose_ ) {
743  std::stringstream ss;
744  ss << " Muon corrections:" << std::endl
745  << " In/In : " << "(" << muons.inVertexInCalo_.size() << ") " << corr_muons_in_cone.energy() << std::endl
746  << " In/Out : " << "(" << muons.inVertexOutOfCalo_.size() << ") " << corr_muons_out_of_cone.energy() << std::endl
747  << " Out/In : " << "(" << muons.outOfVertexInCalo_.size() << ") " << corr_muons_out_of_vertex.energy();
748  edm::LogVerbatim("JetPlusTrackCorrector") << ss.str();
749  }
750 
751  return corr_muons;
752 
753 }
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:99
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 491 of file JetPlusTrackCorrector.h.

References calculateCorr(), and muonMass_.

494  {
495  return calculateCorr( jet, muons, not_used, in_cone_at_vertex, in_cone_at_calo_face, muonMass_, false, 2. );
496 }
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.
tuple muons
Definition: patZpeak.py:38
JetPlusTrackCorrector::P4 JetPlusTrackCorrector::pionCorrection ( const P4 jet,
const jpt::MatchedTracks pions 
)

Calculates corrections to be applied using pions.

Definition at line 645 of file JetPlusTrackCorrector.cc.

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

Referenced by correction().

646  {
647 
648  P4 corr_pions;
649 /*
650  std::cout<<" pionCorrection::Corrections for jet "<< theResponseOfChargedWithEff <<" "<<
651  theResponseOfChargedWithoutEff <<" "<<
652  theSumPtWithEff <<" "<<
653  theSumPtWithoutEff <<" "<<
654  theSumEnergyWithEff <<" "<<
655  theSumEnergyWithoutEff <<std::endl;
656 */
657 
658  // In-cone
659 
660  P4 corr_pions_in_cone;
661  P4 corr_pions_eff_in_cone;
662  Efficiency in_cone( responseMap(), efficiencyMap(), leakageMap() );
663 
664  if ( useInConeTracks_ ) {
665  corr_pions_in_cone = pionCorrection( jet, pions.inVertexInCalo_, in_cone, true, true );
666  corr_pions += corr_pions_in_cone;
667  if ( useEff_ ) {
668  corr_pions_eff_in_cone = pionEfficiency( jet, in_cone, true );
669  corr_pions += corr_pions_eff_in_cone;
670  }
671  }
672 
673  // Out-of-cone
674 
675  P4 corr_pions_out_of_cone;
676  P4 corr_pions_eff_out_of_cone;
677  Efficiency out_of_cone( responseMap(), efficiencyMap(), leakageMap() );
678 
679  if ( useOutOfConeTracks_ ) {
680  corr_pions_out_of_cone = pionCorrection( jet, pions.inVertexOutOfCalo_, out_of_cone, true, false );
681  corr_pions += corr_pions_out_of_cone;
682  if ( useEff_ ) {
683  corr_pions_eff_out_of_cone = pionEfficiency( jet, out_of_cone, false );
684  corr_pions += corr_pions_eff_out_of_cone;
685  }
686  }
687 
688  // Out-of-vertex
689 
690  P4 corr_pions_out_of_vertex;
691  Efficiency not_used( responseMap(), efficiencyMap(), leakageMap() );
692 
693  if ( useOutOfVertexTracks_ ) {
694  corr_pions_out_of_vertex = pionCorrection( jet, pions.outOfVertexInCalo_, not_used, false, true );
695  corr_pions += corr_pions_out_of_vertex;
696  }
697 
698  if ( verbose_ ) {
699  std::stringstream ss;
700  ss << " Pion corrections:" << std::endl
701  << " In/In : " << "(" << pions.inVertexInCalo_.size() << ") " << corr_pions_in_cone.energy() << std::endl
702  << " In/Out : " << "(" << pions.inVertexOutOfCalo_.size() << ") " << corr_pions_out_of_cone.energy() << std::endl
703  << " Out/In : " << "(" << pions.outOfVertexInCalo_.size() << ") " << corr_pions_out_of_vertex.energy() << std::endl;
704  if ( useEff_ ) {
705  ss << " Pion efficiency corrections:" << std::endl
706  << " In/In : " << "(" << pions.inVertexInCalo_.size() << ") " << corr_pions_eff_in_cone.energy() << std::endl
707  << " In/Out : " << "(" << pions.inVertexOutOfCalo_.size() << ") " << corr_pions_eff_out_of_cone.energy();
708  }
709  edm::LogVerbatim("JetPlusTrackCorrector") << ss.str();
710  }
711 
712  return corr_pions;
713 
714 }
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:99
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 483 of file JetPlusTrackCorrector.h.

References calculateCorr(), and pionMass_.

487  {
488  return calculateCorr( jet, pions, eff, in_cone_at_vertex, in_cone_at_calo_face, pionMass_, true, -1. );
489 }
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 1008 of file JetPlusTrackCorrector.cc.

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

1010  {
1011 
1012  // Total correction to be applied
1013  P4 correction;
1014 
1015  double theSumResp = 0;
1016  double theSumPt = 0;
1017  double theSumEnergy = 0;
1018 
1019  // Iterate through eta/pt bins
1020  for ( uint32_t ieta = 0; ieta < response_.nEtaBins()-1; ++ieta ) {
1021  for ( uint32_t ipt = 0; ipt < response_.nPtBins()-1; ++ipt ) {
1022 
1023  // Check tracks are found in this eta/pt bin
1024  if ( !eff.nTrks(ieta,ipt) ) { continue; }
1025 
1026  for ( uint16_t ii = 0; ii < 2; ++ii ) {
1027 
1028  // Check which correction should be applied
1029  double corr = 0.;
1030  if ( ii == 0 ) { corr = eff.outOfConeCorr( ieta, ipt );}
1031  else if ( ii == 1 && in_cone_at_calo_face ) { corr = eff.inConeCorr( ieta, ipt );}
1032  else { continue; }
1033 
1034  // Calculate correction to be applied
1035  P4 corr_p4;
1036  if ( vectorial_ && vecResponse_ ) {
1037  double corr_eta = response_.binCenterEta(ieta);
1038  double corr_phi = jet.phi(); //@@ jet phi!
1039  double corr_pt = response_.binCenterPt(ipt);
1040  corr_p4 = PtEtaPhiM( corr_pt, corr_eta, corr_phi, pionMass_ ); //@@ E^2 = p^2 + m_pion^2, |p| calc'ed from pt bin
1041  corr_p4 *= ( corr_p4.energy() > 0. ? corr / corr_p4.energy() : 1. ); //@@ p4 scaled up by mean energy for bin
1042  } else {
1043  corr_p4 = ( jet.energy() > 0. ? corr / jet.energy() : 1. ) * jet;
1044  }
1045 
1046  // Apply correction
1047  if ( ii == 0 ) { correction += corr_p4; theSumPt += corr_p4.pt(); theSumEnergy += corr_p4.energy();} //@@ Add out-of-cone
1048  else if ( ii == 1 ) { correction -= corr_p4; theSumResp += corr_p4.energy();} //@@ Subtract in-cone
1049 
1050  }
1051 
1052  }
1053  }
1054 
1055  theResponseOfChargedWithEff += theSumResp;
1056  theSumPtWithEff += theSumPt;
1057  theSumEnergyWithEff += theSumEnergy;
1058 /*
1059  std::cout<<" Efficiency correction End::Corrections for jet "<< theResponseOfChargedWithEff <<" "<<
1060  theResponseOfChargedWithoutEff <<" "<<
1061  theSumPtWithEff <<" "<<
1062  theSumPtWithoutEff <<" "<<
1063  theSumEnergyWithEff <<" "<<
1064  theSumEnergyWithoutEff <<std::endl;
1065 */
1066  return correction;
1067 
1068 }
math::XYZTLorentzVector P4
uint32_t nEtaBins() const
int ii
Definition: cuy.py:588
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
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(), reco::deltaR2(), edm::RefVector< C, T, F >::end(), reco::LeafCandidate::et(), reco::LeafCandidate::eta(), reco::JetTracksAssociation::getValue(), cuy::ii, 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().

1143  {
1144 
1145  // std::cout<<" NEW1 Merge/Split schema "<<jetSplitMerge_<<std::endl;
1146 
1147  tracksthis = reco::JetTracksAssociation::getValue(jtV0,fJet);
1148 
1149  if(jetSplitMerge_<0) 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 
1162  double jetEta=fJet.eta();
1163  double jetPhi=fJet.phi();
1164  double jetEtIn=1.0/fJet.et();
1165 
1166  for(TrackRefs::iterator it = tracks.begin(); it != tracks.end(); it++ )
1167  {
1168  double trkEta=(**it).eta();
1169  double trkPhi=(**it).phi();
1170  double dR2this = deltaR2( jetEta, jetPhi, trkEta, trkPhi );
1171  // double dfi = fabs(fJet.phi()-(**it).phi());
1172  // if(dfi>4.*atan(1.))dfi = 8.*atan(1.)-dfi;
1173  // double deta = fJet.eta() - (**it).eta();
1174  // double dR2check = sqrt(dfi*dfi+deta*deta);
1175 
1176  double scalethis = dR2this;
1177  if(jetSplitMerge_ == 0) scalethis = 1.*jetEtIn;
1178  if(jetSplitMerge_ == 2) scalethis = dR2this*jetEtIn;
1179  tr++;
1180  int flag = 1;
1181  for(JetBaseRefIterator ii = theJets.begin(); ii != theJets.end(); ii++)
1182  {
1183  if(&(**ii) == &fJet ) {continue;}
1184  double dR2 = deltaR2( (*ii)->eta(), (*ii)->phi(), trkEta, trkPhi );
1185  double scale = dR2;
1186  if(jetSplitMerge_ == 0) scale = 1./(**ii).et();
1187  if(jetSplitMerge_ == 2) scale = dR2/(**ii).et();
1188  if(scale < scalethis) flag = 0;
1189 
1190  if(flag == 0) {
1191  //std::cout<<" Track belong to another jet also "<<dR2<<" "<<
1192  //(*ii)->et()<<" "<<(*ii)->eta()<<" "<< (*ii)->phi()<<" Track "<<(**it).eta()<<" "<<(**it).phi()<<" "<<scalethis<<" "<<scale<<" "<<flag<<std::endl;
1193  break;
1194  }
1195  }
1196 
1197  //std::cout<<" Track "<<tr<<" "<<flag<<" "<<dR2this<<" "<<dR2check<<" Jet "<<fJet.eta()<<" "<< fJet.phi()<<" Track "<<(**it).eta()<<" "<<(**it).phi()<<std::endl;
1198  if(flag == 1) {tracksthis.push_back (*it);}else{Excl.push_back (*it);}
1199  }
1200 
1201  //std::cout<<" The new size of tracks "<<tracksthis.size()<<" Excludede "<<Excl.size()<<std::endl;
1202  return;
1203 
1204 }
virtual double et() const
transverse energy
int ii
Definition: cuy.py:588
virtual double eta() const
momentum pseudorapidity
reco::TrackRefVector TrackRefs
refhelper::RefVectorTrait< TrackCollection, T, F >::iterator_type iterator
Definition: RefVector.h:38
double deltaR2(const T1 &t1, const T2 &t2)
Definition: deltaR.h:36
const reco::TrackRefVector & getValue(const Container &, const reco::JetBaseRef &)
get value for the association. Throw exception if no association found
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 512 of file JetPlusTrackCorrector.h.

References response_.

Referenced by pionCorrection().

512 { 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 634 of file JetPlusTrackCorrector.cc.

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

Referenced by matchTracks().

636  {
637  if ( !pions.inVertexInCalo_.empty() ||
638  !muons.inVertexInCalo_.empty() ||
639  !elecs.inVertexInCalo_.empty() ) { return true; }
640  else { return false; }
641 }
reco::TrackRefVector inVertexInCalo_
bool empty() const
Is the RefVector empty.
Definition: RefVector.h:96
bool JetPlusTrackCorrector::vectorialCorrection ( ) const
inline

Returns value of configurable.

Definition at line 480 of file JetPlusTrackCorrector.h.

References vectorial_.

480 { return vectorial_; }

Member Data Documentation

double JetPlusTrackCorrector::dzVertexCut_
protected

Definition at line 422 of file JetPlusTrackCorrector.h.

Referenced by failTrackQuality().

const jpt::Map JetPlusTrackCorrector::efficiency_
protected

Definition at line 435 of file JetPlusTrackCorrector.h.

Referenced by correctAA(), and efficiencyMap().

jpt::Efficiency not_used JetPlusTrackCorrector::efficiency_
protected

Definition at line 452 of file JetPlusTrackCorrector.h.

double JetPlusTrackCorrector::elecMass_
protected

Definition at line 441 of file JetPlusTrackCorrector.h.

Referenced by elecCorrection().

edm::InputTag JetPlusTrackCorrector::electronIds_
protected

Definition at line 428 of file JetPlusTrackCorrector.h.

Referenced by getElectrons(), and JetPlusTrackCorrector().

edm::InputTag JetPlusTrackCorrector::electrons_
protected

Definition at line 427 of file JetPlusTrackCorrector.h.

Referenced by getElectrons(), and JetPlusTrackCorrector().

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

Definition at line 458 of file JetPlusTrackCorrector.h.

Referenced by JetPlusTrackCorrector(), and jtaUsingEventData().

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

Definition at line 457 of file JetPlusTrackCorrector.h.

Referenced by JetPlusTrackCorrector(), and jtaUsingEventData().

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

Definition at line 460 of file JetPlusTrackCorrector.h.

Referenced by JetPlusTrackCorrector(), and matchTracks().

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

Definition at line 462 of file JetPlusTrackCorrector.h.

Referenced by getElectrons(), and JetPlusTrackCorrector().

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

Definition at line 461 of file JetPlusTrackCorrector.h.

Referenced by getElectrons(), and JetPlusTrackCorrector().

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

Definition at line 459 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 436 of file JetPlusTrackCorrector.h.

Referenced by leakageMap().

jpt::Efficiency not_used JetPlusTrackCorrector::leakage_
protected

Definition at line 452 of file JetPlusTrackCorrector.h.

double JetPlusTrackCorrector::maxEta_
protected

Definition at line 444 of file JetPlusTrackCorrector.h.

Referenced by canCorrect().

double JetPlusTrackCorrector::muonMass_
protected

Definition at line 440 of file JetPlusTrackCorrector.h.

Referenced by muonCorrection().

edm::InputTag JetPlusTrackCorrector::muons_
protected

Definition at line 426 of file JetPlusTrackCorrector.h.

Referenced by getMuons(), and JetPlusTrackCorrector().

double JetPlusTrackCorrector::pionMass_
protected

Definition at line 439 of file JetPlusTrackCorrector.h.

Referenced by pionCorrection(), and pionEfficiency().

double JetPlusTrackCorrector::ptErrorQuality_
protected

Definition at line 421 of file JetPlusTrackCorrector.h.

Referenced by failTrackQuality().

const jpt::Map JetPlusTrackCorrector::response_
protected

Definition at line 434 of file JetPlusTrackCorrector.h.

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

jpt::Efficiency not_used JetPlusTrackCorrector::response_
protected

Definition at line 452 of file JetPlusTrackCorrector.h.

edm::InputTag JetPlusTrackCorrector::srcPVs_
protected

Definition at line 420 of file JetPlusTrackCorrector.h.

Referenced by JetPlusTrackCorrector().

float JetPlusTrackCorrector::theResponseOfChargedWithEff
protected
float JetPlusTrackCorrector::theResponseOfChargedWithoutEff
protected
float JetPlusTrackCorrector::theSumEnergyWithEff
protected
float JetPlusTrackCorrector::theSumEnergyWithoutEff
protected

Definition at line 450 of file JetPlusTrackCorrector.h.

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

float JetPlusTrackCorrector::theSumPtForBeta
protected

Definition at line 451 of file JetPlusTrackCorrector.h.

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

float JetPlusTrackCorrector::theSumPtWithEff
protected
float JetPlusTrackCorrector::theSumPtWithoutEff
protected

Definition at line 448 of file JetPlusTrackCorrector.h.

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

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

Definition at line 431 of file JetPlusTrackCorrector.h.

Referenced by failTrackQuality(), and matchTracks().

bool JetPlusTrackCorrector::useEff_
protected

Definition at line 411 of file JetPlusTrackCorrector.h.

Referenced by JetPlusTrackCorrector(), and pionCorrection().

bool JetPlusTrackCorrector::useElecs_
protected

Definition at line 413 of file JetPlusTrackCorrector.h.

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

bool JetPlusTrackCorrector::useInConeTracks_
protected

Definition at line 407 of file JetPlusTrackCorrector.h.

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

bool JetPlusTrackCorrector::useMuons_
protected

Definition at line 412 of file JetPlusTrackCorrector.h.

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

bool JetPlusTrackCorrector::useOutOfConeTracks_
protected

Definition at line 408 of file JetPlusTrackCorrector.h.

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

bool JetPlusTrackCorrector::useOutOfVertexTracks_
protected

Definition at line 409 of file JetPlusTrackCorrector.h.

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

bool JetPlusTrackCorrector::usePions_
protected

Definition at line 410 of file JetPlusTrackCorrector.h.

Referenced by correction(), and JetPlusTrackCorrector().

bool JetPlusTrackCorrector::useTrackQuality_
protected

Definition at line 414 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 423 of file JetPlusTrackCorrector.h.

Referenced by failTrackQuality(), and matchTracks().