CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
34 
35 
36 namespace pat {
38  class TrackerIsolationPt;
39  class CaloIsolationEnergy;
40 
43 
44  public:
46  explicit PATMuonProducer(const edm::ParameterSet & iConfig);
50  virtual void produce(edm::Event & iEvent, const edm::EventSetup& iSetup) override;
52  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
53 
54  private:
57  typedef std::vector<edm::Handle<edm::Association<reco::GenParticleCollection> > > GenAssociations;
58  typedef std::vector< edm::Handle< edm::ValueMap<IsoDeposit> > > IsoDepositMaps;
59  typedef std::vector< edm::Handle< edm::ValueMap<double> > > IsolationValueMaps;
60  typedef std::pair<pat::IsolationKeys,edm::InputTag> IsolationLabel;
61  typedef std::vector<IsolationLabel> IsolationLabels;
62 
63 
65  void fillMuon( Muon& aMuon, const MuonBaseRef& muonRef, const reco::CandidateBaseRef& baseRef, const GenAssociations& genMatches, const IsoDepositMaps& deposits, const IsolationValueMaps& isolationValues) const;
68  template<typename T> void readIsolationLabels( const edm::ParameterSet & iConfig, const char* psetName, IsolationLabels& labels, std::vector<edm::EDGetTokenT<edm::ValueMap<T> > > & tokens);
69 
70 
71  // embed various impact parameters with errors
72  // embed high level selection
73  void embedHighLevel( pat::Muon & aMuon,
74  reco::TrackRef track,
76  reco::Vertex & primaryVertex,
77  bool primaryVertexIsValid,
78  reco::BeamSpot & beamspot,
79  bool beamspotIsValid );
80 
81 
82  private:
85 
111  std::vector<edm::EDGetTokenT<edm::Association<reco::GenParticleCollection> > > genMatchTokens_;
129  bool usePV_;
134  std::vector<edm::EDGetTokenT<edm::ValueMap<IsoDeposit> > > isoDepositTokens_;
137  std::vector<edm::EDGetTokenT<edm::ValueMap<double> > > isolationValueTokens_;
142 
154  };
155 
156 }
157 
158 
159 using namespace pat;
160 
161 
162 template<typename T>
163 void PATMuonProducer::readIsolationLabels( const edm::ParameterSet & iConfig, const char* psetName, IsolationLabels& labels, std::vector<edm::EDGetTokenT<edm::ValueMap<T> > > & tokens)
164 {
165  labels.clear();
166 
167  if (iConfig.exists( psetName )) {
168  edm::ParameterSet depconf = iConfig.getParameter<edm::ParameterSet>(psetName);
169 
170  if (depconf.exists("tracker")) labels.push_back(std::make_pair(pat::TrackIso, depconf.getParameter<edm::InputTag>("tracker")));
171  if (depconf.exists("ecal")) labels.push_back(std::make_pair(pat::EcalIso, depconf.getParameter<edm::InputTag>("ecal")));
172  if (depconf.exists("hcal")) labels.push_back(std::make_pair(pat::HcalIso, depconf.getParameter<edm::InputTag>("hcal")));
173  if (depconf.exists("pfAllParticles")) {
174  labels.push_back(std::make_pair(pat::PfAllParticleIso, depconf.getParameter<edm::InputTag>("pfAllParticles")));
175  }
176  if (depconf.exists("pfChargedHadrons")) {
177  labels.push_back(std::make_pair(pat::PfChargedHadronIso, depconf.getParameter<edm::InputTag>("pfChargedHadrons")));
178  }
179  if (depconf.exists("pfChargedAll")) {
180  labels.push_back(std::make_pair(pat::PfChargedAllIso, depconf.getParameter<edm::InputTag>("pfChargedAll")));
181  }
182  if (depconf.exists("pfPUChargedHadrons")) {
183  labels.push_back(std::make_pair(pat::PfPUChargedHadronIso, depconf.getParameter<edm::InputTag>("pfPUChargedHadrons")));
184  }
185  if (depconf.exists("pfNeutralHadrons")) {
186  labels.push_back(std::make_pair(pat::PfNeutralHadronIso, depconf.getParameter<edm::InputTag>("pfNeutralHadrons")));
187  }
188  if (depconf.exists("pfPhotons")) {
189  labels.push_back(std::make_pair(pat::PfGammaIso, depconf.getParameter<edm::InputTag>("pfPhotons")));
190  }
191  if (depconf.exists("user")) {
192  std::vector<edm::InputTag> userdeps = depconf.getParameter<std::vector<edm::InputTag> >("user");
193  std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
194  int key = UserBaseIso;
195  for ( ; it != ed; ++it, ++key) {
196  labels.push_back(std::make_pair(IsolationKeys(key), *it));
197  }
198  }
199  }
200  tokens = edm::vector_transform(labels, [this](IsolationLabel const & label){return consumes<edm::ValueMap<T> >(label.second);});
201 }
202 
203 #endif
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
std::pair< pat::IsolationKeys, edm::InputTag > IsolationLabel
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
class definition
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
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
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)
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_
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
~PATMuonProducer()
default destructur
int iEvent
Definition: GenABIO.cc:243
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
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
everything that needs to be done during the event loop
void readIsolationLabels(const edm::ParameterSet &iConfig, const char *psetName, IsolationLabels &labels, std::vector< edm::EDGetTokenT< edm::ValueMap< T > > > &tokens)
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
pat::helper::EfficiencyLoader efficiencyLoader_
helper class to add efficiencies to the muon
bool embedPickyMuon_
embed track from picky muon fit into the muon
list key
Definition: combine.py:13
bool embedDytMuon_
embed track from DYT muon fit into the muon
Calculates a lepton&#39;s calorimetric isolation energy.
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
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
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
Calculates a lepton&#39;s tracker isolation pt.
bool embedHighLevelSelection_
embed high level selection variables