DESY Hbb Analysis Framework
mssm_xs_tools.cc
Go to the documentation of this file.
2 #include <iostream>
3 
4 
5 mssm_xs_tools::mssm_xs_tools(const char* filename, bool kINT, unsigned verbosity) : verbosity_(verbosity), kINTERPOL_(kINT){
6  if(verbosity>99){
7  std::cout << "Welcome to the MSSM neutral cross section tool (v1.0). In case of questions contact:"
8  << std::endl
9  << " Allison Mc Carn / ATLAS (allison.renae.mc.carn@cern.ch)," << std::endl
10  << " Trevor Vickey / ATLAS (trevor.vickey@cern.ch), " << std::endl
11  << " Felix Frensch / CMS (felix.frensch@cern.ch) " << std::endl
12  << " Roger Wolf / CMS (roger.wolf@cern.ch), " << std::endl
13  << " Stefan Liebler / Theory (stefan.liebler@desy.de), " << std::endl
14  << " Michael Spira / Theory (michael.spira@psi.ch), " << std::endl
15  << " Pietro Slavich / Theory (slavich@lpthe.jussieu.fr). " << std::endl;
16 
17  }
18  if(!filename){
19  std::cout << "Chose input file using the method mssm_xs_tools::setup()" << std::endl;
20  }
21  else{
22  input_ = new TFile(filename);
23  }
24 }
25 
26 void
27 mssm_xs_tools::setup(const char* filename){
28  /* ______________________________________________________________________________________________
29  * If not available, yet open input file from full path specified in [filename]. If input_ does
30  * already point to a file nothing is done. This quarantees that only one file can be opened for
31  * one instance of the class.
32  */
33  if(!input_){
34  input_ = new TFile(filename);
35  }
36  return;
37 }
38 
39 std::string
40 mssm_xs_tools::br_rule(const char* decay){
41  /* ______________________________________________________________________________________________
42  * Function argument [decay] expected to be of special form (e.g. "A->tautau"). Search for
43  * deliminator "->" required to be present in [decay]. Split argument: first block corresponds to
44  * building block [BOSON], second block to building block [DECAY]. Prefix histogram name with
45  * "br", append [BOSON], append [DECAY], separated by "_" (histogram name in example above:
46  * "br_A_tautau").
47  */
48  std::string name;
49  std::string source(decay);
50  if(source.find("->")!=std::string::npos){
51  name = std::string("br")+"_"+source.substr(0, source.find("->"))+"_"+source.substr(source.find("->")+2);
52  }
53  return name;
54 }
55 
56 std::string
57 mssm_xs_tools::width_rule(const char* boson){
58  /* ______________________________________________________________________________________________
59  * Function agrument [boson] expected to be of special form (e.g. "H"). Function argument
60  * corresponds to building block [BOSON] of histogram name. Prefix histogram name with
61  * "width", append [BOSON], separated by "_" (histgoram name in example above: "width_H");
62  */
63  return std::string("width")+"_"+std::string(boson);
64 }
65 
66 std::string
67 mssm_xs_tools::xsec_rule(const char* mode){
68  /* ______________________________________________________________________________________________
69  * Function argument [mode] expected to be of special form (e.g. "gg->A::scaleUp"); "->" and "::"
70  * are deliminators of building blocks; "->" is required to be present, while"::" is optional.
71  * Search for deliminators "->" (required to be present) and "::" (optional) in [mode]. Split
72  * argument: first block corresponds to [PROD], second block to [BOSON], the third block (option-
73  * al) to [UNCERT]. Prefix histogram name with "xs", append [PROD], append [BOSON], append
74  * [UNCERT] if available, seperated by "_" (histogram name in example above: "xs_gg_A_scaleUp").
75  */
76  std::string source(mode);
77  std::string process = source.find("->")!=std::string::npos ? source.substr(0, source.find("->")) : std::string();
78  std::string uncert = source.find("::")!=std::string::npos ? source.substr(source.rfind("::")+2) : std::string();
79  std::string boson = source.substr(source.find("->")+2, source.rfind("::")-(source.find("->")+2));
80  std::string name;
81  if(!process.empty()){
82  name = std::string("xs")+"_"+process+"_"+boson+(uncert.empty()? uncert : std::string("_")+uncert);
83  }
84  return name;
85 }
86 
87 std::string
88 mssm_xs_tools::mass_rule(const char* boson){
89  /* ______________________________________________________________________________________________
90  * Function agrument [boson] expected to be of special form (e.g. "H"). Function argument corres-
91  * ponds to building block [BOSON] of histogram name. Prefix histogram name with "m", append
92  * [BOSON], seperated by "_" (histgoram name in example above: "m_H");
93  */
94  return std::string("m")+"_"+std::string(boson);
95 }
96 
97 TH2F*
98 mssm_xs_tools::hist(std::string histname){
99  /* ______________________________________________________________________________________________
100  * Check if a histogram with name [histname] is already on stack. If so return historam. If not
101  * try to get a histogram with name [histname] from the input file, cast to TH2F*; add histogram
102  * on stack with key [histogramname]. If getting the histogram from the input file was not
103  * successful issue a WARNING and return a NULL pointer. For verbosity_>2 issue MESSAGE that a
104  * histogram with name [histname] has been read from the input file upon successful completion.
105  * Save histogram on stack for future use. Return pointer to histogram.
106  */
107  if(hists_.find(histname) == hists_.end()){
108  // hist not on stack; read from file; if it fails return NULL.
109  hists_[std::string(histname)] = (TH2F*) input_->Get(histname.c_str());
110  //std::cout << "* " << hists_[std::string(histname)]->GetName() << std::endl;
111  if(!hists_.find(histname)->second){
112  std::cout << "WARNING: required histogram "
113  << "[" << histname << "] "
114  << "does not exist in input file "
115  << "[" << input_->GetName() << "]"
116  << std::endl
117  << " "
118  << "return NULL..."
119  << std::endl;
120  return NULL;
121  }
122  else{
123  // cash maximal number of bins on x- (mA) and y- (tanb) axis of TH2F,
124  // used to define the boundaries of the histogram when running in
125  // interpolation mode
126  nbinsX_ = hists_.find(histname)->second->GetXaxis()->GetNbins();
127  nbinsY_ = hists_.find(histname)->second->GetYaxis()->GetNbins();
128  if(verbosity_>2){
129  std::cout << "MESSAGE: read histogram "
130  << "[" << histname << "] "
131  << "from input file "
132  << "[" << input_->GetName() << "]"
133  << std::endl;
134  }
135  }
136  }
137  return hists_.find(histname)->second;
138 }
std::string br_rule(const char *br)
rule to determine histogram names related to branching fractions in the input file ...
std::map< std::string, TH2F * > hists_
histogram container (filled in constructor)
void setup(const char *filename)
open input file to access histograms (only needed if input file was not specified in the constructor)...
TFile * input_
root input file (opened in constructor)
TH2F * hist(std::string name)
a save way to access a histogram from the stack; returns NULL if histogram does not exist on stack ...
std::string mass_rule(const char *b)
rule to determine histogram names related to masses in the input file
std::string xsec_rule(const char *xs)
rule to determine histogram names related to cross sections in the input file
unsigned verbosity_
verbosity level
mssm_xs_tools(const char *filename="", bool kINTERPLOTATION=false, unsigned verbosity=0)
constructor
Definition: mssm_xs_tools.cc:5
std::string width_rule(const char *b)
rule to determine histogram names related to full decay widths in the input file