Skip to content

Commit

Permalink
Nckw new logger (#868)
Browse files Browse the repository at this point in the history
* Minimial version of CombineLogger

Replace Logger with stripped down version (CombineLogger)

* new splash

* moving messages to the logger, 1 of many

* replace couts with logger (2 of many)

* fixing compilation errors, sorry

---------

Co-authored-by: Nick Wardle <nckw@cern.ch>
Co-authored-by: Giacomo Ortona <gortona@cern.ch>
  • Loading branch information
3 people authored Dec 4, 2023
1 parent be488af commit b47ce81
Show file tree
Hide file tree
Showing 17 changed files with 425 additions and 573 deletions.
8 changes: 6 additions & 2 deletions bin/combine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "../interface/CascadeMinimizer.h"
#include "../interface/ProfilingTools.h"
#include "../interface/GenerateOnly.h"
#include "../interface/Logger.h"
#include "../interface/CombineLogger.h"
#include <map>

using namespace std;
Expand All @@ -51,6 +51,9 @@ int main(int argc, char **argv) {

Combine combiner;

// Set name of Log file (ideally would make this similar format to out file)
CombineLogger::instance().setName("combine_logger.out");

map<string, LimitAlgo *> methods;
algo = new Significance(); methods.insert(make_pair(algo->name(), algo));
algo = new BayesianFlatPrior(); methods.insert(make_pair(algo->name(), algo));
Expand Down Expand Up @@ -250,6 +253,7 @@ int main(int argc, char **argv) {
}

TString fileName = "higgsCombine" + name + "."+whichMethod+"."+massName+toyName+"root";

TFile *test = new TFile(fileName, "RECREATE"); outputFile = test;
TTree *t = new TTree("limit", "limit");
int syst, iToy, iSeed, iChannel;
Expand Down Expand Up @@ -324,7 +328,7 @@ int main(int argc, char **argv) {

try {
combiner.run(datacard, dataset, limit, limitErr, iToy, t, runToys);
if (verbose>0) Logger::instance().printLog();
if (verbose>0) CombineLogger::instance().printLog();
} catch (std::exception &ex) {
cerr << "Error when running the combination:\n\t" << ex.what() << std::endl;
test->Close();
Expand Down
122 changes: 48 additions & 74 deletions data/splash.txt
Original file line number Diff line number Diff line change
@@ -1,74 +1,48 @@
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@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@@@@@@@` @@# ': +@@. #@ # #` #@ ,@@: @: @@ :# :@, @@@@@@@@@@@@@@@@@,
;@@@@@@@@@@@+ ` @@ ` `@@ @ @` #@ ` @: @@ :@' :@, .@@@@@@@@@@@,
;@@@@@@@@@@@@. +@@+ @@@ @. .@` #@ ;@: @@ :@@. :@, .@@@@@@@@@@@,
;@@@@@@@@@@@@@+` `#@@@@#. ;@@@@` `@' '@` @@` `,#@@; `@@` ;@@@ :@: ,@@@@@@@@@@@,
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@,
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@,
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@,
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@,
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@,


``
:'''+++++'',
`;`.++++++++'+'.
`'` ;+''++++++';;:
;+,'+++'''++++'+'+:
.+++++'''''''''+::;+.
`+++++''''''''''',.,#+
;++++''''''''''''``;+#;
,+''++'''''''''+'+::####,
`++'++'''''''''+''++++++#+`
`;'''+#'` ;++++'''''''''''::;+++++#+'
:';.`.''++,+++++'''''''''+;,.:++++++#+.
.'';.` .''+++++++''''',:'''':``'+++++#;;;
`;'''.`` ;''++++++'''';. .''+''.:+++++++::;
:'''''. ;'''++++++''''. ;'++++++++++++;,::
.'''''''''''''''++++''''';.;'+'::'+++++++++`;.
;''''''''''''';;;'++++++'''''++,,.;+++++++##++
,''''''''''''';;;;;'++'''++++++++.``'+++++#;:+#,
:'''''''''''';;;;;;;;''''++++++###; :+++++#+,:++
::..';'''''';;;;;;;;;;'''++++++++##++++++++#'.,+.
.,.``''''''';;;;;;;;;;;''++++;+'++++#++++++##+,';
'`` ,;;;'';;;;;;;;;;;;;;'++++';;.++++++++++##+##`
.; .';'';;;;;;;;;;;;:;;;''+++#,#+,++++++++#::+#:
:;;''''';;;;;;;;;;;:.``:;;;,'+++;#####+++++',,'+
;;''''';;;;;;;;;;;:.`` ,;;;,:+++#;########+;`,+.
;;'';';;;;;;;;;;;;``` :'';;`'++#; .+##::#+#,':
;''';;;;;;;;;;;;;;` ,;'''',,++#+` ,+;`###.
;''';;;;;;;;;;;;;;: `:;+++'''.++##, .:.
:''';';;;;;;;;;;;;;;;;'+++++++++##+
:''''';;;;;;;;;;;;;;;'+#####+++++##`
,';;'';;;;;;;;;;;;;;+#+++###+++'+#+;
.';;;:,;;;;;;;;;;;+#++++++++++++'+#+
.'';,.`.;;;;;;;;'#+++++++++++++#++++,
`''.`` .;;;;;;'#++++++++++++++###+++'
`'' :;;;;;++++++++++++++++###+#+++`
;: ,;;;;+++++++++++++++++++++###++:
';,`:';;++++++++++++++++++++++#####+'
;';'';'#+++###++++++++++++++########;
`++++##+++###+++++++++++++##########,
'#######+++++++++':::,+###########+
`########++++++#+.,:,,+##########+.
:#+######++++##+`.,,+####+######.
'+##+++###+++++++############+`
;###++#+++#++++++#########+`
`+######+###++#########+`
,##################+.
`'##############+.
.#++########+`
;++#####+.
.::,.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@.%&&&&&&&&&&&&&&&&&&&@@@@@@@@@@@@@@@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@@@@@@@@@@@@@@@/%
@.%&&&&&&&&&&&(.(&&( #&&&&#((&&&&##%(%#(%&&&.(#(#&&&&&%###&&&&&%#%((%&&&&&&#(#&&&&&&&&&&&&&&&&&&@@@&,&@@@@@@@@@@@@@@@@/%
@.#######%%%%%./&&&&&&&&.,&&&( %&% %% &#.&&&.,&&&,.&&&&&,,&&&&&& /&&*,&&& ,(((,.&&&&&&&&&&&&&&&&&&@,%@@@@@@@@@@@@@@@@@/%
@.(###########(.,//*./##/ /#(.,&&( /% /#.(&(../#( *&&%//..//&&&( *%%,.#&&*./#(/*&&&&&&&&&&&&&&&&&&,#@@@@@@@@@@@@@@@@@@/%
@.(############################%&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&,#&&@@@@@@@@@@@@@@@@@/%
@.(#################################%&&&&&&&&&&&&&&&&&&&&&&&&(#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&,(&&&&@@@@@@@@@@@@@@@@/%
@.(#####################################%&&&&&&&&&&&&&&&&&&&(*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&,(&&&&&&&@@@@@@@@@@@@@@/%
@.(#########################################&&&&&&&&&&&&&&&*/&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&,(&&&&&&&&&@@@@@@@@@@@@@/%
@.(############################################&&&&&&&&&&&%#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&,(&&&&&&&&&&&@@@@@@@@@@@@/%
@.(###############################################&&&&&&&*#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&,#&&&&&&&&&&&&&&@@@@@@@@@@/%
@.(#################################################%&&%(&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&%,#&&&&&&&&&&&&&&&&@@@@@@@@@/%
@.(//#((##############################################%%&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&%,%&&&&&&&&&&&&&&&&&&@@@@@@@@/%
@.(############/*(/(#################################/*#%&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&%,%&&&&&&&&&&&&&&&&&&&&@@@@@@@/%
@.###################(/#/(##########################(#####%&&&&&&&&&&&&&&&&&&&&&&&&&&&&#,&&&&&&&&&&&&&&&&&&&&&&&@@@@@@/%
@.#########################//#####################(,(#######&&&&&&&&&&&&&&&&&&&&&&&&&&(,&&&&&&&&&&&&&&&&&&&&&&&&&@@@@@/%
@.############################((/################//##########%&&&&&&&&&&&&&&&&&&&&&&&/*&&&&&&&&&&&&&&&&&&&&&&&&&&@@@@@/%
@.#######################/,/(((((/,*(###########//#############&&&&&&&&&&&&&&&&&&&&&*/&&&&&&&&&&&&&&&&&&&&&&&&&&&&@@@@*%
@.####################**(###########/,,(######/,(###############&&&&&&&&&&&&&&&&&&&*(&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&@@@*%
@.&&&&&&&&&&&%#####(*/################/**/####(##################&&&&&&&&&&&&&&&&&,%&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&@@*%
@.&&&&&&&&&&&&&&&&//####################*/**,(####################&&&&&&&&&&&&&&%,%&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&@@*%
@.&&&&&&&&&&&&&&#*&&&%###################(*(,/#####################&&&&&&&&&&&&(*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&@*%
@.&&&&&&&&&&&&&*#&&&&&&&################(/#*((,(###################%&&&&&&&&&&/(&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&@*%
@.&&&&&&&&&&&%,&&&&&&&&&&&############,*####/(#**###################&&&&&&&&&,#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*%
@.%&&&&&&&&&/(&&&&&&&&&&&&&%#######(*########((##,(##################&&&&&&%,&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*%
@.%&&&&&&&&,&&&&&&&&&&&&&&&&&#####(/##########(###(,(################%&&&&(/&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*%
@.%&&&&&&#*&&&&&&&&&&&&&&&&&&&#*,(#############/####*/################&&&,%&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*%
@.%&&&&&*%&&&&&&&&&&&&&&&&&&(,#################*(####(,(##############&(*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*%
@.&@@&/(&&&&&&&&&&&&&&&&&*&&&&&#################*######(,(###########(,%&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*%
@.(@/(@@&&&&&&&&&&&%(/&%&&&&&&&%################*########(**#######/*(%&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*%
@.(&&#/%%,,,#%,,*(#############(/////////////////////////////*,,,,/////(((((((((((((((((((((((((((((((((((((((((((((((,%
31 changes: 31 additions & 0 deletions interface/CombineLogger.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef HiggsAnalysis_CombinedLimit_CombineLogger_h
#define HiggsAnalysis_CombinedLimit_CombineLogger_h

#include <iostream>
#include <fstream>
#include <string>

class CombineLogger
{
public:
static int nLogs;

static CombineLogger& instance();

static void setName(const char* _fName){
fName=_fName;
};

void log(const std::string & _file, const int _lineN, const std::string& _logmsg, const std::string& _function);
void printLog();

protected:
// Static variable for the instance
static CombineLogger* pL;

static const char* fName;
std::ofstream outStream;
CombineLogger();
virtual ~CombineLogger();
};
#endif
79 changes: 0 additions & 79 deletions interface/Logger.h

This file was deleted.

10 changes: 5 additions & 5 deletions src/AsimovUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "../interface/ToyMCSamplerOpt.h"
#include "../interface/CloseCoutSentry.h"
#include "../interface/CascadeMinimizer.h"
#include "../interface/Logger.h"
#include "../interface/CombineLogger.h"

RooAbsData *asimovutils::asimovDatasetNominal(RooStats::ModelConfig *mc, double poiValue, int verbose) {
RooArgSet poi(*mc->GetParametersOfInterest());
Expand All @@ -20,11 +20,11 @@ RooAbsData *asimovutils::asimovDatasetNominal(RooStats::ModelConfig *mc, double
toymcoptutils::SimPdfGenInfo newToyMC(*mc->GetPdf(), *mc->GetObservables(), false);

if (verbose>2) {
Logger::instance().log(std::string(Form("AsimovUtils.cc: %d -- Parameters after fit for asimov dataset",__LINE__)),Logger::kLogLevelInfo,__func__);
CombineLogger::instance().log("AsimovUtils.cc",__LINE__,"Parameters after fit for asimov dataset",__func__);
std::unique_ptr<TIterator> iter(mc->GetPdf()->getParameters((const RooArgSet*) 0)->createIterator());
for (RooAbsArg *a = (RooAbsArg *) iter->Next(); a != 0; a = (RooAbsArg *) iter->Next()) {
TString varstring = utils::printRooArgAsString(a);
Logger::instance().log(std::string(Form("AsimovUtils.cc: %d -- %s",__LINE__,varstring.Data())),Logger::kLogLevelInfo,__func__);
CombineLogger::instance().log("AsimovUtils.cc",__LINE__,std::string(Form("%s",varstring.Data())),__func__);
}
}

Expand Down Expand Up @@ -66,11 +66,11 @@ RooAbsData *asimovutils::asimovDatasetWithFit(RooStats::ModelConfig *mc, RooAbsD
}

if (verbose>2) {
Logger::instance().log(std::string(Form("AsimovUtils.cc: %d -- Parameters after fit for asimov dataset",__LINE__)),Logger::kLogLevelInfo,__func__);
CombineLogger::instance().log("AsimovUtils.cc",__LINE__,"Parameters after fit for asimov dataset",__func__);
std::unique_ptr<TIterator> iter(mc->GetPdf()->getParameters(realdata)->createIterator());
for (RooAbsArg *a = (RooAbsArg *) iter->Next(); a != 0; a = (RooAbsArg *) iter->Next()) {
TString varstring = utils::printRooArgAsString(a);
Logger::instance().log(std::string(Form("AsimovUtils.cc: %d -- %s",__LINE__,varstring.Data())),Logger::kLogLevelInfo,__func__);
CombineLogger::instance().log("AsimovUtils.cc",__LINE__,std::string(Form("%s",varstring.Data())),__func__);
}
}

Expand Down
Loading

0 comments on commit b47ce81

Please sign in to comment.