CMS 3D CMS Logo

PATMuonProducer.h
Go to the documentation of this file.
1 //
2 //
3 
4 #ifndef PhysicsTools_PatAlgos_PATMuonProducer_h
5 #define PhysicsTools_PatAlgos_PATMuonProducer_h
6 
18 #include <string>
19 
25 
30 
37 
38 namespace pat {
40  class TrackerIsolationPt;
41  class CaloIsolationEnergy;
42 
45 
46  public:
48  explicit PATMuonProducer(const edm::ParameterSet & iConfig);
50  ~PATMuonProducer() override;
52  void produce(edm::Event & iEvent, const edm::EventSetup& iSetup) override;
54  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
55 
56  private:
59  typedef std::vector<edm::Handle<edm::Association<reco::GenParticleCollection> > > GenAssociations;
60  typedef std::vector< edm::Handle< edm::ValueMap<IsoDeposit> > > IsoDepositMaps;
61  typedef std::vector< edm::Handle< edm::ValueMap<double> > > IsolationValueMaps;
62  typedef std::pair<pat::IsolationKeys,edm::InputTag> IsolationLabel;
63  typedef std::vector<IsolationLabel> IsolationLabels;
64 
65 
67  void fillMuon( Muon& aMuon, const MuonBaseRef& muonRef, const reco::CandidateBaseRef& baseRef, const GenAssociations& genMatches, const IsoDepositMaps& deposits, const IsolationValueMaps& isolationValues) const;
70  template<typename T> void readIsolationLabels( const edm::ParameterSet & iConfig, const char* psetName, IsolationLabels& labels, std::vector<edm::EDGetTokenT<edm::ValueMap<T> > > & tokens);
71 
73  double getRelMiniIsoPUCorrected(const pat::Muon& muon, float rho);
74 
75  // embed various impact parameters with errors
76  // embed high level selection
77  void embedHighLevel( pat::Muon & aMuon,
81  bool primaryVertexIsValid,
83  bool beamspotIsValid );
84  double relMiniIsoPUCorrected( const pat::Muon& aMuon,
85  double rho);
86 
87  private:
90 
91  // for mini-iso calculation
94  std::vector<double> miniIsoParams_;
96 
126  std::vector<edm::EDGetTokenT<edm::Association<reco::GenParticleCollection> > > genMatchTokens_;
146  IsolationLabels isoDepositLabels_;
147  std::vector<edm::EDGetTokenT<edm::ValueMap<IsoDeposit> > > isoDepositTokens_;
149  IsolationLabels isolationValueLabels_;
150  std::vector<edm::EDGetTokenT<edm::ValueMap<double> > > isolationValueTokens_;
159  //PUPPI isolation tokens
163  //PUPPINoLeptons isolation tokens
171  double mvaDrMax_;
181 
193 
196  };
197 
198 }
199 
200 
201 
202 
203 template<typename T>
205 {
206  labels.clear();
207 
208  if (iConfig.exists( psetName )) {
209  edm::ParameterSet depconf = iConfig.getParameter<edm::ParameterSet>(psetName);
210 
211  if (depconf.exists("tracker")) labels.push_back(std::make_pair(pat::TrackIso, depconf.getParameter<edm::InputTag>("tracker")));
212  if (depconf.exists("ecal")) labels.push_back(std::make_pair(pat::EcalIso, depconf.getParameter<edm::InputTag>("ecal")));
213  if (depconf.exists("hcal")) labels.push_back(std::make_pair(pat::HcalIso, depconf.getParameter<edm::InputTag>("hcal")));
214  if (depconf.exists("pfAllParticles")) {
215  labels.push_back(std::make_pair(pat::PfAllParticleIso, depconf.getParameter<edm::InputTag>("pfAllParticles")));
216  }
217  if (depconf.exists("pfChargedHadrons")) {
218  labels.push_back(std::make_pair(pat::PfChargedHadronIso, depconf.getParameter<edm::InputTag>("pfChargedHadrons")));
219  }
220  if (depconf.exists("pfChargedAll")) {
221  labels.push_back(std::make_pair(pat::PfChargedAllIso, depconf.getParameter<edm::InputTag>("pfChargedAll")));
222  }
223  if (depconf.exists("pfPUChargedHadrons")) {
224  labels.push_back(std::make_pair(pat::PfPUChargedHadronIso, depconf.getParameter<edm::InputTag>("pfPUChargedHadrons")));
225  }
226  if (depconf.exists("pfNeutralHadrons")) {
227  labels.push_back(std::make_pair(pat::PfNeutralHadronIso, depconf.getParameter<edm::InputTag>("pfNeutralHadrons")));
228  }
229  if (depconf.exists("pfPhotons")) {
230  labels.push_back(std::make_pair(pat::PfGammaIso, depconf.getParameter<edm::InputTag>("pfPhotons")));
231  }
232  if (depconf.exists("user")) {
233  std::vector<edm::InputTag> userdeps = depconf.getParameter<std::vector<edm::InputTag> >("user");
234  std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
236  for ( ; it != ed; ++it, ++key) {
237  labels.push_back(std::make_pair(pat::IsolationKeys(key), *it));
238  }
239  tokens = edm::vector_transform(labels, [this](IsolationLabel const & label){return consumes<edm::ValueMap<T> >(label.second);});
240  }
241  }
242  tokens = edm::vector_transform(labels, [this](pat::PATMuonProducer::IsolationLabel const & label){return consumes<edm::ValueMap<T> >(label.second);});
243 }
244 
245 #endif
bool embedTpfmsMuon_
embed track from tpfms muon fit into the muon
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_charged_hadrons_
bool useUserData_
add user data to the muon (this will be data members of th muon even w/o embedding) ...
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_photons_
T getParameter(std::string const &) const
std::pair< pat::IsolationKeys, edm::InputTag > IsolationLabel
Assists in assimilating all pat::UserData into pat objects.
pat::MuonMvaEstimator mvaEstimator_
bool addPuppiIsolation_
add puppi isolation
edm::EDGetTokenT< edm::ValueMap< reco::MuonMETCorrectionData > > tcMETMuonCorrsToken_
source of tcMET muon corrections
bool embedTcMETMuonCorrs_
embed muon MET correction info for tcMET into the muon
class definition
edm::EDGetTokenT< std::vector< reco::Vertex > > pvToken_
input source of the primary vertex
std::string mvaTrainingFile_
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_photons_
edm::EDGetTokenT< double > rho_
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
~PATMuonProducer() override
default destructur
edm::EDGetTokenT< edm::ValueMap< reco::MuonSimInfo > > simInfo_
MC info.
std::vector< pat::PackedCandidate > PackedCandidateCollection
void setMuonMiniIso(pat::Muon &aMuon, const pat::PackedCandidateCollection *pc)
bool exists(std::string const &parameterName) const
checks if a parameter exists
bool embedBestTrack_
embed the track from best muon measurement (global pflow)
edm::EDGetTokenT< reco::JetCorrector > mvaL1Corrector_
bool addResolutions_
add resolutions to the muon (this will be data members of th muon even w/o embedding) ...
IsolationKeys
Enum defining isolation keys.
Definition: Isolation.h:9
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_charged_hadrons_
std::vector< double > miniIsoParams_
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
void embedHighLevel(pat::Muon &aMuon, reco::TrackRef track, reco::TransientTrack &tt, reco::Vertex &primaryVertex, bool primaryVertexIsValid, reco::BeamSpot &beamspot, bool beamspotIsValid)
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_neutral_hadrons_
edm::EDGetTokenT< reco::JetTagCollection > mvaBTagCollectionTag_
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_
Definition: HeavyIon.h:7
std::vector< IsolationLabel > IsolationLabels
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
int iEvent
Definition: GenABIO.cc:230
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
Definition: Muon.py:1
bool embedPfEcalEnergy_
add ecal PF energy
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
everything that needs to be done during the event loop
double relMiniIsoPUCorrected(const pat::Muon &aMuon, double rho)
double getRelMiniIsoPUCorrected(const pat::Muon &muon, float rho)
edm::EDGetTokenT< pat::PackedCandidateCollection > pcToken_
bool embedTunePBestTrack_
embed the track from best muon measurement (muon only)
std::string softMvaTrainingFile_
std::vector< edm::Handle< edm::Association< reco::GenParticleCollection > > > GenAssociations
edm::EDGetTokenT< reco::JetCorrector > mvaL1L2L3ResCorrector_
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
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
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
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
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
bool forceEmbedBestTrack_
force separate embed of the best track even if already embedded
pat::SoftMuonMvaEstimator softMvaEstimator_
edm::RefToBase< reco::Muon > MuonBaseRef
typedefs for convenience
bool embedPFCandidate_
embed pfCandidates into the muon
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueTokens_
bool computeMuonMVA_
standard muon selectors
bool embedCombinedMuon_
embed track of the combined fit into the muon
Analysis-level muon class.
Definition: Muon.h:50
pat::helper::KinResolutionsLoader resolutionLoader_
helper class to add resolutions to the muon
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_neutral_hadrons_
bool embedHighLevelSelection_
embed high level selection variables