Go to the documentation of this file.00001 #include "Validation/DTRecHits/interface/utils.h"
00002 #include "TF1.h"
00003 #include "TProfile.h"
00004
00005 void Tutils::drawGFit(TH1 * h1, float min, float max, float minfit, float maxfit) {
00006 setStyle(h1);
00007 static int i = 0;
00008 i++;
00009
00010
00011 h1->GetXaxis()->SetRangeUser(min,max);
00012 TString fitName = "g";
00013 fitName += i;
00014 TF1* g1 = new TF1(fitName.Data(),"gaus",minfit,maxfit);
00015 g1->SetLineColor(2);
00016 g1->SetLineWidth(2);
00017 h1->Fit(g1,"RQ");
00018 h1->Draw();
00019
00020
00021
00022 }
00023 void Tutils::setStyle(TH1 *histo) {
00024 mystyle = getStyle("tdr");
00025 histo->GetXaxis()->SetTitleFont(mystyle->GetTitleFont());
00026 histo->GetXaxis()->SetTitleSize(mystyle->GetTitleFontSize());
00027 histo->GetXaxis()->SetLabelFont(mystyle->GetLabelFont());
00028 histo->GetXaxis()->SetLabelSize(mystyle->GetLabelSize());
00029
00030 histo->GetYaxis()->SetTitleFont(mystyle->GetTitleFont());
00031 histo->GetYaxis()->SetTitleSize(mystyle->GetTitleFontSize());
00032 histo->GetYaxis()->SetLabelFont(mystyle->GetLabelFont());
00033 histo->GetYaxis()->SetLabelSize(mystyle->GetLabelSize());
00034 }
00035
00036 void Tutils::setStyle(TH2 *histo) {
00037 mystyle = getStyle("tdr");
00038 histo->GetXaxis()->SetTitleFont(mystyle->GetTitleFont());
00039 histo->GetXaxis()->SetTitleSize(mystyle->GetTitleFontSize());
00040 histo->GetXaxis()->SetLabelFont(mystyle->GetLabelFont());
00041 histo->GetXaxis()->SetLabelSize(mystyle->GetLabelSize());
00042
00043 histo->GetYaxis()->SetTitleFont(mystyle->GetTitleFont());
00044 histo->GetYaxis()->SetTitleSize(mystyle->GetTitleFontSize());
00045 histo->GetYaxis()->SetLabelFont(mystyle->GetLabelFont());
00046 histo->GetYaxis()->SetLabelSize(mystyle->GetLabelSize());
00047 }
00048
00049 TStyle * Tutils::getStyle(TString name)
00050 {
00051 TStyle *theStyle;
00052 if ( name == "mstyle" ) {
00053 theStyle = new TStyle("mstyle", "mstyle");
00054
00055 theStyle->SetPadBorderMode(0);
00056 theStyle->SetCanvasBorderMode(0);
00057 theStyle->SetPadColor(0);
00058 theStyle->SetCanvasColor(0);
00059 theStyle->SetMarkerStyle(8);
00060 theStyle->SetMarkerSize(0.7);
00061 theStyle->SetStatH(0.3);
00062 theStyle->SetStatW(0.15);
00063
00064
00065 theStyle->SetTitleBorderSize(1);
00066 theStyle->SetPalette(1);
00067
00068 } else if( name == "tdr" ) {
00069 theStyle = new TStyle("tdrStyle","Style for P-TDR");
00070
00071
00072 theStyle->SetCanvasBorderMode(0);
00073 theStyle->SetCanvasColor(kWhite);
00074 theStyle->SetCanvasDefH(600);
00075 theStyle->SetCanvasDefW(600);
00076 theStyle->SetCanvasDefX(0);
00077 theStyle->SetCanvasDefY(0);
00078
00079
00080 theStyle->SetPadBorderMode(0);
00081
00082 theStyle->SetPadColor(kWhite);
00083 theStyle->SetPadGridX(true);
00084 theStyle->SetPadGridY(true);
00085 theStyle->SetGridColor(0);
00086 theStyle->SetGridStyle(3);
00087 theStyle->SetGridWidth(1);
00088
00089
00090 theStyle->SetFrameBorderMode(0);
00091 theStyle->SetFrameBorderSize(1);
00092 theStyle->SetFrameFillColor(0);
00093 theStyle->SetFrameFillStyle(0);
00094 theStyle->SetFrameLineColor(1);
00095 theStyle->SetFrameLineStyle(1);
00096 theStyle->SetFrameLineWidth(1);
00097
00098
00099
00100
00101 theStyle->SetHistLineColor(1);
00102 theStyle->SetHistLineStyle(0);
00103 theStyle->SetHistLineWidth(1);
00104
00105
00106
00107 theStyle->SetEndErrorSize(2);
00108
00109 theStyle->SetErrorX(0.);
00110
00111 theStyle->SetMarkerStyle(20);
00112
00113
00114 theStyle->SetOptFit(1);
00115 theStyle->SetFitFormat("5.4g");
00116 theStyle->SetFuncColor(2);
00117 theStyle->SetFuncStyle(1);
00118 theStyle->SetFuncWidth(1);
00119
00120
00121 theStyle->SetOptDate(0);
00122
00123
00124
00125
00126 theStyle->SetOptFile(0);
00127
00128 theStyle->SetOptStat(10);
00129 theStyle->SetStatColor(kWhite);
00130 theStyle->SetStatFont(42);
00131 theStyle->SetStatFontSize(0.07);
00132 theStyle->SetStatTextColor(1);
00133 theStyle->SetStatFormat("6.4g");
00134 theStyle->SetStatBorderSize(1);
00135 theStyle->SetStatH(0.3);
00136 theStyle->SetStatW(0.2);
00137
00138
00139
00140
00141
00142 theStyle->SetPadTopMargin(0.05);
00143 theStyle->SetPadBottomMargin(0.13);
00144 theStyle->SetPadLeftMargin(0.16);
00145 theStyle->SetPadRightMargin(0.02);
00146
00147
00148
00149 theStyle->SetOptTitle(0);
00150 theStyle->SetTitleFont(42);
00151 theStyle->SetTitleColor(1);
00152 theStyle->SetTitleTextColor(1);
00153 theStyle->SetTitleFillColor(10);
00154 theStyle->SetTitleFontSize(0.05);
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164 theStyle->SetTitleColor(1, "XYZ");
00165 theStyle->SetTitleFont(42, "XYZ");
00166 theStyle->SetTitleSize(0.06, "XYZ");
00167
00168
00169 theStyle->SetTitleXOffset(0.9);
00170 theStyle->SetTitleYOffset(1.25);
00171
00172
00173
00174
00175 theStyle->SetLabelColor(1, "XYZ");
00176 theStyle->SetLabelFont(42, "XYZ");
00177 theStyle->SetLabelOffset(0.007, "XYZ");
00178 theStyle->SetLabelSize(0.045, "XYZ");
00179
00180
00181
00182 theStyle->SetAxisColor(1, "XYZ");
00183 theStyle->SetStripDecimals(kTRUE);
00184 theStyle->SetTickLength(0.03, "XYZ");
00185 theStyle->SetNdivisions(510, "XYZ");
00186 theStyle->SetPadTickX(1);
00187 theStyle->SetPadTickY(1);
00188
00189
00190 theStyle->SetOptLogx(0);
00191 theStyle->SetOptLogy(0);
00192 theStyle->SetOptLogz(0);
00193
00194
00195 theStyle->SetPaperSize(20.,20.);
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212 } else {
00213
00214 theStyle = gStyle;
00215 }
00216 return theStyle;
00217 }
00218
00219 void Tutils::plotAndProfileX (TH2* h2, float min, float max,bool profile) {
00220 setStyle(h2);
00221
00222
00223 h2->GetYaxis()->SetRangeUser(min,max);
00224 h2->Draw();
00225 if (profile) {
00226 TProfile* prof = h2->ProfileX();
00227 prof->SetMarkerColor(2);
00228 prof->SetLineColor(2);
00229 prof->Draw("same");
00230 }
00231
00232
00233
00234 }