DESY Hbb Analysis Framework
Functions | Variables
plotscomp_config.h File Reference
#include "boost/program_options.hpp"
#include "boost/algorithm/string.hpp"
#include <string>
#include <iostream>
#include <fstream>
#include <vector>

Go to the source code of this file.

Functions

int plotscomp_config (int argc, char *argv[])
 

Variables

bool app_
 
std::string file1_
 
std::string file2_
 
std::string file_
 
std::vector< std::string > files_
 
std::string hist1_
 
std::string hist2_
 
std::string hist_
 
std::vector< std::string > histos_
 
std::string legend1_
 
std::string legend2_
 
bool logx_
 
bool logy_
 
float max_
 
float min_
 
std::string outplot_
 
float scale_
 
std::string title_
 
std::vector< std::string > titles_
 

Function Documentation

int plotscomp_config ( int  argc,
char *  argv[] 
)

Definition at line 44 of file plotscomp_config.h.

References app_, file1_, file2_, file_, files_, hist1_, hist2_, hist_, histos_, legend1_, legend2_, logx_, logy_, max_, min_, outplot_, scale_, title_, and titles_.

Referenced by main().

45 {
46  app_ = true;
47  logx_ = false;
48  logy_ = false;
49  try
50  {
51  namespace po = boost::program_options;
52  po::options_description desc("Options");
53  desc.add_options()
54  ("help,h" , "Show help messages")
55  ("bkg,b" , "Run in the background")
56  ("logx" , "x-axis in log scale")
57  ("logy" , "y-axis in log scale")
58  ("files" , po::value<std::vector<std::string> >(&files_)->multitoken(),"list of files")
59  ("histos" , po::value<std::vector<std::string> >(&histos_)->multitoken(),"list of histograms")
60  ("titles" , po::value<std::vector<std::string> >(&titles_)->multitoken(),"titles of histograms")
61  ("title,t" , po::value <std::string> (&title_) -> default_value("") , "Title of the histogram")
62  ("legend1" , po::value <std::string> (&legend1_)-> default_value("histo 1") , "Legend of the histogram 1")
63  ("legend2" , po::value <std::string> (&legend2_)-> default_value("histo 2") , "Legend of the histogram 2")
64  ("scale,s" , po::value <float> (&scale_) -> default_value(1) , "Scale factor for the 2nd histogram")
65  ("min" , po::value <float> (&min_) -> default_value(-1) , "Min value histogram range")
66  ("max" , po::value <float> (&max_) -> default_value(-2) , "Max value histogram range")
67  ("file,f" , po::value <std::string> (&file_) -> default_value("") , "File with up to 2 histograms to compare")
68  ("hist1" , po::value <std::string> (&hist1_ ) -> default_value("") , "1st histogram name in file")
69  ("hist2" , po::value <std::string> (&hist2_ ) -> default_value("") , "2nd histogram name in file")
70  ("hist,h" , po::value <std::string> (&hist_) -> default_value("") , "Histogram name common to the different files")
71  ("file1" , po::value <std::string> (&file1_) -> default_value("") , "1st file with 1 histogram to compare")
72  ("file2" , po::value <std::string> (&file2_) -> default_value("") , "2nd file with 1 histogram to compare")
73  ("output" , po::value <std::string> (&outplot_)-> default_value("") , "name of the output plot");
74 
75 // ("config,c",po::value<std::string>(&cfg_),"Configuration file name");
76 
77 // po::options_description config("Configuration");
78 // config.add_options()
79 // ("file",po::value <std::string> (&file_) ->default_value(""),"File with up to 2 histograms to compare")
80 // ("hist",po::value <std::string> (&hist_) ->default_value(""),"Histogram name common to the different files");
81 
82  po::variables_map vm;
83  try
84  {
85  po::store(po::parse_command_line(argc, argv, desc), vm); // can throw
86  // --help option
87 
88  if ( vm.count("help") )
89  {
90  std::cout << "PlotsCompare macro" << std::endl
91  << desc << std::endl;
92 // << config << std::endl;
93  return 1;
94  }
95  if ( vm.count("logx") ) logx_ = true;
96  if ( vm.count("logy") ) logy_ = true;
97  if ( vm.count("bkg") ) app_ = false;
98 
99  po::notify(vm);
100 
101 // std::ifstream cfg_s(cfg_.c_str());
102 // po::store(po::parse_config_file(cfg_s, config), vm); // can throw
103 // if ( vm.count("config") )
104 // {
105 //
106 // }
107  po::notify(vm);
108  }
109  catch(po::error& e)
110  {
111  std::cerr << "ERROR: " << e.what() << std::endl << std::endl;
112  std::cerr << desc << std::endl;
113  return -1;
114  }
115 
116  }
117  catch(std::exception& e)
118  {
119  std::cerr << "ERROR: " << e.what() << std::endl << std::endl;
120  return -1;
121  }
122 
123  return 0;
124 }
std::vector< std::string > titles_
std::vector< std::string > histos_
std::string hist1_
std::string file1_
float min_
std::string file2_
std::string legend2_
std::string title_
std::string legend1_
std::string outplot_
std::string file_
std::string hist_
float max_
bool app_
float scale_
std::string hist2_
bool logx_
std::vector< std::string > files_
bool logy_

Variable Documentation

bool app_

Definition at line 40 of file plotscomp_config.h.

Referenced by main(), and plotscomp_config().

std::string file1_

Definition at line 25 of file plotscomp_config.h.

Referenced by main(), and plotscomp_config().

std::string file2_

Definition at line 26 of file plotscomp_config.h.

Referenced by main(), and plotscomp_config().

std::string file_

Definition at line 20 of file plotscomp_config.h.

Referenced by main(), and plotscomp_config().

std::vector<std::string> files_

Definition at line 16 of file plotscomp_config.h.

Referenced by plotscomp_config().

std::string hist1_

Definition at line 21 of file plotscomp_config.h.

Referenced by main(), and plotscomp_config().

std::string hist2_

Definition at line 22 of file plotscomp_config.h.

Referenced by main(), and plotscomp_config().

std::string hist_

Definition at line 24 of file plotscomp_config.h.

Referenced by main(), and plotscomp_config().

std::vector<std::string> histos_

Definition at line 17 of file plotscomp_config.h.

Referenced by plotscomp_config().

std::string legend1_

Definition at line 29 of file plotscomp_config.h.

Referenced by main(), and plotscomp_config().

std::string legend2_

Definition at line 30 of file plotscomp_config.h.

Referenced by main(), and plotscomp_config().

bool logx_

Definition at line 38 of file plotscomp_config.h.

Referenced by main(), plot_ratio(), and plotscomp_config().

bool logy_

Definition at line 39 of file plotscomp_config.h.

Referenced by draw_legend(), main(), plot_ratio(), and plotscomp_config().

float max_

Definition at line 34 of file plotscomp_config.h.

Referenced by main(), and plotscomp_config().

float min_

Definition at line 34 of file plotscomp_config.h.

Referenced by main(), and plotscomp_config().

std::string outplot_

Definition at line 32 of file plotscomp_config.h.

Referenced by main(), and plotscomp_config().

float scale_

Definition at line 36 of file plotscomp_config.h.

Referenced by main(), and plotscomp_config().

std::string title_

Definition at line 28 of file plotscomp_config.h.

Referenced by main(), and plotscomp_config().

std::vector<std::string> titles_

Definition at line 18 of file plotscomp_config.h.

Referenced by plotscomp_config().