CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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:
33  testAnalyzer(const edm::ParameterSet& pset);
34 private:
35  virtual void analyze(const edm::Event& event, const edm::EventSetup& setup) override;
36  virtual void endJob() override;
37  int SingleTrigger_ ,DoubleTrigger_ , NoTrigger_ , zmumuIncrement_ ;
38  InputTag selectMuon_, zMuMu_ ;
39  string pathName_;
40  int nbinsEta_;
41  double minEta_ , maxEta_;
42  int nbinsPt_;
43  double minPt_ , maxPt_;
46  TH1D *h_numberTrigMuon_, *h_numberMuon_ ;
47  TH1D *h_numberTrigMuon_ptStudy_, *h_numberMuon_ptStudy_ ;
49  vector<double> vectorPt , vectorEta ;
50 };
51 
53  selectMuon_( pset.getParameter<InputTag>( "selectMuon" ) ),
54  zMuMu_( pset.getParameter<InputTag>( "ZMuMu" ) ),
55  pathName_( pset.getParameter<string>( "pathName" ) ),
56  nbinsEta_( pset.getParameter<int>( "EtaBins" ) ),
57  minEta_( pset.getParameter<double>( "minEta" ) ),
58  maxEta_( pset.getParameter<double>( "maxEta" ) ),
59  nbinsPt_( pset.getParameter<int>( "PtBins" ) ),
60  minPt_( pset.getParameter<double>( "minPt" ) ),
61  maxPt_( pset.getParameter<double>( "maxPt" ) ),
62  nbinsEtaPt_( pset.getParameter<int>( "EtaPt80Bins" ) ){
63  SingleTrigger_= 0;
64  DoubleTrigger_= 0;
65  NoTrigger_= 0;
68  h_pt_distribution_ = fs->make<TH1D>("PtResolution ","Pt Resolution",200,-4.,4.);
69  h_numberMuon_ = fs->make<TH1D>("Denominatore","Number of Muons vs Eta",nbinsEta_,minEta_,maxEta_);
70  h_numberTrigMuon_ = fs->make<TH1D>("NumeratoreTrigMuon","Number of Triggered Muons vs Eta",nbinsEta_ ,minEta_,maxEta_);
71  h_numberMuon_ptStudy_ = fs->make<TH1D>("DenominatorePtStudy","Number of Muons vs Pt",nbinsPt_,minPt_,maxPt_);
72  h_numberTrigMuon_ptStudy_ = fs->make<TH1D>("NumeratoreTrigMuonPtStudy","Number of Triggered Muons vs Pt",nbinsPt_,minPt_,maxPt_);
73  h_EtaDist_Pt80_ = fs->make<TH1D>("EtaDistr","Eta distribution (Pt>80)",nbinsEtaPt_,minEta_,maxEta_);
74 }
75 
77  Handle<vector<pat::Muon> > selectMuon;
78  event.getByLabel(selectMuon_, selectMuon);
80  event.getByLabel(zMuMu_, zMuMu);
81  int zmumuSize = zMuMu->size();
82  if(zmumuSize > 0){
83  for( int i = 0; i < zmumuSize ; ++i){
84  bool singleTrigFlag0 = false;
85  bool singleTrigFlag1 = false;
87  const Candidate & zMuMuCand = (*zMuMu)[i];
88  CandidateBaseRef dau0 = zMuMuCand.daughter(0)->masterClone();
89  CandidateBaseRef dau1 = zMuMuCand.daughter(1)->masterClone();
90  const pat::Muon& mu0 = dynamic_cast<const pat::Muon&>(*dau0);//cast in patMuon
91  const pat::Muon& mu1 = dynamic_cast<const pat::Muon&>(*dau1);
92  const pat::TriggerObjectStandAloneCollection mu0HLTMatches =
94  const pat::TriggerObjectStandAloneCollection mu1HLTMatches =
96  double EtaPatMu0 = mu0.eta();
97  double EtaPatMu1 = mu1.eta();
98  double PtPatMu0 = mu0.pt();
99  double PtPatMu1 = mu1.pt();
100  h_numberMuon_->Fill(EtaPatMu0);
101  h_numberMuon_->Fill(EtaPatMu1);
102  h_numberMuon_ptStudy_->Fill(PtPatMu0);
103  h_numberMuon_ptStudy_->Fill(PtPatMu1);
104  int dimTrig0 = mu0HLTMatches.size();
105  int dimTrig1 = mu1HLTMatches.size();
106  if(dimTrig0 !=0){
107  for(int j = 0; j < dimTrig0 ; ++j){
108  singleTrigFlag0 = true;
109  h_numberTrigMuon_->Fill(EtaPatMu0);
110  h_numberTrigMuon_ptStudy_->Fill(PtPatMu0);
111  double PtTrig = mu0HLTMatches[j].pt();
112  double PtDif = PtTrig-PtPatMu0;
113  h_pt_distribution_->Fill(PtDif);
114  }
115  }
116  else{
117  if(PtPatMu0>80) {
118  h_EtaDist_Pt80_->Fill(EtaPatMu0);
119  vectorPt.push_back(PtPatMu0);
120  vectorEta.push_back(EtaPatMu0);
121  }
122  }
123  if(dimTrig1 !=0){
124  for(int j = 0; j < dimTrig1 ; ++j){
125  singleTrigFlag1 = true;
126  h_numberTrigMuon_->Fill(EtaPatMu1);
127  h_numberTrigMuon_ptStudy_->Fill(PtPatMu1);
128  double PtTrig = mu0HLTMatches[j].pt();
129  double PtDif = PtTrig-PtPatMu1;
130  h_pt_distribution_->Fill(PtDif);
131  }
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)DoubleTrigger_++;
142  if(singleTrigFlag0 && !singleTrigFlag1)SingleTrigger_++;
143  if(!singleTrigFlag0 && singleTrigFlag1)SingleTrigger_++;
144  if(!singleTrigFlag0 && !singleTrigFlag1)NoTrigger_++;
145 
146  }//end loop on ZMuMu candidates
147  }//end check on ZMuMu
148 
149 }
150 
152  cout<< "DoubleTrigger = " << DoubleTrigger_ << " , SingleTrigger = " << SingleTrigger_ << " , NoTrigger = "<< NoTrigger_ <<" ,zmumuIncrement = "<< zmumuIncrement_ << endl;
153  double OneTrig = (double)SingleTrigger_/(double)zmumuIncrement_;
154  double DoubleTrig = (double)DoubleTrigger_/(double)zmumuIncrement_;
155  cout<< "eps^2 = " << DoubleTrig << endl;
156  cout<< "2eps(1 - eps) = " << OneTrig << endl;
157  int dimVec =vectorPt.size();
158  for(int i = 0; i<dimVec; ++i) cout << "Pt = " << vectorPt[i] << " ==> Eta = " << vectorEta[i] << endl;
159 }
160 
162 
164 
int i
Definition: DBlmapReader.cc:9
virtual void endJob() override
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
virtual void analyze(const edm::Event &event, const edm::EventSetup &setup) override
TH1D * h_numberMuon_ptStudy_
vector< double > vectorEta
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
std::vector< TriggerObjectStandAlone > TriggerObjectStandAloneCollection
Collection of TriggerObjectStandAlone.
TH1D * h_numberTrigMuon_
testAnalyzer(const edm::ParameterSet &pset)
int j
Definition: DBlmapReader.cc:9
const TriggerObjectStandAloneCollection triggerObjectMatchesByPath(const std::string &namePath, const bool pathLastFilterAccepted=false, const bool pathL3FilterAccepted=true) const
Definition: PATObject.h:596
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
TH1D * h_pt_distribution_
TH1D * h_numberTrigMuon_ptStudy_
InputTag selectMuon_
tuple cout
Definition: gather_cfg.py:121
virtual float pt() const GCC11_FINAL
transverse momentum
Analysis-level muon class.
Definition: Muon.h:50
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
tuple zMuMu
zMuMu vector of PSet is common to all categories except zMuTrk category
vector< double > vectorPt
virtual const CandidateBaseRef & masterClone() const =0