CMS 3D CMS Logo

triggerEfficiency.cc
Go to the documentation of this file.
1 /* \class testAnalyzer
2  * author: Noli Pasquale
3  * version 0.1
4  * TriggerEfficiency module
5  *
6  */
21 #include "TH1.h"
22 #include <vector>
23 #include <string>
24 #include <iostream>
25 #include <iterator>
26 using namespace edm;
27 using namespace std;
28 using namespace reco;
29 using namespace pat;
30 
31 class testAnalyzer : public edm::EDAnalyzer {
32 public:
34 
35 private:
36  void analyze(const edm::Event& event, const edm::EventSetup& setup) override;
37  void endJob() override;
38  int SingleTrigger_, DoubleTrigger_, NoTrigger_, zmumuIncrement_;
41  string pathName_;
42  int nbinsEta_;
43  double minEta_, maxEta_;
44  int nbinsPt_;
45  double minPt_, maxPt_;
48  TH1D *h_numberTrigMuon_, *h_numberMuon_;
49  TH1D *h_numberTrigMuon_ptStudy_, *h_numberMuon_ptStudy_;
51  vector<double> vectorPt, vectorEta;
52 };
53 
55  : selectMuonToken_(consumes<vector<pat::Muon> >(pset.getParameter<InputTag>("selectMuon"))),
56  zMuMuToken_(consumes<CandidateView>(pset.getParameter<InputTag>("ZMuMu"))),
57  pathName_(pset.getParameter<string>("pathName")),
58  nbinsEta_(pset.getParameter<int>("EtaBins")),
59  minEta_(pset.getParameter<double>("minEta")),
60  maxEta_(pset.getParameter<double>("maxEta")),
61  nbinsPt_(pset.getParameter<int>("PtBins")),
62  minPt_(pset.getParameter<double>("minPt")),
63  maxPt_(pset.getParameter<double>("maxPt")),
64  nbinsEtaPt_(pset.getParameter<int>("EtaPt80Bins")) {
65  SingleTrigger_ = 0;
66  DoubleTrigger_ = 0;
67  NoTrigger_ = 0;
68  zmumuIncrement_ = 0;
70  h_pt_distribution_ = fs->make<TH1D>("PtResolution ", "Pt Resolution", 200, -4., 4.);
71  h_numberMuon_ = fs->make<TH1D>("Denominatore", "Number of Muons vs Eta", nbinsEta_, minEta_, maxEta_);
73  fs->make<TH1D>("NumeratoreTrigMuon", "Number of Triggered Muons vs Eta", nbinsEta_, minEta_, maxEta_);
74  h_numberMuon_ptStudy_ = fs->make<TH1D>("DenominatorePtStudy", "Number of Muons vs Pt", nbinsPt_, minPt_, maxPt_);
76  fs->make<TH1D>("NumeratoreTrigMuonPtStudy", "Number of Triggered Muons vs Pt", nbinsPt_, minPt_, maxPt_);
77  h_EtaDist_Pt80_ = fs->make<TH1D>("EtaDistr", "Eta distribution (Pt>80)", nbinsEtaPt_, minEta_, maxEta_);
78 }
79 
81  Handle<vector<pat::Muon> > selectMuon;
82  event.getByToken(selectMuonToken_, selectMuon);
84  event.getByToken(zMuMuToken_, zMuMu);
85  int zmumuSize = zMuMu->size();
86  if (zmumuSize > 0) {
87  for (int i = 0; i < zmumuSize; ++i) {
88  bool singleTrigFlag0 = false;
89  bool singleTrigFlag1 = false;
91  const Candidate& zMuMuCand = (*zMuMu)[i];
92  CandidateBaseRef dau0 = zMuMuCand.daughter(0)->masterClone();
93  CandidateBaseRef dau1 = zMuMuCand.daughter(1)->masterClone();
94  const pat::Muon& mu0 = dynamic_cast<const pat::Muon&>(*dau0); //cast in patMuon
95  const pat::Muon& mu1 = dynamic_cast<const pat::Muon&>(*dau1);
98  double EtaPatMu0 = mu0.eta();
99  double EtaPatMu1 = mu1.eta();
100  double PtPatMu0 = mu0.pt();
101  double PtPatMu1 = mu1.pt();
102  h_numberMuon_->Fill(EtaPatMu0);
103  h_numberMuon_->Fill(EtaPatMu1);
104  h_numberMuon_ptStudy_->Fill(PtPatMu0);
105  h_numberMuon_ptStudy_->Fill(PtPatMu1);
106  int dimTrig0 = mu0HLTMatches.size();
107  int dimTrig1 = mu1HLTMatches.size();
108  if (dimTrig0 != 0) {
109  for (int j = 0; j < dimTrig0; ++j) {
110  singleTrigFlag0 = true;
111  h_numberTrigMuon_->Fill(EtaPatMu0);
112  h_numberTrigMuon_ptStudy_->Fill(PtPatMu0);
113  double PtTrig = mu0HLTMatches[j].pt();
114  double PtDif = PtTrig - PtPatMu0;
115  h_pt_distribution_->Fill(PtDif);
116  }
117  } else {
118  if (PtPatMu0 > 80) {
119  h_EtaDist_Pt80_->Fill(EtaPatMu0);
120  vectorPt.push_back(PtPatMu0);
121  vectorEta.push_back(EtaPatMu0);
122  }
123  }
124  if (dimTrig1 != 0) {
125  for (int j = 0; j < dimTrig1; ++j) {
126  singleTrigFlag1 = true;
127  h_numberTrigMuon_->Fill(EtaPatMu1);
128  h_numberTrigMuon_ptStudy_->Fill(PtPatMu1);
129  double PtTrig = mu0HLTMatches[j].pt();
130  double PtDif = PtTrig - PtPatMu1;
131  h_pt_distribution_->Fill(PtDif);
132  }
133  } else {
134  if (PtPatMu0 > 80) {
135  h_EtaDist_Pt80_->Fill(EtaPatMu1);
136  vectorPt.push_back(PtPatMu0);
137  vectorEta.push_back(EtaPatMu0);
138  }
139  }
140 
141  if (singleTrigFlag0 && singleTrigFlag1)
142  DoubleTrigger_++;
143  if (singleTrigFlag0 && !singleTrigFlag1)
144  SingleTrigger_++;
145  if (!singleTrigFlag0 && singleTrigFlag1)
146  SingleTrigger_++;
147  if (!singleTrigFlag0 && !singleTrigFlag1)
148  NoTrigger_++;
149 
150  } //end loop on ZMuMu candidates
151  } //end check on ZMuMu
152 }
153 
155  cout << "DoubleTrigger = " << DoubleTrigger_ << " , SingleTrigger = " << SingleTrigger_
156  << " , NoTrigger = " << NoTrigger_ << " ,zmumuIncrement = " << zmumuIncrement_ << endl;
157  double OneTrig = (double)SingleTrigger_ / (double)zmumuIncrement_;
158  double DoubleTrig = (double)DoubleTrigger_ / (double)zmumuIncrement_;
159  cout << "eps^2 = " << DoubleTrig << endl;
160  cout << "2eps(1 - eps) = " << OneTrig << endl;
161  int dimVec = vectorPt.size();
162  for (int i = 0; i < dimVec; ++i)
163  cout << "Pt = " << vectorPt[i] << " ==> Eta = " << vectorEta[i] << endl;
164 }
165 
167 
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)
testAnalyzer::minEta_
double minEta_
Definition: triggerEfficiency.cc:43
Handle.h
testAnalyzer::nbinsEtaPt_
int nbinsEtaPt_
Definition: triggerEfficiency.cc:46
mps_fire.i
i
Definition: mps_fire.py:355
ZMuMuAnalysisNtupler_cff.zMuMu
zMuMu
zMuMu vector of PSet is common to all categories except zMuTrk category
Definition: ZMuMuAnalysisNtupler_cff.py:340
testAnalyzer::maxPt_
double maxPt_
Definition: triggerEfficiency.cc:45
testAnalyzer
Definition: triggerEfficiency.cc:31
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
Muon.h
gather_cfg.cout
cout
Definition: gather_cfg.py:144
EDAnalyzer.h
reco::LeafCandidate::pt
double pt() const final
transverse momentum
Definition: LeafCandidate.h:146
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
pat::Muon
Analysis-level muon class.
Definition: Muon.h:51
testAnalyzer::h_numberTrigMuon_
TH1D * h_numberTrigMuon_
Definition: triggerEfficiency.cc:48
edm::Handle
Definition: AssociativeIterator.h:50
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
testAnalyzer::nbinsEta_
int nbinsEta_
Definition: triggerEfficiency.cc:42
Muon
Definition: Muon.py:1
testAnalyzer::testAnalyzer
testAnalyzer(const edm::ParameterSet &pset)
Definition: triggerEfficiency.cc:54
CandMatchMap.h
edm::EDAnalyzer
Definition: EDAnalyzer.h:29
testAnalyzer::DoubleTrigger_
int DoubleTrigger_
Definition: triggerEfficiency.cc:38
testAnalyzer::pathName_
string pathName_
Definition: triggerEfficiency.cc:41
MakerMacros.h
testAnalyzer::h_numberMuon_
TH1D * h_numberMuon_
Definition: triggerEfficiency.cc:48
testAnalyzer::selectMuonToken_
EDGetTokenT< vector< pat::Muon > > selectMuonToken_
Definition: triggerEfficiency.cc:39
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
testAnalyzer::analyze
void analyze(const edm::Event &event, const edm::EventSetup &setup) override
Definition: triggerEfficiency.cc:80
Service.h
testAnalyzer::vectorEta
vector< double > vectorEta
Definition: triggerEfficiency.cc:51
Particle.h
testAnalyzer::vectorPt
vector< double > vectorPt
Definition: triggerEfficiency.cc:51
testAnalyzer::nbinsPt_
int nbinsPt_
Definition: triggerEfficiency.cc:44
testAnalyzer::minPt_
double minPt_
Definition: triggerEfficiency.cc:45
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TFileService.h
edm::View
Definition: CaloClusterFwd.h:14
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
reco::LeafCandidate::eta
double eta() const final
momentum pseudorapidity
Definition: LeafCandidate.h:152
testAnalyzer::zMuMuToken_
EDGetTokenT< CandidateView > zMuMuToken_
Definition: triggerEfficiency.cc:40
testAnalyzer::h_numberMuon_ptStudy_
TH1D * h_numberMuon_ptStudy_
Definition: triggerEfficiency.cc:49
edm::Service< TFileService >
createfilelist.int
int
Definition: createfilelist.py:10
pat::TriggerObjectStandAloneCollection
std::vector< TriggerObjectStandAlone > TriggerObjectStandAloneCollection
Collection of TriggerObjectStandAlone.
Definition: TriggerObjectStandAlone.h:219
pat::PATObject::triggerObjectMatchesByPath
const TriggerObjectStandAloneCollection triggerObjectMatchesByPath(const std::string &namePath, const bool pathLastFilterAccepted=false, const bool pathL3FilterAccepted=true) const
Definition: PATObject.h:682
analyze
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EventSetup
Definition: EventSetup.h:57
pat
Definition: HeavyIon.h:7
testAnalyzer::maxEta_
double maxEta_
Definition: triggerEfficiency.cc:43
InputTag.h
reco::Candidate
Definition: Candidate.h:27
std
Definition: JetResolutionObject.h:76
testAnalyzer::zmumuIncrement_
int zmumuIncrement_
Definition: triggerEfficiency.cc:38
testAnalyzer::endJob
void endJob() override
Definition: triggerEfficiency.cc:154
edm::RefToBase< Candidate >
reco::Candidate::masterClone
virtual const CandidateBaseRef & masterClone() const =0
testAnalyzer::SingleTrigger_
int SingleTrigger_
Definition: triggerEfficiency.cc:38
AssociationVector.h
Candidate.h
testAnalyzer::NoTrigger_
int NoTrigger_
Definition: triggerEfficiency.cc:38
ParameterSet.h
testAnalyzer::h_numberTrigMuon_ptStudy_
TH1D * h_numberTrigMuon_ptStudy_
Definition: triggerEfficiency.cc:49
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
testAnalyzer::h_EtaDist_Pt80_
TH1D * h_EtaDist_Pt80_
Definition: triggerEfficiency.cc:50
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
TriggerObjectStandAlone.h
edm::InputTag
Definition: InputTag.h:15
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileService.h:64
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
testAnalyzer::h_pt_distribution_
TH1D * h_pt_distribution_
Definition: triggerEfficiency.cc:47
PATObject.h