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