ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/AnalysisFramework/various_assignments/SimPa/AdditionalTools/CalibrationT5zz.C
Revision: 1.2
Committed: Tue Apr 10 15:40:36 2012 UTC (13 years ago) by pablom
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +12 -0 lines
Log Message:
Updated style in 2D plots

File Contents

# User Rev Content
1 pablom 1.1 #include <iostream>
2     #include <vector>
3     #include <sys/stat.h>
4     #include <getopt.h>
5     #include <stdio.h>
6     #include <stdlib.h>
7     #include "../../../Plotting/Modules//GeneralToolBox.C"
8     #include "../../../Plotting/Modules//SampleClass.C"
9     #include "../../../Plotting/Modules//setTDRStyle.C"
10     //#include "../../../Plotting/Modules//Setup.C"
11     //#include "../../../Plotting/Modules//Poisson_Calculator.C"
12     //#include "../../../Plotting/Modules//ActiveSamples.C"
13     //#include "../../../Plotting/Modules//PeakFinder.C"
14     //#include "../../../Plotting/Modules//UpperLimitsWithShape.C"
15     //#include "../../../Plotting/Modules//Plotting_Functions.C"
16     //#include "../../../Plotting/Modules//LimitCalculation.C"
17     //#include "../../../Plotting/Modules//ResultModule.C"
18     //#include "../../../Plotting/Modules//CrossSectionReader.C"
19     //#include "../../../Plotting/Modules//Systematics.C"
20     //#include "../../../Plotting/Modules//SUSYScan.C"
21     #include <TCut.h>
22     #include <TROOT.h>
23     #include <TCanvas.h>
24     #include <TMath.h>
25     #include <TColor.h>
26     #include <TPaveText.h>
27     #include <TRandom.h>
28     #include <TH1.h>
29     #include <TH2.h>
30     #include <TF1.h>
31     #include <TSQLResult.h>
32    
33    
34     using namespace std;
35    
36     void runEfficiency(string, string);
37     void plots_for_config(string);
38    
39    
40     int main(int argc, char *argv[]) {
41    
42     if(argc != 3 && argc != 2) {
43     cout << "Usage: ./MassHierarchy.exec inputFile.root" << endl;
44     cout << "Usage: ./MassHierarchy.exec inputFile.root outputFile.root" << endl;
45     return -1;
46     }
47    
48     if(argc == 3) {
49     string inputFile(argv[1]);
50     string outputFile(argv[2]);
51     runEfficiency(inputFile, outputFile);
52     } else {
53     string inputFile(argv[1]);
54     do_png(1);
55     do_pdf(1);
56     char currentpath[1024];
57     char *path = getcwd(currentpath, 1024);
58     PlottingSetup::basedirectory=string(currentpath)+"/";
59     plots_for_config(inputFile);
60     }
61    
62     return 0;
63    
64     }
65    
66    
67     void plots_for_config(string inputFile) {
68    
69     gROOT->SetStyle("Plain");
70     bool do_fat_line=false; // if you want to have HistLineWidth=1 and FuncWidth=1 as it was before instead of 2
71     setTDRStyle(do_fat_line);
72     gStyle->SetTextFont(42);
73    
74     TFile *_file = TFile::Open(inputFile.c_str());
75    
76     for(int cut = 50; cut < 260; cut += 50) {
77     char name[50];
78     sprintf(name, "eff_%d", cut);
79     string name2_(name);
80     string name_ = "Calibration_" + name2_;
81     TH2F *histo = (TH2F *) _file->Get(name);
82     if(histo == NULL) continue;
83     TCanvas *m1 = new TCanvas("m1");
84 pablom 1.2 m1->SetRightMargin(0.17);
85 pablom 1.1 m1->cd();
86 pablom 1.2 //histo->GetZaxis()->SetTitleOffset(0.1);
87     histo->GetZaxis()->SetRangeUser(0, 0.11);
88     histo->GetXaxis()->SetTitle("m_{glu} [GeV]");
89     histo->GetYaxis()->SetTitle("m_{LSP} [GeV]");
90     histo->GetZaxis()->SetTitle("A #times #varepsilon (#geq 1 Z(ll))");
91     histo->GetYaxis()->SetTitleOffset(1.4);
92     histo->GetZaxis()->SetTitleOffset(1.5);
93     histo->GetXaxis()->CenterTitle();
94     histo->GetYaxis()->CenterTitle();
95     histo->GetZaxis()->CenterTitle();
96    
97 pablom 1.1 histo->Draw("COLZ");
98     CompleteSave(m1, "Plots/" + name_);
99     delete m1;
100     }
101    
102     }
103    
104    
105    
106    
107     void runEfficiency(string inputFile, string outputFile) {
108    
109     //INPUT : The generated events root file
110     TFile f(inputFile.c_str());
111     TTree *s = (TTree *) f.Get("events");
112    
113     //OUTPUT: The histogram root file
114     TFile f2(outputFile.c_str(), "RECREATE");
115     f2.cd();
116    
117    
118     char nameHisto[50];
119     char theJZBCutP[50];
120     char theJZBCutN[50];
121     sprintf(nameHisto, "eff_%d", 50);
122     sprintf(theJZBCutP, "jzb > %d", 50);
123     sprintf(theJZBCutN, "jzb < -%d", 50);
124     TCut JZBP(theJZBCutP);
125     TCut JZBN(theJZBCutN);
126    
127     TH2F *eff = new TH2F(nameHisto, "", 48, 0, 1200, 48, 0, 1200);
128     eff->GetXaxis()->SetTitle("m_{Glu} [GeV]");
129     eff->GetYaxis()->SetTitle("m_{LSP} [GeV]");
130     for(float massGlu = 150; massGlu < 1200.0; massGlu += 25.0) {
131     for(float massLSP = 50; massLSP < 1200.0; massLSP += 25.0) {
132     float massChi = massLSP+0.5*(massGlu-massLSP);
133     if(massChi < massLSP + 100.0 || massGlu < massChi + 2) continue;
134     char theCut_[250];
135     sprintf(theCut_, "abs(massGlu-%f) < 1 && abs(massChi-%f) < 1 && abs(massLSP-%f) < 1", massGlu, massChi, massLSP);
136     TCut theCut(theCut_);
137     float npos = s->Draw("jzb", JZBP+theCut+"nleptons==2&&njets>2", "OF");
138     float nneg = s->Draw("jzb", JZBN+theCut+"nleptons==2&&njets>2", "OF");
139     float efficiency = (npos-nneg)/20000.0;
140     cout << "Mass Glu: " << massGlu << " MassLSP " << massLSP << " Efficiency: " << efficiency << endl;
141     if(efficiency < 0) {
142     cout << "Lower than 0" << endl;
143     efficiency = 0.0001;
144     }
145     eff->SetBinContent(eff->FindBin(massGlu, massLSP), efficiency);
146     }
147     }
148    
149     f2.Write();
150     f2.Close();
151     f.Close();
152    
153     }