Skip to content

Commit

Permalink
Update all
Browse files Browse the repository at this point in the history
  • Loading branch information
ddiaz006 committed Dec 4, 2020
1 parent 42f0550 commit 361c992
Show file tree
Hide file tree
Showing 25 changed files with 3,129 additions and 187 deletions.
22 changes: 20 additions & 2 deletions model/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ TARGET4 = MakeWorkspace_VR_SYS
TARGET5 = MakeMockupSystematics
TARGET6 = MakeWorkspace_VR_Merged_EMu
TARGET7 = MakeWorkspace_VR_SYS_ALL_TF
TARGET8 = MakeWorkspace_VR_SYS_ALL_TF_EMuCombo
TARGET9 = MakeWorkspace_VR_SYS_ALL_TF_EMuCombo_Reparam

SRC = $(REPO)/build_ws.cc $(COMMON)/src/CommandLineInput.cc
SRC2 = $(REPO)/app/build_ws_validation_region.cc $(COMMON)/src/CommandLineInput.cc
Expand All @@ -26,6 +28,8 @@ SRC4 = $(REPO)/app/build_ws_validation_region_systematics.cc $(COMMON)/src/Comma
SRC5 = $(REPO)/app/make_mockup_systematics.cc $(COMMON)/src/CommandLineInput.cc
SRC6 = $(REPO)/app/build_ws_validation_region_merged_emu.cc $(COMMON)/src/CommandLineInput.cc
SRC7 = $(REPO)/app/build_ws_validation_region_systematics_all_tf.cc $(COMMON)/src/CommandLineInput.cc
SRC8 = $(REPO)/app/build_ws_validation_region_systematics_all_tf_EleMuCombo.cc $(COMMON)/src/CommandLineInput.cc
SRC9 = $(REPO)/app/build_ws_validation_region_systematics_all_tf_EleMuCombo_reparam.cc $(COMMON)/src/CommandLineInput.cc

OBJ = $(SRC:.cc=.o)
OBJ2 = $(SRC2:.cc=.o)
Expand All @@ -34,8 +38,10 @@ OBJ4 = $(SRC4:.cc=.o)
OBJ5 = $(SRC5:.cc=.o)
OBJ6 = $(SRC6:.cc=.o)
OBJ7 = $(SRC7:.cc=.o)
OBJ8 = $(SRC8:.cc=.o)
OBJ9 = $(SRC9:.cc=.o)

all : $(TARGET) $(TARGET2) $(TARGET4) $(TARGET5) $(TARGET6) $(TARGET7)
all : $(TARGET) $(TARGET2) $(TARGET4) $(TARGET5) $(TARGET6) $(TARGET7) $(TARGET8) $(TARGET9)

$(TARGET) : $(OBJ)
$(LD) $(CPPFLAGS) -o $(TARGET) $(OBJ) $(LDFLAGS)
Expand Down Expand Up @@ -80,10 +86,22 @@ $(TARGET7) : $(OBJ7)
@echo $<
@echo $^

$(TARGET8) : $(OBJ8)
$(LD) $(CPPFLAGS) -o $(TARGET8) $(OBJ8) $(LDFLAGS)
@echo $@
@echo $<
@echo $^

$(TARGET9) : $(OBJ9)
$(LD) $(CPPFLAGS) -o $(TARGET9) $(OBJ9) $(LDFLAGS)
@echo $@
@echo $<
@echo $^

%.o : %.cc
$(CXX) $(CPPFLAGS) -o $@ -c $<
@echo $@
@echo $<

clean :
rm -f *.o app/*.o src/*.o include/*.o $(TARGET) $(TARGET2) $(TARGET4) $(TARGET5) $(TARGET6) $(TARGET7) $(COMMON)/src/*.o *~
rm -f *.o app/*.o src/*.o include/*.o $(TARGET) $(TARGET2) $(TARGET4) $(TARGET5) $(TARGET6) $(TARGET7) $(TARGET8) $(TARGET9) $(COMMON)/src/*.o *~
107 changes: 23 additions & 84 deletions model/app/build_ws_validation_region_systematics_all_tf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ using namespace std;


//Global options
bool _additional_method_sys =true;
bool _additional_method_sys = false;
const float signal_scaling = 1.0;
TString dummy_syst = "0.01";
TString xvar = "nSelectedAODCaloJetTag";
Expand All @@ -83,6 +83,7 @@ TString xvar = "nSelectedAODCaloJetTag";
//TString xvar_suffix = "_log_eemumu";
//TString xvar_suffix = "_log";
//TString xvar_suffix = "_mockup_sys_hadd";
//TString xvar_suffix = "SB7_mockup_sys_hadd_PreApp";
TString xvar_suffix = "_mockup_sys_hadd_PreApp";
TString signal_string = "Sig_MS55ct100";
//TString data_string = "bkgtotal"; //"Data";
Expand Down Expand Up @@ -398,13 +399,7 @@ void build_twomuzh(RooWorkspace* wspace, TString light_est = "DY"){
RooDataHist data_twomuzh_hist("data_obs_twomuzh", "Data observed in TwoMuZH", vars, &data_twomuzh_th1);
wspace->import(data_twomuzh_hist);

//----------------------------------------------------
//setting up to add additional systematic uncertainty
//----------------------------------------------------
//std::string add_logN_systematic = "TMath::Power(1+0.1,@0)";
//std::string add_logN_systematic[] = {"TMath::Power(1+0.01,@0)","TMath::Power(1+0.01,@0)","TMath::Power(1+0.01,@0)"};
std::string add_logN_systematic[] = {"TMath::Power(1+0.15,@0)","TMath::Power(1+0.15,@0)","TMath::Power(1+0.15,@0)"};
//std::string add_logN_systematic[] = {"TMath::Power(1+0.2,@0)","TMath::Power(1+0.2,@0)","TMath::Power(1+0.2,@0)"};

RooRealVar rrv_bkg_method_add_sys_bin1("rrv_bkg_method_add_sys_bin1","rrv_bkg_method_add_sys_bin1", 0.0);
RooRealVar rrv_bkg_method_add_sys_bin2("rrv_bkg_method_add_sys_bin2","rrv_bkg_method_add_sys_bin2", 0.0);
RooRealVar rrv_bkg_method_add_sys_bin3("rrv_bkg_method_add_sys_bin3","rrv_bkg_method_add_sys_bin3", 0.0);
Expand Down Expand Up @@ -449,32 +444,14 @@ void build_twomuzh(RooWorkspace* wspace, TString light_est = "DY"){
RooFormulaVar* heavy_twomuzh_bin1;
RooFormulaVar* heavy_twomuzh_bin2;
RooFormulaVar* heavy_twomuzh_bin3;
// if(_additional_method_sys)
// {
// // heavy_twomuzh_bin1 = new RooFormulaVar("heavy_twomuzh_bin1", "Heavy background yield in twomuzh, bin 1",
// // "@0*@1*@2", RooArgList(*tf_heavy_elemu_to_twomuzh_bin1, *heavy_elemu_bin1, heavy_twomuzh_logN_add_sys_bin1));
// // heavy_twomuzh_bin2 = new RooFormulaVar("heavy_twomuzh_bin2", "Heavy background yield in twomuzh, bin 2",
// // "@0*@1*@2", RooArgList(*tf_heavy_elemu_to_twomuzh_bin2, *heavy_elemu_bin2, heavy_twomuzh_logN_add_sys_bin2));
// // heavy_twomuzh_bin3 = new RooFormulaVar("heavy_twomuzh_bin3", "Heavy background yield in twomuzh, bin 3",
// // "@0*@1*@2", RooArgList(*tf_heavy_elemu_to_twomuzh_bin3, *heavy_elemu_bin3, heavy_twomuzh_logN_add_sys_bin3));
// }
// else
// {
// heavy_twomuzh_bin1 = new RooFormulaVar("heavy_twomuzh_bin1", "Heavy background yield in twomuzh, bin 1",
// "@0*@1", RooArgList(*tf_heavy_elemu_to_twomuzh_bin1, *heavy_elemu_bin1));
// heavy_twomuzh_bin2 = new RooFormulaVar("heavy_twomuzh_bin2", "Heavy background yield in twomuzh, bin 2",
// "@0*@1", RooArgList(*tf_heavy_elemu_to_twomuzh_bin2, *heavy_elemu_bin2));
// heavy_twomuzh_bin3 = new RooFormulaVar("heavy_twomuzh_bin3", "Heavy background yield in twomuzh, bin 3",
// "@0*@1", RooArgList(*tf_heavy_elemu_to_twomuzh_bin3, *heavy_elemu_bin3));
// }
// correct implementation to build with add sys.
heavy_twomuzh_bin1 = new RooFormulaVar("heavy_twomuzh_bin1", "Heavy background yield in twomuzh, bin 1",
"@0*@1", RooArgList(*tf_heavy_elemu_to_twomuzh_bin1, *heavy_elemu_bin1));
heavy_twomuzh_bin2 = new RooFormulaVar("heavy_twomuzh_bin2", "Heavy background yield in twomuzh, bin 2",
"@0*@1", RooArgList(*tf_heavy_elemu_to_twomuzh_bin2, *heavy_elemu_bin2));
heavy_twomuzh_bin3 = new RooFormulaVar("heavy_twomuzh_bin3", "Heavy background yield in twomuzh, bin 3",
"@0*@1", RooArgList(*tf_heavy_elemu_to_twomuzh_bin3, *heavy_elemu_bin3));


heavy_twomuzh_bin1 = new RooFormulaVar("heavy_twomuzh_bin1", "Heavy background yield in twomuzh, bin 1",
"@0*@1", RooArgList(*tf_heavy_elemu_to_twomuzh_bin1, *heavy_elemu_bin1));
heavy_twomuzh_bin2 = new RooFormulaVar("heavy_twomuzh_bin2", "Heavy background yield in twomuzh, bin 2",
"@0*@1", RooArgList(*tf_heavy_elemu_to_twomuzh_bin2, *heavy_elemu_bin2));
heavy_twomuzh_bin3 = new RooFormulaVar("heavy_twomuzh_bin3", "Heavy background yield in twomuzh, bin 3",
"@0*@1", RooArgList(*tf_heavy_elemu_to_twomuzh_bin3, *heavy_elemu_bin3));

RooArgList heavy_twomuzh_bins;
heavy_twomuzh_bins.add(*heavy_twomuzh_bin1);
heavy_twomuzh_bins.add(*heavy_twomuzh_bin2);
Expand Down Expand Up @@ -523,15 +500,6 @@ void build_twomuzh(RooWorkspace* wspace, TString light_est = "DY"){
RooRealVar* light_twomudy_bin2 = wspace->var("light_twomudy_bin2");
RooRealVar* light_twomudy_bin3 = wspace->var("light_twomudy_bin3");

//---------------------------------------------------------
//Include additional systematic uncertainty for the method
//---------------------------------------------------------
// RooFormulaVar light_twomuzh_logN_add_sys_bin1("light_twomuzh_logN_add_sys_bin1", "additional log-normal for method, bin 1",
// add_logN_systematic[0].c_str(), RooArgList(rrv_twomuzh_add_sys_bin1));
// RooFormulaVar light_twomuzh_logN_add_sys_bin2("light_twomuzh_logN_add_sys_bin2", "additional log-normal for method, bin 2",
// add_logN_systematic[1].c_str(), RooArgList(rrv_twomuzh_add_sys_bin2));
// RooFormulaVar light_twomuzh_logN_add_sys_bin3("light_twomuzh_logN_add_sys_bin3", "additional log-normal for method, bin 3",
// add_logN_systematic[2].c_str(), RooArgList(rrv_twomuzh_add_sys_bin3));

RooFormulaVar* light_twomuzh_bin1;
RooFormulaVar* light_twomuzh_bin2;
Expand All @@ -543,13 +511,13 @@ void build_twomuzh(RooWorkspace* wspace, TString light_est = "DY"){
"@0*@1", RooArgList(*tf_light_twomudy_to_twomuzh_bin2, *light_twomudy_bin2));
light_twomuzh_bin3 = new RooFormulaVar("light_twomuzh_bin3", "Light background yield in twomuzh, bin 3",
"@0*@1", RooArgList(*tf_light_twomudy_to_twomuzh_bin3, *light_twomudy_bin3));
//light_twomuzh_bin3 = new RooFormulaVar("light_twomuzh_bin3", "Light background yield in twomuzh, bin 3",
//"@0*pow( (1+@1), 5.)", RooArgList(*tf_light_twomudy_to_twomuzh_bin3, *light_twomudy_bin3));

RooArgList light_twomuzh_bins;
light_twomuzh_bins.add(*light_twomuzh_bin1);
light_twomuzh_bins.add(*light_twomuzh_bin2);
std::cout << "pre" << std::endl;
light_twomuzh_bins.add(*light_twomuzh_bin3);
std::cout << "post" << std::endl;
RooParametricHist p_light_twomuzh("light_twomuzh", "Light PDF in TwoMuZH Region", *ntags, light_twomuzh_bins, data_twomuzh_th1);
RooAddition p_light_twomuzh_norm("light_twomuzh_norm", "Total number of light events in TwoMuZH Region", light_twomuzh_bins);

Expand Down Expand Up @@ -625,26 +593,6 @@ void build_twomuzh(RooWorkspace* wspace, TString light_est = "DY"){
int systematic_i_ctr = 0;
for ( auto &sys_map : systematic_map )
{
///std::cout << "====> SYS NAME: " << sys_map.first << std::endl;
///std::string rrv_sys_name = "rrv_signal_twomuzh_"+sys_map.first;//one RooRealVar per systematic
///std::cout << "====> SYS NAME: " << rrv_sys_name << std::endl;
///std::string rfv_sys_name_bin1 = "rrv_signal_twomuzh_"+sys_map.first+"_bin1";
///std::string rfv_sys_name_bin2 = "rrv_signal_twomuzh_"+sys_map.first+"_bin2";
///std::string rfv_sys_name_bin3 = "rrv_signal_twomuzh_"+sys_map.first+"_bin3";
///rrv_signal_twomuzh_systematic[systematic_i_ctr] = new RooRealVar(rrv_sys_name.c_str(),rrv_sys_name.c_str(), 0.0);//each systemetic is controlled by 1 nuissance parameter
///rrv_signal_twomuzh_systematic[systematic_i_ctr]->setConstant(kTRUE);
/////RooFormulaVars 1 per ntag-bin
///rfv_signal_twomuzh_systematic_bin1[systematic_i_ctr] = new RooFormulaVar(rfv_sys_name_bin1.c_str(), rfv_sys_name_bin1.c_str(),
///sys_map.second[0].c_str(),RooArgList(*rrv_signal_twomuzh_systematic[systematic_i_ctr]));
///rfv_signal_twomuzh_systematic_bin2[systematic_i_ctr] = new RooFormulaVar(rfv_sys_name_bin2.c_str(), rfv_sys_name_bin2.c_str(),
///sys_map.second[1].c_str(),RooArgList(*rrv_signal_twomuzh_systematic[systematic_i_ctr]));
///rfv_signal_twomuzh_systematic_bin3[systematic_i_ctr] = new RooFormulaVar(rfv_sys_name_bin3.c_str(), rfv_sys_name_bin3.c_str(),
///sys_map.second[2].c_str(),RooArgList(*rrv_signal_twomuzh_systematic[systematic_i_ctr]));

/////add to RooArgList
///signal_twomuzh_sys_arglist[0].add(*rfv_signal_twomuzh_systematic_bin1[systematic_i_ctr]);
///signal_twomuzh_sys_arglist[1].add(*rfv_signal_twomuzh_systematic_bin2[systematic_i_ctr]);
///signal_twomuzh_sys_arglist[2].add(*rfv_signal_twomuzh_systematic_bin3[systematic_i_ctr]);
std::string sys_map_first_tmp = "rrv_"+sys_map.first;
RooRealVar* rrv_syst = wspace->var(sys_map_first_tmp.c_str());
signal_twomuzh_sys_arglist[0].add(RooArgList(*rrv_syst));
Expand All @@ -663,15 +611,6 @@ void build_twomuzh(RooWorkspace* wspace, TString light_est = "DY"){
systematic_i_ctr++;
}

//RooRealVar rrv_signal_zh_amax_sys("rrv_signal_zh_amax_sys","rrv_signal_zh_amax_sys", 0.0);//controlled by 1 nuissance parameter
//rrv_signal_zh_amax_sys.setConstant(kTRUE);
//RooFormulaVar rfv_signal_twomuzh_amax_sys_bin1("rfv_signal_twomuzh_amax_sys_bin1", "amax systematic (log-normal) bin1",
//signal_logN_amax[0].c_str(), RooArgList(rrv_signal_zh_amax_sys));;
//RooFormulaVar rfv_signal_twomuzh_amax_sys_bin2("rfv_signal_twomuzh_amax_sys_bin2", "amax systematic (log-normal) bin2",
//signal_logN_amax[1].c_str(), RooArgList(rrv_signal_zh_amax_sys));
//RooFormulaVar rfv_signal_twomuzh_amax_sys_bin3("rfv_signal_twomuzh_amax_sys_bin3", "amax systematic (log-normal) bin3",
//signal_logN_amax[2].c_str(), RooArgList(rrv_signal_zh_amax_sys));

std::cout<<"Sys Arg List signal1: "<<signal_twomuzh_sys_arglist[0]<<std::endl;
std::cout<<"Sys Arg List signal2: "<<signal_twomuzh_sys_arglist[1]<<std::endl;
std::cout<<"Sys Arg List signal3: "<<signal_twomuzh_sys_arglist[2]<<std::endl;
Expand Down Expand Up @@ -944,11 +883,11 @@ void build_elemu(RooWorkspace *wspace){
//Create one parameter per bin representing the yield
TH1F* h_heavy_elemu = (TH1F*)f_elemu->Get("heavy");
RooRealVar heavy_elemu_bin1("heavy_elemu_bin1", "Heavy background yield in EleMu, bin 1",
h_heavy_elemu->GetBinContent(1), h_heavy_elemu->GetBinContent(1)*0.5,h_heavy_elemu->GetBinContent(1)*1.5 );
h_heavy_elemu->GetBinContent(1), h_heavy_elemu->GetBinContent(1)*0.01,h_heavy_elemu->GetBinContent(1)*100.5 );
RooRealVar heavy_elemu_bin2("heavy_elemu_bin2", "Heavy background yield in EleMu, bin 2",
h_heavy_elemu->GetBinContent(2), h_heavy_elemu->GetBinContent(2)*0.5,h_heavy_elemu->GetBinContent(2)*1.5 );
h_heavy_elemu->GetBinContent(2), h_heavy_elemu->GetBinContent(2)*0.01,h_heavy_elemu->GetBinContent(2)*100.5 );
RooRealVar heavy_elemu_bin3("heavy_elemu_bin3", "Heavy background yield in EleMu, bin 3",
h_heavy_elemu->GetBinContent(3), 0 ,(h_heavy_elemu->GetBinContent(3)+10)*1.5 );
h_heavy_elemu->GetBinContent(3), 0 ,(h_heavy_elemu->GetBinContent(3)+10)*100.5 );
RooArgList heavy_elemu_bins;
heavy_elemu_bins.add(heavy_elemu_bin1);
heavy_elemu_bins.add(heavy_elemu_bin2);
Expand Down Expand Up @@ -1005,11 +944,11 @@ void build_elemul(RooWorkspace *wspace){
//Create one parameter per bin representing the yield
TH1F* h_heavy_elemul = (TH1F*)f_elemul->Get("heavy");
RooRealVar heavy_elemul_bin1("heavy_elemul_bin1", "Heavy background yield in EleMuL, bin 1",
h_heavy_elemul->GetBinContent(1), h_heavy_elemul->GetBinContent(1)*0.5,h_heavy_elemul->GetBinContent(1)*1.5 );
h_heavy_elemul->GetBinContent(1), h_heavy_elemul->GetBinContent(1)*0.01,h_heavy_elemul->GetBinContent(1)*100.5 );
RooRealVar heavy_elemul_bin2("heavy_elemul_bin2", "Heavy background yield in EleMuL, bin 2",
h_heavy_elemul->GetBinContent(2), h_heavy_elemul->GetBinContent(2)*0.5,h_heavy_elemul->GetBinContent(2)*1.5 );
h_heavy_elemul->GetBinContent(2), h_heavy_elemul->GetBinContent(2)*0.01,h_heavy_elemul->GetBinContent(2)*100.5 );
RooRealVar heavy_elemul_bin3("heavy_elemul_bin3", "Heavy background yield in EleMuL, bin 3",
h_heavy_elemul->GetBinContent(3), 0, (h_heavy_elemul->GetBinContent(3)+10)*1.5);
h_heavy_elemul->GetBinContent(3), 0, (h_heavy_elemul->GetBinContent(3)+10)*100.5);
RooArgList heavy_elemul_bins;
heavy_elemul_bins.add(heavy_elemul_bin1);
heavy_elemul_bins.add(heavy_elemul_bin2);
Expand Down Expand Up @@ -1136,11 +1075,11 @@ void build_twomudy(RooWorkspace* wspace){
//Create one parameter per bin representing the yield
TH1F* h_light_twomudy = (TH1F*)f_twomudy->Get("light");
RooRealVar light_twomudy_bin1("light_twomudy_bin1", "Light background yield in TwoMuDY, bin 1",
h_light_twomudy->GetBinContent(1), h_light_twomudy->GetBinContent(1)*0.5, h_light_twomudy->GetBinContent(1)*1.5);
h_light_twomudy->GetBinContent(1), h_light_twomudy->GetBinContent(1)*0.01, h_light_twomudy->GetBinContent(1)*100.5);
RooRealVar light_twomudy_bin2("light_twomudy_bin2", "Light background yield in TwoMuDY, bin 2",
h_light_twomudy->GetBinContent(2), h_light_twomudy->GetBinContent(2)*0.5, h_light_twomudy->GetBinContent(2)*1.5);
h_light_twomudy->GetBinContent(2), h_light_twomudy->GetBinContent(2)*0.01, h_light_twomudy->GetBinContent(2)*100.5);
RooRealVar light_twomudy_bin3("light_twomudy_bin3", "Light background yield in TwoMuDY, bin 3",
h_light_twomudy->GetBinContent(3), 0, (h_light_twomudy->GetBinContent(3)+10)*1.5);
h_light_twomudy->GetBinContent(3), 0, (h_light_twomudy->GetBinContent(3)+10)*100.5);
RooArgList light_twomudy_bins;
light_twomudy_bins.add(light_twomudy_bin1);
light_twomudy_bins.add(light_twomudy_bin2);
Expand Down Expand Up @@ -1327,7 +1266,7 @@ int main( int argc, char* argv[] ){

//Make RRVs for systematics
for(unsigned int i=0; i<sys_vec.size(); i++){
RooRealVar r("rrv_"+sys_vec[i], "rrv_"+sys_vec[i], 1, 0, 5);
RooRealVar r("rrv_"+sys_vec[i], "rrv_"+sys_vec[i], 0.0, -5.0, 5.0);
r.setConstant(kTRUE);
wspace->import(r, RooFit::RecycleConflictNodes());
}
Expand Down
Loading

0 comments on commit 361c992

Please sign in to comment.