CMS 3D CMS Logo

ZMuMuEfficiency Class Reference

Inheritance diagram for ZMuMuEfficiency:

edm::EDAnalyzer

List of all members.

Public Member Functions

 ZMuMuEfficiency (const edm::ParameterSet &pset)

Private Member Functions

virtual void analyze (const edm::Event &event, const edm::EventSetup &setup)
virtual void endJob ()

Private Attributes

double etamax_
reco::CandidateRef globalMuonCandRef_
TH1D * h_etaMuonOverlappedToStandAlone_
TH1D * h_etaMuonOverlappedToTrack_
TH1D * h_etaStandAlone_
TH1D * h_etaTrack_
TH1D * h_ptMuonOverlappedToStandAlone_
TH1D * h_ptMuonOverlappedToTrack_
TH1D * h_ptStandAlone_
TH1D * h_ptTrack_
double isomax_
edm::InputTag muonIso_
edm::InputTag muonMatchMap_
edm::InputTag muons_
size_t nbinsEta_
size_t nbinsPt_
int numberOfMatchedZMuSta_
int numberOfMatchedZMuTrack_
int numberOfOverlappedStandAlone_
int numberOfOverlappedTracks_
OverlapChecker overlap_
double ptmin_
edm::InputTag standAlone_
edm::InputTag standAloneIso_
reco::CandidateRef standAloneMuonCandRef_
edm::InputTag trackIso_
reco::CandidateRef trackMuonCandRef_
edm::InputTag tracks_
double zMassMax_
double zMassMin_
edm::InputTag zMuStandAlone_
edm::InputTag zMuStandAloneMatchMap_
edm::InputTag zMuTrack_
edm::InputTag zMuTrackMatchMap_


Detailed Description

Definition at line 21 of file ZMuMuEfficiency.cc.


Constructor & Destructor Documentation

ZMuMuEfficiency::ZMuMuEfficiency ( const edm::ParameterSet pset  ) 

Definition at line 66 of file ZMuMuEfficiency.cc.

References etamax_, h_etaMuonOverlappedToStandAlone_, h_etaMuonOverlappedToTrack_, h_etaStandAlone_, h_etaTrack_, h_ptMuonOverlappedToStandAlone_, h_ptMuonOverlappedToTrack_, h_ptStandAlone_, h_ptTrack_, TFileDirectory::make(), nbinsEta_, nbinsPt_, numberOfMatchedZMuSta_, numberOfMatchedZMuTrack_, numberOfOverlappedStandAlone_, numberOfOverlappedTracks_, and ptmin_.

00066                                                          : 
00067   zMuTrack_(pset.getParameter<InputTag>("zMuTrack")), 
00068   zMuTrackMatchMap_(pset.getParameter<InputTag>("zMuTrackMatchMap")), 
00069   zMuStandAlone_(pset.getParameter<InputTag>("zMuStandAlone")), 
00070   zMuStandAloneMatchMap_(pset.getParameter<InputTag>("zMuStandAloneMatchMap")), 
00071   muons_(pset.getParameter<InputTag>("muons")), 
00072   muonMatchMap_(pset.getParameter<InputTag>("muonMatchMap")), 
00073   muonIso_(pset.getParameter<InputTag>("muonIso")), 
00074   tracks_(pset.getParameter<InputTag>("tracks")), 
00075   trackIso_(pset.getParameter<InputTag>("trackIso")), 
00076   standAlone_(pset.getParameter<InputTag>("standAlone")), 
00077   standAloneIso_(pset.getParameter<InputTag>("standAloneIso")), 
00078   zMassMin_(pset.getUntrackedParameter<double>("zMassMin")), 
00079   zMassMax_(pset.getUntrackedParameter<double>("zMassMax")), 
00080   ptmin_(pset.getUntrackedParameter<double>("ptmin")), 
00081   etamax_(pset.getUntrackedParameter<double>("etamax")),  
00082   isomax_(pset.getUntrackedParameter<double>("isomax")), 
00083   nbinsPt_(pset.getUntrackedParameter<size_t>("nbinsPt")), 
00084   nbinsEta_(pset.getUntrackedParameter<size_t>("nbinsEta")) {
00085   Service<TFileService> fs;
00086   TFileDirectory trackEffDir = fs->mkdir("TrackEfficiency");
00087   h_etaStandAlone_ = trackEffDir.make<TH1D>("StandAloneMuonEta", 
00088                                             "StandAlone #eta for Z -> #mu + standalone", 
00089                                             nbinsEta_, -etamax_, etamax_);
00090   h_etaMuonOverlappedToStandAlone_ = trackEffDir.make<TH1D>("MuonOverlappedToStandAloneEta", 
00091                                                             "Global muon overlapped to standAlone #eta for Z -> #mu + sa", 
00092                                                             nbinsEta_, -etamax_, etamax_);
00093   h_ptStandAlone_ = trackEffDir.make<TH1D>("StandAloneMuonPt", 
00094                                            "StandAlone p_{t} for Z -> #mu + standalone", 
00095                                            nbinsPt_, ptmin_, 200);
00096   h_ptMuonOverlappedToStandAlone_ = trackEffDir.make<TH1D>("MuonOverlappedToStandAlonePt", 
00097                                                            "Global muon overlapped to standAlone p_{t} for Z -> #mu + sa", 
00098                                                            nbinsPt_, ptmin_, 200);
00099   
00100   
00101   TFileDirectory standaloneEffDir = fs->mkdir("StandaloneEfficiency");
00102   h_etaTrack_ = standaloneEffDir.make<TH1D>("TrackMuonEta", 
00103                                             "Track #eta for Z -> #mu + track", 
00104                                             nbinsEta_, -etamax_, etamax_);
00105   h_etaMuonOverlappedToTrack_ = standaloneEffDir.make<TH1D>("MuonOverlappedToTrackEta", 
00106                                                             "Global muon overlapped to track #eta for Z -> #mu + tk", 
00107                                                             nbinsEta_, -etamax_, etamax_);
00108   h_ptTrack_ = standaloneEffDir.make<TH1D>("TrackMuonPt", 
00109                                            "Track p_{t} for Z -> #mu + track", 
00110                                            nbinsPt_, ptmin_, 200);
00111   h_ptMuonOverlappedToTrack_ = standaloneEffDir.make<TH1D>("MuonOverlappedToTrackPt", 
00112                                                            "Global muon overlapped to track p_{t} for Z -> #mu + tk", 
00113                                                            nbinsPt_, ptmin_, 200);
00114   
00115   numberOfMatchedZMuSta_ = 0;
00116   numberOfMatchedZMuTrack_ = 0;
00117   numberOfOverlappedStandAlone_ = 0;
00118   numberOfOverlappedTracks_ = 0;
00119 }


Member Function Documentation

void ZMuMuEfficiency::analyze ( const edm::Event event,
const edm::EventSetup setup 
) [private, virtual]

Implements edm::EDAnalyzer.

Definition at line 121 of file ZMuMuEfficiency.cc.

References edm::RefToBase< T >::castTo(), reco::Candidate::daughter(), etamax_, globalMuonCandRef_, h_etaMuonOverlappedToStandAlone_, h_etaMuonOverlappedToTrack_, h_etaStandAlone_, h_etaTrack_, h_ptMuonOverlappedToStandAlone_, h_ptMuonOverlappedToTrack_, h_ptStandAlone_, h_ptTrack_, i, edm::Ref< C, T, F >::id(), isomax_, j, reco::Particle::mass(), reco::Candidate::masterClone(), muonIso_, muonMatchMap_, muons_cfi::muons, muons_, numberOfMatchedZMuSta_, numberOfMatchedZMuTrack_, numberOfOverlappedStandAlone_, numberOfOverlappedTracks_, overlap_, ptmin_, standAlone_, standAloneIso_, standAloneMuonCandRef_, trackIso_, trackMuonCandRef_, tracks, tracks_, zMassMax_, zMassMin_, zMuStandAlone_, zMuStandAloneMatchMap_, zMuTrack_, and zMuTrackMatchMap_.

00121                                                                          {
00122   Handle<CandidateCollection> zMuTrack;  
00123   Handle<CandMatchMap> zMuTrackMatchMap; //Map of Z made by Mu + Track
00124   Handle<CandidateCollection> zMuStandAlone; 
00125   Handle<CandMatchMap> zMuStandAloneMatchMap; //Map of Z made by Mu + StandAlone
00126   Handle<CandidateCollection> muons; //Collection of Muons
00127   Handle<CandMatchMap> muonMatchMap; 
00128   Handle<IsolationCollection> muonIso; 
00129   Handle<CandidateCollection> tracks; //Collection of Tracks
00130   Handle<IsolationCollection> trackIso; 
00131   Handle<CandidateCollection> standAlone; //Collection of StandAlone
00132   Handle<IsolationCollection> standAloneIso; 
00133   
00134   event.getByLabel(zMuTrack_, zMuTrack); 
00135   event.getByLabel(zMuStandAlone_, zMuStandAlone); 
00136   event.getByLabel(muons_, muons); 
00137   event.getByLabel(tracks_, tracks); 
00138   event.getByLabel(standAlone_, standAlone); 
00139   
00140   //TRACK
00141   if (zMuStandAlone->size() > 0) {
00142     event.getByLabel(zMuStandAloneMatchMap_, zMuStandAloneMatchMap); 
00143     event.getByLabel(muonIso_, muonIso); 
00144     event.getByLabel(standAloneIso_, standAloneIso); 
00145     event.getByLabel(muonMatchMap_, muonMatchMap); 
00146     for(size_t i = 0; i < zMuStandAlone->size(); ++i) { //loop on candidates
00147       const Candidate & zMuStaCand = (*zMuStandAlone)[i]; //the candidate
00148       CandidateRef zMuStaCandRef(zMuStandAlone,i);
00149       bool isMatched = false;
00150       CandMatchMap::const_iterator zMuStaMapIt = zMuStandAloneMatchMap->find(zMuStaCandRef);
00151       if(zMuStaMapIt != zMuStandAloneMatchMap->end()) isMatched = true;
00152       CandidateRef dau0 = zMuStaCand.daughter(0)->masterClone().castTo<CandidateRef>();
00153       CandidateRef dau1 = zMuStaCand.daughter(1)->masterClone().castTo<CandidateRef>();
00154       
00155       // Cuts
00156       if((dau0->pt() > ptmin_) && (dau1->pt() > ptmin_) && 
00157          (fabs(dau0->eta()) < etamax_) && (fabs(dau1->eta()) < etamax_) && 
00158          (zMuStaCand.mass() > zMassMin_) && (zMuStaCand.mass() < zMassMax_) && 
00159          (isMatched)) {
00160         CandidateRef standAloneCandRef(standAlone,0);
00161         if(dau0.id() == standAloneCandRef.id()) {
00162           standAloneMuonCandRef_ = dau0;
00163           globalMuonCandRef_ = dau1;
00164         }
00165         if(dau1.id()== standAloneCandRef.id()) {
00166           standAloneMuonCandRef_ = dau1;
00167           globalMuonCandRef_ = dau0;
00168         }
00169         //The Z daughters are already matched!
00170         const double globalMuonIsolation = (*muonIso)[globalMuonCandRef_];
00171         const double standAloneMuonIsolation = (*standAloneIso)[standAloneMuonCandRef_];
00172         
00173         if((globalMuonIsolation < isomax_) && (standAloneMuonIsolation < isomax_)) {
00174           numberOfMatchedZMuSta_++;
00175           h_etaStandAlone_->Fill(standAloneMuonCandRef_->eta()); //Denominator eta for measuring track efficiency
00176           h_ptStandAlone_->Fill(standAloneMuonCandRef_->pt());   //Denominator pt for measuring track eff
00177           
00178           for(size_t j = 0; j < muons->size() ; ++j) {
00179             const Candidate & muCand = (*muons)[j]; 
00180             CandidateRef muCandRef(muons, j); 
00181             CandMatchMap::const_iterator muonMapIt = muonMatchMap->find(muCandRef); 
00182             if((muonMapIt != muonMatchMap->end()) && (overlap_(*standAloneMuonCandRef_, muCand))) { 
00183               h_etaMuonOverlappedToStandAlone_->Fill(standAloneMuonCandRef_->eta()); //Numerator eta
00184               h_ptMuonOverlappedToStandAlone_->Fill(standAloneMuonCandRef_->pt());   //Numerator pt
00185               numberOfOverlappedTracks_++;
00186             }
00187           }
00188         }
00189       }
00190     }
00191   } //end loop on Candidate
00192   
00193   //STANDALONE
00194   if (zMuTrack->size() > 0) {
00195     event.getByLabel(zMuTrackMatchMap_, zMuTrackMatchMap); 
00196     event.getByLabel(muonIso_, muonIso); 
00197     event.getByLabel(trackIso_, trackIso); 
00198     event.getByLabel(muonMatchMap_, muonMatchMap); 
00199     for(size_t i = 0; i < zMuTrack->size(); ++i) { //loop on candidates
00200       const Candidate & zMuTrkCand = (*zMuTrack)[i]; //the candidate
00201       CandidateRef zMuTrkCandRef(zMuTrack,i);
00202       bool isMatched = false;
00203       CandMatchMap::const_iterator zMuTrkMapIt = zMuTrackMatchMap->find(zMuTrkCandRef);
00204       if(zMuTrkMapIt != zMuTrackMatchMap->end()) isMatched = true;
00205       CandidateRef dau0 = zMuTrkCand.daughter(0)->masterClone().castTo<CandidateRef>();
00206       CandidateRef dau1 = zMuTrkCand.daughter(1)->masterClone().castTo<CandidateRef>();
00207 
00208       // Cuts
00209       if ((dau0->pt() > ptmin_) && (dau1->pt() > ptmin_) && 
00210           (fabs(dau0->eta()) < etamax_) && (fabs(dau1->eta())< etamax_) && 
00211           (zMuTrkCand.mass() > zMassMin_) && (zMuTrkCand.mass() < zMassMax_) && 
00212           (isMatched)) {
00213         CandidateRef trackCandRef(tracks,0);
00214         if(dau0.id() == trackCandRef.id()) {
00215           trackMuonCandRef_ = dau0;
00216           globalMuonCandRef_ = dau1;
00217         }
00218         if(dau1.id() == trackCandRef.id()) {
00219           trackMuonCandRef_ = dau1;
00220           globalMuonCandRef_ = dau0;
00221         }
00222         //The Z daughters are already matched!
00223         const double globalMuonIsolation = (*muonIso)[globalMuonCandRef_];
00224         const double trackMuonIsolation = (*trackIso)[trackMuonCandRef_];
00225         
00226         if((globalMuonIsolation < isomax_) && (trackMuonIsolation < isomax_)) {
00227           numberOfMatchedZMuTrack_++;
00228           h_etaTrack_->Fill(trackMuonCandRef_->eta()); //Denominator eta Sta
00229           h_ptTrack_->Fill(trackMuonCandRef_->pt());   //Denominator pt Sta
00230           
00231           for(size_t j = 0; j < muons->size() ; ++j) {
00232             const Candidate & muCand = (*muons)[j];
00233             CandidateRef muCandRef(muons, j); 
00234             CandMatchMap::const_iterator muonMapIt = muonMatchMap->find(muCandRef); 
00235             if((muonMapIt != muonMatchMap->end()) && (overlap_(*trackMuonCandRef_, muCand))) { 
00236               h_etaMuonOverlappedToTrack_->Fill(trackMuonCandRef_->eta()); //Numerator sta eta
00237               h_ptMuonOverlappedToTrack_->Fill(trackMuonCandRef_->pt());   //Numerator sta pt
00238               numberOfOverlappedStandAlone_++;
00239             }
00240           }
00241         }
00242       }
00243     }
00244   } //end loop on Candidate  
00245 } 

void ZMuMuEfficiency::endJob ( void   )  [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 248 of file ZMuMuEfficiency.cc.

References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), numberOfMatchedZMuSta_, numberOfMatchedZMuTrack_, numberOfOverlappedStandAlone_, numberOfOverlappedTracks_, and funct::sqrt().

00248                              {
00249   double efficiencySTA =(double)numberOfOverlappedStandAlone_/(double)numberOfMatchedZMuTrack_;
00250   double errorEff_STA = sqrt( efficiencySTA*(1 - efficiencySTA)/(double)numberOfMatchedZMuTrack_);
00251 
00252   double efficiencyTRACK =(double)numberOfOverlappedTracks_/(double)numberOfMatchedZMuSta_;
00253   double errorEff_TRACK = sqrt( efficiencyTRACK*(1 - efficiencyTRACK)/(double)numberOfMatchedZMuSta_);
00254 
00255   cout << "------------------------------------   Efficiency   ----------------------------- " << endl;
00256   cout << "numberOfOverlappedStandAlone = " << numberOfOverlappedStandAlone_ << endl; 
00257   cout << "numberOfMatchedZMuTrack = " << numberOfMatchedZMuTrack_ << endl; 
00258   cout << "numberOfOverlappedTracks = " << numberOfOverlappedTracks_ << endl; 
00259   cout << "numberOfMatchedZMuSta = " << numberOfMatchedZMuSta_ << endl; 
00260   cout << "Efficiency StandAlone = " << efficiencySTA << " +/- " << errorEff_STA << endl;
00261   cout << "Efficiency Track      = " << efficiencyTRACK << " +/- " << errorEff_TRACK << endl;
00262 }


Member Data Documentation

double ZMuMuEfficiency::etamax_ [private]

Definition at line 33 of file ZMuMuEfficiency.cc.

Referenced by analyze(), and ZMuMuEfficiency().

reco::CandidateRef ZMuMuEfficiency::globalMuonCandRef_ [private]

Definition at line 35 of file ZMuMuEfficiency.cc.

Referenced by analyze().

TH1D * ZMuMuEfficiency::h_etaMuonOverlappedToStandAlone_ [private]

Definition at line 39 of file ZMuMuEfficiency.cc.

Referenced by analyze(), and ZMuMuEfficiency().

TH1D * ZMuMuEfficiency::h_etaMuonOverlappedToTrack_ [private]

Definition at line 43 of file ZMuMuEfficiency.cc.

Referenced by analyze(), and ZMuMuEfficiency().

TH1D* ZMuMuEfficiency::h_etaStandAlone_ [private]

Definition at line 39 of file ZMuMuEfficiency.cc.

Referenced by analyze(), and ZMuMuEfficiency().

TH1D* ZMuMuEfficiency::h_etaTrack_ [private]

Definition at line 43 of file ZMuMuEfficiency.cc.

Referenced by analyze(), and ZMuMuEfficiency().

TH1D * ZMuMuEfficiency::h_ptMuonOverlappedToStandAlone_ [private]

Definition at line 40 of file ZMuMuEfficiency.cc.

Referenced by analyze(), and ZMuMuEfficiency().

TH1D * ZMuMuEfficiency::h_ptMuonOverlappedToTrack_ [private]

Definition at line 44 of file ZMuMuEfficiency.cc.

Referenced by analyze(), and ZMuMuEfficiency().

TH1D* ZMuMuEfficiency::h_ptStandAlone_ [private]

Definition at line 40 of file ZMuMuEfficiency.cc.

Referenced by analyze(), and ZMuMuEfficiency().

TH1D* ZMuMuEfficiency::h_ptTrack_ [private]

Definition at line 44 of file ZMuMuEfficiency.cc.

Referenced by analyze(), and ZMuMuEfficiency().

double ZMuMuEfficiency::isomax_ [private]

Definition at line 33 of file ZMuMuEfficiency.cc.

Referenced by analyze().

edm::InputTag ZMuMuEfficiency::muonIso_ [private]

Definition at line 30 of file ZMuMuEfficiency.cc.

Referenced by analyze().

edm::InputTag ZMuMuEfficiency::muonMatchMap_ [private]

Definition at line 30 of file ZMuMuEfficiency.cc.

Referenced by analyze().

edm::InputTag ZMuMuEfficiency::muons_ [private]

Definition at line 30 of file ZMuMuEfficiency.cc.

Referenced by analyze().

size_t ZMuMuEfficiency::nbinsEta_ [private]

Definition at line 34 of file ZMuMuEfficiency.cc.

Referenced by ZMuMuEfficiency().

size_t ZMuMuEfficiency::nbinsPt_ [private]

Definition at line 34 of file ZMuMuEfficiency.cc.

Referenced by ZMuMuEfficiency().

int ZMuMuEfficiency::numberOfMatchedZMuSta_ [private]

Definition at line 46 of file ZMuMuEfficiency.cc.

Referenced by analyze(), endJob(), and ZMuMuEfficiency().

int ZMuMuEfficiency::numberOfMatchedZMuTrack_ [private]

Definition at line 46 of file ZMuMuEfficiency.cc.

Referenced by analyze(), endJob(), and ZMuMuEfficiency().

int ZMuMuEfficiency::numberOfOverlappedStandAlone_ [private]

Definition at line 47 of file ZMuMuEfficiency.cc.

Referenced by analyze(), endJob(), and ZMuMuEfficiency().

int ZMuMuEfficiency::numberOfOverlappedTracks_ [private]

Definition at line 47 of file ZMuMuEfficiency.cc.

Referenced by analyze(), endJob(), and ZMuMuEfficiency().

OverlapChecker ZMuMuEfficiency::overlap_ [private]

Definition at line 36 of file ZMuMuEfficiency.cc.

Referenced by analyze().

double ZMuMuEfficiency::ptmin_ [private]

Definition at line 33 of file ZMuMuEfficiency.cc.

Referenced by analyze(), and ZMuMuEfficiency().

edm::InputTag ZMuMuEfficiency::standAlone_ [private]

Definition at line 32 of file ZMuMuEfficiency.cc.

Referenced by analyze().

edm::InputTag ZMuMuEfficiency::standAloneIso_ [private]

Definition at line 32 of file ZMuMuEfficiency.cc.

Referenced by analyze().

reco::CandidateRef ZMuMuEfficiency::standAloneMuonCandRef_ [private]

Definition at line 35 of file ZMuMuEfficiency.cc.

Referenced by analyze().

edm::InputTag ZMuMuEfficiency::trackIso_ [private]

Definition at line 31 of file ZMuMuEfficiency.cc.

Referenced by analyze().

reco::CandidateRef ZMuMuEfficiency::trackMuonCandRef_ [private]

Definition at line 35 of file ZMuMuEfficiency.cc.

Referenced by analyze().

edm::InputTag ZMuMuEfficiency::tracks_ [private]

Definition at line 31 of file ZMuMuEfficiency.cc.

Referenced by analyze().

double ZMuMuEfficiency::zMassMax_ [private]

Definition at line 33 of file ZMuMuEfficiency.cc.

Referenced by analyze().

double ZMuMuEfficiency::zMassMin_ [private]

Definition at line 33 of file ZMuMuEfficiency.cc.

Referenced by analyze().

edm::InputTag ZMuMuEfficiency::zMuStandAlone_ [private]

Definition at line 29 of file ZMuMuEfficiency.cc.

Referenced by analyze().

edm::InputTag ZMuMuEfficiency::zMuStandAloneMatchMap_ [private]

Definition at line 29 of file ZMuMuEfficiency.cc.

Referenced by analyze().

edm::InputTag ZMuMuEfficiency::zMuTrack_ [private]

Definition at line 28 of file ZMuMuEfficiency.cc.

Referenced by analyze().

edm::InputTag ZMuMuEfficiency::zMuTrackMatchMap_ [private]

Definition at line 28 of file ZMuMuEfficiency.cc.

Referenced by analyze().


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:36:09 2009 for CMSSW by  doxygen 1.5.4