ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/rootEWKanalyzer/normalizeMC2.C
Revision: 1.1
Committed: Mon Jun 7 14:57:40 2010 UTC (14 years, 10 months ago) by jueugste
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Log Message:
first commit

File Contents

# User Rev Content
1 jueugste 1.1 using namespace std;
2    
3     void normalizeMC2() {
4     // luminosity (nb-1 / 1000 = pb-1)
5     double lumi = 7.6 / 1000.;
6     cout<<"Integrated luminosity is: "<<lumi<<" pb-1"<<endl;
7     TFile *QCD15 = TFile::Open("QCD15/root/QCD15.root");
8     TFile *GJ1520 = TFile::Open("GJ1520/root/GJ1520.root");
9     TFile *GJ2030 = TFile::Open("GJ2030/root/GJ2030.root");
10     TFile *GJ30 = TFile::Open("GJ30/root/GJ30.root");
11     TFile *Wenu = TFile::Open("Wenu/root/Wenu.root");
12    
13     // xsec * filter
14     double xsecQCD15 = 876200000.0 * 1;
15     double xsecGJ1520 = 114700.0 * 1.;
16     double xsecGJ2030 = 57180.0 * 1.;
17     double xsecGJ30 = 20070.0 * 1.;
18     double xsecWenu = 9679.9 * 0.779;
19    
20     TH1I *histQCD15 = QCD15->Get("numberOfEvents");
21     TH1I *histGJ1520 = GJ1520->Get("numberOfEvents");
22     TH1I *histGJ2030 = GJ2030->Get("numberOfEvents");
23     TH1I *histGJ30 = GJ30->Get("numberOfEvents");
24     TH1I *histWenu = Wenu->Get("numberOfEvents");
25    
26     // get the number of events
27     int numQCD15 = histQCD15->Integral();
28     int numGJ1520 = histGJ1520->Integral();
29     int numGJ2030 = histGJ2030->Integral();
30     int numGJ30 = histGJ30->Integral();
31     int numWenu = histWenu->Integral();
32    
33     cout<<"have: "<<endl;
34     cout<<numQCD15<<endl;
35     cout<<numGJ1520<<endl;
36     cout<<numGJ2030<<endl;
37     cout<<numGJ30<<endl;
38     cout<<numWenu<<endl;
39    
40     // calculate the normalization factor
41     double normQCD15 = lumi * xsecQCD15;
42     double normGJ1520 = lumi * xsecGJ1520;
43     double normGJ2030 = lumi * xsecGJ2030;
44     double normGJ30 = lumi * xsecGJ30;
45     double normWenu = lumi * xsecWenu;
46    
47     cout<<"should have: "<<endl;
48     cout<<"QCD em:"<<endl;
49     cout<<normQCD15<<endl;
50     cout<<"Photen Jet:"<<endl;
51     cout<<normGJ1520<<endl;
52     cout<<normGJ2030<<endl;
53     cout<<normGJ30<<endl;
54     cout<<"Wenu:"<<endl;
55     cout<<normWenu<<endl;
56    
57     double facQCD15 = normQCD15/numQCD15;
58     double facGJ1520 = normGJ1520/numGJ1520;
59     double facGJ2030 = normGJ2030/numGJ2030;
60     double facGJ30 = normGJ30/numGJ30;
61     double facWenu = normWenu/numWenu;
62    
63     cout<<"factor: "<<endl;
64     cout<<facQCD15<<endl;
65     cout<<facGJ1520<<endl;
66     cout<<facGJ2030<<endl;
67     cout<<facGJ30<<endl;
68     cout<<facWenu<<endl;
69    
70     TFile *out=new TFile("bckgd.root","RECREATE");
71    
72     // loop over all histos
73     TIter next (QCD15->GetListOfKeys ());
74    
75     for (TKey* key = 0; (key = (TKey *) next());) {
76     TH1D *h_QCD15 = QCD15->Get(key->GetName());
77     TH1D *h_GJ1520 = GJ1520->Get(key->GetName());
78     TH1D *h_GJ2030 = GJ2030->Get(key->GetName());
79     TH1D *h_GJ30 = GJ30->Get(key->GetName());
80     TH1D *h_Wenu = Wenu->Get(key->GetName());
81    
82     // scale them
83     h_QCD15->Scale(facQCD15);
84     h_GJ1520->Scale(facGJ1520);
85     h_GJ2030->Scale(facGJ2030);
86     h_GJ30->Scale(facGJ30);
87     h_Wenu->Scale(facWenu);
88    
89     // sum the background up
90     h_QCD15->Add(h_GJ1520);
91     h_QCD15->Add(h_GJ2030);
92     h_QCD15->Add(h_GJ30);
93     //h_QCD15->Add(h_Wenu);
94    
95     h_QCD15->Write();
96    
97    
98    
99     } // loop over keys
100    
101    
102     QCD15->Close();
103     GJ1520->Close();
104     GJ2030->Close();
105     GJ30->Close();
106     Wenu->Close();
107     out->Close();
108    
109    
110     }