CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PATMuonProducer.cc
Go to the documentation of this file.
1 //
2 // $Id: PATMuonProducer.cc,v 1.49.2.2 2012/09/21 15:49:27 vadler Exp $
3 //
4 
6 
10 
14 
16 
19 
22 
24 
27 
28 
31 
36 
37 
38 #include "TMath.h"
39 
40 #include <vector>
41 #include <memory>
42 
43 
44 using namespace pat;
45 using namespace std;
46 
47 
48 PATMuonProducer::PATMuonProducer(const edm::ParameterSet & iConfig) : useUserData_(iConfig.exists("userData")),
49  isolator_(iConfig.exists("userIsolation") ? iConfig.getParameter<edm::ParameterSet>("userIsolation") : edm::ParameterSet(), false)
50 {
51  // input source
52  muonSrc_ = iConfig.getParameter<edm::InputTag>( "muonSource" );
53  // embedding of tracks
54  embedBestTrack_ = iConfig.getParameter<bool>( "embedMuonBestTrack" );
55  embedImprovedBestTrack_ = iConfig.getParameter<bool>( "embedImprovedMuonBestTrack" );
56  embedTrack_ = iConfig.getParameter<bool>( "embedTrack" );
57  embedCombinedMuon_ = iConfig.getParameter<bool>( "embedCombinedMuon" );
58  embedStandAloneMuon_ = iConfig.getParameter<bool>( "embedStandAloneMuon" );
59  // embedding of muon MET correction information
60  embedCaloMETMuonCorrs_ = iConfig.getParameter<bool>("embedCaloMETMuonCorrs" );
61  embedTcMETMuonCorrs_ = iConfig.getParameter<bool>("embedTcMETMuonCorrs" );
62  caloMETMuonCorrs_ = iConfig.getParameter<edm::InputTag>("caloMETMuonCorrs" );
63  tcMETMuonCorrs_ = iConfig.getParameter<edm::InputTag>("tcMETMuonCorrs" );
64  // pflow specific configurables
65  useParticleFlow_ = iConfig.getParameter<bool>( "useParticleFlow" );
66  embedPFCandidate_ = iConfig.getParameter<bool>( "embedPFCandidate" );
67  pfMuonSrc_ = iConfig.getParameter<edm::InputTag>( "pfMuonSource" );
68  // embedding of tracks from TeV refit
69  embedPickyMuon_ = iConfig.getParameter<bool>( "embedPickyMuon" );
70  embedTpfmsMuon_ = iConfig.getParameter<bool>( "embedTpfmsMuon" );
71  embedDytMuon_ = iConfig.getParameter<bool>( "embedDytMuon" );
72  // Monte Carlo matching
73  addGenMatch_ = iConfig.getParameter<bool>( "addGenMatch" );
74  if(addGenMatch_){
75  embedGenMatch_ = iConfig.getParameter<bool>( "embedGenMatch" );
76  if(iConfig.existsAs<edm::InputTag>("genParticleMatch")){
77  genMatchSrc_.push_back(iConfig.getParameter<edm::InputTag>( "genParticleMatch" ));
78  } else {
79  genMatchSrc_ = iConfig.getParameter<std::vector<edm::InputTag> >( "genParticleMatch" );
80  }
81  }
82  // efficiencies
83  addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies");
84  if(addEfficiencies_){
86  }
87  // resolutions
88  addResolutions_ = iConfig.getParameter<bool>("addResolutions");
89  if (addResolutions_) {
91  }
92  // read isoDeposit labels, for direct embedding
93  readIsolationLabels(iConfig, "isoDeposits", isoDepositLabels_);
94  // read isolation value labels, for direct embedding
95  readIsolationLabels(iConfig, "isolationValues", isolationValueLabels_);
96  // check to see if the user wants to add user data
97  if( useUserData_ ){
99  }
100  // embed high level selection variables
101  usePV_ = true;
102  embedHighLevelSelection_ = iConfig.getParameter<bool>("embedHighLevelSelection");
103  if ( embedHighLevelSelection_ ) {
104  beamLineSrc_ = iConfig.getParameter<edm::InputTag>("beamLineSrc");
105  usePV_ = iConfig.getParameter<bool>("usePV");
106  pvSrc_ = iConfig.getParameter<edm::InputTag>("pvSrc");
107  }
108  // produces vector of muons
109  produces<std::vector<Muon> >();
110 }
111 
112 
114 {
115 }
116 
118 {
119  // switch off embedding (in unschedules mode)
120  if (iEvent.isRealData()){
121  addGenMatch_ = false;
122  embedGenMatch_ = false;
123  }
124 
126  iEvent.getByLabel(muonSrc_, muons);
127 
128  // get the ESHandle for the transient track builder,
129  // if needed for high level selection embedding
131 
132  if(isolator_.enabled()) isolator_.beginEvent(iEvent,iSetup);
134  if(resolutionLoader_.enabled()) resolutionLoader_.newEvent(iEvent, iSetup);
135 
136  IsoDepositMaps deposits(isoDepositLabels_.size());
137  for (size_t j = 0; j<isoDepositLabels_.size(); ++j) {
138  iEvent.getByLabel(isoDepositLabels_[j].second, deposits[j]);
139  }
140 
141  IsolationValueMaps isolationValues(isolationValueLabels_.size());
142  for (size_t j = 0; j<isolationValueLabels_.size(); ++j) {
143  iEvent.getByLabel(isolationValueLabels_[j].second, isolationValues[j]);
144  }
145 
146  // prepare the MC matching
147  GenAssociations genMatches(genMatchSrc_.size());
148  if (addGenMatch_) {
149  for (size_t j = 0, nd = genMatchSrc_.size(); j < nd; ++j) {
150  iEvent.getByLabel(genMatchSrc_[j], genMatches[j]);
151  }
152  }
153 
154  // prepare the high level selection: needs beamline
155  // OR primary vertex, depending on user selection
156  reco::TrackBase::Point beamPoint(0,0,0);
157  reco::Vertex primaryVertex;
159  bool beamSpotIsValid = false;
160  bool primaryVertexIsValid = false;
161  if ( embedHighLevelSelection_ ) {
162  // get the beamspot
163  edm::Handle<reco::BeamSpot> beamSpotHandle;
164  iEvent.getByLabel(beamLineSrc_, beamSpotHandle);
165 
166  // get the primary vertex
168  iEvent.getByLabel( pvSrc_, pvHandle );
169 
170  if( beamSpotHandle.isValid() ){
171  beamSpot = *beamSpotHandle;
172  beamSpotIsValid = true;
173  } else{
174  edm::LogError("DataNotAvailable")
175  << "No beam spot available from EventSetup, not adding high level selection \n";
176  }
177  beamPoint = reco::TrackBase::Point ( beamSpot.x0(), beamSpot.y0(), beamSpot.z0() );
178  if( pvHandle.isValid() && !pvHandle->empty() ) {
179  primaryVertex = pvHandle->at(0);
180  primaryVertexIsValid = true;
181  } else {
182  edm::LogError("DataNotAvailable")
183  << "No primary vertex available from EventSetup, not adding high level selection \n";
184  }
185  // this is needed by the IPTools methods from the tracking group
186  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", trackBuilder);
187  }
188 
189  // this will be the new object collection
190  std::vector<Muon> * patMuons = new std::vector<Muon>();
191 
192  if( useParticleFlow_ ){
193  // get the PFCandidates of type muons
195  iEvent.getByLabel(pfMuonSrc_, pfMuons);
196 
197  unsigned index=0;
198  for( reco::PFCandidateConstIterator i = pfMuons->begin(); i != pfMuons->end(); ++i, ++index) {
199  const reco::PFCandidate& pfmu = *i;
200  //const reco::IsolaPFCandidate& pfmu = *i;
201  const reco::MuonRef& muonRef = pfmu.muonRef();
202  assert( muonRef.isNonnull() );
203 
204  MuonBaseRef muonBaseRef(muonRef);
205  Muon aMuon(muonBaseRef);
206 
207  if ( useUserData_ ) {
208  userDataHelper_.add( aMuon, iEvent, iSetup );
209  }
210 
211  // embed high level selection
212  if ( embedHighLevelSelection_ ) {
213  // get the tracks
214  reco::TrackRef innerTrack = muonBaseRef->innerTrack();
215  reco::TrackRef globalTrack= muonBaseRef->globalTrack();
216  reco::TrackRef bestTrack = muon::muonBestTrack(*muonBaseRef, reco::defaultTuneP).first;
217 
218  // Make sure the collection it points to is there
219  if ( bestTrack.isNonnull() && bestTrack.isAvailable() ) {
220  unsigned int nhits = bestTrack->numberOfValidHits(); // ????
221  aMuon.setNumberOfValidHits( nhits );
222 
223  reco::TransientTrack tt = trackBuilder->build(bestTrack);
224  embedHighLevel( aMuon,
225  bestTrack,
226  tt,
227  primaryVertex,
228  primaryVertexIsValid,
229  beamSpot,
230  beamSpotIsValid );
231 
232  // Correct to PV, or beam spot
233  if ( !usePV_ ) {
234  double corr_d0 = -1.0 * bestTrack->dxy( beamPoint );
235  aMuon.setDB( corr_d0, -1.0 );
236  } else {
237  std::pair<bool,Measurement1D> result = IPTools::absoluteTransverseImpactParameter(tt, primaryVertex);
238  double d0_corr = result.second.value();
239  double d0_err = result.second.error();
240  aMuon.setDB( d0_corr, d0_err );
241  }
242  }
243 
244  if ( globalTrack.isNonnull() && globalTrack.isAvailable() ) {
245  double norm_chi2 = globalTrack->chi2() / globalTrack->ndof();
246  aMuon.setNormChi2( norm_chi2 );
247  }
248  }
249  reco::PFCandidateRef pfRef(pfMuons,index);
250  //reco::PFCandidatePtr ptrToMother(pfMuons,index);
251  reco::CandidateBaseRef pfBaseRef( pfRef );
252 
253  aMuon.setPFCandidateRef( pfRef );
254  if( embedPFCandidate_ ) aMuon.embedPFCandidate();
255  fillMuon( aMuon, muonBaseRef, pfBaseRef, genMatches, deposits, isolationValues );
256  patMuons->push_back(aMuon);
257  }
258  }
259  else {
261  iEvent.getByLabel(muonSrc_, muons);
262 
263  // embedding of muon MET corrections
265  //edm::ValueMap<reco::MuonMETCorrectionData> caloMETmuCorValueMap;
267  iEvent.getByLabel(caloMETMuonCorrs_, caloMETMuonCorrs);
268  //caloMETmuCorValueMap = *caloMETmuCorValueMap_h;
269  }
271  //edm::ValueMap<reco::MuonMETCorrectionData> tcMETmuCorValueMap;
273  iEvent.getByLabel(tcMETMuonCorrs_, tcMETMuonCorrs);
274  //tcMETmuCorValueMap = *tcMETmuCorValueMap_h;
275  }
276  for (edm::View<reco::Muon>::const_iterator itMuon = muons->begin(); itMuon != muons->end(); ++itMuon) {
277  // construct the Muon from the ref -> save ref to original object
278  unsigned int idx = itMuon - muons->begin();
279  MuonBaseRef muonRef = muons->refAt(idx);
280  reco::CandidateBaseRef muonBaseRef( muonRef );
281 
282  Muon aMuon(muonRef);
283  fillMuon( aMuon, muonRef, muonBaseRef, genMatches, deposits, isolationValues);
284 
285  // Isolation
286  if (isolator_.enabled()) {
287  //reco::CandidatePtr mother = ptrToMother->sourceCandidatePtr(0);
288  isolator_.fill(*muons, idx, isolatorTmpStorage_);
289  typedef pat::helper::MultiIsolator::IsolationValuePairs IsolationValuePairs;
290  // better to loop backwards, so the vector is resized less times
291  for (IsolationValuePairs::const_reverse_iterator it = isolatorTmpStorage_.rbegin(), ed = isolatorTmpStorage_.rend(); it != ed; ++it) {
292  aMuon.setIsolation(it->first, it->second);
293  }
294  }
295 
296  // for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
297  // aMuon.setIsoDeposit(isoDepositLabels_[j].first,
298  // (*deposits[j])[muonRef]);
299  // }
300 
301  // add sel to selected
302  edm::Ptr<reco::Muon> muonsPtr = muons->ptrAt(idx);
303  if ( useUserData_ ) {
304  userDataHelper_.add( aMuon, iEvent, iSetup );
305  }
306 
307  // embed high level selection
308  if ( embedHighLevelSelection_ ) {
309  // get the tracks
310  reco::TrackRef innerTrack = itMuon->innerTrack();
311  reco::TrackRef globalTrack= itMuon->globalTrack();
312  reco::TrackRef bestTrack = muon::muonBestTrack(*itMuon, reco::defaultTuneP).first;
313 
314  // Make sure the collection it points to is there
315  if ( bestTrack.isNonnull() && bestTrack.isAvailable() ) {
316  unsigned int nhits = bestTrack->numberOfValidHits(); // ????
317  aMuon.setNumberOfValidHits( nhits );
318 
319  reco::TransientTrack tt = trackBuilder->build(bestTrack);
320  embedHighLevel( aMuon,
321  bestTrack,
322  tt,
323  primaryVertex,
324  primaryVertexIsValid,
325  beamSpot,
326  beamSpotIsValid );
327 
328  // Correct to PV, or beam spot
329  if ( !usePV_ ) {
330  double corr_d0 = -1.0 * bestTrack->dxy( beamPoint );
331  aMuon.setDB( corr_d0, -1.0 );
332  } else {
333  std::pair<bool,Measurement1D> result = IPTools::absoluteTransverseImpactParameter(tt, primaryVertex);
334  double d0_corr = result.second.value();
335  double d0_err = result.second.error();
336  aMuon.setDB( d0_corr, d0_err );
337  }
338  }
339 
340  if ( globalTrack.isNonnull() && globalTrack.isAvailable() ) {
341  double norm_chi2 = globalTrack->chi2() / globalTrack->ndof();
342  aMuon.setNormChi2( norm_chi2 );
343  }
344  }
345 
346  // embed MET muon corrections
347  if( embedCaloMETMuonCorrs_ ) aMuon.embedCaloMETMuonCorrs((*caloMETMuonCorrs)[muonRef]);
348  if( embedTcMETMuonCorrs_ ) aMuon.embedTcMETMuonCorrs((*tcMETMuonCorrs )[muonRef]);
349 
350  patMuons->push_back(aMuon);
351  }
352  }
353 
354  // sort muons in pt
355  std::sort(patMuons->begin(), patMuons->end(), pTComparator_);
356 
357  // put genEvt object in Event
358  std::auto_ptr<std::vector<Muon> > ptr(patMuons);
359  iEvent.put(ptr);
360 
362 }
363 
364 
365 void PATMuonProducer::fillMuon( Muon& aMuon, const MuonBaseRef& muonRef, const reco::CandidateBaseRef& baseRef, const GenAssociations& genMatches, const IsoDepositMaps& deposits, const IsolationValueMaps& isolationValues ) const
366 {
367  // in the particle flow algorithm,
368  // the muon momentum is recomputed.
369  // the new value is stored as the momentum of the
370  // resulting PFCandidate of type Muon, and choosen
371  // as the pat::Muon momentum
372  if (useParticleFlow_)
373  aMuon.setP4( aMuon.pfCandidateRef()->p4() );
374  if (embedBestTrack_) aMuon.embedMuonBestTrack();
376  aMuon.setBestTrack(newBestTrack.second);
379  aMuon.setImprovedBestTrack(newImprovedBestTrack.second);
380  if (embedTrack_) aMuon.embedTrack();
383 
384  // embed the TeV refit track refs (only available for globalMuons)
385  if (aMuon.isGlobalMuon()) {
387  aMuon.embedPickyMuon();
389  aMuon.embedTpfmsMuon();
391  aMuon.embedDytMuon();
392  }
393 
394  // store the match to the generated final state muons
395  if (addGenMatch_) {
396  for(size_t i = 0, n = genMatches.size(); i < n; ++i) {
397  reco::GenParticleRef genMuon = (*genMatches[i])[baseRef];
398  aMuon.addGenParticleRef(genMuon);
399  }
400  if (embedGenMatch_) aMuon.embedGenParticle();
401  }
402  if (efficiencyLoader_.enabled()) {
403  efficiencyLoader_.setEfficiencies( aMuon, muonRef );
404  }
405 
406  for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
407  if(useParticleFlow_) {
408  if (deposits[j]->contains(baseRef.id())) {
409  aMuon.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[baseRef]);
410  } else if (deposits[j]->contains(muonRef.id())){
411  aMuon.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[muonRef]);
412  } else {
413  reco::CandidatePtr source = aMuon.pfCandidateRef()->sourceCandidatePtr(0);
414  aMuon.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[source]);
415  }
416  }
417  else{
418  aMuon.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[muonRef]);
419  }
420  }
421 
422  for (size_t j = 0; j<isolationValues.size(); ++j) {
423  if(useParticleFlow_) {
424  if (isolationValues[j]->contains(baseRef.id())) {
425  aMuon.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[baseRef]);
426  } else if (isolationValues[j]->contains(muonRef.id())) {
427  aMuon.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[muonRef]);
428  } else {
429  reco::CandidatePtr source = aMuon.pfCandidateRef()->sourceCandidatePtr(0);
430  aMuon.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[source]);
431  }
432  }
433  else{
434  aMuon.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[muonRef]);
435  }
436  }
437 
438  if (resolutionLoader_.enabled()) {
440  }
441 }
442 
443 // ParameterSet description for module
445 {
447  iDesc.setComment("PAT muon producer module");
448 
449  // input source
450  iDesc.add<edm::InputTag>("muonSource", edm::InputTag("no default"))->setComment("input collection");
451 
452  // embedding
453  iDesc.add<bool>("embedMuonBestTrack", true)->setComment("embed muon best track");
454  iDesc.add<bool>("embedImprovedMuonBestTrack", true)->setComment("embed muon best track, new tuneP (only 53X)");
455  iDesc.add<bool>("embedTrack", true)->setComment("embed external track");
456  iDesc.add<bool>("embedStandAloneMuon", true)->setComment("embed external stand-alone muon");
457  iDesc.add<bool>("embedCombinedMuon", false)->setComment("embed external combined muon");
458  iDesc.add<bool>("embedPickyMuon", false)->setComment("embed external picky track");
459  iDesc.add<bool>("embedTpfmsMuon", false)->setComment("embed external tpfms track");
460  iDesc.add<bool>("embedDytMuon", false)->setComment("embed external dyt track ");
461 
462  // embedding of MET muon corrections
463  iDesc.add<bool>("embedCaloMETMuonCorrs", true)->setComment("whether to add MET muon correction for caloMET or not");
464  iDesc.add<edm::InputTag>("caloMETMuonCorrs", edm::InputTag("muonMETValueMapProducer" , "muCorrData"))->setComment("source of MET muon corrections for caloMET");
465  iDesc.add<bool>("embedTcMETMuonCorrs", true)->setComment("whether to add MET muon correction for tcMET or not");
466  iDesc.add<edm::InputTag>("tcMETMuonCorrs", edm::InputTag("muonTCMETValueMapProducer" , "muCorrData"))->setComment("source of MET muon corrections for tcMET");
467 
468  // pf specific parameters
469  iDesc.add<edm::InputTag>("pfMuonSource", edm::InputTag("pfMuons"))->setComment("particle flow input collection");
470  iDesc.add<bool>("useParticleFlow", false)->setComment("whether to use particle flow or not");
471  iDesc.add<bool>("embedPFCandidate", false)->setComment("embed external particle flow object");
472 
473  // MC matching configurables
474  iDesc.add<bool>("addGenMatch", true)->setComment("add MC matching");
475  iDesc.add<bool>("embedGenMatch", false)->setComment("embed MC matched MC information");
476  std::vector<edm::InputTag> emptySourceVector;
477  iDesc.addNode( edm::ParameterDescription<edm::InputTag>("genParticleMatch", edm::InputTag(), true) xor
478  edm::ParameterDescription<std::vector<edm::InputTag> >("genParticleMatch", emptySourceVector, true)
479  )->setComment("input with MC match information");
480 
482 
483  // IsoDeposit configurables
484  edm::ParameterSetDescription isoDepositsPSet;
485  isoDepositsPSet.addOptional<edm::InputTag>("tracker");
486  isoDepositsPSet.addOptional<edm::InputTag>("ecal");
487  isoDepositsPSet.addOptional<edm::InputTag>("hcal");
488  isoDepositsPSet.addOptional<edm::InputTag>("particle");
489  isoDepositsPSet.addOptional<edm::InputTag>("pfChargedHadrons");
490  isoDepositsPSet.addOptional<edm::InputTag>("pfChargedAll");
491  isoDepositsPSet.addOptional<edm::InputTag>("pfPUChargedHadrons");
492  isoDepositsPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
493  isoDepositsPSet.addOptional<edm::InputTag>("pfPhotons");
494  isoDepositsPSet.addOptional<std::vector<edm::InputTag> >("user");
495  iDesc.addOptional("isoDeposits", isoDepositsPSet);
496 
497  // isolation values configurables
498  edm::ParameterSetDescription isolationValuesPSet;
499  isolationValuesPSet.addOptional<edm::InputTag>("tracker");
500  isolationValuesPSet.addOptional<edm::InputTag>("ecal");
501  isolationValuesPSet.addOptional<edm::InputTag>("hcal");
502  isolationValuesPSet.addOptional<edm::InputTag>("particle");
503  isolationValuesPSet.addOptional<edm::InputTag>("pfChargedHadrons");
504  isolationValuesPSet.addOptional<edm::InputTag>("pfChargedAll");
505  isolationValuesPSet.addOptional<edm::InputTag>("pfPUChargedHadrons");
506  isolationValuesPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
507  isolationValuesPSet.addOptional<edm::InputTag>("pfPhotons");
508  iDesc.addOptional("isolationValues", isolationValuesPSet);
509 
510  // Efficiency configurables
511  edm::ParameterSetDescription efficienciesPSet;
512  efficienciesPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
513  iDesc.add("efficiencies", efficienciesPSet);
514  iDesc.add<bool>("addEfficiencies", false);
515 
516  // Check to see if the user wants to add user data
517  edm::ParameterSetDescription userDataPSet;
519  iDesc.addOptional("userData", userDataPSet);
520 
521  edm::ParameterSetDescription isolationPSet;
522  isolationPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
523  iDesc.add("userIsolation", isolationPSet);
524 
525  iDesc.add<bool>("embedHighLevelSelection", true)->setComment("embed high level selection");
526  edm::ParameterSetDescription highLevelPSet;
527  highLevelPSet.setAllowAnything();
528  iDesc.addNode( edm::ParameterDescription<edm::InputTag>("beamLineSrc", edm::InputTag(), true)
529  )->setComment("input with high level selection");
531  )->setComment("input with high level selection");
532  iDesc.addNode( edm::ParameterDescription<bool>("usePV", bool(), true)
533  )->setComment("input with high level selection, use primary vertex (true) or beam line (false)");
534 
535  //descriptions.add("PATMuonProducer", iDesc);
536 }
537 
538 
539 void PATMuonProducer::readIsolationLabels( const edm::ParameterSet & iConfig, const char* psetName, IsolationLabels& labels)
540 {
541  labels.clear();
542 
543  if (iConfig.exists( psetName )) {
544  edm::ParameterSet depconf = iConfig.getParameter<edm::ParameterSet>(psetName);
545 
546  if (depconf.exists("tracker")) labels.push_back(std::make_pair(pat::TrackIso, depconf.getParameter<edm::InputTag>("tracker")));
547  if (depconf.exists("ecal")) labels.push_back(std::make_pair(pat::EcalIso, depconf.getParameter<edm::InputTag>("ecal")));
548  if (depconf.exists("hcal")) labels.push_back(std::make_pair(pat::HcalIso, depconf.getParameter<edm::InputTag>("hcal")));
549  if (depconf.exists("pfAllParticles")) {
550  labels.push_back(std::make_pair(pat::PfAllParticleIso, depconf.getParameter<edm::InputTag>("pfAllParticles")));
551  }
552  if (depconf.exists("pfChargedHadrons")) {
553  labels.push_back(std::make_pair(pat::PfChargedHadronIso, depconf.getParameter<edm::InputTag>("pfChargedHadrons")));
554  }
555  if (depconf.exists("pfChargedAll")) {
556  labels.push_back(std::make_pair(pat::PfChargedAllIso, depconf.getParameter<edm::InputTag>("pfChargedAll")));
557  }
558  if (depconf.exists("pfPUChargedHadrons")) {
559  labels.push_back(std::make_pair(pat::PfPUChargedHadronIso, depconf.getParameter<edm::InputTag>("pfPUChargedHadrons")));
560  }
561  if (depconf.exists("pfNeutralHadrons")) {
562  labels.push_back(std::make_pair(pat::PfNeutralHadronIso, depconf.getParameter<edm::InputTag>("pfNeutralHadrons")));
563  }
564  if (depconf.exists("pfPhotons")) {
565  labels.push_back(std::make_pair(pat::PfGammaIso, depconf.getParameter<edm::InputTag>("pfPhotons")));
566  }
567  if (depconf.exists("user")) {
568  std::vector<edm::InputTag> userdeps = depconf.getParameter<std::vector<edm::InputTag> >("user");
569  std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
570  int key = UserBaseIso;
571  for ( ; it != ed; ++it, ++key) {
572  labels.push_back(std::make_pair(IsolationKeys(key), *it));
573  }
574  }
575  }
576 }
577 
578 
579 
580 // embed various impact parameters with errors
581 // embed high level selection
583  reco::TrackRef track,
585  reco::Vertex & primaryVertex,
586  bool primaryVertexIsValid,
587  reco::BeamSpot & beamspot,
588  bool beamspotIsValid
589  )
590 {
591  // Correct to PV
592 
593  // PV2D
594  std::pair<bool,Measurement1D> result =
596  GlobalVector(track->px(),
597  track->py(),
598  track->pz()),
599  primaryVertex);
600  double d0_corr = result.second.value();
601  double d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
602  aMuon.setDB( d0_corr, d0_err, pat::Muon::PV2D);
603 
604 
605  // PV3D
606  result =
608  GlobalVector(track->px(),
609  track->py(),
610  track->pz()),
611  primaryVertex);
612  d0_corr = result.second.value();
613  d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
614  aMuon.setDB( d0_corr, d0_err, pat::Muon::PV3D);
615 
616 
617  // Correct to beam spot
618  // make a fake vertex out of beam spot
619  reco::Vertex vBeamspot(beamspot.position(), beamspot.rotatedCovariance3D());
620 
621  // BS2D
622  result =
624  GlobalVector(track->px(),
625  track->py(),
626  track->pz()),
627  vBeamspot);
628  d0_corr = result.second.value();
629  d0_err = beamspotIsValid ? result.second.error() : -1.0;
630  aMuon.setDB( d0_corr, d0_err, pat::Muon::BS2D);
631 
632  // BS3D
633  result =
635  GlobalVector(track->px(),
636  track->py(),
637  track->pz()),
638  vBeamspot);
639  d0_corr = result.second.value();
640  d0_err = beamspotIsValid ? result.second.error() : -1.0;
641  aMuon.setDB( d0_corr, d0_err, pat::Muon::BS3D);
642 }
643 
645 
bool embedTpfmsMuon_
embed track from tpfms muon fit into the muon
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) ...
T getParameter(std::string const &) const
void setComment(std::string const &value)
double z0() const
z coordinate
Definition: BeamSpot.h:69
Assists in assimilating all pat::UserData into pat objects.
bool usePV_
use the primary vertex or the beamspot
int i
Definition: DBlmapReader.cc:9
void embedStandAloneMuon()
set reference to Track reconstructed in the muon detector only (reimplemented from reco::Muon) ...
Definition: Muon.cc:282
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
reco::Muon::MuonTrackTypePair muonBestTrack(const reco::Muon &muon, reco::TunePType tunePType)
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
void setIsolation(IsolationKeys key, float value)
Definition: Lepton.h:100
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:187
bool embedImprovedBestTrack_
embed the track from best muon measurement, new tuneP, 53X option only
bool contains(EventRange const &lh, EventID const &rh)
Definition: EventRange.cc:38
void embedPFCandidate()
embed the IsolatedPFCandidate pointed to by pfCandidateRef_
Definition: Muon.cc:345
bool addEfficiencies_
add efficiencies to the muon (this will be data members of th muon even w/o embedding) ...
void setAllowAnything()
allow any parameter label/value pairs
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
bool embedCaloMETMuonCorrs_
embed muon MET correction info for caloMET into the muon
edm::InputTag pvSrc_
input source of the primary vertex
std::pair< bool, Measurement1D > signedTransverseImpactParameter(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:50
bool exists(std::string const &parameterName) const
checks if a parameter exists
bool isGlobalMuon() const
Definition: Muon.h:211
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
bool embedBestTrack_
embed the track from best muon measurement
std::pair< bool, Measurement1D > signedImpactParameter3D(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:71
virtual void setP4(const LorentzVector &p4)
set 4-momentum
edm::InputTag tcMETMuonCorrs_
source of tcMET muon corrections
edm::InputTag pfMuonSrc_
input source pfCandidates that will be to be transformed into pat::Muons, when using PF2PAT ...
bool addResolutions_
add resolutions to the muon (this will be data members of th muon even w/o embedding) ...
IsolationKeys
Enum defining isolation keys.
Definition: Isolation.h:9
bool isAvailable() const
Definition: Ref.h:276
PFCandidateCollection::const_iterator PFCandidateConstIterator
iterator
ProductID id() const
Definition: RefToBase.h:220
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
void setPFCandidateRef(const reco::PFCandidateRef &ref)
add a reference to the source IsolatedPFCandidate
Definition: Muon.h:135
bool isRealData() const
Definition: EventBase.h:60
void embedHighLevel(pat::Muon &aMuon, reco::TrackRef track, reco::TransientTrack &tt, reco::Vertex &primaryVertex, bool primaryVertexIsValid, reco::BeamSpot &beamspot, bool beamspotIsValid)
void embedPickyMuon()
embed reference to the above picky Track
Definition: Muon.cc:315
PATMuonProducer(const edm::ParameterSet &iConfig)
default constructir
pat::helper::MultiIsolator isolator_
helper class to add userdefined isolation values to the muon
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:177
void embedCombinedMuon()
set reference to Track reconstructed in both tracked and muon detector (reimplemented from reco::Muon...
Definition: Muon.cc:292
static void fillDescription(edm::ParameterSetDescription &iDesc)
std::vector< IsolationLabel > IsolationLabels
U second(std::pair< T, U > const &p)
void embedCaloMETMuonCorrs(const reco::MuonMETCorrectionData &t)
embed the MuonMETCorrectionData for muon corrected caloMET
Definition: Muon.cc:301
bool useParticleFlow_
switch to use particle flow (PF2PAT) or not
pat::PATUserDataHelper< pat::Muon > userDataHelper_
helper class to add userData to the muon
bool isAValidMuonTrack(const MuonTrackType &type) const
Definition: Muon.cc:760
bool enabled() const
True if it has a non null configuration.
Definition: MultiIsolator.h:50
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
bool embedStandAloneMuon_
embed track from muon system into the muon
void setComment(std::string const &value)
~PATMuonProducer()
default destructur
reco::PFCandidateRef pfCandidateRef() const
reference to the source IsolatedPFCandidates
Definition: Muon.cc:232
int iEvent
Definition: GenABIO.cc:243
void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup)
GreaterByPt< Muon > pTComparator_
bool embedTrack_
embed the track from inner tracker into the muon
bool addGenMatch_
add generator match information
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
description of config file parameters
edm::InputTag beamLineSrc_
input source of the primary vertex/beamspot
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
void embedGenParticle()
Definition: PATObject.h:675
void embedTrack()
set reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.cc:272
void embedTcMETMuonCorrs(const reco::MuonMETCorrectionData &t)
embed the MuonMETCorrectionData for tcMET
Definition: Muon.cc:308
tuple result
Definition: query.py:137
int j
Definition: DBlmapReader.cc:9
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)
everything that needs to be done during the event loop
math::XYZPoint Point
point in the space
Definition: TrackBase.h:76
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool first
Definition: L1TdeRCT.cc:94
bool isValid() const
Definition: HandleBase.h:76
std::vector< edm::InputTag > genMatchSrc_
input tags for generator match information
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:355
void embedTpfmsMuon()
embed reference to the above tpfms Track
Definition: Muon.cc:325
void addGenParticleRef(const reco::GenParticleRef &ref)
Definition: PATObject.h:659
edm::InputTag muonSrc_
input source
void embedDytMuon()
embed reference to the above dyt Track
Definition: Muon.cc:335
void readIsolationLabels(const edm::ParameterSet &iConfig, const char *psetName, IsolationLabels &labels)
static void fillDescription(edm::ParameterSetDescription &iDesc)
Method for documentation and validation of PSet.
void embedMuonBestTrack()
set reference to Track selected to be the best measurement of the muon parameters (reimplemented from...
Definition: Muon.cc:250
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.
edm::InputTag caloMETMuonCorrs_
source of caloMET muon corrections
void embedImprovedMuonBestTrack()
set reference to Track selected to be the best measurement of the muon parameters (reimplemented from...
Definition: Muon.cc:259
std::pair< bool, Measurement1D > absoluteTransverseImpactParameter(const reco::TransientTrack &transientTrack, const reco::Vertex &vertex)
Definition: IPTools.cc:43
std::vector< edm::Handle< edm::Association< reco::GenParticleCollection > > > GenAssociations
void fillMuon(Muon &aMuon, const MuonBaseRef &muonRef, const reco::CandidateBaseRef &baseRef, const GenAssociations &genMatches, const IsoDepositMaps &deposits, const IsolationValueMaps &isolationValues) const
common muon filling, for both the standard and PF2PAT case
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
Definition: MultiIsolator.h:16
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:33
virtual void setBestTrack(MuonTrackType muonType)
Definition: Muon.h:94
pat::helper::EfficiencyLoader efficiencyLoader_
helper class to add efficiencies to the muon
bool embedPickyMuon_
embed track from picky muon fit into the muon
void setNormChi2(double normChi2)
Definition: Muon.h:235
list key
Definition: combine.py:13
tuple muons
Definition: patZpeak.py:38
bool embedDytMuon_
embed track from DYT muon fit into the muon
double y0() const
y coordinate
Definition: BeamSpot.h:67
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:63
IsolationLabels isoDepositLabels_
input source for isoDeposits
Covariance3DMatrix rotatedCovariance3D() const
Definition: BeamSpot.cc:79
IsolationLabels isolationValueLabels_
input source isolation value maps
std::pair< TrackRef, Muon::MuonTrackType > MuonTrackTypePair
Definition: Muon.h:41
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
bool embedPFCandidate_
embed pfCandidates into the muon
void newEvent(const edm::Event &event, const edm::EventSetup &setup) const
To be called for each new event, reads in the EventSetup object.
void setNumberOfValidHits(unsigned int numberOfValidHits)
Definition: Muon.h:230
bool embedCombinedMuon_
embed track of the combined fit into the muon
Analysis-level muon class.
Definition: Muon.h:51
pat::helper::KinResolutionsLoader resolutionLoader_
helper class to add resolutions to the muon
void newEvent(const edm::Event &event) const
To be called for each new event, reads in the ValueMaps for efficiencies.
void setDB(double dB, double edB, IpType type=None)
Definition: Muon.h:220
Global3DVector GlobalVector
Definition: GlobalVector.h:10
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const
Definition: MultiIsolator.h:82
tuple pfMuons
Definition: pfMuons_cff.py:10
virtual void setImprovedBestTrack(MuonTrackType muonType)
Definition: Muon.h:91
double x0() const
x coordinate
Definition: BeamSpot.h:65
bool embedHighLevelSelection_
embed high level selection variables