test
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_ ;
40  string pathName_;
41  int nbinsEta_;
42  double minEta_ , maxEta_;
43  int nbinsPt_;
44  double minPt_ , maxPt_;
47  TH1D *h_numberTrigMuon_, *h_numberMuon_ ;
48  TH1D *h_numberTrigMuon_ptStudy_, *h_numberMuon_ptStudy_ ;
50  vector<double> vectorPt , vectorEta ;
51 };
52 
54  selectMuonToken_( consumes<vector<pat::Muon> >( pset.getParameter<InputTag>( "selectMuon" ) ) ),
55  zMuMuToken_( consumes<CandidateView>( pset.getParameter<InputTag>( "ZMuMu" ) ) ),
56  pathName_( pset.getParameter<string>( "pathName" ) ),
57  nbinsEta_( pset.getParameter<int>( "EtaBins" ) ),
58  minEta_( pset.getParameter<double>( "minEta" ) ),
59  maxEta_( pset.getParameter<double>( "maxEta" ) ),
60  nbinsPt_( pset.getParameter<int>( "PtBins" ) ),
61  minPt_( pset.getParameter<double>( "minPt" ) ),
62  maxPt_( pset.getParameter<double>( "maxPt" ) ),
63  nbinsEtaPt_( pset.getParameter<int>( "EtaPt80Bins" ) ){
64  SingleTrigger_= 0;
65  DoubleTrigger_= 0;
66  NoTrigger_= 0;
69  h_pt_distribution_ = fs->make<TH1D>("PtResolution ","Pt Resolution",200,-4.,4.);
70  h_numberMuon_ = fs->make<TH1D>("Denominatore","Number of Muons vs Eta",nbinsEta_,minEta_,maxEta_);
71  h_numberTrigMuon_ = fs->make<TH1D>("NumeratoreTrigMuon","Number of Triggered Muons vs Eta",nbinsEta_ ,minEta_,maxEta_);
72  h_numberMuon_ptStudy_ = fs->make<TH1D>("DenominatorePtStudy","Number of Muons vs Pt",nbinsPt_,minPt_,maxPt_);
73  h_numberTrigMuon_ptStudy_ = fs->make<TH1D>("NumeratoreTrigMuonPtStudy","Number of Triggered Muons vs Pt",nbinsPt_,minPt_,maxPt_);
74  h_EtaDist_Pt80_ = fs->make<TH1D>("EtaDistr","Eta distribution (Pt>80)",nbinsEtaPt_,minEta_,maxEta_);
75 }
76 
78  Handle<vector<pat::Muon> > selectMuon;
79  event.getByToken(selectMuonToken_, selectMuon);
81  event.getByToken(zMuMuToken_, zMuMu);
82  int zmumuSize = zMuMu->size();
83  if(zmumuSize > 0){
84  for( int i = 0; i < zmumuSize ; ++i){
85  bool singleTrigFlag0 = false;
86  bool singleTrigFlag1 = false;
88  const Candidate & zMuMuCand = (*zMuMu)[i];
89  CandidateBaseRef dau0 = zMuMuCand.daughter(0)->masterClone();
90  CandidateBaseRef dau1 = zMuMuCand.daughter(1)->masterClone();
91  const pat::Muon& mu0 = dynamic_cast<const pat::Muon&>(*dau0);//cast in patMuon
92  const pat::Muon& mu1 = dynamic_cast<const pat::Muon&>(*dau1);
93  const pat::TriggerObjectStandAloneCollection mu0HLTMatches =
95  const pat::TriggerObjectStandAloneCollection mu1HLTMatches =
97  double EtaPatMu0 = mu0.eta();
98  double EtaPatMu1 = mu1.eta();
99  double PtPatMu0 = mu0.pt();
100  double PtPatMu1 = mu1.pt();
101  h_numberMuon_->Fill(EtaPatMu0);
102  h_numberMuon_->Fill(EtaPatMu1);
103  h_numberMuon_ptStudy_->Fill(PtPatMu0);
104  h_numberMuon_ptStudy_->Fill(PtPatMu1);
105  int dimTrig0 = mu0HLTMatches.size();
106  int dimTrig1 = mu1HLTMatches.size();
107  if(dimTrig0 !=0){
108  for(int j = 0; j < dimTrig0 ; ++j){
109  singleTrigFlag0 = true;
110  h_numberTrigMuon_->Fill(EtaPatMu0);
111  h_numberTrigMuon_ptStudy_->Fill(PtPatMu0);
112  double PtTrig = mu0HLTMatches[j].pt();
113  double PtDif = PtTrig-PtPatMu0;
114  h_pt_distribution_->Fill(PtDif);
115  }
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  }
134  else{
135  if(PtPatMu0>80) {
136  h_EtaDist_Pt80_->Fill(EtaPatMu1);
137  vectorPt.push_back(PtPatMu0);
138  vectorEta.push_back(EtaPatMu0);
139  }
140  }
141 
142  if(singleTrigFlag0 && singleTrigFlag1)DoubleTrigger_++;
143  if(singleTrigFlag0 && !singleTrigFlag1)SingleTrigger_++;
144  if(!singleTrigFlag0 && singleTrigFlag1)SingleTrigger_++;
145  if(!singleTrigFlag0 && !singleTrigFlag1)NoTrigger_++;
146 
147  }//end loop on ZMuMu candidates
148  }//end check on ZMuMu
149 
150 }
151 
153  cout<< "DoubleTrigger = " << DoubleTrigger_ << " , SingleTrigger = " << SingleTrigger_ << " , NoTrigger = "<< NoTrigger_ <<" ,zmumuIncrement = "<< zmumuIncrement_ << endl;
154  double OneTrig = (double)SingleTrigger_/(double)zmumuIncrement_;
155  double DoubleTrig = (double)DoubleTrigger_/(double)zmumuIncrement_;
156  cout<< "eps^2 = " << DoubleTrig << endl;
157  cout<< "2eps(1 - eps) = " << OneTrig << endl;
158  int dimVec =vectorPt.size();
159  for(int i = 0; i<dimVec; ++i) cout << "Pt = " << vectorPt[i] << " ==> Eta = " << vectorEta[i] << endl;
160 }
161 
163 
165 
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 float pt() const
transverse momentum
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.
EDGetTokenT< vector< pat::Muon > > selectMuonToken_
EDGetTokenT< CandidateView > zMuMuToken_
TH1D * h_numberTrigMuon_
virtual float eta() const
momentum pseudorapidity
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
TH1D * h_pt_distribution_
TH1D * h_numberTrigMuon_ptStudy_
tuple cout
Definition: gather_cfg.py:121
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