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 TString subdetector = "PIXEL";
61 
62 /***********************************
63 Table Of Contents
64 0. Track Split Plot
65 1. Misalignment Dependence
66 2. Make Plots
67 3. Axis Label
68 4. Axis Limits
69 5. Place Legend
70 6. TDR Style
71 ***********************************/
72 
73 #include "trackSplitPlot.h"
74 
75 //===================
76 //0. Track Split Plot
77 //===================
78 
79 TCanvas *trackSplitPlot(Int_t nFiles,TString *files,TString *names,TString xvar,TString yvar,
80  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
81  TString saveas = "");
82 TCanvas *trackSplitPlot(Int_t nFiles,TString *files,TString *names,TString var,
83  Bool_t relative = false,Bool_t pull = false,TString saveas = "");
84 TCanvas *trackSplitPlot(TString file,TString xvar,TString yvar,Bool_t profile = false,
85  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
86  TString saveas = "");
87 TCanvas *trackSplitPlot(TString file,TString var,
88  Bool_t relative = false,Bool_t pull = false,
89  TString saveas = "");
90 void placeholder(TString saveas = "",Bool_t wide = false);
91 void saveplot(TCanvas *c1,TString saveas);
92 void deleteCanvas(TObject *canvas);
93 void runNumberZoomed(Int_t nFiles,TString *files,TString *names,TString yvar,
94  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
95  Int_t firstRun = -1,Int_t lastRun = -1,TString saveas = "");
96 
97 //==========================
98 //1. Misalignment Dependence
99 //==========================
100 
101 void misalignmentDependence(TCanvas *c1old,
102  Int_t nFiles,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
103  TF1 *function,Int_t parameter,TString parametername = "",TString functionname = "",
104  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
105  TString saveas = "");
106 void misalignmentDependence(TCanvas *c1old,
107  Int_t nFiles,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
108  TF1 *function,Int_t nParameters,Int_t *parameters,TString *parameternames,TString functionname = "",
109  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
110  TString saveas = "");
111 void misalignmentDependence(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
112  TF1 *function,Int_t parameter,TString parametername = "",TString functionname = "",
113  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
114  TString saveas = "");
115 void misalignmentDependence(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
116  TF1 *function,Int_t nParameters,Int_t *parameters,TString *parameternames,TString functionname = "",
117  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
118  TString saveas = "");
119 void misalignmentDependence(TCanvas *c1old,
120  Int_t nFiles,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
121  TString function,Int_t parameter,TString parametername = "",TString functionname = "",
122  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
123  TString saveas = "");
124 void misalignmentDependence(TCanvas *c1old,
125  Int_t nFiles,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
126  TString function,Int_t nParameters,Int_t *parameters,TString *parameternames,TString functionname = "",
127  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
128  TString saveas = "");
129 void misalignmentDependence(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
130  TString function,Int_t parameter,TString parametername = "",TString functionname = "",
131  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
132  TString saveas = "");
133 void misalignmentDependence(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
134  TString function,Int_t nParameters,Int_t *parameters,TString *parameternames,TString functionname = "",
135  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
136  TString saveas = "");
137 Bool_t misalignmentDependence(TCanvas *c1old,
138  Int_t nFiles,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
139  Bool_t drawfits = true,
140  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
141  TString saveas = "");
142 Bool_t misalignmentDependence(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
143  Bool_t drawfits = true,
144  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
145  TString saveas = "");
146 Bool_t hasFit(TString misalignment,TString xvar,TString yvar,Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false);
147 
148 
149 //=============
150 //2. Make Plots
151 //=============
152 
153 void makePlots(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString directory,Bool_t matrix[xsize][ysize]);
154 void makePlots(Int_t nFiles,TString *files,TString *names,TString directory, Bool_t matrix[xsize][ysize]);
155 void makePlots(TString file,TString misalignment,Double_t *values,Double_t *phases,TString directory,Bool_t matrix[xsize][ysize]);
156 void makePlots(TString file,TString directory,Bool_t matrix[xsize][ysize]);
157 void makePlots(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString directory,TString xvar,TString yvar);
158 void makePlots(Int_t nFiles,TString *files,TString *names,TString directory,TString xvar,TString yvar);
159 void makePlots(TString file,TString misalignment,Double_t *values,Double_t *phases,TString directory,
160  TString xvar,TString yvar);
161 void makePlots(TString file,TString directory,TString xvar,TString yvar);
162 void makePlots(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString directory);
163 void makePlots(Int_t nFiles,TString *files,TString *names,TString directory);
164 void makePlots(TString file,TString misalignment,Double_t *values,Double_t *phases,TString directory);
165 void makePlots(TString file,TString directory);
166 
167 //=============
168 //3. Axis Label
169 //=============
170 
171 TString fancyname(TString variable);
172 TString units(TString variable,Char_t axis);
173 TString axislabel(TString variable, Char_t axis, Bool_t relative = false, Bool_t resolution = false, Bool_t pull = false);
174 void setAxisLabels(TH1 *p, PlotType type,TString xvar,TString yvar,Bool_t relative,Bool_t pull);
175 void setAxisLabels(TMultiGraph *p, PlotType type,TString xvar,TString yvar,Bool_t relative,Bool_t pull);
176 TString nPart(Int_t part,TString string,TString delimit = ";",Bool_t removerest = true);
177 
178 //==============
179 //4. Axis Limits
180 //==============
181 
182 Double_t findStatistic(Statistic what,Int_t nFiles,TString *files,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
183 Double_t findAverage(Int_t nFiles,TString *files,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
184 Double_t findMin(Int_t nFiles,TString *files,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
185 Double_t findMax(Int_t nFiles,TString *files,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
186 Double_t findRMS(Int_t nFiles,TString *files,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
187 Double_t findStatistic(Statistic what,TString file,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
188 Double_t findAverage(TString file,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
189 Double_t findMin(TString file,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
190 Double_t findMax(TString file,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
191 Double_t findRMS(TString file,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
192 void axislimits(Int_t nFiles,TString *files,TString var,Char_t axis,Bool_t relative,Bool_t pull,Double_t &min,Double_t &max);
193 
194 //===============
195 //5. Place Legend
196 //===============
197 
198 Double_t placeLegend(TLegend *l, Double_t width, Double_t height, Double_t x1min, Double_t y1min, Double_t x2max, Double_t y2max);
199 Bool_t fitsHere(TLegend *l,Double_t x1, Double_t y1, Double_t x2, Double_t y2);
200 
201 //============
202 //6. TDR Style
203 //============
204 
205 void setTDRStyle();
206 void set_plot_style();
207 void setupcolors();
208 
209 #endif
TString yvariables[ysize]
const double Pi
type
Definition: HCALResponse.h:21
TList * stufftodelete
Double_t increaseby
TString xvariables[xsize]
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
TString subdetector
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:861
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
tuple nFiles
Definition: cmsBatch.py:306
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="")