CMS 3D CMS Logo

trackSplitPlot.h
Go to the documentation of this file.
1 #ifndef TRACKSPLITPLOT_H
2 #define TRACKSPLITPLOT_H
3 
4 #include <fstream>
5 #include <iostream>
6 #include <sstream>
7 #include <cmath>
8 #include "TCanvas.h"
9 #include "TClass.h"
10 #include "TColor.h"
11 #include "TFile.h"
12 #include "TGaxis.h"
13 #include "TGraph2DErrors.h"
14 #include "TGraphErrors.h"
15 #include "TH1.h"
16 #include "TH1F.h"
17 #include "TH2F.h"
18 #include "TLegend.h"
19 #include "TLegendEntry.h"
20 #include "TList.h"
21 #include "TMath.h"
22 #include "TMultiGraph.h"
23 #include "TObject.h"
24 #include "TProfile.h"
25 #include "TROOT.h"
26 #include "TString.h"
27 #include "TStyle.h"
28 #include "TSystem.h"
29 #include "TText.h"
30 #include "TTree.h"
31 
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 ofstream devnull("/dev/null");
71 template<typename T> T identity(T t) {return t;}
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 = "", ostream& summaryfile=devnull);
80 TCanvas *trackSplitPlot(Int_t nFiles,TString *files,TString *names,TString var,
81  Bool_t relative = false,Bool_t pull = false,TString saveas = "", ostream& summaryfile=devnull);
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 = "", ostream& summaryfile=devnull);
85 TCanvas *trackSplitPlot(TString file,TString var,
86  Bool_t relative = false,Bool_t pull = false,
87  TString saveas = "", ostream& summaryfile=devnull);
88 void placeholder(TString saveas = "",Bool_t wide = false);
89 void saveplot(TCanvas *c1,TString saveas);
90 void deleteCanvas(TObject *canvas);
91 void setupcolors();
92 void runNumberZoomed(Int_t nFiles,TString *files,TString *names,TString yvar,
93  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
94  Int_t firstRun = -1,Int_t lastRun = -1,TString saveas = "");
95 
96 //==========================
97 //1. Misalignment Dependence
98 //==========================
99 
100 void misalignmentDependence(TCanvas *c1old,
101  Int_t nFiles,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
102  TF1 *function,Int_t parameter,TString parametername = "",TString functionname = "",
103  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
104  TString saveas = "");
105 void misalignmentDependence(TCanvas *c1old,
106  Int_t nFiles,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
107  TF1 *function,Int_t nParameters,Int_t *parameters,TString *parameternames,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 parameter,TString parametername = "",TString functionname = "",
112  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
113  TString saveas = "");
114 void misalignmentDependence(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
115  TF1 *function,Int_t nParameters,Int_t *parameters,TString *parameternames,TString functionname = "",
116  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
117  TString saveas = "");
118 void misalignmentDependence(TCanvas *c1old,
119  Int_t nFiles,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
120  TString function,Int_t parameter,TString parametername = "",TString functionname = "",
121  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
122  TString saveas = "");
123 void misalignmentDependence(TCanvas *c1old,
124  Int_t nFiles,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
125  TString function,Int_t nParameters,Int_t *parameters,TString *parameternames,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 parameter,TString parametername = "",TString functionname = "",
130  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
131  TString saveas = "");
132 void misalignmentDependence(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
133  TString function,Int_t nParameters,Int_t *parameters,TString *parameternames,TString functionname = "",
134  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
135  TString saveas = "");
136 Bool_t misalignmentDependence(TCanvas *c1old,
137  Int_t nFiles,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 misalignmentDependence(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString xvar,TString yvar,
142  Bool_t drawfits = true,
143  Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false,
144  TString saveas = "");
145 Bool_t hasFit(TString misalignment,TString xvar,TString yvar,Bool_t relative = false,Bool_t resolution = false,Bool_t pull = false);
146 
147 
148 //=============
149 //2. Make Plots
150 //=============
151 
152 void makePlots(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString directory,Bool_t matrix[xsize][ysize]);
153 void makePlots(Int_t nFiles,TString *files,TString *names,TString directory, Bool_t matrix[xsize][ysize]);
154 void makePlots(TString file,TString misalignment,Double_t *values,Double_t *phases,TString directory,Bool_t matrix[xsize][ysize]);
155 void makePlots(TString file,TString directory,Bool_t matrix[xsize][ysize]);
156 void makePlots(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString directory,TString xvar,TString yvar);
157 void makePlots(Int_t nFiles,TString *files,TString *names,TString directory,TString xvar,TString yvar);
158 void makePlots(TString file,TString misalignment,Double_t *values,Double_t *phases,TString directory,
159  TString xvar,TString yvar);
160 void makePlots(TString file,TString directory,TString xvar,TString yvar);
161 void makePlots(Int_t nFiles,TString *files,TString *names,TString misalignment,Double_t *values,Double_t *phases,TString directory);
162 void makePlots(Int_t nFiles,TString *files,TString *names,TString directory);
163 void makePlots(TString file,TString misalignment,Double_t *values,Double_t *phases,TString directory);
164 void makePlots(TString file,TString directory);
165 
166 //=============
167 //3. Axis Label
168 //=============
169 
170 TString fancyname(TString variable);
171 TString units(TString variable,Char_t axis);
172 TString plainunits(TString variable,Char_t axis);
173 TString latexunits(TString variable,Char_t axis);
174 TString axislabel(TString variable, Char_t axis, Bool_t relative = false, Bool_t resolution = false, Bool_t pull = false);
175 TString latexlabel(TString variable, Char_t axis, Bool_t relative = false, Bool_t resolution = false, Bool_t pull = false);
176 void setAxisLabels(TH1 *p, PlotType type,TString xvar,TString yvar,Bool_t relative,Bool_t pull);
177 void setAxisLabels(TMultiGraph *p, PlotType type,TString xvar,TString yvar,Bool_t relative,Bool_t pull);
178 TString nPart(Int_t part,TString string,TString delimit = ";",Bool_t removerest = true);
179 
180 //==============
181 //4. Axis Limits
182 //==============
183 
184 Double_t findStatistic(Statistic what,Int_t nFiles,TString *files,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
185 Double_t findAverage(Int_t nFiles,TString *files,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
186 Double_t findMin(Int_t nFiles,TString *files,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
187 Double_t findMax(Int_t nFiles,TString *files,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
188 Double_t findRMS(Int_t nFiles,TString *files,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
189 Double_t findStatistic(Statistic what,TString file,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
190 Double_t findAverage(TString file,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
191 Double_t findMin(TString file,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
192 Double_t findMax(TString file,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
193 Double_t findRMS(TString file,TString var,Char_t axis,Bool_t relative = false,Bool_t pull = false);
194 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);
195 
196 //===============
197 //5. Place Legend
198 //===============
199 
200 Double_t placeLegend(TLegend *l, Double_t width, Double_t height, Double_t x1min, Double_t y1min, Double_t x2max, Double_t y2max);
201 Bool_t fitsHere(TLegend *l,Double_t x1, Double_t y1, Double_t x2, Double_t y2);
202 
203 #endif
Minimum
Definition: trackSplitPlot.h:34
svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
dataset.firstRun
firstRun
Definition: dataset.py:940
ScatterPlot
Definition: trackSplitPlot.h:33
Histogram
Definition: trackSplitPlot.h:33
Maximum
Definition: trackSplitPlot.h:34
ApeEstimator_cff.width
width
Definition: ApeEstimator_cff.py:24
findMin
Double_t findMin(Int_t nFiles, TString *files, TString var, Char_t axis, Bool_t relative=false, Bool_t pull=false)
Statistic
Statistic
Definition: trackSplitPlot.h:34
trackSplitPlot
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="", ostream &summaryfile=devnull)
hasFit
Bool_t hasFit(TString misalignment, TString xvar, TString yvar, Bool_t relative=false, Bool_t resolution=false, Bool_t pull=false)
latexlabel
TString latexlabel(TString variable, Char_t axis, Bool_t relative=false, Bool_t resolution=false, Bool_t pull=false)
devnull
ofstream devnull("/dev/null")
colors
vector< Color_t > colors
Definition: trackSplitPlot.h:37
makeMuonMisalignmentScenario.matrix
list matrix
Definition: makeMuonMisalignmentScenario.py:141
stufftodelete
TList * stufftodelete
Definition: trackSplitPlot.h:52
plainunits
TString plainunits(TString variable, Char_t axis)
colorsset
bool colorsset
Definition: trackSplitPlot.h:39
findStatistic
Double_t findStatistic(Statistic what, Int_t nFiles, TString *files, TString var, Char_t axis, Bool_t relative=false, Bool_t pull=false)
phases
std::vector< int > phases
Definition: compareAlignments.cc:30
min
T min(T a, T b)
Definition: MathUtil.h:58
testProducerWithPsetDescEmpty_cfi.x2
x2
Definition: testProducerWithPsetDescEmpty_cfi.py:28
outliercut
double outliercut
Definition: trackSplitPlot.h:55
findRMS
Double_t findRMS(Int_t nFiles, TString *files, TString var, Char_t axis, Bool_t relative=false, Bool_t pull=false)
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
SiStripBadComponentsDQMServiceTemplate_cfg.lastRun
lastRun
Definition: SiStripBadComponentsDQMServiceTemplate_cfg.py:27
xvariables
TString xvariables[xsize]
Definition: trackSplitPlot.h:48
ysize
const Int_t ysize
Definition: trackSplitPlot.h:43
OrgHistogram
Definition: trackSplitPlot.h:33
setupcolors
void setupcolors()
xsize
const Int_t xsize
Definition: trackSplitPlot.h:42
setAxisLabels
void setAxisLabels(TH1 *p, PlotType type, TString xvar, TString yvar, Bool_t relative, Bool_t pull)
tools.TF1
TF1
Definition: tools.py:23
makePlots
void makePlots(Int_t nFiles, TString *files, TString *names, TString misalignment, Double_t *values, Double_t *phases, TString directory, Bool_t matrix[xsize][ysize])
parameters
parameters
Definition: BeamSpot_PayloadInspector.cc:14
units
TString units(TString variable, Char_t axis)
trigObjTnPSource_cfi.var
var
Definition: trigObjTnPSource_cfi.py:21
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
testProducerWithPsetDescEmpty_cfi.y1
y1
Definition: testProducerWithPsetDescEmpty_cfi.py:29
part
part
Definition: HCALResponse.h:20
parameter
Definition: vlib.h:168
MainPageGenerator.files
files
Definition: MainPageGenerator.py:256
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:122
minrun
Int_t minrun
Definition: trackSplitPlot.h:40
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
relativeConstraints.relative
relative
Definition: relativeConstraints.py:78
L1TObjectsTimingClient_cff.resolution
resolution
Definition: L1TObjectsTimingClient_cff.py:52
legendGrid
Int_t legendGrid
Definition: trackSplitPlot.h:44
OrderedSet.t
t
Definition: OrderedSet.py:90
saveplot
void saveplot(TCanvas *c1, TString saveas)
fancyname
TString fancyname(TString variable)
RMS
Definition: trackSplitPlot.h:34
fitsHere
Bool_t fitsHere(TLegend *l, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
nPart
TString nPart(Int_t part, TString string, TString delimit=";", Bool_t removerest=true)
PostProcessor_cff.profile
profile
Definition: PostProcessor_cff.py:38
testProducerWithPsetDescEmpty_cfi.y2
y2
Definition: testProducerWithPsetDescEmpty_cfi.py:30
Resolution
Definition: trackSplitPlot.h:33
yvariables
TString yvariables[ysize]
Definition: trackSplitPlot.h:49
increaseby
Double_t increaseby
Definition: trackSplitPlot.h:46
placeholder
void placeholder(TString saveas="", Bool_t wide=false)
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
placeLegend
Double_t placeLegend(TLegend *l, Double_t width, Double_t height, Double_t x1min, Double_t y1min, Double_t x2max, Double_t y2max)
axislimits
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)
maxrun
Int_t maxrun
Definition: trackSplitPlot.h:41
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
alignmentValidation.c1
c1
do drawing
Definition: alignmentValidation.py:1025
trackSplitPlot.h
styles
vector< Style_t > styles
Definition: trackSplitPlot.h:38
latexunits
TString latexunits(TString variable, Char_t axis)
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:193
identity
T identity(T t)
Definition: trackSplitPlot.h:71
Profile
Definition: trackSplitPlot.h:33
taus_updatedMVAIds_cff.variable
variable
Definition: taus_updatedMVAIds_cff.py:32
type
type
Definition: HCALResponse.h:21
axislabel
TString axislabel(TString variable, Char_t axis, Bool_t relative=false, Bool_t resolution=false, Bool_t pull=false)
runNumberZoomed
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="")
T
long double T
Definition: Basic3DVectorLD.h:48
findAverage
Double_t findAverage(Int_t nFiles, TString *files, TString var, Char_t axis, Bool_t relative=false, Bool_t pull=false)
createBeamHaloJobs.directory
string directory
Definition: createBeamHaloJobs.py:211
relativearray
Bool_t relativearray[ysize]
Definition: trackSplitPlot.h:50
cmsBatch.nFiles
nFiles
Definition: cmsBatch.py:308
Pi
const double Pi
Definition: CosmicMuonParameters.h:18
pi
const Double_t pi
Definition: trackSplitPlot.h:36
Average
Definition: trackSplitPlot.h:34
trigObjTnPSource_cfi.bins
bins
Definition: trigObjTnPSource_cfi.py:20
PlotType
PlotType
Definition: trackSplitPlot.h:33
deleteCanvas
void deleteCanvas(TObject *canvas)
findMax
Double_t findMax(Int_t nFiles, TString *files, TString var, Char_t axis, Bool_t relative=false, Bool_t pull=false)
margin
Double_t margin
Definition: trackSplitPlot.h:45
misalignmentDependence
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="")
subdetector
TString subdetector
Definition: trackSplitPlot.h:54