CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10/src/Validation/EventGenerator/plugins/TTbar_GenJetAnalyzer.cc

Go to the documentation of this file.
00001 #include "Validation/EventGenerator/interface/TTbar_GenJetAnalyzer.h"
00002 
00003 
00004 TTbar_GenJetAnalyzer::TTbar_GenJetAnalyzer(const edm::ParameterSet& iConfig):
00005   jets_(iConfig.getParameter<edm::InputTag>("jets")),
00006   genEventInfoProductTag_(iConfig.getParameter<edm::InputTag>("genEventInfoProductTag"))
00007 {
00008    //now do what ever initialization is needed
00009   dbe = 0;
00010   dbe = edm::Service<DQMStore>().operator->();
00011 }
00012 
00013 
00014 TTbar_GenJetAnalyzer::~TTbar_GenJetAnalyzer()
00015 {
00016  
00017    // do anything here that needs to be done at desctruction time
00018    // (e.g. close files, deallocate resources etc.)
00019 
00020 }
00021 
00022 
00023 //
00024 // member functions
00025 //
00026 
00027 // ------------ method called for each event  ------------
00028 void
00029 
00030 TTbar_GenJetAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00031 {
00032   using namespace edm;
00033  
00034   // --- the MC weights ---
00035   Handle<GenEventInfoProduct> evt_info;
00036   iEvent.getByLabel(genEventInfoProductTag_, evt_info);
00037   if(!evt_info.isValid()) return;
00038   weight = evt_info->weight() ;
00039 
00040   // Gather information in the GenJet collection
00041   edm::Handle<std::vector<reco::GenJet> > jets;
00042   iEvent.getByLabel(jets_, jets );
00043 
00044   if(!jets.isValid()) return;
00045   // loop Jet collection and fill histograms
00046   int njets = 0;
00047   for(std::vector<reco::GenJet>::const_iterator jet_it=jets->begin(); jet_it!=jets->end(); ++jet_it){  
00048 
00049     ++njets; 
00050 
00051     hists_["jetPtAll" ]->Fill( jet_it->pt() , weight );
00052     hists_["jetEtaAll"]->Fill( jet_it->eta(), weight );
00053 
00054     if (njets == 1) { hists_["jetPt1" ]->Fill( jet_it->pt() , weight );
00055                       hists_["jetEta1"]->Fill( jet_it->eta(), weight );
00056                     }
00057     if (njets == 2) { hists_["jetPt2" ]->Fill( jet_it->pt() , weight );
00058                       hists_["jetEta2"]->Fill( jet_it->eta(), weight );
00059                     }
00060     if (njets == 3) { hists_["jetPt3" ]->Fill( jet_it->pt() , weight );
00061                       hists_["jetEta3"]->Fill( jet_it->eta(), weight );
00062                     }
00063     if (njets == 4) { hists_["jetPt4" ]->Fill( jet_it->pt() , weight );
00064                       hists_["jetEta4"]->Fill( jet_it->eta(), weight );
00065                     }
00066   }
00067 
00068 }
00069 
00070 
00071 // ------------ method called once each job just before starting event loop  ------------
00072 void 
00073 TTbar_GenJetAnalyzer::beginJob()
00074 {
00075   if(!dbe) return;
00076   dbe->setCurrentFolder("Generator/TTbar");
00077   hists_["jetPtAll" ] = dbe->book1D("TTbar_jetPtAll" , "pt" , 1000,  0., 1000.); 
00078   hists_["jetPt1"   ] = dbe->book1D("TTbar_jetPt1"   , "pt" , 1000,  0., 1000.); 
00079   hists_["jetPt2"   ] = dbe->book1D("TTbar_jetPt2"   , "pt" , 1000,  0., 1000.); 
00080   hists_["jetPt3"   ] = dbe->book1D("TTbar_jetPt3"   , "pt" , 1000,  0., 1000.); 
00081   hists_["jetPt4"   ] = dbe->book1D("TTbar_jetPt4"   , "pt" , 1000,  0., 1000.); 
00082                                                                                     
00083   hists_["jetEtaAll"] = dbe->book1D("TTbar_jetEtaAll", "eta",  100, -5.,    5.); 
00084   hists_["jetEta1"  ] = dbe->book1D("TTbar_jetEta1"  , "eta",  100, -5.,    5.); 
00085   hists_["jetEta2"  ] = dbe->book1D("TTbar_jetEta2"  , "eta",  100, -5.,    5.); 
00086   hists_["jetEta3"  ] = dbe->book1D("TTbar_jetEta3"  , "eta",  100, -5.,    5.); 
00087   hists_["jetEta4"  ] = dbe->book1D("TTbar_jetEta4"  , "eta",  100, -5.,    5.); 
00088 }
00089 
00090 // ------------ method called once each job just after ending the event loop  ------------
00091 void 
00092 TTbar_GenJetAnalyzer::endJob() 
00093 {
00094 }
00095 
00096 // ------------ method called when starting to processes a run  ------------
00097 void 
00098 TTbar_GenJetAnalyzer::beginRun(edm::Run const&, edm::EventSetup const&)
00099 {
00100 }
00101 
00102 // ------------ method called when ending the processing of a run  ------------
00103 void 
00104 TTbar_GenJetAnalyzer::endRun(edm::Run const&, edm::EventSetup const&)
00105 {
00106 }
00107 
00108 // ------------ method called when starting to processes a luminosity block  ------------
00109 void 
00110 TTbar_GenJetAnalyzer::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
00111 {
00112 }
00113 
00114 // ------------ method called when ending the processing of a luminosity block  ------------
00115 void 
00116 TTbar_GenJetAnalyzer::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
00117 {
00118 }
00119 
00120 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
00121 void
00122 TTbar_GenJetAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
00123   //The following says we do not know what parameters are allowed so do no validation
00124   // Please change this to state exactly what you do use, even if it is no parameters
00125   edm::ParameterSetDescription desc;
00126   desc.setUnknown();
00127   descriptions.addDefault(desc);
00128 }
00129