CMS 3D CMS Logo

List of all members | 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::one::EDAnalyzer< edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Types

typedef math::XYZTLorentzVector LorentzVector
 
typedef math::XYZVector Vector
 typedef's to simplify get functions More...
 
- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

 PatZToMuMuAnalyzer (const edm::ParameterSet &cfg)
 default constructor More...
 
 ~PatZToMuMuAnalyzer () override
 default destructor More...
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::SharedResources >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &setup) override
 everything that needs to be done during the event loop More...
 
bool booked (const std::string histName) const
 check if histogram was booked More...
 
void fill (const std::string histName, double value) const
 fill histogram if it had been booked before More...
 
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 More...
 
double mass (const math::XYZVector &t1, const math::XYZVector &t2) const
 calculate the mass of the Z boson from the tracker momenta by hand More...
 

Private Attributes

std::map< std::string, TH1D * > hists_
 management of 1d histograms More...
 
edm::EDGetTokenT< edm::View< pat::Muon > > muonsToken_
 input for muons More...
 
double shift_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

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 32 of file PatZToMuMuAnalyzer.cc.

Member Typedef Documentation

◆ LorentzVector

Definition at line 36 of file PatZToMuMuAnalyzer.cc.

◆ Vector

typedef's to simplify get functions

Definition at line 35 of file PatZToMuMuAnalyzer.cc.

Constructor & Destructor Documentation

◆ PatZToMuMuAnalyzer()

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

default constructor

Definition at line 77 of file PatZToMuMuAnalyzer.cc.

References hists_, TFileService::kSharedResource, and TFileService::make().

78  : muonsToken_(consumes<edm::View<pat::Muon> >(cfg.getParameter<edm::InputTag>("muons"))),
79  shift_(cfg.getParameter<double>("shift")) {
80  usesResource(TFileService::kSharedResource);
81 
82  edm::Service<TFileService> fileService;
83 
84  // mass plot around Z peak from global tracks
85  hists_["globalMass"] = fileService->make<TH1D>("globalMass", "Mass_{Z} (global) (GeV)", 90, 30., 120.);
86  // eta from global tracks
87  hists_["globalEta"] = fileService->make<TH1D>("globalEta", "#eta (global)", 48, -2.4, 2.4);
88  // pt from global tracks
89  hists_["globalPt"] = fileService->make<TH1D>("globalPt", "p_{T} (global) (GeV)", 100, 0., 100.);
90  // mass plot around Z peak from inner tracks
91  hists_["innerMass"] = fileService->make<TH1D>("innerMass", "Mass_{Z} (inner) (GeV)", 90, 30., 120.);
92  // eta from inner tracks
93  hists_["innerEta"] = fileService->make<TH1D>("innerEta", "#eta (inner)", 48, -2.4, 2.4);
94  // pt from inner tracks
95  hists_["innerPt"] = fileService->make<TH1D>("innerPt", "p_{T} (inner) (GeV)", 100, 0., 100.);
96  // mass plot around Z peak from outer tracks
97  hists_["outerMass"] = fileService->make<TH1D>("outerMass", "Mass_{Z} (outer) (GeV)", 90, 30., 120.);
98  // eta from outer tracks
99  hists_["outerEta"] = fileService->make<TH1D>("outerEta", "#eta (outer)", 48, -2.4, 2.4);
100  // pt from outer tracks
101  hists_["outerPt"] = fileService->make<TH1D>("outerPt", "p_{T} (outer) (GeV)", 100, 0., 100.);
102  // delta pt between global and outer track
103  hists_["deltaPt"] = fileService->make<TH1D>("deltaPt", "#Delta p_{T} (GeV)", 100, -20., 20.);
104  // delta eta between global and outer track
105  hists_["deltaEta"] = fileService->make<TH1D>("deltaEta", "#Delta #eta", 100, -0.2, 0.2);
106  // delta phi between global and outer track
107  hists_["deltaPhi"] = fileService->make<TH1D>("deltaPhi", "#Delta #phi", 100, -0.2, 0.2);
108 }
static const std::string kSharedResource
Definition: TFileService.h:76
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::map< std::string, TH1D * > hists_
management of 1d histograms
edm::EDGetTokenT< edm::View< pat::Muon > > muonsToken_
input for muons
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64

◆ ~PatZToMuMuAnalyzer()

PatZToMuMuAnalyzer::~PatZToMuMuAnalyzer ( )
inlineoverride

default destructor

Definition at line 41 of file PatZToMuMuAnalyzer.cc.

41 {};

Member Function Documentation

◆ analyze()

void PatZToMuMuAnalyzer::analyze ( const edm::Event event,
const edm::EventSetup setup 
)
overrideprivatevirtual

everything that needs to be done during the event loop

Implements edm::one::EDAnalyzerBase.

Definition at line 129 of file PatZToMuMuAnalyzer.cc.

References fill(), PDWG_BPHSkim_cff::muons, muonsToken_, and AlCaHLTBitMon_QueryRunRegistry::string.

129  {
130  // pat candidate collection
132  event.getByToken(muonsToken_, muons);
133 
134  // Fill some basic muon quantities as
135  // reconstructed from inner and outer
136  // tack
137  for (edm::View<pat::Muon>::const_iterator mu1 = muons->begin(); mu1 != muons->end(); ++mu1) {
138  for (edm::View<pat::Muon>::const_iterator mu2 = muons->begin(); mu2 != muons->end(); ++mu2) {
139  if (mu2 > mu1) { // prevent double conting
140  if (mu1->charge() * mu2->charge() < 0) { // check only muon pairs of unequal charge
141  fill(std::string("inner"), mu1->innerTrack(), mu2->innerTrack());
142  fill(std::string("outer"), mu1->outerTrack(), mu2->outerTrack());
143  fill(std::string("global"), mu1->globalTrack(), mu2->globalTrack());
144 
145  if (mu1->isGlobalMuon()) {
146  fill("deltaPt", mu1->outerTrack()->pt() - mu1->globalTrack()->pt());
147  fill("deltaEta", mu1->outerTrack()->eta() - mu1->globalTrack()->eta());
148  fill("deltaPhi", mu1->outerTrack()->phi() - mu1->globalTrack()->phi());
149  }
150  if (mu2->isGlobalMuon()) {
151  fill("deltaPt", mu2->outerTrack()->pt() - mu2->globalTrack()->pt());
152  fill("deltaEta", mu2->outerTrack()->eta() - mu2->globalTrack()->eta());
153  fill("deltaPhi", mu2->outerTrack()->phi() - mu2->globalTrack()->phi());
154  }
155  }
156  }
157  }
158  }
159 }
void fill(const std::string histName, double value) const
fill histogram if it had been booked before
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
edm::EDGetTokenT< edm::View< pat::Muon > > muonsToken_
input for muons

◆ booked()

bool PatZToMuMuAnalyzer::booked ( const std::string  histName) const
inlineprivate

check if histogram was booked

Definition at line 50 of file PatZToMuMuAnalyzer.cc.

References hists_.

Referenced by fill().

50 { return hists_.find(histName) != hists_.end(); };
std::map< std::string, TH1D * > hists_
management of 1d histograms

◆ fill() [1/2]

void PatZToMuMuAnalyzer::fill ( const std::string  histName,
double  value 
) const
inlineprivate

fill histogram if it had been booked before

Definition at line 52 of file PatZToMuMuAnalyzer.cc.

References booked(), and hists_.

Referenced by analyze(), and fill().

52  {
53  if (booked(histName))
54  hists_.find(histName)->second->Fill(value);
55  };
Definition: value.py:1
bool booked(const std::string histName) const
check if histogram was booked
std::map< std::string, TH1D * > hists_
management of 1d histograms

◆ fill() [2/2]

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 110 of file PatZToMuMuAnalyzer.cc.

References mps_setup::append, fill(), compare::hists, mass(), AlCaHLTBitMon_QueryRunRegistry::string, RandomServiceHelper::t1, and RandomServiceHelper::t2.

110  {
111  if (t1.isAvailable()) {
112  // fill pt from global track for first muon
113  fill(std::string(hists).append("Pt"), t1->pt());
114  // fill pt from global track for second muon
115  fill(std::string(hists).append("Eta"), t1->eta());
116  }
117  if (t2.isAvailable()) {
118  // fill eta from global track for first muon
119  fill(std::string(hists).append("Pt"), t2->pt());
120  // fill eta from global track for second muon
121  fill(std::string(hists).append("Eta"), t2->eta());
122  }
123  if (t1.isAvailable() && t2.isAvailable()) {
124  // fill invariant mass of the Z boson candidate
125  fill(std::string(hists).append("Mass"), mass(t1->momentum(), t2->momentum()));
126  }
127 }
void fill(const std::string histName, double value) const
fill histogram if it had been booked before
double mass(const math::XYZVector &t1, const math::XYZVector &t2) const
calculate the mass of the Z boson from the tracker momenta by hand

◆ mass()

double PatZToMuMuAnalyzer::mass ( const math::XYZVector t1,
const math::XYZVector t2 
) const
inlineprivate

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

Definition at line 68 of file PatZToMuMuAnalyzer.cc.

References shift_, mathSSE::sqrt(), RandomServiceHelper::t1, and RandomServiceHelper::t2.

Referenced by Particle.Particle::__str__(), DiObject.DiMuon::__str__(), and fill().

68  {
69  return (LorentzVector(shift_ * t1.x(), shift_ * t1.y(), t1.z(), sqrt((0.1057 * 0.1057) + t1.mag2())) +
70  LorentzVector(shift_ * t2.x(), shift_ * t2.y(), t2.z(), sqrt((0.1057 * 0.1057) + t2.mag2())))
71  .mass();
72 }
double mass(const math::XYZVector &t1, const math::XYZVector &t2) const
calculate the mass of the Z boson from the tracker momenta by hand
T sqrt(T t)
Definition: SSEVec.h:19
math::XYZTLorentzVector LorentzVector

Member Data Documentation

◆ hists_

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

management of 1d histograms

Definition at line 65 of file PatZToMuMuAnalyzer.cc.

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

◆ muonsToken_

edm::EDGetTokenT<edm::View<pat::Muon> > PatZToMuMuAnalyzer::muonsToken_
private

input for muons

Definition at line 60 of file PatZToMuMuAnalyzer.cc.

Referenced by analyze().

◆ shift_

double PatZToMuMuAnalyzer::shift_
private

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

Definition at line 63 of file PatZToMuMuAnalyzer.cc.

Referenced by mass().