CMS 3D CMS Logo

ZGlobalVsSAIsolationAnalyzer.cc
Go to the documentation of this file.
24 #include <vector>
25 #include <string>
26 #include <iostream>
27 
28 using namespace edm;
29 using namespace std;
30 using namespace reco;
31 using namespace isodeposit;
32 
34 public:
37 
38 private:
39  void analyze(const edm::Event& event, const edm::EventSetup& setup) override;
40  void endJob() override;
42  double dRVeto;
43  double dRTrk, dREcal, dRHcal;
45  double alpha, beta;
46  double isoCut_;
47  unsigned long selGlobal_, selSA_, totGlobal_, totSA_;
48  bool isolated(const Direction& dir,
49  const pat::IsoDeposit* trkIsoDep,
50  const pat::IsoDeposit* ecalIsoDep,
51  const pat::IsoDeposit* hcalIsoDep);
52  void evaluate(const reco::Candidate* dau);
53 };
54 
56  : srcToken_(consumes<CandidateView>(cfg.getParameter<InputTag>("src"))),
57  dRVeto(cfg.getParameter<double>("veto")),
58  dRTrk(cfg.getParameter<double>("deltaRTrk")),
59  dREcal(cfg.getParameter<double>("deltaREcal")),
60  dRHcal(cfg.getParameter<double>("deltaRHcal")),
61  ptThreshold(cfg.getParameter<double>("ptThreshold")),
62  etEcalThreshold(cfg.getParameter<double>("etEcalThreshold")),
63  etHcalThreshold(cfg.getParameter<double>("etHcalThreshold")),
64  alpha(cfg.getParameter<double>("alpha")),
65  beta(cfg.getParameter<double>("beta")),
66  isoCut_(cfg.getParameter<double>("isoCut")),
67  selGlobal_(0),
68  selSA_(0),
69  totGlobal_(0),
70  totSA_(0) {}
71 
73  const pat::IsoDeposit* trkIsoDep,
74  const pat::IsoDeposit* ecalIsoDep,
75  const pat::IsoDeposit* hcalIsoDep) {
76  IsoDeposit::AbsVetos vetoTrk, vetoEcal, vetoHcal;
77  vetoTrk.push_back(new ConeVeto(dir, dRVeto));
78  vetoTrk.push_back(new ThresholdVeto(ptThreshold));
79  vetoEcal.push_back(new ConeVeto(dir, 0.));
80  vetoEcal.push_back(new ThresholdVeto(etEcalThreshold));
81  vetoHcal.push_back(new ConeVeto(dir, 0.));
82  vetoHcal.push_back(new ThresholdVeto(etHcalThreshold));
83 
84  double trkIso = trkIsoDep->sumWithin(dir, dRTrk, vetoTrk);
85  double ecalIso = ecalIsoDep->sumWithin(dir, dREcal, vetoEcal);
86  double hcalIso = hcalIsoDep->sumWithin(dir, dRHcal, vetoHcal);
87  double iso = alpha * ((0.5 * (1 + beta) * ecalIso) + (0.5 * (1 - beta) * hcalIso)) + (1 - alpha) * trkIso;
88  return iso < isoCut_;
89 }
90 
92  const pat::Muon* mu = dynamic_cast<const pat::Muon*>(&*dau->masterClone());
93  if (mu == nullptr)
94  throw Exception(errors::InvalidReference) << "Daughter is not a muon!\n";
95  const pat::IsoDeposit* trkIsoDep = mu->isoDeposit(pat::TrackIso);
96  const pat::IsoDeposit* ecalIsoDep = mu->isoDeposit(pat::EcalIso);
97  const pat::IsoDeposit* hcalIsoDep = mu->isoDeposit(pat::HcalIso);
98  // global muon
99  {
100  Direction dir = Direction(mu->eta(), mu->phi());
101  if (isolated(dir, trkIsoDep, ecalIsoDep, hcalIsoDep))
102  selGlobal_++;
103  totGlobal_++;
104  }
105  // stand-alone
106  {
108  Direction dir = Direction(sa->eta(), sa->phi());
109  if (isolated(dir, trkIsoDep, ecalIsoDep, hcalIsoDep))
110  selSA_++;
111  totSA_++;
112  }
113 }
114 
117  event.getByToken(srcToken_, dimuons);
118  for (unsigned int i = 0; i < dimuons->size(); ++i) {
119  const Candidate& zmm = (*dimuons)[i];
120  evaluate(zmm.daughter(0));
121  evaluate(zmm.daughter(1));
122  }
123 }
124 
126  cout << "Isolation efficiency report:" << endl;
127  double eff, err;
128  eff = double(selGlobal_) / double(totGlobal_);
129  err = sqrt(eff * (1. - eff) / double(totGlobal_));
130  cout << "Global: " << selGlobal_ << "/" << totGlobal_ << " = " << eff << "+/-" << err << endl;
131  eff = double(selSA_) / double(totSA_);
132  err = sqrt(eff * (1. - eff) / double(totSA_));
133  cout << "St.Al.: " << selSA_ << "/" << totSA_ << " = " << eff << "+/-" << err << endl;
134 }
135 
137 
ewkMuLumiMonitorDQM_cfi.ptThreshold
ptThreshold
Definition: ewkMuLumiMonitorDQM_cfi.py:13
reco::Candidate::daughter
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode)
zMuMuMuonUserData.dRHcal
dRHcal
Definition: zMuMuMuonUserData.py:19
mps_fire.i
i
Definition: mps_fire.py:428
pat::EcalIso
Definition: Isolation.h:11
ZGlobalVsSAIsolationAnalyzer::ptThreshold
double ptThreshold
Definition: ZGlobalVsSAIsolationAnalyzer.cc:44
GlobalTrackerMuonAlignment_cfi.isolated
isolated
Definition: GlobalTrackerMuonAlignment_cfi.py:4
IsoDepositVetos.h
edm::errors::InvalidReference
Definition: EDMException.h:39
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
ZGlobalVsSAIsolationAnalyzer::analyze
void analyze(const edm::Event &event, const edm::EventSetup &setup) override
Definition: ZGlobalVsSAIsolationAnalyzer.cc:115
ZGlobalVsSAIsolationAnalyzer::selGlobal_
unsigned long selGlobal_
Definition: ZGlobalVsSAIsolationAnalyzer.cc:47
zMuMuMuonUserData.alpha
alpha
zGenParticlesMatch = cms.InputTag(""),
Definition: zMuMuMuonUserData.py:9
edm::EDGetTokenT< CandidateView >
edm
HLT enums.
Definition: AlignableModifier.h:19
zMuMuMuonUserData.beta
beta
Definition: zMuMuMuonUserData.py:10
ZMuMuCategoriesSequences_cff.trkIso
trkIso
Definition: ZMuMuCategoriesSequences_cff.py:140
Muon.h
gather_cfg.cout
cout
Definition: gather_cfg.py:144
GenericParticle.h
ZGlobalVsSAIsolationAnalyzer::dRHcal
double dRHcal
Definition: ZGlobalVsSAIsolationAnalyzer.cc:43
reco::Candidate::get
T get() const
get a component
Definition: Candidate.h:221
EDAnalyzer.h
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
pat::Muon
Analysis-level muon class.
Definition: Muon.h:51
edm::Handle
Definition: AssociativeIterator.h:50
ZGlobalVsSAIsolationAnalyzer::endJob
void endJob() override
Definition: ZGlobalVsSAIsolationAnalyzer.cc:125
ZGlobalVsSAIsolationAnalyzer::evaluate
void evaluate(const reco::Candidate *dau)
Definition: ZGlobalVsSAIsolationAnalyzer.cc:91
IsoDepositDirection.h
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
ZGlobalVsSAIsolationAnalyzer::srcToken_
EDGetTokenT< CandidateView > srcToken_
Definition: ZGlobalVsSAIsolationAnalyzer.cc:41
edm::Ref< TrackCollection >
edm::EDAnalyzer
Definition: EDAnalyzer.h:28
GenParticle.h
CandidateFwd.h
EDMException.h
WZMuSkim_cff.dimuons
dimuons
Definition: WZMuSkim_cff.py:26
reco::isodeposit::ConeVeto
Definition: IsoDepositVetos.h:9
MakerMacros.h
reco::StandAloneMuonTag
stand alone muon component tag
Definition: RecoCandidate.h:77
Track.h
ZGlobalVsSAIsolationAnalyzer::dRTrk
double dRTrk
Definition: ZGlobalVsSAIsolationAnalyzer.cc:43
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
zMuMuMuonUserData.dREcal
dREcal
Definition: zMuMuMuonUserData.py:18
ZGlobalVsSAIsolationAnalyzer::isoCut_
double isoCut_
Definition: ZGlobalVsSAIsolationAnalyzer.cc:46
Service.h
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
zMuMuMuonUserData.dRTrk
dRTrk
Definition: zMuMuMuonUserData.py:17
reco::IsoDeposit::AbsVetos
isodeposit::AbsVetos AbsVetos
Definition: IsoDeposit.h:53
Particle.h
ZGlobalVsSAIsolationAnalyzer::ZGlobalVsSAIsolationAnalyzer
ZGlobalVsSAIsolationAnalyzer(const edm::ParameterSet &cfg)
Definition: ZGlobalVsSAIsolationAnalyzer.cc:55
Isolation.h
ZGlobalVsSAIsolationAnalyzer::dRVeto
double dRVeto
Definition: ZGlobalVsSAIsolationAnalyzer.cc:42
ZGlobalVsSAIsolationAnalyzer::dREcal
double dREcal
Definition: ZGlobalVsSAIsolationAnalyzer.cc:43
IsoDeposit.h
reco::TrackRef
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
TFileService.h
edm::View
Definition: CaloClusterFwd.h:14
ZGlobalVsSAIsolationAnalyzer::Vector
math::XYZVector Vector
Definition: ZGlobalVsSAIsolationAnalyzer.cc:35
edm::ParameterSet
Definition: ParameterSet.h:47
ZGlobalVsSAIsolationAnalyzer
Definition: ZGlobalVsSAIsolationAnalyzer.cc:33
Event.h
deltaR.h
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
pat::TrackIso
Definition: Isolation.h:10
reco::IsoDeposit::sumWithin
double sumWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:137
pat::HcalIso
Definition: Isolation.h:12
zMuMuMuonUserData.etEcalThreshold
etEcalThreshold
Definition: zMuMuMuonUserData.py:14
analyze
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EventSetup
Definition: EventSetup.h:57
submitPVResolutionJobs.err
err
Definition: submitPVResolutionJobs.py:85
InputTag.h
reco::isodeposit::ThresholdVeto
Definition: IsoDepositVetos.h:21
looper.cfg
cfg
Definition: looper.py:297
reco::Candidate
Definition: Candidate.h:27
ValueMap.h
ZGlobalVsSAIsolationAnalyzer::isolated
bool isolated(const Direction &dir, const pat::IsoDeposit *trkIsoDep, const pat::IsoDeposit *ecalIsoDep, const pat::IsoDeposit *hcalIsoDep)
Definition: ZGlobalVsSAIsolationAnalyzer.cc:72
std
Definition: JetResolutionObject.h:76
ZGlobalVsSAIsolationAnalyzer::selSA_
unsigned long selSA_
Definition: ZGlobalVsSAIsolationAnalyzer.cc:47
ZGlobalVsSAIsolationAnalyzer::beta
double beta
Definition: ZGlobalVsSAIsolationAnalyzer.cc:45
reco::isodeposit::Direction
Definition: IsoDepositDirection.h:19
Exception
Definition: hltDiff.cc:246
EventSetup.h
reco::IsoDeposit
Definition: IsoDeposit.h:49
reco::Candidate::masterClone
virtual const CandidateBaseRef & masterClone() const =0
AssociationVector.h
ZGlobalVsSAIsolationAnalyzer::totGlobal_
unsigned long totGlobal_
Definition: ZGlobalVsSAIsolationAnalyzer.cc:47
Candidate.h
IsoDepositFwd.h
ZGlobalVsSAIsolationAnalyzer::etEcalThreshold
double etEcalThreshold
Definition: ZGlobalVsSAIsolationAnalyzer.cc:44
ParameterSet.h
ZGlobalVsSAIsolationAnalyzer::totSA_
unsigned long totSA_
Definition: ZGlobalVsSAIsolationAnalyzer.cc:47
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
ZGlobalVsSAIsolationAnalyzer::etHcalThreshold
double etHcalThreshold
Definition: ZGlobalVsSAIsolationAnalyzer.cc:44
edm::InputTag
Definition: InputTag.h:15
zMuMuMuonUserData.etHcalThreshold
etHcalThreshold
Definition: zMuMuMuonUserData.py:15
ZGlobalVsSAIsolationAnalyzer::alpha
double alpha
Definition: ZGlobalVsSAIsolationAnalyzer.cc:45
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23