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$
3 //
4 
6 
10 
13 
15 
18 
21 
23 
26 
27 
30 
35 
36 
37 #include "TMath.h"
38 
39 #include <vector>
40 #include <memory>
41 
42 
43 using namespace pat;
44 using namespace std;
45 
46 
47 PATMuonProducer::PATMuonProducer(const edm::ParameterSet & iConfig) : useUserData_(iConfig.exists("userData")),
48  isolator_(iConfig.exists("userIsolation") ? iConfig.getParameter<edm::ParameterSet>("userIsolation") : edm::ParameterSet(), false)
49 {
50  // input source
51  muonSrc_ = iConfig.getParameter<edm::InputTag>( "muonSource" );
52  // embedding of tracks
53  embedTrack_ = iConfig.getParameter<bool>( "embedTrack" );
54  embedCombinedMuon_ = iConfig.getParameter<bool>( "embedCombinedMuon" );
55  embedStandAloneMuon_ = iConfig.getParameter<bool>( "embedStandAloneMuon" );
56 
57  // embedding of muon MET correction information
58  embedCaloMETMuonCorrs_ = iConfig.getParameter<bool>("embedCaloMETMuonCorrs" );
59  embedTcMETMuonCorrs_ = iConfig.getParameter<bool>("embedTcMETMuonCorrs" );
60  caloMETMuonCorrs_ = iConfig.getParameter<edm::InputTag>("caloMETMuonCorrs" );
61  tcMETMuonCorrs_ = iConfig.getParameter<edm::InputTag>("tcMETMuonCorrs" );
62 
63  // pflow specific configurables
64  useParticleFlow_ = iConfig.getParameter<bool>( "useParticleFlow" );
65  embedPFCandidate_ = iConfig.getParameter<bool>( "embedPFCandidate" );
66  pfMuonSrc_ = iConfig.getParameter<edm::InputTag>( "pfMuonSource" );
67 
68  // TeV track refits
69  addTeVRefits_ = iConfig.getParameter<bool>("addTeVRefits");
70  if(addTeVRefits_){
71  pickySrc_ = iConfig.getParameter<edm::InputTag>("pickySrc");
72  tpfmsSrc_ = iConfig.getParameter<edm::InputTag>("tpfmsSrc");
73  }
74  // embedding of tracks from TeV refit
75  embedPickyMuon_ = iConfig.getParameter<bool>( "embedPickyMuon" );
76  embedTpfmsMuon_ = iConfig.getParameter<bool>( "embedTpfmsMuon" );
77 
78  // Monte Carlo matching
79  addGenMatch_ = iConfig.getParameter<bool>( "addGenMatch" );
80  if(addGenMatch_){
81  embedGenMatch_ = iConfig.getParameter<bool>( "embedGenMatch" );
82  if(iConfig.existsAs<edm::InputTag>("genParticleMatch")){
83  genMatchSrc_.push_back(iConfig.getParameter<edm::InputTag>( "genParticleMatch" ));
84  } else {
85  genMatchSrc_ = iConfig.getParameter<std::vector<edm::InputTag> >( "genParticleMatch" );
86  }
87  }
88 
89  // efficiencies
90  addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies");
91  if(addEfficiencies_){
93  }
94 
95  // resolutions
96  addResolutions_ = iConfig.getParameter<bool>("addResolutions");
97  if (addResolutions_) {
99  }
100 
101  // read isoDeposit labels, for direct embedding
102  readIsolationLabels(iConfig, "isoDeposits", isoDepositLabels_);
103  // read isolation value labels, for direct embedding
104  readIsolationLabels(iConfig, "isolationValues", isolationValueLabels_);
105 
106  // check to see if the user wants to add user data
107  if( useUserData_ ){
109  }
110 
111  // embed high level selection variables
112  usePV_ = true;
113  embedHighLevelSelection_ = iConfig.getParameter<bool>("embedHighLevelSelection");
114  if ( embedHighLevelSelection_ ) {
115  beamLineSrc_ = iConfig.getParameter<edm::InputTag>("beamLineSrc");
116  usePV_ = iConfig.getParameter<bool>("usePV");
117  pvSrc_ = iConfig.getParameter<edm::InputTag>("pvSrc");
118  }
119 
120  // produces vector of muons
121  produces<std::vector<Muon> >();
122 }
123 
124 
126 {
127 }
128 
130 {
132  iEvent.getByLabel(muonSrc_, muons);
133 
134  if (iEvent.isRealData()){
135  addGenMatch_ = false;
136  embedGenMatch_ = false;
137  }
138 
139  // get the ESHandle for the transient track builder,
140  // if needed for high level selection embedding
142 
143  if(isolator_.enabled()) isolator_.beginEvent(iEvent,iSetup);
145  if(resolutionLoader_.enabled()) resolutionLoader_.newEvent(iEvent, iSetup);
146 
148  for (size_t j = 0; j<isoDepositLabels_.size(); ++j) {
150  }
151 
152  IsolationValueMaps isolationValues(isolationValueLabels_.size());
153  for (size_t j = 0; j<isolationValueLabels_.size(); ++j) {
154  iEvent.getByLabel(isolationValueLabels_[j].second, isolationValues[j]);
155  }
156 
157  // prepare the MC matching
158  GenAssociations genMatches(genMatchSrc_.size());
159  if (addGenMatch_) {
160  for (size_t j = 0, nd = genMatchSrc_.size(); j < nd; ++j) {
161  iEvent.getByLabel(genMatchSrc_[j], genMatches[j]);
162  }
163  }
164 
165  // prepare the high level selection: needs beamline
166  // OR primary vertex, depending on user selection
167  reco::TrackBase::Point beamPoint(0,0,0);
168  reco::Vertex primaryVertex;
170  bool beamSpotIsValid = false;
171  bool primaryVertexIsValid = false;
172  if ( embedHighLevelSelection_ ) {
173  // get the beamspot
174  edm::Handle<reco::BeamSpot> beamSpotHandle;
175  iEvent.getByLabel(beamLineSrc_, beamSpotHandle);
176 
177  // get the primary vertex
179  iEvent.getByLabel( pvSrc_, pvHandle );
180 
181  if( beamSpotHandle.isValid() ){
182  beamSpot = *beamSpotHandle;
183  beamSpotIsValid = true;
184  } else{
185  edm::LogError("DataNotAvailable")
186  << "No beam spot available from EventSetup, not adding high level selection \n";
187  }
188  beamPoint = reco::TrackBase::Point ( beamSpot.x0(), beamSpot.y0(), beamSpot.z0() );
189  if( pvHandle.isValid() ) {
190  primaryVertex = pvHandle->at(0);
191  primaryVertexIsValid = true;
192  } else {
193  edm::LogError("DataNotAvailable")
194  << "No primary vertex available from EventSetup, not adding high level selection \n";
195  }
196  // this is needed by the IPTools methods from the tracking group
197  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", trackBuilder);
198  }
199 
200  // this will be the new object collection
201  std::vector<Muon> * patMuons = new std::vector<Muon>();
202 
203  if( useParticleFlow_ ){
204  // get the PFCandidates of type muons
206  iEvent.getByLabel(pfMuonSrc_, pfMuons);
207 
208  unsigned index=0;
209  for( reco::PFCandidateConstIterator i = pfMuons->begin(); i != pfMuons->end(); ++i, ++index) {
210  const reco::PFCandidate& pfmu = *i;
211  //const reco::IsolaPFCandidate& pfmu = *i;
212  const reco::MuonRef& muonRef = pfmu.muonRef();
213  assert( muonRef.isNonnull() );
214 
215  MuonBaseRef muonBaseRef(muonRef);
216  Muon aMuon(muonBaseRef);
217 
218  if ( useUserData_ ) {
219  userDataHelper_.add( aMuon, iEvent, iSetup );
220  }
221 
222  // embed high level selection
223  if ( embedHighLevelSelection_ ) {
224  // get the tracks
225  reco::TrackRef innerTrack = muonBaseRef->innerTrack();
226  reco::TrackRef globalTrack= muonBaseRef->globalTrack();
227  // Make sure the collection it points to is there
228  if ( innerTrack.isNonnull() && innerTrack.isAvailable() ) {
229  unsigned int nhits = innerTrack->numberOfValidHits();
230  aMuon.setNumberOfValidHits( nhits );
231 
232  reco::TransientTrack tt = trackBuilder->build(innerTrack);
233  embedHighLevel( aMuon,
234  innerTrack,
235  tt,
236  primaryVertex,
237  primaryVertexIsValid,
238  beamSpot,
239  beamSpotIsValid );
240 
241  // Correct to PV, or beam spot
242  if ( !usePV_ ) {
243  double corr_d0 = -1.0 * innerTrack->dxy( beamPoint );
244  aMuon.setDB( corr_d0, -1.0 );
245  } else {
246  std::pair<bool,Measurement1D> result = IPTools::absoluteTransverseImpactParameter(tt, primaryVertex);
247  double d0_corr = result.second.value();
248  double d0_err = result.second.error();
249  aMuon.setDB( d0_corr, d0_err );
250  }
251  }
252 
253  if ( globalTrack.isNonnull() && globalTrack.isAvailable() ) {
254  double norm_chi2 = globalTrack->chi2() / globalTrack->ndof();
255  aMuon.setNormChi2( norm_chi2 );
256  }
257  }
258 
259  reco::PFCandidateRef pfRef(pfMuons,index);
260  //reco::PFCandidatePtr ptrToMother(pfMuons,index);
261  reco::CandidateBaseRef pfBaseRef( pfRef );
262 
263  aMuon.setPFCandidateRef( pfRef );
264  if( embedPFCandidate_ ) aMuon.embedPFCandidate();
265  fillMuon( aMuon, muonBaseRef, pfBaseRef, genMatches, deposits, isolationValues );
266  patMuons->push_back(aMuon);
267  }
268  }
269  else {
271  iEvent.getByLabel(muonSrc_, muons);
272 
273  // prepare the TeV refit track retrieval
274  edm::Handle<reco::TrackToTrackMap> pickyMap, tpfmsMap;
275  if (addTeVRefits_) {
276  iEvent.getByLabel(pickySrc_, pickyMap);
277  iEvent.getByLabel(tpfmsSrc_, tpfmsMap);
278  }
279 
280  // embedding of muon MET corrections
282  //edm::ValueMap<reco::MuonMETCorrectionData> caloMETmuCorValueMap;
284  iEvent.getByLabel(caloMETMuonCorrs_, caloMETMuonCorrs);
285  //caloMETmuCorValueMap = *caloMETmuCorValueMap_h;
286  }
288  //edm::ValueMap<reco::MuonMETCorrectionData> tcMETmuCorValueMap;
290  iEvent.getByLabel(tcMETMuonCorrs_, tcMETMuonCorrs);
291  //tcMETmuCorValueMap = *tcMETmuCorValueMap_h;
292  }
293 
294  for (edm::View<reco::Muon>::const_iterator itMuon = muons->begin(); itMuon != muons->end(); ++itMuon) {
295  // construct the Muon from the ref -> save ref to original object
296  unsigned int idx = itMuon - muons->begin();
297  MuonBaseRef muonRef = muons->refAt(idx);
298  reco::CandidateBaseRef muonBaseRef( muonRef );
299 
300  Muon aMuon(muonRef);
301  fillMuon( aMuon, muonRef, muonBaseRef, genMatches, deposits, isolationValues);
302 
303  // store the TeV refit track refs (only available for globalMuons)
304  if (addTeVRefits_ && itMuon->isGlobalMuon()) {
306  const reco::TrackRef& globalTrack = itMuon->globalTrack();
307 
308  // If the getByLabel calls failed above (i.e. if the TeV refit
309  // maps/collections were not in the event), then the TrackRefs
310  // in the Muon object will remain null.
311  if (!pickyMap.failedToGet()) {
312  it = pickyMap->find(globalTrack);
313  if (it != pickyMap->end()) aMuon.setPickyMuon(it->val);
314  if (embedPickyMuon_) aMuon.embedPickyMuon();
315  }
316 
317  if (!tpfmsMap.failedToGet()) {
318  it = tpfmsMap->find(globalTrack);
319  if (it != tpfmsMap->end()) aMuon.setTpfmsMuon(it->val);
320  if (embedTpfmsMuon_) aMuon.embedTpfmsMuon();
321  }
322  }
323 
324  // Isolation
325  if (isolator_.enabled()) {
326  //reco::CandidatePtr mother = ptrToMother->sourceCandidatePtr(0);
327  isolator_.fill(*muons, idx, isolatorTmpStorage_);
328  typedef pat::helper::MultiIsolator::IsolationValuePairs IsolationValuePairs;
329  // better to loop backwards, so the vector is resized less times
330  for (IsolationValuePairs::const_reverse_iterator it = isolatorTmpStorage_.rbegin(), ed = isolatorTmpStorage_.rend(); it != ed; ++it) {
331  aMuon.setIsolation(it->first, it->second);
332  }
333  }
334 
335  // for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
336  // aMuon.setIsoDeposit(isoDepositLabels_[j].first,
337  // (*deposits[j])[muonRef]);
338  // }
339 
340  // add sel to selected
341  edm::Ptr<reco::Muon> muonsPtr = muons->ptrAt(idx);
342  if ( useUserData_ ) {
343  userDataHelper_.add( aMuon, iEvent, iSetup );
344  }
345 
346  // embed high level selection
347  if ( embedHighLevelSelection_ ) {
348  // get the tracks
349  reco::TrackRef innerTrack = itMuon->innerTrack();
350  reco::TrackRef globalTrack= itMuon->globalTrack();
351  // Make sure the collection it points to is there
352  if ( innerTrack.isNonnull() && innerTrack.isAvailable() ) {
353  unsigned int nhits = innerTrack->numberOfValidHits();
354  aMuon.setNumberOfValidHits( nhits );
355 
356  reco::TransientTrack tt = trackBuilder->build(innerTrack);
357  embedHighLevel( aMuon,
358  innerTrack,
359  tt,
360  primaryVertex,
361  primaryVertexIsValid,
362  beamSpot,
363  beamSpotIsValid );
364 
365  // Correct to PV, or beam spot
366  if ( !usePV_ ) {
367  double corr_d0 = -1.0 * innerTrack->dxy( beamPoint );
368  aMuon.setDB( corr_d0, -1.0 );
369  } else {
370  std::pair<bool,Measurement1D> result = IPTools::absoluteTransverseImpactParameter(tt, primaryVertex);
371  double d0_corr = result.second.value();
372  double d0_err = result.second.error();
373  aMuon.setDB( d0_corr, d0_err );
374  }
375  }
376 
377  if ( globalTrack.isNonnull() && globalTrack.isAvailable() ) {
378  double norm_chi2 = globalTrack->chi2() / globalTrack->ndof();
379  aMuon.setNormChi2( norm_chi2 );
380  }
381  }
382 
383  // embed MET muon corrections
384  if( embedCaloMETMuonCorrs_ ) aMuon.embedCaloMETMuonCorrs((*caloMETMuonCorrs)[muonRef]);
385  if( embedTcMETMuonCorrs_ ) aMuon.embedTcMETMuonCorrs((*tcMETMuonCorrs )[muonRef]);
386 
387  patMuons->push_back(aMuon);
388  }
389  }
390 
391  // sort muons in pt
392  std::sort(patMuons->begin(), patMuons->end(), pTComparator_);
393 
394  // put genEvt object in Event
395  std::auto_ptr<std::vector<Muon> > ptr(patMuons);
396  iEvent.put(ptr);
397 
399 }
400 
401 
402 void PATMuonProducer::fillMuon( Muon& aMuon, const MuonBaseRef& muonRef, const reco::CandidateBaseRef& baseRef, const GenAssociations& genMatches, const IsoDepositMaps& deposits, const IsolationValueMaps& isolationValues ) const
403 {
404  // in the particle flow algorithm,
405  // the muon momentum is recomputed.
406  // the new value is stored as the momentum of the
407  // resulting PFCandidate of type Muon, and choosen
408  // as the pat::Muon momentum
409  if (useParticleFlow_)
410  aMuon.setP4( aMuon.pfCandidateRef()->p4() );
411 
412  if (embedTrack_) aMuon.embedTrack();
415 
416  // store the match to the generated final state muons
417  if (addGenMatch_) {
418  for(size_t i = 0, n = genMatches.size(); i < n; ++i) {
419  reco::GenParticleRef genMuon = (*genMatches[i])[baseRef];
420  aMuon.addGenParticleRef(genMuon);
421  }
422  if (embedGenMatch_) aMuon.embedGenParticle();
423  }
424 
425  if (efficiencyLoader_.enabled()) {
426  efficiencyLoader_.setEfficiencies( aMuon, muonRef );
427  }
428 
429  for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
430  if (useParticleFlow_) {
431  if (deposits[j]->contains(baseRef.id()))
432  aMuon.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[baseRef]);
433  else {
434  reco::CandidatePtr source = aMuon.pfCandidateRef()->sourceCandidatePtr(0);
435  aMuon.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[source]);
436  }
437  }
438  else{
439  aMuon.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[muonRef]);
440  }
441  }
442 
443  for (size_t j = 0; j<isolationValues.size(); ++j) {
444  if (useParticleFlow_) {
445  if (isolationValues[j]->contains(baseRef.id()))
446  aMuon.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[baseRef]);
447  else {
448  reco::CandidatePtr source = aMuon.pfCandidateRef()->sourceCandidatePtr(0);
449  aMuon.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[source]);
450  }
451  }
452  else{
453  aMuon.setIsolation(isolationValueLabels_[j].first, (*isolationValues[j])[muonRef]);
454  }
455  }
456 
457  if (resolutionLoader_.enabled()) {
459  }
460 }
461 
462 // ParameterSet description for module
464 {
466  iDesc.setComment("PAT muon producer module");
467 
468  // input source
469  iDesc.add<edm::InputTag>("muonSource", edm::InputTag("no default"))->setComment("input collection");
470 
471  // embedding
472  iDesc.add<bool>("embedTrack", true)->setComment("embed external track");
473  iDesc.add<bool>("embedStandAloneMuon", true)->setComment("embed external stand-alone muon");
474  iDesc.add<bool>("embedCombinedMuon", false)->setComment("embed external combined muon");
475  iDesc.add<bool>("embedPickyMuon", false)->setComment("embed external picky muon");
476  iDesc.add<bool>("embedTpfmsMuon", false)->setComment("embed external tpfms muon");
477 
478  // embedding of MET muon corrections
479  iDesc.add<bool>("embedCaloMETMuonCorrs", true)->setComment("whether to add MET muon correction for caloMET or not");
480  iDesc.add<edm::InputTag>("caloMETMuonCorrs", edm::InputTag("muonMETValueMapProducer" , "muCorrData"))->setComment("source of MET muon corrections for caloMET");
481  iDesc.add<bool>("embedTcMETMuonCorrs", true)->setComment("whether to add MET muon correction for tcMET or not");
482  iDesc.add<edm::InputTag>("tcMETMuonCorrs", edm::InputTag("muonTCMETValueMapProducer" , "muCorrData"))->setComment("source of MET muon corrections for tcMET");
483 
484  // pf specific parameters
485  iDesc.add<edm::InputTag>("pfMuonSource", edm::InputTag("pfMuons"))->setComment("particle flow input collection");
486  iDesc.add<bool>("useParticleFlow", false)->setComment("whether to use particle flow or not");
487  iDesc.add<bool>("embedPFCandidate", false)->setComment("embed external particle flow object");
488 
489  // TeV refit
490  iDesc.ifValue( edm::ParameterDescription<bool>("addTeVRefits", true, true),
491  true >> (edm::ParameterDescription<edm::InputTag>("pickySrc", edm::InputTag(), true) and
493  )->setComment("If TeV refits are added, their sources need to be specified");
494 
495  // MC matching configurables
496  iDesc.add<bool>("addGenMatch", true)->setComment("add MC matching");
497  iDesc.add<bool>("embedGenMatch", false)->setComment("embed MC matched MC information");
498  std::vector<edm::InputTag> emptySourceVector;
499  iDesc.addNode( edm::ParameterDescription<edm::InputTag>("genParticleMatch", edm::InputTag(), true) xor
500  edm::ParameterDescription<std::vector<edm::InputTag> >("genParticleMatch", emptySourceVector, true)
501  )->setComment("input with MC match information");
502 
504 
505  // IsoDeposit configurables
506  edm::ParameterSetDescription isoDepositsPSet;
507  isoDepositsPSet.addOptional<edm::InputTag>("tracker");
508  isoDepositsPSet.addOptional<edm::InputTag>("ecal");
509  isoDepositsPSet.addOptional<edm::InputTag>("hcal");
510  isoDepositsPSet.addOptional<edm::InputTag>("particle");
511  isoDepositsPSet.addOptional<edm::InputTag>("pfChargedHadrons");
512  isoDepositsPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
513  isoDepositsPSet.addOptional<edm::InputTag>("pfPhotons");
514  isoDepositsPSet.addOptional<std::vector<edm::InputTag> >("user");
515  iDesc.addOptional("isoDeposits", isoDepositsPSet);
516 
517  // isolation values configurables
518  edm::ParameterSetDescription isolationValuesPSet;
519  isolationValuesPSet.addOptional<edm::InputTag>("tracker");
520  isolationValuesPSet.addOptional<edm::InputTag>("ecal");
521  isolationValuesPSet.addOptional<edm::InputTag>("hcal");
522  isolationValuesPSet.addOptional<edm::InputTag>("particle");
523  isolationValuesPSet.addOptional<edm::InputTag>("pfChargedHadrons");
524  isolationValuesPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
525  isolationValuesPSet.addOptional<edm::InputTag>("pfPhotons");
526  iDesc.addOptional("isolationValues", isolationValuesPSet);
527 
528  // Efficiency configurables
529  edm::ParameterSetDescription efficienciesPSet;
530  efficienciesPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
531  iDesc.add("efficiencies", efficienciesPSet);
532  iDesc.add<bool>("addEfficiencies", false);
533 
534  // Check to see if the user wants to add user data
535  edm::ParameterSetDescription userDataPSet;
537  iDesc.addOptional("userData", userDataPSet);
538 
539  edm::ParameterSetDescription isolationPSet;
540  isolationPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
541  iDesc.add("userIsolation", isolationPSet);
542 
543  iDesc.add<bool>("embedHighLevelSelection", true)->setComment("embed high level selection");
544  edm::ParameterSetDescription highLevelPSet;
545  highLevelPSet.setAllowAnything();
546  iDesc.addNode( edm::ParameterDescription<edm::InputTag>("beamLineSrc", edm::InputTag(), true)
547  )->setComment("input with high level selection");
549  )->setComment("input with high level selection");
550  iDesc.addNode( edm::ParameterDescription<bool>("usePV", bool(), true)
551  )->setComment("input with high level selection, use primary vertex (true) or beam line (false)");
552 
553  //descriptions.add("PATMuonProducer", iDesc);
554 }
555 
556 
557 void PATMuonProducer::readIsolationLabels( const edm::ParameterSet & iConfig, const char* psetName, IsolationLabels& labels)
558 {
559  labels.clear();
560 
561  if (iConfig.exists( psetName )) {
562  edm::ParameterSet depconf = iConfig.getParameter<edm::ParameterSet>(psetName);
563 
564  if (depconf.exists("tracker")) labels.push_back(std::make_pair(pat::TrackIso, depconf.getParameter<edm::InputTag>("tracker")));
565  if (depconf.exists("ecal")) labels.push_back(std::make_pair(pat::EcalIso, depconf.getParameter<edm::InputTag>("ecal")));
566  if (depconf.exists("hcal")) labels.push_back(std::make_pair(pat::HcalIso, depconf.getParameter<edm::InputTag>("hcal")));
567  if (depconf.exists("pfAllParticles")) {
568  labels.push_back(std::make_pair(pat::PfAllParticleIso, depconf.getParameter<edm::InputTag>("pfAllParticles")));
569  }
570  if (depconf.exists("pfChargedHadrons")) {
571  labels.push_back(std::make_pair(pat::PfChargedHadronIso, depconf.getParameter<edm::InputTag>("pfChargedHadrons")));
572  }
573  if (depconf.exists("pfNeutralHadrons")) {
574  labels.push_back(std::make_pair(pat::PfNeutralHadronIso, depconf.getParameter<edm::InputTag>("pfNeutralHadrons")));
575  }
576  if (depconf.exists("pfPhotons")) {
577  labels.push_back(std::make_pair(pat::PfGammaIso, depconf.getParameter<edm::InputTag>("pfPhotons")));
578  }
579  if (depconf.exists("user")) {
580  std::vector<edm::InputTag> userdeps = depconf.getParameter<std::vector<edm::InputTag> >("user");
581  std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
582  int key = UserBaseIso;
583  for ( ; it != ed; ++it, ++key) {
584  labels.push_back(std::make_pair(IsolationKeys(key), *it));
585  }
586  }
587  }
588 }
589 
590 
591 
592 // embed various impact parameters with errors
593 // embed high level selection
597  reco::Vertex & primaryVertex,
598  bool primaryVertexIsValid,
600  bool beamspotIsValid
601  )
602 {
603  // Correct to PV
604 
605  // PV2D
606  std::pair<bool,Measurement1D> result =
608  GlobalVector(innerTrack->px(),
609  innerTrack->py(),
610  innerTrack->pz()),
611  primaryVertex);
612  double d0_corr = result.second.value();
613  double d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
614  aMuon.setDB( d0_corr, d0_err, pat::Muon::PV2D);
615 
616 
617  // PV3D
618  result =
620  GlobalVector(innerTrack->px(),
621  innerTrack->py(),
622  innerTrack->pz()),
623  primaryVertex);
624  d0_corr = result.second.value();
625  d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
626  aMuon.setDB( d0_corr, d0_err, pat::Muon::PV3D);
627 
628 
629  // Correct to beam spot
630  // make a fake vertex out of beam spot
631  reco::Vertex vBeamspot(beamspot.position(), beamspot.covariance3D());
632 
633  // BS2D
634  result =
636  GlobalVector(innerTrack->px(),
637  innerTrack->py(),
638  innerTrack->pz()),
639  vBeamspot);
640  d0_corr = result.second.value();
641  d0_err = beamspotIsValid ? result.second.error() : -1.0;
642  aMuon.setDB( d0_corr, d0_err, pat::Muon::BS2D);
643 
644  // BS3D
645  result =
647  GlobalVector(innerTrack->px(),
648  innerTrack->py(),
649  innerTrack->pz()),
650  vBeamspot);
651  d0_corr = result.second.value();
652  d0_err = beamspotIsValid ? result.second.error() : -1.0;
653  aMuon.setDB( d0_corr, d0_err, pat::Muon::BS3D);
654 }
655 
657 
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:209
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
edm::InputTag pickySrc_
input tag for picky muon refit
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:180
bool contains(EventRange const &lh, EventID const &rh)
Definition: EventRange.cc:38
Covariance3DMatrix covariance3D() const
return only 3D position covariance matrix
Definition: BeamSpot.h:109
void embedPFCandidate()
embed the IsolatedPFCandidate pointed to by pfCandidateRef_
Definition: Muon.cc:260
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
edm::InputTag tpfmsSrc_
input tag for tpfms muon refit
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
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
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:278
PFCandidateCollection::const_iterator PFCandidateConstIterator
iterator
ProductID id() const
Definition: RefToBase.h:215
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:111
bool isRealData() const
Definition: EventBase.h:60
void embedPickyMuon()
embed reference to the above picky Track
Definition: Muon.cc:242
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:173
void embedCombinedMuon()
set reference to Track reconstructed in both tracked and muon detector (reimplemented from reco::Muon...
Definition: Muon.cc:219
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:228
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 isNonnull() const
Checks for non-null.
Definition: Ref.h:248
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:181
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:84
void embedGenParticle()
Definition: PATObject.h:665
void embedTrack()
set reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.cc:199
void embedTcMETMuonCorrs(const reco::MuonMETCorrectionData &t)
embed the MuonMETCorrectionData for tcMET
Definition: Muon.cc:235
void embedHighLevel(pat::Muon &aMuon, reco::TrackRef innerTrack, reco::TransientTrack &tt, reco::Vertex &primaryVertex, bool primaryVertexIsValid, reco::BeamSpot &beamspot, bool beamspotIsValid)
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
void setTpfmsMuon(const reco::TrackRef &t)
Definition: Muon.h:100
math::XYZPoint Point
point in the space
Definition: TrackBase.h:75
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool first
Definition: L1TdeRCT.cc:79
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:359
tuple labels
Definition: L1TDQM_cfg.py:62
bool failedToGet() const
Definition: HandleBase.h:80
void embedTpfmsMuon()
embed reference to the above tpfms Track
Definition: Muon.cc:251
void addGenParticleRef(const reco::GenParticleRef &ref)
Definition: PATObject.h:649
ParameterDescriptionNode * ifValue(ParameterDescription< T > const &switchParameter, std::auto_ptr< ParameterDescriptionCases< T > > cases)
edm::InputTag muonSrc_
input source
void readIsolationLabels(const edm::ParameterSet &iConfig, const char *psetName, IsolationLabels &labels)
static void fillDescription(edm::ParameterSetDescription &iDesc)
Method for documentation and validation of PSet.
const T & get() const
Definition: EventSetup.h:55
bool addTeVRefits_
add TeV track refits for the muon
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
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:34
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:196
list key
Definition: combine.py:13
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
IsolationLabels isolationValueLabels_
input source isolation value maps
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:191
bool embedCombinedMuon_
embed track of the combined fit into the muon
Analysis-level muon class.
Definition: Muon.h:47
pat::helper::KinResolutionsLoader resolutionLoader_
helper class to add resolutions to the muon
reco::MuonRef muonRef() const
Definition: PFCandidate.h:148
void setPickyMuon(const reco::TrackRef &t)
Definition: Muon.h:97
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:184
Global3DVector GlobalVector
Definition: GlobalVector.h:10
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const
Definition: MultiIsolator.h:82
double x0() const
x coordinate
Definition: BeamSpot.h:65
bool embedHighLevelSelection_
embed high level selection variables