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 Member Functions | Private Attributes
CalibAnalyzer< Ref, Rec, Alg > Class Template Reference

#include <CalibAnalyzer.h>

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

Public Member Functions

 CalibAnalyzer (const edm::ParameterSet &)
 
 ~CalibAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

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_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

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.

67  :
68  recs_( cfg.getParameter<edm::InputTag>( "recs" ) ),
69  refs_( cfg.getParameter<edm::InputTag>( "refs" ) ),
70  hist_( cfg.getParameter<std::string > ( "hist" ) ),
71  type_( cfg.getParameter<int>( "type" ) ),
72  bins_( cfg.getParameter<int>( "bins" ) ),
73  min_ ( cfg.getParameter<double>( "min" ) ),
74  max_ ( cfg.getParameter<double>( "max" ) ),
75  binsPt_ ( cfg.getParameter<std::vector<double> >( "binsPt" ) ),
76  binsEta_( cfg.getParameter<std::vector<double> >( "binsEta" ) ),
77  alg_( cfg )
78 {
79 }
edm::InputTag recs_
Definition: CalibAnalyzer.h:45
T getParameter(std::string const &) const
std::vector< double > binsPt_
Definition: CalibAnalyzer.h:51
std::string hist_
Definition: CalibAnalyzer.h:47
std::vector< double > binsEta_
Definition: CalibAnalyzer.h:51
edm::InputTag refs_
Definition: CalibAnalyzer.h:46
template<typename Ref , typename Rec , typename Alg >
CalibAnalyzer< Ref, Rec, Alg >::~CalibAnalyzer ( )
inline

Definition at line 33 of file CalibAnalyzer.h.

33 {};

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 82 of file CalibAnalyzer.h.

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

83 {
84  edm::Handle<Ref> refs;
85  evt.getByLabel(refs_, refs);
86 
87  edm::Handle<Rec> recs;
88  evt.getByLabel(recs_, recs);
89 
90  // do matching
91  std::map<unsigned int, unsigned int> matches=alg_(*refs, *recs);
92 
93  if( !matches.size()>0 )
94  edm::LogWarning ( "NoMatchOrBalance" )
95  << "No single match/balance found to any Rec object in collection";
96 
97  // fill comparison plots for matched jets
98  for(std::map<unsigned int, unsigned int>::const_iterator match=matches.begin();
99  match!=matches.end(); ++match){
100 
101  CompType cmp(type_);
102  double val=cmp((*refs)[match->first].pt(), (*recs)[match->second].pt());
103 
104  fill((*refs)[match->first].pt(), val, binsPt_, ktPt_ );// inclusive binned in pt
105  fill((*refs)[match->first].eta(), val, binsEta_, ktEta_);// inclusive binned in eta
106 
107  // differential in eta binned in pt
108  for(int idx=0; idx<((int)binsEta_.size()-1); ++idx)
109  if( (binsEta_[idx]<(*refs)[match->first].eta()) && ((*refs)[match->first].eta()<binsEta_[idx+1]) )
110  fill((*refs)[match->first].pt(), val, binsPt_, ktEtaPt_[idx] );
111  recVsRef_->Fill( TMath::Log10((*refs)[match->first].pt()), TMath::Log10((*recs)[match->second].pt()) );
112  }
113 }
edm::InputTag recs_
Definition: CalibAnalyzer.h:45
CompType
supported comparison types
std::vector< double > binsPt_
Definition: CalibAnalyzer.h:51
void fill(const double &var, const double &val, const std::vector< double > &bins, const std::vector< TH1F * > &hists)
std::vector< std::vector< TH1F * > > ktEtaPt_
Definition: CalibAnalyzer.h:61
std::vector< double > binsEta_
Definition: CalibAnalyzer.h:51
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
edm::InputTag refs_
Definition: CalibAnalyzer.h:46
TH2F * recVsRef_
Definition: CalibAnalyzer.h:55
std::vector< TH1F * > ktEta_
Definition: CalibAnalyzer.h:59
std::vector< TH1F * > ktPt_
Definition: CalibAnalyzer.h:57
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:6
template<typename Ref , typename Rec , typename Alg >
void CalibAnalyzer< Ref, Rec, Alg >::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 126 of file CalibAnalyzer.h.

References edm::errors::Configuration, edm::hlt::Exception, estimatePileup::hist, TFileDirectory::make(), and dbtoconf::out.

127 {
128  if( hist_.empty() )
129  return;
130 
132  if( !fs )
133  throw edm::Exception( edm::errors::Configuration, "TFile Service is not registered in cfg file" );
134 
135  ofstream hist(hist_.c_str(), std::ios::out);
136  NameScheme val("val"), fit("fit"), cal("cal"), res("res");
137 
138  // book additional control histograms
139  recVsRef_= fs->make<TH2F>( val.name("recVsRef"),val.name("recVsRef"), 20, 1., 3., 20, 1., 3.);
140 
141  // book kt histograms differential in pt
142  for(int idx=0; idx<((int)binsPt_.size()-1); ++idx)
143  ktPt_.push_back( fs->make<TH1F>(fit.name(hist, "ktPt",idx), fit.name("kt",idx), bins_, min_, max_) );
144  calPt_= fs->make<TH1F>(cal.name(hist, "ktPt"), cal.name("calPt"), ((int)binsPt_.size()-1), &binsPt_[0]);
145  resPt_= fs->make<TH1F>(res.name(hist, "ktPt"), res.name("resPt"), ((int)binsPt_.size()-1), &binsPt_[0]);
146 
147  // book kt histograms differential in eta
148  for(int jdx=0; jdx<((int)binsEta_.size()-1); ++jdx)
149  ktEta_.push_back(fs->make<TH1F>(fit.name(hist, "ktEta",jdx),fit.name("kt",jdx), bins_, min_, max_) );
150  calEta_= fs->make<TH1F>(cal.name(hist, "ktEta"), cal.name("calEta"), ((int)binsEta_.size()-1), &binsEta_[0]);
151  resEta_= fs->make<TH1F>(res.name(hist, "ktEta"), res.name("resEta"), ((int)binsEta_.size()-1), &binsEta_[0]);
152 
153  // book kt histograms differential in eta and pt
154  for(int jdx=0; jdx<((int)binsEta_.size()-1); ++jdx){
155  std::vector<TH1F*> buffer;
156  calEtaPt_.push_back(fs->make<TH1F>(cal.name(hist,"ktEtaPt",jdx), cal.name("calEtaPt",jdx), ((int)binsPt_.size()-1), &binsPt_[0]));
157  resEtaPt_.push_back(fs->make<TH1F>(res.name(hist,"ktEtaPt",jdx), res.name("resEtaPt",jdx), ((int)binsPt_.size()-1), &binsPt_[0]));
158  for(int idx=0; idx<((int)binsPt_.size()-1); ++idx)
159  buffer.push_back( fs->make<TH1F>(fit.name(hist, "ktEtaPt",jdx,idx), fit.name("ktEtaPt",jdx,idx), bins_, min_, max_) );
160  ktEtaPt_.push_back(buffer);
161  }
162 }
std::vector< double > binsPt_
Definition: CalibAnalyzer.h:51
std::string hist_
Definition: CalibAnalyzer.h:47
std::vector< TH1F * > calEtaPt_
Definition: CalibAnalyzer.h:60
std::vector< std::vector< TH1F * > > ktEtaPt_
Definition: CalibAnalyzer.h:61
std::vector< double > binsEta_
Definition: CalibAnalyzer.h:51
tuple out
Definition: dbtoconf.py:99
TH2F * recVsRef_
Definition: CalibAnalyzer.h:55
std::vector< TH1F * > ktEta_
Definition: CalibAnalyzer.h:59
std::vector< TH1F * > ktPt_
Definition: CalibAnalyzer.h:57
T * make() const
make new ROOT object
std::vector< TH1F * > resEtaPt_
Definition: CalibAnalyzer.h:60
template<typename Ref , typename Rec , typename Alg >
virtual void CalibAnalyzer< Ref, Rec, Alg >::endJob ( void  )
inlineprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 39 of file CalibAnalyzer.h.

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

39 { 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.

117 {
118  for(unsigned int idx=0; idx<(bins.size()-1); ++idx){
119  if( (bins[idx]<var) && (var<bins[idx+1]) ){
120  hists[idx]->Fill( val );
121  }
122  }
123 }

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