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