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