CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

PatZToMuMuAnalyzer Class Reference

Module to analyze the performance of muon reconstruction on the example of Z->mumu events. More...

#include <PhysicsTools/PatExamples/plugins/PatZToMuMuAnalyzer.h>

Inheritance diagram for PatZToMuMuAnalyzer:
edm::EDAnalyzer

List of all members.

Public Types

typedef math::XYZTLorentzVector LorentzVector
typedef math::XYZVector Vector
 typedef's to simplify get functions

Public Member Functions

 PatZToMuMuAnalyzer (const edm::ParameterSet &cfg)
 default constructor
 ~PatZToMuMuAnalyzer ()
 default destructor

Private Member Functions

virtual void analyze (const edm::Event &event, const edm::EventSetup &setup)
 everything that needs to be done during the event loop
bool booked (const std::string histName) const
 check if histogram was booked
void fill (const std::string histName, double value) const
 fill histogram if it had been booked before
void fill (std::string hists, const reco::TrackRef &t1, const reco::TrackRef &t2) const
 fill a predefined set of histograms from inner outer or global tracks for first and second mu candidate
double mass (const math::XYZVector &t1, const math::XYZVector &t2) const
 calculate the mass of the Z boson from the tracker momenta by hand

Private Attributes

std::map< std::string, TH1D * > hists_
 management of 1d histograms
edm::InputTag muons_
 input for muons
double shift_

Detailed Description

Module to analyze the performance of muon reconstruction on the example of Z->mumu events.

Module to analyze the performance of muon reconstruction on the example of Z->mumu events: transverse momentum and eta of the muon candidates and the mass of the Z boson candidate are plotted from inner, outer and global tracks. The mass is recalculated by an extra finction. The difference of the outer track and the global track are plotted for the transverse momentum, eta and phi of the two muon candi- dates, for global muons as far as available. The only input parameters are:

_muons_ --> indicating the muon collection of choice. _shift_ --> indicating the relative shift of the transverse momentum for the estimate of the effect on the invariant mass.

The shift is applied to all mass calculations.

Definition at line 33 of file PatZToMuMuAnalyzer.cc.


Member Typedef Documentation

Definition at line 38 of file PatZToMuMuAnalyzer.cc.

typedef's to simplify get functions

Definition at line 37 of file PatZToMuMuAnalyzer.cc.


Constructor & Destructor Documentation

PatZToMuMuAnalyzer::PatZToMuMuAnalyzer ( const edm::ParameterSet cfg) [explicit]

default constructor

Definition at line 76 of file PatZToMuMuAnalyzer.cc.

References fileService, and hists_.

                                                                :
  muons_(cfg.getParameter< edm::InputTag >("muons")),
  shift_(cfg.getParameter< double >("shift"))
{
  edm::Service< TFileService > fileService;
  
  // mass plot around Z peak from global tracks
  hists_[ "globalMass"] = fileService->make< TH1D >( "globalMass" , "Mass_{Z} (global) (GeV)",   90,    30.,   120.);
  // eta from global tracks
  hists_[ "globalEta" ] = fileService->make< TH1D >( "globalEta"  , "#eta (global)"          ,   48,   -2.4,    2.4);
  // pt from global tracks
  hists_[ "globalPt"  ] = fileService->make< TH1D >( "globalPt"   , "p_{T} (global) (GeV)"   ,  100,     0.,   100.);
  // mass plot around Z peak from inner tracks
  hists_[ "innerMass" ] = fileService->make< TH1D >( "innerMass"  , "Mass_{Z} (inner) (GeV)" ,   90,    30.,   120.);
  // eta from inner tracks
  hists_[ "innerEta"  ] = fileService->make< TH1D >( "innerEta"   , "#eta (inner)"           ,   48,   -2.4,    2.4);
  // pt from inner tracks
  hists_[ "innerPt"   ] = fileService->make< TH1D >( "innerPt"    , "p_{T} (inner) (GeV)"    ,  100,     0.,   100.);
  // mass plot around Z peak from outer tracks
  hists_[ "outerMass" ] = fileService->make< TH1D >( "outerMass"  , "Mass_{Z} (outer) (GeV)" ,   90,    30.,   120.);
  // eta from outer tracks
  hists_[ "outerEta"  ] = fileService->make< TH1D >( "outerEta"   , "#eta (outer)"           ,   48,   -2.4,    2.4);
  // pt from outer tracks
  hists_[ "outerPt"   ] = fileService->make< TH1D >( "outerPt"    , "p_{T} (outer) (GeV)"    ,  100,     0.,   100.);
  // delta pt between global and outer track
  hists_[ "deltaPt"   ] = fileService->make< TH1D >( "deltaPt"    , "#Delta p_{T} (GeV)"     ,  100,   -20.,    20.);
  // delta eta between global and outer track
  hists_[ "deltaEta"  ] = fileService->make< TH1D >( "deltaEta"   , "#Delta #eta"            ,  100,   -0.2,    0.2);
  // delta phi between global and outer track
  hists_[ "deltaPhi"  ] = fileService->make< TH1D >( "deltaPhi"   , "#Delta #phi"            ,  100,   -0.2,    0.2);
}
PatZToMuMuAnalyzer::~PatZToMuMuAnalyzer ( ) [inline]

default destructor

Definition at line 43 of file PatZToMuMuAnalyzer.cc.

{};

Member Function Documentation

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

everything that needs to be done during the event loop

Implements edm::EDAnalyzer.

Definition at line 128 of file PatZToMuMuAnalyzer.cc.

References fill(), patZpeak::muons, and muons_.

{
  // pat candidate collection
  edm::Handle< edm::View<pat::Muon> > muons;
  event.getByLabel(muons_, muons);

  // Fill some basic muon quantities as 
  // reconstructed from inner and outer 
  // tack 
  for(edm::View<pat::Muon>::const_iterator mu1=muons->begin(); mu1!=muons->end(); ++mu1){
    for(edm::View<pat::Muon>::const_iterator mu2=muons->begin(); mu2!=muons->end(); ++mu2){
      if(mu2>mu1){ // prevent double conting
        if( mu1->charge()*mu2->charge()<0 ){ // check only muon pairs of unequal charge 
          fill(std::string("inner" ), mu1->innerTrack (), mu2->innerTrack ());
          fill(std::string("outer" ), mu1->outerTrack (), mu2->outerTrack ());
          fill(std::string("global"), mu1->globalTrack(), mu2->globalTrack());
          
          if(mu1->isGlobalMuon()){
            fill("deltaPt" , mu1->outerTrack()->pt ()-mu1->globalTrack()->pt ());
            fill("deltaEta", mu1->outerTrack()->eta()-mu1->globalTrack()->eta());
            fill("deltaPhi", mu1->outerTrack()->phi()-mu1->globalTrack()->phi());
          }
          if(mu2->isGlobalMuon()){
            fill("deltaPt" , mu2->outerTrack()->pt ()-mu2->globalTrack()->pt ());
            fill("deltaEta", mu2->outerTrack()->eta()-mu2->globalTrack()->eta());
            fill("deltaPhi", mu2->outerTrack()->phi()-mu2->globalTrack()->phi());
          }
        }
      }
    }
  }
}
bool PatZToMuMuAnalyzer::booked ( const std::string  histName) const [inline, private]

check if histogram was booked

Definition at line 52 of file PatZToMuMuAnalyzer.cc.

References hists_.

Referenced by fill().

{ return hists_.find(histName.c_str())!=hists_.end(); };
void PatZToMuMuAnalyzer::fill ( const std::string  histName,
double  value 
) const [inline, private]

fill histogram if it had been booked before

Definition at line 54 of file PatZToMuMuAnalyzer.cc.

References booked(), hists_, and edm::second().

Referenced by analyze(), and fill().

{ if(booked(histName.c_str())) hists_.find(histName.c_str())->second->Fill(value); };
void PatZToMuMuAnalyzer::fill ( std::string  hists,
const reco::TrackRef t1,
const reco::TrackRef t2 
) const [private]

fill a predefined set of histograms from inner outer or global tracks for first and second mu candidate

Definition at line 108 of file PatZToMuMuAnalyzer.cc.

References python::multivaluedict::append(), fill(), edm::Ref< C, T, F >::isAvailable(), and mass().

{
  if( t1.isAvailable() ){
    // fill pt from global track for first muon
    fill( std::string(hists).append("Pt") , t1->pt() );
    // fill pt from global track for second muon
    fill( std::string(hists).append("Eta"), t1->eta() );
  }
  if( t2.isAvailable() ){
    // fill eta from global track for first muon
    fill( std::string(hists).append("Pt") , t2->pt() );
    // fill eta from global track for second muon
    fill( std::string(hists).append("Eta"), t2->eta() );
  }
  if( t1.isAvailable() && t2.isAvailable() ){
    // fill invariant mass of the Z boson candidate
    fill( std::string(hists).append("Mass"), mass(t1->momentum(), t2->momentum()));
  }
}
double PatZToMuMuAnalyzer::mass ( const math::XYZVector t1,
const math::XYZVector t2 
) const [inline, private]

calculate the mass of the Z boson from the tracker momenta by hand

Definition at line 68 of file PatZToMuMuAnalyzer.cc.

References shift_, and mathSSE::sqrt().

Referenced by fill().

{
  return (LorentzVector(shift_*t1.x(), shift_*t1.y(), t1.z(), sqrt((0.1057*0.1057)+t1.mag2())) + LorentzVector(shift_*t2.x(), shift_*t2.y(), t2.z(), sqrt((0.1057*0.1057)+t2.mag2()))).mass();
}

Member Data Documentation

std::map< std::string, TH1D* > PatZToMuMuAnalyzer::hists_ [private]

management of 1d histograms

Definition at line 64 of file PatZToMuMuAnalyzer.cc.

Referenced by booked(), fill(), and PatZToMuMuAnalyzer().

input for muons

Definition at line 59 of file PatZToMuMuAnalyzer.cc.

Referenced by analyze().

double PatZToMuMuAnalyzer::shift_ [private]

shift in transverse momentum to determine a rough uncertainty on the Z mass estimation

Definition at line 62 of file PatZToMuMuAnalyzer.cc.

Referenced by mass().