Skip to content

Commit

Permalink
comments and indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
rkansal47 authored and kcormi committed Oct 10, 2023
1 parent 301a6ab commit d36c486
Showing 1 changed file with 22 additions and 26 deletions.
48 changes: 22 additions & 26 deletions src/Combine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,14 @@ void Combine::applyOptions(const boost::program_options::variables_map &vm) {
}

std::string Combine::parseRegex(std::string instr, const RooArgSet *nuisances, RooWorkspace *w) {
// expand regexps
// expand regexps inside the "rgx{}" option
while (instr.find("rgx{") != std::string::npos) {
size_t pos1 = instr.find("rgx{");
size_t pos2 = instr.find("}",pos1);
std::string prestr = instr.substr(0,pos1);
std::string poststr = instr.substr(pos2+1,instr.size()-pos2);
std::string reg_esp = instr.substr(pos1+4,pos2-pos1-4);

//std::cout<<"interpreting "<<reg_esp<<" as regex "<<std::endl;
std::regex rgx( reg_esp, std::regex::ECMAScript);

std::string matchingParams="";
Expand All @@ -241,15 +240,14 @@ std::string Combine::parseRegex(std::string instr, const RooArgSet *nuisances, R
instr = boost::replace_all_copy(instr, ",,", ",");
}

// expand regexps
// expand regexps inside the "var{}" option
while (instr.find("var{") != std::string::npos) {
size_t pos1 = instr.find("var{");
size_t pos2 = instr.find("}",pos1);
std::string prestr = instr.substr(0,pos1);
std::string poststr = instr.substr(pos2+1,instr.size()-pos2);
std::string reg_esp = instr.substr(pos1+4,pos2-pos1-4);

// std::cout<<"interpreting "<<reg_esp<<" as regex "<<std::endl;
std::regex rgx( reg_esp, std::regex::ECMAScript);

std::string matchingParams="";
Expand Down Expand Up @@ -649,7 +647,6 @@ void Combine::run(TString hlfFile, const std::string &dataset, double &limit, do
if (floatNuisances_ != "") {
floatNuisances_ = parseRegex(floatNuisances_, nuisances, w);

//RooArgSet toFloat((floatNuisances_=="all")?*nuisances:(w->argSet(floatNuisances_.c_str())));
RooArgSet toFloat;
if (floatNuisances_=="all") {
toFloat.add(*nuisances);
Expand All @@ -672,8 +669,8 @@ void Combine::run(TString hlfFile, const std::string &dataset, double &limit, do
}

if (verbose > 0) {
std::cout << "Set floating the following parameters: "; toFloat.Print("");
Logger::instance().log(std::string(Form("Combine.cc: %d -- Set floating the following parameters: ",__LINE__)),Logger::kLogLevelInfo,__func__);
std::cout << "Floating the following parameters: "; toFloat.Print("");
Logger::instance().log(std::string(Form("Combine.cc: %d -- Floating the following parameters: ",__LINE__)),Logger::kLogLevelInfo,__func__);
std::unique_ptr<TIterator> iter(toFloat.createIterator());
for (RooAbsArg *a = (RooAbsArg*) iter->Next(); a != 0; a = (RooAbsArg*) iter->Next()) {
Logger::instance().log(std::string(Form("Combine.cc: %d %s ",__LINE__,a->GetName())),Logger::kLogLevelInfo,__func__);
Expand All @@ -685,7 +682,6 @@ void Combine::run(TString hlfFile, const std::string &dataset, double &limit, do
if (freezeNuisances_ != "") {
freezeNuisances_ = parseRegex(freezeNuisances_, nuisances, w);

//RooArgSet toFreeze((freezeNuisances_=="all")?*nuisances:(w->argSet(freezeNuisances_.c_str())));
RooArgSet toFreeze;
if (freezeNuisances_=="allConstrainedNuisances") {
toFreeze.add(*nuisances);
Expand Down Expand Up @@ -713,7 +709,7 @@ void Combine::run(TString hlfFile, const std::string &dataset, double &limit, do
std::unique_ptr<TIterator> iter(toFreeze.createIterator());
for (RooAbsArg *a = (RooAbsArg*) iter->Next(); a != 0; a = (RooAbsArg*) iter->Next()) {
Logger::instance().log(std::string(Form("Combine.cc: %d %s ",__LINE__,a->GetName())),Logger::kLogLevelInfo,__func__);
}
}
}
utils::setAllConstant(toFreeze, true);
if (nuisances) {
Expand All @@ -731,24 +727,24 @@ void Combine::run(TString hlfFile, const std::string &dataset, double &limit, do
for (std::vector<string>::iterator ng_it=nuisanceGroups.begin();ng_it!=nuisanceGroups.end();ng_it++){
bool freeze_complement=false;
if (boost::algorithm::starts_with((*ng_it),"^")){
freeze_complement=true;
(*ng_it).erase(0,1);
}
freeze_complement=true;
(*ng_it).erase(0,1);
}

if (!w->set(Form("group_%s",(*ng_it).c_str()))){
std::cerr << "Unknown nuisance group: " << (*ng_it) << std::endl;
throw std::invalid_argument("Unknown nuisance group name");
}
RooArgSet groupNuisances(*(w->set(Form("group_%s",(*ng_it).c_str()))));
RooArgSet toFreeze;
if (!w->set(Form("group_%s",(*ng_it).c_str()))){
std::cerr << "Unknown nuisance group: " << (*ng_it) << std::endl;
throw std::invalid_argument("Unknown nuisance group name");
}
RooArgSet groupNuisances(*(w->set(Form("group_%s",(*ng_it).c_str()))));
RooArgSet toFreeze;

if (freeze_complement) {
RooArgSet still_floating(*mc->GetNuisanceParameters());
still_floating.remove(groupNuisances,true,true);
toFreeze.add(still_floating);
} else {
toFreeze.add(groupNuisances);
}
if (freeze_complement) {
RooArgSet still_floating(*mc->GetNuisanceParameters());
still_floating.remove(groupNuisances,true,true);
toFreeze.add(still_floating);
} else {
toFreeze.add(groupNuisances);
}

if (verbose > 0) { std::cout << "Freezing the following nuisance parameters: "; toFreeze.Print(""); }
utils::setAllConstant(toFreeze, true);
Expand All @@ -758,7 +754,7 @@ void Combine::run(TString hlfFile, const std::string &dataset, double &limit, do
mc->SetNuisanceParameters(newnuis);
if (mc_bonly) mc_bonly->SetNuisanceParameters(newnuis);
nuisances = mc->GetNuisanceParameters();
}
}
}
}

Expand Down

0 comments on commit d36c486

Please sign in to comment.