CMS 3D CMS Logo

ZToMuMuIsolationSelector.cc

Go to the documentation of this file.
00001 /* \class ZToMuMuIsolationSelector
00002  *
00003  * \author Luca Lista, INFN
00004  *
00005  */
00006 #include "FWCore/ParameterSet/interface/InputTag.h"
00007 #include "DataFormats/Candidate/interface/Candidate.h"
00008 #include "DataFormats/Common/interface/Handle.h"
00009 
00010 struct IsolatedSelector {
00011   IsolatedSelector(double cut) : cut_(cut) { }
00012   bool operator()(double i1, double i2) const {
00013     return i1 < cut_ && i2 < cut_;
00014   }
00015   double cut_;
00016 };
00017 
00018 struct NonIsolatedSelector {
00019   NonIsolatedSelector(double cut) : isolated_(cut) { }
00020   bool operator()(double i1, double i2) const {
00021     return !isolated_(i1, i2);
00022   }
00023 private:
00024   IsolatedSelector isolated_;
00025 };
00026 
00027 #include "DataFormats/Common/interface/ValueMap.h"
00028 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00029 #include "FWCore/Framework/interface/Event.h"
00030 namespace edm { class EventSetup; }
00031 
00032 typedef edm::ValueMap<float> IsolationCollection;
00033 
00034 template<typename Isolator>
00035 class ZToMuMuIsolationSelector {
00036 public:
00037   ZToMuMuIsolationSelector(const edm::ParameterSet &);
00038   bool operator()(const reco::Candidate&) const;
00039   void newEvent(const edm::Event&, const edm::EventSetup&);
00040   edm::InputTag  muIso1_, muIso2_;
00041   double isoCut_;
00042   Isolator isolator_;
00043   edm::Handle<IsolationCollection> hMuIso1_, hMuIso2_;
00044 };
00045 
00046 template<typename Isolator>
00047 ZToMuMuIsolationSelector<Isolator>::ZToMuMuIsolationSelector(const edm::ParameterSet & cfg) :
00048   muIso1_(cfg.template getParameter<edm::InputTag>("muonIsolations1")),
00049   muIso2_(cfg.template getParameter<edm::InputTag>("muonIsolations2")),
00050   isolator_(cfg.template getParameter<double>("isoCut")) {
00051 }
00052 
00053 template<typename Isolator>
00054 void ZToMuMuIsolationSelector<Isolator>::newEvent(const edm::Event& ev, const edm::EventSetup&) {
00055   ev.getByLabel(muIso1_, hMuIso1_);
00056   ev.getByLabel(muIso2_, hMuIso2_);
00057 }
00058 
00059 template<typename Isolator>
00060 bool ZToMuMuIsolationSelector<Isolator>::operator()(const reco::Candidate & z) const {
00061   if(z.numberOfDaughters()!=2) return false;
00062   const reco::Candidate * dau0 = z.daughter(0);
00063   const reco::Candidate * dau1 = z.daughter(1);
00064   reco::CandidateBaseRef mu0 = dau0->masterClone();
00065   reco::CandidateBaseRef mu1 = dau1->masterClone();
00066   double iso0 = (*hMuIso1_)[mu0];
00067   double iso1 = (*hMuIso2_)[mu1];
00068   return isolator_(iso0, iso1);
00069 }
00070 
00071 #include "PhysicsTools/UtilAlgos/interface/SingleObjectSelector.h"
00072 #include "PhysicsTools/UtilAlgos/interface/AndSelector.h"
00073 #include "PhysicsTools/UtilAlgos/interface/StringCutObjectSelector.h"
00074 
00075 #include "PhysicsTools/UtilAlgos/interface/EventSetupInitTrait.h"
00076 EVENTSETUP_STD_INIT_T1(ZToMuMuIsolationSelector);
00077 
00078 typedef SingleObjectSelector<reco::CandidateView, 
00079     AndSelector<ZToMuMuIsolationSelector<IsolatedSelector>, 
00080                 StringCutObjectSelector<reco::Candidate> 
00081     > 
00082   > ZToMuMuIsolatedSelector;
00083 
00084 typedef SingleObjectSelector<reco::CandidateView, 
00085     AndSelector<ZToMuMuIsolationSelector<NonIsolatedSelector>, 
00086                 StringCutObjectSelector<reco::Candidate> 
00087     > 
00088   > ZToMuMuNonIsolatedSelector;
00089 
00090 
00091 #include "FWCore/Framework/interface/MakerMacros.h"
00092 
00093 DEFINE_FWK_MODULE(ZToMuMuIsolatedSelector);
00094 DEFINE_FWK_MODULE(ZToMuMuNonIsolatedSelector);

Generated on Tue Jun 9 17:34:20 2009 for CMSSW by  doxygen 1.5.4