1 |
yangyong |
1.1 |
#include "rootheader.h"
|
2 |
|
|
#include "roofitheader.h"
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
#include "usefullcode.cc"
|
6 |
|
|
|
7 |
|
|
using namespace RooFit ;
|
8 |
|
|
|
9 |
|
|
#include "usefullcoderoofit.cc"
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
///combined the workspace produced by testSelectionZee.C
|
13 |
|
|
void makeZeeWsMCShape(char *test_datasetname, int total_evtRange){
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
TString filename ;
|
17 |
|
|
vector<string> mpair_var;
|
18 |
|
|
mpair_var.push_back("mpair_ebeb");
|
19 |
|
|
mpair_var.push_back("mpair_ebeb_highr9");
|
20 |
|
|
mpair_var.push_back("mpair_ebeb_lowr9");
|
21 |
|
|
mpair_var.push_back("mpair_eeee");
|
22 |
|
|
mpair_var.push_back("mpair_eeee_highr9");
|
23 |
|
|
mpair_var.push_back("mpair_eeee_lowr9");
|
24 |
|
|
mpair_var.push_back("mpair_eeee_highr9_loweps"); //eps_escraw < 0.05
|
25 |
|
|
mpair_var.push_back("mpair_eeee_highr9_higheps");//eps_escraw > 0.05
|
26 |
|
|
mpair_var.push_back("mpair_eeee_lowr9_loweps"); //eps_escraw < 0.05
|
27 |
|
|
mpair_var.push_back("mpair_eeee_lowr9_higheps");//eps_escraw > 0.05
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
map<string,RooDataSet*> rhs_map_mpair;
|
31 |
|
|
map<string,RooDataSet*> rhs_map_mpair_corr;
|
32 |
|
|
|
33 |
|
|
RooRealVar *rv_mass = new RooRealVar("rv_mass","mass",100,60,120);
|
34 |
|
|
RooRealVar *rv_weight = new RooRealVar("rv_weight","weight",1.0,0,1E6);
|
35 |
|
|
|
36 |
|
|
for(int j=0; j< int( mpair_var.size()); j++){
|
37 |
|
|
string mpairname = mpair_var[j];
|
38 |
|
|
TString rname = TString( Form("rhs_%s",mpairname.c_str()) );
|
39 |
|
|
rhs_map_mpair[mpairname] = new RooDataSet(rname,rname,RooArgList(*rv_mass,*rv_weight),rv_weight->GetName());
|
40 |
|
|
|
41 |
|
|
mpairname = string (Form("%s_corr",mpair_var[j].c_str()));
|
42 |
|
|
rname = TString( Form("rhs_%s",mpairname.c_str()) );
|
43 |
|
|
rhs_map_mpair_corr[mpairname] = new RooDataSet(rname,rname,RooArgList(*rv_mass,*rv_weight),rv_weight->GetName());
|
44 |
|
|
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
float mMin = 0;
|
48 |
|
|
float mMax = 10000;
|
49 |
|
|
|
50 |
|
|
for(int n=1; n<=total_evtRange; n++){
|
51 |
|
|
filename = TString (Form("selres/testSelectionZee.v3.%s.r%d.root",test_datasetname,n));
|
52 |
|
|
cout<<filename<<endl;
|
53 |
|
|
TFile *f = new TFile(filename,"read");
|
54 |
|
|
RooWorkspace* w = (RooWorkspace*) f->Get("zeeShape") ;
|
55 |
|
|
|
56 |
|
|
for(int j=0; j< int( mpair_var.size()); j++){
|
57 |
|
|
string mpairname = mpair_var[j];
|
58 |
|
|
TString rname = TString( Form("rhs_%s",mpairname.c_str()) );
|
59 |
|
|
RooDataSet *rd = (RooDataSet*)w->data(rname);
|
60 |
|
|
appendcwd(rhs_map_mpair[mpairname],rd,rv_mass,rv_weight,mMin, mMax,1);
|
61 |
|
|
|
62 |
|
|
rname = TString( Form("rhs_%s",mpairname.c_str()) ) + TString("_corr");
|
63 |
|
|
rd = (RooDataSet*)w->data(rname);
|
64 |
|
|
mpairname = mpair_var[j] + string("_corr");
|
65 |
|
|
appendcwd(rhs_map_mpair_corr[mpairname],rd,rv_mass,rv_weight,mMin, mMax,1);
|
66 |
|
|
|
67 |
|
|
}
|
68 |
|
|
}
|
69 |
|
|
|
70 |
|
|
filename = TString(Form("res/ZeeShape.v3.%s.r1to%d.root",test_datasetname, total_evtRange));
|
71 |
|
|
cout<<filename<<endl;
|
72 |
|
|
TFile *fnew = new TFile(filename,"recreate");
|
73 |
|
|
RooWorkspace *w = new RooWorkspace("zeeShape","workspace") ;
|
74 |
|
|
for (std::map<string,RooDataSet*>::iterator it_data = rhs_map_mpair.begin()
|
75 |
|
|
;it_data != rhs_map_mpair.end();it_data++) {
|
76 |
|
|
w->import(*it_data->second);
|
77 |
|
|
}
|
78 |
|
|
for (std::map<string,RooDataSet*>::iterator it_data = rhs_map_mpair_corr.begin()
|
79 |
|
|
;it_data != rhs_map_mpair_corr.end();it_data++) {
|
80 |
|
|
w->import(*it_data->second);
|
81 |
|
|
}
|
82 |
|
|
|
83 |
|
|
|
84 |
|
|
w->Write();
|
85 |
|
|
|
86 |
|
|
fnew->Write();
|
87 |
|
|
fnew->Close();
|
88 |
|
|
|
89 |
|
|
}
|