CMS 3D CMS Logo

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 
34 
35 const Double_t pi = TMath::Pi();
36 vector<Color_t> colors;
37 vector<Style_t> styles;
38 bool colorsset = false;
39 Int_t minrun = -1;
40 Int_t maxrun = -1;
41 const Int_t xsize = 8;
42 const Int_t ysize = 9;
43 Int_t legendGrid = 100;
44 Double_t margin = .1;
45 Double_t increaseby = .1;
46 
47 TString xvariables[xsize] = {"", "pt", "eta", "phi", "dz", "dxy", "theta", "qoverpt"};
48 TString yvariables[ysize] = {"pt", "pt", "eta", "phi", "dz", "dxy", "theta", "qoverpt", ""};
49 Bool_t relativearray[ysize] = {true, false, false, false, false, false, false, false, false};
50 
51 TList *stufftodelete = new TList();
52 
53 TString subdetector = "PIXEL";
54 double outliercut = 0.99; //use the middle 99% of tracks to find the mean and RMS
55  //(a few tracks are fit badly and skew them otherwise)
56 
57 /***********************************
58 Table Of Contents
59 0. Track Split Plot
60 1. Misalignment Dependence
61 2. Make Plots
62 3. Axis Label
63 4. Axis Limits
64 5. Place Legend
65 ***********************************/
66 
67 #include "trackSplitPlot.h"
68 
69 //===================
70 //0. Track Split Plot
71 //===================
72 
73 TCanvas *trackSplitPlot(Int_t nFiles,TString *files,TString *names,TString xvar,TString yvar,
74  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
75  TString saveas = "");
76 TCanvas *trackSplitPlot(Int_t nFiles,TString *files,TString *names,TString var,
77  Bool_t relative = false,Bool_t pull = false,TString saveas = "");
78 TCanvas *trackSplitPlot(TString file,TString xvar,TString yvar,Bool_t profile = false,
79  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
80  TString saveas = "");
81 TCanvas *trackSplitPlot(TString file,TString var,
82  Bool_t relative = false,Bool_t pull = false,
83  TString saveas = "");
84 void placeholder(TString saveas = "",Bool_t wide = false);
85 void saveplot(TCanvas *c1,TString saveas);
86 void deleteCanvas(TObject *canvas);
87 void setupcolors();
88 void runNumberZoomed(Int_t nFiles,TString *files,TString *names,TString yvar,
89  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
90  Int_t firstRun = -1,Int_t lastRun = -1,TString saveas = "");
91 
92 //==========================
93 //1. Misalignment Dependence
94 //==========================
95 
96 void misalignmentDependence(TCanvas *c1old,
97  Int_t nFiles,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
98  TF1 *function,Int_t parameter,TString parametername = "",TString functionname = "",
99  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
100  TString saveas = "");
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 nParameters,Int_t *parameters,TString *parameternames,TString functionname = "",
104  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
105  TString saveas = "");
106 void misalignmentDependence(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
107  TF1 *function,Int_t parameter,TString parametername = "",TString functionname = "",
108  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
109  TString saveas = "");
110 void misalignmentDependence(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
111  TF1 *function,Int_t nParameters,Int_t *parameters,TString *parameternames,TString functionname = "",
112  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
113  TString saveas = "");
114 void misalignmentDependence(TCanvas *c1old,
115  Int_t nFiles,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
116  TString function,Int_t parameter,TString parametername = "",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 nParameters,Int_t *parameters,TString *parameternames,TString functionname = "",
122  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
123  TString saveas = "");
124 void misalignmentDependence(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
125  TString function,Int_t parameter,TString parametername = "",TString functionname = "",
126  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
127  TString saveas = "");
128 void misalignmentDependence(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
129  TString function,Int_t nParameters,Int_t *parameters,TString *parameternames,TString functionname = "",
130  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
131  TString saveas = "");
132 Bool_t misalignmentDependence(TCanvas *c1old,
133  Int_t nFiles,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
134  Bool_t drawfits = true,
135  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
136  TString saveas = "");
137 Bool_t misalignmentDependence(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
138  Bool_t drawfits = true,
139  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
140  TString saveas = "");
141 Bool_t hasFit(TString misalignment,TString xvar,TString yvar,Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false);
142 
143 
144 //=============
145 //2. Make Plots
146 //=============
147 
148 void makePlots(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString directory,Bool_t matrix[xsize][ysize]);
149 void makePlots(Int_t nFiles,TString *files,TString *names,TString directory, Bool_t matrix[xsize][ysize]);
150 void makePlots(TString file,TString misalignment,Double_t *values,Double_t *phases,TString directory,Bool_t matrix[xsize][ysize]);
151 void makePlots(TString file,TString directory,Bool_t matrix[xsize][ysize]);
152 void makePlots(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString directory,TString xvar,TString yvar);
153 void makePlots(Int_t nFiles,TString *files,TString *names,TString directory,TString xvar,TString yvar);
154 void makePlots(TString file,TString misalignment,Double_t *values,Double_t *phases,TString directory,
155  TString xvar,TString yvar);
156 void makePlots(TString file,TString directory,TString xvar,TString yvar);
157 void makePlots(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString directory);
158 void makePlots(Int_t nFiles,TString *files,TString *names,TString directory);
159 void makePlots(TString file,TString misalignment,Double_t *values,Double_t *phases,TString directory);
160 void makePlots(TString file,TString directory);
161 
162 //=============
163 //3. Axis Label
164 //=============
165 
166 TString fancyname(TString variable);
167 TString units(TString variable,Char_t axis);
168 TString axislabel(TString variable, Char_t axis, Bool_t relative = false, Bool_t resolution = false, Bool_t pull = false);
169 void setAxisLabels(TH1 *p, PlotType type,TString xvar,TString yvar,Bool_t relative,Bool_t pull);
170 void setAxisLabels(TMultiGraph *p, PlotType type,TString xvar,TString yvar,Bool_t relative,Bool_t pull);
171 TString nPart(Int_t part,TString string,TString delimit = ";",Bool_t removerest = true);
172 
173 //==============
174 //4. Axis Limits
175 //==============
176 
177 Double_t findStatistic(Statistic what,Int_t nFiles,TString *files,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
178 Double_t findAverage(Int_t nFiles,TString *files,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
179 Double_t findMin(Int_t nFiles,TString *files,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
180 Double_t findMax(Int_t nFiles,TString *files,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
181 Double_t findRMS(Int_t nFiles,TString *files,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
182 Double_t findStatistic(Statistic what,TString file,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
183 Double_t findAverage(TString file,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
184 Double_t findMin(TString file,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
185 Double_t findMax(TString file,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
186 Double_t findRMS(TString file,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
187 void axislimits(Int_t nFiles,TString *files,TString var,Char_t axis,Bool_t relative,Bool_t pull,Double_t &min,Double_t &max,Double_t &bins);
188 
189 //===============
190 //5. Place Legend
191 //===============
192 
193 Double_t placeLegend(TLegend *l, Double_t width, Double_t height, Double_t x1min, Double_t y1min, Double_t x2max, Double_t y2max);
194 Bool_t fitsHere(TLegend *l,Double_t x1, Double_t y1, Double_t x2, Double_t y2);
195 
196 #endif
TString yvariables[ysize]
const double Pi
type
Definition: HCALResponse.h:21
TList * stufftodelete
Double_t increaseby
TString xvariables[xsize]
double outliercut
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[]
void axislimits(Int_t nFiles, TString *files, TString var, Char_t axis, Bool_t relative, Bool_t pull, Double_t &min, Double_t &max, Double_t &bins)
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)
void deleteCanvas(TObject *canvas)
Int_t maxrun
const Int_t ysize
TString fancyname(TString variable)
const Double_t pi
void setAxisLabels(TH1 *p, PlotType type, TString xvar, TString yvar, Bool_t relative, Bool_t pull)
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="")
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 saveplot(TCanvas *c1, TString saveas)
TString nPart(Int_t part, TString string, TString delimit=";", Bool_t removerest=true)
std::vector< int > phases
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)
TString units(TString variable, Char_t axis)
Bool_t relativearray[ysize]
bool colorsset
Bool_t fitsHere(TLegend *l, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
def canvas(sub, attr)
Definition: svgfig.py:481
firstRun
Definition: dataset.py:924
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)
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)
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="")