Go to the documentation of this file.00001 #include "DataFormats/Common/interface/Handle.h"
00002 #include "DataFormats/JetReco/interface/Jet.h"
00003 #include "DataFormats/PatCandidates/interface/Jet.h"
00004 #include "PhysicsTools/PatExamples/interface/AnalysisTasksAnalyzerJEC.h"
00005 #include "TH2.h"
00006 #include "TProfile.h"
00007
00009 AnalysisTasksAnalyzerJEC::AnalysisTasksAnalyzerJEC(const edm::ParameterSet& cfg, TFileDirectory& fs):
00010 edm::BasicAnalyzer::BasicAnalyzer(cfg, fs),
00011 Jets_(cfg.getParameter<edm::InputTag>("Jets")),
00012 jecLevel_(cfg.getParameter<std::string>("jecLevel")),
00013 jecSetLabel_(cfg.getParameter<std::string>("jecSetLabel"))
00014 {
00015 hists_["Response" ] = fs.make<TH2F>("Response" , "response "+TString(jecLevel_)+"; #eta;p_{T}(reco)/p_{T}(gen)" , 5, -3.3, 3.3, 100, 0.4, 1.6);
00016 }
00018 AnalysisTasksAnalyzerJEC::~AnalysisTasksAnalyzerJEC()
00019 {
00020 }
00022 void
00023 AnalysisTasksAnalyzerJEC::analyze(const edm::EventBase& event)
00024 {
00025
00026
00027 using pat::Jet;
00028
00029
00030 edm::Handle<std::vector<Jet> > Jets;
00031 event.getByLabel(Jets_, Jets);
00032
00033
00034 for(std::vector<Jet>::const_iterator jet_it=Jets->begin(); jet_it!=Jets->end(); ++jet_it){
00035
00036
00038 for(unsigned int k=0; k< jet_it->availableJECSets().size(); ++k){
00039 edm::LogInfo ("hint1") <<"\n \n *************** HINT 1 *************** \n \n Label of available JEC Set: "<< jet_it->availableJECSets()[k]
00040 <<"\n \n You found out which JEC Sets were created within the PAT tuple creation! The wrong label caused the segmentation fault in the next for-loop where you ask for JEC levels of a JEC Set that does not exist. Correct the JEC label in your config file and eliminate the segmentation fault. \n *********************************************** \n";
00041 }
00042 for(unsigned int k=0; k< jet_it->availableJECLevels().size(); ++k){
00043 edm::LogInfo("hint2")<<" \n \n Label of available JEC level: "<< jet_it->availableJECLevels(jecSetLabel_)[k] << "\n \n ";
00044 }
00045 edm::LogInfo("hint2")<<"\n \n *************** HINT 2 ************** \n You did it correctly congratulations!!!! And you found out above which JEC levels are saved within the jets. We want to investigate these in the following with the response function. At the moment you are trying to access the JEC Level: "
00046 << jecLevel_ << ". Does it exist? This causes the error below (see 'Exception Message')! Correct the label of the correction level to an existing one that you are interested in. \n ******************************************* \n " <<std::endl;
00047 if(jet_it->genParticlesSize()>0){
00048 hists_["Response" ]->Fill( jet_it->correctedJet(jecLevel_).eta(), jet_it->correctedJet(jecLevel_).pt()/ jet_it->genParticle(0)->pt());
00049 }
00050 }
00051 }