CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

MuonWithPFIsoProducer Class Reference

Inheritance diagram for MuonWithPFIsoProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 MuonWithPFIsoProducer (const edm::ParameterSet &)
 ~MuonWithPFIsoProducer ()

Private Member Functions

virtual void beginJob ()
virtual void endJob ()
virtual void produce (edm::Event &, const edm::EventSetup &) override

Private Attributes

double gammaIsoVeto_
edm::InputTag muonTag_
double neutralHadronIsoVeto_
edm::InputTag pfTag_
double trackIsoVeto_
bool usePfMuonsOnly_

Detailed Description

Definition at line 12 of file MuonWithPFIsoProducer.cc.


Constructor & Destructor Documentation

MuonWithPFIsoProducer::MuonWithPFIsoProducer ( const edm::ParameterSet pset) [explicit]

Definition at line 44 of file MuonWithPFIsoProducer.cc.

References gammaIsoVeto_, edm::ParameterSet::getUntrackedParameter(), muonTag_, neutralHadronIsoVeto_, pfTag_, trackIsoVeto_, and usePfMuonsOnly_.

                                                                        {

  // What is being produced
      produces<std::vector<reco::Muon> >();

  // Muon collection
      muonTag_ = pset.getUntrackedParameter<edm::InputTag> ("MuonTag", edm::InputTag("muons"));

  // PF candidate collection
      pfTag_ = pset.getUntrackedParameter<edm::InputTag> ("PFTag", edm::InputTag("particleFlow"));

  // Use only PF muons to get exact consistency with PfMET
      usePfMuonsOnly_ = pset.getUntrackedParameter<bool> ("UsePfMuonsOnly", false);

  // Veto cone
      trackIsoVeto_ = pset.getUntrackedParameter<double> ("TrackIsoVeto", 0.01);
      gammaIsoVeto_ = pset.getUntrackedParameter<double> ("GammaIsoVeto", 0.07);
      neutralHadronIsoVeto_ = pset.getUntrackedParameter<double> ("NeutralHadronIsoVeto", 0.1);

} 
MuonWithPFIsoProducer::~MuonWithPFIsoProducer ( )

Definition at line 66 of file MuonWithPFIsoProducer.cc.

                                             {
}

Member Function Documentation

void MuonWithPFIsoProducer::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 70 of file MuonWithPFIsoProducer.cc.

                                     {
}
void MuonWithPFIsoProducer::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 74 of file MuonWithPFIsoProducer.cc.

                                  {
}
void MuonWithPFIsoProducer::produce ( edm::Event ev,
const edm::EventSetup iSetup 
) [override, private, virtual]

Implements edm::EDProducer.

Definition at line 78 of file MuonWithPFIsoProducer.cc.

References deltaR(), reco::PFCandidate::e, reco::PFCandidate::egamma_HF, reco::MuonIsolation::emEt, reco::MuonIsolation::emVetoEt, reco::PFCandidate::gamma, gammaIsoVeto_, edm::Event::getByLabel(), reco::PFCandidate::h, reco::PFCandidate::h0, reco::PFCandidate::h_HF, reco::MuonIsolation::hadEt, reco::MuonIsolation::hadVetoEt, i, edm::Ref< C, T, F >::isNonnull(), j, RPCpg::mu, muonTag_, neutralHadronIsoVeto_, MuonAlignmentFromReference_cff::newmuons, reco::MuonIsolation::nTracks, pfTag_, edm::Event::put(), reco::Muon::setIsolation(), reco::MuonIsolation::sumPt, reco::MuonIsolation::trackerVetoPt, trackIsoVeto_, and usePfMuonsOnly_.

                                                                             {

      // Initialize pointer to new output muon collection
      std::auto_ptr<reco::MuonCollection> newmuons (new reco::MuonCollection);

      // Get Muon collection
      edm::Handle<edm::View<reco::Muon> > muonCollection;
      if (!ev.getByLabel(muonTag_, muonCollection)) {
            edm::LogError("") << ">>> Muon collection does not exist !!!";
            ev.put(newmuons);
            return;
      }

      // Get PFCandidate collection
      edm::Handle<edm::View<reco::PFCandidate> > pfCollection;
      if (!ev.getByLabel(pfTag_, pfCollection)) {
            edm::LogError("") << ">>> PFCandidate collection does not exist !!!";
            ev.put(newmuons);
            return;
      }

      // Loop over Pf candidates to find muons and collect deposits in veto, 
      // dR<0.3 and dR<0.5 cones. Interpret "track" as charged particles (e,mu,
      // chraged hadrons). Interpret "em" as photons and also as electromagnetic 
      // energy in HF. Interpret "had" as neutral hadrons and also as hadronic
      // energy in HF. Apply weights if requested at input level.
      // HO energies are not filled. Ditto for jet energies around the muon.
      unsigned int muonCollectionSize = muonCollection->size();
      unsigned int pfCollectionSize = pfCollection->size();
      for (unsigned int i=0; i<muonCollectionSize; i++) {
            edm::RefToBase<reco::Muon> mu = muonCollection->refAt(i);

            // Ask for PfMuon consistency if requested
            bool muonFound = false;

            // Starting bycloning this muon
            reco::Muon* newmu = mu->clone();
            reco::TrackRef tk = mu->innerTrack();

            // Set isolations
            reco::MuonIsolation iso03;
            reco::MuonIsolation iso05;
            // Loop on all candidates
            for (unsigned int j=0; j<pfCollectionSize; j++) {
                  edm::RefToBase<reco::PFCandidate> pf = pfCollection->refAt(j);

                  // Check the muon is in the PF collection when required
                  bool thisIsTheMuon = false;
                  if (tk.isNonnull() && pf->trackRef()==tk) {
                        thisIsTheMuon = true;
                        muonFound = true;
                  }
                         
                  // Get dR. Nothing to add if dR>0.5
                  double deltaR = Geom::deltaR(mu->momentum(),pf->momentum());
                  if (deltaR>0.5) continue;

                  // Fill "tracker" components
                  if (   pf->particleId()==reco::PFCandidate::h
                      || pf->particleId()==reco::PFCandidate::e
                      || pf->particleId()==reco::PFCandidate::mu ) {
                        if (deltaR<trackIsoVeto_ || thisIsTheMuon) {
                              iso05.trackerVetoPt += pf->pt();
                              iso03.trackerVetoPt += pf->pt();
                        } else {
                              iso05.sumPt += pf->pt();
                              iso05.nTracks++;
                              if (deltaR<0.3) {
                                    iso03.sumPt += pf->pt();
                                    iso03.nTracks++;
                              }
                        }
                  // Fill "em" components
                  } else if (   pf->particleId()==reco::PFCandidate::gamma 
                             || pf->particleId()==reco::PFCandidate::egamma_HF) {
                        if (deltaR<gammaIsoVeto_) {
                              iso05.emVetoEt += pf->pt();
                              iso03.emVetoEt += pf->pt();
                        } else {
                              iso05.emEt += pf->pt();
                              if (deltaR<0.3) iso03.emEt += pf->pt();
                        }
                  // Fill "had" components
                  } else if (   pf->particleId()==reco::PFCandidate::h0
                             || pf->particleId()==reco::PFCandidate::h_HF) {
                        if (deltaR<neutralHadronIsoVeto_) {
                              iso05.hadVetoEt += pf->pt();
                              iso03.hadVetoEt += pf->pt();
                        } else {
                              iso05.hadEt += pf->pt();
                              if (deltaR<0.3) iso03.hadEt += pf->pt();
                        }
                  }
            }

            // Do not take this muon (under explicit request) if it is not a PfMuon
            if (usePfMuonsOnly_ && (!muonFound)) continue;

            // Set this isolation information in the new muon
            newmu->setIsolation(iso03,iso05);
            
            // Add new muon to output collection
            newmuons->push_back(*newmu);

      }

      // Add output collection to event
      ev.put(newmuons);
}

Member Data Documentation

Definition at line 28 of file MuonWithPFIsoProducer.cc.

Referenced by MuonWithPFIsoProducer(), and produce().

Definition at line 22 of file MuonWithPFIsoProducer.cc.

Referenced by MuonWithPFIsoProducer(), and produce().

Definition at line 29 of file MuonWithPFIsoProducer.cc.

Referenced by MuonWithPFIsoProducer(), and produce().

Definition at line 23 of file MuonWithPFIsoProducer.cc.

Referenced by MuonWithPFIsoProducer(), and produce().

Definition at line 27 of file MuonWithPFIsoProducer.cc.

Referenced by MuonWithPFIsoProducer(), and produce().

Definition at line 25 of file MuonWithPFIsoProducer.cc.

Referenced by MuonWithPFIsoProducer(), and produce().