ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/LJMet/MultivariateAnalysis/root/toyMC.C
(Generate patch)

Comparing UserCode/LJMet/MultivariateAnalysis/root/toyMC.C (file contents):
Revision 1.2 by kukartse, Fri May 1 06:58:27 2009 UTC vs.
Revision 1.3 by kukartse, Fri May 1 07:54:10 2009 UTC

# Line 17 | Line 17 | public:
17    ~toyMC();
18    
19    void load_templates();
20 +  void load_ejets_templates();
21    int do_fit(TH1F * _data);
22    int generate_toy(int n_sig, int n_phys, int n_qcd);
23    void set_overflow_bins(TH1F * h);
# Line 111 | Line 112 | void toyMC::load_templates(){
112   }
113  
114  
115 + void toyMC::load_ejets_templates(){
116 +  //TFile * data_file = new TFile("./TMVApp-data-electron-01may2009.root","READ");
117 +  TFile * data_file = new TFile("./TMVApp-data-wzfastsim-electron-01may2009.root","READ");
118 +  TFile * ttbar_phys_template_file = new TFile("./TMVA-el.root","READ");
119 +  TFile * qcd_template_file = new TFile("./TMVApp-qcd-electron-01may2009.root","READ");
120 +  
121 +  TTree * t_data       = (TTree *)data_file->Get("classifier");
122 +  TTree * t_ttbar_phys = (TTree *)ttbar_phys_template_file->Get("TestTree");
123 +  TTree * t_qcd        = (TTree *)qcd_template_file->Get("classifier");
124 +  
125 +  delete data;
126 +  delete ttbar;
127 +  delete wzjets;
128 +  delete qcd;
129 +
130 +  data   = new TH1F("data"  ,"data"  ,50, -0.9, 0.9);
131 +  ttbar  = new TH1F("ttbar" ,"ttbar" ,50, -0.9, 0.9);
132 +  wzjets = new TH1F("wzjets","wzjets",50, -0.9, 0.9);
133 +  qcd    = new TH1F("qcd"   ,"qcd"   ,50, -0.9, 0.9);
134 +
135 +  t_data   -> Draw("MVA_BDT>>data");
136 +  t_ttbar_phys  -> Draw("MVA_BDT>>ttbar","type==1");
137 +  t_ttbar_phys -> Draw("MVA_BDT>>wzjets","type==0");
138 +  t_qcd    -> Draw("MVA_BDT>>qcd");
139 +
140 +  //data_file->Close();
141 +  //ttbar_phys_template_file->Close();
142 +  //qcd_template_file->Close();
143 +
144 +  delete mc;
145 +  mc = new TObjArray(3);        // MC histograms are put in this array
146 +  mc->Add(ttbar);
147 +  mc->Add(wzjets);
148 +  mc->Add(qcd);
149 + }
150 +
151 +
152   int toyMC::do_fit(TH1F * _data){
153    delete fit;
154    fit = new TFractionFitter(_data, mc); // initialise
155    fit->Constrain(1,0.0,1.0);               // constrain fraction 1 to be between 0 and 1
156    fit->Constrain(2,0.0,1.0);               // constrain fraction 1 to be between 0 and 1
157 +  fit->Constrain(3,0.0,1.0);               // constrain fraction 1 to be between 0 and 1
158    //fit->Constrain(3,0.07298,0.07299);               // constrain fraction 1 to be between 0 and 1
159 <  fit->Constrain(3,0.1459,0.1460);               // constrain fraction 1 to be between 0 and 1
121 <  //fit->Constrain(3,0.0,1.0);               // constrain fraction 1 to be between 0 and 1
159 >  //fit->Constrain(3,0.2981,0.2982);               // constrain fraction 1 to be between 0 and 1
160    //fit->SetRangeX(1,30);                    // use only the first 15 bins in the fit
161    Int_t status = fit->Fit();               // perform the fit
162 +  if (status!=0) status = fit->Fit();
163    cout << "fit status: " << status << endl;
164    return status;
165   }
# Line 129 | Line 168 | int toyMC::do_fit(TH1F * _data){
168   int toyMC::generate_toy(int n_sig, int n_bg, int n_qcd){
169    int n_events=0;
170    delete toy_data;
171 <  toy_data = new TH1F("toy_data"  ,"toy_data"  ,30, -0.8, 0.8);
171 >
172 >  toy_data = new TH1F("toy_data"  ,"toy_data"  ,50, -0.9, 0.9);
173  
174    int _nsig = _random.Poisson(n_sig);
175    int _nbg  = _random.Poisson(n_bg);
# Line 175 | Line 215 | void toyMC::debug_hist(TH1F * h){
215  
216  
217   int toyMC::fit_data(){
218 <  load_templates();
218 >  //load_templates();
219 >  load_ejets_templates();
220    int _res = do_fit(data);
221    int n_data = data->GetEntries();
222    TH1F * result = (TH1F*) fit->GetPlot();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines