Example #1
0
void setTDRStyle() {
  TStyle *tdrStyle = new TStyle("tdrStyle","Style for P-TDR");

// For the canvas:
  tdrStyle->SetCanvasBorderMode(0);
  tdrStyle->SetCanvasColor(kWhite);
  tdrStyle->SetCanvasDefH(600); //Height of canvas
  tdrStyle->SetCanvasDefW(600); //Width of canvas
  tdrStyle->SetCanvasDefX(0);   //POsition on screen
  tdrStyle->SetCanvasDefY(0);

// For the Pad:
  tdrStyle->SetPadBorderMode(0);
  // tdrStyle->SetPadBorderSize(Width_t size = 1);
  tdrStyle->SetPadColor(kWhite);
  tdrStyle->SetPadGridX(false);
  tdrStyle->SetPadGridY(false);
  tdrStyle->SetGridColor(0);
  tdrStyle->SetGridStyle(3);
  tdrStyle->SetGridWidth(1);

// For the frame:
  tdrStyle->SetFrameBorderMode(0);
  tdrStyle->SetFrameBorderSize(1);
  tdrStyle->SetFrameFillColor(0);
  tdrStyle->SetFrameFillStyle(0);
  tdrStyle->SetFrameLineColor(1);
  tdrStyle->SetFrameLineStyle(1);
  tdrStyle->SetFrameLineWidth(1);

// For the histo:
  // tdrStyle->SetHistFillColor(1);
  // tdrStyle->SetHistFillStyle(0);
  tdrStyle->SetHistLineColor(1);
  tdrStyle->SetHistLineStyle(0);
  tdrStyle->SetHistLineWidth(1);
  // tdrStyle->SetLegoInnerR(Float_t rad = 0.5);
  // tdrStyle->SetNumberContours(Int_t number = 20);

  tdrStyle->SetEndErrorSize(2);
  // tdrStyle->SetErrorMarker(20);
  tdrStyle->SetErrorX(0.);
  
  tdrStyle->SetMarkerStyle(20);

//For the fit/function:
  tdrStyle->SetOptFit(1);
  tdrStyle->SetFitFormat("5.4g");
  tdrStyle->SetFuncColor(2);
  tdrStyle->SetFuncStyle(1);
  tdrStyle->SetFuncWidth(1);

//For the date:
  tdrStyle->SetOptDate(0);
  // tdrStyle->SetDateX(Float_t x = 0.01);
  // tdrStyle->SetDateY(Float_t y = 0.01);

// For the statistics box:
  tdrStyle->SetOptFile(0);
  tdrStyle->SetOptStat(0); // To display the mean and RMS:   SetOptStat("mr");
  tdrStyle->SetStatColor(kWhite);
  tdrStyle->SetStatFont(42);
  tdrStyle->SetStatFontSize(0.025);
  tdrStyle->SetStatTextColor(1);
  tdrStyle->SetStatFormat("6.4g");
  tdrStyle->SetStatBorderSize(1);
  tdrStyle->SetStatH(0.1);
  tdrStyle->SetStatW(0.15);
  // tdrStyle->SetStatStyle(Style_t style = 1001);
  // tdrStyle->SetStatX(Float_t x = 0);
  // tdrStyle->SetStatY(Float_t y = 0);

// Margins:
  tdrStyle->SetPadTopMargin(0.05);
  tdrStyle->SetPadBottomMargin(0.13);
  tdrStyle->SetPadLeftMargin(0.16);
  tdrStyle->SetPadRightMargin(0.02);

// For the Global title:

  tdrStyle->SetOptTitle(0);
  tdrStyle->SetTitleFont(42);
  tdrStyle->SetTitleColor(1);
  tdrStyle->SetTitleTextColor(1);
  tdrStyle->SetTitleFillColor(10);
  tdrStyle->SetTitleFontSize(0.05);
  // tdrStyle->SetTitleH(0); // Set the height of the title box
  // tdrStyle->SetTitleW(0); // Set the width of the title box
  // tdrStyle->SetTitleX(0); // Set the position of the title box
  // tdrStyle->SetTitleY(0.985); // Set the position of the title box
  // tdrStyle->SetTitleStyle(Style_t style = 1001);
  // tdrStyle->SetTitleBorderSize(2);

// For the axis titles:

  tdrStyle->SetTitleColor(1, "XYZ");
  tdrStyle->SetTitleFont(42, "XYZ");
  tdrStyle->SetTitleSize(0.06, "XYZ");
  // tdrStyle->SetTitleXSize(Float_t size = 0.02); // Another way to set the size?
  // tdrStyle->SetTitleYSize(Float_t size = 0.02);
  tdrStyle->SetTitleXOffset(0.9);
  tdrStyle->SetTitleYOffset(1.25);
  // tdrStyle->SetTitleOffset(1.1, "Y"); // Another way to set the Offset

// For the axis labels:

  tdrStyle->SetLabelColor(1, "XYZ");
  tdrStyle->SetLabelFont(42, "XYZ");
  tdrStyle->SetLabelOffset(0.007, "XYZ");
  tdrStyle->SetLabelSize(0.05, "XYZ");

// For the axis:

  tdrStyle->SetAxisColor(1, "XYZ");
  tdrStyle->SetStripDecimals(kTRUE);
  tdrStyle->SetTickLength(0.03, "XYZ");
  tdrStyle->SetNdivisions(510, "XYZ");
  tdrStyle->SetPadTickX(1);  // To get tick marks on the opposite side of the frame
  tdrStyle->SetPadTickY(1);

// Change for log plots:
  tdrStyle->SetOptLogx(0);
  tdrStyle->SetOptLogy(0);
  tdrStyle->SetOptLogz(0);

// Postscript options:
  tdrStyle->SetPaperSize(20.,20.);
  // tdrStyle->SetLineScalePS(Float_t scale = 3);
  // tdrStyle->SetLineStyleString(Int_t i, const char* text);
  // tdrStyle->SetHeaderPS(const char* header);
  // tdrStyle->SetTitlePS(const char* pstitle);

  // tdrStyle->SetBarOffset(Float_t baroff = 0.5);
  // tdrStyle->SetBarWidth(Float_t barwidth = 0.5);
  // tdrStyle->SetPaintTextFormat(const char* format = "g");
  // tdrStyle->SetPalette(Int_t ncolors = 0, Int_t* colors = 0);
  // tdrStyle->SetTimeOffset(Double_t toffset);
  // tdrStyle->SetHistMinimumZero(kTRUE);

  tdrStyle->cd();

}
Example #2
0
void FakeRate() {


  TStyle *tdrStyle = new TStyle("tdrStyle","Style for P-TDR");

  // For the canvas:
  tdrStyle->SetCanvasBorderMode(0);
  tdrStyle->SetCanvasColor(kWhite);
  tdrStyle->SetCanvasDefH(600); //Height of canvas
  tdrStyle->SetCanvasDefW(600); //Width of canvas
  tdrStyle->SetCanvasDefX(0);   //POsition on screen
  tdrStyle->SetCanvasDefY(0);

  // For the Pad:
  tdrStyle->SetPadBorderMode(0);
  tdrStyle->SetPadColor(kWhite);
  tdrStyle->SetPadGridX(true);
  tdrStyle->SetPadGridY(true);
  tdrStyle->SetGridColor(0);
  tdrStyle->SetGridStyle(3);
  tdrStyle->SetGridWidth(1);

  // For the frame:
  tdrStyle->SetFrameBorderMode(0);
  tdrStyle->SetFrameBorderSize(1);
  tdrStyle->SetFrameFillColor(0);
  tdrStyle->SetFrameFillStyle(0);
  tdrStyle->SetFrameLineColor(1);
  tdrStyle->SetFrameLineStyle(1);
  tdrStyle->SetFrameLineWidth(1);

  // For the histo:
  tdrStyle->SetHistLineColor(1);
  tdrStyle->SetHistLineStyle(0);
  tdrStyle->SetHistLineWidth(1);
  tdrStyle->SetEndErrorSize(2);
  tdrStyle->SetErrorX(0.);
  tdrStyle->SetMarkerStyle(20);

  //For the fit/function:
  tdrStyle->SetOptFit(1);
  tdrStyle->SetFitFormat("5.4g");
  tdrStyle->SetFuncColor(2);
  tdrStyle->SetFuncStyle(1);
  tdrStyle->SetFuncWidth(1);

  //For the date:
  tdrStyle->SetOptDate(0);

  // For the statistics box:
  tdrStyle->SetOptFile(0);
  tdrStyle->SetOptStat("emr"); // To display the mean and RMS:   SetOptStat("mr");
  tdrStyle->SetStatColor(kWhite);
  tdrStyle->SetStatFont(42);
  tdrStyle->SetStatFontSize(0.025);
  tdrStyle->SetStatTextColor(1);
  tdrStyle->SetStatFormat("6.4g");
  tdrStyle->SetStatBorderSize(1);
  tdrStyle->SetStatH(0.1);
  tdrStyle->SetStatW(0.15);

  // Margins:
  tdrStyle->SetPadTopMargin(0.07);
  tdrStyle->SetPadBottomMargin(0.13);
  tdrStyle->SetPadLeftMargin(0.13);
  tdrStyle->SetPadRightMargin(0.05);

  // For the Global title:
  tdrStyle->SetTitleFont(35);
  tdrStyle->SetTitleColor(1);
  tdrStyle->SetTitleTextColor(1);
  tdrStyle->SetTitleFillColor(10);
  tdrStyle->SetTitleFontSize(0.045);
  tdrStyle->SetTitleX(0.15); // Set the position of the title box
  tdrStyle->SetTitleBorderSize(0);

  // For the axis titles:
  tdrStyle->SetTitleColor(1, "XYZ");
  tdrStyle->SetTitleFont(42, "XYZ");
  tdrStyle->SetTitleSize(0.04, "XYZ");
  tdrStyle->SetTitleXOffset(0.9);
  tdrStyle->SetTitleYOffset(1.5);

  // For the axis labels:
  tdrStyle->SetLabelColor(1, "XYZ");
  tdrStyle->SetLabelFont(42, "XYZ");
  tdrStyle->SetLabelOffset(0.007, "XYZ");
  tdrStyle->SetLabelSize(0.03, "XYZ");

  // For the axis:
  tdrStyle->SetAxisColor(1, "XYZ");
  tdrStyle->SetStripDecimals(kTRUE);
  tdrStyle->SetTickLength(0.03, "XYZ");
  tdrStyle->SetNdivisions(510, "XYZ");
  tdrStyle->SetPadTickX(1);  // To get tick marks on the opposite side of the frame
  tdrStyle->SetPadTickY(1);

  // Change for log plots:
  tdrStyle->SetOptLogx(0);
  tdrStyle->SetOptLogy(0);
  tdrStyle->SetOptLogz(0);

  // Postscript options:
  tdrStyle->SetPaperSize(20.,20.);
  tdrStyle->SetPalette(1);
  
  const Int_t NRGBs = 5;
  const Int_t NCont = 255;

  Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
  Double_t red[NRGBs]   = { 0.00, 0.00, 0.87, 1.00, 0.51 };
  Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
  Double_t blue[NRGBs]  = { 0.51, 1.00, 0.12, 0.00, 0.00 };
  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
  tdrStyle->SetNumberContours(NCont);

  gROOT -> ForceStyle();

  tdrStyle->cd();
  
  int binsize = 10;
  int binlow = 30;
  int binup = 130;

  TString cut_Iasonas_n = "pfmet_pt < 40. && ph_N_Pt   > 0. && ph_N_sinin < 0.011";
  TString cut_Iasonas_d = "pfmet_pt < 40. && ph_DLU_Pt > 0. ";

  TString cut_Zeynep_n = "Num_Pho_Pt > 0. && Num_Pho_SigmaIEtaIEta < 0.011";
  TString cut_Zeynep_d = "Den_Pho_Pt > 0.";

  TString cut_Zeynep_n_new = "passedNum && Pho_Pt > 0. && Pho_SigmaIEtaIEta < 0.011 && muVeto0==0";
  TString cut_Zeynep_d_new = "passedDen && Pho_Pt > 0. && muVeto0==0";


  TFile *f_Iasonas = new TFile("old_results/dataAll.root","READ");
  f_Iasonas->cd("Analyzer");
  TH1F *h_num_I  = new TH1F("h_num_I","h_num_I" ,binsize ,binlow ,binup);
  TH1F *h_den_I  = new TH1F("h_den_I","h_den_I" ,binsize ,binlow ,binup);

  AnalyzerTree->Draw("ph_N_Pt>>h_num_I",cut_Iasonas_n,"goff");
  AnalyzerTree->Draw("ph_DLU_Pt>>h_den_I",cut_Iasonas_d,"goff");
  
  TH1F *h_raw_I = (TH1F*)h_num_I->Clone("h_raw_I");
  h_raw_I->Divide(h_den_I);

  //TFile *f_Zeynep = new TFile("higgsHistograms_QCD.root","READ");
  //TFile *f_Zeynep = new TFile("higgsHistograms_QCD_newHoE.root","READ");
  TFile *f_Zeynep = new TFile("n_jetTest2.root","READ");
  f_Zeynep->cd("Analyzer");
  h_num_Z  = new TH1F("h_num_Z","h_num_Z" ,binsize ,binlow ,binup);
  h_den_Z  = new TH1F("h_den_Z","h_den_Z" ,binsize ,binlow ,binup);
  
  AnalyzerTree->Draw("Pho_Pt>>h_num_Z",cut_Zeynep_n_new,"goff");
  AnalyzerTree->Draw("Pho_Pt>>h_den_Z",cut_Zeynep_d_new,"goff");
 
  TH1F *h_raw_Z = (TH1F*)h_num_Z->Clone("h_raw_Z");
  h_raw_Z->Divide(h_den_Z);


  TFile *f_Zeynep_o = new TFile("old_results/compareDen_Num/ifStatements/testing_simple_1fake.root","READ");
  //TFile *f_Zeynep_o = new TFile("higgsHistograms_QCD_newHoE.root","READ");
  f_Zeynep_o->cd("Analyzer");
  h_num_Z_o  = new TH1F("h_num_Z_o","h_num_Z_o" ,binsize ,binlow ,binup);
  h_den_Z_o  = new TH1F("h_den_Z_o","h_den_Z_o" ,binsize ,binlow ,binup);

  AnalyzerTree->Draw("Num_Pho_Pt>>h_num_Z_o",cut_Zeynep_n,"goff");
  AnalyzerTree->Draw("Den_Pho_Pt>>h_den_Z_o",cut_Zeynep_d,"goff");

  TH1F *h_raw_Z_o = (TH1F*)h_num_Z_o->Clone("h_raw_Z_o");
  h_raw_Z_o->Divide(h_den_Z_o);





  TCanvas* c1 =  new TCanvas("c1","c1",700,600);
  c1->cd();

  h_raw_I->SetTitle("Raw Fake Rate");
  h_raw_I->GetYaxis()->SetTitle("Raw Fake Rate");
  h_raw_I->GetXaxis()->SetTitle("Offline Photon Pt [GeV]");
  h_raw_I->Draw();
  h_raw_I->GetYaxis()->SetRangeUser(0.0,15);

  h_raw_Z->SetLineColor(2);
  h_raw_Z->Draw("same");

  h_raw_Z_o->SetLineColor(4);
  h_raw_Z_o->Draw("same");


  gStyle->SetOptStat(kFALSE);
  
  TLegend *leg = new TLegend(0.6879195,0.7482517,0.9496644,0.9300699,NULL,"brNDC");
  leg->AddEntry(h_raw_I, "Iasonas Raw Fake Rate" ,"l");
  leg->AddEntry(h_raw_Z, "Zeynep Raw Fake Rate" ,"l");
  leg->AddEntry(h_raw_Z_o, "Zeynep old Raw Fake Rate" ,"l");

  leg->SetFillColor(0);
  leg->SetShadowColor(0);
  leg->Draw();
  
  

}
Example #3
0
void
SetOKStyle()
{
  TStyle* OKStyle = new TStyle("OKStyle", "OK Default Style");

  // Colors

  //set the background color to white
  OKStyle->SetFillColor(10);
  OKStyle->SetFrameFillColor(kWhite);
  OKStyle->SetFrameFillStyle(0);
  OKStyle->SetFillStyle(0);
  OKStyle->SetCanvasColor(kWhite);
  OKStyle->SetPadColor(kWhite);
  OKStyle->SetTitleFillColor(0);
  OKStyle->SetStatColor(kWhite);

  // Get rid of drop shadow on legends
  // This doesn't seem to work.  Call SetBorderSize(1) directly on your TLegends
  OKStyle->SetLegendBorderSize(1);

  //don't put a colored frame around the plots
  OKStyle->SetFrameBorderMode(0);
  OKStyle->SetCanvasBorderMode(0);
  OKStyle->SetPadBorderMode(0);

  //use the primary color palette
  OKStyle->SetPalette(1, 0);

  //set the default line color for a histogram to be black
  OKStyle->SetHistLineColor(kBlack);

  //set the default line color for a fit function to be red
  OKStyle->SetFuncColor(kBlue);

  //make the axis labels black
  OKStyle->SetLabelColor(kBlack, "xyz");

  //set the default title color to be black
  OKStyle->SetTitleColor(kBlack);

  //set the margins
  OKStyle->SetPadBottomMargin(0.15);
  OKStyle->SetPadLeftMargin(0.1);
  OKStyle->SetPadTopMargin(0.075);
  OKStyle->SetPadRightMargin(0.1);

  //set axis label and title text sizes
  OKStyle->SetLabelSize(0.035, "xyz");
  OKStyle->SetTitleSize(0.05, "xyz");
  OKStyle->SetTitleOffset(0.9, "xyz");
  OKStyle->SetStatFontSize(0.035);
  OKStyle->SetTextSize(0.05);
  OKStyle->SetTitleBorderSize(0);
  OKStyle->SetTitleStyle(0);

  OKStyle->SetLegendBorderSize(0);

  //set line widths
  OKStyle->SetHistLineWidth(1);
  OKStyle->SetFrameLineWidth(2);
  OKStyle->SetFuncWidth(2);

  // Misc

  //align the titles to be centered
  //OKStyle->SetTextAlign(22);

  //turn off xy grids
  OKStyle->SetPadGridX(1);
  OKStyle->SetPadGridY(1);

  //set the tick mark style
  OKStyle->SetPadTickX(1);
  OKStyle->SetPadTickY(1);

  //don't show the fit parameters in a box
  OKStyle->SetOptFit(0);

  //set the default stats shown
  OKStyle->SetOptStat(1);

  //marker settings
// 	OKStyle->SetMarkerStyle(8);
// 	OKStyle->SetMarkerSize(0.7);

  // Fonts
  OKStyle->SetStatFont(42);
  OKStyle->SetLabelFont(42, "xyz");
  OKStyle->SetTitleFont(42, "xyz");
  OKStyle->SetTextFont(42);

  // Set the paper size for output
  OKStyle->SetPaperSize(TStyle::kUSLetter);

  //done
  OKStyle->cd();

  cout << "Using Jin's Style" << endl;
}
void setMYStyle() {

  TStyle *myStyle = new TStyle("MYStyle","My Style");

// For the canvas:
  myStyle->SetCanvasBorderMode(0);
  myStyle->SetCanvasColor(kWhite);
  myStyle->SetCanvasDefH(600); //Height of canvas
  myStyle->SetCanvasDefW(600); //Width of canvas
  myStyle->SetCanvasDefX(0);   //POsition on screen
  myStyle->SetCanvasDefY(0);

// For the Pad:
  myStyle->SetPadBorderMode(0);
  myStyle->SetPadColor(kWhite);
  myStyle->SetPadGridX(false);
  myStyle->SetPadGridY(false);
  myStyle->SetGridColor(0);
  myStyle->SetGridStyle(3);
  myStyle->SetGridWidth(1);

// For the frame:
  myStyle->SetFrameBorderMode(0);
  myStyle->SetFrameBorderSize(1);
  myStyle->SetFrameFillColor(0);
  myStyle->SetFrameFillStyle(0);
  myStyle->SetFrameLineColor(1);
  myStyle->SetFrameLineStyle(1);
  myStyle->SetFrameLineWidth(1);

// For the histo:
  myStyle->SetHistLineColor(1);
  myStyle->SetHistLineStyle(0);
  myStyle->SetHistLineWidth(1);
  myStyle->SetEndErrorSize(2);
  myStyle->SetErrorX(0.);
  myStyle->SetMarkerStyle(20);

//For the fit/function:
  myStyle->SetOptFit(1);
  myStyle->SetFitFormat("5.4g");
  myStyle->SetFuncColor(2);
  myStyle->SetFuncStyle(1);
  myStyle->SetFuncWidth(1);

//For the date:
  myStyle->SetOptDate(0);

// For the statistics box:
  myStyle->SetOptFile(0);
  myStyle->SetOptStat(0); // To display the mean and RMS:   SetOptStat("mr");
  myStyle->SetStatColor(kWhite);
  myStyle->SetStatFont(42);
  myStyle->SetStatFontSize(0.025);
  myStyle->SetStatTextColor(1);
  myStyle->SetStatFormat("6.4g");
  myStyle->SetStatBorderSize(1);
  myStyle->SetStatH(0.1);
  myStyle->SetStatW(0.15);

// Margins:
  myStyle->SetPadTopMargin(0.07);
  myStyle->SetPadBottomMargin(0.13);
  myStyle->SetPadLeftMargin(0.13);
  myStyle->SetPadRightMargin(0.13);

// For the Global title:
  myStyle->SetOptTitle(0);
  myStyle->SetTitleFont(42);
  myStyle->SetTitleColor(1);
  myStyle->SetTitleTextColor(1);
  myStyle->SetTitleFillColor(10);
  myStyle->SetTitleFontSize(0.05);

// For the axis titles:
  myStyle->SetTitleColor(1, "XYZ");
  myStyle->SetTitleFont(42, "XYZ");
  myStyle->SetTitleSize(0.06, "XYZ");
  myStyle->SetTitleXOffset(0.9);
  myStyle->SetTitleYOffset(1.);

// For the axis labels:
  myStyle->SetLabelColor(1, "XYZ");
  myStyle->SetLabelFont(42, "XYZ");
  myStyle->SetLabelOffset(0.007, "XYZ");
  myStyle->SetLabelSize(0.045, "XYZ");

// For the axis:
  myStyle->SetAxisColor(1, "XYZ");
  myStyle->SetStripDecimals(kTRUE);
  myStyle->SetTickLength(0.03, "XYZ");
  myStyle->SetNdivisions(510, "XYZ");
  myStyle->SetPadTickX(1);  // To get tick marks on the opposite side of the frame
  myStyle->SetPadTickY(1);

// Change for log plots:
  myStyle->SetOptLogx(0);
  myStyle->SetOptLogy(0);
  myStyle->SetOptLogz(0);

// Postscript options:
  myStyle->SetPaperSize(20.,20.);

  myStyle->cd();
}
Example #5
0
void setHHStyle(TStyle& HHStyle)
{
    const int fontstyle=42;
    HHStyle.SetPalette(1);
        
    // ==============
    //  Canvas
    // ==============
            
    HHStyle.SetCanvasBorderMode(0);
    HHStyle.SetCanvasColor(kWhite);
    HHStyle.SetCanvasDefH(600); //Height of canvas
    HHStyle.SetCanvasDefW(600); //Width of canvas
    HHStyle.SetCanvasDefX(0);   //Position on screen
    HHStyle.SetCanvasDefY(0);
            
    // ==============
    //  Pad
    // ==============
            
    HHStyle.SetPadBorderMode(0);
    // HHStyle.SetPadBorderSize(Width_t size = 1);
    HHStyle.SetPadColor(kWhite);
    HHStyle.SetPadGridX(false);
    HHStyle.SetPadGridY(false);
    HHStyle.SetGridColor(kGray);
    HHStyle.SetGridStyle(3);
    HHStyle.SetGridWidth(1);
            
    // ==============
    //  Frame
    // ==============
            
    HHStyle.SetFrameBorderMode(0);
    HHStyle.SetFrameBorderSize(1);
    HHStyle.SetFrameFillColor(0);
    HHStyle.SetFrameFillStyle(0);
    HHStyle.SetFrameLineColor(1);
    HHStyle.SetFrameLineStyle(1);
    HHStyle.SetFrameLineWidth(1);
            
    // ==============
    //  Histo
    // ==============

    HHStyle.SetErrorX(0.0);
    HHStyle.SetEndErrorSize(8);
            
    // HHStyle.SetHistFillColor(1);
    // HHStyle.SetHistFillStyle(0);
    // HHStyle.SetHistLineColor(1);
    HHStyle.SetHistLineStyle(0);
    HHStyle.SetHistLineWidth(1);
    // HHStyle.SetLegoInnerR(Float_t rad = 0.5);
    // HHStyle.SetNumberContours(Int_t number = 20);

    // HHStyle.SetErrorMarker(20);
            
    HHStyle.SetMarkerStyle(20);
            
    // ==============
    //  Fit/function
    // ==============
            
    HHStyle.SetOptFit(0);
    HHStyle.SetFitFormat("5.4g");
    HHStyle.SetFuncColor(2);
    HHStyle.SetFuncStyle(1);
    HHStyle.SetFuncWidth(1);
            
    // ==============
    //  Date
    // ============== 
            
    HHStyle.SetOptDate(0);
    // HHStyle.SetDateX(Float_t x = 0.01);
    // HHStyle.SetDateY(Float_t y = 0.01);
            
    // =====================
    //  Statistics Box
    // =====================
            
    HHStyle.SetOptFile(0);
    HHStyle.SetOptStat(0); // To display the mean and RMS:   SetOptStat("mr");
    HHStyle.SetStatColor(kWhite);
    HHStyle.SetStatFont(fontstyle);
    HHStyle.SetStatFontSize(0.025);
    HHStyle.SetStatTextColor(1);
    HHStyle.SetStatFormat("6.4g");
    HHStyle.SetStatBorderSize(1);
    HHStyle.SetStatH(0.1);
    HHStyle.SetStatW(0.15);
    // HHStyle.SetStatStyle(Style_t style = 1001);
    // HHStyle.SetStatX(Float_t x = 0);
    // HHStyle.SetStatY(Float_t y = 0);
            
    // ==============
    //  Margins
    // ==============

    HHStyle.SetPadTopMargin(0.1);
    HHStyle.SetPadBottomMargin(0.15);
    HHStyle.SetPadLeftMargin(0.20);
    HHStyle.SetPadRightMargin(0.05);
            
    // ==============
    //  Global Title
    // ==============
            
    HHStyle.SetOptTitle(0);
    HHStyle.SetTitleFont(fontstyle);
    HHStyle.SetTitleColor(1);
    HHStyle.SetTitleTextColor(1);
    HHStyle.SetTitleFillColor(10);
    HHStyle.SetTitleFontSize(0.05);
    // HHStyle.SetTitleH(0); // Set the height of the title box
    // HHStyle.SetTitleW(0); // Set the width of the title box
    // HHStyle.SetTitleX(0); // Set the position of the title box
    // HHStyle.SetTitleY(0.985); // Set the position of the title box
    // HHStyle.SetTitleStyle(Style_t style = 1001);
    // HHStyle.SetTitleBorderSize(2);
            
    // ==============
    //  Axis titles
    // ==============
            
    HHStyle.SetTitleColor(1, "XYZ");
    HHStyle.SetTitleFont(fontstyle, "XYZ");
    HHStyle.SetTitleSize(0.04, "XYZ");
    // HHStyle.SetTitleXSize(Float_t size = 0.02); // Another way to set the size?
    // HHStyle.SetTitleYSize(Float_t size = 0.02);
    HHStyle.SetTitleXOffset(1.0);
    HHStyle.SetTitleYOffset(1.7);
    // HHStyle.SetTitleOffset(1.1, "Y"); // Another way to set the Offset
            
    // ==============
    //  Axis Label
    // ==============
            
    //HHStyle.SetLabelColor(1, "XYZ");
    HHStyle.SetLabelFont(fontstyle, "XYZ");
    HHStyle.SetLabelOffset(0.007, "XYZ");
    HHStyle.SetLabelSize(0.04, "XYZ");
            
    // ==============
    //  Axis
    // ==============
            
    HHStyle.SetAxisColor(1, "XYZ");
    HHStyle.SetStripDecimals(kTRUE);
    HHStyle.SetTickLength(0.03, "XYZ");
    HHStyle.SetNdivisions(510, "XYZ");
    HHStyle.SetPadTickX(1);  // To get tick marks on the opposite side of the frame
    HHStyle.SetPadTickY(1);
            
    // Change for log plots:
    HHStyle.SetOptLogx(0);
    HHStyle.SetOptLogy(0);
    HHStyle.SetOptLogz(0);
            
    // ==============
    //  Text
    // ==============
            
    HHStyle.SetTextAlign(11);
    HHStyle.SetTextAngle(0);
    HHStyle.SetTextColor(1);
    HHStyle.SetTextFont(fontstyle);
    HHStyle.SetTextSize(0.04);
            
    // =====================
    //  Postscript options:
    // =====================
            
    HHStyle.SetPaperSize(20.,20.);
    // HHStyle.SetLineScalePS(Float_t scale = 3);
    // HHStyle.SetLineStyleString(Int_t i, const char* text);
    // HHStyle.SetHeaderPS(const char* header);
    // HHStyle.SetTitlePS(const char* pstitle);
            
    // HHStyle.SetBarOffset(Float_t baroff = 0.5);
    // HHStyle.SetBarWidth(Float_t barwidth = 0.5);
    // HHStyle.SetPaintTextFormat(const char* format = "g");
    // HHStyle.SetPalette(Int_t ncolors = 0, Int_t* colors = 0);
    // HHStyle.SetTimeOffset(Double_t toffset);
    // HHStyle.SetHistMinimumZero(kTRUE);
}
Example #6
0
void Histograms(){

  //-------------------------------------------------------------------------------------------------------
  //use the style defined by Julia
  TStyle* jStyle = new TStyle("jStyle", "jStyle");
  Style(jStyle,1);

  //-------------------------------------------------------------------------------------------------------
  //user input
  //?
  Double_t time_cut = 5.89; //33.0 ns for 6.5 m det, 3.265 ns for 0.65 m detector, 5.84 ns for 0.65m+0.5m Buffer
  std::string out = "/home/christoph/geant4/MyG4_applications/Sphere1-build/output/Plots";
  Int_t width_pixels= 700;  //for automatic output graphs
  Int_t height_pixels=500;  // for automatic output graphs
  std::string coverage_string = "off"; 
  Int_t coverage = 0;

  //-------------------------------------------------------------------------------------------------------
  //define the Trees and fill them from the output files of the simulation
  //TTree *WL_Tree = new TTree("WL_Tree", "WL_Tree");
  TTree *Hits_Tree = new TTree("Hits_Tree", "Hits_Tree");      // Photon hits on sensitive elements
  TTree *Events_Tree = new TTree("Events_Tree","Events_Tree"); // From file with event information
  //WL_Tree->ReadFile("/home/christoph/geant4/MyG4_applications/Sphere1-build/output/wavelengths.txt", "wavelength");
  Hits_Tree->ReadFile("/home/christoph/geant4/MyG4_applications/Sphere1-build/output/photon_hits.txt","x_hit:y_hit:z_hit:cos_theta:photon_wavelength:true_time:PE_creation:PE_time:detection_coverage_included:true_time_corrected:PE_time_corrected:cos_theta_reco:theta_reco:phi_reco:process:eventID");
  Events_Tree->ReadFile("/home/christoph/geant4/MyG4_applications/Sphere1-build/output/events.txt","eventID_ET:Nprimaries:pos_x:pos_y:pos_z:fake_x:fake_y:fake_z:pdg1:Ekin1:dir_x1:dir_y1:dir_z1:pdg2:Ekin2:dir_x2:dir_y2:dir_z2:Npe:forward_hits:backward_hits");

  //-------------------------------------------------------------------------------------------------------
  //define the histograms which are output by default
  TH1F * wl_created = new TH1F("wl_created","Photons created originally (before propagation);wavelength [nm];entries per bin",175,100.,800.); //1
  TH1F * wl_hit = new TH1F("wl_hit","Photons which arrive at the sphere;wavelength [nm];entries per bin",175,100.,800.); //2  
  TH1F * cos_theta_detected = new TH1F("cos_theta_detected","True cos(#Theta), coverage and QE applied ;cos(#Theta);entries per bin",100,-1.,1.); //4
  TH1F * wl_hit_detected = new TH1F("wl_hit_detected","Photon hits which create photoelectrons (coverage and QE applied);wavelength [nm];entries per bin",175,100.,800.); //3
  TH1F * time_hit_detected = new TH1F("time_hit_detected","True time of photon hits which create photoelectrons (coverage and QE applied);true time [ns];entries per bin",3000,0.,300.); 
  TH1F * cos_theta_detected_cut = new TH1F("cos_theta_detected_cut","True cos(#Theta) of photon hits (coverage and QE and time cut applied);true cos(#Theta);entries per bin",100,-1.,1.); //6
  TH1F * time_afterTTS = new TH1F("time_afterTTS","Hit time after TTS has been applied (coverage and QE applied);time [ns];entries per bin",3000,0.,300.);  //5 
  TH1F * forward_hits_h = new TH1F("forward_hits_h","Number of detected forward hits (after time cut); Nhits; entries",300,0.,300.);
  TH1F * backward_hits_h = new TH1F("backward_hits_h","Number of detected backward hits (after time cut); Nhits; entries",300,0.,300.);
  TH1F * forward_over_backward_h = new TH1F("forward_over_backward_h","Ratio forward/backward hits (after reconstructed time cut);N_{forward}/N_{backward};entries",100,0.,3.); 
  TH1F * time_afterTTS_fakeVertex = new TH1F("time_afterTTS_fakeVertex","Time after correction (fake recoed vertex used) and after TTS applied, QE and coverage applied;time [ns];entries per bin",3000,0.,300);
  TH1F * time_afterTTS_fakeVertex_Cerenkov = new TH1F("time_afterTTS_fakeVertex_Cerenkov","Cerenkov only: Time after correction (fake recoed vertex used) and after TTS applied, QE applied, coverage not applied;time [ns];entries per bin",600,0.,60.);
  TH1F * time_afterTTS_fakeVertex_Scintillation = new TH1F("time_afterTTS_fakeVertex_Scintillation","Scintillation only: Time after correction (fake recoed vertex used) and after TTS applied, QE applied, coverage not applied;time [ns];entries per bin",600,0.,60.);
  TH1F * cos_theta_reco_detected = new TH1F("cos_theta_reco_detected","cos(#Theta) with reco vertex, QE and coverage applied;cos(#Theta);entries per bin",100,-1.,1.);
  TH1F * cos_theta_reco_detected_cut = new TH1F("cos_theta_reco_detected_cut","cos(#Theta) with reco vertex, QE and coverage applied, time cut applied;cos(#Theta);entries per bin",100,-1.,1.);  
  TH2F * theta_phi = new TH2F("theta_phi","all events: cos(#Theta) vs. #Phi (using reco vertex), QE applied, coverage not applied, time cut applied;#Phi;cos(#Theta);",1000,-TMath::Pi(),TMath::Pi(),1000,-1.0,1.0);
  TH2F * theta_phi_1event = new TH2F("theta_phi_1event","1 event: cos(#Theta) vs. #Phi (using reco vertex), QE applied, coverage not applied, time cut applied;#Phi;cos(#Theta);",1000,-TMath::Pi(),TMath::Pi(),1000,-1.0,1.0);
  TH2F * theta_phi_ideal = new TH2F("theta_phi_ideal","cos(#Theta) vs. #Phi (using reco vertex), QE not applied, coverage not applied, time cut applied;#Phi;cos(#Theta);",1000,-TMath::Pi(),TMath::Pi(),1000,-1.0,1.0);
  TH1F * cos_psi_h = new TH1F("cos_psi_h","cos(#Psi): Angle between original particle direction and direction from reco vertex to average hits, QE applied, coverage not applied, time cut applied ;cos(#Psi);entries",100,-1.,1.);
  //WL_Tree->Draw("photon_wavelength>>wl_created");


  //-------------------------------------------------------------------------------------------------------
  //fill histograms     
  Hits_Tree->Draw("photon_wavelength>>wl_hit");    
  Hits_Tree->Draw("cos_theta>>cos_theta_detected","detection_coverage_included==1 && PE_creation==1");
  Hits_Tree->Draw("cos_theta_reco>>cos_theta_reco_detected","detection_coverage_included==1 && PE_creation==1");
  Hits_Tree->Draw("photon_wavelength>>wl_hit_detected","detection_coverage_included==1 && PE_creation==1");
  Hits_Tree->Draw("true_time>>time_hit_detected","detection_coverage_included==1 && PE_creation==1");
  Hits_Tree->Draw("cos_theta>>cos_theta_detected_cut",Form("detection_coverage_included==1 && PE_creation==1 && PE_time_corrected < %f",time_cut));
  Hits_Tree->Draw("cos_theta_reco>>cos_theta_reco_detected_cut",Form("detection_coverage_included==1 && PE_creation==1 && PE_time_corrected < %f",time_cut));
  Hits_Tree->Draw("PE_time>>time_afterTTS","detection_coverage_included==1 && PE_creation==1");
  Hits_Tree->Draw("PE_time_corrected>>time_afterTTS_fakeVertex","detection_coverage_included==1 && PE_creation==1");
  Hits_Tree->Draw("PE_time_corrected>>time_afterTTS_fakeVertex_Cerenkov","PE_creation==1 && process==1");
  Hits_Tree->Draw("PE_time_corrected>>time_afterTTS_fakeVertex_Scintillation","PE_creation==1 && process==0");
  Events_Tree->Draw("forward_hits>>forward_hits_h");
  Events_Tree->Draw("backward_hits>>backward_hits_h");
  Events_Tree->Draw("forward_hits/backward_hits>>forward_over_backward_h");
  Hits_Tree->Draw("cos(theta_reco):phi_reco>>theta_phi",Form("PE_creation==1 && PE_time_corrected < %f",time_cut),"");
  Hits_Tree->Draw("cos(theta_reco):phi_reco>>theta_phi_1event",Form("eventID==0 && PE_creation==1 && PE_time_corrected < %f",time_cut),"");
  Hits_Tree->Draw("cos(theta_reco):phi_reco>>theta_phi_ideal",Form("PE_time_corrected < %f",time_cut),"");



  //-------------------------------------------------------------------------------------------------------
  // calculate some integrals, this is deprecated, if I need it again I would count the numbers at simulation runtime  
  // ?deprecated 
  int count1=0;
  int count2=0;
  count1=wl_created->Integral(  wl_created->FindBin(360.)  ,  wl_created->FindBin(550.) -1 );
  count2=wl_created->Integral(  wl_created->FindBin(400.)  ,  wl_created->FindBin(550.) -1 );
  
  int count3=0;
  int count4=0;
  count3=wl_hit->Integral(  wl_hit->FindBin(360.)  ,  wl_hit->FindBin(550.) -1 );
  count4=wl_hit->Integral(  wl_hit->FindBin(400.)  ,  wl_hit->FindBin(550.) -1 );

  int count1_detected=0;
  int count2_detected=0;
  count1_detected=wl_hit_detected->Integral(  wl_hit_detected->FindBin(360.)  ,  wl_hit_detected->FindBin(550.) -1 );
  count2_detected=wl_hit_detected->Integral(  wl_hit_detected->FindBin(400.)  ,  wl_hit_detected->FindBin(550.) -1 );

  //-------------------------------------------------------------------------------------------------------
  //calculate the number of photons which are detected in forward direction and backward direction, respectively (after time cut)
  int count_forward=0;
  int count_backward=0;
  count_backward=cos_theta_detected_cut->Integral( cos_theta_detected_cut->FindBin(-0.99999999),cos_theta_detected_cut->FindBin(-0.00000001));
  count_forward=cos_theta_detected_cut->Integral( cos_theta_detected_cut->FindBin(0.00000001),cos_theta_detected_cut->FindBin(0.99999999)); 
  TNtuple *tn1 = new TNtuple("tn1","","nphot_created_360_550:nphot_created_400_550:nphot_hit_360_550:nphot_hit_400_550:nphot_detected_360_550:nphot_detected_400_550:count_forward:count_backward");
  tn1->Fill(count1,count2,count3,count4,count1_detected,count2_detected,count_forward,count_backward);


  //-----------------------------------------------------------------------------------------------------------------------
  //analysis: calculate the mean hit position to get an estimate of the direction
  //step1: define variables and branches for the TTrees
  Float_t x_hit_v = 0.0;
  Float_t y_hit_v = 0.0;
  Float_t z_hit_v = 0.0;
  Float_t cos_theta_v = 0.0;
  Float_t photon_wavelength_v = 0.0;
  Float_t true_time_v = 0.0;
  Float_t PE_creation_v = 0.0;
  Float_t PE_time_v = 0.0;
  Float_t detection_coverage_included_v = 0.0;
  Float_t true_time_corrected_v = 0.0;
  Float_t PE_time_corrected_v = 0.0;
  Float_t cos_theta_reco_v = 0.0;
  Float_t theta_reco_v = 0.0; 
  Float_t phi_reco_v = 0.0;
  Float_t process_v = 0.0;
  Float_t eventID_v = 0.0;

  TBranch  *x_hit_b = 0;
  TBranch  *y_hit_b = 0;
  TBranch  *z_hit_b = 0;
  TBranch  *cos_theta_b = 0;
  TBranch  *photon_wavelength_b = 0;
  TBranch  *true_time_b = 0;
  TBranch  *PE_creation_b = 0;
  TBranch  *PE_time_b = 0;
  TBranch  *detection_coverage_included_b = 0;
  TBranch  *true_time_corrected_b = 0;
  TBranch  *PE_time_corrected_b = 0;
  TBranch  *cos_theta_reco_b = 0;
  TBranch  *theta_reco_b = 0;
  TBranch  *phi_reco_b = 0;
  TBranch  *process_b = 0;
  TBranch  *eventID_b = 0;

  Hits_Tree->SetBranchAddress("x_hit", &x_hit_v, &x_hit_b);
  Hits_Tree->SetBranchAddress("y_hit", &y_hit_v, &y_hit_b);
  Hits_Tree->SetBranchAddress("z_hit", &z_hit_v, &z_hit_b);  
  Hits_Tree->SetBranchAddress("cos_theta", &cos_theta_v, &cos_theta_b);
  Hits_Tree->SetBranchAddress("photon_wavelength", &photon_wavelength_v, &photon_wavelength_b);
  Hits_Tree->SetBranchAddress("true_time", &true_time_v, &true_time_b);
  Hits_Tree->SetBranchAddress("PE_creation", &PE_creation_v, &PE_creation_b);
  Hits_Tree->SetBranchAddress("PE_time", &PE_time_v, &PE_time_b);
  Hits_Tree->SetBranchAddress("detection_coverage_included", &detection_coverage_included_v, &detection_coverage_included_b);
  Hits_Tree->SetBranchAddress("true_time_corrected", &true_time_corrected_v, &true_time_corrected_b);
  Hits_Tree->SetBranchAddress("PE_time_corrected", &PE_time_corrected_v, &PE_time_corrected_b);
  Hits_Tree->SetBranchAddress("cos_theta_reco", &cos_theta_reco_v, &cos_theta_reco_b);
  Hits_Tree->SetBranchAddress("theta_reco", &theta_reco_v, &theta_reco_b);
  Hits_Tree->SetBranchAddress("phi_reco", &phi_reco_v, &phi_reco_b);
  Hits_Tree->SetBranchAddress("process", &process_v, &process_b);
  Hits_Tree->SetBranchAddress("eventID", &eventID_v, &eventID_b);
 
  //Event Tree
  Float_t eventID_ET_v = 0.0;
  Float_t Nprimaries_v = 0.0;
  Float_t pos_x_v = 0.0;
  Float_t pos_y_v = 0.0;
  Float_t pos_z_v = 0.0;
  Float_t fake_x_v = 0.0;
  Float_t fake_y_v = 0.0;
  Float_t fake_z_v = 0.0;
  Float_t pdg1_v = 0.0;
  Float_t Ekin1_v = 0.0;
  Float_t dir_x1_v = 0.0;
  Float_t dir_y1_v = 0.0;
  Float_t dir_z1_v = 0.0;
  Float_t pdg2_v = 0.0;
  Float_t Ekin2_v = 0.0;
  Float_t dir_x2_v = 0.0;
  Float_t dir_y2_v = 0.0;
  Float_t dir_z2_v = 0.0;
  Float_t Npe_v = 0.0;
  Float_t forward_hits_v = 0.0;
  Float_t backward_hits_v = 0.0;

  TBranch *eventID_ET_b = 0;
  TBranch *Nprimaries_b = 0;
  TBranch *pos_x_b = 0;
  TBranch *pos_y_b = 0;
  TBranch *pos_z_b = 0;
  TBranch *fake_x_b = 0;
  TBranch *fake_y_b = 0;
  TBranch *fake_z_b = 0;
  TBranch *pdg1_b = 0;
  TBranch *Ekin1_b = 0;
  TBranch *dir_x1_b = 0;
  TBranch *dir_y1_b = 0;
  TBranch *dir_z1_b = 0;
  TBranch *pdg2_b = 0;
  TBranch *Ekin2_b = 0;
  TBranch *dir_x2_b = 0;
  TBranch *dir_y2_b = 0;
  TBranch *dir_z2_b = 0;
  TBranch *Npe_b = 0;
  TBranch *forward_hits_b = 0;
  TBranch *backward_hits_b = 0;

  Events_Tree->SetBranchAddress("eventID_ET", &eventID_ET_v, &eventID_ET_b);
  Events_Tree->SetBranchAddress("Nprimaries", &Nprimaries_v, &Nprimaries_b);
  Events_Tree->SetBranchAddress("pos_x", &pos_x_v, &pos_x_b);
  Events_Tree->SetBranchAddress("pos_y", &pos_y_v, &pos_y_b);
  Events_Tree->SetBranchAddress("pos_z", &pos_z_v, &pos_z_b);
  Events_Tree->SetBranchAddress("fake_x", &fake_x_v, &fake_x_b);
  Events_Tree->SetBranchAddress("fake_y", &fake_y_v, &fake_y_b);
  Events_Tree->SetBranchAddress("fake_z", &fake_z_v, &fake_z_b);
  Events_Tree->SetBranchAddress("pdg1", &pdg1_v, &pdg1_b);
  Events_Tree->SetBranchAddress("Ekin1", &Ekin1_v, &Ekin1_b);
  Events_Tree->SetBranchAddress("dir_x1", &dir_x1_v, &dir_x1_b);
  Events_Tree->SetBranchAddress("dir_y1", &dir_y1_v, &dir_y1_b);
  Events_Tree->SetBranchAddress("dir_z1", &dir_z1_v, &dir_z1_b);
  Events_Tree->SetBranchAddress("pdg2", &pdg2_v, &pdg2_b);
  Events_Tree->SetBranchAddress("Ekin2", &Ekin2_v, &Ekin2_b);
  Events_Tree->SetBranchAddress("dir_x2", &dir_x2_v, &dir_x2_b);
  Events_Tree->SetBranchAddress("dir_y2", &dir_y2_v, &dir_y2_b);
  Events_Tree->SetBranchAddress("dir_z2", &dir_z2_v, &dir_z2_b);
  Events_Tree->SetBranchAddress("Npe", &Npe_v, &Npe_b);
  Events_Tree->SetBranchAddress("forward_hits", &forward_hits_v, &forward_hits_b);
  Events_Tree->SetBranchAddress("backward_hits", &backward_hits_v, &backward_hits_b);


  //-----------------------------------------------------------------------------------------------------------------------
  //step2: Loop over Hits and calculate mean hit position for hits which create PEs and fulfill the time cut. 
  Long64_t nentries = Hits_Tree->GetEntries(); 
  cout << "nentries = " << nentries << endl; 

  Float_t mean_x_hit=0.0;
  Float_t mean_y_hit=0.0;
  Float_t mean_z_hit=0.0;
  Int_t current_event=0.0;
  Int_t hit_count=0;
  Double_t cos_psi=0.0;

  for (Long64_t i=0;i<nentries;i++) 
    {
      Hits_Tree->GetEntry(i);
      //y_hit_b->GetEntry(i);
      //z_hit_b->GetEntry(i);
      //cout << "i= " << i << ", x_hit_v= " << x_hit_v << ", y_hit_v=" << y_hit_v << ", z_hit_v=" << z_hit_v << endl; 

      if(current_event!=eventID_v)
        {
          mean_x_hit=mean_x_hit/hit_count;
          mean_y_hit=mean_y_hit/hit_count;
          mean_z_hit=mean_z_hit/hit_count;

          //calculation of cos(angle) between reconstructed direction and real direction (1,0,0)=x
          //cos_psi = mean_x_hit/sqrt(mean_x_hit*mean_x_hit + mean_y_hit*mean_y_hit + mean_z_hit*mean_z_hit); //This is if we knew the vertex (0,0,0) 
          Events_Tree->GetEntry(current_event);
          //hardcoded direction of original particle: x-direction!! 
          //?
          cos_psi = (mean_x_hit-fake_x_v)/std::sqrt((mean_x_hit-fake_x_v)*(mean_x_hit-fake_x_v)+(mean_y_hit-fake_y_v)*(mean_y_hit-fake_y_v)+(mean_z_hit-fake_z_v)*(mean_z_hit-fake_z_v));           

          cos_psi_h->Fill(cos_psi); 
          cout << "current_event= " << current_event << ", hit_count= " << hit_count << ", mean_x_hit= " << mean_x_hit << ", mean_y_hit= " << mean_y_hit << ", mean_z_hit= " << mean_z_hit << ", fake_x_v= " << fake_x_v << ", fake_y_v= " << fake_y_v << ", fake_z_v= " << fake_z_v << endl;

          mean_x_hit=0.0;
          mean_y_hit=0.0;
          mean_z_hit=0.0;
          hit_count=0;
        }
   
      if(PE_creation_v == 1 && PE_time_corrected_v < time_cut)
        {
          mean_x_hit+=x_hit_v;
          mean_y_hit+=y_hit_v;
          mean_z_hit+=z_hit_v;
          hit_count+=1;
        }
      current_event=eventID_v;
       
    }
  //get the cos_psi value for the last event
  mean_x_hit=mean_x_hit/hit_count;
  mean_y_hit=mean_y_hit/hit_count;
  mean_z_hit=mean_z_hit/hit_count;
  //calculation of cos(angle) between reconstructed direction and real direction (1,0,0):
  Events_Tree->GetEntry(current_event);
  cos_psi = (mean_x_hit-fake_x_v)/std::sqrt((mean_x_hit-fake_x_v)*(mean_x_hit-fake_x_v)+(mean_y_hit-fake_y_v)*(mean_y_hit-fake_y_v)+(mean_z_hit-fake_z_v)*(mean_z_hit-fake_z_v));
  cos_psi_h->Fill(cos_psi);
  cout << "current_event= " << current_event << ", hit_count= " << hit_count << ", mean_x_hit= " << mean_x_hit << ", mean_y_hit= " << mean_y_hit << ", mean_z_hit= " << mean_z_hit << ", fake_x_v= " << fake_x_v << ", fake_y_v= " << fake_y_v << ", fake_z_v= " << fake_z_v << endl;


  //-----------------------------------------------------------------------------------------------------------------------
  //
  TFile *tf = new TFile("/home/christoph/geant4/MyG4_applications/Sphere1-build/output/output.root","NEW");

  //make histograms nicer
  format_h(wl_hit,1,2);
  format_h(wl_hit_detected,1,2);
  format_h(cos_theta_detected,1,2);
  format_h(cos_theta_reco_detected,1,2);
  format_h(time_hit_detected,1,2);
  format_h(cos_theta_detected_cut,1,2);
  format_h(time_afterTTS,1,2);
  format_h(time_afterTTS_fakeVertex,1,2);
  format_h(time_afterTTS_fakeVertex_Cerenkov,1,2);
  format_h(time_afterTTS_fakeVertex_Scintillation,1,2);
  format_h(forward_hits_h,1,2);
  format_h(backward_hits_h,1,2);
  format_h(forward_over_backward_h,1,2);
  format_h(cos_psi_h,1,2);
 
  //write Trees and histograms to file
  //WL_Tree->Write();
  Hits_Tree->Write();
  Events_Tree->Write();
  tn1->Write();
  wl_created->Write();
  wl_hit->Write();
  wl_hit_detected->Write();
  cos_theta_detected->Write();
  cos_theta_reco_detected->Write();
  time_hit_detected->Write();
  cos_theta_detected_cut->Write();
  time_afterTTS->Write();
  time_afterTTS_fakeVertex->Write();
  time_afterTTS_fakeVertex_Cerenkov->Write();
  time_afterTTS_fakeVertex_Scintillation->Write();
  forward_hits_h->Write();
  backward_hits_h->Write();
  forward_over_backward_h->Write();
  theta_phi->Write();
  theta_phi_1event->Write();
  theta_phi_ideal->Write();
  cos_psi_h->Write();

  //create a few selected plots
  //plot1
  TCanvas* c1 = new TCanvas("c1", "source energy", width_pixels, height_pixels); 
  theta_phi->Draw("goff");
  jStyle->SetFrameLineWidth(2);
  theta_phi->SetMarkerColor(2);
  //theta_phi->SetMarkerStyle(7);
  c1->Update();
  c1->SaveAs(Form("%s/theta_phi.png",out.c_str()),"png");
  c1->SaveAs(Form("%s/theta_phi.C",out.c_str()),"C");

  //plot2
  theta_phi_1event->Draw("goff");
  jStyle->SetFrameLineWidth(2); 
  theta_phi_1event->SetMarkerColor(2);
  theta_phi_1event->SetMarkerStyle(20);
  c1->Update();
  c1->SaveAs(Form("%s/theta_phi_1event.png",out.c_str()),"png");
  c1->SaveAs(Form("%s/theta_phi_1event.C",out.c_str()),"C");
 
  //plot3
  cos_psi_h->Draw();
  jStyle->SetFrameLineWidth(2);
  cos_psi_h->SetLineColor(2); 
  c1->Update();
  c1->SaveAs(Form("%s/cos_psi_h.png",out.c_str()),"png");
  c1->SaveAs(Form("%s/cos_psi_h.C",out.c_str()),"C");  

  //plot4
  time_afterTTS_fakeVertex_Scintillation->SetLineColor(2);
  time_afterTTS_fakeVertex_Scintillation->Draw();
  time_afterTTS_fakeVertex_Cerenkov->SetLineColor(4);
  time_afterTTS_fakeVertex_Cerenkov->Draw("same");
  TLine * tl1 = new TLine(3.265,0.0,3.265,10000000.);
  tl1->SetLineWidth(2);
  tl1->SetLineStyle(2);
  //tl1->Draw("same");
  c1->Update();
  c1->SaveAs(Form("%s/time_afterTTS_fakeVertex.png",out.c_str()),"png");
  c1->SaveAs(Form("%s/time_afterTTS_fakeVertex.C",out.c_str()),"C");  


  tf->Close();


  
}
Example #7
0
void Style(){
	
	TStyle *tdrStyle = new TStyle("tdrStyle","Style for P-TDR");
	
	// For the canvas:
	tdrStyle->SetCanvasBorderMode(0);
	tdrStyle->SetCanvasColor(kWhite);
	tdrStyle->SetCanvasDefH(600); //Height of canvas
	tdrStyle->SetCanvasDefW(1100); //Width of canvas
	tdrStyle->SetCanvasDefX(0);   //POsition on screen
	tdrStyle->SetCanvasDefY(0);
	
	// For the Pad:
	tdrStyle->SetPadBorderMode(0);
	tdrStyle->SetPadColor(kWhite);
	tdrStyle->SetPadGridX(false);
	tdrStyle->SetPadGridY(false);
	tdrStyle->SetGridColor(0);
	tdrStyle->SetGridStyle(3);
	tdrStyle->SetGridWidth(1);
	
	// For the frame:
	tdrStyle->SetFrameBorderMode(0);
	tdrStyle->SetFrameBorderSize(1);
	tdrStyle->SetFrameFillColor(0);
	tdrStyle->SetFrameFillStyle(0);
	tdrStyle->SetFrameLineColor(1);
	tdrStyle->SetFrameLineStyle(1);
	tdrStyle->SetFrameLineWidth(1);
	
	tdrStyle->SetHistLineWidth(1.5);
	//For the fit/function:
	tdrStyle->SetOptFit(1);
	tdrStyle->SetStatColor(kWhite);
	tdrStyle->SetStatFont(42);
	tdrStyle->SetStatFontSize(0.025);
	tdrStyle->SetOptStat(000000);
	tdrStyle->SetStatColor(kWhite);
	
	// Margins:
	tdrStyle->SetPadTopMargin(0.05);
	tdrStyle->SetPadBottomMargin(0.13);
	tdrStyle->SetPadLeftMargin(0.10);
	tdrStyle->SetPadRightMargin(0.02);
	
	// For the Global title:
	
	tdrStyle->SetOptTitle(0);
	tdrStyle->SetTitleFont(42);
	tdrStyle->SetTitleColor(1);
	tdrStyle->SetTitleTextColor(1);
	tdrStyle->SetTitleFillColor(10);
	tdrStyle->SetTitleFontSize(0.05);
	
	// For the axis titles:
	
	tdrStyle->SetTitleColor(1, "XYZ");
	tdrStyle->SetTitleFont(42, "XYZ");
	tdrStyle->SetTitleSize(0.04, "XYZ");
	tdrStyle->SetTitleXOffset(1.1);
	tdrStyle->SetTitleYOffset(1.1);
	
	// For the axis labels:
	
	tdrStyle->SetLabelColor(1, "XYZ");
	tdrStyle->SetLabelFont(42, "XYZ");
	tdrStyle->SetLabelOffset(0.007, "XYZ");
	tdrStyle->SetLabelSize(0.04, "XYZ");
	
	// For the axis:
	
	tdrStyle->SetAxisColor(1, "XYZ");
	tdrStyle->SetStripDecimals(kTRUE);
	tdrStyle->SetTickLength(0.03, "XYZ");
	tdrStyle->SetNdivisions(510, "XYZ");
	tdrStyle->SetPadTickX(1);  // To get tick marks on the opposite side of the frame
	tdrStyle->SetPadTickY(1);
	
	// Change for log plots:
	tdrStyle->SetOptLogx(0);
	tdrStyle->SetOptLogy(0);
	tdrStyle->SetOptLogz(0);
	
	// Postscript options:
	tdrStyle->SetPaperSize(20.,20.);
	
	tdrStyle->cd();
	
	gStyle->SetFillColor(-1);
}
void teenyWeenyBtagEffCalculation(){
  
  // TDR style crap - include from Utilities.cc
  TStyle *tdrStyle = new TStyle("tdrStyle","Style for P-TDR");
  // For the canvas:
  tdrStyle->SetCanvasBorderMode(0);
  tdrStyle->SetCanvasColor(kWhite);
  tdrStyle->SetCanvasDefH(600); //Height of canvas
  tdrStyle->SetCanvasDefW(600); //Width of canvas
  tdrStyle->SetCanvasDefX(0);   //Position on screen
  tdrStyle->SetCanvasDefY(0);
  
  // For the Pad:
  tdrStyle->SetPadBorderMode(0);
  // tdrStyle->SetPadBorderSize(Width_t size = 1);
  tdrStyle->SetPadColor(kWhite);
  tdrStyle->SetPadGridX(false);
  tdrStyle->SetPadGridY(false);
  tdrStyle->SetGridColor(0);
  tdrStyle->SetGridStyle(3);
  tdrStyle->SetGridWidth(1);
  
  // For the frame:
  tdrStyle->SetFrameBorderMode(0);
  tdrStyle->SetFrameBorderSize(1);
  tdrStyle->SetFrameFillColor(0);
  tdrStyle->SetFrameFillStyle(0);
  tdrStyle->SetFrameLineColor(1);
  tdrStyle->SetFrameLineStyle(1);
  tdrStyle->SetFrameLineWidth(1);
  
  // For the histo:
  // tdrStyle->SetHistFillColor(1);
  // tdrStyle->SetHistFillStyle(0);
  tdrStyle->SetHistLineColor(1);
  tdrStyle->SetHistLineStyle(0);
  tdrStyle->SetHistLineWidth(1);
  // tdrStyle->SetLegoInnerR(Float_t rad = 0.5);
  // tdrStyle->SetNumberContours(Int_t number = 20);
  
  tdrStyle->SetEndErrorSize(2);
  //tdrStyle->SetErrorMarker(20);
  tdrStyle->SetErrorX(0.);
  
  tdrStyle->SetMarkerStyle(20);
  
  //For the fit/function:
  tdrStyle->SetOptFit(1);
  tdrStyle->SetFitFormat("5.4g");
  tdrStyle->SetFuncColor(2);
  tdrStyle->SetFuncStyle(1);
  tdrStyle->SetFuncWidth(1);
  
  //For the date:
  tdrStyle->SetOptDate(0);
  // tdrStyle->SetDateX(Float_t x = 0.01);
  // tdrStyle->SetDateY(Float_t y = 0.01);
  
  // For the statistics box:
  tdrStyle->SetOptFile(0);
  tdrStyle->SetOptStat(0); // To display the mean and RMS:   SetOptStat("mr");
  tdrStyle->SetStatColor(kWhite);
  tdrStyle->SetStatFont(42);
  tdrStyle->SetStatFontSize(0.025);
  tdrStyle->SetStatTextColor(1);
  tdrStyle->SetStatFormat("6.4g");
  tdrStyle->SetStatBorderSize(1);
  tdrStyle->SetStatH(0.1);
  tdrStyle->SetStatW(0.15);
  // tdrStyle->SetStatStyle(Style_t style = 1001);
  // tdrStyle->SetStatX(Float_t x = 0);
  // tdrStyle->SetStatY(Float_t y = 0);

  // Margins:
  tdrStyle->SetPadTopMargin(0.05);
  tdrStyle->SetPadBottomMargin(0.13);
  tdrStyle->SetPadLeftMargin(0.16);
  tdrStyle->SetPadRightMargin(0.04);
  
  // For the Global title:

  tdrStyle->SetOptTitle(0);
  tdrStyle->SetTitleFont(42);
  tdrStyle->SetTitleColor(1);
  tdrStyle->SetTitleTextColor(1);
  tdrStyle->SetTitleFillColor(10);
  tdrStyle->SetTitleFontSize(0.05);
  // tdrStyle->SetTitleH(0); // Set the height of the title box
  // tdrStyle->SetTitleW(0); // Set the width of the title box
  // tdrStyle->SetTitleX(0); // Set the position of the title box
  // tdrStyle->SetTitleY(0.985); // Set the position of the title box
  // tdrStyle->SetTitleStyle(Style_t style = 1001);
  // tdrStyle->SetTitleBorderSize(2);
  
  // For the axis titles:
  
  tdrStyle->SetTitleColor(1, "XYZ");
  tdrStyle->SetTitleFont(42, "XYZ");
  tdrStyle->SetTitleSize(0.05, "XYZ");
  // tdrStyle->SetTitleXSize(Float_t size = 0.02); // Another way to set the size?
  // tdrStyle->SetTitleYSize(Float_t size = 0.02);
  tdrStyle->SetTitleXOffset(0.9);
  tdrStyle->SetTitleYOffset(1.25);
  // tdrStyle->SetTitleOffset(1.1, "Y"); // Another way to set the Offset
//  tdrStyle->SetTitleOffset(.3, "X"); // Another way to set the Offset
//  tdrStyle->SetTitleOffset(1., "Y"); // Another way to set the Offset
//  
  // For the axis labels:

  tdrStyle->SetLabelColor(1, "XYZ");
  tdrStyle->SetLabelFont(42, "XYZ");
  tdrStyle->SetLabelOffset(0.007, "XYZ");
  tdrStyle->SetLabelSize(0.05, "XYZ");

  // For the axis:

  tdrStyle->SetAxisColor(1, "XYZ");
  tdrStyle->SetStripDecimals(kTRUE);
  tdrStyle->SetTickLength(0.03, "XYZ");
  tdrStyle->SetNdivisions(510, "XYZ");
  tdrStyle->SetPadTickX(1);  // To get tick marks on the opposite side of the frame
  tdrStyle->SetPadTickY(1);

  // Change for log plots:
  tdrStyle->SetOptLogx(0);
  tdrStyle->SetOptLogy(0);
  tdrStyle->SetOptLogz(0);

  // Postscript options:
  tdrStyle->SetPaperSize(20.,20.);
  // tdrStyle->SetLineScalePS(Float_t scale = 3);
  // tdrStyle->SetLineStyleString(Int_t i, const char* text);
  // tdrStyle->SetHeaderPS(const char* header);
  // tdrStyle->SetTitlePS(const char* pstitle);

  // tdrStyle->SetBarOffset(Float_t baroff = 0.5);
  // tdrStyle->SetBarWidth(Float_t barwidth = 0.5);
  // tdrStyle->SetPaintTextFormat(const char* format = "g");
  // tdrStyle->SetPalette(Int_t ncolors = 0, Int_t* colors = 0);
  // tdrStyle->SetTimeOffset(Double_t toffset);
  // tdrStyle->SetHistMinimumZero(kTRUE);

  tdrStyle->cd();

  // Meat of the stuff

//
//  ned in current scope  (tmpfile):1:
//    (const int)0
//*** Interpreter error recovered ***
//root [4] .ls
//      TFile**/lustre/ncg.ingrid.pt/cmslocal/samples/CMSSW_5_3_7_patch4/chiggs/fakerate_fractionsEstimate/trees/TauFRWMuMCFailing_PFlow.root
//      TFile*/lustre/ncg.ingrid.pt/cmslocal/samples/CMSSW_5_3_7_patch4/chiggs/fakerate_fractionsEstimate/trees/TauFRWMuMCFailing_PFlow.root
//root [5] .q
//[vischia@ui-cms01 TopTaus]$ ls /lustre/ncg.ingrid.pt/
//cmslocal/ cmst3/    data1/    data2/    data3/    
//[vischia@ui-cms01 TopTaus]$ ls /lustre/ncg.ingrid.pt/cmslocal/vischia/
//MyTMVA_temporaneo/      backupFirstFullRun2012/ myt
//
//																									   
//	

  TFile* ttmutau = new TFile("/lustre/ncg.ingrid.pt/cmslocal/vischia/store/tau/Jan13ReReco/dataRedo/test_preapp2/nomt-2012-V1-mc-MU-20GeV/out-ttbar-mutau.root");
  
  TH1F* btag_eff_fakebs_num   = (TH1F*) ttmutau->Get("PFlow/RecoSteps/m_tau/MET/btag_eff_fakebs_num_27" );                 
  TH1F* btag_eff_fakebs_den   = (TH1F*) ttmutau->Get("PFlow/RecoSteps/m_tau/MET/btag_eff_fakebs_den_27" );
  TH1F* btag_eff_nomatch_num  = (TH1F*) ttmutau->Get("PFlow/RecoSteps/m_tau/MET/btag_eff_nomatch_num_27");
  TH1F* btag_eff_nomatch_den  = (TH1F*) ttmutau->Get("PFlow/RecoSteps/m_tau/MET/btag_eff_nomatch_den_27");
  TH1F* btag_eff_fakebs2_num  = (TH1F*) ttmutau->Get("PFlow/RecoSteps/m_tau/MET/btag_eff_fakebs2_num_27");
  TH1F* btag_eff_fakebs2_den  = (TH1F*) ttmutau->Get("PFlow/RecoSteps/m_tau/MET/btag_eff_fakebs2_den_27");
  TH1F* btag_eff_realbs_num   = (TH1F*) ttmutau->Get("PFlow/RecoSteps/m_tau/MET/btag_eff_realbs_num_27" );
  TH1F* btag_eff_realbs_den   = (TH1F*) ttmutau->Get("PFlow/RecoSteps/m_tau/MET/btag_eff_realbs_den_27" );   
  
  //  num= passing
  //  den = non passing
  
  double fakesWNonMatchedPassing_over_fakesWNonMatchedNonPassing = ( btag_eff_fakebs_num->Integral()+ btag_eff_nomatch_num->Integral() )  / ( btag_eff_fakebs_den->Integral() + btag_eff_nomatch_den->Integral()     );
  double fakesWoutNonMatchedPassing_over_fakesWoutNonMatchedNonPassing = btag_eff_fakebs_num->Integral() /     btag_eff_fakebs_den->Integral();
  double fakesAllNonBsPassing_over_fakesAllNonBsNonPassing = btag_eff_fakebs2_num->Integral() /     btag_eff_fakebs2_den->Integral();
  double realBsNonPassing_over_fakeAndRealbsNonPassing =  btag_eff_realbs_den->Integral() /   (  btag_eff_fakebs_den->Integral() +btag_eff_realbs_den->Integral());
  double realBsPassing_over_realBsNonPassing  = btag_eff_realbs_num->Integral() /  btag_eff_realbs_den->Integral();
  double realBsPassing_over_realBs  = btag_eff_realbs_num->Integral() / ( btag_eff_realbs_num->Integral() + btag_eff_realbs_den->Integral()   );
  double fakeBsPassing_over_fakeBs  = btag_eff_fakebs_num->Integral() / ( btag_eff_fakebs_num->Integral() + btag_eff_fakebs_den->Integral()   );
  double fakeBsPassing_over_fakeBs_includeNonMatched  = btag_eff_fakebs2_num->Integral() / ( btag_eff_fakebs2_num->Integral() + btag_eff_fakebs2_den->Integral()   );

  cout << "fakesWNonMatchedPassing_over_fakesWNonMatchedNonPassing: "        << fakesWNonMatchedPassing_over_fakesWNonMatchedNonPassing	   <<endl;   
  cout << "fakesWoutNonMatchedPassing_over_fakesWoutNonMatchedNonPassing: "  << fakesWoutNonMatchedPassing_over_fakesWoutNonMatchedNonPassing <<endl;
  cout << "fakesAllNonBsPassing_over_fakesAllNonBsNonPassing: "	        << fakesAllNonBsPassing_over_fakesAllNonBsNonPassing	      	   <<endl;
  cout << "realBsNonPassing_over_fakeAndRealbsNonPassing: "		        << realBsNonPassing_over_fakeAndRealbsNonPassing	   <<endl;	      
  cout << "realBsPassing_over_realBsNonPassing: "                            << realBsPassing_over_realBsNonPassing                           <<endl;
  cout << "realBsPassing_over_realBs: "                                      << realBsPassing_over_realBs                                   <<endl;
  cout << "fakeBsPassing_over_fakeBs: "                                      << fakeBsPassing_over_fakeBs                                   <<endl;
  cout << "fakeBsPassing_over_fakeBs_includeNonMatched: "                    << fakeBsPassing_over_fakeBs_includeNonMatched                 <<endl;
//  
//  httllq->Sumw2();
//  httllg->Sumw2();
//
//  httllq->Add(hwjetq,1.);
//  httllg->Add(hwjetg,1.);
//  httlla->Add(hwjeta,1.);
//
//  double fqf= httllq->Integral() / (httllq->Integral() + httllg->Integral());
//  double fgf= httllg->Integral() / (httllq->Integral() + httllg->Integral());
//  
// 
//  cout << "Fractions in ttll sample: quarks " << ttllfq << ", gluons " << ttllfg << endl;
//  cout << "Fractions in wjet sample: quarks " << wjetfq << ", gluons " << wjetfg << endl;
//  cout << "Combination: quarks " << 0.5*ttllfq + 0.5*wjetfq << ", gluons " << 0.5*ttllfg+0.5*wjetfg << endl;
//  cout << "Fractions in main anal. sample: quarks " << fqf << ", gluons " << fgf << endl;
//  cout << "-------------------------------" << endl;
//
//  TFile* wmuP = new TFile("/lustre/ncg.ingrid.pt/cmslocal/samples/CMSSW_5_3_7_patch4/chiggs/fakerate_testPOG/trees/TauFRWMuMCPassing_PFlow.root");
//  TFile* wmuF = new TFile("/lustre/ncg.ingrid.pt/cmslocal/samples/CMSSW_5_3_7_patch4/chiggs/fakerate_testPOG/trees/TauFRWMuMCFailing_PFlow.root");
//  TFile* qcdP = new TFile("/lustre/ncg.ingrid.pt/cmslocal/samples/CMSSW_5_3_7_patch4/chiggs/fakerate_testPOG/trees/TauFRQCDMCPassing_PFlow.root");
//  TFile* qcdF = new TFile("/lustre/ncg.ingrid.pt/cmslocal/samples/CMSSW_5_3_7_patch4/chiggs/fakerate_testPOG/trees/TauFRQCDMCFailing_PFlow.root");
//    
//  std::vector<TH1F*> v_wplusjets_pt;
//  std::vector<TH1F*> v_wplusjets_pt_unknown;
//  std::vector<TH1F*> v_wplusjets_pt_quark;
//  std::vector<TH1F*> v_wplusjets_pt_bquark;
//  std::vector<TH1F*> v_wplusjets_pt_gluon;
//  std::vector<TH1F*> v_wplusjets_pt_allquark;
//
//  std::vector<TH1F*> v_qf;
//  std::vector<TH1F*> v_gf;
//
//
//  v_wplusjets_pt         .push_back( (TH1F*) ((TH1F*) wmuP->Get("wplusjets_pt")         )->Clone("wmuP_wplusjets_pt")          );	       
//  v_wplusjets_pt_unknown .push_back( (TH1F*) ((TH1F*) wmuP->Get("wplusjets_pt_unknown") )->Clone("wmuP_wplusjets_pt_unknown")  ); 
//  v_wplusjets_pt_quark	 .push_back( (TH1F*) ((TH1F*) wmuP->Get("wplusjets_pt_quark")   )->Clone("wmuP_wplusjets_pt_quark")    );   
//  v_wplusjets_pt_bquark	 .push_back( (TH1F*) ((TH1F*) wmuP->Get("wplusjets_pt_bquark")  )->Clone("wmuP_wplusjets_pt_bquark")   );  
//  v_wplusjets_pt_gluon	 .push_back( (TH1F*) ((TH1F*) wmuP->Get("wplusjets_pt_gluon")   )->Clone("wmuP_wplusjets_pt_gluon")    );   
//  v_wplusjets_pt_allquark.push_back( (TH1F*) ((TH1F*) wmuP->Get("wplusjets_pt_allquark"))->Clone("wmuP_wplusjets_pt_allquark") );
//
//  v_wplusjets_pt         .push_back( (TH1F*) ((TH1F*) wmuF->Get("wplusjets_pt")         )->Clone("wmuF_wplusjets_pt")          );	       
//  v_wplusjets_pt_unknown .push_back( (TH1F*) ((TH1F*) wmuF->Get("wplusjets_pt_unknown") )->Clone("wmuF_wplusjets_pt_unknown")  ); 
//  v_wplusjets_pt_quark	 .push_back( (TH1F*) ((TH1F*) wmuF->Get("wplusjets_pt_quark")   )->Clone("wmuF_wplusjets_pt_quark")    );   
//  v_wplusjets_pt_bquark	 .push_back( (TH1F*) ((TH1F*) wmuF->Get("wplusjets_pt_bquark")  )->Clone("wmuF_wplusjets_pt_bquark")   );  
//  v_wplusjets_pt_gluon	 .push_back( (TH1F*) ((TH1F*) wmuF->Get("wplusjets_pt_gluon")   )->Clone("wmuF_wplusjets_pt_gluon")    );   
//  v_wplusjets_pt_allquark.push_back( (TH1F*) ((TH1F*) wmuF->Get("wplusjets_pt_allquark"))->Clone("wmuF_wplusjets_pt_allquark") );
//
//  v_wplusjets_pt         .push_back( (TH1F*) ((TH1F*) qcdP->Get("wplusjets_pt")         )->Clone("qcdP_wplusjets_pt")          );	       
//  v_wplusjets_pt_unknown .push_back( (TH1F*) ((TH1F*) qcdP->Get("wplusjets_pt_unknown") )->Clone("qcdP_wplusjets_pt_unknown")  ); 
//  v_wplusjets_pt_quark	 .push_back( (TH1F*) ((TH1F*) qcdP->Get("wplusjets_pt_quark")   )->Clone("qcdP_wplusjets_pt_quark")    );   
//  v_wplusjets_pt_bquark	 .push_back( (TH1F*) ((TH1F*) qcdP->Get("wplusjets_pt_bquark")  )->Clone("qcdP_wplusjets_pt_bquark")   );  
//  v_wplusjets_pt_gluon	 .push_back( (TH1F*) ((TH1F*) qcdP->Get("wplusjets_pt_gluon")   )->Clone("qcdP_wplusjets_pt_gluon")    );   
//  v_wplusjets_pt_allquark.push_back( (TH1F*) ((TH1F*) qcdP->Get("wplusjets_pt_allquark"))->Clone("qcdP_wplusjets_pt_allquark") );
//
//  v_wplusjets_pt         .push_back( (TH1F*) ((TH1F*) qcdF->Get("wplusjets_pt")         )->Clone("qcdF_wplusjets_pt")          );	       
//  v_wplusjets_pt_unknown .push_back( (TH1F*) ((TH1F*) qcdF->Get("wplusjets_pt_unknown") )->Clone("qcdF_wplusjets_pt_unknown")  ); 
//  v_wplusjets_pt_quark	 .push_back( (TH1F*) ((TH1F*) qcdF->Get("wplusjets_pt_quark")   )->Clone("qcdF_wplusjets_pt_quark")    );   
//  v_wplusjets_pt_bquark	 .push_back( (TH1F*) ((TH1F*) qcdF->Get("wplusjets_pt_bquark")  )->Clone("qcdF_wplusjets_pt_bquark")   );  
//  v_wplusjets_pt_gluon	 .push_back( (TH1F*) ((TH1F*) qcdF->Get("wplusjets_pt_gluon")   )->Clone("qcdF_wplusjets_pt_gluon")    );   
//  v_wplusjets_pt_allquark.push_back( (TH1F*) ((TH1F*) qcdF->Get("wplusjets_pt_allquark"))->Clone("qcdF_wplusjets_pt_allquark") );
//
//  std::vector<int> colours;
//  colours.push_back(1);
//  colours.push_back(2);
//  colours.push_back(4);  
//  colours.push_back(5);
//
//  std::vector<TString> labels;
//  labels.push_back("W+1jet ");
//  labels.push_back("W+1jet ");
//  labels.push_back("QCDmulti ");
//  labels.push_back("QCDmulti ");
//
//  std::vector<TString> fBase;
//  fBase.push_back("WMu1");
//  fBase.push_back("WMu2");
//  fBase.push_back("QCD1");
//  fBase.push_back("QCD2");
//
//  for(size_t i=0; i<v_wplusjets_pt.size(); ++i){
//    v_wplusjets_pt         [i]->SetLineColor(colours[i]);    
//    v_wplusjets_pt_unknown [i]->SetLineColor(colours[i]);
//    v_wplusjets_pt_quark   [i]->SetLineColor(colours[1]);	 
//    v_wplusjets_pt_bquark  [i]->SetLineColor(colours[i]);	 
//    v_wplusjets_pt_gluon   [i]->SetLineColor(colours[2]);	 
//    v_wplusjets_pt_allquark[i]->SetLineColor(colours[1]);    
//
//    v_wplusjets_pt         [i]->SetLineWidth(3);    
//    v_wplusjets_pt_unknown [i]->SetLineWidth(3);
//    v_wplusjets_pt_quark   [i]->SetLineWidth(3);	 
//    v_wplusjets_pt_bquark  [i]->SetLineWidth(3);	 
//    v_wplusjets_pt_gluon   [i]->SetLineWidth(3);	 
//    v_wplusjets_pt_allquark[i]->SetLineWidth(3);    
//
//    //    v_wplusjets_pt_gluon[i]->Add(v_wplusjets_pt_unknown[i],1.);
//
//    TH1F* numQ = v_wplusjets_pt_allquark[i]->Clone(TString(v_wplusjets_pt_allquark[i]->GetName())+"numQ");
//    TH1F* numG = v_wplusjets_pt_gluon[i]->Clone(TString(v_wplusjets_pt_gluon[i]->GetName())+"numG");
//    TH1F* den =  v_wplusjets_pt_allquark[i]->Clone(TString(v_wplusjets_pt_allquark[i]->GetName())+"den");
//
//    numQ->GetYaxis()->SetTitle("Jet content");	 
//    numG->GetYaxis()->SetTitle("Jet content");	 
//    
//
//    cout << "Fractions for " << fBase[i] << ": quark " << v_wplusjets_pt_allquark[i]->Integral() / (v_wplusjets_pt_allquark[i]->Integral() + v_wplusjets_pt_gluon[i]->Integral() ) << ", gluon " << v_wplusjets_pt_gluon[i]->Integral() / (v_wplusjets_pt_allquark[i]->Integral() + v_wplusjets_pt_gluon[i]->Integral() ) << endl;
//    
//    numQ->Sumw2();
//    numG->Sumw2();
//    den->Sumw2();
//    
//    den->Add(v_wplusjets_pt_gluon[i],1.);
//    
//    numQ->Divide(den);
//    numG->Divide(den);
//    cout << "I divided" << endl;
//
//    v_qf.push_back(numQ);
//    v_gf.push_back(numG);
//    
//    
//    //    TLegend* leg_ = new TLegend(0.15,0.65,0.62,0.80,NULL,"brNDC");
//    TLegend* leg_ = new TLegend(0.40,0.50,0.80,0.70,NULL,"brNDC");
//    leg_->SetTextFont(42);
//    leg_->SetBorderSize(0);
//    leg_->SetLineColor(1);
//    leg_->SetLineStyle(1);
//    leg_->SetLineWidth(1);
//    leg_->SetFillColor(0);
//    leg_->SetFillStyle(0);
//    leg_->AddEntry(numQ,/*labels[i]+*/"Quark jets fraction","lpf");  
//    leg_->AddEntry(numG,/*labels[i]+*/"Gluon jets fraction","lpf");
//
//    TPaveText *pt1 = new TPaveText(0.17,0.45,0.5,0.5, "brNDC");
//    pt1->SetBorderSize(1);
//    pt1->SetFillColor(19);
//    pt1->SetFillStyle(0);
//    pt1->SetLineColor(0);
//    pt1->SetTextFont(132);
//    pt1->SetTextSize(0.033);
//    //  TText *text = pt1->AddText("#splitline{m_{H^{#pm}} = 120 GeV/c^{2},}{BR(t #rightarrow H^{+}b) = 0.05}");
//    TCanvas* myCanva = new TCanvas(labels[i],labels[i],2000,2000);
//    myCanva->cd();
//
//    if(i<2){
//      numQ->Draw("hist");
//      numG->Draw("histsame");
//    }
//    else{
//      numG->Draw("hist");
//      numQ->Draw("histsame");
//    }
//    leg_->Draw();
//    //    pt1->Draw("same");
//    myCanva->SaveAs(fBase[i]+".pdf");
//    myCanva->SaveAs(fBase[i]+".png");
//    myCanva->Clear();
//    delete myCanva;
//    delete pt1;
//    delete numQ;
//    delete numG;
//    delete den;
//    delete leg_;
//  }
}
Example #9
0
//set global style to PRD recommendation????
void SetStyle_PRD(){

  TStyle *RootStyle = new TStyle("Root-Style","Single Top Style for PRD");
  
#ifdef __CINT__
  TStyle *GloStyle;
  GloStyle = gStyle;                          // save the global style reference
  gStyle = RootStyle;
#endif


  // Canvas

  RootStyle->SetCanvasColor     (0);
  RootStyle->SetCanvasBorderMode(0);

  // Pads

  RootStyle->SetPadColor       (0);
  RootStyle->SetPadBorderMode  (0);
  RootStyle->SetPadBottomMargin(0.17);
  RootStyle->SetPadTopMargin   (0.07);
  RootStyle->SetPadLeftMargin  (0.18);
  RootStyle->SetPadRightMargin (0.08);
  RootStyle->SetPadTickX       (0);
  RootStyle->SetPadTickY       (0);

  // Frames

  RootStyle->SetFrameLineWidth (3);
  RootStyle->SetFrameFillColor (0);
  RootStyle->SetFrameBorderMode(0);
  RootStyle->SetFrameBorderSize(0);


  // Histograms

   RootStyle->SetHistFillColor(0);
   RootStyle->SetHistLineWidth(2);

  // Functions

  //RootStyle->SetFuncColor(1);
  //RootStyle->SetFuncStyle(0);
  //RootStyle->SetFuncWidth(2);

  //Legends 

  //RootStyle->SetLegendBorderSize(0);
  //RootStyle->SetFillStyle(0);
  //RootStyle->SetTextFont(62); 
  //RootStyle->SetTextSize(0.045);

  // Labels, Ticks, and Titles

  //RootStyle->SetTickLength ( 0.015,"X");
  RootStyle->SetTitleSize  ( 0.070,"X");
  RootStyle->SetTitleOffset( 1.100,"X");
  RootStyle->SetLabelSize  ( 0.070,"X");
  RootStyle->SetNdivisions ( 505  ,"X");

//RootStyle->SetTickLength ( 0.015,"Y");
  RootStyle->SetTitleSize  ( 0.070,"Y");
  RootStyle->SetTitleOffset( 1.300,"Y");
  RootStyle->SetLabelSize  ( 0.070,"Y");
  RootStyle->SetNdivisions ( 505  ,"Y");

//   RootStyle->SetTickLength ( 0.015,"Z");
//   RootStyle->SetTitleSize  ( 0.060,"Z");
//   RootStyle->SetTitleOffset( 1.100,"Z");
//   RootStyle->SetLabelOffset( 0.015,"Z");
//   RootStyle->SetLabelSize  ( 0.050,"Z");
//   RootStyle->SetLabelFont  ( 42   ,"Z");
//   RootStyle->SetTitleFont  ( 42   ,"Z");
//   RootStyle->SetNdivisions ( 707   ,"Z");


  RootStyle->SetTitleBorderSize  (0);
  RootStyle->SetTitleFillColor  (0);  
//RootStyle->SetTitleFont  (42);
//RootStyle->SetTitleColor  (1);

  RootStyle->SetLineWidth  (2);

  // Options

  RootStyle->SetOptFit        (0111);
  RootStyle->SetOptStat       (1);
  RootStyle->SetStatBorderSize(0);
  RootStyle->SetStatColor     (0);
  RootStyle->SetStatW(0.5);
//  RootStyle->SetMarkerStyle(20);
//RootStyle->SetMarkerSize(1.25);

//RootStyle->SetPalette(1);

}
Example #10
0
TStyle* createMyStyle() {
  TStyle *myStyle = new TStyle("myStyle", "myStyle");

  // For the canvas:
  myStyle->SetCanvasBorderMode(0);
  myStyle->SetCanvasColor(kWhite);
  myStyle->SetCanvasDefH(800); //Height of canvas
  myStyle->SetCanvasDefW(800); //Width of canvas
  myStyle->SetCanvasDefX(0);   //POsition on screen
  myStyle->SetCanvasDefY(0);

  // For the Pad:
  myStyle->SetPadBorderMode(0);
  myStyle->SetPadColor(kWhite);
  myStyle->SetPadGridX(false);
  myStyle->SetPadGridY(false);
  myStyle->SetGridColor(0);
  myStyle->SetGridStyle(3);
  myStyle->SetGridWidth(1);

  // For the frame:
  myStyle->SetFrameBorderMode(0);
  myStyle->SetFrameBorderSize(1);
  myStyle->SetFrameFillColor(0);
  myStyle->SetFrameFillStyle(0);
  myStyle->SetFrameLineColor(1);
  myStyle->SetFrameLineStyle(1);
  myStyle->SetFrameLineWidth(1);

  // For the histo:
  myStyle->SetHistLineStyle(1);
  myStyle->SetHistLineWidth(2);
  myStyle->SetEndErrorSize(2);

  //For the fit/function:
  myStyle->SetFitFormat("5.4g");
  myStyle->SetFuncColor(2);
  myStyle->SetFuncStyle(1);
  myStyle->SetFuncWidth(1);

  // For the statistics box:
  myStyle->SetOptFile(0);
  myStyle->SetStatColor(kWhite);
  //myStyle->SetStatFont(43);
  //myStyle->SetStatFontSize(0.025);
  myStyle->SetStatTextColor(1);
  myStyle->SetStatFormat("6.4g");
  myStyle->SetStatBorderSize(1);
  myStyle->SetStatH(0.12);
  myStyle->SetStatW(0.3);
  myStyle->SetStatY(0.92);
  myStyle->SetStatX(0.94);

  //For the date:
  myStyle->SetOptDate(0);

  // Margins:
  myStyle->SetPadTopMargin(TOP_MARGIN);
  myStyle->SetPadBottomMargin(BOTTOM_MARGIN);
  myStyle->SetPadLeftMargin(LEFT_MARGIN);
  myStyle->SetPadRightMargin(RIGHT_MARGIN);

  // For the Global title:
  myStyle->SetOptTitle(0);
  myStyle->SetTitleFont(63);
  myStyle->SetTitleColor(1);
  myStyle->SetTitleTextColor(1);
  myStyle->SetTitleFillColor(10);
  myStyle->SetTitleBorderSize(0);
  myStyle->SetTitleAlign(33); 
  myStyle->SetTitleX(1);
  myStyle->SetTitleFontSize(TITLE_FONTSIZE);

  // For the axis titles:

  myStyle->SetTitleColor(1, "XYZ");
  myStyle->SetTitleFont(43, "XYZ");
  myStyle->SetTitleSize(TITLE_FONTSIZE, "XYZ");
  myStyle->SetTitleYOffset(2.); 
  myStyle->SetTitleXOffset(1.25);

  myStyle->SetLabelColor(1, "XYZ");
  myStyle->SetLabelFont(43, "XYZ");
  myStyle->SetLabelOffset(0.01, "YZ");
  myStyle->SetLabelOffset(0.015, "X");
  myStyle->SetLabelSize(LABEL_FONTSIZE, "XYZ");

  myStyle->SetAxisColor(1, "XYZ");
  myStyle->SetStripDecimals(kTRUE);
  myStyle->SetTickLength(0.03, "XYZ");
  myStyle->SetNdivisions(510, "XYZ");
  myStyle->SetPadTickX(1);  // To get tick marks on the opposite side of the frame
  myStyle->SetPadTickY(1);

  myStyle->SetOptLogx(0);
  myStyle->SetOptLogy(0);
  myStyle->SetOptLogz(0);

  myStyle->SetHatchesSpacing(1.3);
  myStyle->SetHatchesLineWidth(1);

  myStyle->cd();

  return myStyle;
}
Example #11
0
void SetStyle()
{
  TStyle *MITStyle = new TStyle("MIT-Style","The Perfect Style for Plots ;-)");
  gStyle = MITStyle;

  // Canvas
  MITStyle->SetCanvasColor     (0);
  MITStyle->SetCanvasBorderSize(10);
  MITStyle->SetCanvasBorderMode(0);
  MITStyle->SetCanvasDefH      (700);
  MITStyle->SetCanvasDefW      (700);
  MITStyle->SetCanvasDefX      (100);
  MITStyle->SetCanvasDefY      (100);

  // Pads
  MITStyle->SetPadColor       (0);
  MITStyle->SetPadBorderSize  (10);
  MITStyle->SetPadBorderMode  (0);
  MITStyle->SetPadBottomMargin(0.13);
  MITStyle->SetPadTopMargin   (0.08);
  MITStyle->SetPadLeftMargin  (0.15);
  MITStyle->SetPadRightMargin (0.05);
  MITStyle->SetPadGridX       (0);
  MITStyle->SetPadGridY       (0);
  MITStyle->SetPadTickX       (0);
  MITStyle->SetPadTickY       (0);

  // Frames
  MITStyle->SetFrameFillStyle ( 0);
  MITStyle->SetFrameFillColor ( 0);
  MITStyle->SetFrameLineColor ( 1);
  MITStyle->SetFrameLineStyle ( 0);
  MITStyle->SetFrameLineWidth ( 1);
  MITStyle->SetFrameBorderSize(10);
  MITStyle->SetFrameBorderMode( 0);

  // Histograms
  MITStyle->SetHistFillColor(2);
  MITStyle->SetHistFillStyle(0);
  MITStyle->SetHistLineColor(1);
  MITStyle->SetHistLineStyle(0);
  MITStyle->SetHistLineWidth(2);
  MITStyle->SetNdivisions(505);

  // Functions
  MITStyle->SetFuncColor(1);
  MITStyle->SetFuncStyle(0);
  MITStyle->SetFuncWidth(2);

  // Various
  MITStyle->SetMarkerStyle(20);
  MITStyle->SetMarkerColor(kBlack);
  MITStyle->SetMarkerSize (1.2);

  MITStyle->SetTitleSize  (0.055,"X");
  MITStyle->SetTitleOffset(1.200,"X");
  MITStyle->SetLabelOffset(0.005,"X");
  MITStyle->SetLabelSize  (0.050,"X");
  MITStyle->SetLabelFont  (42   ,"X");

  MITStyle->SetStripDecimals(kFALSE);

  MITStyle->SetTitleSize  (0.055,"Y");
  MITStyle->SetTitleOffset(1.800,"Y");
  MITStyle->SetLabelOffset(0.010,"Y");
  MITStyle->SetLabelSize  (0.050,"Y");
  MITStyle->SetLabelFont  (42   ,"Y");

  MITStyle->SetTextSize   (0.055);
  MITStyle->SetTextFont   (42);

  MITStyle->SetStatFont   (42);
  MITStyle->SetTitleFont  (42);
  MITStyle->SetTitleFont  (42,"X");
  MITStyle->SetTitleFont  (42,"Y");

  MITStyle->SetOptStat    (0);
  return;
}
Example #12
0
//-------------------------------------------------------------------------------
void setIStyle() {
  
  TStyle* IStyle = new TStyle("IStyle","Ignazio Style");   
  
  gROOT->Reset();
  gROOT->SetStyle("Plain");

   // For the Global title:
  IStyle->SetOptTitle(1); // In general I want global title!
  IStyle->SetTitleFont(42);
  IStyle->SetTitleColor(1);
  IStyle->SetTitleTextColor(1);
  IStyle->SetTitleFillColor(10);
  IStyle->SetTitleFontSize(0.05);

  IStyle->SetCanvasBorderMode(0);
  IStyle->SetCanvasColor(kWhite);
  IStyle->SetCanvasDefH(400);     //Height of canvas
  IStyle->SetCanvasDefW(600);     //Width of canvas
  IStyle->SetPadBorderMode(0);
  IStyle->SetPadColor(kWhite);
  /*
  // Pad Margins:
  //-----------------------------
  IStyle->SetPadTopMargin(0.05);
  IStyle->SetPadBottomMargin(0.13);
  IStyle->SetPadLeftMargin(0.16);
  IStyle->SetPadRightMargin(0.02);
  */

  // For the frame:
  //-----------------------------
  IStyle->SetFrameBorderMode(0);
  IStyle->SetFrameBorderSize(1);
  IStyle->SetFrameFillColor(kWhite);
  IStyle->SetFrameFillStyle(0);
  IStyle->SetFrameLineColor(1);
  IStyle->SetFrameLineStyle(1);
  IStyle->SetFrameLineWidth(1);

  // For the histo:
  //-----------------------------
  IStyle->SetHistLineWidth(1);
  IStyle->SetHistLineColor(kBlack);
  IStyle->SetEndErrorSize(2);
  IStyle->SetErrorX(0.);
  // IStyle->SetMarkerStyle(kFullDotSmall); 
  // IStyle->SetMarkerStyle(kFullDotMedium); 
  IStyle->SetMarkerStyle(kFullDotLarge);
  // IStyle->SetMarkerStyle(kFullCircle);


  // For the statistics box:
  //-----------------------------
  /*
    gStyle->SetOptStat("option-string");

    Where option string can contain:-
    n ;  name of histogram is printed
    e ;  number of entries printed
    m ;  mean value printed
    r ;  rms printed
    u ;  number of underflows printed
    o ;  number of overflows printed
    i ;  integral of bins printed
    Example: gStyle->SetOptStat("ne");
    print only name of histogram and number of entries.

    To remove it altogther:-

  gStyle->SetOptStat("");
  */
  // IStyle->SetOptStat("emr");        
  /*
  The parameter mode can be = ksiourmen  (default = 000001111)
    k = 1;  kurtosis printed
    k = 2;  kurtosis and kurtosis error printed
    s = 1;  skewness printed
    s = 2;  skewness and skewness error printed
    i = 1;  integral of bins printed
    o = 1;  number of overflows printed
    u = 1;  number of underflows printed
    r = 1;  rms printed
    r = 2;  rms and rms error printed
    m = 1;  mean value printed
    m = 2;  mean and mean error values printed
    e = 1;  number of entries printed
    n = 1;  name of histogram is printed
  Example: gStyle->SetOptStat(11);
           print only name of histogram and number of entries.
           gStyle->SetOptStat(1101);  displays the name of histogram, mean value and RMS.
  WARNING: never call SetOptStat(000111); but SetOptStat(1111), 0001111 will
          be taken as an octal number !!
  WARNING: SetOptStat(1) is taken as SetOptStat(1111) (for back compatibility
           with older versions. If you want to print only the name of the histogram
           call SetOptStat(1000000001).
  NOTE that in case of 2-D histograms, when selecting just underflow (10000)
        or overflow (100000), the stats box will show all combinations
        of underflow/overflows and not just one single number!
  */

  //  IStyle->SetOptStat(1110);  
  IStyle->SetOptStat(0); 

  IStyle->SetStatColor(kWhite);
  IStyle->SetStatFont(42);
 
  // For fitting:
  //-----------------------------
  IStyle->SetFuncWidth(1);         // for the fit function 
  IStyle->SetFuncColor(kBlack);    // for the fit function 
  IStyle->SetOptFit(111);          // IStyle->SetOptFit(0) to get rid of
  IStyle->SetStatW(0.18);          // set width of stat box
  IStyle->SetStatFontSize(0.04);   // set the font size for stat box

  /*
  // Change for log plots:
  IStyle->SetOptLogx(0);
  IStyle->SetOptLogy(0);
  IStyle->SetOptLogz(0)
  */

  // IStyle->SetPalette(1);
  palette();
  IStyle->cd(); // this becomes now the current style gStyle

}