CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
pat::PATMuonProducer Class Reference

class definition More...

#include "PhysicsTools/PatAlgos/interface/PATMuonProducer.h"

Inheritance diagram for pat::PATMuonProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PATMuonProducer (const edm::ParameterSet &iConfig)
 default constructir More...
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 everything that needs to be done during the event loop More...
 
 ~PATMuonProducer ()
 default destructur More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 description of config file parameters More...
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Types

typedef std::vector
< edm::Handle
< edm::Association
< reco::GenParticleCollection > > > 
GenAssociations
 
typedef std::vector
< edm::Handle< edm::ValueMap
< IsoDeposit > > > 
IsoDepositMaps
 
typedef std::pair
< pat::IsolationKeys,
edm::InputTag
IsolationLabel
 
typedef std::vector
< IsolationLabel
IsolationLabels
 
typedef std::vector
< edm::Handle< edm::ValueMap
< double > > > 
IsolationValueMaps
 
typedef edm::RefToBase
< reco::Muon
MuonBaseRef
 typedefs for convenience More...
 

Private Member Functions

void embedHighLevel (pat::Muon &aMuon, reco::TrackRef track, reco::TransientTrack &tt, reco::Vertex &primaryVertex, bool primaryVertexIsValid, reco::BeamSpot &beamspot, bool beamspotIsValid)
 
void fillMuon (Muon &aMuon, const MuonBaseRef &muonRef, const reco::CandidateBaseRef &baseRef, const GenAssociations &genMatches, const IsoDepositMaps &deposits, const IsolationValueMaps &isolationValues) const
 common muon filling, for both the standard and PF2PAT case More...
 
template<typename T >
void readIsolationLabels (const edm::ParameterSet &iConfig, const char *psetName, IsolationLabels &labels, std::vector< edm::EDGetTokenT< edm::ValueMap< T > > > &tokens)
 

Private Attributes

bool addEfficiencies_
 add efficiencies to the muon (this will be data members of th muon even w/o embedding) More...
 
bool addGenMatch_
 add generator match information More...
 
bool addResolutions_
 add resolutions to the muon (this will be data members of th muon even w/o embedding) More...
 
edm::EDGetTokenT< reco::BeamSpotbeamLineToken_
 input source of the primary vertex/beamspot More...
 
edm::EDGetTokenT
< edm::ValueMap
< reco::MuonMETCorrectionData > > 
caloMETMuonCorrsToken_
 source of caloMET muon corrections More...
 
pat::helper::EfficiencyLoader efficiencyLoader_
 helper class to add efficiencies to the muon More...
 
bool embedBestTrack_
 embed the track from best muon measurement (global pflow) More...
 
bool embedCaloMETMuonCorrs_
 embed muon MET correction info for caloMET into the muon More...
 
bool embedCombinedMuon_
 embed track of the combined fit into the muon More...
 
bool embedDytMuon_
 embed track from DYT muon fit into the muon More...
 
bool embedGenMatch_
 embed the gen match information into the muon More...
 
bool embedHighLevelSelection_
 embed high level selection variables More...
 
bool embedPFCandidate_
 embed pfCandidates into the muon More...
 
bool embedPickyMuon_
 embed track from picky muon fit into the muon More...
 
bool embedStandAloneMuon_
 embed track from muon system into the muon More...
 
bool embedTcMETMuonCorrs_
 embed muon MET correction info for tcMET into the muon More...
 
bool embedTpfmsMuon_
 embed track from tpfms muon fit into the muon More...
 
bool embedTrack_
 embed the track from inner tracker into the muon More...
 
bool embedTunePBestTrack_
 embed the track from best muon measurement (muon only) More...
 
bool forceEmbedBestTrack_
 force separate embed of the best track even if already embedded More...
 
std::vector< edm::EDGetTokenT
< edm::Association
< reco::GenParticleCollection > > > 
genMatchTokens_
 input tags for generator match information More...
 
IsolationLabels isoDepositLabels_
 input source for isoDeposits More...
 
std::vector< edm::EDGetTokenT
< edm::ValueMap< IsoDeposit > > > 
isoDepositTokens_
 
IsolationLabels isolationValueLabels_
 input source isolation value maps More...
 
std::vector< edm::EDGetTokenT
< edm::ValueMap< double > > > 
isolationValueTokens_
 
pat::helper::MultiIsolator isolator_
 helper class to add userdefined isolation values to the muon More...
 
pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_
 isolation value pair for temporary storage before being folded into the muon More...
 
edm::EDGetTokenT< edm::View
< reco::Muon > > 
muonToken_
 input source More...
 
edm::EDGetTokenT
< reco::PFCandidateCollection
pfMuonToken_
 input source pfCandidates that will be to be transformed into pat::Muons, when using PF2PAT More...
 
GreaterByPt< MuonpTComparator_
 
edm::EDGetTokenT< std::vector
< reco::Vertex > > 
pvToken_
 input source of the primary vertex More...
 
pat::helper::KinResolutionsLoader resolutionLoader_
 helper class to add resolutions to the muon More...
 
edm::EDGetTokenT
< edm::ValueMap
< reco::MuonMETCorrectionData > > 
tcMETMuonCorrsToken_
 source of tcMET muon corrections More...
 
bool useParticleFlow_
 switch to use particle flow (PF2PAT) or not More...
 
bool usePV_
 use the primary vertex or the beamspot More...
 
pat::PATUserDataHelper< pat::MuonuserDataHelper_
 helper class to add userData to the muon More...
 
bool useUserData_
 add user data to the muon (this will be data members of th muon even w/o embedding) More...
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

class definition

Produces pat::Muon's.

The PATMuonProducer produces analysis-level pat::Muon's starting from a collection of objects of reco::Muon.

Author
Steven Lowette, Roger Wolf
Version
Id:
PATMuonProducer.h,v 1.29 2012/08/22 15:02:52 bellan Exp

Definition at line 42 of file PATMuonProducer.h.

Member Typedef Documentation

Definition at line 57 of file PATMuonProducer.h.

Definition at line 58 of file PATMuonProducer.h.

Definition at line 60 of file PATMuonProducer.h.

Definition at line 61 of file PATMuonProducer.h.

typedef std::vector< edm::Handle< edm::ValueMap<double> > > pat::PATMuonProducer::IsolationValueMaps
private

Definition at line 59 of file PATMuonProducer.h.

typedefs for convenience

Definition at line 56 of file PATMuonProducer.h.

Constructor & Destructor Documentation

PATMuonProducer::PATMuonProducer ( const edm::ParameterSet iConfig)
explicit

default constructir

Definition at line 46 of file PATMuonProducer.cc.

References addGenMatch_, caloMETMuonCorrsToken_, edm::EDConsumerBase::consumes(), embedBestTrack_, embedCaloMETMuonCorrs_, embedCombinedMuon_, embedDytMuon_, embedGenMatch_, embedPFCandidate_, embedPickyMuon_, embedStandAloneMuon_, embedTcMETMuonCorrs_, embedTpfmsMuon_, embedTrack_, embedTunePBestTrack_, edm::ParameterSet::existsAs(), forceEmbedBestTrack_, genMatchTokens_, edm::ParameterSet::getParameter(), muonToken_, pfMuonToken_, GlobalPosition_Frontier_DevDB_cff::tag, tcMETMuonCorrsToken_, useParticleFlow_, and edm::vector_transform().

46  : useUserData_(iConfig.exists("userData")),
47  isolator_(iConfig.exists("userIsolation") ? iConfig.getParameter<edm::ParameterSet>("userIsolation") : edm::ParameterSet(), consumesCollector(), false)
48 {
49  // input source
50  muonToken_ = consumes<edm::View<reco::Muon> >(iConfig.getParameter<edm::InputTag>( "muonSource" ));
51  // embedding of tracks
52  embedBestTrack_ = iConfig.getParameter<bool>( "embedMuonBestTrack" );
53  embedTunePBestTrack_ = iConfig.getParameter<bool>( "embedTunePMuonBestTrack" );
54  forceEmbedBestTrack_ = iConfig.getParameter<bool>( "forceBestTrackEmbedding" );
55  embedTrack_ = iConfig.getParameter<bool>( "embedTrack" );
56  embedCombinedMuon_ = iConfig.getParameter<bool>( "embedCombinedMuon" );
57  embedStandAloneMuon_ = iConfig.getParameter<bool>( "embedStandAloneMuon" );
58  // embedding of muon MET correction information
59  embedCaloMETMuonCorrs_ = iConfig.getParameter<bool>("embedCaloMETMuonCorrs" );
60  embedTcMETMuonCorrs_ = iConfig.getParameter<bool>("embedTcMETMuonCorrs" );
61  caloMETMuonCorrsToken_ = mayConsume<edm::ValueMap<reco::MuonMETCorrectionData> >(iConfig.getParameter<edm::InputTag>("caloMETMuonCorrs" ));
62  tcMETMuonCorrsToken_ = mayConsume<edm::ValueMap<reco::MuonMETCorrectionData> >(iConfig.getParameter<edm::InputTag>("tcMETMuonCorrs" ));
63  // pflow specific configurables
64  useParticleFlow_ = iConfig.getParameter<bool>( "useParticleFlow" );
65  embedPFCandidate_ = iConfig.getParameter<bool>( "embedPFCandidate" );
66  pfMuonToken_ = mayConsume<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>( "pfMuonSource" ));
67  // embedding of tracks from TeV refit
68  embedPickyMuon_ = iConfig.getParameter<bool>( "embedPickyMuon" );
69  embedTpfmsMuon_ = iConfig.getParameter<bool>( "embedTpfmsMuon" );
70  embedDytMuon_ = iConfig.getParameter<bool>( "embedDytMuon" );
71  // Monte Carlo matching
72  addGenMatch_ = iConfig.getParameter<bool>( "addGenMatch" );
73  if (addGenMatch_) {
74  embedGenMatch_ = iConfig.getParameter<bool>( "embedGenMatch" );
75  if (iConfig.existsAs<edm::InputTag>("genParticleMatch")) {
77  }
78  else {
79  genMatchTokens_ = edm::vector_transform(iConfig.getParameter<std::vector<edm::InputTag> >( "genParticleMatch" ), [this](edm::InputTag const & tag){return consumes<edm::Association<reco::GenParticleCollection> >(tag);});
80  }
81  }
82  // efficiencies
83  addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies");
84  if(addEfficiencies_){
86  }
87  // resolutions
88  addResolutions_ = iConfig.getParameter<bool>("addResolutions");
89  if (addResolutions_) {
91  }
92  // read isoDeposit labels, for direct embedding
94  // read isolation value labels, for direct embedding
96  // check to see if the user wants to add user data
97  if( useUserData_ ){
99  }
100  // embed high level selection variables
101  usePV_ = true;
102  embedHighLevelSelection_ = iConfig.getParameter<bool>("embedHighLevelSelection");
103  if ( embedHighLevelSelection_ ) {
104  beamLineToken_ = consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamLineSrc"));
105  usePV_ = iConfig.getParameter<bool>("usePV");
106  pvToken_ = consumes<std::vector<reco::Vertex> >(iConfig.getParameter<edm::InputTag>("pvSrc"));
107  }
108  // produces vector of muons
109  produces<std::vector<Muon> >();
110 }
bool embedTpfmsMuon_
embed track from tpfms muon fit into the muon
bool useUserData_
add user data to the muon (this will be data members of th muon even w/o embedding) ...
T getParameter(std::string const &) const
Assists in assimilating all pat::UserData into pat objects.
bool usePV_
use the primary vertex or the beamspot
edm::EDGetTokenT< edm::ValueMap< reco::MuonMETCorrectionData > > tcMETMuonCorrsToken_
source of tcMET muon corrections
bool embedTcMETMuonCorrs_
embed muon MET correction info for tcMET into the muon
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:184
edm::EDGetTokenT< std::vector< reco::Vertex > > pvToken_
input source of the primary vertex
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
input source
bool addEfficiencies_
add efficiencies to the muon (this will be data members of th muon even w/o embedding) ...
edm::EDGetTokenT< edm::ValueMap< reco::MuonMETCorrectionData > > caloMETMuonCorrsToken_
source of caloMET muon corrections
bool embedCaloMETMuonCorrs_
embed muon MET correction info for caloMET into the muon
bool exists(std::string const &parameterName) const
checks if a parameter exists
bool embedBestTrack_
embed the track from best muon measurement (global pflow)
bool addResolutions_
add resolutions to the muon (this will be data members of th muon even w/o embedding) ...
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
edm::EDGetTokenT< reco::PFCandidateCollection > pfMuonToken_
input source pfCandidates that will be to be transformed into pat::Muons, when using PF2PAT ...
pat::helper::MultiIsolator isolator_
helper class to add userdefined isolation values to the muon
std::vector< edm::EDGetTokenT< edm::ValueMap< IsoDeposit > > > isoDepositTokens_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< reco::BeamSpot > beamLineToken_
input source of the primary vertex/beamspot
bool useParticleFlow_
switch to use particle flow (PF2PAT) or not
pat::PATUserDataHelper< pat::Muon > userDataHelper_
helper class to add userData to the muon
bool embedStandAloneMuon_
embed track from muon system into the muon
bool embedTrack_
embed the track from inner tracker into the muon
bool addGenMatch_
add generator match information
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
void readIsolationLabels(const edm::ParameterSet &iConfig, const char *psetName, IsolationLabels &labels, std::vector< edm::EDGetTokenT< edm::ValueMap< T > > > &tokens)
bool embedTunePBestTrack_
embed the track from best muon measurement (muon only)
pat::helper::EfficiencyLoader efficiencyLoader_
helper class to add efficiencies to the muon
bool embedPickyMuon_
embed track from picky muon fit into the muon
bool embedDytMuon_
embed track from DYT muon fit into the muon
bool embedGenMatch_
embed the gen match information into the muon
IsolationLabels isoDepositLabels_
input source for isoDeposits
std::vector< edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > > genMatchTokens_
input tags for generator match information
IsolationLabels isolationValueLabels_
input source isolation value maps
bool forceEmbedBestTrack_
force separate embed of the best track even if already embedded
bool embedPFCandidate_
embed pfCandidates into the muon
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueTokens_
bool embedCombinedMuon_
embed track of the combined fit into the muon
pat::helper::KinResolutionsLoader resolutionLoader_
helper class to add resolutions to the muon
bool embedHighLevelSelection_
embed high level selection variables
PATMuonProducer::~PATMuonProducer ( )

default destructur

Definition at line 113 of file PATMuonProducer.cc.

114 {
115 }

Member Function Documentation

void PATMuonProducer::embedHighLevel ( pat::Muon aMuon,
reco::TrackRef  track,
reco::TransientTrack tt,
reco::Vertex primaryVertex,
bool  primaryVertexIsValid,
reco::BeamSpot beamspot,
bool  beamspotIsValid 
)
private

Definition at line 546 of file PATMuonProducer.cc.

References pat::Muon::BS2D, pat::Muon::BS3D, reco::BeamSpot::position(), pat::Muon::PV2D, pat::Muon::PV3D, query::result, reco::BeamSpot::rotatedCovariance3D(), pat::Muon::setDB(), IPTools::signedImpactParameter3D(), and IPTools::signedTransverseImpactParameter().

Referenced by produce().

554 {
555  // Correct to PV
556 
557  // PV2D
558  std::pair<bool,Measurement1D> result =
560  GlobalVector(track->px(),
561  track->py(),
562  track->pz()),
563  primaryVertex);
564  double d0_corr = result.second.value();
565  double d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
566  aMuon.setDB( d0_corr, d0_err, pat::Muon::PV2D);
567 
568 
569  // PV3D
570  result =
572  GlobalVector(track->px(),
573  track->py(),
574  track->pz()),
575  primaryVertex);
576  d0_corr = result.second.value();
577  d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
578  aMuon.setDB( d0_corr, d0_err, pat::Muon::PV3D);
579 
580 
581  // Correct to beam spot
582  // make a fake vertex out of beam spot
583  reco::Vertex vBeamspot(beamspot.position(), beamspot.rotatedCovariance3D());
584 
585  // BS2D
586  result =
588  GlobalVector(track->px(),
589  track->py(),
590  track->pz()),
591  vBeamspot);
592  d0_corr = result.second.value();
593  d0_err = beamspotIsValid ? result.second.error() : -1.0;
594  aMuon.setDB( d0_corr, d0_err, pat::Muon::BS2D);
595 
596  // BS3D
597  result =
599  GlobalVector(track->px(),
600  track->py(),
601  track->pz()),
602  vBeamspot);
603  d0_corr = result.second.value();
604  d0_err = beamspotIsValid ? result.second.error() : -1.0;
605  aMuon.setDB( d0_corr, d0_err, pat::Muon::BS3D);
606 }
std::pair< bool, Measurement1D > signedTransverseImpactParameter(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:50
std::pair< bool, Measurement1D > signedImpactParameter3D(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:71
tuple result
Definition: query.py:137
const Point & position() const
position
Definition: BeamSpot.h:62
Covariance3DMatrix rotatedCovariance3D() const
Definition: BeamSpot.cc:78
void setDB(double dB, double edB, IpType type=None)
Definition: Muon.h:216
Global3DVector GlobalVector
Definition: GlobalVector.h:10
void PATMuonProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

description of config file parameters

Definition at line 447 of file PATMuonProducer.cc.

References edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addNode(), edm::ParameterSetDescription::addOptional(), pat::helper::KinResolutionsLoader::fillDescription(), pat::PATUserDataHelper< ObjectType >::fillDescription(), edm::ParameterSetDescription::setAllowAnything(), edm::ParameterSetDescription::setComment(), and edm::ParameterDescriptionNode::setComment().

448 {
450  iDesc.setComment("PAT muon producer module");
451 
452  // input source
453  iDesc.add<edm::InputTag>("muonSource", edm::InputTag("no default"))->setComment("input collection");
454 
455  // embedding
456  iDesc.add<bool>("embedMuonBestTrack", true)->setComment("embed muon best track (global pflow)");
457  iDesc.add<bool>("embedTunePMuonBestTrack", true)->setComment("embed muon best track (muon only)");
458  iDesc.add<bool>("forceBestTrackEmbedding", true)->setComment("force embedding separately the best tracks even if they're already embedded e.g. as tracker or global tracks");
459  iDesc.add<bool>("embedTrack", true)->setComment("embed external track");
460  iDesc.add<bool>("embedStandAloneMuon", true)->setComment("embed external stand-alone muon");
461  iDesc.add<bool>("embedCombinedMuon", false)->setComment("embed external combined muon");
462  iDesc.add<bool>("embedPickyMuon", false)->setComment("embed external picky track");
463  iDesc.add<bool>("embedTpfmsMuon", false)->setComment("embed external tpfms track");
464  iDesc.add<bool>("embedDytMuon", false)->setComment("embed external dyt track ");
465 
466  // embedding of MET muon corrections
467  iDesc.add<bool>("embedCaloMETMuonCorrs", true)->setComment("whether to add MET muon correction for caloMET or not");
468  iDesc.add<edm::InputTag>("caloMETMuonCorrs", edm::InputTag("muonMETValueMapProducer" , "muCorrData"))->setComment("source of MET muon corrections for caloMET");
469  iDesc.add<bool>("embedTcMETMuonCorrs", true)->setComment("whether to add MET muon correction for tcMET or not");
470  iDesc.add<edm::InputTag>("tcMETMuonCorrs", edm::InputTag("muonTCMETValueMapProducer" , "muCorrData"))->setComment("source of MET muon corrections for tcMET");
471 
472  // pf specific parameters
473  iDesc.add<edm::InputTag>("pfMuonSource", edm::InputTag("pfMuons"))->setComment("particle flow input collection");
474  iDesc.add<bool>("useParticleFlow", false)->setComment("whether to use particle flow or not");
475  iDesc.add<bool>("embedPFCandidate", false)->setComment("embed external particle flow object");
476 
477  // MC matching configurables
478  iDesc.add<bool>("addGenMatch", true)->setComment("add MC matching");
479  iDesc.add<bool>("embedGenMatch", false)->setComment("embed MC matched MC information");
480  std::vector<edm::InputTag> emptySourceVector;
481  iDesc.addNode( edm::ParameterDescription<edm::InputTag>("genParticleMatch", edm::InputTag(), true) xor
482  edm::ParameterDescription<std::vector<edm::InputTag> >("genParticleMatch", emptySourceVector, true)
483  )->setComment("input with MC match information");
484 
486 
487  // IsoDeposit configurables
488  edm::ParameterSetDescription isoDepositsPSet;
489  isoDepositsPSet.addOptional<edm::InputTag>("tracker");
490  isoDepositsPSet.addOptional<edm::InputTag>("ecal");
491  isoDepositsPSet.addOptional<edm::InputTag>("hcal");
492  isoDepositsPSet.addOptional<edm::InputTag>("particle");
493  isoDepositsPSet.addOptional<edm::InputTag>("pfChargedHadrons");
494  isoDepositsPSet.addOptional<edm::InputTag>("pfChargedAll");
495  isoDepositsPSet.addOptional<edm::InputTag>("pfPUChargedHadrons");
496  isoDepositsPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
497  isoDepositsPSet.addOptional<edm::InputTag>("pfPhotons");
498  isoDepositsPSet.addOptional<std::vector<edm::InputTag> >("user");
499  iDesc.addOptional("isoDeposits", isoDepositsPSet);
500 
501  // isolation values configurables
502  edm::ParameterSetDescription isolationValuesPSet;
503  isolationValuesPSet.addOptional<edm::InputTag>("tracker");
504  isolationValuesPSet.addOptional<edm::InputTag>("ecal");
505  isolationValuesPSet.addOptional<edm::InputTag>("hcal");
506  isolationValuesPSet.addOptional<edm::InputTag>("particle");
507  isolationValuesPSet.addOptional<edm::InputTag>("pfChargedHadrons");
508  isolationValuesPSet.addOptional<edm::InputTag>("pfChargedAll");
509  isolationValuesPSet.addOptional<edm::InputTag>("pfPUChargedHadrons");
510  isolationValuesPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
511  isolationValuesPSet.addOptional<edm::InputTag>("pfPhotons");
512  iDesc.addOptional("isolationValues", isolationValuesPSet);
513 
514  // Efficiency configurables
515  edm::ParameterSetDescription efficienciesPSet;
516  efficienciesPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
517  iDesc.add("efficiencies", efficienciesPSet);
518  iDesc.add<bool>("addEfficiencies", false);
519 
520  // Check to see if the user wants to add user data
521  edm::ParameterSetDescription userDataPSet;
523  iDesc.addOptional("userData", userDataPSet);
524 
525  edm::ParameterSetDescription isolationPSet;
526  isolationPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
527  iDesc.add("userIsolation", isolationPSet);
528 
529  iDesc.add<bool>("embedHighLevelSelection", true)->setComment("embed high level selection");
530  edm::ParameterSetDescription highLevelPSet;
531  highLevelPSet.setAllowAnything();
532  iDesc.addNode( edm::ParameterDescription<edm::InputTag>("beamLineSrc", edm::InputTag(), true)
533  )->setComment("input with high level selection");
535  )->setComment("input with high level selection");
536  iDesc.addNode( edm::ParameterDescription<bool>("usePV", bool(), true)
537  )->setComment("input with high level selection, use primary vertex (true) or beam line (false)");
538 
539  //descriptions.add("PATMuonProducer", iDesc);
540 }
void setComment(std::string const &value)
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
void setAllowAnything()
allow any parameter label/value pairs
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
static void fillDescription(edm::ParameterSetDescription &iDesc)
void setComment(std::string const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescription(edm::ParameterSetDescription &iDesc)
Method for documentation and validation of PSet.
void PATMuonProducer::fillMuon ( Muon aMuon,
const MuonBaseRef muonRef,
const reco::CandidateBaseRef baseRef,
const GenAssociations genMatches,
const IsoDepositMaps deposits,
const IsolationValueMaps isolationValues 
) const
private

common muon filling, for both the standard and PF2PAT case

Definition at line 370 of file PATMuonProducer.cc.

References addGenMatch_, pat::PATObject< ObjectType >::addGenParticleRef(), edm::contains(), reco::Muon::DYT, efficiencyLoader_, embedBestTrack_, pat::Muon::embedCombinedMuon(), embedCombinedMuon_, pat::Muon::embedDytMuon(), embedDytMuon_, embedGenMatch_, pat::PATObject< ObjectType >::embedGenParticle(), pat::Muon::embedMuonBestTrack(), pat::Muon::embedPickyMuon(), embedPickyMuon_, pat::Muon::embedStandAloneMuon(), embedStandAloneMuon_, pat::Muon::embedTpfmsMuon(), embedTpfmsMuon_, pat::Muon::embedTrack(), embedTrack_, embedTunePBestTrack_, pat::Muon::embedTunePMuonBestTrack(), pat::helper::EfficiencyLoader::enabled(), pat::helper::KinResolutionsLoader::enabled(), first, forceEmbedBestTrack_, i, edm::RefToBase< T >::id(), reco::Muon::isAValidMuonTrack(), reco::Muon::isGlobalMuon(), isoDepositLabels_, isolationValueLabels_, j, n, pat::Muon::pfCandidateRef(), reco::Muon::Picky, resolutionLoader_, pat::helper::EfficiencyLoader::setEfficiencies(), pat::Lepton< LeptonType >::setIsoDeposit(), pat::Lepton< LeptonType >::setIsolation(), reco::LeafCandidate::setP4(), pat::helper::KinResolutionsLoader::setResolutions(), source, reco::Muon::TPFMS, and useParticleFlow_.

Referenced by produce().

371 {
372  // in the particle flow algorithm,
373  // the muon momentum is recomputed.
374  // the new value is stored as the momentum of the
375  // resulting PFCandidate of type Muon, and choosen
376  // as the pat::Muon momentum
377  if (useParticleFlow_)
378  aMuon.setP4( aMuon.pfCandidateRef()->p4() );
379  if (embedTrack_) aMuon.embedTrack();
382 
383  // embed the TeV refit track refs (only available for globalMuons)
384  if (aMuon.isGlobalMuon()) {
386  aMuon.embedPickyMuon();
388  aMuon.embedTpfmsMuon();
390  aMuon.embedDytMuon();
391  }
392 
393  // embed best tracks (at the end, so unless forceEmbedBestTrack_ is true we can save some space not embedding them twice)
396 
397  // store the match to the generated final state muons
398  if (addGenMatch_) {
399  for(size_t i = 0, n = genMatches.size(); i < n; ++i) {
400  reco::GenParticleRef genMuon = (*genMatches[i])[baseRef];
401  aMuon.addGenParticleRef(genMuon);
402  }
403  if (embedGenMatch_) aMuon.embedGenParticle();
404  }
405  if (efficiencyLoader_.enabled()) {
406  efficiencyLoader_.setEfficiencies( aMuon, muonRef );
407  }
408 
409  for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
410  if(useParticleFlow_) {
411  if (deposits[j]->contains(baseRef.id())) {
412  aMuon.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[baseRef]);
413  } else if (deposits[j]->contains(muonRef.id())){
414  aMuon.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[muonRef]);
415  } else {
416  reco::CandidatePtr source = aMuon.pfCandidateRef()->sourceCandidatePtr(0);
417  aMuon.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[source]);
418  }
419  }
420  else{
421  aMuon.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[muonRef]);
422  }
423  }
424 
425  for (size_t j = 0; j<isolationValues.size(); ++j) {
426  if(useParticleFlow_) {
427  if (isolationValues[j]->contains(baseRef.id())) {
428  aMuon.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[baseRef]);
429  } else if (isolationValues[j]->contains(muonRef.id())) {
430  aMuon.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[muonRef]);
431  } else {
432  reco::CandidatePtr source = aMuon.pfCandidateRef()->sourceCandidatePtr(0);
433  aMuon.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[source]);
434  }
435  }
436  else{
437  aMuon.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[muonRef]);
438  }
439  }
440 
441  if (resolutionLoader_.enabled()) {
443  }
444 }
bool embedTpfmsMuon_
embed track from tpfms muon fit into the muon
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
int i
Definition: DBlmapReader.cc:9
void embedStandAloneMuon()
set reference to Track reconstructed in the muon detector only (reimplemented from reco::Muon) ...
Definition: Muon.cc:303
void setIsolation(IsolationKeys key, float value)
Definition: Lepton.h:98
bool contains(EventRange const &lh, EventID const &rh)
Definition: EventRange.cc:38
void embedMuonBestTrack(bool force=false)
embed the Track selected to be the best measurement of the muon parameters
Definition: Muon.cc:245
bool isGlobalMuon() const
Definition: Muon.h:218
bool embedBestTrack_
embed the track from best muon measurement (global pflow)
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
ProductID id() const
Definition: RefToBase.h:221
void embedPickyMuon()
embed reference to the above picky Track
Definition: Muon.cc:336
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
void setIsoDeposit(IsolationKeys key, const IsoDeposit &dep)
Sets the IsoDeposit associated with some key; if it is already existent, it is overwritten.
Definition: Lepton.h:175
void embedCombinedMuon()
set reference to Track reconstructed in both tracked and muon detector (reimplemented from reco::Muon...
Definition: Muon.cc:313
bool useParticleFlow_
switch to use particle flow (PF2PAT) or not
bool isAValidMuonTrack(const MuonTrackType &type) const
Definition: Muon.cc:853
bool embedStandAloneMuon_
embed track from muon system into the muon
reco::PFCandidateRef pfCandidateRef() const
reference to the source IsolatedPFCandidates
Definition: Muon.cc:228
bool embedTrack_
embed the track from inner tracker into the muon
bool addGenMatch_
add generator match information
void embedGenParticle()
Definition: PATObject.h:677
void embedTrack()
set reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.cc:293
int j
Definition: DBlmapReader.cc:9
bool first
Definition: L1TdeRCT.cc:75
void embedTpfmsMuon()
embed reference to the above tpfms Track
Definition: Muon.cc:346
void addGenParticleRef(const reco::GenParticleRef &ref)
Definition: PATObject.h:661
void embedDytMuon()
embed reference to the above dyt Track
Definition: Muon.cc:356
bool embedTunePBestTrack_
embed the track from best muon measurement (muon only)
void setEfficiencies(pat::PATObject< T > &obj, const R &originalRef) const
Sets the efficiencies for this object, using the reference to the original objects.
void embedTunePMuonBestTrack(bool force=false)
embed the Track selected to be the best measurement of the muon parameters
Definition: Muon.cc:267
pat::helper::EfficiencyLoader efficiencyLoader_
helper class to add efficiencies to the muon
bool embedPickyMuon_
embed track from picky muon fit into the muon
bool embedDytMuon_
embed track from DYT muon fit into the muon
virtual void setP4(const LorentzVector &p4) GCC11_FINAL
set 4-momentum
bool embedGenMatch_
embed the gen match information into the muon
IsolationLabels isoDepositLabels_
input source for isoDeposits
IsolationLabels isolationValueLabels_
input source isolation value maps
bool forceEmbedBestTrack_
force separate embed of the best track even if already embedded
bool embedCombinedMuon_
embed track of the combined fit into the muon
pat::helper::KinResolutionsLoader resolutionLoader_
helper class to add resolutions to the muon
static std::string const source
Definition: EdmProvDump.cc:43
void PATMuonProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

everything that needs to be done during the event loop

Implements edm::EDProducer.

Definition at line 117 of file PATMuonProducer.cc.

References IPTools::absoluteTransverseImpactParameter(), addGenMatch_, beamLineToken_, SiPixelRawToDigiRegional_cfi::beamSpot, pat::helper::MultiIsolator::beginEvent(), caloMETMuonCorrsToken_, efficiencyLoader_, pat::Muon::embedCaloMETMuonCorrs(), embedCaloMETMuonCorrs_, embedGenMatch_, embedHighLevel(), embedHighLevelSelection_, pat::Muon::embedPFCandidate(), embedPFCandidate_, pat::Muon::embedTcMETMuonCorrs(), embedTcMETMuonCorrs_, pat::helper::EfficiencyLoader::enabled(), pat::helper::KinResolutionsLoader::enabled(), pat::helper::MultiIsolator::enabled(), pat::helper::MultiIsolator::endEvent(), pat::helper::MultiIsolator::fill(), fillMuon(), genMatchTokens_, edm::EventSetup::get(), edm::Event::getByToken(), i, customizeTrackingMonitorSeedNumber::idx, cmsHarvester::index, susybsm::HSCParticleType::innerTrack, edm::Ref< C, T, F >::isAvailable(), edm::Ref< C, T, F >::isNonnull(), isoDepositTokens_, isolationValueTokens_, isolator_, isolatorTmpStorage_, edm::EventBase::isRealData(), edm::HandleBase::isValid(), j, reco::PFCandidate::muonRef(), patZpeak::muons, muonToken_, pat::helper::EfficiencyLoader::newEvent(), pat::helper::KinResolutionsLoader::newEvent(), muonProducer_cfi::patMuons, pfMuons_cff::pfMuons, pfMuonToken_, HWWFunctions::primaryVertex(), pTComparator_, edm::Event::put(), pvToken_, resolutionLoader_, query::result, pat::Muon::setDB(), pat::Lepton< LeptonType >::setIsolation(), pat::Muon::setNormChi2(), pat::Muon::setNumberOfValidHits(), pat::Muon::setPFCandidateRef(), python.multivaluedict::sort(), tcMETMuonCorrsToken_, groupFilesInBlocks::tt, useParticleFlow_, usePV_, userDataHelper_, useUserData_, reco::BeamSpot::x0(), reco::BeamSpot::y0(), and reco::BeamSpot::z0().

118 {
119  // switch off embedding (in unschedules mode)
120  if (iEvent.isRealData()){
121  addGenMatch_ = false;
122  embedGenMatch_ = false;
123  }
124 
126  iEvent.getByToken(muonToken_, muons);
127 
128  // get the ESHandle for the transient track builder,
129  // if needed for high level selection embedding
131 
132  if(isolator_.enabled()) isolator_.beginEvent(iEvent,iSetup);
134  if(resolutionLoader_.enabled()) resolutionLoader_.newEvent(iEvent, iSetup);
135 
136  IsoDepositMaps deposits(isoDepositTokens_.size());
137  for (size_t j = 0; j<isoDepositTokens_.size(); ++j) {
138  iEvent.getByToken(isoDepositTokens_[j], deposits[j]);
139  }
140 
141  IsolationValueMaps isolationValues(isolationValueTokens_.size());
142  for (size_t j = 0; j<isolationValueTokens_.size(); ++j) {
143  iEvent.getByToken(isolationValueTokens_[j], isolationValues[j]);
144  }
145 
146  // prepare the MC genMatchTokens_
147  GenAssociations genMatches(genMatchTokens_.size());
148  if (addGenMatch_) {
149  for (size_t j = 0, nd = genMatchTokens_.size(); j < nd; ++j) {
150  iEvent.getByToken(genMatchTokens_[j], genMatches[j]);
151  }
152  }
153 
154  // prepare the high level selection: needs beamline
155  // OR primary vertex, depending on user selection
156  reco::TrackBase::Point beamPoint(0,0,0);
159  bool beamSpotIsValid = false;
160  bool primaryVertexIsValid = false;
161  if ( embedHighLevelSelection_ ) {
162  // get the beamspot
163  edm::Handle<reco::BeamSpot> beamSpotHandle;
164  iEvent.getByToken(beamLineToken_, beamSpotHandle);
165 
166  // get the primary vertex
168  iEvent.getByToken( pvToken_, pvHandle );
169 
170  if( beamSpotHandle.isValid() ){
171  beamSpot = *beamSpotHandle;
172  beamSpotIsValid = true;
173  } else{
174  edm::LogError("DataNotAvailable")
175  << "No beam spot available from EventSetup, not adding high level selection \n";
176  }
177  beamPoint = reco::TrackBase::Point ( beamSpot.x0(), beamSpot.y0(), beamSpot.z0() );
178  if( pvHandle.isValid() && !pvHandle->empty() ) {
179  primaryVertex = pvHandle->at(0);
180  primaryVertexIsValid = true;
181  } else {
182  edm::LogError("DataNotAvailable")
183  << "No primary vertex available from EventSetup, not adding high level selection \n";
184  }
185  // this is needed by the IPTools methods from the tracking group
186  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", trackBuilder);
187  }
188 
189  // this will be the new object collection
190  std::vector<Muon> * patMuons = new std::vector<Muon>();
191 
192  if( useParticleFlow_ ){
193  // get the PFCandidates of type muons
195  iEvent.getByToken(pfMuonToken_, pfMuons);
196 
197  unsigned index=0;
198  for( reco::PFCandidateConstIterator i = pfMuons->begin(); i != pfMuons->end(); ++i, ++index) {
199  const reco::PFCandidate& pfmu = *i;
200  //const reco::IsolaPFCandidate& pfmu = *i;
201  const reco::MuonRef& muonRef = pfmu.muonRef();
202  assert( muonRef.isNonnull() );
203 
204  MuonBaseRef muonBaseRef(muonRef);
205  Muon aMuon(muonBaseRef);
206 
207  if ( useUserData_ ) {
208  userDataHelper_.add( aMuon, iEvent, iSetup );
209  }
210 
211  // embed high level selection
212  if ( embedHighLevelSelection_ ) {
213  // get the tracks
214  reco::TrackRef innerTrack = muonBaseRef->innerTrack();
215  reco::TrackRef globalTrack= muonBaseRef->globalTrack();
216  reco::TrackRef bestTrack = muonBaseRef->muonBestTrack();
217  reco::TrackRef chosenTrack = innerTrack;
218  // Make sure the collection it points to is there
219  if ( bestTrack.isNonnull() && bestTrack.isAvailable() )
220  chosenTrack = bestTrack;
221 
222  if ( chosenTrack.isNonnull() && chosenTrack.isAvailable() ) {
223  unsigned int nhits = chosenTrack->numberOfValidHits(); // ????
224  aMuon.setNumberOfValidHits( nhits );
225 
226  reco::TransientTrack tt = trackBuilder->build(chosenTrack);
227  embedHighLevel( aMuon,
228  chosenTrack,
229  tt,
230  primaryVertex,
231  primaryVertexIsValid,
232  beamSpot,
233  beamSpotIsValid );
234 
235  // Correct to PV, or beam spot
236  if ( !usePV_ ) {
237  double corr_d0 = -1.0 * chosenTrack->dxy( beamPoint );
238  aMuon.setDB( corr_d0, -1.0 );
239  } else {
240  std::pair<bool,Measurement1D> result = IPTools::absoluteTransverseImpactParameter(tt, primaryVertex);
241  double d0_corr = result.second.value();
242  double d0_err = result.second.error();
243  aMuon.setDB( d0_corr, d0_err );
244  }
245  }
246 
247  if ( globalTrack.isNonnull() && globalTrack.isAvailable() ) {
248  double norm_chi2 = globalTrack->chi2() / globalTrack->ndof();
249  aMuon.setNormChi2( norm_chi2 );
250  }
251  }
252  reco::PFCandidateRef pfRef(pfMuons,index);
253  //reco::PFCandidatePtr ptrToMother(pfMuons,index);
254  reco::CandidateBaseRef pfBaseRef( pfRef );
255 
256  aMuon.setPFCandidateRef( pfRef );
257  if( embedPFCandidate_ ) aMuon.embedPFCandidate();
258  fillMuon( aMuon, muonBaseRef, pfBaseRef, genMatches, deposits, isolationValues );
259  patMuons->push_back(aMuon);
260  }
261  }
262  else {
264  iEvent.getByToken(muonToken_, muons);
265 
266  // embedding of muon MET corrections
268  //edm::ValueMap<reco::MuonMETCorrectionData> caloMETmuCorValueMap;
270  iEvent.getByToken(caloMETMuonCorrsToken_, caloMETMuonCorrs);
271  //caloMETmuCorValueMap = *caloMETmuCorValueMap_h;
272  }
274  //edm::ValueMap<reco::MuonMETCorrectionData> tcMETmuCorValueMap;
276  iEvent.getByToken(tcMETMuonCorrsToken_, tcMETMuonCorrs);
277  //tcMETmuCorValueMap = *tcMETmuCorValueMap_h;
278  }
279  for (edm::View<reco::Muon>::const_iterator itMuon = muons->begin(); itMuon != muons->end(); ++itMuon) {
280  // construct the Muon from the ref -> save ref to original object
281  unsigned int idx = itMuon - muons->begin();
282  MuonBaseRef muonRef = muons->refAt(idx);
283  reco::CandidateBaseRef muonBaseRef( muonRef );
284 
285  Muon aMuon(muonRef);
286  fillMuon( aMuon, muonRef, muonBaseRef, genMatches, deposits, isolationValues);
287 
288  // Isolation
289  if (isolator_.enabled()) {
290  //reco::CandidatePtr mother = ptrToMother->sourceCandidatePtr(0);
291  isolator_.fill(*muons, idx, isolatorTmpStorage_);
292  typedef pat::helper::MultiIsolator::IsolationValuePairs IsolationValuePairs;
293  // better to loop backwards, so the vector is resized less times
294  for (IsolationValuePairs::const_reverse_iterator it = isolatorTmpStorage_.rbegin(), ed = isolatorTmpStorage_.rend(); it != ed; ++it) {
295  aMuon.setIsolation(it->first, it->second);
296  }
297  }
298 
299  // for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
300  // aMuon.setIsoDeposit(isoDepositLabels_[j].first,
301  // (*deposits[j])[muonRef]);
302  // }
303 
304  // add sel to selected
305  edm::Ptr<reco::Muon> muonsPtr = muons->ptrAt(idx);
306  if ( useUserData_ ) {
307  userDataHelper_.add( aMuon, iEvent, iSetup );
308  }
309 
310  // embed high level selection
311  if ( embedHighLevelSelection_ ) {
312  // get the tracks
313  reco::TrackRef innerTrack = itMuon->innerTrack();
314  reco::TrackRef globalTrack= itMuon->globalTrack();
315  reco::TrackRef bestTrack = itMuon->muonBestTrack();
316  reco::TrackRef chosenTrack = innerTrack;
317  // Make sure the collection it points to is there
318  if ( bestTrack.isNonnull() && bestTrack.isAvailable() )
319  chosenTrack = bestTrack;
320  if ( chosenTrack.isNonnull() && chosenTrack.isAvailable() ) {
321  unsigned int nhits = chosenTrack->numberOfValidHits(); // ????
322  aMuon.setNumberOfValidHits( nhits );
323 
324  reco::TransientTrack tt = trackBuilder->build(chosenTrack);
325  embedHighLevel( aMuon,
326  chosenTrack,
327  tt,
328  primaryVertex,
329  primaryVertexIsValid,
330  beamSpot,
331  beamSpotIsValid );
332 
333  // Correct to PV, or beam spot
334  if ( !usePV_ ) {
335  double corr_d0 = -1.0 * chosenTrack->dxy( beamPoint );
336  aMuon.setDB( corr_d0, -1.0 );
337  } else {
338  std::pair<bool,Measurement1D> result = IPTools::absoluteTransverseImpactParameter(tt, primaryVertex);
339  double d0_corr = result.second.value();
340  double d0_err = result.second.error();
341  aMuon.setDB( d0_corr, d0_err );
342  }
343  }
344 
345  if ( globalTrack.isNonnull() && globalTrack.isAvailable() ) {
346  double norm_chi2 = globalTrack->chi2() / globalTrack->ndof();
347  aMuon.setNormChi2( norm_chi2 );
348  }
349  }
350 
351  // embed MET muon corrections
352  if( embedCaloMETMuonCorrs_ ) aMuon.embedCaloMETMuonCorrs((*caloMETMuonCorrs)[muonRef]);
353  if( embedTcMETMuonCorrs_ ) aMuon.embedTcMETMuonCorrs((*tcMETMuonCorrs )[muonRef]);
354 
355  patMuons->push_back(aMuon);
356  }
357  }
358 
359  // sort muons in pt
360  std::sort(patMuons->begin(), patMuons->end(), pTComparator_);
361 
362  // put genEvt object in Event
363  std::auto_ptr<std::vector<Muon> > ptr(patMuons);
364  iEvent.put(ptr);
365 
367 }
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
bool useUserData_
add user data to the muon (this will be data members of th muon even w/o embedding) ...
bool isAvailable() const
Definition: Ref.h:276
double z0() const
z coordinate
Definition: BeamSpot.h:68
bool usePV_
use the primary vertex or the beamspot
int i
Definition: DBlmapReader.cc:9
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
edm::EDGetTokenT< edm::ValueMap< reco::MuonMETCorrectionData > > tcMETMuonCorrsToken_
source of tcMET muon corrections
bool embedTcMETMuonCorrs_
embed muon MET correction info for tcMET into the muon
edm::EDGetTokenT< std::vector< reco::Vertex > > pvToken_
input source of the primary vertex
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
input source
edm::EDGetTokenT< edm::ValueMap< reco::MuonMETCorrectionData > > caloMETMuonCorrsToken_
source of caloMET muon corrections
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
bool embedCaloMETMuonCorrs_
embed muon MET correction info for caloMET into the muon
PFCandidateCollection::const_iterator PFCandidateConstIterator
iterator
bool isRealData() const
Definition: EventBase.h:60
void embedHighLevel(pat::Muon &aMuon, reco::TrackRef track, reco::TransientTrack &tt, reco::Vertex &primaryVertex, bool primaryVertexIsValid, reco::BeamSpot &beamspot, bool beamspotIsValid)
edm::EDGetTokenT< reco::PFCandidateCollection > pfMuonToken_
input source pfCandidates that will be to be transformed into pat::Muons, when using PF2PAT ...
pat::helper::MultiIsolator isolator_
helper class to add userdefined isolation values to the muon
std::vector< edm::EDGetTokenT< edm::ValueMap< IsoDeposit > > > isoDepositTokens_
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
edm::EDGetTokenT< reco::BeamSpot > beamLineToken_
input source of the primary vertex/beamspot
bool useParticleFlow_
switch to use particle flow (PF2PAT) or not
pat::PATUserDataHelper< pat::Muon > userDataHelper_
helper class to add userData to the muon
bool enabled() const
True if it has a non null configuration.
Definition: MultiIsolator.h:50
void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup)
GreaterByPt< Muon > pTComparator_
bool addGenMatch_
add generator match information
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
tuple result
Definition: query.py:137
int j
Definition: DBlmapReader.cc:9
math::XYZPoint Point
point in the space
Definition: TrackBase.h:82
bool isValid() const
Definition: HandleBase.h:76
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:450
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
const T & get() const
Definition: EventSetup.h:55
std::pair< bool, Measurement1D > absoluteTransverseImpactParameter(const reco::TransientTrack &transientTrack, const reco::Vertex &vertex)
Definition: IPTools.cc:43
std::vector< edm::Handle< edm::Association< reco::GenParticleCollection > > > GenAssociations
void fillMuon(Muon &aMuon, const MuonBaseRef &muonRef, const reco::CandidateBaseRef &baseRef, const GenAssociations &genMatches, const IsoDepositMaps &deposits, const IsolationValueMaps &isolationValues) const
common muon filling, for both the standard and PF2PAT case
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
Definition: MultiIsolator.h:16
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
pat::helper::EfficiencyLoader efficiencyLoader_
helper class to add efficiencies to the muon
tuple muons
Definition: patZpeak.py:38
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
double y0() const
y coordinate
Definition: BeamSpot.h:66
std::vector< edm::Handle< edm::ValueMap< IsoDeposit > > > IsoDepositMaps
pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_
isolation value pair for temporary storage before being folded into the muon
bool embedGenMatch_
embed the gen match information into the muon
std::vector< edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > > genMatchTokens_
input tags for generator match information
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
edm::RefToBase< reco::Muon > MuonBaseRef
typedefs for convenience
bool embedPFCandidate_
embed pfCandidates into the muon
void newEvent(const edm::Event &event, const edm::EventSetup &setup) const
To be called for each new event, reads in the EventSetup object.
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueTokens_
Analysis-level muon class.
Definition: Muon.h:50
pat::helper::KinResolutionsLoader resolutionLoader_
helper class to add resolutions to the muon
void newEvent(const edm::Event &event) const
To be called for each new event, reads in the ValueMaps for efficiencies.
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const
Definition: MultiIsolator.h:82
tuple pfMuons
Definition: pfMuons_cff.py:8
double x0() const
x coordinate
Definition: BeamSpot.h:64
bool embedHighLevelSelection_
embed high level selection variables
template<typename T >
void PATMuonProducer::readIsolationLabels ( const edm::ParameterSet iConfig,
const char *  psetName,
IsolationLabels labels,
std::vector< edm::EDGetTokenT< edm::ValueMap< T > > > &  tokens 
)
private

fill label vector from the contents of the parameter set, for the embedding of isoDeposits or userIsolation values

Definition at line 167 of file PATMuonProducer.h.

References pat::EcalIso, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), pat::HcalIso, combine::key, diffTwoXMLs::label, pat::PfAllParticleIso, pat::PfChargedAllIso, pat::PfChargedHadronIso, pat::PfGammaIso, pat::PfNeutralHadronIso, pat::PfPUChargedHadronIso, pat::TrackIso, pat::UserBaseIso, and edm::vector_transform().

168 {
169  labels.clear();
170 
171  if (iConfig.exists( psetName )) {
172  edm::ParameterSet depconf = iConfig.getParameter<edm::ParameterSet>(psetName);
173 
174  if (depconf.exists("tracker")) labels.push_back(std::make_pair(pat::TrackIso, depconf.getParameter<edm::InputTag>("tracker")));
175  if (depconf.exists("ecal")) labels.push_back(std::make_pair(pat::EcalIso, depconf.getParameter<edm::InputTag>("ecal")));
176  if (depconf.exists("hcal")) labels.push_back(std::make_pair(pat::HcalIso, depconf.getParameter<edm::InputTag>("hcal")));
177  if (depconf.exists("pfAllParticles")) {
178  labels.push_back(std::make_pair(pat::PfAllParticleIso, depconf.getParameter<edm::InputTag>("pfAllParticles")));
179  }
180  if (depconf.exists("pfChargedHadrons")) {
181  labels.push_back(std::make_pair(pat::PfChargedHadronIso, depconf.getParameter<edm::InputTag>("pfChargedHadrons")));
182  }
183  if (depconf.exists("pfChargedAll")) {
184  labels.push_back(std::make_pair(pat::PfChargedAllIso, depconf.getParameter<edm::InputTag>("pfChargedAll")));
185  }
186  if (depconf.exists("pfPUChargedHadrons")) {
187  labels.push_back(std::make_pair(pat::PfPUChargedHadronIso, depconf.getParameter<edm::InputTag>("pfPUChargedHadrons")));
188  }
189  if (depconf.exists("pfNeutralHadrons")) {
190  labels.push_back(std::make_pair(pat::PfNeutralHadronIso, depconf.getParameter<edm::InputTag>("pfNeutralHadrons")));
191  }
192  if (depconf.exists("pfPhotons")) {
193  labels.push_back(std::make_pair(pat::PfGammaIso, depconf.getParameter<edm::InputTag>("pfPhotons")));
194  }
195  if (depconf.exists("user")) {
196  std::vector<edm::InputTag> userdeps = depconf.getParameter<std::vector<edm::InputTag> >("user");
197  std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
198  int key = UserBaseIso;
199  for ( ; it != ed; ++it, ++key) {
200  labels.push_back(std::make_pair(IsolationKeys(key), *it));
201  }
202  }
203  }
204  tokens = edm::vector_transform(labels, [this](IsolationLabel const & label){return consumes<edm::ValueMap<T> >(label.second);});
205 }
T getParameter(std::string const &) const
std::pair< pat::IsolationKeys, edm::InputTag > IsolationLabel
bool exists(std::string const &parameterName) const
checks if a parameter exists
IsolationKeys
Enum defining isolation keys.
Definition: Isolation.h:9
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
list key
Definition: combine.py:13

Member Data Documentation

bool pat::PATMuonProducer::addEfficiencies_
private

add efficiencies to the muon (this will be data members of th muon even w/o embedding)

Definition at line 143 of file PATMuonProducer.h.

bool pat::PATMuonProducer::addGenMatch_
private

add generator match information

Definition at line 113 of file PATMuonProducer.h.

Referenced by fillMuon(), PATMuonProducer(), and produce().

bool pat::PATMuonProducer::addResolutions_
private

add resolutions to the muon (this will be data members of th muon even w/o embedding)

Definition at line 119 of file PATMuonProducer.h.

edm::EDGetTokenT<reco::BeamSpot> pat::PATMuonProducer::beamLineToken_
private

input source of the primary vertex/beamspot

Definition at line 131 of file PATMuonProducer.h.

Referenced by produce().

edm::EDGetTokenT<edm::ValueMap<reco::MuonMETCorrectionData> > pat::PATMuonProducer::caloMETMuonCorrsToken_
private

source of caloMET muon corrections

Definition at line 101 of file PATMuonProducer.h.

Referenced by PATMuonProducer(), and produce().

pat::helper::EfficiencyLoader pat::PATMuonProducer::efficiencyLoader_
private

helper class to add efficiencies to the muon

Definition at line 155 of file PATMuonProducer.h.

Referenced by fillMuon(), and produce().

bool pat::PATMuonProducer::embedBestTrack_
private

embed the track from best muon measurement (global pflow)

Definition at line 87 of file PATMuonProducer.h.

Referenced by fillMuon(), and PATMuonProducer().

bool pat::PATMuonProducer::embedCaloMETMuonCorrs_
private

embed muon MET correction info for caloMET into the muon

Definition at line 99 of file PATMuonProducer.h.

Referenced by PATMuonProducer(), and produce().

bool pat::PATMuonProducer::embedCombinedMuon_
private

embed track of the combined fit into the muon

Definition at line 97 of file PATMuonProducer.h.

Referenced by fillMuon(), and PATMuonProducer().

bool pat::PATMuonProducer::embedDytMuon_
private

embed track from DYT muon fit into the muon

Definition at line 111 of file PATMuonProducer.h.

Referenced by fillMuon(), and PATMuonProducer().

bool pat::PATMuonProducer::embedGenMatch_
private

embed the gen match information into the muon

Definition at line 117 of file PATMuonProducer.h.

Referenced by fillMuon(), PATMuonProducer(), and produce().

bool pat::PATMuonProducer::embedHighLevelSelection_
private

embed high level selection variables

Definition at line 129 of file PATMuonProducer.h.

Referenced by produce().

bool pat::PATMuonProducer::embedPFCandidate_
private

embed pfCandidates into the muon

Definition at line 127 of file PATMuonProducer.h.

Referenced by PATMuonProducer(), and produce().

bool pat::PATMuonProducer::embedPickyMuon_
private

embed track from picky muon fit into the muon

Definition at line 107 of file PATMuonProducer.h.

Referenced by fillMuon(), and PATMuonProducer().

bool pat::PATMuonProducer::embedStandAloneMuon_
private

embed track from muon system into the muon

Definition at line 95 of file PATMuonProducer.h.

Referenced by fillMuon(), and PATMuonProducer().

bool pat::PATMuonProducer::embedTcMETMuonCorrs_
private

embed muon MET correction info for tcMET into the muon

Definition at line 103 of file PATMuonProducer.h.

Referenced by PATMuonProducer(), and produce().

bool pat::PATMuonProducer::embedTpfmsMuon_
private

embed track from tpfms muon fit into the muon

Definition at line 109 of file PATMuonProducer.h.

Referenced by fillMuon(), and PATMuonProducer().

bool pat::PATMuonProducer::embedTrack_
private

embed the track from inner tracker into the muon

Definition at line 93 of file PATMuonProducer.h.

Referenced by fillMuon(), and PATMuonProducer().

bool pat::PATMuonProducer::embedTunePBestTrack_
private

embed the track from best muon measurement (muon only)

Definition at line 89 of file PATMuonProducer.h.

Referenced by fillMuon(), and PATMuonProducer().

bool pat::PATMuonProducer::forceEmbedBestTrack_
private

force separate embed of the best track even if already embedded

Definition at line 91 of file PATMuonProducer.h.

Referenced by fillMuon(), and PATMuonProducer().

std::vector<edm::EDGetTokenT<edm::Association<reco::GenParticleCollection> > > pat::PATMuonProducer::genMatchTokens_
private

input tags for generator match information

Definition at line 115 of file PATMuonProducer.h.

Referenced by PATMuonProducer(), and produce().

IsolationLabels pat::PATMuonProducer::isoDepositLabels_
private

input source for isoDeposits

Definition at line 137 of file PATMuonProducer.h.

Referenced by fillMuon().

std::vector<edm::EDGetTokenT<edm::ValueMap<IsoDeposit> > > pat::PATMuonProducer::isoDepositTokens_
private

Definition at line 138 of file PATMuonProducer.h.

Referenced by produce().

IsolationLabels pat::PATMuonProducer::isolationValueLabels_
private

input source isolation value maps

Definition at line 140 of file PATMuonProducer.h.

Referenced by fillMuon().

std::vector<edm::EDGetTokenT<edm::ValueMap<double> > > pat::PATMuonProducer::isolationValueTokens_
private

Definition at line 141 of file PATMuonProducer.h.

Referenced by produce().

pat::helper::MultiIsolator pat::PATMuonProducer::isolator_
private

helper class to add userdefined isolation values to the muon

Definition at line 151 of file PATMuonProducer.h.

Referenced by produce().

pat::helper::MultiIsolator::IsolationValuePairs pat::PATMuonProducer::isolatorTmpStorage_
private

isolation value pair for temporary storage before being folded into the muon

Definition at line 153 of file PATMuonProducer.h.

Referenced by produce().

edm::EDGetTokenT<edm::View<reco::Muon> > pat::PATMuonProducer::muonToken_
private

input source

Definition at line 84 of file PATMuonProducer.h.

Referenced by PATMuonProducer(), and produce().

edm::EDGetTokenT<reco::PFCandidateCollection> pat::PATMuonProducer::pfMuonToken_
private

input source pfCandidates that will be to be transformed into pat::Muons, when using PF2PAT

Definition at line 125 of file PATMuonProducer.h.

Referenced by PATMuonProducer(), and produce().

GreaterByPt<Muon> pat::PATMuonProducer::pTComparator_
private

— tools — comparator for pt ordering

Definition at line 149 of file PATMuonProducer.h.

Referenced by produce().

edm::EDGetTokenT<std::vector<reco::Vertex> > pat::PATMuonProducer::pvToken_
private

input source of the primary vertex

Definition at line 135 of file PATMuonProducer.h.

Referenced by produce().

pat::helper::KinResolutionsLoader pat::PATMuonProducer::resolutionLoader_
private

helper class to add resolutions to the muon

Definition at line 121 of file PATMuonProducer.h.

Referenced by fillMuon(), and produce().

edm::EDGetTokenT<edm::ValueMap<reco::MuonMETCorrectionData> > pat::PATMuonProducer::tcMETMuonCorrsToken_
private

source of tcMET muon corrections

Definition at line 105 of file PATMuonProducer.h.

Referenced by PATMuonProducer(), and produce().

bool pat::PATMuonProducer::useParticleFlow_
private

switch to use particle flow (PF2PAT) or not

Definition at line 123 of file PATMuonProducer.h.

Referenced by fillMuon(), PATMuonProducer(), and produce().

bool pat::PATMuonProducer::usePV_
private

use the primary vertex or the beamspot

Definition at line 133 of file PATMuonProducer.h.

Referenced by produce().

pat::PATUserDataHelper<pat::Muon> pat::PATMuonProducer::userDataHelper_
private

helper class to add userData to the muon

Definition at line 157 of file PATMuonProducer.h.

Referenced by produce().

bool pat::PATMuonProducer::useUserData_
private

add user data to the muon (this will be data members of th muon even w/o embedding)

Definition at line 145 of file PATMuonProducer.h.

Referenced by produce().