Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:32:11

0001 #include "Validation/EventGenerator/interface/TTbar_GenLepAnalyzer.h"
0002 #include "DQMServices/Core/interface/DQMStore.h"
0003 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
0004 #include "Validation/EventGenerator/interface/PdtPdgMini.h"
0005 #include "Validation/EventGenerator/interface/DQMHelper.h"
0006 
0007 TTbar_GenLepAnalyzer::TTbar_GenLepAnalyzer(const edm::ParameterSet& iConfig)
0008     : leps_(iConfig.getParameter<edm::InputTag>("leptons")) {
0009   lepsToken_ = consumes<edm::View<reco::Candidate> >(leps_);
0010 }
0011 
0012 TTbar_GenLepAnalyzer::~TTbar_GenLepAnalyzer() {
0013   // do anything here that needs to be done at desctruction time
0014   // (e.g. close files, deallocate resources etc.)
0015 }
0016 
0017 //
0018 // member functions
0019 //
0020 
0021 // ------------ method called for each event  ------------
0022 void TTbar_GenLepAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0023   // Handle to the Leptons collections
0024   edm::Handle<edm::View<reco::Candidate> > leps;
0025   iEvent.getByToken(lepsToken_, leps);
0026   if (!leps.isValid())
0027     return;
0028 
0029   // loop Jet collection and fill histograms
0030   int nleps = 0;
0031   for (edm::View<reco::Candidate>::const_iterator lep_it = leps->begin(); lep_it != leps->end(); ++lep_it) {
0032     ++nleps;
0033 
0034     if (nleps > 0) {
0035       hists_["lepPtAll"]->Fill(lep_it->p4().pt());
0036       hists_["lepEtaAll"]->Fill(lep_it->p4().eta());
0037     }
0038     if (nleps == 1) {
0039       hists_["lepPt1"]->Fill(lep_it->p4().pt());
0040       hists_["lepEta1"]->Fill(lep_it->p4().eta());
0041     }
0042     if (nleps == 2) {
0043       hists_["lepPt2"]->Fill(lep_it->p4().pt());
0044       hists_["lepEta2"]->Fill(lep_it->p4().eta());
0045     }
0046     if (nleps == 3) {
0047       hists_["lepPt3"]->Fill(lep_it->p4().pt());
0048       hists_["lepEta3"]->Fill(lep_it->p4().eta());
0049     }
0050     if (nleps == 4) {
0051       hists_["lepPt4"]->Fill(lep_it->p4().pt());
0052       hists_["lepEta4"]->Fill(lep_it->p4().eta());
0053     }
0054   }
0055 
0056   hists_["lepN"]->Fill(nleps);
0057 }
0058 
0059 void TTbar_GenLepAnalyzer::bookHistograms(DQMStore::IBooker& i, edm::Run const& r, edm::EventSetup const& e) {
0060   DQMHelper dqm(&i);
0061   i.setCurrentFolder("Generator/TTbar");
0062   hists_["lepN"] = dqm.book1dHisto(
0063       "TTbar_lepN" + leps_.label(), "N", 10, -.5, 9.5, "Number of " + leps_.label(), "Number of Events");
0064 
0065   hists_["lepPtAll"] = dqm.book1dHisto("TTbar_lepPtAll_" + leps_.label(),
0066                                        "pt",
0067                                        1000,
0068                                        0.,
0069                                        1000.,
0070                                        "P_{t}^{All-" + leps_.label() + "} (GeV)",
0071                                        "Number of Events");
0072   hists_["lepPt1"] = dqm.book1dHisto("TTbar_lepPt1_" + leps_.label(),
0073                                      "pt",
0074                                      1000,
0075                                      0.,
0076                                      1000.,
0077                                      "P_{t}^{1st-" + leps_.label() + "} (GeV)",
0078                                      "Number of Events");
0079   hists_["lepPt2"] = dqm.book1dHisto("TTbar_lepPt2_" + leps_.label(),
0080                                      "pt",
0081                                      1000,
0082                                      0.,
0083                                      1000.,
0084                                      "P_{t}^{2nd-" + leps_.label() + "} (GeV)",
0085                                      "Number of Events");
0086   hists_["lepPt3"] = dqm.book1dHisto("TTbar_lepPt3_" + leps_.label(),
0087                                      "pt",
0088                                      1000,
0089                                      0.,
0090                                      1000.,
0091                                      "P_{t}^{3rd-" + leps_.label() + "} (GeV)",
0092                                      "Number of Events");
0093   hists_["lepPt4"] = dqm.book1dHisto("TTbar_lepPt4_" + leps_.label(),
0094                                      "pt",
0095                                      1000,
0096                                      0.,
0097                                      1000.,
0098                                      "P_{t}^{4th-" + leps_.label() + "} (GeV)",
0099                                      "Number of Events");
0100 
0101   hists_["lepEtaAll"] = dqm.book1dHisto(
0102       "TTbar_lepEtaAll" + leps_.label(), "eta", 100, -5., 5., "#eta^{All-" + leps_.label() + "}", "Number of Events");
0103   hists_["lepEta1"] = dqm.book1dHisto(
0104       "TTbar_lepEta1" + leps_.label(), "eta", 100, -5., 5., "#eta^{1st-" + leps_.label() + "}", "Number of Events");
0105   hists_["lepEta2"] = dqm.book1dHisto(
0106       "TTbar_lepEta2" + leps_.label(), "eta", 100, -5., 5., "#eta^{2nd-" + leps_.label() + "}", "Number of Events");
0107   hists_["lepEta3"] = dqm.book1dHisto(
0108       "TTbar_lepEta3" + leps_.label(), "eta", 100, -5., 5., "#eta^{3rd-" + leps_.label() + "}", "Number of Events");
0109   hists_["lepEta4"] = dqm.book1dHisto(
0110       "TTbar_lepEta4" + leps_.label(), "eta", 100, -5., 5., "#eta^{4th-" + leps_.label() + "}", "Number of Events");
0111 }