1 #ifndef CalibAnalyzer_h
2 #define CalibAnalyzer_h
27 template <
typename Ref,
typename Rec,
typename Alg>
41 void fill(
const double& var,
const double& val,
const std::vector<double>& bins,
const std::vector<TH1F*>& hists);
66 template <
typename Ref,
typename Rec,
typename Alg>
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" ) ),
81 template <
typename Ref,
typename Rec,
typename Alg>
91 std::map<unsigned int, unsigned int> matches=alg_(*refs, *recs);
93 if( !matches.size()>0 )
95 <<
"No single match/balance found to any Rec object in collection";
98 for(std::map<unsigned int, unsigned int>::const_iterator
match=matches.begin();
102 double val=cmp((*refs)[
match->first].pt(), (*recs)[
match->second].pt());
104 fill((*refs)[
match->first].pt(), val, binsPt_, ktPt_ );
105 fill((*refs)[
match->first].eta(), val, binsEta_, ktEta_);
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()) );
115 template <
typename Ref,
typename Rec,
typename Alg>
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 );
125 template <
typename Ref,
typename Rec,
typename Alg>
136 NameScheme val(
"val"), fit(
"fit"), cal(
"cal"), res(
"res");
139 recVsRef_= fs->
make<TH2F>( val.name(
"recVsRef"),val.name(
"recVsRef"), 20, 1., 3., 20, 1., 3.);
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]);
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]);
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);
std::vector< double > binsPt_
std::vector< TH1F * > calEtaPt_
void fill(const double &var, const double &val, const std::vector< double > &bins, const std::vector< TH1F * > &hists)
std::vector< std::vector< TH1F * > > ktEtaPt_
std::vector< double > binsEta_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
CalibAnalyzer(const edm::ParameterSet &)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
std::vector< TH1F * > ktEta_
std::vector< TH1F * > ktPt_
T * make() const
make new ROOT object
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
std::vector< TH1F * > resEtaPt_