CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
ExampleMuonAnalyzer Class Reference

#include <MuonAnalyzer.h>

Inheritance diagram for ExampleMuonAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &eventSetup)
 
virtual void beginJob ()
 
virtual void endJob ()
 
 ExampleMuonAnalyzer (const edm::ParameterSet &pset)
 Constructor. More...
 
virtual ~ExampleMuonAnalyzer ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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::MuonCollection
theMuonToken
 

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 &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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 ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
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)
 

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 25 of file MuonAnalyzer.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 28 of file MuonAnalyzer.cc.

References edm::ParameterSet::getParameter().

28  {
29 
30  theMuonToken = consumes<pat::MuonCollection>(pset.getParameter<InputTag>("MuonCollection"));
31 }
T getParameter(std::string const &) const
edm::EDGetTokenT< pat::MuonCollection > theMuonToken
Definition: MuonAnalyzer.h:42
ExampleMuonAnalyzer::~ExampleMuonAnalyzer ( )
virtual

Destructor.

Definition at line 34 of file MuonAnalyzer.cc.

34  {
35 }

Member Function Documentation

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

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

Implements edm::EDAnalyzer.

Definition at line 68 of file MuonAnalyzer.cc.

References muon::All, muon::AllArbitrated, muon::AllStandAloneMuons, muon::AllTrackerMuons, diffTreeTool::diff, muon::GlobalMuonPromptTight, muon::isGoodMuon(), metsig::muon, patZpeak::muons, muon::segmentCompatibility(), WZElectronSkims53X_cff::selectedMuons, muon::TM2DCompatibilityLoose, muon::TM2DCompatibilityTight, muon::TMLastStationLoose, muon::TMLastStationOptimizedLowPtLoose, muon::TMLastStationOptimizedLowPtTight, muon::TMLastStationTight, muon::TMOneStationLoose, muon::TMOneStationTight, and muon::TrackerMuonArbitrated.

68  {
69 
70  // Get the Muon collection
72  event.getByToken(theMuonToken, muons);
73 
74  // How many muons in the event?
75  hNMuons->Fill(muons->size());
76 
78 
79 
80  // Let's look inside the muon collection.
81  for (pat::MuonCollection::const_iterator muon = muons->begin(); muon != muons->end(); ++muon){
82 
83  // pT spectra of muons
84  hPtRec->Fill(muon->pt());
85 
86  // what is the resolution in pt? Easy! We have the association with generated information
87  // cout<<muon->pt()<<" "<<muon->genParticle()->pt()<<endl;
88  if( muon->genLepton()!=0){
89  double reso = (muon->pt() - muon->genLepton()->pt())/muon->genLepton()->pt();
90  hPtReso->Fill(muon->genLepton()->pt(),reso);
91  }
92 
93  // What is the energy deposit in HCal?
94  if(muon->isEnergyValid())
95  hEHcal->Fill(muon->calEnergy().had);
96 
97  // Which type of muons in the collection?
98  if(muon->isStandAloneMuon())
99  if(muon->isGlobalMuon())
100  if(muon->isTrackerMuon()) hMuonType->Fill(1); // STA + GLB + TM
101  else hMuonType->Fill(2); // STA + GLB
102  else
103  if(muon->isTrackerMuon()) hMuonType->Fill(3); // STA + TM
104  else hMuonType->Fill(5); // STA
105  else
106  if(muon->isTrackerMuon()) hMuonType->Fill(4); // TM
107 
108  // ...mmm I want to study the relative resolution of the STA track with respect to the Tracker track.
109  // or I want to look at a track stab
110  if(muon->isGlobalMuon()){
111  double diff = muon->innerTrack()->pt() - muon->standAloneMuon()->pt();
112  hPtSTATKDiff->Fill(diff);
113  }
114 
115  // Muon ID quantities
116 
117  // Muon in CMS are usually MIP. What is the compatibility of a muon HP using only claorimeters?
118  if(muon->isCaloCompatibilityValid())
119  hMuCaloCompatibility->Fill(muon->caloCompatibility());
120 
121  // The muon system can also be used just as only for ID. What is the compatibility of a muon HP using only calorimeters?
123 
124 
125  // How many chambers have been associated to a muon track?
126  hChamberMatched->Fill(muon->numberOfChambers());
127  // If you look at MuonSegmentMatcher class you will see a lot of interesting quantities to look at!
128  // you can get the list of matched info using matches()
129 
130 
131  // Muon ID selection. As described in AN-2008/098
132  if(muon::isGoodMuon(*muon, muon::All)) // dummy options - always true
133  hMuIdAlgo->Fill(0);
134  if(muon::isGoodMuon(*muon, muon::AllStandAloneMuons)) // checks isStandAloneMuon flag
135  hMuIdAlgo->Fill(1);
136  if(muon::isGoodMuon(*muon, muon::AllTrackerMuons)) // checks isTrackerMuon flag
137  hMuIdAlgo->Fill(2);
138  if(muon::isGoodMuon(*muon, muon::TrackerMuonArbitrated)) // resolve ambiguity of sharing segments
139  hMuIdAlgo->Fill(3);
140  if(muon::isGoodMuon(*muon, muon::AllArbitrated)) // all muons with the tracker muon arbitrated
141  hMuIdAlgo->Fill(4);
142  if(muon::isGoodMuon(*muon, muon::GlobalMuonPromptTight)) // global muons with tighter fit requirements
143  hMuIdAlgo->Fill(5);
144  if(muon::isGoodMuon(*muon, muon::TMLastStationLoose)) // penetration depth loose selector
145  hMuIdAlgo->Fill(6);
146  if(muon::isGoodMuon(*muon, muon::TMLastStationTight)) // penetration depth tight selector
147  hMuIdAlgo->Fill(7);
148  if(muon::isGoodMuon(*muon, muon::TM2DCompatibilityLoose)) // likelihood based loose selector
149  hMuIdAlgo->Fill(8);
150  if(muon::isGoodMuon(*muon, muon::TM2DCompatibilityTight)) // likelihood based tight selector
151  hMuIdAlgo->Fill(9);
152  if(muon::isGoodMuon(*muon, muon::TMOneStationLoose)) // require one well matched segment
153  hMuIdAlgo->Fill(10);
154  if(muon::isGoodMuon(*muon, muon::TMOneStationTight)) // require one well matched segment
155  hMuIdAlgo->Fill(11);
156  if(muon::isGoodMuon(*muon, muon::TMLastStationOptimizedLowPtLoose)) // combination of TMLastStation and TMOneStation
157  hMuIdAlgo->Fill(12);
158  if(muon::isGoodMuon(*muon, muon::TMLastStationOptimizedLowPtTight)) // combination of TMLastStation and TMOneStation
159  hMuIdAlgo->Fill(13);
160 
161 
162 
163  // Isolation variables. There are many type of isolation. You can even build your own combining the output of
164  // muon->isolationR03(). E.g.: 1.2*muon->isolationR03().emEt + 0.8*muon->isolationR03().hadEt
165  // *** WARNING *** it is just an EXAMPLE!
166  if(muon->isIsolationValid()){
167  hMuIso03CaloComb->Fill(1.2*muon->isolationR03().emEt + 0.8*muon->isolationR03().hadEt);
168  hMuIso03SumPt->Fill(muon->isolationR03().sumPt);
169  }
170 
171  // OK, let see if we understood everything.
172  // Suppose we are searching for H->ZZ->4mu.
173  // In mean the 4 muons have/are:
174  // high pt (but 1 out of 4 can be at quite low pt)
175  // isolated
176  // so, we can make some requirements
177  if(muon->isolationR03().sumPt< 0.2){
178  if(muon->isGlobalMuon() ||
181  selectedMuons.push_back(*muon);
182  }
183  }
184 
186  if(selectedMuons.size() == 4){
188  for (pat::MuonCollection::const_iterator muon = selectedMuons.begin(); muon != selectedMuons.end(); ++muon){
189  p4CM = p4CM + muon->p4();
190  }
191  h4MuInvMass->Fill(p4CM.mass());
192  }
193 }
TH1F * hMuSegCompatibility
Definition: MuonAnalyzer.h:55
TH1F * hMuCaloCompatibility
Definition: MuonAnalyzer.h:54
float segmentCompatibility(const reco::Muon &muon, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
std::vector< Muon > MuonCollection
Definition: Muon.h:33
tuple muons
Definition: patZpeak.py:38
edm::EDGetTokenT< pat::MuonCollection > theMuonToken
Definition: MuonAnalyzer.h:42
void ExampleMuonAnalyzer::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 37 of file MuonAnalyzer.cc.

References fileService, and TFileService::make().

37  {
38 
39  // Book histograms
41  hPtRec = fileService->make<TH1F>("pT","p_{T}^{rec}",250,0,120);
42  hPtReso = fileService->make<TH2F>("pT_Reso","(p_{T}^{rec}-p_{T}^{sim})/p_{T}^{sim}",250,0,120,100,-0.2,0.2);
43  hNMuons = fileService->make<TH1I>("NMuons","Number of muons per event",20,0,20);
44 
45  hEHcal = fileService->make<TH1F>("EHCal","Energy deposit in HCAL",100,0,10);
46 
47  // ID
48  hMuonType = fileService->make<TH1I>("MuonType", "Type of Muons", 5, 1, 6);
49  hPtSTATKDiff = fileService->make<TH1F>("DiffPt_STA_TK","p^{TK}_{T}-p^{STA}_T",200,-50,50);
50  hMuCaloCompatibility = fileService->make<TH1F>("CaloCompatibility","Muon HP using Calorimeters only",100,0,1);
51  hMuSegCompatibility = fileService->make<TH1F>("SegmentCompatibility","Muon HP using segments only",100,0,1);
52  hChamberMatched = fileService->make<TH1I>("NumMatchedChamber", "Number of matched chambers", 7, 0, 7);
53  hMuIdAlgo = fileService->make<TH1I>("MuonIDSelectors", "Results of muon id selectors", 13, 0, 13);
54 
55  // Isolation
56  hMuIso03SumPt = fileService->make<TH1F>("MuIso03SumPt","Isolation #Delta(R)=0.3: SumPt",200,0,10);
57  hMuIso03CaloComb = fileService->make<TH1F>("MuIso03CaloComb","Isolation #Delta(R)=0.3: 1.2*ECAL+0.8HCAL",200,0,10);
58 
59  // 4Mu invariant mass
60  h4MuInvMass = fileService->make<TH1F>("InvMass4MuSystem","Invariant mass of the 4 muons system",200,0,500);
61 
62 }
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
TH1F * hMuSegCompatibility
Definition: MuonAnalyzer.h:55
TH1F * hMuCaloCompatibility
Definition: MuonAnalyzer.h:54
edm::Service< TFileService > fileService
void ExampleMuonAnalyzer::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 64 of file MuonAnalyzer.cc.

64  {
65 }

Member Data Documentation

TH1F* ExampleMuonAnalyzer::h4MuInvMass
private

Definition at line 63 of file MuonAnalyzer.h.

TH1I* ExampleMuonAnalyzer::hChamberMatched
private

Definition at line 56 of file MuonAnalyzer.h.

TH1F* ExampleMuonAnalyzer::hEHcal
private

Definition at line 48 of file MuonAnalyzer.h.

TH1F* ExampleMuonAnalyzer::hMuCaloCompatibility
private

Definition at line 54 of file MuonAnalyzer.h.

TH1I* ExampleMuonAnalyzer::hMuIdAlgo
private

Definition at line 57 of file MuonAnalyzer.h.

TH1F* ExampleMuonAnalyzer::hMuIso03CaloComb
private

Definition at line 61 of file MuonAnalyzer.h.

TH1F* ExampleMuonAnalyzer::hMuIso03SumPt
private

Definition at line 60 of file MuonAnalyzer.h.

TH1I* ExampleMuonAnalyzer::hMuonType
private

Definition at line 50 of file MuonAnalyzer.h.

TH1F* ExampleMuonAnalyzer::hMuSegCompatibility
private

Definition at line 55 of file MuonAnalyzer.h.

TH1I* ExampleMuonAnalyzer::hNMuons
private

Definition at line 45 of file MuonAnalyzer.h.

TH1F* ExampleMuonAnalyzer::hPtRec
private

Definition at line 46 of file MuonAnalyzer.h.

TH2F* ExampleMuonAnalyzer::hPtReso
private

Definition at line 47 of file MuonAnalyzer.h.

TH1F* ExampleMuonAnalyzer::hPtSTATKDiff
private

Definition at line 51 of file MuonAnalyzer.h.

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

Definition at line 42 of file MuonAnalyzer.h.