Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renaming endl to RESTendl and other loggers functions #225

Merged
merged 4 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions macros/REST_CheckRunFileList.C
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Int_t REST_CheckRunFileList(TString namePattern, Int_t N = 100000) {

vector<TString> filesNotWellClosed;

TRestStringOutput cout;
TRestStringOutput RESTLog;

string a = TRestTools::Execute((string)("ls -d -1 " + namePattern));
vector<string> b = Split(a, "\n");
Expand All @@ -29,14 +29,14 @@ Int_t REST_CheckRunFileList(TString namePattern, Int_t N = 100000) {
int cont = 0;
for (int i = 0; i < b.size(); i++) {
string filename = b[i];
cout << filename << endl;
RESTLog << filename << RESTendl;
cont++;
TRestRun* run = new TRestRun();

TFile* f = new TFile(filename.c_str());

if (!TRestTools::fileExists(filename)) {
cout << "WARNING. Input file does not exist" << endl;
RESTLog << "WARNING. Input file does not exist" << RESTendl;
exit(1);
}

Expand All @@ -48,12 +48,12 @@ Int_t REST_CheckRunFileList(TString namePattern, Int_t N = 100000) {
while ((key = (TKey*)nextkey())) {
string className = key->GetClassName();
if (className == "TRestRun") {
cout << key->GetName() << endl;
RESTLog << key->GetName() << RESTendl;
run = (TRestRun*)f->Get(key->GetName());
}
}

cout << "Run time (hours) : " << run->GetRunLength() / 3600. << endl;
RESTLog << "Run time (hours) : " << run->GetRunLength() / 3600. << RESTendl;
if (run->GetRunLength() > 0) totalTime += run->GetRunLength() / 3600.;

if (run->GetEndTimestamp() == 0 || run->GetRunLength() < 0) {
Expand All @@ -66,15 +66,15 @@ Int_t REST_CheckRunFileList(TString namePattern, Int_t N = 100000) {
}

if (filesNotWellClosed.size() > 0) {
cout << endl;
cout << "---------------------" << endl;
cout << "Files not well closed" << endl;
cout << "---------------------" << endl;
for (int i = 0; i < filesNotWellClosed.size(); i++) cout << filesNotWellClosed[i] << endl;
RESTLog << RESTendl;
RESTLog << "---------------------" << RESTendl;
RESTLog << "Files not well closed" << RESTendl;
RESTLog << "---------------------" << RESTendl;
for (int i = 0; i < filesNotWellClosed.size(); i++) RESTLog << filesNotWellClosed[i] << RESTendl;
}

cout << "------------------------------" << endl;
cout << "Total runs time : " << totalTime << " hours" << endl;
RESTLog << "------------------------------" << RESTendl;
RESTLog << "Total runs time : " << totalTime << " hours" << RESTendl;

return 0;
}
Expand Down
12 changes: 6 additions & 6 deletions macros/REST_CreateHisto.C
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
//*******************************************************************************************************
Int_t REST_CreateHisto(string varName, string rootFileName, TString histoName, int startVal = 0,
int endVal = 1000, int bins = 1000, Double_t normFactor = 1) {
TRestStringOutput cout;
TRestStringOutput RESTLog;

std::vector<string> inputFilesNew = TRestTools::GetFilesMatchingPattern(rootFileName);

TH1D* h = new TH1D(histoName, histoName, bins, startVal, endVal);

if (inputFilesNew.size() == 0) {
cout << "Files not found!" << endl;
RESTLog << "Files not found!" << RESTendl;
return -1;
}

Expand All @@ -38,9 +38,9 @@ Int_t REST_CreateHisto(string varName, string rootFileName, TString histoName, i

Int_t obsID = run->GetAnalysisTree()->GetObservableID(varName);
if (obsID == -1) {
cout << endl;
cout.setcolor(COLOR_BOLDRED);
cout << "No observable \"" << varName << "\" in file " << inputFilesNew[n] << endl;
RESTLog << RESTendl;
RESTLog.setcolor(COLOR_BOLDRED);
RESTLog << "No observable \"" << varName << "\" in file " << inputFilesNew[n] << RESTendl;
continue;
}
for (int i = 0; i < run->GetEntries(); i++) {
Expand All @@ -58,7 +58,7 @@ Int_t REST_CreateHisto(string varName, string rootFileName, TString histoName, i
h->Write(histoName);
f->Close();

cout << "Written histogram " << histoName << " into " << rootFileName << endl;
RESTLog << "Written histogram " << histoName << " into " << rootFileName << RESTendl;

return 0;
};
Expand Down
8 changes: 4 additions & 4 deletions macros/REST_DataSummary.C
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@ Int_t REST_DataSummary(TString pattern, TString startDate = "", TString endDate
}

if (runEndTimeStamp - runStartTimeStamp <= 0) {
warning << "Problem with start/end timestamps" << endl;
warning << "Skipping file : " << TRestTools::GetPureFileName(files[n]) << endl;
RESTWarning << "Problem with start/end timestamps" << RESTendl;
RESTWarning << "Skipping file : " << TRestTools::GetPureFileName(files[n]) << RESTendl;
continue;
}

for (int m = 0; m < metadataConditions.size(); m++) {
cout << metadataConditions[m] << endl;
if (!run->EvaluateMetadataMember(metadataConditions[m])) {
warning << "Condition : " << metadataConditions[m] << " not satisfied" << endl;
warning << "Skipping file : " << TRestTools::GetPureFileName(files[n]) << endl;
RESTWarning << "Condition : " << metadataConditions[m] << " not satisfied" << RESTendl;
RESTWarning << "Skipping file : " << TRestTools::GetPureFileName(files[n]) << RESTendl;
continue;
}
}
Expand Down
16 changes: 8 additions & 8 deletions macros/REST_Fit.C
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
//***
//*******************************************************************************************************
Int_t REST_Fit(string varName, string rootFileName, double startVal, double endVal, int nBins = 100) {
TRestStringOutput cout;
cout << "Variable name : " << varName << endl;
cout << "Fit range : ( " << startVal << " , " << endVal << " ) " << endl;
TRestStringOutput RESTLog;
RESTLog << "Variable name : " << varName << RESTendl;
RESTLog << "Fit range : ( " << startVal << " , " << endVal << " ) " << RESTendl;

if (startVal >= endVal) {
cout << "Start or End integration values not properly defined!!!" << endl;
RESTLog << "Start or End integration values not properly defined!!!" << RESTendl;
return -1;
}

Expand All @@ -33,7 +33,7 @@ Int_t REST_Fit(string varName, string rootFileName, double startVal, double endV
TRestRun* run = new TRestRun();

if (inputFilesNew.size() == 0) {
cout << "Files not found!" << endl;
RESTLog << "Files not found!" << RESTendl;
return -1;
}

Expand All @@ -44,9 +44,9 @@ Int_t REST_Fit(string varName, string rootFileName, double startVal, double endV

Int_t obsID = run->GetAnalysisTree()->GetObservableID(varName);
if (obsID == -1) {
cout << endl;
cout.setcolor(COLOR_BOLDRED);
cout << "No observable \"" << varName << "\" in file " << inputFilesNew[n] << endl;
RESTLog << RESTendl;
RESTLog.setcolor(COLOR_BOLDRED);
RESTLog << "No observable \"" << varName << "\" in file " << inputFilesNew[n] << RESTendl;
continue;
}
for (int i = 0; i < run->GetEntries(); i++) {
Expand Down
30 changes: 15 additions & 15 deletions macros/REST_Integrate.C
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@
//***
//*******************************************************************************************************
Int_t REST_Integrate(string varName, string rootFileName, double startVal, double endVal) {
TRestStringOutput cout;
cout << "Variable name : " << varName << endl;
cout << "Integration range : ( " << startVal << " , " << endVal << " ) " << endl;
TRestStringOutput RESTLog;
RESTLog << "Variable name : " << varName << RESTendl;
RESTLog << "Integration range : ( " << startVal << " , " << endVal << " ) " << RESTendl;

if (startVal >= endVal) {
cout << "Start or End integration values not properly defined!!!" << endl;
RESTLog << "Start or End integration values not properly defined!!!" << RESTendl;
return -1;
}

std::vector<string> inputFilesNew = TRestTools::GetFilesMatchingPattern(rootFileName);

if (inputFilesNew.size() == 0) {
cout << "Files not found!" << endl;
RESTLog << "Files not found!" << RESTendl;
return -1;
}

Expand All @@ -43,9 +43,9 @@ Int_t REST_Integrate(string varName, string rootFileName, double startVal, doubl

Int_t obsID = run->GetAnalysisTree()->GetObservableID(varName);
if (obsID == -1) {
cout << endl;
cout.setcolor(COLOR_BOLDRED);
cout << "No observable \"" << varName << "\" in file " << inputFilesNew[n] << endl;
RESTLog << RESTendl;
RESTLog.setcolor(COLOR_BOLDRED);
RESTLog << "No observable \"" << varName << "\" in file " << inputFilesNew[n] << RESTendl;
continue;
}
for (int i = 0; i < run->GetEntries(); i++) {
Expand All @@ -55,13 +55,13 @@ Int_t REST_Integrate(string varName, string rootFileName, double startVal, doubl
}
}

cout.setcolor(COLOR_BOLDBLUE);
cout.setborder("*");
cout << endl;
cout << "=" << endl;
cout << "Integral : " << integral << endl;
cout << "=" << endl;
cout << endl;
RESTLog.setcolor(COLOR_BOLDBLUE);
RESTLog.setborder("*");
RESTLog << RESTendl;
RESTLog << "=" << RESTendl;
RESTLog << "Integral : " << integral << RESTendl;
RESTLog << "=" << RESTendl;
RESTLog << RESTendl;

delete run;

Expand Down
36 changes: 18 additions & 18 deletions macros/REST_IntegrateSmearing.C
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
//***
//*******************************************************************************************************
Int_t REST_IntegrateSmearing(string varName, string rootFileName, double Middle) {
TRestStringOutput cout;
TRestStringOutput RESTLog;

std::vector<string> inputFilesNew = TRestTools::GetFilesMatchingPattern(rootFileName);

if (inputFilesNew.size() == 0) {
cout << "Files not found!" << endl;
RESTLog << "Files not found!" << RESTendl;
return -1;
}

Expand All @@ -41,12 +41,12 @@ Int_t REST_IntegrateSmearing(string varName, string rootFileName, double Middle)

Int_t obsID = run->GetAnalysisTree()->GetObservableID(varName);
if (obsID == -1) {
cout << endl;
cout.setcolor(COLOR_BOLDRED);
cout << "No observable \"" << varName << "\" in file " << inputFilesNew[n] << endl;
RESTLog << RESTendl;
RESTLog.setcolor(COLOR_BOLDRED);
RESTLog << "No observable \"" << varName << "\" in file " << inputFilesNew[n] << RESTendl;
continue;
}
cout << "Entries : " << run->GetEntries() << endl;
RESTLog << "Entries : " << run->GetEntries() << RESTendl;
TH1D* h = new TH1D("histo", "histo", 180, Qbb - 90, Qbb + 90);
Int_t peak = 0;
for (int i = 0; i < run->GetEntries(); i++) {
Expand Down Expand Up @@ -78,18 +78,18 @@ Int_t REST_IntegrateSmearing(string varName, string rootFileName, double Middle)
contribution_3 += gausFunc->Integral(mean - 2 * sigma_3, mean + 2 * sigma_3);
}

cout.setcolor(COLOR_BOLDBLUE);
cout.setborder("*");
cout << endl;
cout << "=" << endl;
cout << "Total events : " << run->GetEntries() << endl;
cout << " " << endl;
cout << "FWHM = 0.5% -> " << contribution_1 << endl;
cout << "FWHM = 1.% -> " << contribution_2 << endl;
cout << "FWHM = 3.% -> " << contribution_3 << endl;
cout << "peak : " << peak << endl;
cout << "=" << endl;
cout << endl;
RESTLog.setcolor(COLOR_BOLDBLUE);
RESTLog.setborder("*");
RESTLog << RESTendl;
RESTLog << "=" << RESTendl;
RESTLog << "Total events : " << run->GetEntries() << RESTendl;
RESTLog << " " << RESTendl;
RESTLog << "FWHM = 0.5% -> " << contribution_1 << RESTendl;
RESTLog << "FWHM = 1.% -> " << contribution_2 << RESTendl;
RESTLog << "FWHM = 3.% -> " << contribution_3 << RESTendl;
RESTLog << "peak : " << peak << RESTendl;
RESTLog << "=" << RESTendl;
RESTLog << RESTendl;

delete run;
}
Expand Down
6 changes: 3 additions & 3 deletions macros/REST_MakeMetadata.C
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
//*******************************************************************************************************
Int_t REST_MakeMetadata(TString name) {
if (name.First("TRest") != 0) {
ferr << "invalid process name! REST process name must be start with \"TRest\" " << endl;
RESTError << "invalid process name! REST process name must be start with \"TRest\" " << RESTendl;
return -1;
}

ofstream headerFile(name + ".h");
if (headerFile.fail()) {
ferr << "failed to create file!" << endl;
RESTError << "failed to create file!" << RESTendl;
return -1;
}

Expand Down Expand Up @@ -105,7 +105,7 @@ Int_t REST_MakeMetadata(TString name) {

ofstream sourceFile(name + ".cxx");
if (headerFile.fail()) {
ferr << "failed to create file!" << endl;
RESTError << "failed to create file!" << RESTendl;
return -1;
}

Expand Down
10 changes: 5 additions & 5 deletions macros/REST_MakeProcess.C
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ Int_t REST_MakeProcess(TString name, TString inputevent = "TRestEvent", TString
// --> generate a data-conversion process template form TRestDetectorHitsEvent to TRestTrackEvent

if (name.First("TRest") != 0 || name.Contains("Process") == false) {
ferr << "invalid process name! REST process name must be start with \"TRest\" and ends with "
"\"Process\"!"
<< endl;
RESTError << "invalid process name! REST process name must be start with \"TRest\" and ends with "
"\"Process\"!"
<< RESTendl;
return -1;
}

Expand Down Expand Up @@ -62,7 +62,7 @@ Int_t REST_MakeProcess(TString name, TString inputevent = "TRestEvent", TString

ofstream headerfile(name + ".h");
if (headerfile.fail()) {
ferr << "failed to create file!" << endl;
RESTError << "failed to create file!" << RESTendl;
return -1;
}

Expand Down Expand Up @@ -163,7 +163,7 @@ Int_t REST_MakeProcess(TString name, TString inputevent = "TRestEvent", TString

ofstream sourcefile(name + ".cxx");
if (headerfile.fail()) {
ferr << "failed to create file!" << endl;
RESTError << "failed to create file!" << RESTendl;
return -1;
}

Expand Down
6 changes: 3 additions & 3 deletions macros/REST_PrintDataBase.C
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ using namespace std;
//***
//*******************************************************************************************************
Int_t REST_DataBase(Int_t run = -1) {
TRestStringOutput fout;
TRestStringOutput RESTfout;
if (gDataBase == NULL) {
fout.setcolor(COLOR_BOLDRED);
fout << "gDataBase is NULL" << endl;
RESTfout.setcolor(COLOR_BOLDRED);
RESTfout << "gDataBase is NULL" << RESTendl;
} else {
if (run < 0) run = gDataBase->get_lastrun();
gDataBase->print(Form("select * from rest_runs where run_id=%i", run));
Expand Down
16 changes: 8 additions & 8 deletions macros/REST_PrintFileContents.C
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@
//***
//*******************************************************************************************************
Int_t REST_FileContents(TString fName) {
TRestStringOutput fout;
TRestStringOutput RESTfout;
TFile* fFile = new TFile(fName);
if (fFile == NULL) {
fout << "I could not open file : " << fName << endl;
RESTfout << "I could not open file : " << fName << RESTendl;
return 0;
}
TIter nextkey(fFile->GetListOfKeys());
TKey* key;
Int_t c = 0;
fout << "==========================================" << endl;
RESTfout << "==========================================" << RESTendl;
while ((key = (TKey*)nextkey()) != NULL) {
if (c > 0) fout << " ------------------------------------- " << endl;
if (c > 0) RESTfout << " ------------------------------------- " << RESTendl;

fout << "ClassName : " << key->GetClassName() << endl;
fout << "Name : " << key->GetName() << endl;
fout << "Title : " << key->GetTitle() << endl;
RESTfout << "ClassName : " << key->GetClassName() << RESTendl;
RESTfout << "Name : " << key->GetName() << RESTendl;
RESTfout << "Title : " << key->GetTitle() << RESTendl;

c++;
}
fout << "==========================================" << endl;
RESTfout << "==========================================" << RESTendl;

return 0;
}
Expand Down
Loading