CMS 3D CMS Logo

TopMuonAnalyzer.cc
Go to the documentation of this file.
3 
4 
6  inputToken_ (consumes<std::vector<pat::Muon> >(cfg.getParameter<edm::InputTag>("input" ))),
7  verbose_(cfg.getParameter<bool> ("verbose"))
8 {
10 
11  mult_ = fs->make<TH1F>("mult", "multiplicity (muons)", 10, 0 , 10);
12  en_ = fs->make<TH1F>("en" , "energy (muons)", 60, 0., 300.);
13  pt_ = fs->make<TH1F>("pt" , "pt (muons)", 60, 0., 300.);
14  eta_ = fs->make<TH1F>("eta" , "eta (muons)", 30, -3., 3.);
15  phi_ = fs->make<TH1F>("phi" , "phi (muons)", 40, -4., 4.);
16 
17 }
18 
20 {
21 }
22 
23 void
25 {
27  evt.getByToken(inputToken_, muons);
28 
29  // fill histograms
30 
31  mult_->Fill( muons->size() );
32  for(std::vector<pat::Muon>::const_iterator muon=muons->begin(); muon!=muons->end(); ++muon){
33  pt_ ->Fill( muon->pt() );
34  en_ ->Fill( muon->energy() );
35  eta_->Fill( muon->eta() );
36  phi_->Fill( muon->phi() );
37  }
38 
39  // produce printout if desired
40 
41  if( muons->size()<1 || !verbose_ )
42  return;
43 
44  unsigned i=0;
45 
46  std::cout << "==================================================================="
47  << std::endl;
48  std::cout << std::setw(5 ) << "mu :"
49  << std::setw(13) << "pt :"
50  << std::setw(13) << "eta :"
51  << std::setw(13) << "phi :"
52  << std::setw(13) << "relIso :"
53  << std::setw(6 ) << "GLB :"
54  << std::setw(4 ) << "TRK" << std::endl;
55  std::cout << "-------------------------------------------------------------------"
56  << std::endl;
57  for(std::vector<pat::Muon>::const_iterator muon=muons->begin(); muon!=muons->end(); ++muon){
58  std::cout << std::setw(3 ) << i << " : "
59  << std::setw(10) << muon->pt() << " : "
60  << std::setw(10) << muon->eta() << " : "
61  << std::setw(10) << muon->phi() << " : "
62  << std::setw(10) << (muon->trackIso()+muon->caloIso())/muon->pt() << " : "
63  << std::setw( 3) << muon->isGlobalMuon() << " : "
64  << std::setw( 3) << muon->isTrackerMuon() << std::endl;
65  i++;
66  }
67  std::cout << "==================================================================="
68  << std::endl;
69 }
70 
72 {
73 }
74 
76 {
77 }
int i
Definition: DBlmapReader.cc:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
virtual void beginJob()
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
virtual void analyze(const edm::Event &, const edm::EventSetup &)
Definition: HeavyIon.h:7
edm::EDGetTokenT< std::vector< pat::Muon > > inputToken_
Definition: Muon.py:1
HLT enums.
TopMuonAnalyzer(const edm::ParameterSet &)
virtual void endJob()