CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
Tutils Class Reference

#include <utils.h>

Public Member Functions

void drawGFit (TH1 *h1, float min, float max)
 
void drawGFit (TH1 *h1, float min, float max, float minfit, float maxfit)
 
void drawGFit (TH1 *h1, float nsigmas, float min, float max)
 
void plotAndProfileX (TH2 *h2, float min, float max, bool profile=false)
 
void setStyle (TH1 *histo)
 
void setStyle (TH2 *histo)
 

Private Member Functions

TStyle * getStyle (const TString &name)
 

Private Attributes

TStyle * mystyle
 

Detailed Description

Definition at line 9 of file utils.h.

Member Function Documentation

◆ drawGFit() [1/3]

void Tutils::drawGFit ( TH1 *  h1,
float  min,
float  max 
)

◆ drawGFit() [2/3]

void Tutils::drawGFit ( TH1 *  h1,
float  min,
float  max,
float  minfit,
float  maxfit 
)

Definition at line 5 of file utils.cc.

5  {
6  setStyle(h1);
7  static int i = 0;
8  i++;
9  // h1->SetGrid(1,1);
10  // h1->SetGridColor(15);
11  h1->GetXaxis()->SetRangeUser(min, max);
12  TString fitName = "g";
13  fitName += i;
14  TF1 *g1 = new TF1(fitName.Data(), "gaus", minfit, maxfit);
15  g1->SetLineColor(2);
16  g1->SetLineWidth(2);
17  h1->Fit(g1, "RQ");
18  h1->Draw();
19  // TPaveStats *st =
20  // (TPaveStats*)h1->GetListOfFunctions()->FindObject("stats");
21  // st->SetX2NDC(0.905);
22  // st->SetY2NDC(0.905);
23 }

References diffTwoXMLs::g1, mps_fire::i, SiStripPI::max, min(), setStyle(), and tools::TF1.

◆ drawGFit() [3/3]

void Tutils::drawGFit ( TH1 *  h1,
float  nsigmas,
float  min,
float  max 
)

◆ getStyle()

TStyle * Tutils::getStyle ( const TString &  name)
private

Definition at line 50 of file utils.cc.

50  {
51  TStyle *theStyle;
52  if (name == "mstyle") {
53  theStyle = new TStyle("mstyle", "mstyle");
54  // theStyle->SetOptStat(0);
55  theStyle->SetPadBorderMode(0);
56  theStyle->SetCanvasBorderMode(0);
57  theStyle->SetPadColor(0);
58  theStyle->SetCanvasColor(0);
59  theStyle->SetMarkerStyle(8);
60  theStyle->SetMarkerSize(0.7);
61  theStyle->SetStatH(0.3);
62  theStyle->SetStatW(0.15);
63  // theStyle->SetTextFont(132);
64  // theStyle->SetTitleFont(132);
65  theStyle->SetTitleBorderSize(1);
66  theStyle->SetPalette(1);
67 
68  } else if (name == "tdr") {
69  theStyle = new TStyle("tdrStyle", "Style for P-TDR");
70 
71  // For the canvas:
72  theStyle->SetCanvasBorderMode(0);
73  theStyle->SetCanvasColor(kWhite);
74  theStyle->SetCanvasDefH(600); // Height of canvas
75  theStyle->SetCanvasDefW(600); // Width of canvas
76  theStyle->SetCanvasDefX(0); // POsition on screen
77  theStyle->SetCanvasDefY(0);
78 
79  // For the Pad:
80  theStyle->SetPadBorderMode(0);
81  // theStyle->SetPadBorderSize(Width_t size = 1);
82  theStyle->SetPadColor(kWhite);
83  theStyle->SetPadGridX(true);
84  theStyle->SetPadGridY(true);
85  theStyle->SetGridColor(0);
86  theStyle->SetGridStyle(3);
87  theStyle->SetGridWidth(1);
88 
89  // For the frame:
90  theStyle->SetFrameBorderMode(0);
91  theStyle->SetFrameBorderSize(1);
92  theStyle->SetFrameFillColor(0);
93  theStyle->SetFrameFillStyle(0);
94  theStyle->SetFrameLineColor(1);
95  theStyle->SetFrameLineStyle(1);
96  theStyle->SetFrameLineWidth(1);
97 
98  // For the histo:
99  // theStyle->SetHistFillColor(1);
100  // theStyle->SetHistFillStyle(0);
101  theStyle->SetHistLineColor(1);
102  theStyle->SetHistLineStyle(0);
103  theStyle->SetHistLineWidth(1);
104  // theStyle->SetLegoInnerR(Float_t rad = 0.5);
105  // theStyle->SetNumberContours(Int_t number = 20);
106 
107  theStyle->SetEndErrorSize(2);
108  // theStyle->SetErrorMarker(20);
109  theStyle->SetErrorX(0.);
110 
111  theStyle->SetMarkerStyle(20);
112 
113  // For the fit/function:
114  theStyle->SetOptFit(1);
115  theStyle->SetFitFormat("5.4g");
116  theStyle->SetFuncColor(2);
117  theStyle->SetFuncStyle(1);
118  theStyle->SetFuncWidth(1);
119 
120  // For the date:
121  theStyle->SetOptDate(0);
122  // theStyle->SetDateX(Float_t x = 0.01);
123  // theStyle->SetDateY(Float_t y = 0.01);
124 
125  // For the statistics box:
126  theStyle->SetOptFile(0);
127  // theStyle->SetOptStat(0); // To display the mean and RMS:
128  // SetOptStat("mr");
129  theStyle->SetOptStat(10);
130  theStyle->SetStatColor(kWhite);
131  theStyle->SetStatFont(42);
132  theStyle->SetStatFontSize(0.07);
133  theStyle->SetStatTextColor(1);
134  theStyle->SetStatFormat("6.4g");
135  theStyle->SetStatBorderSize(1);
136  theStyle->SetStatH(0.3);
137  theStyle->SetStatW(0.2);
138  // theStyle->SetStatStyle(Style_t style = 1001);
139  // theStyle->SetStatX(Float_t x = 0);
140  // theStyle->SetStatY(Float_t y = 0);
141 
142  // Margins:
143  theStyle->SetPadTopMargin(0.05);
144  theStyle->SetPadBottomMargin(0.13);
145  theStyle->SetPadLeftMargin(0.16);
146  theStyle->SetPadRightMargin(0.02);
147 
148  // For the Global title:
149 
150  theStyle->SetOptTitle(0);
151  theStyle->SetTitleFont(42);
152  theStyle->SetTitleColor(1);
153  theStyle->SetTitleTextColor(1);
154  theStyle->SetTitleFillColor(10);
155  theStyle->SetTitleFontSize(0.05);
156  // theStyle->SetTitleH(0); // Set the height of the title box
157  // theStyle->SetTitleW(0); // Set the width of the title box
158  // theStyle->SetTitleX(0); // Set the position of the title box
159  // theStyle->SetTitleY(0.985); // Set the position of the title box
160  // theStyle->SetTitleStyle(Style_t style = 1001);
161  // theStyle->SetTitleBorderSize(2);
162 
163  // For the axis titles:
164 
165  theStyle->SetTitleColor(1, "XYZ");
166  theStyle->SetTitleFont(42, "XYZ");
167  theStyle->SetTitleSize(0.06, "XYZ");
168  // theStyle->SetTitleXSize(Float_t size = 0.02); // Another way to set the
169  // size? theStyle->SetTitleYSize(Float_t size = 0.02);
170  theStyle->SetTitleXOffset(0.9);
171  theStyle->SetTitleYOffset(1.25);
172  // theStyle->SetTitleOffset(1.1, "Y"); // Another way to set the Offset
173 
174  // For the axis labels:
175 
176  theStyle->SetLabelColor(1, "XYZ");
177  theStyle->SetLabelFont(42, "XYZ");
178  theStyle->SetLabelOffset(0.007, "XYZ");
179  theStyle->SetLabelSize(0.045, "XYZ");
180 
181  // For the axis:
182 
183  theStyle->SetAxisColor(1, "XYZ");
184  theStyle->SetStripDecimals(kTRUE);
185  theStyle->SetTickLength(0.03, "XYZ");
186  theStyle->SetNdivisions(510, "XYZ");
187  theStyle->SetPadTickX(1); // To get tick marks on the opposite side of the frame
188  theStyle->SetPadTickY(1);
189 
190  // Change for log plots:
191  theStyle->SetOptLogx(0);
192  theStyle->SetOptLogy(0);
193  theStyle->SetOptLogz(0);
194 
195  // Postscript options:
196  theStyle->SetPaperSize(20., 20.);
197  // theStyle->SetLineScalePS(Float_t scale = 3);
198  // theStyle->SetLineStyleString(Int_t i, const char* text);
199  // theStyle->SetHeaderPS(const char* header);
200  // theStyle->SetTitlePS(const char* pstitle);
201 
202  // theStyle->SetBarOffset(Float_t baroff = 0.5);
203  // theStyle->SetBarWidth(Float_t barwidth = 0.5);
204  // theStyle->SetPaintTextFormat(const char* format = "g");
205  // theStyle->SetPalette(Int_t ncolors = 0, Int_t* colors = 0);
206  // theStyle->SetTimeOffset(Double_t toffset);
207  // theStyle->SetHistMinimumZero(kTRUE);
208 
209  // style->SetOptFit(101);
210  // style->SetOptStat(1111111);
211 
212  } else {
213  // Avoid modifying the default style!
214  theStyle = gStyle;
215  }
216  return theStyle;
217 }

References Skims_PA_cff::name.

Referenced by setStyle().

◆ plotAndProfileX()

void Tutils::plotAndProfileX ( TH2 *  h2,
float  min,
float  max,
bool  profile = false 
)

Definition at line 219 of file utils.cc.

219  {
220  setStyle(h2);
221  // gPad->SetGrid(1,1);
222  // gStyle->SetGridColor(15);
223  h2->GetYaxis()->SetRangeUser(min, max);
224  h2->Draw();
225  if (profile) {
226  TProfile *prof = h2->ProfileX();
227  prof->SetMarkerColor(2);
228  prof->SetLineColor(2);
229  prof->Draw("same");
230  }
231  // TLine * l = new
232  // TLine(h2->GetXaxis()->GetXmin(),0,h2->GetXaxis()->GetXmax(),0);
233  // l->SetLineColor(3);
234  // l->Draw();
235 }

References SiStripPI::max, min(), PostProcessor_cff::profile, and setStyle().

◆ setStyle() [1/2]

void Tutils::setStyle ( TH1 *  histo)

Definition at line 24 of file utils.cc.

24  {
25  mystyle = getStyle("tdr");
26  histo->GetXaxis()->SetTitleFont(mystyle->GetTitleFont());
27  histo->GetXaxis()->SetTitleSize(mystyle->GetTitleFontSize());
28  histo->GetXaxis()->SetLabelFont(mystyle->GetLabelFont());
29  histo->GetXaxis()->SetLabelSize(mystyle->GetLabelSize());
30 
31  histo->GetYaxis()->SetTitleFont(mystyle->GetTitleFont());
32  histo->GetYaxis()->SetTitleSize(mystyle->GetTitleFontSize());
33  histo->GetYaxis()->SetLabelFont(mystyle->GetLabelFont());
34  histo->GetYaxis()->SetLabelSize(mystyle->GetLabelSize());
35 }

References getStyle(), timingPdfMaker::histo, and mystyle.

Referenced by drawGFit(), and plotAndProfileX().

◆ setStyle() [2/2]

void Tutils::setStyle ( TH2 *  histo)

Definition at line 37 of file utils.cc.

37  {
38  mystyle = getStyle("tdr");
39  histo->GetXaxis()->SetTitleFont(mystyle->GetTitleFont());
40  histo->GetXaxis()->SetTitleSize(mystyle->GetTitleFontSize());
41  histo->GetXaxis()->SetLabelFont(mystyle->GetLabelFont());
42  histo->GetXaxis()->SetLabelSize(mystyle->GetLabelSize());
43 
44  histo->GetYaxis()->SetTitleFont(mystyle->GetTitleFont());
45  histo->GetYaxis()->SetTitleSize(mystyle->GetTitleFontSize());
46  histo->GetYaxis()->SetLabelFont(mystyle->GetLabelFont());
47  histo->GetYaxis()->SetLabelSize(mystyle->GetLabelSize());
48 }

References getStyle(), timingPdfMaker::histo, and mystyle.

Member Data Documentation

◆ mystyle

TStyle* Tutils::mystyle
private

Definition at line 20 of file utils.h.

Referenced by setStyle().

mps_fire.i
i
Definition: mps_fire.py:355
min
T min(T a, T b)
Definition: MathUtil.h:58
Tutils::getStyle
TStyle * getStyle(const TString &name)
Definition: utils.cc:50
diffTwoXMLs.g1
g1
Definition: diffTwoXMLs.py:52
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:279
tools.TF1
TF1
Definition: tools.py:23
Tutils::setStyle
void setStyle(TH1 *histo)
Definition: utils.cc:24
PostProcessor_cff.profile
profile
Definition: PostProcessor_cff.py:38
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
Tutils::mystyle
TStyle * mystyle
Definition: utils.h:20
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17