-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathControlPlotsConfig.h
257 lines (226 loc) · 10.1 KB
/
ControlPlotsConfig.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
// $Id: ControlPlotsConfig.h,v 1.10 2011/04/01 10:23:49 kirschen Exp $
#ifndef CONTROLPLOTS_CONFIG_H
#define CONTROLPLOTS_CONFIG_H
#include <cmath>
#include <map>
#include <string>
#include <vector>
#include "TObject.h"
class ConfigFile;
//! \brief Reads parameters for profile plots from configuration
//! file and defines centrally labels and axes titles etc.
//!
//! This class stores what variables are plotted in the profile
//! plots, what jet energy correction types are applied and
//! what profile types are created.
//!
//! Furthermore, it defines key words which are to be used in the
//! configuration file to define e.g.
//! - what variables are plotted
//! - what jet energy corrections are applied
//! - what profile types are created.
//! The class also defines for each key word string representations
//! which can be used in histogram titles, legends etc.
//!
//! Possible key words of axis and binning variables are
//! - Eta
//! - GenJetPt
//! - GenJetResponse
//!
//! Possible key words for jet energy correction types are
//! - Uncorrected
//! - Kalibri
//! - L2L3
//! - L2L3Res
//! - L2L3L4
//! - L2L3ResL4
//!
//! Possible key words for profile types are
//! - Mean
//! - StandardDeviation
//! - GaussFitMean
//! - GaussFitWidth
//! - Median
//! - IQMean
//! - Chi2
//! - Probability
//! - Quantiles
//!
//! \sa \p ControlPlotsProfile
//!
//! \author Matthias Schroeder
//! \date 2009/12/18
//! $Id: ControlPlotsConfig.h,v 1.10 2011/04/01 10:23:49 kirschen Exp $
// ----------------------------------------------------------------
class ControlPlotsConfig {
public:
//! Different jet energy correction types
enum CorrectionType { Uncorrected, Kalibri, L2L3, L2L3Res, L2L3L4, L2L3ResL4 };
typedef std::vector<CorrectionType>::const_iterator CorrectionTypeIt;
typedef std::pair<int,CorrectionType> InputTag;
typedef std::vector<InputTag>::const_iterator InputTagsIterator;
//! Number of defined profile types
static const int nProfileTypes = 12;
//! Different types of profile histograms
enum ProfileType { Mean=0, StandardDeviation, GaussFitMean, GaussFitWidth, Median, IQMean, Chi2, Probability, Quantiles, RatioOfMeans, RatioOfGaussFitMeans, RatioOfIQMeans};
typedef std::vector<ProfileType>::const_iterator ProfileTypeIt;
ControlPlotsConfig(const ConfigFile *configFile, const std::string &name);
//! Returns the profile's name
std::string name() const { return name_; }
//! Return name of root file for export
std::string outRootFileName() const {return outRootFileName_; }
//! Set name of root file for export
void setOutRootFileName(std::string outRootFileName);// const{ outRootFileName_=outRootFileName;}
//! Returns the bin edges of the binning variable
const std::vector<double> *binEdges() const { return &binEdges_; }
//! Returns the number of bins
int nBins() const { return nBins_; }
//! Returns the minimum of the binning range
double min() const { return binEdges_.front(); }
//! Returns the maximum of the binning range
double max() const { return binEdges_.back(); }
//! Returns the name of the binning variable
std::string binVariable() const { return binVar_; }
//! 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;
//! 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 bin edges of the x variable
const std::vector<double> *xBinEdges() const { return &xBinEdges_; }
//! Returns the number of x bins
int nXBins() const { return nXBins_; }
//! Returns the minimum of the x range
double xMin() const { return xBinEdges_.front(); }
//! Returns the maximum of the x range
double xMax() const { return xBinEdges_.back(); }
//! Returns the name of the x variable
std::string xVariable() const { return xVar_; }
//! Returns the title of the x axis
std::string xTitle() const { return axisTitle(xVariable()); }
//! 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;
//! Specifies whether there is logarithmic binning of the x axis
bool logX() const { return logX_; }
//! Returns the bin edges of the y variable
const std::vector<double> *yBinEdges() const { return &yBinEdges_; }
//! Returns the number of y bins
int nYBins() const { return nYBins_; }
//! Returns the minimum of the y range
double yMin() const { return yBinEdges_.front(); }
//! Returns the maximum of the y range
double yMax() const { return yBinEdges_.back(); }
//! Returns the zoomed minimum of the y range
double yMinZoom(ProfileType profType) const {
std::map<ProfileType,double>::const_iterator i = yMinZoom_.find(profType);
return i->second;
}
//! Returns the zoomed maximum of the y range
double yMaxZoom(ProfileType profType) const {
std::map<ProfileType,double>::const_iterator i = yMaxZoom_.find(profType);
return i->second;
}
//! Returns the name of the y variable
std::string yVariable() const { return yVar_; }
//! Returns the title of the y axis
std::string yTitle() const { return axisTitle(yVariable()); }
//! Returns the title of the profile's y axis depending on the \p ProfileType \p type
std::string yProfileTitle(ProfileType type) const;
//! Returns the marker and line color for the \p InputTag \p tag
int color(const InputTag& tag) const;
//! Returns the marker style for the \p InputTag \p tag
int markerStyle(const InputTag& tag) const;
//! Returns a legend label for the \p InputTag \p tag
std::string legendLabel(const InputTag& tag) const;
//! Returns the correction types for which profiles are to be plotted
const std::vector<InputTag> *inputTags() const { return &inputTags_; }
//! Returns an iterator to the first correction type to be plotted
InputTagsIterator inputTagsBegin() const { return inputTags_.begin(); }
//! Returns an iterator to the last correction type to be plotted
InputTagsIterator inputTagsEnd() const { return inputTags_.end(); }
//! Specifies whether the y distributions per x bin are to be drawn
bool drawDistributions() const { return ! inputTagsDistributions_.empty(); }
//! Returns the input tags for which y distributions are to be plotted
const std::vector<InputTag> *distributionInputTags() const { return &inputTagsDistributions_; }
//! Returns an iterator to the first correction type to be plotted
InputTagsIterator distributionInputTagsBegin() const { return inputTagsDistributions_.begin(); }
//! Returns an iterator to the last correction type to be plotted
InputTagsIterator distributionInputTagsEnd() const { return inputTagsDistributions_.end(); }
//! Returns the \p CorrectionType for a given correction type name
CorrectionType correctionType(const std::string &typeName) const;
//! Returns the name of a given \p CorrectionType
std::string correctionTypeName(CorrectionType corrType) const;
//! Returns the name of a given \p Sample
std::string sampleName(int sample) const;
//! Returns the name of a given \p InputTag
std::string inputTagName(const InputTag& tag) const;
//! Returns the profile types which are to be drawn
const std::vector<ProfileType> *profileTypes() const { return &profTypes_; }
//! Returns an iterator to the first profile type to be drawn
ProfileTypeIt profileTypesBegin() const { return profTypes_.begin(); }
//! Returns an iterator to the last profile type to be drawn
ProfileTypeIt profileTypesEnd() const { return profTypes_.end(); }
//! Returns the \p ProfileType for a given profile type name
ProfileType profileType(const std::string &typeName) const;
//! Returns the profile type name for a given \p ProfileType
std::string profileTypeName(ProfileType profType) const;
//! Returns the name of the directory in which the control plots are stored
std::string outDirName() const { return outDirName_; }
//! Returns the file ending ("eps") of the control plots
std::string outFileType() const { return outFileType_; }
//! Specifies whether the plots are only saved in a root-file.
bool outOnlyRoot() const { return outOnlyRoot_; }
//! Specifies whether X and Y projections of all 2D-histos are created and written out.
bool outXYProjections() const { return outXYProjections_; }
//! Writes a \p obj to ROOT file
void toRootFile(TObject *obj) const;
private:
const ConfigFile *config_;
const std::string name_;
std::string binVar_;
std::vector<double> binEdges_;
int nBins_;
std::string xVar_;
std::vector<double> xBinEdges_;
int nXBins_;
bool logX_;
std::string cutVar_;
std::pair<double,double> cutEdges_;
std::string yVar_;
std::vector<double> yBinEdges_;
int nYBins_;
std::map<ProfileType,double> yMinZoom_;
std::map<ProfileType,double> yMaxZoom_;
std::map<int,std::string> sampleNames_;
std::vector<InputTag> inputTags_;
std::vector<InputTag> inputTagsDistributions_;
std::vector<ProfileType> profTypes_;
std::string outRootFileName_;
std::string outDirName_;
std::string outFileType_;
bool outOnlyRoot_;
bool outXYProjections_;
std::map<InputTag,int> colors_;
std::map<InputTag,int> markerStyles_;
std::map<InputTag,std::string> legendLabels_;
//! Read parameter values from configuration file
void init();
//! Create a binning with equal bin sizes in logarithmic scale
bool equidistLogBins(std::vector<double>& bins, int nBins, double first, double last) const;
//! Returns the histogram axis title for a variable \p varName
std::string axisTitle(const std::string &varName) const;
//! Returns the unit for a variable \p varName
std::string unitTitle(const std::string &varName) const;
//! Returns the variable name as it appears in axis titles etc for \p varName
std::string varTitle(const std::string &varName) const;
double round(double x) const { return (x > 0.5) ? ceil(x) : floor(x); }
template <class T> std::string toString(const T& t) const;
};
#endif