PageRenderTime 29ms CodeModel.GetById 15ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 0ms

/ElectroWeakAnalysis/ZMuMu/plugins/ZToMuMuFilter.cc

https://github.com/aivanov-cern/cmssw
C++ | 72 lines | 61 code | 6 blank | 5 comment | 14 complexity | f58ce41944ae168b299b868cfe929d92 MD5 | raw file
 1/* \class ZToMuMuFilter
 2 *
 3 * \author Juan Alcaraz, CIEMAT
 4 *
 5 */
 6#include "FWCore/Framework/interface/EDFilter.h"
 7#include "FWCore/Utilities/interface/InputTag.h"
 8
 9class ZToMuMuFilter : public edm::EDFilter {
10public:
11  ZToMuMuFilter(const edm::ParameterSet &);
12private:
13  virtual bool filter(edm::Event&, const edm::EventSetup&) override;
14  edm::InputTag zCands_, muIso1_, muIso2_;
15  double ptMin_, etaMin_, etaMax_, massMin_, massMax_, isoMax_;
16};
17
18#include "DataFormats/Common/interface/Handle.h"
19#include "FWCore/Framework/interface/Event.h"
20#include "FWCore/ParameterSet/interface/ParameterSet.h"
21#include "DataFormats/Candidate/interface/Candidate.h"
22#include "DataFormats/Candidate/interface/CandAssociation.h"
23using namespace edm;
24using namespace std;
25using namespace reco;
26
27ZToMuMuFilter::ZToMuMuFilter( const ParameterSet & cfg ) :
28  zCands_(cfg.getParameter<InputTag>("zCands")),
29  muIso1_(cfg.getParameter<InputTag>("muonIsolations1")),
30  muIso2_(cfg.getParameter<InputTag>("muonIsolations2")),
31  ptMin_(cfg.getParameter<double>("ptMin")),
32  etaMin_(cfg.getParameter<double>("etaMin")),
33  etaMax_(cfg.getParameter<double>("etaMax")),
34  massMin_(cfg.getParameter<double>("massMin")),
35  massMax_(cfg.getParameter<double>("massMax")),
36  isoMax_(cfg.getParameter<double>("isoMax")) {
37}
38
39bool ZToMuMuFilter::filter (Event & ev, const EventSetup &) {
40  Handle<CandidateCollection> zCands;
41  ev.getByLabel(zCands_, zCands);
42  Handle<CandDoubleAssociations> muIso1;
43  ev.getByLabel(muIso1_, muIso1);
44  Handle<CandDoubleAssociations> muIso2;
45  ev.getByLabel(muIso2_, muIso2);
46  unsigned int nZ = zCands->size();
47  if (nZ == 0) return false;
48  for(unsigned int i = 0; i < nZ; ++ i) {
49    const Candidate & zCand = (*zCands)[i];
50    double zMass = zCand.mass();
51    if (zMass < massMin_ || zMass > massMax_) return false;
52    if(zCand.numberOfDaughters()!=2) return false;
53    const Candidate * dau0 = zCand.daughter(0);
54    const Candidate * dau1 = zCand.daughter(1);
55    double pt0 = dau0->pt(), pt1 = dau1->pt();
56    if (pt0 < ptMin_ || pt1 < ptMin_) return false;
57    double eta0 = dau0->eta(), eta1 = dau1->eta();
58    if(eta0 < etaMin_ || eta0 > etaMax_) return false;
59    if(eta1 < etaMin_ || eta1 > etaMax_) return false;
60    CandidateRef mu0 = dau0->masterClone().castTo<CandidateRef>();
61    CandidateRef mu1 = dau1->masterClone().castTo<CandidateRef>();
62    double iso0 = (*muIso1)[mu0];
63    double iso1 = (*muIso2)[mu1];
64    if (iso0 > isoMax_) return false;
65    if (iso1 > isoMax_) return false;
66  }
67  return true;
68}
69
70#include "FWCore/Framework/interface/MakerMacros.h"
71
72DEFINE_FWK_MODULE( ZToMuMuFilter );