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
AnalysisTasksAnalyzerBTag Class Reference

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

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

Inheritance diagram for AnalysisTasksAnalyzerBTag:
edm::BasicAnalyzer

Public Member Functions

 AnalysisTasksAnalyzerBTag (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 ~AnalysisTasksAnalyzerBTag ()
 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

unsigned int bins_
 
std::string bTagAlgo_
 
std::map< std::string, TH1 * > hists_
 histograms More...
 
edm::InputTag Jets_
 input tag for mouns More...
 
double lowerbin_
 
bool skip_
 
std::string softMuonTagInfoLabel_
 
double upperbin_
 

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 AnalysisTasksAnalyzerBTag.h.

Constructor & Destructor Documentation

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

default constructor

Definition at line 8 of file AnalysisTasksAnalyzerBTag.cc.

References bins_, hists_, lowerbin_, TFileDirectory::make(), and upperbin_.

8  :
10  Jets_(cfg.getParameter<edm::InputTag>("Jets")),
11  bTagAlgo_(cfg.getParameter<std::string>("bTagAlgo")),
12  bins_(cfg.getParameter<unsigned int>("bins")),
13  lowerbin_(cfg.getParameter<double>("lowerbin")),
14  upperbin_(cfg.getParameter<double>("upperbin"))
15 {
16  hists_["NumSoftMuons"] = fs.make<TH1F>("NumSoftMuons" , "NumSoftMuons" ,4, -0.5, 3.5);
17  hists_["BTag_b"] = fs.make<TH1F>("BTag_b" , "BTag_b" , bins_, lowerbin_, upperbin_);
18  hists_["BTag_g"] = fs.make<TH1F>("BTag_g" , "BTag_g" , bins_, lowerbin_, upperbin_);
19  hists_["BTag_c"] = fs.make<TH1F>("BTag_c" , "BTag_c" , bins_, lowerbin_, upperbin_);
20  hists_["BTag_uds"] = fs.make<TH1F>("BTag_uds", "BTag_uds", bins_, lowerbin_, upperbin_);
21  hists_["BTag_other"] = fs.make<TH1F>("BTag_other", "BTag_other", bins_, lowerbin_, upperbin_);
22  hists_["effBTag_b"] = fs.make<TH1F>("effBTag_b" , "effBTag_b" , bins_, lowerbin_, upperbin_);
23  hists_["effBTag_g"] = fs.make<TH1F>("effBTag_g" , "effBTag_g" , bins_, lowerbin_, upperbin_);
24  hists_["effBTag_c"] = fs.make<TH1F>("effBTag_c" , "effBTag_c" , bins_, lowerbin_, upperbin_);
25  hists_["effBTag_uds"] = fs.make<TH1F>("effBTag_uds", "effBTag_uds", bins_, lowerbin_, upperbin_);
26  hists_["effBTag_other"] = fs.make<TH1F>("effBTag_other", "effBTag_other", bins_, lowerbin_, upperbin_);
27 }
T getParameter(std::string const &) const
std::map< std::string, TH1 * > hists_
histograms
BasicAnalyzer(const edm::ParameterSet &cfg, TFileDirectory &fileService)
default constructor
Definition: BasicAnalyzer.h:45
T * make() const
make new ROOT object
edm::InputTag Jets_
input tag for mouns
AnalysisTasksAnalyzerBTag::~AnalysisTasksAnalyzerBTag ( )
virtual

default destructor

Definition at line 28 of file AnalysisTasksAnalyzerBTag.cc.

References bins_, hists_, and i.

29 {
30  for(unsigned int i=0; i< bins_; ++i){
31  hists_["effBTag_b"]->SetBinContent(i,hists_["BTag_b"]->Integral(i,hists_["BTag_b"]->GetNbinsX()+1)/hists_["BTag_b"]->Integral(0,hists_["BTag_b"]->GetNbinsX()+1) );
32  hists_["effBTag_g"]->SetBinContent(i,hists_["BTag_g"]->Integral(i,hists_["BTag_g"]->GetNbinsX()+1)/hists_["BTag_g"]->Integral(0,hists_["BTag_g"]->GetNbinsX()+1) );
33  hists_["effBTag_c"]->SetBinContent(i,hists_["BTag_c"]->Integral(i,hists_["BTag_c"]->GetNbinsX()+1)/hists_["BTag_c"]->Integral(0,hists_["BTag_c"]->GetNbinsX()+1) );
34  hists_["effBTag_uds"]->SetBinContent(i,hists_["BTag_uds"]->Integral(i,hists_["BTag_uds"]->GetNbinsX()+1)/hists_["BTag_uds"]->Integral(0,hists_["BTag_uds"]->GetNbinsX()+1) );
35  hists_["effBTag_other"]->SetBinContent(i,hists_["BTag_other"]->Integral(i,hists_["BTag_other"]->GetNbinsX()+1)/hists_["BTag_other"]->Integral(0,hists_["BTag_other"]->GetNbinsX()+1) );
36  }
37 }
int i
Definition: DBlmapReader.cc:9
std::map< std::string, TH1 * > hists_
histograms

Member Function Documentation

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

everything that needs to be done during the event loop

Implements edm::BasicAnalyzer.

Definition at line 40 of file AnalysisTasksAnalyzerBTag.cc.

References abs, pat::Jet::bDiscriminator(), bTagAlgo_, pat::Jet::getPairDiscri(), hists_, METSkim_cff::Jets, Jets_, and pat::Jet::partonFlavour().

41 {
42  // define what Jet you are using; this is necessary as FWLite is not
43  // capable of reading edm::Views
44  using pat::Jet;
45 
46  // Handle to the Jet collection
48  event.getByLabel(Jets_, Jets);
49 
50  // loop Jet collection and fill histograms
51  for(std::vector<Jet>::const_iterator Jet_it=Jets->begin(); Jet_it!=Jets->end(); ++Jet_it){
52  edm::LogInfo ("hint3") << "\n \n investigate the next jet...\n \n "<<std::endl;
53  pat::Jet Jet(*Jet_it);
54 
55 
56  const std::vector< std::pair< std::string, float > > discrPairs = Jet.getPairDiscri();
57  for(unsigned int pair_i = 0;pair_i <discrPairs.size(); ++pair_i ){
58  edm::LogInfo ("hint3") << "discr name: "<< discrPairs[pair_i].first<<" value: "<< discrPairs[pair_i].second<<std::endl;
59  }
60 
61  //Categorize the Jets
62  if( abs(Jet.partonFlavour())==5){
63  hists_["BTag_b"]->Fill(Jet.bDiscriminator(bTagAlgo_));
64  }
65  else{
66  if( abs(Jet.partonFlavour())==21 || abs(Jet.partonFlavour())==9 ){
67  hists_["BTag_g"]->Fill(Jet.bDiscriminator(bTagAlgo_));
68  }
69  else{
70  if( abs(Jet.partonFlavour())==4){
71  hists_["BTag_c"]->Fill(Jet.bDiscriminator(bTagAlgo_));
72  }
73  else{
74  if( abs(Jet.partonFlavour())==1 || abs(Jet.partonFlavour())==2 || abs(Jet.partonFlavour())==3){
75  hists_["BTag_uds"]->Fill(Jet.bDiscriminator(bTagAlgo_));
76  }
77  else{
78  hists_["BTag_other"]->Fill(Jet.bDiscriminator(bTagAlgo_));
79  }
80  }
81  }
82  }
83  }
84 }
#define abs(x)
Definition: mlp_lapack.h:159
std::map< std::string, TH1 * > hists_
histograms
tuple Jets
Definition: METSkim_cff.py:17
Analysis-level calorimeter jet class.
Definition: Jet.h:72
edm::InputTag Jets_
input tag for mouns
void AnalysisTasksAnalyzerBTag::beginJob ( void  )
inlinevirtual

everything that needs to be done before the event loop

Implements edm::BasicAnalyzer.

Definition at line 27 of file AnalysisTasksAnalyzerBTag.h.

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

everything that needs to be done after the event loop

Implements edm::BasicAnalyzer.

Definition at line 29 of file AnalysisTasksAnalyzerBTag.h.

29 {};

Member Data Documentation

unsigned int AnalysisTasksAnalyzerBTag::bins_
private
std::string AnalysisTasksAnalyzerBTag::bTagAlgo_
private

Definition at line 36 of file AnalysisTasksAnalyzerBTag.h.

Referenced by analyze().

std::map<std::string, TH1*> AnalysisTasksAnalyzerBTag::hists_
private

histograms

Definition at line 43 of file AnalysisTasksAnalyzerBTag.h.

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

edm::InputTag AnalysisTasksAnalyzerBTag::Jets_
private

input tag for mouns

Definition at line 35 of file AnalysisTasksAnalyzerBTag.h.

Referenced by analyze().

double AnalysisTasksAnalyzerBTag::lowerbin_
private

Definition at line 38 of file AnalysisTasksAnalyzerBTag.h.

Referenced by AnalysisTasksAnalyzerBTag().

bool AnalysisTasksAnalyzerBTag::skip_
private

Definition at line 41 of file AnalysisTasksAnalyzerBTag.h.

std::string AnalysisTasksAnalyzerBTag::softMuonTagInfoLabel_
private

Definition at line 40 of file AnalysisTasksAnalyzerBTag.h.

double AnalysisTasksAnalyzerBTag::upperbin_
private

Definition at line 39 of file AnalysisTasksAnalyzerBTag.h.

Referenced by AnalysisTasksAnalyzerBTag().