CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

CalibAnalyzer< Ref, Rec, Alg > Class Template Reference

#include <CalibAnalyzer.h>

Inheritance diagram for CalibAnalyzer< Ref, Rec, Alg >:
edm::EDAnalyzer

List of all members.

Public Member Functions

 CalibAnalyzer (const edm::ParameterSet &)
 ~CalibAnalyzer ()

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginJob ()
virtual void endJob ()
void fill (const double &var, const double &val, const std::vector< double > &bins, const std::vector< TH1F * > &hists)

Private Attributes

Alg alg_
int bins_
std::vector< double > binsEta_
std::vector< double > binsPt_
TH1F * calEta_
std::vector< TH1F * > calEtaPt_
TH1F * calPt_
std::string hist_
std::vector< TH1F * > ktEta_
std::vector< std::vector< TH1F * > > ktEtaPt_
std::vector< TH1F * > ktPt_
double max_
double min_
edm::InputTag recs_
TH2F * recVsRef_
edm::InputTag refs_
TH1F * resEta_
std::vector< TH1F * > resEtaPt_
TH1F * resPt_
int type_

Detailed Description

template<typename Ref, typename Rec, typename Alg>
class CalibAnalyzer< Ref, Rec, Alg >

Definition at line 28 of file CalibAnalyzer.h.


Constructor & Destructor Documentation

template<typename Ref , typename Rec , typename Alg >
CalibAnalyzer< Ref, Rec, Alg >::CalibAnalyzer ( const edm::ParameterSet cfg) [explicit]

Definition at line 67 of file CalibAnalyzer.h.

                                                                     :
  recs_( cfg.getParameter<edm::InputTag>( "recs" ) ),
  refs_( cfg.getParameter<edm::InputTag>( "refs" ) ),
  hist_( cfg.getParameter<std::string > ( "hist" ) ),
  type_( cfg.getParameter<int>( "type" ) ),
  bins_( cfg.getParameter<int>( "bins" ) ),
  min_ ( cfg.getParameter<double>( "min" ) ),
  max_ ( cfg.getParameter<double>( "max" ) ),
  binsPt_ ( cfg.getParameter<std::vector<double> >( "binsPt"  ) ),
  binsEta_( cfg.getParameter<std::vector<double> >( "binsEta" ) ),
  alg_( cfg )
{
}
template<typename Ref , typename Rec , typename Alg >
CalibAnalyzer< Ref, Rec, Alg >::~CalibAnalyzer ( ) [inline]

Definition at line 33 of file CalibAnalyzer.h.

{};

Member Function Documentation

template<typename Ref , typename Rec , typename Alg >
void CalibAnalyzer< Ref, Rec, Alg >::analyze ( const edm::Event evt,
const edm::EventSetup setup 
) [private, virtual]

Implements edm::EDAnalyzer.

Definition at line 82 of file CalibAnalyzer.h.

References lumiContext::fill, edm::Event::getByLabel(), UserOptions_cff::idx, and match().

{
  edm::Handle<Ref> refs;
  evt.getByLabel(refs_, refs);

  edm::Handle<Rec> recs;
  evt.getByLabel(recs_, recs);
  
  // do matching
  std::map<unsigned int, unsigned int> matches=alg_(*refs, *recs);

  if( !matches.size()>0 )
    edm::LogWarning ( "NoMatchOrBalance" ) 
      << "No single match/balance found to any Rec object in collection";
  
  // fill comparison plots for matched jets
  for(std::map<unsigned int, unsigned int>::const_iterator match=matches.begin(); 
      match!=matches.end(); ++match){

    CompType cmp(type_);
    double val=cmp((*refs)[match->first].pt(), (*recs)[match->second].pt());

    fill((*refs)[match->first].pt(),  val, binsPt_,  ktPt_ );// inclusive binned in pt 
    fill((*refs)[match->first].eta(), val, binsEta_, ktEta_);// inclusive binned in eta  

    // differential in eta binned in pt   
    for(int idx=0; idx<((int)binsEta_.size()-1); ++idx)
      if( (binsEta_[idx]<(*refs)[match->first].eta()) && ((*refs)[match->first].eta()<binsEta_[idx+1]) )
        fill((*refs)[match->first].pt(),  val, binsPt_,  ktEtaPt_[idx] );
    recVsRef_->Fill( TMath::Log10((*refs)[match->first].pt()), TMath::Log10((*recs)[match->second].pt()) );
  }
}
template<typename Ref , typename Rec , typename Alg >
void CalibAnalyzer< Ref, Rec, Alg >::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 126 of file CalibAnalyzer.h.

References edm::errors::Configuration, Exception, estimatePileup::hist, UserOptions_cff::idx, and dbtoconf::out.

{
  if( hist_.empty() )
    return;

  edm::Service<TFileService> fs;
  if( !fs )
    throw edm::Exception( edm::errors::Configuration, "TFile Service is not registered in cfg file" );

  ofstream hist(hist_.c_str(), std::ios::out);
  NameScheme val("val"), fit("fit"), cal("cal"), res("res");

  // book additional control histograms
  recVsRef_= fs->make<TH2F>( val.name("recVsRef"),val.name("recVsRef"), 20, 1., 3., 20, 1., 3.);

  // book kt histograms differential in pt
  for(int idx=0; idx<((int)binsPt_.size()-1); ++idx)
    ktPt_.push_back( fs->make<TH1F>(fit.name(hist, "ktPt",idx), fit.name("kt",idx), bins_, min_, max_) );
  calPt_= fs->make<TH1F>(cal.name(hist, "ktPt"), cal.name("calPt"), ((int)binsPt_.size()-1), &binsPt_[0]);
  resPt_= fs->make<TH1F>(res.name(hist, "ktPt"), res.name("resPt"), ((int)binsPt_.size()-1), &binsPt_[0]);
  
  // book kt histograms differential in eta  
  for(int jdx=0; jdx<((int)binsEta_.size()-1); ++jdx)
    ktEta_.push_back(fs->make<TH1F>(fit.name(hist, "ktEta",jdx),fit.name("kt",jdx), bins_, min_, max_) );
  calEta_= fs->make<TH1F>(cal.name(hist, "ktEta"), cal.name("calEta"), ((int)binsEta_.size()-1), &binsEta_[0]);
  resEta_= fs->make<TH1F>(res.name(hist, "ktEta"), res.name("resEta"), ((int)binsEta_.size()-1), &binsEta_[0]);
  
  // book kt histograms differential in eta and pt
  for(int jdx=0; jdx<((int)binsEta_.size()-1); ++jdx){
    std::vector<TH1F*> buffer;
    calEtaPt_.push_back(fs->make<TH1F>(cal.name(hist,"ktEtaPt",jdx), cal.name("calEtaPt",jdx), ((int)binsPt_.size()-1), &binsPt_[0]));
    resEtaPt_.push_back(fs->make<TH1F>(res.name(hist,"ktEtaPt",jdx), res.name("resEtaPt",jdx), ((int)binsPt_.size()-1), &binsPt_[0]));
    for(int idx=0; idx<((int)binsPt_.size()-1); ++idx)
      buffer.push_back( fs->make<TH1F>(fit.name(hist, "ktEtaPt",jdx,idx), fit.name("ktEtaPt",jdx,idx), bins_, min_, max_) );
    ktEtaPt_.push_back(buffer); 
  }
}
template<typename Ref , typename Rec , typename Alg >
virtual void CalibAnalyzer< Ref, Rec, Alg >::endJob ( void  ) [inline, private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 39 of file CalibAnalyzer.h.

References CalibAnalyzer< Ref, Rec, Alg >::alg_.

{ alg_.summarize(); };
template<typename Ref , typename Rec , typename Alg >
void CalibAnalyzer< Ref, Rec, Alg >::fill ( const double &  var,
const double &  val,
const std::vector< double > &  bins,
const std::vector< TH1F * > &  hists 
) [private]

Definition at line 116 of file CalibAnalyzer.h.

References UserOptions_cff::idx.

{
  for(unsigned int idx=0; idx<(bins.size()-1); ++idx){
    if( (bins[idx]<var) && (var<bins[idx+1]) ){
      hists[idx]->Fill( val );
    }
  }
}

Member Data Documentation

template<typename Ref , typename Rec , typename Alg >
Alg CalibAnalyzer< Ref, Rec, Alg >::alg_ [private]

Definition at line 63 of file CalibAnalyzer.h.

Referenced by CalibAnalyzer< Ref, Rec, Alg >::endJob().

template<typename Ref , typename Rec , typename Alg >
int CalibAnalyzer< Ref, Rec, Alg >::bins_ [private]

Definition at line 49 of file CalibAnalyzer.h.

template<typename Ref , typename Rec , typename Alg >
std::vector<double> CalibAnalyzer< Ref, Rec, Alg >::binsEta_ [private]

Definition at line 51 of file CalibAnalyzer.h.

template<typename Ref , typename Rec , typename Alg >
std::vector<double> CalibAnalyzer< Ref, Rec, Alg >::binsPt_ [private]

Definition at line 51 of file CalibAnalyzer.h.

template<typename Ref , typename Rec , typename Alg >
TH1F* CalibAnalyzer< Ref, Rec, Alg >::calEta_ [private]

Definition at line 58 of file CalibAnalyzer.h.

template<typename Ref , typename Rec , typename Alg >
std::vector<TH1F*> CalibAnalyzer< Ref, Rec, Alg >::calEtaPt_ [private]

Definition at line 60 of file CalibAnalyzer.h.

template<typename Ref , typename Rec , typename Alg >
TH1F* CalibAnalyzer< Ref, Rec, Alg >::calPt_ [private]

Definition at line 56 of file CalibAnalyzer.h.

template<typename Ref , typename Rec , typename Alg >
std::string CalibAnalyzer< Ref, Rec, Alg >::hist_ [private]

Definition at line 47 of file CalibAnalyzer.h.

template<typename Ref , typename Rec , typename Alg >
std::vector<TH1F*> CalibAnalyzer< Ref, Rec, Alg >::ktEta_ [private]

Definition at line 59 of file CalibAnalyzer.h.

template<typename Ref , typename Rec , typename Alg >
std::vector<std::vector<TH1F*> > CalibAnalyzer< Ref, Rec, Alg >::ktEtaPt_ [private]

Definition at line 61 of file CalibAnalyzer.h.

template<typename Ref , typename Rec , typename Alg >
std::vector<TH1F*> CalibAnalyzer< Ref, Rec, Alg >::ktPt_ [private]

Definition at line 57 of file CalibAnalyzer.h.

template<typename Ref , typename Rec , typename Alg >
double CalibAnalyzer< Ref, Rec, Alg >::max_ [private]

Definition at line 50 of file CalibAnalyzer.h.

template<typename Ref , typename Rec , typename Alg >
double CalibAnalyzer< Ref, Rec, Alg >::min_ [private]

Definition at line 50 of file CalibAnalyzer.h.

template<typename Ref , typename Rec , typename Alg >
edm::InputTag CalibAnalyzer< Ref, Rec, Alg >::recs_ [private]

Definition at line 45 of file CalibAnalyzer.h.

template<typename Ref , typename Rec , typename Alg >
TH2F* CalibAnalyzer< Ref, Rec, Alg >::recVsRef_ [private]

Definition at line 55 of file CalibAnalyzer.h.

template<typename Ref , typename Rec , typename Alg >
edm::InputTag CalibAnalyzer< Ref, Rec, Alg >::refs_ [private]

Definition at line 46 of file CalibAnalyzer.h.

template<typename Ref , typename Rec , typename Alg >
TH1F * CalibAnalyzer< Ref, Rec, Alg >::resEta_ [private]

Definition at line 58 of file CalibAnalyzer.h.

template<typename Ref , typename Rec , typename Alg >
std::vector<TH1F*> CalibAnalyzer< Ref, Rec, Alg >::resEtaPt_ [private]

Definition at line 60 of file CalibAnalyzer.h.

template<typename Ref , typename Rec , typename Alg >
TH1F * CalibAnalyzer< Ref, Rec, Alg >::resPt_ [private]

Definition at line 56 of file CalibAnalyzer.h.

template<typename Ref , typename Rec , typename Alg >
int CalibAnalyzer< Ref, Rec, Alg >::type_ [private]

Definition at line 48 of file CalibAnalyzer.h.