CMS 3D CMS Logo

PatMCMatching.cc
Go to the documentation of this file.
1 #include <map>
2 #include <string>
3 
4 #include "TH1.h"
5 
12 #include "Math/VectorUtil.h"
13 
15 
17 public:
19  explicit PatMCMatching(const edm::ParameterSet&);
21  ~PatMCMatching() override;
22 
23 private:
24  void beginJob() override;
25  void analyze(const edm::Event&, const edm::EventSetup&) override;
26  void endJob() override;
27 
28  // simple map to contain all histograms;
29  // histograms are booked in the beginJob()
30  // method
31  std::map<std::string, TH1F*> histContainer_;
32 
33  // input tags
35 };
36 
38  : histContainer_(),
39  muonSrcToken_(consumes<edm::View<pat::Muon> >(iConfig.getUntrackedParameter<edm::InputTag>("muonSrc"))) {}
40 
42 
44  // get muon collection
46  iEvent.getByToken(muonSrcToken_, muons);
47 
48  for (edm::View<pat::Muon>::const_iterator muon = muons->begin(); muon != muons->end(); ++muon) {
49  for (unsigned int i = 0; i < muon->genParticleRefs().size(); ++i) {
50  switch (muon->genParticle(i)->status()) {
51  case 1:
52  histContainer_["DR_status1Match"]->Fill(
53  ROOT::Math::VectorUtil::DeltaR(muon->p4(), muon->genParticle(i)->p4()));
54  break;
55  case 3:
56  histContainer_["DR_status3Match"]->Fill(
57  ROOT::Math::VectorUtil::DeltaR(muon->p4(), muon->genParticle(i)->p4()));
58  break;
59  default:
60  histContainer_["DR_defaultMatch"]->Fill(
61  ROOT::Math::VectorUtil::DeltaR(muon->p4(), muon->genParticle(i)->p4()));
62  break;
63  }
64  }
65  }
66 }
67 
69  // register to the TFileService
71 
72  // book histograms:
73  histContainer_["DR_defaultMatch"] = fs->make<TH1F>("DR_defaultMatch", "DR_defaultMatch", 100, 0., 0.02);
74  histContainer_["DR_status1Match"] = fs->make<TH1F>("DR_status1Match", "DR_status1Match", 100, 0., 0.02);
75  histContainer_["DR_status3Match"] = fs->make<TH1F>("DR_status3Match", "DR_status3Match", 100, 0., 0.02);
76 }
77 
79 
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
mps_fire.i
i
Definition: mps_fire.py:428
sistrip::View
View
Definition: ConstantsForView.h:26
muon
Definition: MuonCocktails.h:17
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
Muon.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
PatMCMatching::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: PatMCMatching.cc:43
EDAnalyzer.h
edm::Handle
Definition: AssociativeIterator.h:50
Muon
Definition: Muon.py:1
edm::EDAnalyzer
Definition: EDAnalyzer.h:28
MakerMacros.h
PatMCMatching::~PatMCMatching
~PatMCMatching() override
default destructor
Definition: PatMCMatching.cc:41
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HLT_FULL_cff.muon
muon
Definition: HLT_FULL_cff.py:11710
Service.h
PatMCMatching
Definition: PatMCMatching.cc:16
TFileService.h
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
PatMCMatching::histContainer_
std::map< std::string, TH1F * > histContainer_
Definition: PatMCMatching.cc:31
edm::Service< TFileService >
iEvent
int iEvent
Definition: GenABIO.cc:224
PatMCMatching::muonSrcToken_
edm::EDGetTokenT< edm::View< pat::Muon > > muonSrcToken_
Definition: PatMCMatching.cc:34
edm::EventSetup
Definition: EventSetup.h:57
PatMCMatching::beginJob
void beginJob() override
Definition: PatMCMatching.cc:68
pat
Definition: HeavyIon.h:7
electronAnalyzer_cfi.DeltaR
DeltaR
Definition: electronAnalyzer_cfi.py:33
PatMCMatching::PatMCMatching
PatMCMatching(const edm::ParameterSet &)
default constructor
Definition: PatMCMatching.cc:37
InputTag.h
PatMCMatching::endJob
void endJob() override
Definition: PatMCMatching.cc:78
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
ParameterSet.h
edm::Event
Definition: Event.h:73
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileService.h:64