CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
trackSplitPlot.h
Go to the documentation of this file.
1 #ifndef TRACKSPLITPLOT_H
2 #define TRACKSPLITPLOT_H
3 
4 #include <iostream>
5 #include <sstream>
6 #include <cmath>
7 #include "TCanvas.h"
8 #include "TClass.h"
9 #include "TColor.h"
10 #include "TFile.h"
11 #include "TGaxis.h"
12 #include "TGraph2DErrors.h"
13 #include "TGraphErrors.h"
14 #include "TH1.h"
15 #include "TH1F.h"
16 #include "TH2F.h"
17 #include "TLegend.h"
18 #include "TLegendEntry.h"
19 #include "TList.h"
20 #include "TMath.h"
21 #include "TMultiGraph.h"
22 #include "TObject.h"
23 #include "TProfile.h"
24 #include "TROOT.h"
25 #include "TString.h"
26 #include "TStyle.h"
27 #include "TSystem.h"
28 #include "TText.h"
29 #include "TTree.h"
30 
31 using namespace std;
32 
35 
36 const Double_t pi = TMath::Pi();
37 vector<Color_t> colors;
38 vector<Style_t> styles;
39 bool styleset = false;
40 Int_t minrun = -1;
41 Int_t maxrun = -1;
42 const Int_t xsize = 10;
43 const Int_t ysize = 9;
44 Int_t legendGrid = 100;
45 Double_t margin = .1;
46 Double_t increaseby = .1;
47 Int_t binsScatterPlotx = 1000;
48 Int_t binsScatterPloty = 1000;
49 Int_t binsHistogram = 100;
50 Int_t runNumberBins = 30;
51 Int_t binsProfileResolution = 30; //for everything but runNumber and nHits
52  //(nHits gets a bin for each integer between the minimum and the maximum)
53 
54 TString xvariables[xsize] = {"pt", "eta", "phi", "dz", "dxy", "theta", "qoverpt", "runNumber","nHits",""};
55 TString yvariables[ysize] = {"pt", "pt", "eta", "phi", "dz", "dxy", "theta", "qoverpt", ""};
56 Bool_t relativearray[ysize] = {true, false, false, false, false, false, false, false, false};
57 
58 TList *stufftodelete = new TList();
59 
60 /***********************************
61 Table Of Contents
62 0. Track Split Plot
63 1. Misalignment Dependence
64 2. Make Plots
65 3. Axis Label
66 4. Axis Limits
67 5. Place Legend
68 6. TDR Style
69 ***********************************/
70 
71 #include "trackSplitPlot.h"
72 
73 //===================
74 //0. Track Split Plot
75 //===================
76 
77 TCanvas *trackSplitPlot(Int_t nFiles,TString *files,TString *names,TString xvar,TString yvar,
78  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
79  TString saveas = "");
80 TCanvas *trackSplitPlot(Int_t nFiles,TString *files,TString *names,TString var,
81  Bool_t relative = false,Bool_t pull = false,TString saveas = "");
82 TCanvas *trackSplitPlot(TString file,TString xvar,TString yvar,Bool_t profile = false,
83  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
84  TString saveas = "");
85 TCanvas *trackSplitPlot(TString file,TString var,
86  Bool_t relative = false,Bool_t pull = false,
87  TString saveas = "");
88 void placeholder(TString saveas = "",Bool_t wide = false);
89 void saveplot(TCanvas *c1,TString saveas);
90 void deleteCanvas(TObject *canvas);
91 void runNumberZoomed(Int_t nFiles,TString *files,TString *names,TString yvar,
92  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
93  Int_t firstRun = -1,Int_t lastRun = -1,TString saveas = "");
94 
95 //==========================
96 //1. Misalignment Dependence
97 //==========================
98 
99 void misalignmentDependence(TCanvas *c1old,
100  Int_t nFiles,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
101  TF1 *function,Int_t parameter,TString parametername = "",TString functionname = "",
102  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
103  TString saveas = "");
104 void misalignmentDependence(TCanvas *c1old,
105  Int_t nFiles,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
106  TF1 *function,Int_t nParameters,Int_t *parameters,TString *parameternames,TString functionname = "",
107  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
108  TString saveas = "");
109 void misalignmentDependence(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
110  TF1 *function,Int_t parameter,TString parametername = "",TString functionname = "",
111  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
112  TString saveas = "");
113 void misalignmentDependence(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
114  TF1 *function,Int_t nParameters,Int_t *parameters,TString *parameternames,TString functionname = "",
115  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
116  TString saveas = "");
117 void misalignmentDependence(TCanvas *c1old,
118  Int_t nFiles,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
119  TString function,Int_t parameter,TString parametername = "",TString functionname = "",
120  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
121  TString saveas = "");
122 void misalignmentDependence(TCanvas *c1old,
123  Int_t nFiles,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
124  TString function,Int_t nParameters,Int_t *parameters,TString *parameternames,TString functionname = "",
125  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
126  TString saveas = "");
127 void misalignmentDependence(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
128  TString function,Int_t parameter,TString parametername = "",TString functionname = "",
129  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
130  TString saveas = "");
131 void misalignmentDependence(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
132  TString function,Int_t nParameters,Int_t *parameters,TString *parameternames,TString functionname = "",
133  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
134  TString saveas = "");
135 Bool_t misalignmentDependence(TCanvas *c1old,
136  Int_t nFiles,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
137  Bool_t drawfits = true,
138  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
139  TString saveas = "");
140 Bool_t misalignmentDependence(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
141  Bool_t drawfits = true,
142  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
143  TString saveas = "");
144 Bool_t hasFit(TString misalignment,TString xvar,TString yvar,Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false);
145 
146 
147 //=============
148 //2. Make Plots
149 //=============
150 
151 void makePlots(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString directory,Bool_t matrix[xsize][ysize]);
152 void makePlots(Int_t nFiles,TString *files,TString *names,TString directory, Bool_t matrix[xsize][ysize]);
153 void makePlots(TString file,TString misalignment,Double_t *values,Double_t *phases,TString directory,Bool_t matrix[xsize][ysize]);
154 void makePlots(TString file,TString directory,Bool_t matrix[xsize][ysize]);
155 void makePlots(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString directory,TString xvar,TString yvar);
156 void makePlots(Int_t nFiles,TString *files,TString *names,TString directory,TString xvar,TString yvar);
157 void makePlots(TString file,TString misalignment,Double_t *values,Double_t *phases,TString directory,
158  TString xvar,TString yvar);
159 void makePlots(TString file,TString directory,TString xvar,TString yvar);
160 void makePlots(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString directory);
161 void makePlots(Int_t nFiles,TString *files,TString *names,TString directory);
162 void makePlots(TString file,TString misalignment,Double_t *values,Double_t *phases,TString directory);
163 void makePlots(TString file,TString directory);
164 
165 //=============
166 //3. Axis Label
167 //=============
168 
169 TString fancyname(TString variable);
170 TString units(TString variable,Char_t axis);
171 TString axislabel(TString variable, Char_t axis, Bool_t relative = false, Bool_t resolution = false, Bool_t pull = false);
172 void setAxisLabels(TH1 *p, PlotType type,TString xvar,TString yvar,Bool_t relative,Bool_t pull);
173 void setAxisLabels(TMultiGraph *p, PlotType type,TString xvar,TString yvar,Bool_t relative,Bool_t pull);
174 TString nPart(Int_t part,TString string,TString delimit = ";",Bool_t removerest = true);
175 
176 //==============
177 //4. Axis Limits
178 //==============
179 
180 Double_t findStatistic(Statistic what,Int_t nFiles,TString *files,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
181 Double_t findAverage(Int_t nFiles,TString *files,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
182 Double_t findMin(Int_t nFiles,TString *files,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
183 Double_t findMax(Int_t nFiles,TString *files,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
184 Double_t findRMS(Int_t nFiles,TString *files,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
185 Double_t findStatistic(Statistic what,TString file,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
186 Double_t findAverage(TString file,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
187 Double_t findMin(TString file,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
188 Double_t findMax(TString file,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
189 Double_t findRMS(TString file,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
190 void axislimits(Int_t nFiles,TString *files,TString var,Char_t axis,Bool_t relative,Bool_t pull,Double_t &min,Double_t &max);
191 
192 //===============
193 //5. Place Legend
194 //===============
195 
196 Double_t placeLegend(TLegend *l, Double_t width, Double_t height, Double_t x1min, Double_t y1min, Double_t x2max, Double_t y2max);
197 Bool_t fitsHere(TLegend *l,Double_t x1, Double_t y1, Double_t x2, Double_t y2);
198 
199 //============
200 //6. TDR Style
201 //============
202 
203 void setTDRStyle();
204 void set_plot_style();
205 void setupcolors();
206 
207 #endif
TString yvariables[ysize]
const double Pi
type
Definition: HCALResponse.h:21
TList * stufftodelete
Double_t increaseby
TString xvariables[xsize]
dictionary parameters
Definition: Parameters.py:2
Double_t findStatistic(Statistic what, Int_t nFiles, TString *files, TString var, Char_t axis, Bool_t relative=false, Bool_t pull=false)
static const HistoName names[]
vector< Style_t > styles
PlotType
Double_t findRMS(Int_t nFiles, TString *files, TString var, Char_t axis, Bool_t relative=false, Bool_t pull=false)
bool styleset
void deleteCanvas(TObject *canvas)
string firstRun
Definition: dataset.py:789
Int_t maxrun
const Int_t ysize
Int_t binsScatterPloty
TString fancyname(TString variable)
def canvas
Definition: svgfig.py:481
const Double_t pi
void setAxisLabels(TH1 *p, PlotType type, TString xvar, TString yvar, Bool_t relative, Bool_t pull)
Int_t binsScatterPlotx
vector< Color_t > colors
void placeholder(TString saveas="", Bool_t wide=false)
void runNumberZoomed(Int_t nFiles, TString *files, TString *names, TString yvar, Bool_t relative=false, Bool_t resolution=false, Bool_t pull=false, Int_t firstRun=-1, Int_t lastRun=-1, TString saveas="")
void set_plot_style()
Int_t minrun
Double_t margin
TCanvas * trackSplitPlot(Int_t nFiles, TString *files, TString *names, TString xvar, TString yvar, Bool_t relative=false, Bool_t resolution=false, Bool_t pull=false, TString saveas="")
T min(T a, T b)
Definition: MathUtil.h:58
void axislimits(Int_t nFiles, TString *files, TString var, Char_t axis, Bool_t relative, Bool_t pull, Double_t &min, Double_t &max)
void saveplot(TCanvas *c1, TString saveas)
TString nPart(Int_t part, TString string, TString delimit=";", Bool_t removerest=true)
Double_t findMin(Int_t nFiles, TString *files, TString var, Char_t axis, Bool_t relative=false, Bool_t pull=false)
part
Definition: HCALResponse.h:20
Statistic
Bool_t hasFit(TString misalignment, TString xvar, TString yvar, Bool_t relative=false, Bool_t resolution=false, Bool_t pull=false)
void setTDRStyle()
Definition: plotscripts.py:87
TString units(TString variable, Char_t axis)
Bool_t relativearray[ysize]
Bool_t fitsHere(TLegend *l, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Int_t runNumberBins
const Int_t xsize
Double_t placeLegend(TLegend *l, Double_t width, Double_t height, Double_t x1min, Double_t y1min, Double_t x2max, Double_t y2max)
Double_t findMax(Int_t nFiles, TString *files, TString var, Char_t axis, Bool_t relative=false, Bool_t pull=false)
Int_t binsProfileResolution
void setupcolors()
void makePlots(Int_t nFiles, TString *files, TString *names, TString misalignment, Double_t *values, Double_t *phases, TString directory, Bool_t matrix[xsize][ysize])
Int_t legendGrid
TString axislabel(TString variable, Char_t axis, Bool_t relative=false, Bool_t resolution=false, Bool_t pull=false)
Double_t findAverage(Int_t nFiles, TString *files, TString var, Char_t axis, Bool_t relative=false, Bool_t pull=false)
Int_t binsHistogram
void misalignmentDependence(TCanvas *c1old, Int_t nFiles, TString *names, TString misalignment, Double_t *values, Double_t *phases, TString xvar, TString yvar, TF1 *function, Int_t parameter, TString parametername="", TString functionname="", Bool_t relative=false, Bool_t resolution=false, Bool_t pull=false, TString saveas="")