CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/Validation/EventGenerator/plugins/TTbar_GenLepAnalyzer.cc

Go to the documentation of this file.
00001 #include "Validation/EventGenerator/interface/TTbar_GenLepAnalyzer.h"
00002 #include "DQMServices/Core/interface/DQMStore.h"
00003 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
00004 #include "Validation/EventGenerator/interface/PdtPdgMini.h"
00005 
00006 TTbar_GenLepAnalyzer::TTbar_GenLepAnalyzer(const edm::ParameterSet& iConfig):
00007   leps_(iConfig.getParameter<edm::InputTag>("leptons"))
00008 {
00009    //now do what ever initialization is needed
00010   dbe = 0;
00011   dbe = edm::Service<DQMStore>().operator->();
00012 
00013 }
00014 
00015 
00016 TTbar_GenLepAnalyzer::~TTbar_GenLepAnalyzer()
00017 {
00018  
00019    // do anything here that needs to be done at desctruction time
00020    // (e.g. close files, deallocate resources etc.)
00021 
00022 }
00023 
00024 
00025 //
00026 // member functions
00027 //
00028 
00029 // ------------ method called for each event  ------------
00030 void
00031 TTbar_GenLepAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00032 {
00033 
00034   // Handle to the Leptons collections
00035   edm::Handle< edm::View<reco::Candidate> > leps;
00036   iEvent.getByLabel(leps_, leps);
00037   if(!leps.isValid()) return;
00038 
00039   // loop Jet collection and fill histograms
00040   int nleps = 0;
00041   for(edm::View<reco::Candidate>::const_iterator lep_it=leps->begin(); lep_it!=leps->end(); ++lep_it){
00042 
00043     ++nleps;
00044 
00045     if (nleps > 0) { hists_["lepPtAll" ]->Fill( lep_it->p4().pt()  );
00046       hists_["lepEtaAll"]->Fill( lep_it->p4().eta() );
00047     }
00048     if (nleps == 1) { hists_["lepPt1" ]->Fill( lep_it->p4().pt()  );
00049       hists_["lepEta1"]->Fill( lep_it->p4().eta() );
00050     }
00051     if (nleps == 2) { hists_["lepPt2" ]->Fill( lep_it->p4().pt()  );
00052       hists_["lepEta2"]->Fill( lep_it->p4().eta() );
00053     }
00054     if (nleps == 3) { hists_["lepPt3" ]->Fill( lep_it->p4().pt()  );
00055       hists_["lepEta3"]->Fill( lep_it->p4().eta() );
00056     }
00057     if (nleps == 4) { hists_["lepPt4" ]->Fill( lep_it->p4().pt()  );
00058       hists_["lepEta4"]->Fill( lep_it->p4().eta() );
00059     }
00060   }
00061 
00062   hists_["lepN"     ]->Fill( nleps ) ;
00063 
00064 
00065 }
00066 
00067 
00068 // ------------ method called once each job just before starting event loop  ------------
00069 void 
00070 TTbar_GenLepAnalyzer::beginJob()
00071 {
00072   if(!dbe) return;
00073   dbe->setCurrentFolder("Generator/TTbar");
00074   hists_["lepN"     ] = dbe->book1D("TTbar_lepN"     , "N"  ,   10, -.5,  9.5 );
00075 
00076   hists_["lepPtAll" ] = dbe->book1D("TTbar_lepPtAll_"+leps_.label() , "pt" , 1000,  0., 1000.);
00077   hists_["lepPt1"   ] = dbe->book1D("TTbar_lepPt1_"+leps_.label()   , "pt" , 1000,  0., 1000.);
00078   hists_["lepPt2"   ] = dbe->book1D("TTbar_lepPt2_"+leps_.label()   , "pt" , 1000,  0., 1000.);
00079   hists_["lepPt3"   ] = dbe->book1D("TTbar_lepPt3_"+leps_.label()   , "pt" , 1000,  0., 1000.);
00080   hists_["lepPt4"   ] = dbe->book1D("TTbar_lepPt4_"+leps_.label()   , "pt" , 1000,  0., 1000.);
00081 
00082   hists_["lepEtaAll"] = dbe->book1D("TTbar_lepEtaAll", "eta",  100, -5.,    5.);
00083   hists_["lepEta1"  ] = dbe->book1D("TTbar_lepEta1"  , "eta",  100, -5.,    5.);
00084   hists_["lepEta2"  ] = dbe->book1D("TTbar_lepEta2"  , "eta",  100, -5.,    5.);
00085   hists_["lepEta3"  ] = dbe->book1D("TTbar_lepEta3"  , "eta",  100, -5.,    5.);
00086   hists_["lepEta4"  ] = dbe->book1D("TTbar_lepEta4"  , "eta",  100, -5.,    5.);
00087 }
00088 
00089 // ------------ method called once each job just after ending the event loop  ------------
00090 void 
00091 TTbar_GenLepAnalyzer::endJob() 
00092 {
00093 }
00094 
00095 // ------------ method called when starting to processes a run  ------------
00096 void 
00097 TTbar_GenLepAnalyzer::beginRun(edm::Run const&, edm::EventSetup const&)
00098 {
00099 }
00100 
00101 // ------------ method called when ending the processing of a run  ------------
00102 void 
00103 TTbar_GenLepAnalyzer::endRun(edm::Run const&, edm::EventSetup const&)
00104 {
00105 }
00106 
00107 // ------------ method called when starting to processes a luminosity block  ------------
00108 void 
00109 TTbar_GenLepAnalyzer::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
00110 {
00111 }
00112 
00113 // ------------ method called when ending the processing of a luminosity block  ------------
00114 void 
00115 TTbar_GenLepAnalyzer::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
00116 {
00117 }
00118 
00119 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
00120 void
00121 TTbar_GenLepAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
00122   //The following says we do not know what parameters are allowed so do no validation
00123   // Please change this to state exactly what you do use, even if it is no parameters
00124   edm::ParameterSetDescription desc;
00125   desc.setUnknown();
00126   descriptions.addDefault(desc);
00127 }