CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
AnalysisTasksAnalyzerJEC Class Reference

Example class that can be used both within FWLite and within the full framework. More...

#include "PhysicsTools/UtilAlgos/interface/AnalysisTasksAnalyzerJEC.h"

Inheritance diagram for AnalysisTasksAnalyzerJEC:
edm::BasicAnalyzer

Public Member Functions

 AnalysisTasksAnalyzerJEC (const edm::ParameterSet &cfg, TFileDirectory &fs)
 default constructor More...
 
void analyze (const edm::EventBase &event)
 everything that needs to be done during the event loop More...
 
void beginJob ()
 everything that needs to be done before the event loop More...
 
void endJob ()
 everything that needs to be done after the event loop More...
 
virtual ~AnalysisTasksAnalyzerJEC ()
 default destructor More...
 
- Public Member Functions inherited from edm::BasicAnalyzer
 BasicAnalyzer (const edm::ParameterSet &cfg, TFileDirectory &fileService)
 default constructor More...
 
virtual ~BasicAnalyzer ()
 default destructor More...
 

Private Attributes

bool help_
 
std::map< std::string, TH2 * > hists_
 histograms More...
 
std::string jecLevel_
 
std::string jecSetLabel_
 
unsigned int jetInEvents_
 
edm::InputTag Jets_
 input tag for mouns More...
 
std::string outputFileName_
 
std::string patJetCorrFactors_
 

Detailed Description

Example class that can be used both within FWLite and within the full framework.

This is an example for keeping classes that can be used both within FWLite and within the full framework. The class is derived from the BasicAnalyzer base class, which is an interface for the two wrapper classes EDAnalyzerWrapper and FWLiteAnalyzerWrapper. The latter provides basic configuration file reading and event looping equivalent to the FWLiteHistograms executable of this package. You can see the FWLiteAnalyzerWrapper class at work in the FWLiteWithBasicAnalyzer executable of this package.

Definition at line 19 of file AnalysisTasksAnalyzerJEC.h.

Constructor & Destructor Documentation

AnalysisTasksAnalyzerJEC::AnalysisTasksAnalyzerJEC ( const edm::ParameterSet cfg,
TFileDirectory fs 
)

default constructor

Definition at line 9 of file AnalysisTasksAnalyzerJEC.cc.

References hists_, jecLevel_, and TFileDirectory::make().

9  :
11  Jets_(cfg.getParameter<edm::InputTag>("Jets")),
12  jecLevel_(cfg.getParameter<std::string>("jecLevel")),
13  jecSetLabel_(cfg.getParameter<std::string>("jecSetLabel"))
14 {
15  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);
16 }
T getParameter(std::string const &) const
edm::InputTag Jets_
input tag for mouns
BasicAnalyzer(const edm::ParameterSet &cfg, TFileDirectory &fileService)
default constructor
Definition: BasicAnalyzer.h:45
std::map< std::string, TH2 * > hists_
histograms
T * make() const
make new ROOT object
AnalysisTasksAnalyzerJEC::~AnalysisTasksAnalyzerJEC ( )
virtual

default destructor

deconstructor

Definition at line 18 of file AnalysisTasksAnalyzerJEC.cc.

19 {
20 }

Member Function Documentation

void AnalysisTasksAnalyzerJEC::analyze ( const edm::EventBase event)
virtual

everything that needs to be done during the event loop

Implements edm::BasicAnalyzer.

Definition at line 23 of file AnalysisTasksAnalyzerJEC.cc.

References hists_, jecLevel_, jecSetLabel_, METSkim_cff::Jets, Jets_, and gen::k.

24 {
25  // define what Jet you are using; this is necessary as FWLite is not
26  // capable of reading edm::Views
27  using pat::Jet;
28 
29  // Handle to the Jet collection
31  event.getByLabel(Jets_, Jets);
32 
33  // loop Jet collection and fill histograms
34  for(std::vector<Jet>::const_iterator jet_it=Jets->begin(); jet_it!=Jets->end(); ++jet_it){
35 
36 
38  for(unsigned int k=0; k< jet_it->availableJECSets().size(); ++k){
39  edm::LogInfo ("hint1") <<"\n \n *************** HINT 1 *************** \n \n Label of available JEC Set: "<< jet_it->availableJECSets()[k]
40  <<"\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";
41  }
42  for(unsigned int k=0; k< jet_it->availableJECLevels().size(); ++k){
43  edm::LogInfo("hint2")<<" \n \n Label of available JEC level: "<< jet_it->availableJECLevels(jecSetLabel_)[k] << "\n \n ";
44  }
45  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: "
46  << 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;
47  if(jet_it->genParticlesSize()>0){
48  hists_["Response" ]->Fill( jet_it->correctedJet(jecLevel_).eta(), jet_it->correctedJet(jecLevel_).pt()/ jet_it->genParticle(0)->pt());
49  }
50  }
51 }
edm::InputTag Jets_
input tag for mouns
tuple Jets
Definition: METSkim_cff.py:17
int k[5][pyjets_maxn]
Analysis-level calorimeter jet class.
Definition: Jet.h:72
std::map< std::string, TH2 * > hists_
histograms
void AnalysisTasksAnalyzerJEC::beginJob ( void  )
inlinevirtual

everything that needs to be done before the event loop

Implements edm::BasicAnalyzer.

Definition at line 27 of file AnalysisTasksAnalyzerJEC.h.

27 {};
void AnalysisTasksAnalyzerJEC::endJob ( void  )
inlinevirtual

everything that needs to be done after the event loop

Implements edm::BasicAnalyzer.

Definition at line 29 of file AnalysisTasksAnalyzerJEC.h.

29 {};

Member Data Documentation

bool AnalysisTasksAnalyzerJEC::help_
private

Definition at line 39 of file AnalysisTasksAnalyzerJEC.h.

std::map<std::string, TH2*> AnalysisTasksAnalyzerJEC::hists_
private

histograms

Definition at line 43 of file AnalysisTasksAnalyzerJEC.h.

Referenced by AnalysisTasksAnalyzerJEC(), and analyze().

std::string AnalysisTasksAnalyzerJEC::jecLevel_
private

Definition at line 36 of file AnalysisTasksAnalyzerJEC.h.

Referenced by AnalysisTasksAnalyzerJEC(), and analyze().

std::string AnalysisTasksAnalyzerJEC::jecSetLabel_
private

Definition at line 37 of file AnalysisTasksAnalyzerJEC.h.

Referenced by analyze().

unsigned int AnalysisTasksAnalyzerJEC::jetInEvents_
private

Definition at line 41 of file AnalysisTasksAnalyzerJEC.h.

edm::InputTag AnalysisTasksAnalyzerJEC::Jets_
private

input tag for mouns

Definition at line 35 of file AnalysisTasksAnalyzerJEC.h.

Referenced by analyze().

std::string AnalysisTasksAnalyzerJEC::outputFileName_
private

Definition at line 40 of file AnalysisTasksAnalyzerJEC.h.

std::string AnalysisTasksAnalyzerJEC::patJetCorrFactors_
private

Definition at line 38 of file AnalysisTasksAnalyzerJEC.h.