ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/AnalysisFramework/various_assignments/SimPa/AdditionalTools/MassHierarchyT5zz.C
Revision: 1.1
Committed: Tue Apr 10 14:38:44 2012 UTC (13 years ago) by pablom
Content type: text/plain
Branch: MAIN
Log Message:
SimPa implemented

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     using namespace std;
34    
35     void runEfficiency(string, string);
36     void plots_for_config(string);
37    
38    
39     int main(int argc, char *argv[]) {
40    
41     if(argc != 3 && argc != 2) {
42     cout << "Usage: ./MassHierarchy.exec inputFile.root" << endl;
43     cout << "Usage: ./MassHierarchy.exec inputFile.root outputFile.root" << endl;
44     return -1;
45     }
46    
47     if(argc == 3) {
48     string inputFile(argv[1]);
49     string outputFile(argv[2]);
50     runEfficiency(inputFile, outputFile);
51     } else {
52     string inputFile(argv[1]);
53     do_png(1);
54     do_pdf(1);
55     char currentpath[1024];
56     char *path = getcwd(currentpath, 1024);
57     PlottingSetup::basedirectory=string(currentpath)+"/";
58     plots_for_config(inputFile);
59     }
60    
61     return 0;
62    
63     }
64    
65    
66     void plots_for_config(string inputFile) {
67    
68     gROOT->SetStyle("Plain");
69     bool do_fat_line=false; // if you want to have HistLineWidth=1 and FuncWidth=1 as it was before instead of 2
70     setTDRStyle(do_fat_line);
71     gStyle->SetTextFont(42);
72    
73     TFile *_file = TFile::Open(inputFile.c_str());
74    
75     for(int cut = 50; cut < 260; cut += 50) {
76     char name[50];
77     sprintf(name, "eff_%d", cut);
78     string name_(name);
79     TH2F *histo = (TH2F *) _file->Get(name);
80     if(histo == NULL) continue;
81     TCanvas *m1 = new TCanvas("m1");
82     m1->cd();
83     histo->Draw("COLZ");
84     CompleteSave(m1, "Plots/" + name_);
85     delete m1;
86     }
87    
88     }
89    
90    
91     void runEfficiency(string inputFile, string outputFile) {
92    
93     //INPUT: File with events
94     TFile f(inputFile.c_str());
95     TTree *s = (TTree *) f.Get("events");
96    
97     //OUTPUT: File with histos
98     TFile f2(outputFile.c_str(), "RECREATE");
99     f2.cd();
100    
101     float massLSP = 200;
102     for(int cut = 50; cut < 260; cut += 50) {
103     char nameHisto[100], theJZBCutP[100], theJZBCutN[100];
104     int cut_ = (int)cut;
105     sprintf(nameHisto, "eff_%d", cut_);
106     sprintf(theJZBCutP, "jzb > %d", cut_);
107     sprintf(theJZBCutN, "jzb < -%d", cut_);
108     TCut JZBP(theJZBCutP);
109     TCut JZBN(theJZBCutN);
110     TH2F *eff = new TH2F(nameHisto, "", 40, 0, 1000, 20, 0, 1);
111     eff->GetXaxis()->SetTitle("m_{Glu}-m_{LSP} [GeV]");
112     eff->GetYaxis()->SetTitle("(m_{#chi}-m_{LSP})/(m_{Glu}-m_{LSP})");
113     for(float massGlu = 1200; massGlu > massLSP + 100; massGlu -= 25.0) {
114     for(float x = 0.1; x < 0.99; x += 0.05) {
115     float massChi = massLSP+x*(massGlu-massLSP);
116     if(massChi < massLSP + 100.0 || massGlu < massChi + 2) continue;
117     char theCut_[250];
118     sprintf(theCut_, "abs(massGlu-%f) < 1 && abs(massChi-%f) < 1 && abs(massLSP-%f) < 1", massGlu, massChi, massLSP);
119     TCut theCut(theCut_);
120     float npos = s->Draw("jzb", JZBP+theCut, "OF");
121     float nneg = s->Draw("jzb", JZBN+theCut, "OF");
122     float efficiency = (npos-nneg)/20000.0;
123     cout << "Delta M: " << massGlu-massLSP << " x: " << x << " Efficiency: " << efficiency << endl;
124     if(efficiency < 0) {
125     cout << "Lower than 0" << endl;
126     }
127     eff->SetBinContent(eff->FindBin(massGlu-massLSP, x), efficiency);
128     }
129     }
130     }
131    
132     f2.Write();
133     f2.Close();
134     f.Close();
135    
136     return;
137    
138     }