47 isolator_(iConfig.exists(
"userIsolation") ? iConfig.getParameter<edm::
ParameterSet>(
"userIsolation") : edm::
ParameterSet(), consumesCollector(),
false)
83 addEfficiencies_ = iConfig.getParameter<
bool>(
"addEfficiencies");
88 addResolutions_ = iConfig.getParameter<
bool>(
"addResolutions");
89 if (addResolutions_) {
93 readIsolationLabels(iConfig,
"isoDeposits", isoDepositLabels_, isoDepositTokens_);
95 readIsolationLabels(iConfig,
"isolationValues", isolationValueLabels_, isolationValueTokens_);
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"));
109 produces<std::vector<Muon> >();
113 PATMuonProducer::~PATMuonProducer()
159 bool beamSpotIsValid =
false;
160 bool primaryVertexIsValid =
false;
170 if( beamSpotHandle.
isValid() ){
171 beamSpot = *beamSpotHandle;
172 beamSpotIsValid =
true;
175 <<
"No beam spot available from EventSetup, not adding high level selection \n";
178 if( pvHandle.
isValid() && !pvHandle->empty() ) {
179 primaryVertex = pvHandle->at(0);
180 primaryVertexIsValid =
true;
183 <<
"No primary vertex available from EventSetup, not adding high level selection \n";
190 std::vector<Muon> *
patMuons =
new std::vector<Muon>();
205 Muon aMuon(muonBaseRef);
220 chosenTrack = bestTrack;
223 unsigned int nhits = chosenTrack->numberOfValidHits();
231 primaryVertexIsValid,
237 double corr_d0 = -1.0 * chosenTrack->dxy( beamPoint );
238 aMuon.
setDB( corr_d0, -1.0 );
241 double d0_corr = result.second.value();
242 double d0_err = result.second.error();
243 aMuon.
setDB( d0_corr, d0_err );
248 double norm_chi2 = globalTrack->chi2() / globalTrack->ndof();
258 fillMuon( aMuon, muonBaseRef, pfBaseRef, genMatches, deposits, isolationValues );
259 patMuons->push_back(aMuon);
281 unsigned int idx = itMuon - muons->begin();
286 fillMuon( aMuon, muonRef, muonBaseRef, genMatches, deposits, isolationValues);
319 chosenTrack = bestTrack;
321 unsigned int nhits = chosenTrack->numberOfValidHits();
329 primaryVertexIsValid,
335 double corr_d0 = -1.0 * chosenTrack->dxy( beamPoint );
336 aMuon.
setDB( corr_d0, -1.0 );
339 double d0_corr = result.second.value();
340 double d0_err = result.second.error();
341 aMuon.
setDB( d0_corr, d0_err );
346 double norm_chi2 = globalTrack->chi2() / globalTrack->ndof();
355 patMuons->push_back(aMuon);
363 std::auto_ptr<std::vector<Muon> > ptr(patMuons);
399 for(
size_t i = 0,
n = genMatches.size();
i <
n; ++
i) {
409 for (
size_t j = 0, nd = deposits.size();
j < nd; ++
j) {
425 for (
size_t j = 0;
j<isolationValues.size(); ++
j) {
429 }
else if (isolationValues[
j]->
contains(muonRef.
id())) {
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 ");
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");
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");
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;
483 )->
setComment(
"input with MC match information");
498 isoDepositsPSet.
addOptional<std::vector<edm::InputTag> >(
"user");
512 iDesc.
addOptional(
"isolationValues", isolationValuesPSet);
517 iDesc.
add(
"efficiencies", efficienciesPSet);
518 iDesc.
add<
bool>(
"addEfficiencies",
false);
527 iDesc.
add(
"userIsolation", isolationPSet);
529 iDesc.
add<
bool>(
"embedHighLevelSelection",
true)->setComment(
"embed high level selection");
533 )->
setComment(
"input with high level selection");
535 )->
setComment(
"input with high level selection");
537 )->
setComment(
"input with high level selection, use primary vertex (true) or beam line (false)");
550 bool primaryVertexIsValid,
558 std::pair<bool,Measurement1D>
result =
564 double d0_corr = result.second.value();
565 double d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
576 d0_corr = result.second.value();
577 d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
592 d0_corr = result.second.value();
593 d0_err = beamspotIsValid ? result.second.error() : -1.0;
603 d0_corr = result.second.value();
604 d0_err = beamspotIsValid ? result.second.error() : -1.0;
bool embedTpfmsMuon_
embed track from tpfms muon fit into the muon
bool enabled() const
'true' 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) ...
T getParameter(std::string const &) const
void setComment(std::string const &value)
double z0() const
z coordinate
Assists in assimilating all pat::UserData into pat objects.
bool usePV_
use the primary vertex or the beamspot
void embedDytMuon()
embed reference to the above dyt Track
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
bool isNonnull() const
Checks for non-null.
void embedTpfmsMuon()
embed reference to the above tpfms Track
edm::EDGetTokenT< edm::ValueMap< reco::MuonMETCorrectionData > > tcMETMuonCorrsToken_
source of tcMET muon corrections
void setIsolation(IsolationKeys key, float value)
bool embedTcMETMuonCorrs_
embed muon MET correction info for tcMET into the muon
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
void embedTcMETMuonCorrs(const reco::MuonMETCorrectionData &t)
edm::EDGetTokenT< std::vector< reco::Vertex > > pvToken_
input source of the primary vertex
bool contains(EventRange const &lh, EventID const &rh)
void embedCombinedMuon()
set reference to Track reconstructed in both tracked and muon detector (reimplemented from reco::Muon...
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
input source
void embedTunePMuonBestTrack(bool force=false)
edm::EDGetTokenT< edm::ValueMap< reco::MuonMETCorrectionData > > caloMETMuonCorrsToken_
source of caloMET muon corrections
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void setAllowAnything()
allow any parameter label/value pairs
#define DEFINE_FWK_MODULE(type)
bool embedCaloMETMuonCorrs_
embed muon MET correction info for caloMET into the muon
void embedMuonBestTrack(bool force=false)
bool isGlobalMuon() const
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
bool embedBestTrack_
embed the track from best muon measurement (global pflow)
virtual void setP4(const LorentzVector &p4)
set 4-momentum
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 >
PFCandidateCollection::const_iterator PFCandidateConstIterator
iterator
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
void setPFCandidateRef(const reco::PFCandidateRef &ref)
add a reference to the source IsolatedPFCandidate
void embedHighLevel(pat::Muon &aMuon, reco::TrackRef track, reco::TransientTrack &tt, reco::Vertex &primaryVertex, bool primaryVertexIsValid, reco::BeamSpot &beamspot, bool beamspotIsValid)
void embedStandAloneMuon()
set reference to Track reconstructed in the muon detector only (reimplemented from reco::Muon) ...
PATMuonProducer(const edm::ParameterSet &iConfig)
default constructir
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
'true' if this there is at least one efficiency configured
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void setIsoDeposit(IsolationKeys key, const IsoDeposit &dep)
Sets the IsoDeposit associated with some key; if it is already existent, it is overwritten.
void embedTrack()
set reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
static void fillDescription(edm::ParameterSetDescription &iDesc)
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.
bool embedStandAloneMuon_
embed track from muon system into the muon
void setComment(std::string const &value)
void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup)
GreaterByPt< Muon > pTComparator_
bool embedTrack_
embed the track from inner tracker into the muon
bool addGenMatch_
add generator match information
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
description of config file parameters
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
void embedPFCandidate()
embed the IsolatedPFCandidate pointed to by pfCandidateRef_
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
everything that needs to be done during the event loop
reco::PFCandidateRef pfCandidateRef() const
math::XYZPoint Point
point in the space
ParameterDescriptionBase * add(U const &iLabel, T const &value)
reco::MuonRef muonRef() const
bool isAValidMuonTrack(const MuonTrackType &type) const
void addGenParticleRef(const reco::GenParticleRef &ref)
bool embedTunePBestTrack_
embed the track from best muon measurement (muon only)
static void fillDescription(edm::ParameterSetDescription &iDesc)
Method for documentation and validation of PSet.
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
void setEfficiencies(pat::PATObject< T > &obj, const R &originalRef) const
Sets the efficiencies for this object, using the reference to the original objects.
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
Particle reconstructed by the particle flow algorithm.
pat::helper::EfficiencyLoader efficiencyLoader_
helper class to add efficiencies to the muon
bool embedPickyMuon_
embed track from picky muon fit into the muon
void setNormChi2(double normChi2)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
bool embedDytMuon_
embed track from DYT muon fit into the muon
void embedCaloMETMuonCorrs(const reco::MuonMETCorrectionData &t)
double y0() const
y coordinate
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
const Point & position() const
position
IsolationLabels isoDepositLabels_
input source for isoDeposits
std::vector< edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > > genMatchTokens_
input tags for generator match information
volatile std::atomic< bool > shutdown_flag false
Covariance3DMatrix rotatedCovariance3D() const
IsolationLabels isolationValueLabels_
input source isolation value maps
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
void embedPickyMuon()
embed reference to the above picky Track
bool forceEmbedBestTrack_
force separate embed of the best track even if already embedded
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_
void setNumberOfValidHits(unsigned int numberOfValidHits)
bool embedCombinedMuon_
embed track of the combined fit into the muon
Analysis-level muon class.
pat::helper::KinResolutionsLoader resolutionLoader_
helper class to add resolutions to the muon
static std::string const source
void newEvent(const edm::Event &event) const
To be called for each new event, reads in the ValueMaps for efficiencies.
void setDB(double dB, double edB, IpType type=None)
Global3DVector GlobalVector
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const
double x0() const
x coordinate
bool embedHighLevelSelection_
embed high level selection variables