File indexing completed on 2024-04-06 12:30:44
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 void plotAndProfileX (TH2* h2, float min, float max, bool profile=false) {
0020 gPad->SetGrid(1,1);
0021 gStyle->SetGridColor(15);
0022 h2->GetYaxis()->SetRangeUser(min,max);
0023 h2->Draw();
0024 if (profile) {
0025 TProfile* prof = h2->ProfileX();
0026 prof->SetMarkerColor(2);
0027 prof->SetLineColor(2);
0028 prof->Draw("same");
0029 }
0030 TLine * l = new TLine(h2->GetXaxis()->GetXmin(),0,h2->GetXaxis()->GetXmax(),0);
0031 l->SetLineColor(3);
0032 l->Draw();
0033 }
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059 void drawGFit(TH1 * h1, float min, float max){
0060 drawGFit(h1, min, max, min, max);
0061 gPad->Draw();
0062 }
0063
0064
0065
0066 void drawGFit(TH1 * h1, float min, float max, float minfit, float maxfit) {
0067 static int i = 0;
0068 i++;
0069 gPad->SetGrid(1,1);
0070 gStyle->SetGridColor(15);
0071
0072 h1->GetXaxis()->SetRangeUser(min,max);
0073 TF1* g1 = new TF1(TString("g")+i,"gaus",minfit,maxfit);
0074 g1->SetLineColor(2);
0075 g1->SetLineWidth(2);
0076 h1->Fit(g1,"R");
0077
0078
0079
0080
0081 }
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097 TCanvas * newCanvas(TString name="", TString title="",
0098 Int_t xdiv=0, Int_t ydiv=0, Int_t form = 1, Int_t w=-1){
0099
0100 static int i = 1;
0101
0102 if (name == "") {
0103 name = TString("Canvas ") + i;
0104 i++;
0105 }
0106
0107 if (title == "") title = name;
0108
0109 if (w<0) {
0110 TCanvas * c = new TCanvas(name,title, form);
0111 } else {
0112 TCanvas * c = new TCanvas(name,title,form,w);
0113 }
0114
0115 if (xdiv*ydiv!=0) c->Divide(xdiv,ydiv);
0116 c->cd(1);
0117 return c;
0118 }
0119
0120
0121
0122 TCanvas * newCanvas(Int_t xdiv, Int_t ydiv, Int_t form = 1) {
0123 return newCanvas("","",xdiv,ydiv,form);
0124 }
0125
0126
0127
0128 TCanvas * newCanvas(Int_t form = 1)
0129 {
0130 return newCanvas(0,0,form);
0131 }
0132
0133
0134 TCanvas * newCanvas(TString name, Int_t xdiv=0, Int_t ydiv=0, Int_t form = 1,
0135 Int_t w=-1) {
0136 return newCanvas(name, name,xdiv,ydiv,form,w);
0137 }
0138
0139
0140 TCanvas * newCanvas(TString name, Int_t form = 1, Int_t w=-1)
0141 {
0142 return newCanvas(name, name, 0,0,form,w);
0143 }
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157 void printCanvasesPS(TString name){
0158 TPostScript * ps = new TPostScript(name,112);
0159 TIter iter(gROOT->GetListOfCanvases());
0160
0161 TCanvas *c;
0162
0163 while( (c = (TCanvas *)iter()) )
0164 {
0165 cout << "Printing " << c->GetName() << endl;
0166 ps->NewPage();
0167 c->Draw();
0168 }
0169 cout << " File " << name << " was created" << endl;
0170 ps->Close();
0171 }
0172
0173
0174 void printCanvasesEps(){
0175 TIter iter(gROOT->GetListOfCanvases());
0176 TCanvas *c;
0177 while( (c = (TCanvas *)iter()) ) {
0178 c->Print(0,"eps");
0179 }
0180 }
0181
0182
0183 void printCanvasesEps2() {
0184 gROOT->GetListOfCanvases()->Print("eps");
0185 }
0186
0187
0188
0189 void printCanvases(TString type="eps"){
0190 TIter iter(gROOT->GetListOfCanvases());
0191 TCanvas *c;
0192 while( (c = (TCanvas *)iter()) ) {
0193 c->Print(0,type);
0194 }
0195 }
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209 TStyle * getStyle(TString name="myStyle")
0210 {
0211 TStyle *theStyle;
0212
0213 if ( name == "myStyle" ) {
0214 theStyle = new TStyle("myStyle", "myStyle");
0215
0216 theStyle->SetPadBorderMode(0);
0217 theStyle->SetCanvasBorderMode(0);
0218 theStyle->SetPadColor(0);
0219 theStyle->SetCanvasColor(0);
0220 theStyle->SetMarkerStyle(8);
0221 theStyle->SetMarkerSize(0.7);
0222
0223
0224 theStyle->SetTitleBorderSize(1);
0225 theStyle->SetPalette(1);
0226
0227
0228
0229 } else {
0230
0231 theStyle = gStyle;
0232 }
0233 return theStyle;
0234 }