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 
47 
48 #include <vector>
49 #include <memory>
50 
51 
52 using namespace pat;
53 using namespace std;
54 
55 
57  relMiniIsoPUCorrected_(0),
58  useUserData_(iConfig.exists("userData")),
59  computeMuonMVA_(false),
60  computeSoftMuonMVA_(false),
61  recomputeBasicSelectors_(false),
62  mvaDrMax_(0),
63  mvaUseJec_(false),
64  isolator_(iConfig.exists("userIsolation") ? iConfig.getParameter<edm::ParameterSet>("userIsolation") : edm::ParameterSet(), consumesCollector(), false)
65 {
66  // input source
67  muonToken_ = consumes<edm::View<reco::Muon> >(iConfig.getParameter<edm::InputTag>( "muonSource" ));
68  // embedding of tracks
69  embedBestTrack_ = iConfig.getParameter<bool>( "embedMuonBestTrack" );
70  embedTunePBestTrack_ = iConfig.getParameter<bool>( "embedTunePMuonBestTrack" );
71  forceEmbedBestTrack_ = iConfig.getParameter<bool>( "forceBestTrackEmbedding" );
72  embedTrack_ = iConfig.getParameter<bool>( "embedTrack" );
73  embedCombinedMuon_ = iConfig.getParameter<bool>( "embedCombinedMuon" );
74  embedStandAloneMuon_ = iConfig.getParameter<bool>( "embedStandAloneMuon" );
75  // embedding of muon MET correction information
76  embedCaloMETMuonCorrs_ = iConfig.getParameter<bool>("embedCaloMETMuonCorrs" );
77  embedTcMETMuonCorrs_ = iConfig.getParameter<bool>("embedTcMETMuonCorrs" );
78  caloMETMuonCorrsToken_ = mayConsume<edm::ValueMap<reco::MuonMETCorrectionData> >(iConfig.getParameter<edm::InputTag>("caloMETMuonCorrs" ));
79  tcMETMuonCorrsToken_ = mayConsume<edm::ValueMap<reco::MuonMETCorrectionData> >(iConfig.getParameter<edm::InputTag>("tcMETMuonCorrs" ));
80  // pflow specific configurables
81  useParticleFlow_ = iConfig.getParameter<bool>( "useParticleFlow" );
82  embedPFCandidate_ = iConfig.getParameter<bool>( "embedPFCandidate" );
83  pfMuonToken_ = mayConsume<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>( "pfMuonSource" ));
84  embedPfEcalEnergy_ = iConfig.getParameter<bool>( "embedPfEcalEnergy" );
85  // embedding of tracks from TeV refit
86  embedPickyMuon_ = iConfig.getParameter<bool>( "embedPickyMuon" );
87  embedTpfmsMuon_ = iConfig.getParameter<bool>( "embedTpfmsMuon" );
88  embedDytMuon_ = iConfig.getParameter<bool>( "embedDytMuon" );
89  // Monte Carlo matching
90  addGenMatch_ = iConfig.getParameter<bool>( "addGenMatch" );
91  if (addGenMatch_) {
92  embedGenMatch_ = iConfig.getParameter<bool>( "embedGenMatch" );
93  if (iConfig.existsAs<edm::InputTag>("genParticleMatch")) {
94  genMatchTokens_.push_back(consumes<edm::Association<reco::GenParticleCollection> >(iConfig.getParameter<edm::InputTag>( "genParticleMatch" )));
95  }
96  else {
97  genMatchTokens_ = edm::vector_transform(iConfig.getParameter<std::vector<edm::InputTag> >( "genParticleMatch" ), [this](edm::InputTag const & tag){return consumes<edm::Association<reco::GenParticleCollection> >(tag);});
98  }
99  }
100  // efficiencies
101  addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies");
102  if(addEfficiencies_){
103  efficiencyLoader_ = pat::helper::EfficiencyLoader(iConfig.getParameter<edm::ParameterSet>("efficiencies"), consumesCollector());
104  }
105  // resolutions
106  addResolutions_ = iConfig.getParameter<bool>("addResolutions");
107  if (addResolutions_) {
109  }
110  // puppi
111  addPuppiIsolation_ = iConfig.getParameter<bool>("addPuppiIsolation");
112  if(addPuppiIsolation_){
113  PUPPIIsolation_charged_hadrons_ = consumes<edm::ValueMap<float> >(iConfig.getParameter<edm::InputTag>("puppiIsolationChargedHadrons"));
114  PUPPIIsolation_neutral_hadrons_ = consumes<edm::ValueMap<float> >(iConfig.getParameter<edm::InputTag>("puppiIsolationNeutralHadrons"));
115  PUPPIIsolation_photons_ = consumes<edm::ValueMap<float> >(iConfig.getParameter<edm::InputTag>("puppiIsolationPhotons"));
116  //puppiNoLeptons
117  PUPPINoLeptonsIsolation_charged_hadrons_ = consumes<edm::ValueMap<float> >(iConfig.getParameter<edm::InputTag>("puppiNoLeptonsIsolationChargedHadrons"));
118  PUPPINoLeptonsIsolation_neutral_hadrons_ = consumes<edm::ValueMap<float> >(iConfig.getParameter<edm::InputTag>("puppiNoLeptonsIsolationNeutralHadrons"));
119  PUPPINoLeptonsIsolation_photons_ = consumes<edm::ValueMap<float> >(iConfig.getParameter<edm::InputTag>("puppiNoLeptonsIsolationPhotons"));
120  }
121  // read isoDeposit labels, for direct embedding
122  readIsolationLabels(iConfig, "isoDeposits", isoDepositLabels_, isoDepositTokens_);
123  // read isolation value labels, for direct embedding
125  // check to see if the user wants to add user data
126  if( useUserData_ ){
127  userDataHelper_ = PATUserDataHelper<Muon>(iConfig.getParameter<edm::ParameterSet>("userData"), consumesCollector());
128  }
129  // embed high level selection variables
130  embedHighLevelSelection_ = iConfig.getParameter<bool>("embedHighLevelSelection");
131  if ( embedHighLevelSelection_ ) {
132  beamLineToken_ = consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamLineSrc"));
133  pvToken_ = consumes<std::vector<reco::Vertex> >(iConfig.getParameter<edm::InputTag>("pvSrc"));
134  }
135 
136  //for mini-isolation calculation
137  computeMiniIso_ = iConfig.getParameter<bool>("computeMiniIso");
138 
139  miniIsoParams_ = iConfig.getParameter<std::vector<double> >("miniIsoParams");
140  if(computeMiniIso_ && miniIsoParams_.size() != 9){
141  throw cms::Exception("ParameterError") << "miniIsoParams must have exactly 9 elements.\n";
142  }
143  if(computeMiniIso_)
144  pcToken_ = consumes<pat::PackedCandidateCollection >(iConfig.getParameter<edm::InputTag>("pfCandsForMiniIso"));
145 
146  // standard selectors
147  recomputeBasicSelectors_ = iConfig.getParameter<bool>("recomputeBasicSelectors");
148  computeMuonMVA_ = iConfig.getParameter<bool>("computeMuonMVA");
149  mvaTrainingFile_ = iConfig.getParameter<std::string>("mvaTrainingFile");
150  if (computeMuonMVA_ and not computeMiniIso_)
151  throw cms::Exception("ConfigurationError") << "MiniIso is needed for Muon MVA calculation.\n";
152 
153  if (computeMuonMVA_) {
154  // pfCombinedInclusiveSecondaryVertexV2BJetTags
155  mvaBTagCollectionTag_ = consumes<reco::JetTagCollection>(iConfig.getParameter<edm::InputTag>("mvaJetTag"));
156  mvaL1Corrector_ = consumes<reco::JetCorrector>(iConfig.getParameter<edm::InputTag>("mvaL1Corrector"));
157  mvaL1L2L3ResCorrector_ = consumes<reco::JetCorrector>(iConfig.getParameter<edm::InputTag>("mvaL1L2L3ResCorrector"));
158  rho_ = consumes<double>(iConfig.getParameter<edm::InputTag>("rho"));
159  mvaUseJec_ = iConfig.getParameter<bool>("mvaUseJec");
160  mvaDrMax_ = iConfig.getParameter<double>("mvaDrMax");
161 
162  // xml training file
163  edm::FileInPath fip(mvaTrainingFile_);
164  mvaEstimator_.initialize(fip.fullPath(),mvaDrMax_);
165  }
166 
167  computeSoftMuonMVA_ = iConfig.getParameter<bool>("computeSoftMuonMVA");
168  softMvaTrainingFile_ = iConfig.getParameter<std::string>("softMvaTrainingFile");
169 
170  if(computeSoftMuonMVA_) {
171  // xml soft mva training file
172  edm::FileInPath softfip(softMvaTrainingFile_);
174  }
175 
176  // MC info
177  simInfo_ = consumes<edm::ValueMap<reco::MuonSimInfo> >(iConfig.getParameter<edm::InputTag>("muonSimInfo"));
178 
179  // produces vector of muons
180  produces<std::vector<Muon> >();
181 }
182 
183 
185 {
186 }
187 
189 {
190  // switch off embedding (in unschedules mode)
191  if (iEvent.isRealData()){
192  addGenMatch_ = false;
193  embedGenMatch_ = false;
194  }
195 
197  iEvent.getByToken(muonToken_, muons);
198 
199 
201  if(computeMiniIso_)
202  iEvent.getByToken(pcToken_, pc);
203 
204  // get the ESHandle for the transient track builder,
205  // if needed for high level selection embedding
207 
208  if(isolator_.enabled()) isolator_.beginEvent(iEvent,iSetup);
210  if(resolutionLoader_.enabled()) resolutionLoader_.newEvent(iEvent, iSetup);
211 
213  for (size_t j = 0; j<isoDepositTokens_.size(); ++j) {
214  iEvent.getByToken(isoDepositTokens_[j], deposits[j]);
215  }
216 
218  for (size_t j = 0; j<isolationValueTokens_.size(); ++j) {
220  }
221 
222  //value maps for puppi isolation
223  edm::Handle<edm::ValueMap<float>> PUPPIIsolation_charged_hadrons;
224  edm::Handle<edm::ValueMap<float>> PUPPIIsolation_neutral_hadrons;
225  edm::Handle<edm::ValueMap<float>> PUPPIIsolation_photons;
226  //value maps for puppiNoLeptons isolation
227  edm::Handle<edm::ValueMap<float>> PUPPINoLeptonsIsolation_charged_hadrons;
228  edm::Handle<edm::ValueMap<float>> PUPPINoLeptonsIsolation_neutral_hadrons;
229  edm::Handle<edm::ValueMap<float>> PUPPINoLeptonsIsolation_photons;
230  if(addPuppiIsolation_){
231  //puppi
232  iEvent.getByToken(PUPPIIsolation_charged_hadrons_, PUPPIIsolation_charged_hadrons);
233  iEvent.getByToken(PUPPIIsolation_neutral_hadrons_, PUPPIIsolation_neutral_hadrons);
234  iEvent.getByToken(PUPPIIsolation_photons_, PUPPIIsolation_photons);
235  //puppiNoLeptons
236  iEvent.getByToken(PUPPINoLeptonsIsolation_charged_hadrons_, PUPPINoLeptonsIsolation_charged_hadrons);
237  iEvent.getByToken(PUPPINoLeptonsIsolation_neutral_hadrons_, PUPPINoLeptonsIsolation_neutral_hadrons);
238  iEvent.getByToken(PUPPINoLeptonsIsolation_photons_, PUPPINoLeptonsIsolation_photons);
239  }
240 
241  // inputs for muon mva
242  edm::Handle<reco::JetTagCollection> mvaBTagCollectionTag;
245  if (computeMuonMVA_) {
246  iEvent.getByToken(mvaBTagCollectionTag_,mvaBTagCollectionTag);
247  iEvent.getByToken(mvaL1Corrector_,mvaL1Corrector);
248  iEvent.getByToken(mvaL1L2L3ResCorrector_,mvaL1L2L3ResCorrector);
249  }
250 
251  // prepare the MC genMatchTokens_
252  GenAssociations genMatches(genMatchTokens_.size());
253  if (addGenMatch_) {
254  for (size_t j = 0, nd = genMatchTokens_.size(); j < nd; ++j) {
255  iEvent.getByToken(genMatchTokens_[j], genMatches[j]);
256  }
257  }
258 
259  // prepare the high level selection: needs beamline
260  // OR primary vertex, depending on user selection
263  bool beamSpotIsValid = false;
264  bool primaryVertexIsValid = false;
265  if ( embedHighLevelSelection_ ) {
266  // get the beamspot
267  edm::Handle<reco::BeamSpot> beamSpotHandle;
268  iEvent.getByToken(beamLineToken_, beamSpotHandle);
269 
270  // get the primary vertex
272  iEvent.getByToken( pvToken_, pvHandle );
273 
274  if( beamSpotHandle.isValid() ){
275  beamSpot = *beamSpotHandle;
276  beamSpotIsValid = true;
277  } else{
278  edm::LogError("DataNotAvailable")
279  << "No beam spot available from EventSetup, not adding high level selection \n";
280  }
281  if( pvHandle.isValid() && !pvHandle->empty() ) {
282  primaryVertex = pvHandle->at(0);
283  primaryVertexIsValid = true;
284  } else {
285  edm::LogError("DataNotAvailable")
286  << "No primary vertex available from EventSetup, not adding high level selection \n";
287  }
288  // this is needed by the IPTools methods from the tracking group
289  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", trackBuilder);
290  }
291 
292  // MC info
294  bool simInfoIsAvailalbe = iEvent.getByToken(simInfo_,simInfo);
295 
296  // this will be the new object collection
297  std::vector<Muon> * patMuons = new std::vector<Muon>();
298 
300  if( useParticleFlow_ ){
301  // get the PFCandidates of type muons
302  iEvent.getByToken(pfMuonToken_, pfMuons);
303 
304  unsigned index=0;
305  for( reco::PFCandidateConstIterator i = pfMuons->begin(); i != pfMuons->end(); ++i, ++index) {
306  const reco::PFCandidate& pfmu = *i;
307  //const reco::IsolaPFCandidate& pfmu = *i;
308  const reco::MuonRef& muonRef = pfmu.muonRef();
309  assert( muonRef.isNonnull() );
310 
311  MuonBaseRef muonBaseRef(muonRef);
312  Muon aMuon(muonBaseRef);
313 
314  if ( useUserData_ ) {
315  userDataHelper_.add( aMuon, iEvent, iSetup );
316  }
317 
318  // embed high level selection
319  if ( embedHighLevelSelection_ ) {
320  // get the tracks
321  reco::TrackRef innerTrack = muonBaseRef->innerTrack();
322  reco::TrackRef globalTrack= muonBaseRef->globalTrack();
323  reco::TrackRef bestTrack = muonBaseRef->muonBestTrack();
324  reco::TrackRef chosenTrack = innerTrack;
325  // Make sure the collection it points to is there
326  if ( bestTrack.isNonnull() && bestTrack.isAvailable() )
327  chosenTrack = bestTrack;
328 
329  if ( chosenTrack.isNonnull() && chosenTrack.isAvailable() ) {
330  unsigned int nhits = chosenTrack->numberOfValidHits(); // ????
331  aMuon.setNumberOfValidHits( nhits );
332 
333  reco::TransientTrack tt = trackBuilder->build(chosenTrack);
334  embedHighLevel( aMuon,
335  chosenTrack,
336  tt,
337  primaryVertex,
338  primaryVertexIsValid,
339  beamSpot,
340  beamSpotIsValid );
341 
342  }
343 
344  if ( globalTrack.isNonnull() && globalTrack.isAvailable() && !embedCombinedMuon_) {
345  double norm_chi2 = globalTrack->chi2() / globalTrack->ndof();
346  aMuon.setNormChi2( norm_chi2 );
347  }
348  }
349  reco::PFCandidateRef pfRef(pfMuons,index);
350  //reco::PFCandidatePtr ptrToMother(pfMuons,index);
351  reco::CandidateBaseRef pfBaseRef( pfRef );
352 
353  aMuon.setPFCandidateRef( pfRef );
354  if( embedPFCandidate_ ) aMuon.embedPFCandidate();
355  fillMuon( aMuon, muonBaseRef, pfBaseRef, genMatches, deposits, isolationValues );
356 
357  if(computeMiniIso_)
358  setMuonMiniIso(aMuon, pc.product());
359 
360  if (addPuppiIsolation_) {
361  aMuon.setIsolationPUPPI((*PUPPIIsolation_charged_hadrons)[muonBaseRef],
362  (*PUPPIIsolation_neutral_hadrons)[muonBaseRef],
363  (*PUPPIIsolation_photons)[muonBaseRef]);
364 
365  aMuon.setIsolationPUPPINoLeptons((*PUPPINoLeptonsIsolation_charged_hadrons)[muonBaseRef],
366  (*PUPPINoLeptonsIsolation_neutral_hadrons)[muonBaseRef],
367  (*PUPPINoLeptonsIsolation_photons)[muonBaseRef]);
368  }
369  else {
370  aMuon.setIsolationPUPPI(-999., -999.,-999.);
371  aMuon.setIsolationPUPPINoLeptons(-999., -999.,-999.);
372  }
373 
374  if (embedPfEcalEnergy_) {
375  aMuon.setPfEcalEnergy(pfmu.ecalEnergy());
376  }
377 
378  patMuons->push_back(aMuon);
379  }
380  }
381  else {
383  iEvent.getByToken(muonToken_, muons);
384 
385  // embedding of muon MET corrections
387  //edm::ValueMap<reco::MuonMETCorrectionData> caloMETmuCorValueMap;
389  iEvent.getByToken(caloMETMuonCorrsToken_, caloMETMuonCorrs);
390  //caloMETmuCorValueMap = *caloMETmuCorValueMap_h;
391  }
393  //edm::ValueMap<reco::MuonMETCorrectionData> tcMETmuCorValueMap;
395  iEvent.getByToken(tcMETMuonCorrsToken_, tcMETMuonCorrs);
396  //tcMETmuCorValueMap = *tcMETmuCorValueMap_h;
397  }
398 
399  if (embedPfEcalEnergy_) {
400  // get the PFCandidates of type muons
401  iEvent.getByToken(pfMuonToken_, pfMuons);
402  }
403 
404  for (edm::View<reco::Muon>::const_iterator itMuon = muons->begin(); itMuon != muons->end(); ++itMuon) {
405  // construct the Muon from the ref -> save ref to original object
406  unsigned int idx = itMuon - muons->begin();
407  MuonBaseRef muonRef = muons->refAt(idx);
408  reco::CandidateBaseRef muonBaseRef( muonRef );
409 
410  Muon aMuon(muonRef);
411  fillMuon( aMuon, muonRef, muonBaseRef, genMatches, deposits, isolationValues);
412  if(computeMiniIso_)
413  setMuonMiniIso(aMuon, pc.product());
414  if (addPuppiIsolation_) {
415  aMuon.setIsolationPUPPI((*PUPPIIsolation_charged_hadrons)[muonRef], (*PUPPIIsolation_neutral_hadrons)[muonRef], (*PUPPIIsolation_photons)[muonRef]);
416  aMuon.setIsolationPUPPINoLeptons((*PUPPINoLeptonsIsolation_charged_hadrons)[muonRef], (*PUPPINoLeptonsIsolation_neutral_hadrons)[muonRef], (*PUPPINoLeptonsIsolation_photons)[muonRef]);
417  }
418  else {
419  aMuon.setIsolationPUPPI(-999., -999.,-999.);
420  aMuon.setIsolationPUPPINoLeptons(-999., -999.,-999.);
421  }
422 
423  // Isolation
424  if (isolator_.enabled()) {
425  //reco::CandidatePtr mother = ptrToMother->sourceCandidatePtr(0);
426  isolator_.fill(*muons, idx, isolatorTmpStorage_);
427  typedef pat::helper::MultiIsolator::IsolationValuePairs IsolationValuePairs;
428  // better to loop backwards, so the vector is resized less times
429  for (IsolationValuePairs::const_reverse_iterator it = isolatorTmpStorage_.rbegin(), ed = isolatorTmpStorage_.rend(); it != ed; ++it) {
430  aMuon.setIsolation(it->first, it->second);
431  }
432  }
433 
434  // for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
435  // aMuon.setIsoDeposit(isoDepositLabels_[j].first,
436  // (*deposits[j])[muonRef]);
437  // }
438 
439  // add sel to selected
440  edm::Ptr<reco::Muon> muonsPtr = muons->ptrAt(idx);
441  if ( useUserData_ ) {
442  userDataHelper_.add( aMuon, iEvent, iSetup );
443  }
444 
445  // embed high level selection
446  if ( embedHighLevelSelection_ ) {
447  // get the tracks
448  reco::TrackRef innerTrack = itMuon->innerTrack();
449  reco::TrackRef globalTrack= itMuon->globalTrack();
450  reco::TrackRef bestTrack = itMuon->muonBestTrack();
451  reco::TrackRef chosenTrack = innerTrack;
452  // Make sure the collection it points to is there
453  if ( bestTrack.isNonnull() && bestTrack.isAvailable() )
454  chosenTrack = bestTrack;
455  if ( chosenTrack.isNonnull() && chosenTrack.isAvailable() ) {
456  unsigned int nhits = chosenTrack->numberOfValidHits(); // ????
457  aMuon.setNumberOfValidHits( nhits );
458 
459  reco::TransientTrack tt = trackBuilder->build(chosenTrack);
460  embedHighLevel( aMuon,
461  chosenTrack,
462  tt,
463  primaryVertex,
464  primaryVertexIsValid,
465  beamSpot,
466  beamSpotIsValid );
467 
468  }
469 
470  if ( globalTrack.isNonnull() && globalTrack.isAvailable() ) {
471  double norm_chi2 = globalTrack->chi2() / globalTrack->ndof();
472  aMuon.setNormChi2( norm_chi2 );
473  }
474  }
475 
476  // embed MET muon corrections
477  if( embedCaloMETMuonCorrs_ ) aMuon.embedCaloMETMuonCorrs((*caloMETMuonCorrs)[muonRef]);
478  if( embedTcMETMuonCorrs_ ) aMuon.embedTcMETMuonCorrs((*tcMETMuonCorrs )[muonRef]);
479 
480  if (embedPfEcalEnergy_) {
481  aMuon.setPfEcalEnergy(-99.0);
482  for (const reco::PFCandidate &pfmu : *pfMuons) {
483  if (pfmu.muonRef().isNonnull()) {
484  if (pfmu.muonRef().id() != muonRef.id()) throw cms::Exception("Configuration") << "Muon reference within PF candidates does not point to the muon collection." << std::endl;
485  if (pfmu.muonRef().key() == muonRef.key()) {
486  aMuon.setPfEcalEnergy(pfmu.ecalEnergy());
487  }
488  }
489  }
490  }
491  // MC info
492  aMuon.initSimInfo();
493  if (simInfoIsAvailalbe){
494  const auto& msi = (*simInfo)[muonBaseRef];
495  aMuon.setSimType(msi.primaryClass);
496  aMuon.setExtSimType(msi.extendedClass);
497  aMuon.setSimFlavour(msi.flavour);
498  aMuon.setSimHeaviestMotherFlavour(msi.heaviestMotherFlavour);
499  aMuon.setSimPdgId(msi.pdgId);
500  aMuon.setSimMotherPdgId(msi.motherPdgId);
501  aMuon.setSimBX(msi.tpBX);
502  aMuon.setSimProdRho(msi.vertex.Rho());
503  aMuon.setSimProdZ(msi.vertex.Z());
504  aMuon.setSimPt(msi.p4.pt());
505  aMuon.setSimEta(msi.p4.eta());
506  aMuon.setSimPhi(msi.p4.phi());
507  }
508  patMuons->push_back(aMuon);
509  }
510  }
511 
512  // sort muons in pt
513  std::sort(patMuons->begin(), patMuons->end(), pTComparator_);
514 
515  // Store standard muon selection decisions and jet related
516  // quantaties.
517  // Need a separate loop over muons to have all inputs properly
518  // computed and stored in the object.
520  if (computeMuonMVA_) iEvent.getByToken(rho_,rho);
521  const reco::Vertex* pv(nullptr);
522  if (primaryVertexIsValid) pv = &primaryVertex;
523  for(auto& muon: *patMuons){
525  muon.setSelectors(0);
526  bool isRun2016BCDEF = (272728 <= iEvent.run() && iEvent.run() <= 278808);
527  muon::setCutBasedSelectorFlags(muon, pv, isRun2016BCDEF);
528  }
529  double miniIsoValue = -1;
530  if (computeMiniIso_){
531  // MiniIsolation working points
532  double miniIsoValue = getRelMiniIsoPUCorrected(muon,*rho);
533  muon.setSelector(reco::Muon::MiniIsoLoose, miniIsoValue<0.40);
534  muon.setSelector(reco::Muon::MiniIsoMedium, miniIsoValue<0.20);
535  muon.setSelector(reco::Muon::MiniIsoTight, miniIsoValue<0.10);
536  muon.setSelector(reco::Muon::MiniIsoVeryTight, miniIsoValue<0.05);
537  }
538  if (computeMuonMVA_ && primaryVertexIsValid){
539  if (mvaUseJec_)
541  primaryVertex,
542  *(mvaBTagCollectionTag.product()),
543  &*mvaL1Corrector,
544  &*mvaL1L2L3ResCorrector);
545  else
547  primaryVertex,
548  *(mvaBTagCollectionTag.product()));
549 
550  muon.setMvaValue(mvaEstimator_.mva());
551  muon.setJetPtRatio(mvaEstimator_.jetPtRatio());
552  muon.setJetPtRel(mvaEstimator_.jetPtRel());
553 
554  // multi-isolation
555  if (computeMiniIso_){
556  muon.setSelector(reco::Muon::MultiIsoLoose, miniIsoValue<0.40 && (muon.jetPtRatio() > 0.80 || muon.jetPtRel() > 7.2) );
557  muon.setSelector(reco::Muon::MultiIsoMedium, miniIsoValue<0.16 && (muon.jetPtRatio() > 0.76 || muon.jetPtRel() > 7.2) );
558  }
559 
560  // MVA working points
561  // https://twiki.cern.ch/twiki/bin/viewauth/CMS/LeptonMVA
562  double dB2D = fabs(muon.dB(pat::Muon::BS2D));
563  double dB3D = fabs(muon.dB(pat::Muon::PV3D));
564  double edB3D = fabs(muon.edB(pat::Muon::PV3D));
565  double sip3D = edB3D>0?dB3D/edB3D:0.0;
566  double dz = fabs(muon.muonBestTrack()->dz(primaryVertex.position()));
567 
568  // muon preselection
569  if (muon.pt()>5 and muon.isLooseMuon() and
570  muon.passed(reco::Muon::MiniIsoLoose) and
571  sip3D<8.0 and dB2D<0.05 and dz<0.1){
572  muon.setSelector(reco::Muon::MvaLoose, muon.mvaValue()>-0.60);
573  muon.setSelector(reco::Muon::MvaMedium, muon.mvaValue()>-0.20);
574  muon.setSelector(reco::Muon::MvaTight, muon.mvaValue()> 0.15);
575  }
576  }
577 
578  //SOFT MVA
579  if (computeSoftMuonMVA_){
581  muon.setSoftMvaValue(softMvaEstimator_.mva());
582  //preselection in SoftMuonMvaEstimator.cc
583  muon.setSelector(reco::Muon::SoftMvaId, muon.softMvaValue() > 0.58 ); //WP choose for bmm4
584 
585  }
586  }
587 
588  // put products in Event
589  std::unique_ptr<std::vector<Muon> > ptr(patMuons);
590  iEvent.put(std::move(ptr));
591 
593 }
594 
595 
596 void PATMuonProducer::fillMuon( Muon& aMuon, const MuonBaseRef& muonRef, const reco::CandidateBaseRef& baseRef, const GenAssociations& genMatches, const IsoDepositMaps& deposits, const IsolationValueMaps& isolationValues ) const
597 {
598  // in the particle flow algorithm,
599  // the muon momentum is recomputed.
600  // the new value is stored as the momentum of the
601  // resulting PFCandidate of type Muon, and choosen
602  // as the pat::Muon momentum
603  if (useParticleFlow_)
604  aMuon.setP4( aMuon.pfCandidateRef()->p4() );
605  if (embedTrack_) aMuon.embedTrack();
608 
609  // embed the TeV refit track refs (only available for globalMuons)
610  if (aMuon.isGlobalMuon()) {
612  aMuon.embedPickyMuon();
614  aMuon.embedTpfmsMuon();
616  aMuon.embedDytMuon();
617  }
618 
619  // embed best tracks (at the end, so unless forceEmbedBestTrack_ is true we can save some space not embedding them twice)
622 
623  // store the match to the generated final state muons
624  if (addGenMatch_) {
625  for(size_t i = 0, n = genMatches.size(); i < n; ++i) {
626  reco::GenParticleRef genMuon = (*genMatches[i])[baseRef];
627  aMuon.addGenParticleRef(genMuon);
628  }
629  if (embedGenMatch_) aMuon.embedGenParticle();
630  }
631  if (efficiencyLoader_.enabled()) {
632  efficiencyLoader_.setEfficiencies( aMuon, muonRef );
633  }
634 
635  for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
636  if(useParticleFlow_) {
637  if (deposits[j]->contains(baseRef.id())) {
638  aMuon.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[baseRef]);
639  } else if (deposits[j]->contains(muonRef.id())){
640  aMuon.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[muonRef]);
641  } else {
642  reco::CandidatePtr source = aMuon.pfCandidateRef()->sourceCandidatePtr(0);
643  aMuon.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[source]);
644  }
645  }
646  else{
647  aMuon.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[muonRef]);
648  }
649  }
650 
651  for (size_t j = 0; j<isolationValues.size(); ++j) {
652  if(useParticleFlow_) {
653  if (isolationValues[j]->contains(baseRef.id())) {
654  aMuon.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[baseRef]);
655  } else if (isolationValues[j]->contains(muonRef.id())) {
656  aMuon.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[muonRef]);
657  } else {
658  reco::CandidatePtr source = aMuon.pfCandidateRef()->sourceCandidatePtr(0);
659  aMuon.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[source]);
660  }
661  }
662  else{
663  aMuon.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[muonRef]);
664  }
665  }
666 
667  if (resolutionLoader_.enabled()) {
669  }
670 }
671 
673 {
674  pat::PFIsolation miniiso = pat::getMiniPFIsolation(pc, aMuon.p4(),
675  miniIsoParams_[0], miniIsoParams_[1], miniIsoParams_[2],
676  miniIsoParams_[3], miniIsoParams_[4], miniIsoParams_[5],
677  miniIsoParams_[6], miniIsoParams_[7], miniIsoParams_[8]);
678  aMuon.setMiniPFIsolation(miniiso);
679 }
680 
682 {
683  float mindr(miniIsoParams_[0]);
684  float maxdr(miniIsoParams_[1]);
685  float kt_scale(miniIsoParams_[2]);
686  float drcut = pat::miniIsoDr(muon.p4(),mindr,maxdr,kt_scale);
687  return pat::muonRelMiniIsoPUCorrected(muon.miniPFIsolation(), muon.p4(), drcut, rho);
688 }
689 
690 // ParameterSet description for module
692 {
694  iDesc.setComment("PAT muon producer module");
695 
696  // input source
697  iDesc.add<edm::InputTag>("muonSource", edm::InputTag("no default"))->setComment("input collection");
698 
699  // embedding
700  iDesc.add<bool>("embedMuonBestTrack", true)->setComment("embed muon best track (global pflow)");
701  iDesc.add<bool>("embedTunePMuonBestTrack", true)->setComment("embed muon best track (muon only)");
702  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");
703  iDesc.add<bool>("embedTrack", true)->setComment("embed external track");
704  iDesc.add<bool>("embedStandAloneMuon", true)->setComment("embed external stand-alone muon");
705  iDesc.add<bool>("embedCombinedMuon", false)->setComment("embed external combined muon");
706  iDesc.add<bool>("embedPickyMuon", false)->setComment("embed external picky track");
707  iDesc.add<bool>("embedTpfmsMuon", false)->setComment("embed external tpfms track");
708  iDesc.add<bool>("embedDytMuon", false)->setComment("embed external dyt track ");
709 
710  // embedding of MET muon corrections
711  iDesc.add<bool>("embedCaloMETMuonCorrs", true)->setComment("whether to add MET muon correction for caloMET or not");
712  iDesc.add<edm::InputTag>("caloMETMuonCorrs", edm::InputTag("muonMETValueMapProducer" , "muCorrData"))->setComment("source of MET muon corrections for caloMET");
713  iDesc.add<bool>("embedTcMETMuonCorrs", true)->setComment("whether to add MET muon correction for tcMET or not");
714  iDesc.add<edm::InputTag>("tcMETMuonCorrs", edm::InputTag("muonTCMETValueMapProducer" , "muCorrData"))->setComment("source of MET muon corrections for tcMET");
715 
716  // pf specific parameters
717  iDesc.add<edm::InputTag>("pfMuonSource", edm::InputTag("pfMuons"))->setComment("particle flow input collection");
718  iDesc.add<bool>("useParticleFlow", false)->setComment("whether to use particle flow or not");
719  iDesc.add<bool>("embedPFCandidate", false)->setComment("embed external particle flow object");
720  iDesc.add<bool>("embedPfEcalEnergy", true)->setComment("add ecal energy as reconstructed by PF");
721 
722  // MC matching configurables
723  iDesc.add<bool>("addGenMatch", true)->setComment("add MC matching");
724  iDesc.add<bool>("embedGenMatch", false)->setComment("embed MC matched MC information");
725  std::vector<edm::InputTag> emptySourceVector;
726  iDesc.addNode( edm::ParameterDescription<edm::InputTag>("genParticleMatch", edm::InputTag(), true) xor
727  edm::ParameterDescription<std::vector<edm::InputTag> >("genParticleMatch", emptySourceVector, true)
728  )->setComment("input with MC match information");
729 
730  // mini-iso
731  iDesc.add<bool>("computeMiniIso", false)->setComment("whether or not to compute and store electron mini-isolation");
732  iDesc.add<edm::InputTag>("pfCandsForMiniIso", edm::InputTag("packedPFCandidates"))->setComment("collection to use to compute mini-iso");
733  iDesc.add<std::vector<double> >("miniIsoParams", std::vector<double>())->setComment("mini-iso parameters to use for muons");
734 
736 
737  // IsoDeposit configurables
738  edm::ParameterSetDescription isoDepositsPSet;
739  isoDepositsPSet.addOptional<edm::InputTag>("tracker");
740  isoDepositsPSet.addOptional<edm::InputTag>("ecal");
741  isoDepositsPSet.addOptional<edm::InputTag>("hcal");
742  isoDepositsPSet.addOptional<edm::InputTag>("particle");
743  isoDepositsPSet.addOptional<edm::InputTag>("pfChargedHadrons");
744  isoDepositsPSet.addOptional<edm::InputTag>("pfChargedAll");
745  isoDepositsPSet.addOptional<edm::InputTag>("pfPUChargedHadrons");
746  isoDepositsPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
747  isoDepositsPSet.addOptional<edm::InputTag>("pfPhotons");
748  isoDepositsPSet.addOptional<std::vector<edm::InputTag> >("user");
749  iDesc.addOptional("isoDeposits", isoDepositsPSet);
750 
751  // isolation values configurables
752  edm::ParameterSetDescription isolationValuesPSet;
753  isolationValuesPSet.addOptional<edm::InputTag>("tracker");
754  isolationValuesPSet.addOptional<edm::InputTag>("ecal");
755  isolationValuesPSet.addOptional<edm::InputTag>("hcal");
756  isolationValuesPSet.addOptional<edm::InputTag>("particle");
757  isolationValuesPSet.addOptional<edm::InputTag>("pfChargedHadrons");
758  isolationValuesPSet.addOptional<edm::InputTag>("pfChargedAll");
759  isolationValuesPSet.addOptional<edm::InputTag>("pfPUChargedHadrons");
760  isolationValuesPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
761  isolationValuesPSet.addOptional<edm::InputTag>("pfPhotons");
762  iDesc.addOptional("isolationValues", isolationValuesPSet);
763 
764  iDesc.ifValue(edm::ParameterDescription<bool>("addPuppiIsolation", false, true),
765  true >> (edm::ParameterDescription<edm::InputTag>("puppiIsolationChargedHadrons", edm::InputTag("muonPUPPIIsolation","h+-DR030-ThresholdVeto000-ConeVeto000"), true) and
766  edm::ParameterDescription<edm::InputTag>("puppiIsolationNeutralHadrons", edm::InputTag("muonPUPPIIsolation","h0-DR030-ThresholdVeto000-ConeVeto001"), true) and
767  edm::ParameterDescription<edm::InputTag>("puppiIsolationPhotons", edm::InputTag("muonPUPPIIsolation","gamma-DR030-ThresholdVeto000-ConeVeto001"), true) and
768  edm::ParameterDescription<edm::InputTag>("puppiNoLeptonsIsolationChargedHadrons", edm::InputTag("muonPUPPINoLeptonsIsolation","h+-DR030-ThresholdVeto000-ConeVeto000"), true) and
769  edm::ParameterDescription<edm::InputTag>("puppiNoLeptonsIsolationNeutralHadrons", edm::InputTag("muonPUPPINoLeptonsIsolation","h0-DR030-ThresholdVeto000-ConeVeto001"), true) and
770  edm::ParameterDescription<edm::InputTag>("puppiNoLeptonsIsolationPhotons", edm::InputTag("muonPUPPINoLeptonsIsolation","gamma-DR030-ThresholdVeto000-ConeVeto001"), true)) or
771  false >> edm::EmptyGroupDescription());
772 
773  // Efficiency configurables
774  edm::ParameterSetDescription efficienciesPSet;
775  efficienciesPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
776  iDesc.add("efficiencies", efficienciesPSet);
777  iDesc.add<bool>("addEfficiencies", false);
778 
779  // Check to see if the user wants to add user data
780  edm::ParameterSetDescription userDataPSet;
782  iDesc.addOptional("userData", userDataPSet);
783 
784  edm::ParameterSetDescription isolationPSet;
785  isolationPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
786  iDesc.add("userIsolation", isolationPSet);
787 
788  iDesc.add<bool>("embedHighLevelSelection", true)->setComment("embed high level selection");
789  edm::ParameterSetDescription highLevelPSet;
790  highLevelPSet.setAllowAnything();
791  iDesc.addNode( edm::ParameterDescription<edm::InputTag>("beamLineSrc", edm::InputTag(), true)
792  )->setComment("input with high level selection");
794  )->setComment("input with high level selection");
795 
796  //descriptions.add("PATMuonProducer", iDesc);
797 }
798 
799 
800 
801 // embed various impact parameters with errors
802 // embed high level selection
807  bool primaryVertexIsValid,
809  bool beamspotIsValid
810  )
811 {
812  // Correct to PV
813 
814  // PV2D
815  std::pair<bool,Measurement1D> result =
817  GlobalVector(track->px(),
818  track->py(),
819  track->pz()),
820  primaryVertex);
821  double d0_corr = result.second.value();
822  double d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
823  aMuon.setDB( d0_corr, d0_err, pat::Muon::PV2D);
824 
825 
826  // PV3D
827  result =
829  GlobalVector(track->px(),
830  track->py(),
831  track->pz()),
832  primaryVertex);
833  d0_corr = result.second.value();
834  d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
835  aMuon.setDB( d0_corr, d0_err, pat::Muon::PV3D);
836 
837 
838  // Correct to beam spot
839  // make a fake vertex out of beam spot
840  reco::Vertex vBeamspot(beamspot.position(), beamspot.rotatedCovariance3D());
841 
842  // BS2D
843  result =
845  GlobalVector(track->px(),
846  track->py(),
847  track->pz()),
848  vBeamspot);
849  d0_corr = result.second.value();
850  d0_err = beamspotIsValid ? result.second.error() : -1.0;
851  aMuon.setDB( d0_corr, d0_err, pat::Muon::BS2D);
852 
853  // BS3D
854  result =
856  GlobalVector(track->px(),
857  track->py(),
858  track->pz()),
859  vBeamspot);
860  d0_corr = result.second.value();
861  d0_err = beamspotIsValid ? result.second.error() : -1.0;
862  aMuon.setDB( d0_corr, d0_err, pat::Muon::BS3D);
863 
864 
865  // PVDZ
866  aMuon.setDB( track->dz(primaryVertex.position()), std::hypot(track->dzError(), primaryVertex.zError()), pat::Muon::PVDZ );
867 }
868 
870 
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:222
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:136
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:519
void computeMva(const pat::Muon &imuon)
void setAllowAnything()
allow any parameter label/value pairs
double zError() const
error on z
Definition: Vertex.h:123
void initialize(std::string weightsfile)
void setSimFlavour(int f)
Definition: Muon.h:304
#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:308
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:313
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:309
void setSimHeaviestMotherFlavour(int id)
Definition: Muon.h:305
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:302
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
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:272
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_
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:108
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:459
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:307
const T & get() const
Definition: EventSetup.h:59
std::string softMvaTrainingFile_
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:303
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:310
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
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:306
void setSimPt(float pt)
Definition: Muon.h:311
float miniIsoDr(const math::XYZTLorentzVector &p4, float mindr, float maxdr, float kt_scale)
std::vector< edm::Handle< edm::ValueMap< IsoDeposit > > > IsoDepositMaps
std::string fullPath() const
Definition: FileInPath.cc:197
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
pat::SoftMuonMvaEstimator softMvaEstimator_
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:312
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