CMS 3D CMS Logo

PATMuonProducer.cc
Go to the documentation of this file.
1 //
2 //
3 
5 
9 
13 
15 
19 
22 
24 
27 
31 
36 
37 #include "TMath.h"
38 
40 
45 
46 #include <vector>
47 #include <memory>
48 
49 
50 using namespace pat;
51 using namespace std;
52 
53 
55  relMiniIsoPUCorrected_(0),
56  useUserData_(iConfig.exists("userData")),
57  computeMuonMVA_(false),
58  recomputeBasicSelectors_(false),
59  mvaDrMax_(0),
60  mvaUseJec_(false),
61  isolator_(iConfig.exists("userIsolation") ? iConfig.getParameter<edm::ParameterSet>("userIsolation") : edm::ParameterSet(), consumesCollector(), false)
62 {
63  // input source
64  muonToken_ = consumes<edm::View<reco::Muon> >(iConfig.getParameter<edm::InputTag>( "muonSource" ));
65  // embedding of tracks
66  embedBestTrack_ = iConfig.getParameter<bool>( "embedMuonBestTrack" );
67  embedTunePBestTrack_ = iConfig.getParameter<bool>( "embedTunePMuonBestTrack" );
68  forceEmbedBestTrack_ = iConfig.getParameter<bool>( "forceBestTrackEmbedding" );
69  embedTrack_ = iConfig.getParameter<bool>( "embedTrack" );
70  embedCombinedMuon_ = iConfig.getParameter<bool>( "embedCombinedMuon" );
71  embedStandAloneMuon_ = iConfig.getParameter<bool>( "embedStandAloneMuon" );
72  // embedding of muon MET correction information
73  embedCaloMETMuonCorrs_ = iConfig.getParameter<bool>("embedCaloMETMuonCorrs" );
74  embedTcMETMuonCorrs_ = iConfig.getParameter<bool>("embedTcMETMuonCorrs" );
75  caloMETMuonCorrsToken_ = mayConsume<edm::ValueMap<reco::MuonMETCorrectionData> >(iConfig.getParameter<edm::InputTag>("caloMETMuonCorrs" ));
76  tcMETMuonCorrsToken_ = mayConsume<edm::ValueMap<reco::MuonMETCorrectionData> >(iConfig.getParameter<edm::InputTag>("tcMETMuonCorrs" ));
77  // pflow specific configurables
78  useParticleFlow_ = iConfig.getParameter<bool>( "useParticleFlow" );
79  embedPFCandidate_ = iConfig.getParameter<bool>( "embedPFCandidate" );
80  pfMuonToken_ = mayConsume<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>( "pfMuonSource" ));
81  embedPfEcalEnergy_ = iConfig.getParameter<bool>( "embedPfEcalEnergy" );
82  // embedding of tracks from TeV refit
83  embedPickyMuon_ = iConfig.getParameter<bool>( "embedPickyMuon" );
84  embedTpfmsMuon_ = iConfig.getParameter<bool>( "embedTpfmsMuon" );
85  embedDytMuon_ = iConfig.getParameter<bool>( "embedDytMuon" );
86  // Monte Carlo matching
87  addGenMatch_ = iConfig.getParameter<bool>( "addGenMatch" );
88  if (addGenMatch_) {
89  embedGenMatch_ = iConfig.getParameter<bool>( "embedGenMatch" );
90  if (iConfig.existsAs<edm::InputTag>("genParticleMatch")) {
92  }
93  else {
94  genMatchTokens_ = edm::vector_transform(iConfig.getParameter<std::vector<edm::InputTag> >( "genParticleMatch" ), [this](edm::InputTag const & tag){return consumes<edm::Association<reco::GenParticleCollection> >(tag);});
95  }
96  }
97  // efficiencies
98  addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies");
99  if(addEfficiencies_){
101  }
102  // resolutions
103  addResolutions_ = iConfig.getParameter<bool>("addResolutions");
104  if (addResolutions_) {
106  }
107  // puppi
108  addPuppiIsolation_ = iConfig.getParameter<bool>("addPuppiIsolation");
109  if(addPuppiIsolation_){
110  PUPPIIsolation_charged_hadrons_ = consumes<edm::ValueMap<float> >(iConfig.getParameter<edm::InputTag>("puppiIsolationChargedHadrons"));
111  PUPPIIsolation_neutral_hadrons_ = consumes<edm::ValueMap<float> >(iConfig.getParameter<edm::InputTag>("puppiIsolationNeutralHadrons"));
112  PUPPIIsolation_photons_ = consumes<edm::ValueMap<float> >(iConfig.getParameter<edm::InputTag>("puppiIsolationPhotons"));
113  //puppiNoLeptons
114  PUPPINoLeptonsIsolation_charged_hadrons_ = consumes<edm::ValueMap<float> >(iConfig.getParameter<edm::InputTag>("puppiNoLeptonsIsolationChargedHadrons"));
115  PUPPINoLeptonsIsolation_neutral_hadrons_ = consumes<edm::ValueMap<float> >(iConfig.getParameter<edm::InputTag>("puppiNoLeptonsIsolationNeutralHadrons"));
116  PUPPINoLeptonsIsolation_photons_ = consumes<edm::ValueMap<float> >(iConfig.getParameter<edm::InputTag>("puppiNoLeptonsIsolationPhotons"));
117  }
118  // read isoDeposit labels, for direct embedding
119  readIsolationLabels(iConfig, "isoDeposits", isoDepositLabels_, isoDepositTokens_);
120  // read isolation value labels, for direct embedding
122  // check to see if the user wants to add user data
123  if( useUserData_ ){
125  }
126  // embed high level selection variables
127  embedHighLevelSelection_ = iConfig.getParameter<bool>("embedHighLevelSelection");
128  if ( embedHighLevelSelection_ ) {
129  beamLineToken_ = consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamLineSrc"));
130  pvToken_ = consumes<std::vector<reco::Vertex> >(iConfig.getParameter<edm::InputTag>("pvSrc"));
131  }
132 
133  //for mini-isolation calculation
134  computeMiniIso_ = iConfig.getParameter<bool>("computeMiniIso");
135 
136  miniIsoParams_ = iConfig.getParameter<std::vector<double> >("miniIsoParams");
137  if(computeMiniIso_ && miniIsoParams_.size() != 9){
138  throw cms::Exception("ParameterError") << "miniIsoParams must have exactly 9 elements.\n";
139  }
140  if(computeMiniIso_)
141  pcToken_ = consumes<pat::PackedCandidateCollection >(iConfig.getParameter<edm::InputTag>("pfCandsForMiniIso"));
142 
143  // standard selectors
144  recomputeBasicSelectors_ = iConfig.getParameter<bool>("recomputeBasicSelectors");
145  computeMuonMVA_ = iConfig.getParameter<bool>("computeMuonMVA");
146  mvaTrainingFile_ = iConfig.getParameter<std::string>("mvaTrainingFile");
147  if (computeMuonMVA_ and not computeMiniIso_)
148  throw cms::Exception("ConfigurationError") << "MiniIso is needed for Muon MVA calculation.\n";
149 
150  if (computeMuonMVA_) {
151  // pfCombinedInclusiveSecondaryVertexV2BJetTags
152  mvaBTagCollectionTag_ = consumes<reco::JetTagCollection>(iConfig.getParameter<edm::InputTag>("mvaJetTag"));
153  mvaL1Corrector_ = consumes<reco::JetCorrector>(iConfig.getParameter<edm::InputTag>("mvaL1Corrector"));
154  mvaL1L2L3ResCorrector_ = consumes<reco::JetCorrector>(iConfig.getParameter<edm::InputTag>("mvaL1L2L3ResCorrector"));
155  rho_ = consumes<double>(iConfig.getParameter<edm::InputTag>("rho"));
156  mvaUseJec_ = iConfig.getParameter<bool>("mvaUseJec");
157  mvaDrMax_ = iConfig.getParameter<double>("mvaDrMax");
158 
159  // xml training file
160  edm::FileInPath fip(mvaTrainingFile_);
161  mvaEstimator_.initialize(fip.fullPath(),mvaDrMax_);
162  }
163 
164  // MC info
165  simInfo_ = consumes<edm::ValueMap<reco::MuonSimInfo> >(iConfig.getParameter<edm::InputTag>("muonSimInfo"));
166 
167  // produces vector of muons
168  produces<std::vector<Muon> >();
169 }
170 
171 
173 {
174 }
175 
177 {
178  // switch off embedding (in unschedules mode)
179  if (iEvent.isRealData()){
180  addGenMatch_ = false;
181  embedGenMatch_ = false;
182  }
183 
185  iEvent.getByToken(muonToken_, muons);
186 
187 
189  if(computeMiniIso_)
190  iEvent.getByToken(pcToken_, pc);
191 
192  // get the ESHandle for the transient track builder,
193  // if needed for high level selection embedding
195 
196  if(isolator_.enabled()) isolator_.beginEvent(iEvent,iSetup);
198  if(resolutionLoader_.enabled()) resolutionLoader_.newEvent(iEvent, iSetup);
199 
201  for (size_t j = 0; j<isoDepositTokens_.size(); ++j) {
202  iEvent.getByToken(isoDepositTokens_[j], deposits[j]);
203  }
204 
206  for (size_t j = 0; j<isolationValueTokens_.size(); ++j) {
208  }
209 
210  //value maps for puppi isolation
211  edm::Handle<edm::ValueMap<float>> PUPPIIsolation_charged_hadrons;
212  edm::Handle<edm::ValueMap<float>> PUPPIIsolation_neutral_hadrons;
213  edm::Handle<edm::ValueMap<float>> PUPPIIsolation_photons;
214  //value maps for puppiNoLeptons isolation
215  edm::Handle<edm::ValueMap<float>> PUPPINoLeptonsIsolation_charged_hadrons;
216  edm::Handle<edm::ValueMap<float>> PUPPINoLeptonsIsolation_neutral_hadrons;
217  edm::Handle<edm::ValueMap<float>> PUPPINoLeptonsIsolation_photons;
218  if(addPuppiIsolation_){
219  //puppi
220  iEvent.getByToken(PUPPIIsolation_charged_hadrons_, PUPPIIsolation_charged_hadrons);
221  iEvent.getByToken(PUPPIIsolation_neutral_hadrons_, PUPPIIsolation_neutral_hadrons);
222  iEvent.getByToken(PUPPIIsolation_photons_, PUPPIIsolation_photons);
223  //puppiNoLeptons
224  iEvent.getByToken(PUPPINoLeptonsIsolation_charged_hadrons_, PUPPINoLeptonsIsolation_charged_hadrons);
225  iEvent.getByToken(PUPPINoLeptonsIsolation_neutral_hadrons_, PUPPINoLeptonsIsolation_neutral_hadrons);
226  iEvent.getByToken(PUPPINoLeptonsIsolation_photons_, PUPPINoLeptonsIsolation_photons);
227  }
228 
229  // inputs for muon mva
230  edm::Handle<reco::JetTagCollection> mvaBTagCollectionTag;
233  if (computeMuonMVA_) {
234  iEvent.getByToken(mvaBTagCollectionTag_,mvaBTagCollectionTag);
235  iEvent.getByToken(mvaL1Corrector_,mvaL1Corrector);
236  iEvent.getByToken(mvaL1L2L3ResCorrector_,mvaL1L2L3ResCorrector);
237  }
238 
239  // prepare the MC genMatchTokens_
240  GenAssociations genMatches(genMatchTokens_.size());
241  if (addGenMatch_) {
242  for (size_t j = 0, nd = genMatchTokens_.size(); j < nd; ++j) {
243  iEvent.getByToken(genMatchTokens_[j], genMatches[j]);
244  }
245  }
246 
247  // prepare the high level selection: needs beamline
248  // OR primary vertex, depending on user selection
251  bool beamSpotIsValid = false;
252  bool primaryVertexIsValid = false;
253  if ( embedHighLevelSelection_ ) {
254  // get the beamspot
255  edm::Handle<reco::BeamSpot> beamSpotHandle;
256  iEvent.getByToken(beamLineToken_, beamSpotHandle);
257 
258  // get the primary vertex
260  iEvent.getByToken( pvToken_, pvHandle );
261 
262  if( beamSpotHandle.isValid() ){
263  beamSpot = *beamSpotHandle;
264  beamSpotIsValid = true;
265  } else{
266  edm::LogError("DataNotAvailable")
267  << "No beam spot available from EventSetup, not adding high level selection \n";
268  }
269  if( pvHandle.isValid() && !pvHandle->empty() ) {
270  primaryVertex = pvHandle->at(0);
271  primaryVertexIsValid = true;
272  } else {
273  edm::LogError("DataNotAvailable")
274  << "No primary vertex available from EventSetup, not adding high level selection \n";
275  }
276  // this is needed by the IPTools methods from the tracking group
277  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", trackBuilder);
278  }
279 
280  // MC info
282  bool simInfoIsAvailalbe = iEvent.getByToken(simInfo_,simInfo);
283 
284  // this will be the new object collection
285  std::vector<Muon> * patMuons = new std::vector<Muon>();
286 
288  if( useParticleFlow_ ){
289  // get the PFCandidates of type muons
290  iEvent.getByToken(pfMuonToken_, pfMuons);
291 
292  unsigned index=0;
293  for( reco::PFCandidateConstIterator i = pfMuons->begin(); i != pfMuons->end(); ++i, ++index) {
294  const reco::PFCandidate& pfmu = *i;
295  //const reco::IsolaPFCandidate& pfmu = *i;
296  const reco::MuonRef& muonRef = pfmu.muonRef();
297  assert( muonRef.isNonnull() );
298 
299  MuonBaseRef muonBaseRef(muonRef);
300  Muon aMuon(muonBaseRef);
301 
302  if ( useUserData_ ) {
303  userDataHelper_.add( aMuon, iEvent, iSetup );
304  }
305 
306  // embed high level selection
307  if ( embedHighLevelSelection_ ) {
308  // get the tracks
309  reco::TrackRef innerTrack = muonBaseRef->innerTrack();
310  reco::TrackRef globalTrack= muonBaseRef->globalTrack();
311  reco::TrackRef bestTrack = muonBaseRef->muonBestTrack();
312  reco::TrackRef chosenTrack = innerTrack;
313  // Make sure the collection it points to is there
314  if ( bestTrack.isNonnull() && bestTrack.isAvailable() )
315  chosenTrack = bestTrack;
316 
317  if ( chosenTrack.isNonnull() && chosenTrack.isAvailable() ) {
318  unsigned int nhits = chosenTrack->numberOfValidHits(); // ????
319  aMuon.setNumberOfValidHits( nhits );
320 
321  reco::TransientTrack tt = trackBuilder->build(chosenTrack);
322  embedHighLevel( aMuon,
323  chosenTrack,
324  tt,
325  primaryVertex,
326  primaryVertexIsValid,
327  beamSpot,
328  beamSpotIsValid );
329 
330  }
331 
332  if ( globalTrack.isNonnull() && globalTrack.isAvailable() && !embedCombinedMuon_) {
333  double norm_chi2 = globalTrack->chi2() / globalTrack->ndof();
334  aMuon.setNormChi2( norm_chi2 );
335  }
336  }
337  reco::PFCandidateRef pfRef(pfMuons,index);
338  //reco::PFCandidatePtr ptrToMother(pfMuons,index);
339  reco::CandidateBaseRef pfBaseRef( pfRef );
340 
341  aMuon.setPFCandidateRef( pfRef );
342  if( embedPFCandidate_ ) aMuon.embedPFCandidate();
343  fillMuon( aMuon, muonBaseRef, pfBaseRef, genMatches, deposits, isolationValues );
344 
345  if(computeMiniIso_)
346  setMuonMiniIso(aMuon, pc.product());
347 
348  if (addPuppiIsolation_) {
349  aMuon.setIsolationPUPPI((*PUPPIIsolation_charged_hadrons)[muonBaseRef],
350  (*PUPPIIsolation_neutral_hadrons)[muonBaseRef],
351  (*PUPPIIsolation_photons)[muonBaseRef]);
352 
353  aMuon.setIsolationPUPPINoLeptons((*PUPPINoLeptonsIsolation_charged_hadrons)[muonBaseRef],
354  (*PUPPINoLeptonsIsolation_neutral_hadrons)[muonBaseRef],
355  (*PUPPINoLeptonsIsolation_photons)[muonBaseRef]);
356  }
357  else {
358  aMuon.setIsolationPUPPI(-999., -999.,-999.);
359  aMuon.setIsolationPUPPINoLeptons(-999., -999.,-999.);
360  }
361 
362  if (embedPfEcalEnergy_) {
363  aMuon.setPfEcalEnergy(pfmu.ecalEnergy());
364  }
365 
366  patMuons->push_back(aMuon);
367  }
368  }
369  else {
371  iEvent.getByToken(muonToken_, muons);
372 
373  // embedding of muon MET corrections
375  //edm::ValueMap<reco::MuonMETCorrectionData> caloMETmuCorValueMap;
377  iEvent.getByToken(caloMETMuonCorrsToken_, caloMETMuonCorrs);
378  //caloMETmuCorValueMap = *caloMETmuCorValueMap_h;
379  }
381  //edm::ValueMap<reco::MuonMETCorrectionData> tcMETmuCorValueMap;
383  iEvent.getByToken(tcMETMuonCorrsToken_, tcMETMuonCorrs);
384  //tcMETmuCorValueMap = *tcMETmuCorValueMap_h;
385  }
386 
387  if (embedPfEcalEnergy_) {
388  // get the PFCandidates of type muons
389  iEvent.getByToken(pfMuonToken_, pfMuons);
390  }
391 
392  for (edm::View<reco::Muon>::const_iterator itMuon = muons->begin(); itMuon != muons->end(); ++itMuon) {
393  // construct the Muon from the ref -> save ref to original object
394  unsigned int idx = itMuon - muons->begin();
395  MuonBaseRef muonRef = muons->refAt(idx);
396  reco::CandidateBaseRef muonBaseRef( muonRef );
397 
398  Muon aMuon(muonRef);
399  fillMuon( aMuon, muonRef, muonBaseRef, genMatches, deposits, isolationValues);
400  if(computeMiniIso_)
401  setMuonMiniIso(aMuon, pc.product());
402  if (addPuppiIsolation_) {
403  aMuon.setIsolationPUPPI((*PUPPIIsolation_charged_hadrons)[muonRef], (*PUPPIIsolation_neutral_hadrons)[muonRef], (*PUPPIIsolation_photons)[muonRef]);
404  aMuon.setIsolationPUPPINoLeptons((*PUPPINoLeptonsIsolation_charged_hadrons)[muonRef], (*PUPPINoLeptonsIsolation_neutral_hadrons)[muonRef], (*PUPPINoLeptonsIsolation_photons)[muonRef]);
405  }
406  else {
407  aMuon.setIsolationPUPPI(-999., -999.,-999.);
408  aMuon.setIsolationPUPPINoLeptons(-999., -999.,-999.);
409  }
410 
411  // Isolation
412  if (isolator_.enabled()) {
413  //reco::CandidatePtr mother = ptrToMother->sourceCandidatePtr(0);
414  isolator_.fill(*muons, idx, isolatorTmpStorage_);
415  typedef pat::helper::MultiIsolator::IsolationValuePairs IsolationValuePairs;
416  // better to loop backwards, so the vector is resized less times
417  for (IsolationValuePairs::const_reverse_iterator it = isolatorTmpStorage_.rbegin(), ed = isolatorTmpStorage_.rend(); it != ed; ++it) {
418  aMuon.setIsolation(it->first, it->second);
419  }
420  }
421 
422  // for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
423  // aMuon.setIsoDeposit(isoDepositLabels_[j].first,
424  // (*deposits[j])[muonRef]);
425  // }
426 
427  // add sel to selected
428  edm::Ptr<reco::Muon> muonsPtr = muons->ptrAt(idx);
429  if ( useUserData_ ) {
430  userDataHelper_.add( aMuon, iEvent, iSetup );
431  }
432 
433  // embed high level selection
434  if ( embedHighLevelSelection_ ) {
435  // get the tracks
436  reco::TrackRef innerTrack = itMuon->innerTrack();
437  reco::TrackRef globalTrack= itMuon->globalTrack();
438  reco::TrackRef bestTrack = itMuon->muonBestTrack();
439  reco::TrackRef chosenTrack = innerTrack;
440  // Make sure the collection it points to is there
441  if ( bestTrack.isNonnull() && bestTrack.isAvailable() )
442  chosenTrack = bestTrack;
443  if ( chosenTrack.isNonnull() && chosenTrack.isAvailable() ) {
444  unsigned int nhits = chosenTrack->numberOfValidHits(); // ????
445  aMuon.setNumberOfValidHits( nhits );
446 
447  reco::TransientTrack tt = trackBuilder->build(chosenTrack);
448  embedHighLevel( aMuon,
449  chosenTrack,
450  tt,
451  primaryVertex,
452  primaryVertexIsValid,
453  beamSpot,
454  beamSpotIsValid );
455 
456  }
457 
458  if ( globalTrack.isNonnull() && globalTrack.isAvailable() ) {
459  double norm_chi2 = globalTrack->chi2() / globalTrack->ndof();
460  aMuon.setNormChi2( norm_chi2 );
461  }
462  }
463 
464  // embed MET muon corrections
465  if( embedCaloMETMuonCorrs_ ) aMuon.embedCaloMETMuonCorrs((*caloMETMuonCorrs)[muonRef]);
466  if( embedTcMETMuonCorrs_ ) aMuon.embedTcMETMuonCorrs((*tcMETMuonCorrs )[muonRef]);
467 
468  if (embedPfEcalEnergy_) {
469  aMuon.setPfEcalEnergy(-99.0);
470  for (const reco::PFCandidate &pfmu : *pfMuons) {
471  if (pfmu.muonRef().isNonnull()) {
472  if (pfmu.muonRef().id() != muonRef.id()) throw cms::Exception("Configuration") << "Muon reference within PF candidates does not point to the muon collection." << std::endl;
473  if (pfmu.muonRef().key() == muonRef.key()) {
474  aMuon.setPfEcalEnergy(pfmu.ecalEnergy());
475  }
476  }
477  }
478  }
479  // MC info
480  aMuon.initSimInfo();
481  if (simInfoIsAvailalbe){
482  const auto& msi = (*simInfo)[muonBaseRef];
483  aMuon.setSimType(msi.primaryClass);
484  aMuon.setExtSimType(msi.extendedClass);
485  aMuon.setSimFlavour(msi.flavour);
486  aMuon.setSimHeaviestMotherFlavour(msi.heaviestMotherFlavour);
487  aMuon.setSimPdgId(msi.pdgId);
488  aMuon.setSimMotherPdgId(msi.motherPdgId);
489  aMuon.setSimBX(msi.tpBX);
490  aMuon.setSimProdRho(msi.vertex.Rho());
491  aMuon.setSimProdZ(msi.vertex.Z());
492  aMuon.setSimPt(msi.p4.pt());
493  aMuon.setSimEta(msi.p4.eta());
494  aMuon.setSimPhi(msi.p4.phi());
495  }
496  patMuons->push_back(aMuon);
497  }
498  }
499 
500  // sort muons in pt
501  std::sort(patMuons->begin(), patMuons->end(), pTComparator_);
502 
503  // Store standard muon selection decisions and jet related
504  // quantaties.
505  // Need a separate loop over muons to have all inputs properly
506  // computed and stored in the object.
508  if (computeMuonMVA_) iEvent.getByToken(rho_,rho);
509  const reco::Vertex* pv(nullptr);
510  if (primaryVertexIsValid) pv = &primaryVertex;
511  for(auto& muon: *patMuons){
513  muon.setSelectors(0);
514  bool isRun2016BCDEF = (272728 <= iEvent.run() && iEvent.run() <= 278808);
515  muon::setCutBasedSelectorFlags(muon, pv, isRun2016BCDEF);
516  }
517  if (computeMiniIso_){
518  // MiniIsolation working points
519  double iso = getRelMiniIsoPUCorrected(muon,*rho);
520  muon.setSelector(reco::Muon::MiniIsoLoose, iso<0.40);
521  muon.setSelector(reco::Muon::MiniIsoMedium, iso<0.20);
522  muon.setSelector(reco::Muon::MiniIsoTight, iso<0.10);
523  muon.setSelector(reco::Muon::MiniIsoVeryTight, iso<0.05);
524  }
525  if (computeMuonMVA_ && primaryVertexIsValid){
526  if (mvaUseJec_)
528  primaryVertex,
529  *(mvaBTagCollectionTag.product()),
530  &*mvaL1Corrector,
531  &*mvaL1L2L3ResCorrector);
532  else
534  primaryVertex,
535  *(mvaBTagCollectionTag.product()));
536 
537  muon.setMvaValue(mvaEstimator_.mva());
538  muon.setJetPtRatio(mvaEstimator_.jetPtRatio());
539  muon.setJetPtRel(mvaEstimator_.jetPtRel());
540 
541  // MVA working points
542  // https://twiki.cern.ch/twiki/bin/viewauth/CMS/LeptonMVA
543  double dB2D = fabs(muon.dB(pat::Muon::BS2D));
544  double dB3D = fabs(muon.dB(pat::Muon::PV3D));
545  double edB3D = fabs(muon.edB(pat::Muon::PV3D));
546  double sip3D = edB3D>0?dB3D/edB3D:0.0;
547  double dz = fabs(muon.muonBestTrack()->dz(primaryVertex.position()));
548 
549  // muon preselection
550  if (muon.pt()>5 and muon.isLooseMuon() and
551  muon.passed(reco::Muon::MiniIsoLoose) and
552  sip3D<8.0 and dB2D<0.05 and dz<0.1){
553  muon.setSelector(reco::Muon::MvaLoose, muon.mvaValue()>-0.60);
554  muon.setSelector(reco::Muon::MvaMedium, muon.mvaValue()>-0.20);
555  muon.setSelector(reco::Muon::MvaTight, muon.mvaValue()> 0.15);
556  }
557  }
558  }
559 
560  // put products in Event
561  std::unique_ptr<std::vector<Muon> > ptr(patMuons);
562  iEvent.put(std::move(ptr));
563 
565 }
566 
567 
568 void PATMuonProducer::fillMuon( Muon& aMuon, const MuonBaseRef& muonRef, const reco::CandidateBaseRef& baseRef, const GenAssociations& genMatches, const IsoDepositMaps& deposits, const IsolationValueMaps& isolationValues ) const
569 {
570  // in the particle flow algorithm,
571  // the muon momentum is recomputed.
572  // the new value is stored as the momentum of the
573  // resulting PFCandidate of type Muon, and choosen
574  // as the pat::Muon momentum
575  if (useParticleFlow_)
576  aMuon.setP4( aMuon.pfCandidateRef()->p4() );
577  if (embedTrack_) aMuon.embedTrack();
580 
581  // embed the TeV refit track refs (only available for globalMuons)
582  if (aMuon.isGlobalMuon()) {
584  aMuon.embedPickyMuon();
586  aMuon.embedTpfmsMuon();
588  aMuon.embedDytMuon();
589  }
590 
591  // embed best tracks (at the end, so unless forceEmbedBestTrack_ is true we can save some space not embedding them twice)
594 
595  // store the match to the generated final state muons
596  if (addGenMatch_) {
597  for(size_t i = 0, n = genMatches.size(); i < n; ++i) {
598  reco::GenParticleRef genMuon = (*genMatches[i])[baseRef];
599  aMuon.addGenParticleRef(genMuon);
600  }
601  if (embedGenMatch_) aMuon.embedGenParticle();
602  }
603  if (efficiencyLoader_.enabled()) {
604  efficiencyLoader_.setEfficiencies( aMuon, muonRef );
605  }
606 
607  for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
608  if(useParticleFlow_) {
609  if (deposits[j]->contains(baseRef.id())) {
610  aMuon.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[baseRef]);
611  } else if (deposits[j]->contains(muonRef.id())){
612  aMuon.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[muonRef]);
613  } else {
614  reco::CandidatePtr source = aMuon.pfCandidateRef()->sourceCandidatePtr(0);
615  aMuon.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[source]);
616  }
617  }
618  else{
619  aMuon.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[muonRef]);
620  }
621  }
622 
623  for (size_t j = 0; j<isolationValues.size(); ++j) {
624  if(useParticleFlow_) {
625  if (isolationValues[j]->contains(baseRef.id())) {
626  aMuon.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[baseRef]);
627  } else if (isolationValues[j]->contains(muonRef.id())) {
628  aMuon.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[muonRef]);
629  } else {
630  reco::CandidatePtr source = aMuon.pfCandidateRef()->sourceCandidatePtr(0);
631  aMuon.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[source]);
632  }
633  }
634  else{
635  aMuon.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[muonRef]);
636  }
637  }
638 
639  if (resolutionLoader_.enabled()) {
641  }
642 }
643 
645 {
646  pat::PFIsolation miniiso = pat::getMiniPFIsolation(pc, aMuon.p4(),
647  miniIsoParams_[0], miniIsoParams_[1], miniIsoParams_[2],
648  miniIsoParams_[3], miniIsoParams_[4], miniIsoParams_[5],
649  miniIsoParams_[6], miniIsoParams_[7], miniIsoParams_[8]);
650  aMuon.setMiniPFIsolation(miniiso);
651 }
652 
654 {
655  float mindr(miniIsoParams_[0]);
656  float maxdr(miniIsoParams_[1]);
657  float kt_scale(miniIsoParams_[2]);
658  float drcut = pat::miniIsoDr(muon.p4(),mindr,maxdr,kt_scale);
659  return pat::muonRelMiniIsoPUCorrected(muon.miniPFIsolation(), muon.p4(), drcut, rho);
660 }
661 
662 // ParameterSet description for module
664 {
666  iDesc.setComment("PAT muon producer module");
667 
668  // input source
669  iDesc.add<edm::InputTag>("muonSource", edm::InputTag("no default"))->setComment("input collection");
670 
671  // embedding
672  iDesc.add<bool>("embedMuonBestTrack", true)->setComment("embed muon best track (global pflow)");
673  iDesc.add<bool>("embedTunePMuonBestTrack", true)->setComment("embed muon best track (muon only)");
674  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");
675  iDesc.add<bool>("embedTrack", true)->setComment("embed external track");
676  iDesc.add<bool>("embedStandAloneMuon", true)->setComment("embed external stand-alone muon");
677  iDesc.add<bool>("embedCombinedMuon", false)->setComment("embed external combined muon");
678  iDesc.add<bool>("embedPickyMuon", false)->setComment("embed external picky track");
679  iDesc.add<bool>("embedTpfmsMuon", false)->setComment("embed external tpfms track");
680  iDesc.add<bool>("embedDytMuon", false)->setComment("embed external dyt track ");
681 
682  // embedding of MET muon corrections
683  iDesc.add<bool>("embedCaloMETMuonCorrs", true)->setComment("whether to add MET muon correction for caloMET or not");
684  iDesc.add<edm::InputTag>("caloMETMuonCorrs", edm::InputTag("muonMETValueMapProducer" , "muCorrData"))->setComment("source of MET muon corrections for caloMET");
685  iDesc.add<bool>("embedTcMETMuonCorrs", true)->setComment("whether to add MET muon correction for tcMET or not");
686  iDesc.add<edm::InputTag>("tcMETMuonCorrs", edm::InputTag("muonTCMETValueMapProducer" , "muCorrData"))->setComment("source of MET muon corrections for tcMET");
687 
688  // pf specific parameters
689  iDesc.add<edm::InputTag>("pfMuonSource", edm::InputTag("pfMuons"))->setComment("particle flow input collection");
690  iDesc.add<bool>("useParticleFlow", false)->setComment("whether to use particle flow or not");
691  iDesc.add<bool>("embedPFCandidate", false)->setComment("embed external particle flow object");
692  iDesc.add<bool>("embedPfEcalEnergy", true)->setComment("add ecal energy as reconstructed by PF");
693 
694  // MC matching configurables
695  iDesc.add<bool>("addGenMatch", true)->setComment("add MC matching");
696  iDesc.add<bool>("embedGenMatch", false)->setComment("embed MC matched MC information");
697  std::vector<edm::InputTag> emptySourceVector;
698  iDesc.addNode( edm::ParameterDescription<edm::InputTag>("genParticleMatch", edm::InputTag(), true) xor
699  edm::ParameterDescription<std::vector<edm::InputTag> >("genParticleMatch", emptySourceVector, true)
700  )->setComment("input with MC match information");
701 
702  // mini-iso
703  iDesc.add<bool>("computeMiniIso", false)->setComment("whether or not to compute and store electron mini-isolation");
704  iDesc.add<edm::InputTag>("pfCandsForMiniIso", edm::InputTag("packedPFCandidates"))->setComment("collection to use to compute mini-iso");
705  iDesc.add<std::vector<double> >("miniIsoParams", std::vector<double>())->setComment("mini-iso parameters to use for muons");
706 
708 
709  // IsoDeposit configurables
710  edm::ParameterSetDescription isoDepositsPSet;
711  isoDepositsPSet.addOptional<edm::InputTag>("tracker");
712  isoDepositsPSet.addOptional<edm::InputTag>("ecal");
713  isoDepositsPSet.addOptional<edm::InputTag>("hcal");
714  isoDepositsPSet.addOptional<edm::InputTag>("particle");
715  isoDepositsPSet.addOptional<edm::InputTag>("pfChargedHadrons");
716  isoDepositsPSet.addOptional<edm::InputTag>("pfChargedAll");
717  isoDepositsPSet.addOptional<edm::InputTag>("pfPUChargedHadrons");
718  isoDepositsPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
719  isoDepositsPSet.addOptional<edm::InputTag>("pfPhotons");
720  isoDepositsPSet.addOptional<std::vector<edm::InputTag> >("user");
721  iDesc.addOptional("isoDeposits", isoDepositsPSet);
722 
723  // isolation values configurables
724  edm::ParameterSetDescription isolationValuesPSet;
725  isolationValuesPSet.addOptional<edm::InputTag>("tracker");
726  isolationValuesPSet.addOptional<edm::InputTag>("ecal");
727  isolationValuesPSet.addOptional<edm::InputTag>("hcal");
728  isolationValuesPSet.addOptional<edm::InputTag>("particle");
729  isolationValuesPSet.addOptional<edm::InputTag>("pfChargedHadrons");
730  isolationValuesPSet.addOptional<edm::InputTag>("pfChargedAll");
731  isolationValuesPSet.addOptional<edm::InputTag>("pfPUChargedHadrons");
732  isolationValuesPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
733  isolationValuesPSet.addOptional<edm::InputTag>("pfPhotons");
734  iDesc.addOptional("isolationValues", isolationValuesPSet);
735 
736  iDesc.ifValue(edm::ParameterDescription<bool>("addPuppiIsolation", false, true),
737  true >> (edm::ParameterDescription<edm::InputTag>("puppiIsolationChargedHadrons", edm::InputTag("muonPUPPIIsolation","h+-DR030-ThresholdVeto000-ConeVeto000"), true) and
738  edm::ParameterDescription<edm::InputTag>("puppiIsolationNeutralHadrons", edm::InputTag("muonPUPPIIsolation","h0-DR030-ThresholdVeto000-ConeVeto001"), true) and
739  edm::ParameterDescription<edm::InputTag>("puppiIsolationPhotons", edm::InputTag("muonPUPPIIsolation","gamma-DR030-ThresholdVeto000-ConeVeto001"), true) and
740  edm::ParameterDescription<edm::InputTag>("puppiNoLeptonsIsolationChargedHadrons", edm::InputTag("muonPUPPINoLeptonsIsolation","h+-DR030-ThresholdVeto000-ConeVeto000"), true) and
741  edm::ParameterDescription<edm::InputTag>("puppiNoLeptonsIsolationNeutralHadrons", edm::InputTag("muonPUPPINoLeptonsIsolation","h0-DR030-ThresholdVeto000-ConeVeto001"), true) and
742  edm::ParameterDescription<edm::InputTag>("puppiNoLeptonsIsolationPhotons", edm::InputTag("muonPUPPINoLeptonsIsolation","gamma-DR030-ThresholdVeto000-ConeVeto001"), true)) or
743  false >> edm::EmptyGroupDescription());
744 
745  // Efficiency configurables
746  edm::ParameterSetDescription efficienciesPSet;
747  efficienciesPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
748  iDesc.add("efficiencies", efficienciesPSet);
749  iDesc.add<bool>("addEfficiencies", false);
750 
751  // Check to see if the user wants to add user data
752  edm::ParameterSetDescription userDataPSet;
754  iDesc.addOptional("userData", userDataPSet);
755 
756  edm::ParameterSetDescription isolationPSet;
757  isolationPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
758  iDesc.add("userIsolation", isolationPSet);
759 
760  iDesc.add<bool>("embedHighLevelSelection", true)->setComment("embed high level selection");
761  edm::ParameterSetDescription highLevelPSet;
762  highLevelPSet.setAllowAnything();
763  iDesc.addNode( edm::ParameterDescription<edm::InputTag>("beamLineSrc", edm::InputTag(), true)
764  )->setComment("input with high level selection");
766  )->setComment("input with high level selection");
767 
768  //descriptions.add("PATMuonProducer", iDesc);
769 }
770 
771 
772 
773 // embed various impact parameters with errors
774 // embed high level selection
779  bool primaryVertexIsValid,
781  bool beamspotIsValid
782  )
783 {
784  // Correct to PV
785 
786  // PV2D
787  std::pair<bool,Measurement1D> result =
789  GlobalVector(track->px(),
790  track->py(),
791  track->pz()),
792  primaryVertex);
793  double d0_corr = result.second.value();
794  double d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
795  aMuon.setDB( d0_corr, d0_err, pat::Muon::PV2D);
796 
797 
798  // PV3D
799  result =
801  GlobalVector(track->px(),
802  track->py(),
803  track->pz()),
804  primaryVertex);
805  d0_corr = result.second.value();
806  d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
807  aMuon.setDB( d0_corr, d0_err, pat::Muon::PV3D);
808 
809 
810  // Correct to beam spot
811  // make a fake vertex out of beam spot
812  reco::Vertex vBeamspot(beamspot.position(), beamspot.rotatedCovariance3D());
813 
814  // BS2D
815  result =
817  GlobalVector(track->px(),
818  track->py(),
819  track->pz()),
820  vBeamspot);
821  d0_corr = result.second.value();
822  d0_err = beamspotIsValid ? result.second.error() : -1.0;
823  aMuon.setDB( d0_corr, d0_err, pat::Muon::BS2D);
824 
825  // BS3D
826  result =
828  GlobalVector(track->px(),
829  track->py(),
830  track->pz()),
831  vBeamspot);
832  d0_corr = result.second.value();
833  d0_err = beamspotIsValid ? result.second.error() : -1.0;
834  aMuon.setDB( d0_corr, d0_err, pat::Muon::BS3D);
835 
836 
837  // PVDZ
838  aMuon.setDB( track->dz(primaryVertex.position()), std::hypot(track->dzError(), primaryVertex.zError()), pat::Muon::PVDZ );
839 }
840 
842 
bool embedTpfmsMuon_
embed track from tpfms muon fit into the muon
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_charged_hadrons_
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:577
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_photons_
T getParameter(std::string const &) const
double ecalEnergy() const
return corrected Ecal energy
Definition: PFCandidate.h:221
void setComment(std::string const &value)
Assists in assimilating all pat::UserData into pat objects.
pat::MuonMvaEstimator mvaEstimator_
void newEvent(const edm::Event &event)
To be called for each new event, reads in the ValueMaps for efficiencies.
bool addPuppiIsolation_
add puppi isolation
void embedDytMuon()
embed reference to the above dyt Track
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:127
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
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)
Definition: Lepton.h:99
bool embedTcMETMuonCorrs_
embed muon MET correction info for tcMET into the muon
class definition
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
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)
Definition: EventRange.cc:38
std::string mvaTrainingFile_
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_photons_
void embedCombinedMuon()
set reference to Track reconstructed in both tracked and muon detector (reimplemented from reco::Muon...
edm::EDGetTokenT< double > rho_
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
input source
void embedTunePMuonBestTrack(bool force=false)
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 getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
void setAllowAnything()
allow any parameter label/value pairs
double zError() const
error on z
Definition: Vertex.h:123
void setSimFlavour(int f)
Definition: Muon.h:300
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
bool embedCaloMETMuonCorrs_
embed muon MET correction info for caloMET into the muon
std::pair< bool, Measurement1D > signedTransverseImpactParameter(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:50
~PATMuonProducer() override
default destructur
float muonRelMiniIsoPUCorrected(const PFIsolation &iso, const math::XYZTLorentzVector &p4, float dr, float rho)
edm::EDGetTokenT< edm::ValueMap< reco::MuonSimInfo > > simInfo_
MC info.
void embedMuonBestTrack(bool force=false)
std::vector< pat::PackedCandidate > PackedCandidateCollection
void setIsolationPUPPINoLeptons(float chargedhadrons, float neutralhadrons, float photons)
sets PUPPINoLeptons isolations
Definition: Muon.h:200
void setMuonMiniIso(pat::Muon &aMuon, const pat::PackedCandidateCollection *pc)
reco::TransientTrack build(const reco::Track *p) const
void setSimBX(int bx)
Definition: Muon.h:304
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
bool embedBestTrack_
embed the track from best muon measurement (global pflow)
edm::EDGetTokenT< reco::JetCorrector > mvaL1Corrector_
std::pair< bool, Measurement1D > signedImpactParameter3D(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:71
void setCutBasedSelectorFlags(reco::Muon &muon, const reco::Vertex *vertex=0, bool run2016_hip_mitigation=false)
bool addResolutions_
add resolutions to the muon (this will be data members of th muon even w/o embedding) ...
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_charged_hadrons_
std::vector< double > miniIsoParams_
void setSimPhi(float phi)
Definition: Muon.h:309
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
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 setSimProdRho(float rho)
Definition: Muon.h:305
void setSimHeaviestMotherFlavour(int id)
Definition: Muon.h:301
void setPFCandidateRef(const reco::PFCandidateRef &ref)
add a reference to the source IsolatedPFCandidate
Definition: Muon.h:133
bool isRealData() const
Definition: EventBase.h:64
const Point & position() const
position
Definition: Vertex.h:109
void embedHighLevel(pat::Muon &aMuon, reco::TrackRef track, reco::TransientTrack &tt, reco::Vertex &primaryVertex, bool primaryVertexIsValid, reco::BeamSpot &beamspot, bool beamspotIsValid)
ProductID id() const
Definition: RefToBase.h:242
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_neutral_hadrons_
void setSimType(reco::MuonSimType type)
Definition: Muon.h:298
void embedStandAloneMuon()
set reference to Track reconstructed in the muon detector only (reimplemented from reco::Muon) ...
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 ...
void setIsolationPUPPI(float chargedhadrons, float neutralhadrons, float photons)
sets PUPPI isolations
Definition: Muon.h:193
pat::helper::MultiIsolator isolator_
helper class to add userdefined isolation values to the muon
std::vector< edm::EDGetTokenT< edm::ValueMap< IsoDeposit > > > isoDepositTokens_
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
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.
Definition: Lepton.h:176
Definition: HeavyIon.h:7
void embedTrack()
set reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
static void fillDescription(edm::ParameterSetDescription &iDesc)
const PFIsolation & miniPFIsolation() const
Definition: Lepton.h:196
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
bool embedStandAloneMuon_
embed track from muon system into the muon
void setComment(std::string const &value)
int iEvent
Definition: GenABIO.cc:230
void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup)
GreaterByPt< Muon > pTComparator_
bool embedTrack_
embed the track from inner tracker into the muon
void setDB(double dB, double edB, IPTYPE type=PV2D)
Definition: Muon.h:244
bool addGenMatch_
add generator match information
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
description of config file parameters
Definition: Muon.py:1
bool isGlobalMuon() const override
Definition: Muon.h:265
bool embedPfEcalEnergy_
add ecal PF energy
void embedGenParticle()
Definition: PATObject.h:694
void newEvent(const edm::Event &event, const edm::EventSetup &setup)
To be called for each new event, reads in the EventSetup object.
void embedPFCandidate()
embed the IsolatedPFCandidate pointed to by pfCandidateRef_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
everything that needs to be done during the event loop
ParameterDescriptionNode * ifValue(ParameterDescription< T > const &switchParameter, std::unique_ptr< ParameterDescriptionCases< T > > cases)
reco::PFCandidateRef pfCandidateRef() const
RunNumber_t run() const
Definition: Event.h:99
def pv(vc)
Definition: MetAnalyzer.py:6
double getRelMiniIsoPUCorrected(const pat::Muon &muon, float rho)
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
float jetPtRatio() const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:74
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:455
edm::EDGetTokenT< pat::PackedCandidateCollection > pcToken_
void initialize(std::string weightsfile, float dRmax)
bool isAValidMuonTrack(const MuonTrackType &type) const
void initSimInfo(void)
void addGenParticleRef(const reco::GenParticleRef &ref)
Definition: PATObject.h:678
void setPfEcalEnergy(float pfEcalEnergy)
Definition: Muon.h:267
bool embedTunePBestTrack_
embed the track from best muon measurement (muon only)
T const * product() const
Definition: Handle.h:81
static void fillDescription(edm::ParameterSetDescription &iDesc)
Method for documentation and validation of PSet.
void setSimMotherPdgId(int id)
Definition: Muon.h:303
const T & get() const
Definition: EventSetup.h:55
void setEfficiencies(pat::PATObject< T > &obj, const R &originalRef) const
Sets the efficiencies for this object, using the reference to the original objects.
void setExtSimType(reco::ExtendedMuonSimType type)
Definition: Muon.h:299
void setMiniPFIsolation(PFIsolation const &iso)
Definition: Lepton.h:197
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
void setSimProdZ(float z)
Definition: Muon.h:306
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
void computeMva(const pat::Muon &imuon, const reco::Vertex &vertex, const reco::JetTagCollection &bTags, const reco::JetCorrector *correctorL1=0, const reco::JetCorrector *correctorL1L2L3Res=0)
pat::helper::EfficiencyLoader efficiencyLoader_
helper class to add efficiencies to the muon
HLT enums.
bool embedPickyMuon_
embed track from picky muon fit into the muon
void setNormChi2(double normChi2)
Definition: Muon.h:255
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
bool embedDytMuon_
embed track from DYT muon fit into the muon
void embedCaloMETMuonCorrs(const reco::MuonMETCorrectionData &t)
PFIsolation getMiniPFIsolation(const pat::PackedCandidateCollection *pfcands, const math::XYZTLorentzVector &p4, float mindr=0.05, float maxdr=0.2, float kt_scale=10.0, float ptthresh=0.5, float deadcone_ch=0.0001, float deadcone_pu=0.01, float deadcone_ph=0.01, float deadcone_nh=0.01, float dZ_cut=0.0)
void setSimPdgId(int id)
Definition: Muon.h:302
void setSimPt(float pt)
Definition: Muon.h:307
float miniIsoDr(const math::XYZTLorentzVector &p4, float mindr, float maxdr, float kt_scale)
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
Definition: BeamSpot.h:62
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
float jetPtRel() const
Covariance3DMatrix rotatedCovariance3D() const
Definition: BeamSpot.cc:78
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
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueTokens_
void setNumberOfValidHits(unsigned int numberOfValidHits)
Definition: Muon.h:250
bool computeMuonMVA_
standard muon selectors
void setSimEta(float eta)
Definition: Muon.h:308
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
static std::string const source
Definition: EdmProvDump.cc:43
void setP4(const LorentzVector &p4) final
set 4-momentum
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_neutral_hadrons_
def move(src, dest)
Definition: eostools.py:510
Global3DVector GlobalVector
Definition: GlobalVector.h:10
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const
Definition: MultiIsolator.h:82
bool embedHighLevelSelection_
embed high level selection variables