CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
ExampleMuonAnalyzer Class Reference
Inheritance diagram for ExampleMuonAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &eventSetup) override
 
void beginJob () override
 
void endJob () override
 
 ExampleMuonAnalyzer (const edm::ParameterSet &pset)
 Constructor. More...
 
 ~ExampleMuonAnalyzer () override
 Destructor. More...
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

TH1F * h4MuInvMass
 
TH1I * hChamberMatched
 
TH1F * hEHcal
 
TH1F * hMuCaloCompatibility
 
TH1I * hMuIdAlgo
 
TH1F * hMuIso03CaloComb
 
TH1F * hMuIso03SumPt
 
TH1I * hMuonType
 
TH1F * hMuSegCompatibility
 
TH1I * hNMuons
 
TH1F * hPtRec
 
TH2F * hPtReso
 
TH1F * hPtSTATKDiff
 
edm::EDGetTokenT< pat::MuonCollectiontheMuonToken
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Analyzer of the muon objects

Author
R. Bellan - CERN ricca.nosp@m.rdo..nosp@m.bella.nosp@m.n@ce.nosp@m.rn.ch

Definition at line 21 of file MuonAnalyzer.cc.

Constructor & Destructor Documentation

◆ ExampleMuonAnalyzer()

ExampleMuonAnalyzer::ExampleMuonAnalyzer ( const edm::ParameterSet pset)

Constructor.

Definition at line 66 of file MuonAnalyzer.cc.

66  {
67  theMuonToken = consumes<pat::MuonCollection>(pset.getParameter<InputTag>("MuonCollection"));
68 }

References muonDTDigis_cfi::pset.

◆ ~ExampleMuonAnalyzer()

ExampleMuonAnalyzer::~ExampleMuonAnalyzer ( )
override

Destructor.

Definition at line 71 of file MuonAnalyzer.cc.

71 {}

Member Function Documentation

◆ analyze()

void ExampleMuonAnalyzer::analyze ( const edm::Event event,
const edm::EventSetup eventSetup 
)
overridevirtual

simple selection... Do not want to write here my super-secret Higgs analysis ;-)

Implements edm::EDAnalyzer.

Definition at line 101 of file MuonAnalyzer.cc.

101  {
102  // Get the Muon collection
104  event.getByToken(theMuonToken, muons);
105 
106  // How many muons in the event?
107  hNMuons->Fill(muons->size());
108 
110 
111  // Let's look inside the muon collection.
112  for (pat::MuonCollection::const_iterator muon = muons->begin(); muon != muons->end(); ++muon) {
113  // pT spectra of muons
114  hPtRec->Fill(muon->pt());
115 
116  // what is the resolution in pt? Easy! We have the association with generated information
117  // cout<<muon->pt()<<" "<<muon->genParticle()->pt()<<endl;
118  if (muon->genLepton() != nullptr) {
119  double reso = (muon->pt() - muon->genLepton()->pt()) / muon->genLepton()->pt();
120  hPtReso->Fill(muon->genLepton()->pt(), reso);
121  }
122 
123  // What is the energy deposit in HCal?
124  if (muon->isEnergyValid())
125  hEHcal->Fill(muon->calEnergy().had);
126 
127  // Which type of muons in the collection?
128  if (muon->isStandAloneMuon())
129  if (muon->isGlobalMuon())
130  if (muon->isTrackerMuon())
131  hMuonType->Fill(1); // STA + GLB + TM
132  else
133  hMuonType->Fill(2); // STA + GLB
134  else if (muon->isTrackerMuon())
135  hMuonType->Fill(3); // STA + TM
136  else
137  hMuonType->Fill(5); // STA
138  else if (muon->isTrackerMuon())
139  hMuonType->Fill(4); // TM
140 
141  // ...mmm I want to study the relative resolution of the STA track with respect to the Tracker track.
142  // or I want to look at a track stab
143  if (muon->isGlobalMuon()) {
144  double diff = muon->innerTrack()->pt() - muon->standAloneMuon()->pt();
145  hPtSTATKDiff->Fill(diff);
146  }
147 
148  // Muon ID quantities
149 
150  // Muon in CMS are usually MIP. What is the compatibility of a muon HP using only claorimeters?
151  if (muon->isCaloCompatibilityValid())
152  hMuCaloCompatibility->Fill(muon->caloCompatibility());
153 
154  // The muon system can also be used just as only for ID. What is the compatibility of a muon HP using only calorimeters?
156 
157  // How many chambers have been associated to a muon track?
158  hChamberMatched->Fill(muon->numberOfChambers());
159  // If you look at MuonSegmentMatcher class you will see a lot of interesting quantities to look at!
160  // you can get the list of matched info using matches()
161 
162  // Muon ID selection. As described in AN-2008/098
163  if (muon::isGoodMuon(*muon, muon::All)) // dummy options - always true
164  hMuIdAlgo->Fill(0);
165  if (muon::isGoodMuon(*muon, muon::AllStandAloneMuons)) // checks isStandAloneMuon flag
166  hMuIdAlgo->Fill(1);
167  if (muon::isGoodMuon(*muon, muon::AllTrackerMuons)) // checks isTrackerMuon flag
168  hMuIdAlgo->Fill(2);
169  if (muon::isGoodMuon(*muon, muon::TrackerMuonArbitrated)) // resolve ambiguity of sharing segments
170  hMuIdAlgo->Fill(3);
171  if (muon::isGoodMuon(*muon, muon::AllArbitrated)) // all muons with the tracker muon arbitrated
172  hMuIdAlgo->Fill(4);
173  if (muon::isGoodMuon(*muon, muon::GlobalMuonPromptTight)) // global muons with tighter fit requirements
174  hMuIdAlgo->Fill(5);
175  if (muon::isGoodMuon(*muon, muon::TMLastStationLoose)) // penetration depth loose selector
176  hMuIdAlgo->Fill(6);
177  if (muon::isGoodMuon(*muon, muon::TMLastStationTight)) // penetration depth tight selector
178  hMuIdAlgo->Fill(7);
179  if (muon::isGoodMuon(*muon, muon::TM2DCompatibilityLoose)) // likelihood based loose selector
180  hMuIdAlgo->Fill(8);
181  if (muon::isGoodMuon(*muon, muon::TM2DCompatibilityTight)) // likelihood based tight selector
182  hMuIdAlgo->Fill(9);
183  if (muon::isGoodMuon(*muon, muon::TMOneStationLoose)) // require one well matched segment
184  hMuIdAlgo->Fill(10);
185  if (muon::isGoodMuon(*muon, muon::TMOneStationTight)) // require one well matched segment
186  hMuIdAlgo->Fill(11);
187  if (muon::isGoodMuon(*muon,
188  muon::TMLastStationOptimizedLowPtLoose)) // combination of TMLastStation and TMOneStation
189  hMuIdAlgo->Fill(12);
190  if (muon::isGoodMuon(*muon,
191  muon::TMLastStationOptimizedLowPtTight)) // combination of TMLastStation and TMOneStation
192  hMuIdAlgo->Fill(13);
193 
194  // Isolation variables. There are many type of isolation. You can even build your own combining the output of
195  // muon->isolationR03(). E.g.: 1.2*muon->isolationR03().emEt + 0.8*muon->isolationR03().hadEt
196  // *** WARNING *** it is just an EXAMPLE!
197  if (muon->isIsolationValid()) {
198  hMuIso03CaloComb->Fill(1.2 * muon->isolationR03().emEt + 0.8 * muon->isolationR03().hadEt);
199  hMuIso03SumPt->Fill(muon->isolationR03().sumPt);
200  }
201 
202  // OK, let see if we understood everything.
203  // Suppose we are searching for H->ZZ->4mu.
204  // In mean the 4 muons have/are:
205  // high pt (but 1 out of 4 can be at quite low pt)
206  // isolated
207  // so, we can make some requirements
208  if (muon->isolationR03().sumPt < 0.2) {
209  if (muon->isGlobalMuon() || muon::isGoodMuon(*muon, muon::TM2DCompatibilityLoose) ||
211  selectedMuons.push_back(*muon);
212  }
213  }
214 
216  if (selectedMuons.size() == 4) {
218  for (pat::MuonCollection::const_iterator muon = selectedMuons.begin(); muon != selectedMuons.end(); ++muon) {
219  p4CM = p4CM + muon->p4();
220  }
221  h4MuInvMass->Fill(p4CM.mass());
222  }
223 }

References muon::All, muon::AllArbitrated, muon::AllStandAloneMuons, muon::AllTrackerMuons, change_name::diff, muon::GlobalMuonPromptTight, muon::isGoodMuon(), HLT_FULL_cff::muon, PDWG_BPHSkim_cff::muons, muon::segmentCompatibility(), METSignificanceObjects_cfi::selectedMuons, muon::TM2DCompatibilityLoose, muon::TM2DCompatibilityTight, muon::TMLastStationLoose, muon::TMLastStationOptimizedLowPtLoose, muon::TMLastStationOptimizedLowPtTight, muon::TMLastStationTight, muon::TMOneStationLoose, muon::TMOneStationTight, and muon::TrackerMuonArbitrated.

◆ beginJob()

void ExampleMuonAnalyzer::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 73 of file MuonAnalyzer.cc.

73  {
74  // Book histograms
75  edm::Service<TFileService> fileService;
76  hPtRec = fileService->make<TH1F>("pT", "p_{T}^{rec}", 250, 0, 120);
77  hPtReso = fileService->make<TH2F>("pT_Reso", "(p_{T}^{rec}-p_{T}^{sim})/p_{T}^{sim}", 250, 0, 120, 100, -0.2, 0.2);
78  hNMuons = fileService->make<TH1I>("NMuons", "Number of muons per event", 20, 0, 20);
79 
80  hEHcal = fileService->make<TH1F>("EHCal", "Energy deposit in HCAL", 100, 0, 10);
81 
82  // ID
83  hMuonType = fileService->make<TH1I>("MuonType", "Type of Muons", 5, 1, 6);
84  hPtSTATKDiff = fileService->make<TH1F>("DiffPt_STA_TK", "p^{TK}_{T}-p^{STA}_T", 200, -50, 50);
85  hMuCaloCompatibility = fileService->make<TH1F>("CaloCompatibility", "Muon HP using Calorimeters only", 100, 0, 1);
86  hMuSegCompatibility = fileService->make<TH1F>("SegmentCompatibility", "Muon HP using segments only", 100, 0, 1);
87  hChamberMatched = fileService->make<TH1I>("NumMatchedChamber", "Number of matched chambers", 7, 0, 7);
88  hMuIdAlgo = fileService->make<TH1I>("MuonIDSelectors", "Results of muon id selectors", 13, 0, 13);
89 
90  // Isolation
91  hMuIso03SumPt = fileService->make<TH1F>("MuIso03SumPt", "Isolation #Delta(R)=0.3: SumPt", 200, 0, 10);
93  fileService->make<TH1F>("MuIso03CaloComb", "Isolation #Delta(R)=0.3: 1.2*ECAL+0.8HCAL", 200, 0, 10);
94 
95  // 4Mu invariant mass
96  h4MuInvMass = fileService->make<TH1F>("InvMass4MuSystem", "Invariant mass of the 4 muons system", 200, 0, 500);
97 }

References TFileService::make().

◆ endJob()

void ExampleMuonAnalyzer::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 99 of file MuonAnalyzer.cc.

99 {}

Member Data Documentation

◆ h4MuInvMass

TH1F* ExampleMuonAnalyzer::h4MuInvMass
private

Definition at line 59 of file MuonAnalyzer.cc.

◆ hChamberMatched

TH1I* ExampleMuonAnalyzer::hChamberMatched
private

Definition at line 52 of file MuonAnalyzer.cc.

◆ hEHcal

TH1F* ExampleMuonAnalyzer::hEHcal
private

Definition at line 44 of file MuonAnalyzer.cc.

◆ hMuCaloCompatibility

TH1F* ExampleMuonAnalyzer::hMuCaloCompatibility
private

Definition at line 50 of file MuonAnalyzer.cc.

◆ hMuIdAlgo

TH1I* ExampleMuonAnalyzer::hMuIdAlgo
private

Definition at line 53 of file MuonAnalyzer.cc.

◆ hMuIso03CaloComb

TH1F* ExampleMuonAnalyzer::hMuIso03CaloComb
private

Definition at line 57 of file MuonAnalyzer.cc.

◆ hMuIso03SumPt

TH1F* ExampleMuonAnalyzer::hMuIso03SumPt
private

Definition at line 56 of file MuonAnalyzer.cc.

◆ hMuonType

TH1I* ExampleMuonAnalyzer::hMuonType
private

Definition at line 46 of file MuonAnalyzer.cc.

◆ hMuSegCompatibility

TH1F* ExampleMuonAnalyzer::hMuSegCompatibility
private

Definition at line 51 of file MuonAnalyzer.cc.

◆ hNMuons

TH1I* ExampleMuonAnalyzer::hNMuons
private

Definition at line 41 of file MuonAnalyzer.cc.

◆ hPtRec

TH1F* ExampleMuonAnalyzer::hPtRec
private

Definition at line 42 of file MuonAnalyzer.cc.

◆ hPtReso

TH2F* ExampleMuonAnalyzer::hPtReso
private

Definition at line 43 of file MuonAnalyzer.cc.

◆ hPtSTATKDiff

TH1F* ExampleMuonAnalyzer::hPtSTATKDiff
private

Definition at line 47 of file MuonAnalyzer.cc.

◆ theMuonToken

edm::EDGetTokenT<pat::MuonCollection> ExampleMuonAnalyzer::theMuonToken
private

Definition at line 38 of file MuonAnalyzer.cc.

change_name.diff
diff
Definition: change_name.py:13
ExampleMuonAnalyzer::hEHcal
TH1F * hEHcal
Definition: MuonAnalyzer.cc:44
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
muon
Definition: MuonCocktails.h:17
muon::segmentCompatibility
float segmentCompatibility(const reco::Muon &muon, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
Definition: MuonSelectors.cc:61
ExampleMuonAnalyzer::hMuonType
TH1I * hMuonType
Definition: MuonAnalyzer.cc:46
ExampleMuonAnalyzer::h4MuInvMass
TH1F * h4MuInvMass
Definition: MuonAnalyzer.cc:59
METSignificanceObjects_cfi.selectedMuons
selectedMuons
======================================
Definition: METSignificanceObjects_cfi.py:7
muon::GlobalMuonPromptTight
Definition: MuonSelectors.h:25
muon::TMLastStationTight
Definition: MuonSelectors.h:27
muon::TrackerMuonArbitrated
Definition: MuonSelectors.h:23
ExampleMuonAnalyzer::hPtRec
TH1F * hPtRec
Definition: MuonAnalyzer.cc:42
edm::Handle
Definition: AssociativeIterator.h:50
muon::isGoodMuon
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
Definition: MuonSelectors.cc:649
ExampleMuonAnalyzer::hPtSTATKDiff
TH1F * hPtSTATKDiff
Definition: MuonAnalyzer.cc:47
HLT_FULL_cff.muon
muon
Definition: HLT_FULL_cff.py:11725
ExampleMuonAnalyzer::hMuCaloCompatibility
TH1F * hMuCaloCompatibility
Definition: MuonAnalyzer.cc:50
muon::TMLastStationOptimizedLowPtLoose
Definition: MuonSelectors.h:32
pat::MuonCollection
std::vector< Muon > MuonCollection
Definition: Muon.h:35
ExampleMuonAnalyzer::hMuIdAlgo
TH1I * hMuIdAlgo
Definition: MuonAnalyzer.cc:53
muon::TMOneStationTight
Definition: MuonSelectors.h:31
ExampleMuonAnalyzer::hMuIso03SumPt
TH1F * hMuIso03SumPt
Definition: MuonAnalyzer.cc:56
ExampleMuonAnalyzer::theMuonToken
edm::EDGetTokenT< pat::MuonCollection > theMuonToken
Definition: MuonAnalyzer.cc:38
edm::Service< TFileService >
ExampleMuonAnalyzer::hMuIso03CaloComb
TH1F * hMuIso03CaloComb
Definition: MuonAnalyzer.cc:57
muon::TMOneStationLoose
Definition: MuonSelectors.h:30
TFileService::make
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
muon::AllArbitrated
Definition: MuonSelectors.h:24
muon::TM2DCompatibilityTight
Definition: MuonSelectors.h:29
muon::All
Definition: MuonSelectors.h:19
ExampleMuonAnalyzer::hPtReso
TH2F * hPtReso
Definition: MuonAnalyzer.cc:43
muon::TMLastStationLoose
Definition: MuonSelectors.h:26
ExampleMuonAnalyzer::hChamberMatched
TH1I * hChamberMatched
Definition: MuonAnalyzer.cc:52
ExampleMuonAnalyzer::hNMuons
TH1I * hNMuons
Definition: MuonAnalyzer.cc:41
muon::TMLastStationOptimizedLowPtTight
Definition: MuonSelectors.h:33
muon::AllStandAloneMuons
Definition: MuonSelectors.h:21
ExampleMuonAnalyzer::hMuSegCompatibility
TH1F * hMuSegCompatibility
Definition: MuonAnalyzer.cc:51
reco::Candidate::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
muon::AllTrackerMuons
Definition: MuonSelectors.h:22
edm::InputTag
Definition: InputTag.h:15
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
muon::TM2DCompatibilityLoose
Definition: MuonSelectors.h:28