CMS 3D CMS Logo

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

List of all members.

Public Member Functions

 AnalysisTasksAnalyzerJEC (const edm::ParameterSet &cfg, TFileDirectory &fs)
 default constructor
void analyze (const edm::EventBase &event)
 everything that needs to be done during the event loop
void beginJob ()
 everything that needs to be done before the event loop
void endJob ()
 everything that needs to be done after the event loop
virtual ~AnalysisTasksAnalyzerJEC ()
 default destructor

Private Attributes

bool help_
std::map< std::string, TH2 * > hists_
 histograms
std::string jecLevel_
unsigned int jetInEvents_
edm::InputTag Jets_
 input tag for mouns
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 8 of file AnalysisTasksAnalyzerJEC.cc.

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

                                                                                                : 
  edm::BasicAnalyzer::BasicAnalyzer(cfg, fs),
  Jets_(cfg.getParameter<edm::InputTag>("Jets")),
  jecLevel_(cfg.getParameter<std::string>("jecLevel")),
  patJetCorrFactors_(cfg.getParameter<std::string>("patJetCorrFactors")),
  help_(cfg.getParameter<bool>("help"))
{
 
  hists_["Response"  ] = fs.make<TH2F>("Response"  , "response; #eta;p_{T}(reco)/p_{T}(gen)"  ,  5,  -3.3, 3.3, 100, 0.4, 1.6);
  jetInEvents_=0;
}
AnalysisTasksAnalyzerJEC::~AnalysisTasksAnalyzerJEC ( ) [virtual]

default destructor

deconstructor

A Response function is nicer in a TProfile:

Definition at line 20 of file AnalysisTasksAnalyzerJEC.cc.

References mergeVDriftHistosByStation::file, hists_, and jecLevel_.

{

 TFile* file=new TFile("myResponse"+TString(jecLevel_)+".root", "RECREATE");
 TProfile* prof = hists_["Response"  ]->ProfileX();
 prof->Write();
 file->Write();
 file->Close();
}

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 32 of file AnalysisTasksAnalyzerJEC.cc.

References gather_cfg::cout, help_, hists_, jecLevel_, jetInEvents_, METSkim_cff::Jets, Jets_, gen::k, and patJetCorrFactors_.

{
  // define what Jet you are using; this is necessary as FWLite is not 
  // capable of reading edm::Views
  using pat::Jet;

  // Handle to the Jet collection
  edm::Handle<std::vector<Jet> > Jets;
  event.getByLabel(Jets_, Jets);

  // loop Jet collection and fill histograms
  for(std::vector<Jet>::const_iterator jet_it=Jets->begin(); jet_it!=Jets->end(); ++jet_it){  


  if(help_==true){
     if(jetInEvents_==0){
       std::cout<<"\n \n number of available JEC sets: "<< jet_it->availableJECSets().size() << std::endl; 
       for(unsigned int k=0; k< jet_it->availableJECSets().size(); ++k){
         std::cout<<"\n \n available JEC Set: "<< jet_it->availableJECSets()[k] << std::endl; 
       }
       std::cout<<"\n \n*** You found out which JEC Sets exist! Now correct it in your config file."<<std::endl;
       std::cout<<"\n \n number of available JEC levels "<< jet_it->availableJECLevels().size() << std::endl; 
       for(unsigned int k=0; k< jet_it->availableJECLevels().size(); ++k){
         std::cout<<"\n \n available JEC: "<< jet_it->availableJECLevels(patJetCorrFactors_)[k] << std::endl; 
       }
       std::cout<<"\n \n**** You did it correctly congratulations!!!!  And you found out which JEC levels are saved within the jets. Correct this in your configuration file." <<std::endl;     
     }
  }

     if(jet_it->genParticlesSize()>0){
         hists_["Response" ]->Fill( jet_it->correctedJet(jecLevel_).eta(), jet_it->correctedJet(jecLevel_).pt()/ jet_it->genParticle(0)->pt());
         std::cout<<"\n \n**** You did it correctly congratulations!!!! "<< std::endl;
     }
     jetInEvents_+=1;
  }
}
void AnalysisTasksAnalyzerJEC::beginJob ( void  ) [inline, virtual]

everything that needs to be done before the event loop

Implements edm::BasicAnalyzer.

Definition at line 27 of file AnalysisTasksAnalyzerJEC.h.

{};
void AnalysisTasksAnalyzerJEC::endJob ( void  ) [inline, virtual]

everything that needs to be done after the event loop

Implements edm::BasicAnalyzer.

Definition at line 29 of file AnalysisTasksAnalyzerJEC.h.

{};

Member Data Documentation

Definition at line 38 of file AnalysisTasksAnalyzerJEC.h.

Referenced by analyze().

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

histograms

Definition at line 41 of file AnalysisTasksAnalyzerJEC.h.

Referenced by AnalysisTasksAnalyzerJEC(), analyze(), and ~AnalysisTasksAnalyzerJEC().

std::string AnalysisTasksAnalyzerJEC::jecLevel_ [private]

Definition at line 36 of file AnalysisTasksAnalyzerJEC.h.

Referenced by analyze(), and ~AnalysisTasksAnalyzerJEC().

Definition at line 39 of file AnalysisTasksAnalyzerJEC.h.

Referenced by AnalysisTasksAnalyzerJEC(), and analyze().

input tag for mouns

Definition at line 35 of file AnalysisTasksAnalyzerJEC.h.

Referenced by analyze().

Definition at line 37 of file AnalysisTasksAnalyzerJEC.h.

Referenced by analyze().