00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "FWCore/Framework/interface/EDAnalyzer.h"
00011 #include "FWCore/ParameterSet/interface/InputTag.h"
00012 #include "FWCore/Framework/interface/Event.h"
00013 #include "DataFormats/Common/interface/Handle.h"
00014 #include "DataFormats/Candidate/interface/Particle.h"
00015 #include "DataFormats/Candidate/interface/Candidate.h"
00016 #include "FWCore/ServiceRegistry/interface/Service.h"
00017 #include "PhysicsTools/UtilAlgos/interface/TFileService.h"
00018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00019 #include "DataFormats/Common/interface/AssociationVector.h"
00020 #include "DataFormats/Candidate/interface/CandAssociation.h"
00021 #include "PhysicsTools/UtilAlgos/interface/HistoAnalyzer.h"
00022 #include "TH1.h"
00023 using namespace edm;
00024 using namespace std;
00025 using namespace reco;
00026
00027 typedef edm::AssociationVector<reco::CandidateRefProd, std::vector<double> > IsolationCollection;
00028 typedef HistoAnalyzer<reco::CandidateCollection> BaseAnalyzer;
00029
00030 class ZToMuMuHistogrammer : public BaseAnalyzer {
00031 public:
00032 ZToMuMuHistogrammer(const edm::ParameterSet& pset);
00033
00034 private:
00035 virtual void analyze(const edm::Event& event, const edm::EventSetup& setup);
00036 InputTag zCands_, muIso1_, muIso2_;
00037 TH1 * h_pt1, * h_pt2, * h_eta1, * h_eta2, * h_iso1, * h_iso2;
00038
00039 };
00040
00041 ZToMuMuHistogrammer::ZToMuMuHistogrammer(const edm::ParameterSet& cfg) :
00042 BaseAnalyzer(cfg),
00043 zCands_(cfg.getParameter<InputTag>("src")),
00044 muIso1_(cfg.getParameter<InputTag>("muonIsolations1")),
00045 muIso2_(cfg.getParameter<InputTag>("muonIsolations2")) {
00046 Service<TFileService> fs;
00047 h_pt1 = fs->make<TH1D>("mu1Pt", "muon 1 p_{t} (GeV/c)", 2000, 0., 200.);
00048 h_pt2 = fs->make<TH1D>("mu2Pt", "muon 2 p_{t} (GeV/c)", 2000, 0., 200.);
00049 h_eta1 = fs->make<TH1D>("mu1Eta", "muon 1 #eta", 600, -3, 3);
00050 h_eta2 = fs->make<TH1D>("mu2Eta", "muon 2 #eta", 600, -3, 3);
00051 h_iso1 = fs->make<TH1D>("mu1Iso", "muon 1 isolation (#Sigma p_{t})", 1000, 0, 100);
00052 h_iso2 = fs->make<TH1D>("mu2Iso", "muon 2 isolation (#Sigma p_{t})", 1000, 0, 100);
00053 }
00054
00055 void ZToMuMuHistogrammer::analyze(const edm::Event& ev, const edm::EventSetup& setup) {
00056
00057 BaseAnalyzer::analyze(ev, setup);
00058
00059
00060 Handle<CandidateCollection> zCands;
00061 ev.getByLabel(zCands_, zCands);
00062 Handle<CandDoubleAssociations> muIso1;
00063 ev.getByLabel(muIso1_, muIso1);
00064 Handle<CandDoubleAssociations> muIso2;
00065 ev.getByLabel(muIso2_, muIso2);
00066
00067 size_t n = zCands->size();
00068
00069 for(size_t i = 0; i < n; i++) {
00070 const Candidate & zCand = (*zCands)[i];
00071 const Candidate * dau1 = zCand.daughter(0);
00072 const Candidate * dau2 = zCand.daughter(1);
00073 CandidateRef mu1 = dau1->masterClone().castTo<CandidateRef>();
00074 CandidateRef mu2 = dau2->masterClone().castTo<CandidateRef>();
00075 double iso1 = (*muIso1)[mu1];
00076 double iso2 = (*muIso2)[mu2];
00077 if (dau1->pt() < dau2->pt()) {
00078 std::swap(dau1, dau2);
00079 std::swap(iso1, iso2);
00080 }
00081 h_pt1->Fill(dau1->pt());
00082 h_pt2->Fill(dau2->pt());
00083 h_eta1->Fill(dau1->eta());
00084 h_eta2->Fill(dau2->eta());
00085 h_iso1->Fill(iso1);
00086 h_iso2->Fill(iso2);
00087 }
00088 }
00089
00090 #include "FWCore/Framework/interface/MakerMacros.h"
00091
00092 DEFINE_FWK_MODULE(ZToMuMuHistogrammer);
00093