00001 #include "DataFormats/PatCandidates/interface/Jet.h" 00002 #include "FWCore/MessageLogger/interface/MessageLogger.h" 00003 #include "TopQuarkAnalysis/Examples/plugins/TopJetAnalyzer.h" 00004 00005 00006 TopJetAnalyzer::TopJetAnalyzer(const edm::ParameterSet& cfg): 00007 input_(cfg.getParameter<edm::InputTag>("input")) 00008 { 00009 edm::Service<TFileService> fs; 00010 00011 Num_Jets = fs->make<TH1I>("Number_of_Jets","Num_{Jets}", 10, 0 , 10 ); 00012 pt_Jets = fs->make<TH1F>("pt_of_Jets", "pt_{Jets}", 100, 0., 300.); 00013 energy_Jets=fs->make<TH1F> ("energy_of_Jets","energy_{Jets}",100, 0., 300.); 00014 eta_Jets =fs->make<TH1F> ("eta_of_Jets", "eta_{Jets}", 100, -3., 3.); 00015 phi_Jets =fs->make<TH1F> ("phi_of_Jets", "phi_{Jets}", 100, -5., 5.); 00016 btag_Jets =fs->make<TH1F> ("btag_of_Jets", "btag_{Jet}", 400,-20., 20.); 00017 } 00018 00019 TopJetAnalyzer::~TopJetAnalyzer() 00020 { 00021 } 00022 00023 void 00024 TopJetAnalyzer::analyze(const edm::Event& evt, const edm::EventSetup& setup) 00025 { 00026 edm::Handle<std::vector<pat::Jet> > jets; 00027 evt.getByLabel(input_, jets); 00028 00029 Num_Jets->Fill( jets->size()); 00030 for( std::vector<pat::Jet>::const_iterator jet=jets->begin(); jet!=jets->end(); ++jet){ 00031 pt_Jets ->Fill( jet->pt() ); 00032 energy_Jets->Fill( jet->energy()); 00033 eta_Jets ->Fill( jet->eta() ); 00034 phi_Jets ->Fill( jet->phi() ); 00035 00036 // // test JEC from PAT 00037 // if(jet == jets->begin()){ 00038 // edm::LogVerbatim log("TopJetAnalyzer_jec"); 00039 // //jet->jetCorrFactors().print(); 00040 // log << "--------------------------------\n"; 00041 // log << " Jet Energy Correction Factors: \n"; 00042 // log << "--------------------------------\n"; 00043 // // uncomment for use with PATv1 00044 // // log << " " << jet->jetCorrName() << ": " << jet->pt() << " (default) \n"; 00045 // // uncomment for use with PATv2 00046 // log << " " << jet->corrStep() << ": " << jet->pt() << " (default) \n"; 00047 // log << "--------------------------------\n"; 00048 // log << " " << jet->correctedJet("raw") .jetCorrName() << ": " << jet->correctedJet("raw") .pt() << "\n"; 00049 // log << " " << jet->correctedJet("off") .jetCorrName() << ": " << jet->correctedJet("off") .pt() << "\n"; 00050 // log << " " << jet->correctedJet("rel") .jetCorrName() << ": " << jet->correctedJet("rel") .pt() << "\n"; 00051 // log << " " << jet->correctedJet("abs") .jetCorrName() << ": " << jet->correctedJet("abs") .pt() << "\n"; 00052 // log << " " << jet->correctedJet("emf") .jetCorrName() << ": " << jet->correctedJet("emf") .pt() << "\n"; 00053 // log << " " << jet->correctedJet("had", "glu").jetCorrName() << ": " << jet->correctedJet("had", "glu").pt() << " (gluon )\n"; 00054 // log << " " << jet->correctedJet("had", "uds").jetCorrName() << ": " << jet->correctedJet("had", "uds").pt() << " (uds )\n"; 00055 // log << " " << jet->correctedJet("had", "c" ).jetCorrName() << ": " << jet->correctedJet("had", "c" ).pt() << " (charm )\n"; 00056 // log << " " << jet->correctedJet("had", "b" ).jetCorrName() << ": " << jet->correctedJet("had", "b" ).pt() << " (beauty)\n"; 00057 // log << " " << jet->correctedJet("ue", "glu").jetCorrName() << ": " << jet->correctedJet("ue", "glu").pt() << " (gluon )\n"; 00058 // log << " " << jet->correctedJet("ue", "uds").jetCorrName() << ": " << jet->correctedJet("ue", "uds").pt() << " (uds )\n"; 00059 // log << " " << jet->correctedJet("ue", "c" ).jetCorrName() << ": " << jet->correctedJet("ue", "c" ).pt() << " (charm )\n"; 00060 // log << " " << jet->correctedJet("ue", "b" ).jetCorrName() << ": " << jet->correctedJet("ue", "b" ).pt() << " (beauty)\n"; 00061 // log << " " << jet->correctedJet("part", "glu").jetCorrName() << ": " << jet->correctedJet("part", "glu").pt() << " (gluon )\n"; 00062 // log << " " << jet->correctedJet("part", "uds").jetCorrName() << ": " << jet->correctedJet("part", "uds").pt() << " (uds )\n"; 00063 // log << " " << jet->correctedJet("part", "c" ).jetCorrName() << ": " << jet->correctedJet("part", "c" ).pt() << " (charm )\n"; 00064 // log << " " << jet->correctedJet("part", "b" ).jetCorrName() << ": " << jet->correctedJet("part", "b" ).pt() << " (beauty)\n"; 00065 // } 00066 btag_Jets ->Fill( jet->bDiscriminator("combinedSecondaryVertexBJetTags") ); 00067 } 00068 } 00069 00070 void TopJetAnalyzer::beginJob(const edm::EventSetup&) 00071 { 00072 } 00073 00074 void TopJetAnalyzer::endJob() 00075 { 00076 } 00077 00078