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::stream::EDProducer<> edm::stream::EDProducerBase 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::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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
std::vector< ConsumesInfoconsumesInfo () const
 
 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 (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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::stream::EDProducerBase
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 embedPfEcalEnergy_
 add ecal PF energy 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...
 
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::stream::EDProducer<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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_, embedPfEcalEnergy_, 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  embedPfEcalEnergy_ = iConfig.getParameter<bool>( "embedPfEcalEnergy" );
68  // embedding of tracks from TeV refit
69  embedPickyMuon_ = iConfig.getParameter<bool>( "embedPickyMuon" );
70  embedTpfmsMuon_ = iConfig.getParameter<bool>( "embedTpfmsMuon" );
71  embedDytMuon_ = iConfig.getParameter<bool>( "embedDytMuon" );
72  // Monte Carlo matching
73  addGenMatch_ = iConfig.getParameter<bool>( "addGenMatch" );
74  if (addGenMatch_) {
75  embedGenMatch_ = iConfig.getParameter<bool>( "embedGenMatch" );
76  if (iConfig.existsAs<edm::InputTag>("genParticleMatch")) {
78  }
79  else {
80  genMatchTokens_ = edm::vector_transform(iConfig.getParameter<std::vector<edm::InputTag> >( "genParticleMatch" ), [this](edm::InputTag const & tag){return consumes<edm::Association<reco::GenParticleCollection> >(tag);});
81  }
82  }
83  // efficiencies
84  addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies");
85  if(addEfficiencies_){
87  }
88  // resolutions
89  addResolutions_ = iConfig.getParameter<bool>("addResolutions");
90  if (addResolutions_) {
92  }
93  // read isoDeposit labels, for direct embedding
95  // read isolation value labels, for direct embedding
97  // check to see if the user wants to add user data
98  if( useUserData_ ){
100  }
101  // embed high level selection variables
102  embedHighLevelSelection_ = iConfig.getParameter<bool>("embedHighLevelSelection");
103  if ( embedHighLevelSelection_ ) {
104  beamLineToken_ = consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamLineSrc"));
105  pvToken_ = consumes<std::vector<reco::Vertex> >(iConfig.getParameter<edm::InputTag>("pvSrc"));
106  }
107  // produces vector of muons
108  produces<std::vector<Muon> >();
109 }
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.
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:186
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
bool embedPfEcalEnergy_
add ecal PF energy
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
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
void readIsolationLabels(const edm::ParameterSet &iConfig, const char *psetName, IsolationLabels &labels, std::vector< edm::EDGetTokenT< edm::ValueMap< T > > > &tokens)
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 112 of file PATMuonProducer.cc.

113 {
114 }

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

553 {
554  // Correct to PV
555 
556  // PV2D
557  std::pair<bool,Measurement1D> result =
559  GlobalVector(track->px(),
560  track->py(),
561  track->pz()),
562  primaryVertex);
563  double d0_corr = result.second.value();
564  double d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
565  aMuon.setDB( d0_corr, d0_err, pat::Muon::PV2D);
566 
567 
568  // PV3D
569  result =
571  GlobalVector(track->px(),
572  track->py(),
573  track->pz()),
574  primaryVertex);
575  d0_corr = result.second.value();
576  d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
577  aMuon.setDB( d0_corr, d0_err, pat::Muon::PV3D);
578 
579 
580  // Correct to beam spot
581  // make a fake vertex out of beam spot
582  reco::Vertex vBeamspot(beamspot.position(), beamspot.rotatedCovariance3D());
583 
584  // BS2D
585  result =
587  GlobalVector(track->px(),
588  track->py(),
589  track->pz()),
590  vBeamspot);
591  d0_corr = result.second.value();
592  d0_err = beamspotIsValid ? result.second.error() : -1.0;
593  aMuon.setDB( d0_corr, d0_err, pat::Muon::BS2D);
594 
595  // BS3D
596  result =
598  GlobalVector(track->px(),
599  track->py(),
600  track->pz()),
601  vBeamspot);
602  d0_corr = result.second.value();
603  d0_err = beamspotIsValid ? result.second.error() : -1.0;
604  aMuon.setDB( d0_corr, d0_err, pat::Muon::BS3D);
605 }
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
void setDB(double dB, double edB, IPTYPE type=PV2D)
Definition: Muon.h:220
tuple result
Definition: query.py:137
const Point & position() const
position
Definition: BeamSpot.h:62
Covariance3DMatrix rotatedCovariance3D() const
Definition: BeamSpot.cc:78
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(), HLT_FULL_cff::InputTag, 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  iDesc.add<bool>("embedPfEcalEnergy", true)->setComment("add ecal energy as reconstructed by PF");
477 
478  // MC matching configurables
479  iDesc.add<bool>("addGenMatch", true)->setComment("add MC matching");
480  iDesc.add<bool>("embedGenMatch", false)->setComment("embed MC matched MC information");
481  std::vector<edm::InputTag> emptySourceVector;
482  iDesc.addNode( edm::ParameterDescription<edm::InputTag>("genParticleMatch", edm::InputTag(), true) xor
483  edm::ParameterDescription<std::vector<edm::InputTag> >("genParticleMatch", emptySourceVector, true)
484  )->setComment("input with MC match information");
485 
487 
488  // IsoDeposit configurables
489  edm::ParameterSetDescription isoDepositsPSet;
490  isoDepositsPSet.addOptional<edm::InputTag>("tracker");
491  isoDepositsPSet.addOptional<edm::InputTag>("ecal");
492  isoDepositsPSet.addOptional<edm::InputTag>("hcal");
493  isoDepositsPSet.addOptional<edm::InputTag>("particle");
494  isoDepositsPSet.addOptional<edm::InputTag>("pfChargedHadrons");
495  isoDepositsPSet.addOptional<edm::InputTag>("pfChargedAll");
496  isoDepositsPSet.addOptional<edm::InputTag>("pfPUChargedHadrons");
497  isoDepositsPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
498  isoDepositsPSet.addOptional<edm::InputTag>("pfPhotons");
499  isoDepositsPSet.addOptional<std::vector<edm::InputTag> >("user");
500  iDesc.addOptional("isoDeposits", isoDepositsPSet);
501 
502  // isolation values configurables
503  edm::ParameterSetDescription isolationValuesPSet;
504  isolationValuesPSet.addOptional<edm::InputTag>("tracker");
505  isolationValuesPSet.addOptional<edm::InputTag>("ecal");
506  isolationValuesPSet.addOptional<edm::InputTag>("hcal");
507  isolationValuesPSet.addOptional<edm::InputTag>("particle");
508  isolationValuesPSet.addOptional<edm::InputTag>("pfChargedHadrons");
509  isolationValuesPSet.addOptional<edm::InputTag>("pfChargedAll");
510  isolationValuesPSet.addOptional<edm::InputTag>("pfPUChargedHadrons");
511  isolationValuesPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
512  isolationValuesPSet.addOptional<edm::InputTag>("pfPhotons");
513  iDesc.addOptional("isolationValues", isolationValuesPSet);
514 
515  // Efficiency configurables
516  edm::ParameterSetDescription efficienciesPSet;
517  efficienciesPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
518  iDesc.add("efficiencies", efficienciesPSet);
519  iDesc.add<bool>("addEfficiencies", false);
520 
521  // Check to see if the user wants to add user data
522  edm::ParameterSetDescription userDataPSet;
524  iDesc.addOptional("userData", userDataPSet);
525 
526  edm::ParameterSetDescription isolationPSet;
527  isolationPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
528  iDesc.add("userIsolation", isolationPSet);
529 
530  iDesc.add<bool>("embedHighLevelSelection", true)->setComment("embed high level selection");
531  edm::ParameterSetDescription highLevelPSet;
532  highLevelPSet.setAllowAnything();
533  iDesc.addNode( edm::ParameterDescription<edm::InputTag>("beamLineSrc", edm::InputTag(), true)
534  )->setComment("input with high level selection");
536  )->setComment("input with high level selection");
537 
538  //descriptions.add("PATMuonProducer", iDesc);
539 }
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(), plotBeamSpotDB::first, forceEmbedBestTrack_, i, edm::RefToBase< T >::id(), reco::Muon::isAValidMuonTrack(), reco::Muon::isGlobalMuon(), isoDepositLabels_, isolationValueLabels_, j, gen::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 embedDytMuon()
embed reference to the above dyt Track
void embedTpfmsMuon()
embed reference to the above tpfms Track
void setIsolation(IsolationKeys key, float value)
Definition: Lepton.h:98
bool contains(EventRange const &lh, EventID const &rh)
Definition: EventRange.cc:38
void embedCombinedMuon()
set reference to Track reconstructed in both tracked and muon detector (reimplemented from reco::Muon...
void embedTunePMuonBestTrack(bool force=false)
void embedMuonBestTrack(bool force=false)
bool isGlobalMuon() const
Definition: Muon.h:222
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:227
void embedStandAloneMuon()
set reference to Track reconstructed in the muon detector only (reimplemented from reco::Muon) ...
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 embedTrack()
set reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
bool useParticleFlow_
switch to use particle flow (PF2PAT) or not
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
void embedGenParticle()
Definition: PATObject.h:694
reco::PFCandidateRef pfCandidateRef() const
int j
Definition: DBlmapReader.cc:9
bool isAValidMuonTrack(const MuonTrackType &type) const
void addGenParticleRef(const reco::GenParticleRef &ref)
Definition: PATObject.h:678
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.
virtual void setP4(const LorentzVector &p4) final
set 4-momentum
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
IsolationLabels isolationValueLabels_
input source isolation value maps
void embedPickyMuon()
embed reference to the above picky Track
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::stream::EDProducerBase.

Definition at line 116 of file PATMuonProducer.cc.

References addGenMatch_, assert(), beamLineToken_, SiPixelRawToDigiRegional_cfi::beamSpot, pat::helper::MultiIsolator::beginEvent(), caloMETMuonCorrsToken_, reco::PFCandidate::ecalEnergy(), efficiencyLoader_, pat::Muon::embedCaloMETMuonCorrs(), embedCaloMETMuonCorrs_, embedCombinedMuon_, embedGenMatch_, embedHighLevel(), embedHighLevelSelection_, pat::Muon::embedPFCandidate(), embedPFCandidate_, embedPfEcalEnergy_, 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(), nhits, muonProducer_cfi::patMuons, pfMuons_cff::pfMuons, pfMuonToken_, HLT_FULL_cff::primaryVertex, pTComparator_, edm::Event::put(), pvToken_, resolutionLoader_, pat::Lepton< LeptonType >::setIsolation(), pat::Muon::setNormChi2(), pat::Muon::setNumberOfValidHits(), pat::Muon::setPFCandidateRef(), pat::Muon::setPfEcalEnergy(), tcMETMuonCorrsToken_, groupFilesInBlocks::tt, useParticleFlow_, userDataHelper_, and useUserData_.

117 {
118  // switch off embedding (in unschedules mode)
119  if (iEvent.isRealData()){
120  addGenMatch_ = false;
121  embedGenMatch_ = false;
122  }
123 
125  iEvent.getByToken(muonToken_, muons);
126 
127  // get the ESHandle for the transient track builder,
128  // if needed for high level selection embedding
130 
131  if(isolator_.enabled()) isolator_.beginEvent(iEvent,iSetup);
133  if(resolutionLoader_.enabled()) resolutionLoader_.newEvent(iEvent, iSetup);
134 
135  IsoDepositMaps deposits(isoDepositTokens_.size());
136  for (size_t j = 0; j<isoDepositTokens_.size(); ++j) {
137  iEvent.getByToken(isoDepositTokens_[j], deposits[j]);
138  }
139 
140  IsolationValueMaps isolationValues(isolationValueTokens_.size());
141  for (size_t j = 0; j<isolationValueTokens_.size(); ++j) {
142  iEvent.getByToken(isolationValueTokens_[j], isolationValues[j]);
143  }
144 
145  // prepare the MC genMatchTokens_
146  GenAssociations genMatches(genMatchTokens_.size());
147  if (addGenMatch_) {
148  for (size_t j = 0, nd = genMatchTokens_.size(); j < nd; ++j) {
149  iEvent.getByToken(genMatchTokens_[j], genMatches[j]);
150  }
151  }
152 
153  // prepare the high level selection: needs beamline
154  // OR primary vertex, depending on user selection
157  bool beamSpotIsValid = false;
158  bool primaryVertexIsValid = false;
159  if ( embedHighLevelSelection_ ) {
160  // get the beamspot
161  edm::Handle<reco::BeamSpot> beamSpotHandle;
162  iEvent.getByToken(beamLineToken_, beamSpotHandle);
163 
164  // get the primary vertex
166  iEvent.getByToken( pvToken_, pvHandle );
167 
168  if( beamSpotHandle.isValid() ){
169  beamSpot = *beamSpotHandle;
170  beamSpotIsValid = true;
171  } else{
172  edm::LogError("DataNotAvailable")
173  << "No beam spot available from EventSetup, not adding high level selection \n";
174  }
175  if( pvHandle.isValid() && !pvHandle->empty() ) {
176  primaryVertex = pvHandle->at(0);
177  primaryVertexIsValid = true;
178  } else {
179  edm::LogError("DataNotAvailable")
180  << "No primary vertex available from EventSetup, not adding high level selection \n";
181  }
182  // this is needed by the IPTools methods from the tracking group
183  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", trackBuilder);
184  }
185 
186  // this will be the new object collection
187  std::vector<Muon> * patMuons = new std::vector<Muon>();
188 
190  if( useParticleFlow_ ){
191  // get the PFCandidates of type muons
192  iEvent.getByToken(pfMuonToken_, pfMuons);
193 
194  unsigned index=0;
195  for( reco::PFCandidateConstIterator i = pfMuons->begin(); i != pfMuons->end(); ++i, ++index) {
196  const reco::PFCandidate& pfmu = *i;
197  //const reco::IsolaPFCandidate& pfmu = *i;
198  const reco::MuonRef& muonRef = pfmu.muonRef();
199  assert( muonRef.isNonnull() );
200 
201  MuonBaseRef muonBaseRef(muonRef);
202  Muon aMuon(muonBaseRef);
203 
204  if ( useUserData_ ) {
205  userDataHelper_.add( aMuon, iEvent, iSetup );
206  }
207 
208  // embed high level selection
209  if ( embedHighLevelSelection_ ) {
210  // get the tracks
211  reco::TrackRef innerTrack = muonBaseRef->innerTrack();
212  reco::TrackRef globalTrack= muonBaseRef->globalTrack();
213  reco::TrackRef bestTrack = muonBaseRef->muonBestTrack();
214  reco::TrackRef chosenTrack = innerTrack;
215  // Make sure the collection it points to is there
216  if ( bestTrack.isNonnull() && bestTrack.isAvailable() )
217  chosenTrack = bestTrack;
218 
219  if ( chosenTrack.isNonnull() && chosenTrack.isAvailable() ) {
220  unsigned int nhits = chosenTrack->numberOfValidHits(); // ????
221  aMuon.setNumberOfValidHits( nhits );
222 
223  reco::TransientTrack tt = trackBuilder->build(chosenTrack);
224  embedHighLevel( aMuon,
225  chosenTrack,
226  tt,
227  primaryVertex,
228  primaryVertexIsValid,
229  beamSpot,
230  beamSpotIsValid );
231 
232  }
233 
234  if ( globalTrack.isNonnull() && globalTrack.isAvailable() && !embedCombinedMuon_) {
235  double norm_chi2 = globalTrack->chi2() / globalTrack->ndof();
236  aMuon.setNormChi2( norm_chi2 );
237  }
238  }
239  reco::PFCandidateRef pfRef(pfMuons,index);
240  //reco::PFCandidatePtr ptrToMother(pfMuons,index);
241  reco::CandidateBaseRef pfBaseRef( pfRef );
242 
243  aMuon.setPFCandidateRef( pfRef );
244  if( embedPFCandidate_ ) aMuon.embedPFCandidate();
245  fillMuon( aMuon, muonBaseRef, pfBaseRef, genMatches, deposits, isolationValues );
246 
247  if (embedPfEcalEnergy_) {
248  aMuon.setPfEcalEnergy(pfmu.ecalEnergy());
249  }
250 
251  patMuons->push_back(aMuon);
252  }
253  }
254  else {
256  iEvent.getByToken(muonToken_, muons);
257 
258  // embedding of muon MET corrections
260  //edm::ValueMap<reco::MuonMETCorrectionData> caloMETmuCorValueMap;
262  iEvent.getByToken(caloMETMuonCorrsToken_, caloMETMuonCorrs);
263  //caloMETmuCorValueMap = *caloMETmuCorValueMap_h;
264  }
266  //edm::ValueMap<reco::MuonMETCorrectionData> tcMETmuCorValueMap;
268  iEvent.getByToken(tcMETMuonCorrsToken_, tcMETMuonCorrs);
269  //tcMETmuCorValueMap = *tcMETmuCorValueMap_h;
270  }
271 
272  if (embedPfEcalEnergy_) {
273  // get the PFCandidates of type muons
274  iEvent.getByToken(pfMuonToken_, pfMuons);
275  }
276 
277  for (edm::View<reco::Muon>::const_iterator itMuon = muons->begin(); itMuon != muons->end(); ++itMuon) {
278  // construct the Muon from the ref -> save ref to original object
279  unsigned int idx = itMuon - muons->begin();
280  MuonBaseRef muonRef = muons->refAt(idx);
281  reco::CandidateBaseRef muonBaseRef( muonRef );
282 
283  Muon aMuon(muonRef);
284  fillMuon( aMuon, muonRef, muonBaseRef, genMatches, deposits, isolationValues);
285 
286  // Isolation
287  if (isolator_.enabled()) {
288  //reco::CandidatePtr mother = ptrToMother->sourceCandidatePtr(0);
289  isolator_.fill(*muons, idx, isolatorTmpStorage_);
290  typedef pat::helper::MultiIsolator::IsolationValuePairs IsolationValuePairs;
291  // better to loop backwards, so the vector is resized less times
292  for (IsolationValuePairs::const_reverse_iterator it = isolatorTmpStorage_.rbegin(), ed = isolatorTmpStorage_.rend(); it != ed; ++it) {
293  aMuon.setIsolation(it->first, it->second);
294  }
295  }
296 
297  // for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
298  // aMuon.setIsoDeposit(isoDepositLabels_[j].first,
299  // (*deposits[j])[muonRef]);
300  // }
301 
302  // add sel to selected
303  edm::Ptr<reco::Muon> muonsPtr = muons->ptrAt(idx);
304  if ( useUserData_ ) {
305  userDataHelper_.add( aMuon, iEvent, iSetup );
306  }
307 
308  // embed high level selection
309  if ( embedHighLevelSelection_ ) {
310  // get the tracks
311  reco::TrackRef innerTrack = itMuon->innerTrack();
312  reco::TrackRef globalTrack= itMuon->globalTrack();
313  reco::TrackRef bestTrack = itMuon->muonBestTrack();
314  reco::TrackRef chosenTrack = innerTrack;
315  // Make sure the collection it points to is there
316  if ( bestTrack.isNonnull() && bestTrack.isAvailable() )
317  chosenTrack = bestTrack;
318  if ( chosenTrack.isNonnull() && chosenTrack.isAvailable() ) {
319  unsigned int nhits = chosenTrack->numberOfValidHits(); // ????
320  aMuon.setNumberOfValidHits( nhits );
321 
322  reco::TransientTrack tt = trackBuilder->build(chosenTrack);
323  embedHighLevel( aMuon,
324  chosenTrack,
325  tt,
326  primaryVertex,
327  primaryVertexIsValid,
328  beamSpot,
329  beamSpotIsValid );
330 
331  }
332 
333  if ( globalTrack.isNonnull() && globalTrack.isAvailable() ) {
334  double norm_chi2 = globalTrack->chi2() / globalTrack->ndof();
335  aMuon.setNormChi2( norm_chi2 );
336  }
337  }
338 
339  // embed MET muon corrections
340  if( embedCaloMETMuonCorrs_ ) aMuon.embedCaloMETMuonCorrs((*caloMETMuonCorrs)[muonRef]);
341  if( embedTcMETMuonCorrs_ ) aMuon.embedTcMETMuonCorrs((*tcMETMuonCorrs )[muonRef]);
342 
343  if (embedPfEcalEnergy_) {
344  aMuon.setPfEcalEnergy(-99.0);
345  for (const reco::PFCandidate &pfmu : *pfMuons) {
346  if (pfmu.muonRef().isNonnull()) {
347  if (pfmu.muonRef().id() != muonRef.id()) throw cms::Exception("Configuration") << "Muon reference within PF candidates does not point to the muon collection." << std::endl;
348  if (pfmu.muonRef().key() == muonRef.key()) {
349  aMuon.setPfEcalEnergy(pfmu.ecalEnergy());
350  }
351  }
352  }
353  }
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:576
double ecalEnergy() const
return corrected Ecal energy
Definition: PFCandidate.h:221
int i
Definition: DBlmapReader.cc:9
void newEvent(const edm::Event &event)
To be called for each new event, reads in the ValueMaps for efficiencies.
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
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:462
bool embedCaloMETMuonCorrs_
embed muon MET correction info for caloMET into the muon
assert(m_qm.get())
key_type key() const
Accessor for product key.
Definition: Ref.h:264
PFCandidateCollection::const_iterator PFCandidateConstIterator
iterator
bool isRealData() const
Definition: EventBase.h:63
void embedHighLevel(pat::Muon &aMuon, reco::TrackRef track, reco::TransientTrack &tt, reco::Vertex &primaryVertex, bool primaryVertexIsValid, reco::BeamSpot &beamspot, bool beamspotIsValid)
ProductID id() const
Accessor for product ID.
Definition: Ref.h:258
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
tuple primaryVertex
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:121
bool embedPfEcalEnergy_
add ecal PF energy
void newEvent(const edm::Event &event, const edm::EventSetup &setup)
To be called for each new event, reads in the EventSetup object.
int j
Definition: DBlmapReader.cc:9
bool isValid() const
Definition: HandleBase.h:75
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:56
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
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
ProductIndex id() const
Definition: ProductID.h:38
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
edm::RefToBase< reco::Muon > MuonBaseRef
typedefs for convenience
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
Analysis-level muon class.
Definition: Muon.h:49
pat::helper::KinResolutionsLoader resolutionLoader_
helper class to add resolutions to the muon
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const
Definition: MultiIsolator.h:82
tuple pfMuons
Definition: pfMuons_cff.py:8
bool embedHighLevelSelection_
embed high level selection variables
template<typename T >
void pat::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 166 of file PATMuonProducer.h.

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

167 {
168  labels.clear();
169 
170  if (iConfig.exists( psetName )) {
171  edm::ParameterSet depconf = iConfig.getParameter<edm::ParameterSet>(psetName);
172 
173  if (depconf.exists("tracker")) labels.push_back(std::make_pair(pat::TrackIso, depconf.getParameter<edm::InputTag>("tracker")));
174  if (depconf.exists("ecal")) labels.push_back(std::make_pair(pat::EcalIso, depconf.getParameter<edm::InputTag>("ecal")));
175  if (depconf.exists("hcal")) labels.push_back(std::make_pair(pat::HcalIso, depconf.getParameter<edm::InputTag>("hcal")));
176  if (depconf.exists("pfAllParticles")) {
177  labels.push_back(std::make_pair(pat::PfAllParticleIso, depconf.getParameter<edm::InputTag>("pfAllParticles")));
178  }
179  if (depconf.exists("pfChargedHadrons")) {
180  labels.push_back(std::make_pair(pat::PfChargedHadronIso, depconf.getParameter<edm::InputTag>("pfChargedHadrons")));
181  }
182  if (depconf.exists("pfChargedAll")) {
183  labels.push_back(std::make_pair(pat::PfChargedAllIso, depconf.getParameter<edm::InputTag>("pfChargedAll")));
184  }
185  if (depconf.exists("pfPUChargedHadrons")) {
186  labels.push_back(std::make_pair(pat::PfPUChargedHadronIso, depconf.getParameter<edm::InputTag>("pfPUChargedHadrons")));
187  }
188  if (depconf.exists("pfNeutralHadrons")) {
189  labels.push_back(std::make_pair(pat::PfNeutralHadronIso, depconf.getParameter<edm::InputTag>("pfNeutralHadrons")));
190  }
191  if (depconf.exists("pfPhotons")) {
192  labels.push_back(std::make_pair(pat::PfGammaIso, depconf.getParameter<edm::InputTag>("pfPhotons")));
193  }
194  if (depconf.exists("user")) {
195  std::vector<edm::InputTag> userdeps = depconf.getParameter<std::vector<edm::InputTag> >("user");
196  std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
198  for ( ; it != ed; ++it, ++key) {
199  labels.push_back(std::make_pair(pat::IsolationKeys(key), *it));
200  }
201  tokens = edm::vector_transform(labels, [this](IsolationLabel const & label){return consumes<edm::ValueMap<T> >(label.second);});
202  }
203  }
204  tokens = edm::vector_transform(labels, [this](pat::PATMuonProducer::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
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.

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 141 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(), PATMuonProducer(), and produce().

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::embedPfEcalEnergy_
private

add ecal PF energy

Definition at line 145 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 135 of file PATMuonProducer.h.

Referenced by fillMuon().

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

Definition at line 136 of file PATMuonProducer.h.

Referenced by produce().

IsolationLabels pat::PATMuonProducer::isolationValueLabels_
private

input source isolation value maps

Definition at line 138 of file PATMuonProducer.h.

Referenced by fillMuon().

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

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

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 143 of file PATMuonProducer.h.

Referenced by produce().