Skip to content

Commit

Permalink
added RunNumber as plot variable; minor changes to bintitles(add opti…
Browse files Browse the repository at this point in the history
…on to ommit cut); add: allow explicit xbin edges; add: logy option
  • Loading branch information
kirschen committed Mar 29, 2012
1 parent d9d4c81 commit 6de5d69
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 40 deletions.
2 changes: 2 additions & 0 deletions ControlPlots.cc
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ ControlPlotsFunction::Function ControlPlots::findJetTruthEventFunction(const std
//! \p type.
// -------------------------------------------------------------
ControlPlotsFunction::Function ControlPlots::findTwoJetsPtBalanceEventFunction(const std::string& varName, ControlPlotsConfig::CorrectionType type) const {
if( varName == "RunNumber" )
return &ControlPlotsFunction::twoJetsPtBalanceEventRunNumber;
if( varName == "Eta" )
return &ControlPlotsFunction::twoJetsPtBalanceEventJetEta;
if( varName == "AbsEta" )
Expand Down
88 changes: 55 additions & 33 deletions ControlPlotsConfig.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// $Id: ControlPlotsConfig.cc,v 1.23 2012/02/06 22:14:47 kirschen Exp $
// $Id: ControlPlotsConfig.cc,v 1.24 2012/02/09 16:41:51 kirschen Exp $

#include "ControlPlotsConfig.h"

Expand Down Expand Up @@ -41,7 +41,7 @@ std::string ControlPlotsConfig::binName(int binIdx) const {
//! This is used for the profile histogram title
//! and consists of "min < varTitle(binning) < max (unit)".
// --------------------------------------------------
std::string ControlPlotsConfig::binTitle(double min, double max) const {
std::string ControlPlotsConfig::binTitle(double min, double max, bool showCut) const {
std::string title = toString(min);
title += " #leq ";
title += varTitle(binVariable());
Expand All @@ -53,16 +53,18 @@ std::string ControlPlotsConfig::binTitle(double min, double max) const {
title += " " + unit;
}

if(cutVariable() != "") {
title += " and ";
title += toString(cutMin());
title += " #leq ";
title += varTitle(cutVariable());
title += " < ";
title += toString(cutMax());
std::string unit = unitTitle(cutVariable());
if( unit != "" ) {
title += " " + unit;
if(showCut){
if(cutVariable() != "") {
title += " and ";
title += toString(cutMin());
title += " #leq ";
title += varTitle(cutVariable());
title += " < ";
title += toString(cutMax());
std::string unit = unitTitle(cutVariable());
if( unit != "" ) {
title += " " + unit;
}
}
}

Expand All @@ -89,8 +91,8 @@ std::string ControlPlotsConfig::xBinName(int xBinIdx) const {
//! It is drawn on the histogram and consists of
//! "min < varTitle() < max (unit), xBinMin < varTitle(x) < xBinMax (unit)"
// --------------------------------------------------
std::string ControlPlotsConfig::xBinTitle(int xBinIdx, double binMin, double binMax) const {
std::string title = binTitle(binMin,binMax);
std::string ControlPlotsConfig::xBinTitle(int xBinIdx, double binMin, double binMax, bool showCut) const {
std::string title = binTitle(binMin,binMax,showCut);
if( xBinIdx >= 0 && xBinIdx < nXBins() ) {
title += ", ";
title += toString(round(xBinEdges_.at(xBinIdx)));
Expand Down Expand Up @@ -409,6 +411,7 @@ void ControlPlotsConfig::init() {
logX_ = true;
}
}
bool useDirectBinEdges=false;
double min = 20.;
double max = 100.;
std::vector<double> var = bag_of<double>(config_->read<std::string>(name_+" x edges","15 10 1000"));
Expand All @@ -418,20 +421,30 @@ void ControlPlotsConfig::init() {
max = var.at(2);
} else {
std::cerr << "WARNING: Wrong number of arguments in config line '" << name_ << " x edges'\n";
nXBins_ = 5;
}
xBinEdges_ = std::vector<double>(nXBins_+1);
if( logX_ ) {
if( !equidistLogBins(xBinEdges_,nXBins_,min,max) )
std::cerr << "ERROR creating equidistant logarithmic binning.\n";
} else {
double width = (max - min) / nXBins_;
for(int i = 0; i < nXBins_+1; i++) {
xBinEdges_.at(i) = min + width*i;
std::cerr << " Trying to take arguments as bin edges, instead.\n";
xBinEdges_ = bag_of<double>(config_->read<std::string>(name_+" x edges","0. 1."));
assert( xBinEdges_.size() > 1 );
for(size_t i = 1; i < xBinEdges_.size(); i++) {
assert( xBinEdges_.at(i) > xBinEdges_.at(i-1) );
}
nXBins_ = static_cast<int>(xBinEdges_.size())-1;
if(nXBins_>2)useDirectBinEdges=true;
else nXBins_ = 5;
}
for(int i = 0; i < nXBins_; i++) {
assert( xBinEdges_.at(i) < xBinEdges_.at(i+1) );
if(!useDirectBinEdges){
xBinEdges_ = std::vector<double>(nXBins_+1);
if( logX_ ) {
if( !equidistLogBins(xBinEdges_,nXBins_,min,max) )
std::cerr << "ERROR creating equidistant logarithmic binning.\n";
} else {
double width = (max - min) / nXBins_;
for(int i = 0; i < nXBins_+1; i++) {
xBinEdges_.at(i) = min + width*i;
}
}
for(int i = 0; i < nXBins_; i++) {
assert( xBinEdges_.at(i) < xBinEdges_.at(i+1) );
}
}

cutVar_ = config_->read<std::string>(name_+" cut variable","");
Expand Down Expand Up @@ -477,9 +490,14 @@ void ControlPlotsConfig::init() {
}
}
yBinEdges_ = std::vector<double>(nYBins_+1);
double width = (max - min) / nYBins_;
for(int i = 0; i < nYBins_+1; i++) {
yBinEdges_.at(i) = min + width*i;
if( logY_ ) {
if( !equidistLogBins(yBinEdges_,nYBins_,min,max) )
std::cerr << "ERROR creating equidistant logarithmic binning.\n";
} else {
double width = (max - min) / nXBins_;
for(int i = 0; i < nXBins_+1; i++) {
xBinEdges_.at(i) = min + width*i;
}
}
for(int i = 0; i < nYBins_; i++) {
assert( yBinEdges_.at(i) < yBinEdges_.at(i+1) );
Expand Down Expand Up @@ -695,13 +713,17 @@ std::string ControlPlotsConfig::varTitle(const std::string &varName) const {
else if( varName == "VtxN")
title = "Reconstructed vertices";
else if( varName == "PF_CH_Fraction")
title = "PF charged hadron fraction";
title = "Charged hadrons";
// title = "PF charged hadron fraction";
else if( varName == "PF_NH_Fraction")
title = "PF neutral hadron fraction";
title = "Neutral hadrons";
// title = "PF neutral hadron fraction";
else if( varName == "PF_PH_Fraction")
title = "PF photon fraction";
title = "Photons";
/// title = "PF photon fraction";
else if( varName == "PF_EL_Fraction")
title = "PF electron fraction";
title = "Electrons";
// title = "PF electron fraction";
else if( varName == "DeltaPhi")
title = "#Delta #varphi_{1,2}";

Expand Down
15 changes: 11 additions & 4 deletions ControlPlotsConfig.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// $Id: ControlPlotsConfig.h,v 1.11 2012/01/24 16:26:37 kirschen Exp $
// $Id: ControlPlotsConfig.h,v 1.12 2012/02/09 16:41:51 kirschen Exp $

#ifndef CONTROLPLOTS_CONFIG_H
#define CONTROLPLOTS_CONFIG_H
Expand Down Expand Up @@ -56,7 +56,7 @@ class ConfigFile;
//!
//! \author Matthias Schroeder
//! \date 2009/12/18
//! $Id: ControlPlotsConfig.h,v 1.11 2012/01/24 16:26:37 kirschen Exp $
//! $Id: ControlPlotsConfig.h,v 1.12 2012/02/09 16:41:51 kirschen Exp $
// ----------------------------------------------------------------
class ControlPlotsConfig {
public:
Expand Down Expand Up @@ -102,13 +102,17 @@ class ControlPlotsConfig {
//! Returns the name of the bin
std::string binName(int binIdx) const;
//! Returns the title of the bin
std::string binTitle(double min, double max) const;
std::string binTitle(double min, double max, bool showCut=true) const;
//! Returns the title of the bin used for axis
std::string binAxisTitle() const { return axisTitle(binVariable()); }
//! Returns the name of the cut variable
std::string cutVariable() const { return cutVar_; }
//! Returns the minimum of the cut range
double cutMin() const { return cutEdges_.first; }
//! Returns the maximum of the cut range
double cutMax() const { return cutEdges_.second; }
//! Returns the title of the cut used for axis
std::string cutAxisTitle() const { return axisTitle(cutVariable()); }

//! Returns the bin edges of the x variable
const std::vector<double> *xBinEdges() const { return &xBinEdges_; }
Expand All @@ -125,9 +129,11 @@ class ControlPlotsConfig {
//! Returns the name of the x bin
std::string xBinName(int xBinIdx) const;
//! Returns the title of the x bin
std::string xBinTitle(int xBinIdx, double binMin, double binMax) const;
std::string xBinTitle(int xBinIdx, double binMin, double binMax, bool showCut=true) const;
//! Specifies whether there is logarithmic binning of the x axis
bool logX() const { return logX_; }
//! Specifies whether there is logarithmic binning of the y axis. Beware: often does not make sense for profiles
bool logY() const { return logY_; }

//! Returns the bin edges of the y variable
const std::vector<double> *yBinEdges() const { return &yBinEdges_; }
Expand Down Expand Up @@ -221,6 +227,7 @@ class ControlPlotsConfig {
std::vector<double> xBinEdges_;
int nXBins_;
bool logX_;
bool logY_;

std::string cutVar_;
std::pair<double,double> cutEdges_;
Expand Down
13 changes: 12 additions & 1 deletion ControlPlotsFunction.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// $Id: ControlPlotsFunction.cc,v 1.24 2012/02/06 22:14:47 kirschen Exp $
// $Id: ControlPlotsFunction.cc,v 1.25 2012/02/09 16:41:51 kirschen Exp $

#include "ControlPlotsFunction.h"

Expand Down Expand Up @@ -239,6 +239,17 @@ double ControlPlotsFunction::jetTruthEventResponseL2L3ResL4Corrected(const Event
}


//! \brief Returns run number uf the Event
//!
//! The \p Event \p evt has to be of type \p TwoJetsPtBalanceEvent.
//! Implements \p Function.
// ----------------------------------------------------------------
double ControlPlotsFunction::twoJetsPtBalanceEventRunNumber(const Event *evt) const {
const TwoJetsPtBalanceEvent * jte = static_cast<const TwoJetsPtBalanceEvent*>(evt);
return jte->runNumber();
}


//! \brief Returns #eta of the jet
//!
//! The \p Event \p evt has to be of type \p TwoJetsPtBalanceEvent.
Expand Down
5 changes: 3 additions & 2 deletions ControlPlotsFunction.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// $Id: ControlPlotsFunction.h,v 1.22 2012/02/06 22:14:47 kirschen Exp $
// $Id: ControlPlotsFunction.h,v 1.23 2012/02/09 16:41:51 kirschen Exp $

#ifndef CONTROLPLOTS_FUNCTION_H
#define CONTROLPLOTS_FUNCTION_H
Expand All @@ -24,7 +24,7 @@ class Event;
//!
//! \author Matthias Schroeder
//! \date 2009/12/18
//! $Id: ControlPlotsFunction.h,v 1.22 2012/02/06 22:14:47 kirschen Exp $
//! $Id: ControlPlotsFunction.h,v 1.23 2012/02/09 16:41:51 kirschen Exp $
// ----------------------------------------------------------------
class ControlPlotsFunction {
public:
Expand Down Expand Up @@ -79,6 +79,7 @@ class ControlPlotsFunction {
double jetTruthEventResponseL2L3L4Corrected(const Event * evt) const;
double jetTruthEventResponseL2L3ResL4Corrected(const Event * evt) const;

double twoJetsPtBalanceEventRunNumber(const Event *evt) const;
double twoJetsPtBalanceEventJetEta(const Event *evt) const;
double twoJetsPtBalanceEventJetAbsEta(const Event *evt) const;
double twoJetsPtBalanceEventJetPt(const Event *evt) const;
Expand Down

0 comments on commit 6de5d69

Please sign in to comment.