Skip to content

Commit

Permalink
Merge pull request #350 from rest-for-physics/jgalan_cmake_fix
Browse files Browse the repository at this point in the history
Cmake fixes to clean up warnings during compilation
  • Loading branch information
jgalan authored Dec 23, 2022
2 parents 9752855 + ad1c560 commit 0e09164
Show file tree
Hide file tree
Showing 46 changed files with 1,441 additions and 1,523 deletions.
13 changes: 11 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,20 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
endif ()

if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-fsanitize=address")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
else ()
SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-lstdc++fs")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lstdc++fs")
endif (CMAKE_SYSTEM_NAME MATCHES "Darwin")

if ( CMAKE_BUILD_TYPE MATCHES "Release" )
message( STATUS "Enabling warnings as errors" )
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wno-cast-function-type -Wno-unused-function -Wno-unknown-pragmas -Wno-delete-non-virtual-dtor")
endif ( CMAKE_BUILD_TYPE MATCHES "Release" )

if ( CMAKE_BUILD_TYPE MATCHES "Debug" )
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif ( CMAKE_BUILD_TYPE MATCHES "Debug" )

# https://github.com/rest-for-physics/framework/issues/162 & https://github.com/rest-for-physics/framework/issues/236
if (${CMAKE_VERSION} VERSION_LESS "3.23")
cmake_policy(SET CMP0082 OLD)
Expand Down
18 changes: 15 additions & 3 deletions cmake/MacroRootDict.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -236,22 +236,34 @@ MACRO(COMPILEDIR libname)
foreach (exclude ${excludes})
if ("${exclude}" STREQUAL "${class}")
set(SKIP "TRUE")
# message( STATUS "Skipping ${class}" )
# message( STATUS "Skipping ${class}" )
endif ()
endforeach (exclude)
endif ()

#### We will remove those classes that do not inherit from TObject from dictionary generation
set(NOTDICT "FALSE")
#### Probably all those classes should be on the same directory (framework/tools)
set( nodicts "TRestReflector;TRestSystemOfUnits;TRestStringHelper;TRestPhysics;TRestDataBase;TRestTools;TRestThread" )
foreach (nodict ${nodicts})
if ("${nodict}" STREQUAL "${class}")
set(NOTDICT "TRUE")
message( STATUS "Skipping dictionary generation for ${class}" )
endif ()
endforeach (nodict)
######################################

if (${SKIP} STREQUAL "FALSE")
set(ROOT_DICT_INCLUDE_DIRS ${local_include_dirs} ${external_include_dirs})
file(GLOB_RECURSE header ${class}.h)
if (NOT header)
message(WARNING "header file: " ${class}.h " does not exist for source file: " ${file} ". If you really want to build it, add it to \"addon_src\" variable before calling COMPILEDIR()")
else ()
set(ROOT_DICT_INPUT_HEADERS ${header} ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h)
if (${SCHEMA_EVOLUTION} MATCHES "ON")
if (${SCHEMA_EVOLUTION} MATCHES "ON" AND ${NOTDICT} STREQUAL "FALSE" )
GEN_ROOT_DICT_LINKDEF_HEADER(${class} ${header})
GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h)
else ()
elseif( ${NOTDICT} STREQUAL "FALSE")
GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx)
endif ()

Expand Down
2 changes: 1 addition & 1 deletion cmake/thisREST.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ foreach (mac ${rest_macros})
install(CODE
"
file( APPEND \${CMAKE_INSTALL_PREFIX}/thisREST.csh
alias ${mac} \\\"restManager ${m}\\\"
\"alias ${mac} \\\"restManager ${m}\\\"
\"
)
"
Expand Down
11 changes: 6 additions & 5 deletions source/bin/restManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ int fork_n_execute(string command) {

if (pid == 0) {
/* This is the child process */
system(command.c_str()); // execute the command
int z = system(command.c_str()); // execute the command
if (z != 0) printf("Problem executing command : %s", command.c_str());
// we call exit() when system() returns to complete child process
exit(EXIT_SUCCESS);

} else if (pid < 0) {
/* The fork failed */
printf("Failed to fork(): %s ", command.c_str());
Expand Down Expand Up @@ -126,7 +128,7 @@ int main(int argc, char* argv[]) {
argVApp[1] = batch;
{
// handle special arguments like "--batch"
for (int i = 1; i < args.size(); i++) {
for (unsigned int i = 1; i < args.size(); i++) {
if (args[i] == "--batch") {
RESTcout << "you are in batch mode, all graphical displays off" << RESTendl;
REST_Display_CompatibilityMode = true;
Expand Down Expand Up @@ -160,7 +162,7 @@ int main(int argc, char* argv[]) {
// read arguments
if (args.size() >= 2) {
if (args[1][0] == '-') { // usage1
for (int i = 1; i < args.size(); i++) {
for (unsigned int i = 1; i < args.size(); i++) {
char* c = &args[i][0];
if (*c == '-') {
c++;
Expand Down Expand Up @@ -215,7 +217,6 @@ int main(int argc, char* argv[]) {
RESTcout << "Launching TRestManager..." << RESTendl;
RESTcout << RESTendl;

int pid = 0;
if (doFork && input_files.size() > maxForksAllowed) {
RESTError << "Fork list is larger than " << maxForksAllowed
<< " files. Please, use a glob pattern producing a shorter list" << RESTendl;
Expand Down Expand Up @@ -252,7 +253,7 @@ int main(int argc, char* argv[]) {
} else // usage2
{
vector<string> argumentlist;
for (int i = 2; i < args.size(); i++) {
for (unsigned int i = 2; i < args.size(); i++) {
argumentlist.push_back(args[i]);
}
string type = (args[1]);
Expand Down
2 changes: 1 addition & 1 deletion source/bin/restRoot.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ int main(int argc, char* argv[]) {
map<string, int> metanames;
for (int n = 0; n < numberOfMetadataStructures; n++) {
string metaName = runTmp->GetMetadataStructureNames()[n];
if (metaName.find("Historic") != -1) {
if (metaName.find("Historic") != string::npos) {
continue;
}

Expand Down
13 changes: 5 additions & 8 deletions source/framework/analysis/inc/TRestDataQualityRules.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,28 +69,25 @@ class TRestDataQualityRules : public TObject {

std::vector<Int_t> GetBits() { return fBits; }

TString GetType(Int_t n) {
TString GetType(unsigned int n) {
if (fTypes.size() <= n)
return "";
else
return fTypes[n];
}

TString GetValue(Int_t n) {
TString GetValue(unsigned int n) {
if (fValues.size() <= n)
return "";
else
return fValues[n];
}

TVector2 GetRange(Int_t n) {
if (fRanges.size() <= n)
return TVector2(0, 0);
else
return fRanges[n];
TVector2 GetRange(unsigned int n) {
return (n < fRanges.size()) ? fRanges[n] : TVector2(0,0);
}

Int_t GetBit(Int_t n) {
Int_t GetBit(unsigned int n) {
if (fBits.size() <= n)
return -1;
else
Expand Down
4 changes: 2 additions & 2 deletions source/framework/analysis/src/TRestDataQualityProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ TRestEvent* TRestDataQualityProcess::ProcessEvent(TRestEvent* inputEvent) {
///
void TRestDataQualityProcess::EndProcess() {
/// We loop to each quality number definition
for (int n = 0; n < fQualityNumber.size(); n++) {
for (unsigned int n = 0; n < fQualityNumber.size(); n++) {
/// We loop to each rule from the quality definition
for (int r = 0; r < fRules[n].GetNumberOfRules(); r++) {
// We implement metadata-based quality numbers
Expand Down Expand Up @@ -233,7 +233,7 @@ void TRestDataQualityProcess::InitFromConfigFile() {
void TRestDataQualityProcess::PrintMetadata() {
BeginPrintProcess();

for (int n = 0; n < fQualityNumber.size(); n++) {
for (unsigned int n = 0; n < fQualityNumber.size(); n++) {
RESTMetadata << " " << RESTendl;
RESTMetadata << "xxxxxxxxxxxxxxxxxxxxxx" << RESTendl;
RESTMetadata << " tag : " << fQualityTag[n] << ". Quality number : " << fQualityNumber[n] << RESTendl;
Expand Down
8 changes: 3 additions & 5 deletions source/framework/analysis/src/TRestEventSelectionProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void TRestEventSelectionProcess::Initialize() {
///
///
void TRestEventSelectionProcess::InitProcess() {
if (fFileWithIDs.substr(fFileWithIDs.length() - 4) == ".txt") {
if (TRestTools::GetFileNameExtension(fFileWithIDs) == "txt") {
string line;
ifstream File(fFileWithIDs);

Expand All @@ -111,9 +111,7 @@ void TRestEventSelectionProcess::InitProcess() {
}
File.close();
}
}

else if (fFileWithIDs.substr(fFileWithIDs.length() - 4) == "root") {
} else if (TRestTools::GetFileNameExtension(fFileWithIDs) == "root") {
TRestRun* run = new TRestRun(fFileWithIDs);
fList = run->GetEventIdsWithConditions(fConditions);
delete run;
Expand All @@ -126,7 +124,7 @@ void TRestEventSelectionProcess::InitProcess() {
TRestEvent* TRestEventSelectionProcess::ProcessEvent(TRestEvent* inputEvent) {
fEvent = inputEvent;

for (int i = 0; i < fList.size(); i++) {
for (unsigned int i = 0; i < fList.size(); i++) {
if (fList[i] == fEvent->GetID()) {
return fEvent;
}
Expand Down
6 changes: 3 additions & 3 deletions source/framework/analysis/src/TRestMySQLToAnalysisProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ void TRestMySQLToAnalysisProcess::PrintMetadata() {

RESTMetadata << "List of variables added to the analysis tree" << RESTendl;
RESTMetadata << " ------------------------------------------ " << RESTendl;
for (int n = 0; n < fAnaTreeVariables.size(); n++) {
for (unsigned int n = 0; n < fAnaTreeVariables.size(); n++) {
RESTMetadata << " + SQL field : " << fSQLVariables[n] << RESTendl;
RESTMetadata << " - Tree name : " << fAnaTreeVariables[n] << RESTendl;
RESTMetadata << " - Min value : " << fMinValues[n] << RESTendl;
Expand Down Expand Up @@ -408,7 +408,7 @@ void TRestMySQLToAnalysisProcess::FillDBArrays() {
///
string TRestMySQLToAnalysisProcess::BuildQueryString() {
string sqlQuery = "SELECT timestamp";
for (int n = 0; n < fSQLVariables.size(); n++) {
for (unsigned int n = 0; n < fSQLVariables.size(); n++) {
sqlQuery += ",";
sqlQuery += fSQLVariables[n];
}
Expand All @@ -431,7 +431,7 @@ Double_t TRestMySQLToAnalysisProcess::GetDBValueAtTimestamp(Int_t index, Double_
Int_t bin = (Int_t)((timestamp - fStartTimestamp) / fSampling);

if (bin < 0) return fDBdata.front()[index];
if (bin + 1 >= fDBdata.size()) return fDBdata.back()[index];
if ((unsigned int)(bin + 1) >= fDBdata.size()) return fDBdata.back()[index];

double y2 = fDBdata[bin + 1][index];
double y1 = fDBdata[bin][index];
Expand Down
10 changes: 5 additions & 5 deletions source/framework/analysis/src/TRestRealTimeDrawingProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,11 @@ void TRestRealTimeDrawingProcess::EndProcess() {

void TRestRealTimeDrawingProcess::DrawOnce() {
Long64_t totalentries = GetFullAnalysisTree()->GetEntries();
for (int i = 0; i < fPlots.size(); i++) {
for (unsigned int i = 0; i < fPlots.size(); i++) {
fPlots[i]->SetTreeEntryRange(totalentries - fLastDrawnEntry, fLastDrawnEntry);
fPlots[i]->PlotCombinedCanvas();
}
for (int i = 0; i < fProcessesToDraw.size(); i++) {
for (unsigned int i = 0; i < fProcessesToDraw.size(); i++) {
GetFriendLive(fProcessesToDraw[i])->Draw();
}
}
Expand All @@ -254,9 +254,9 @@ void TRestRealTimeDrawingProcess::DrawWithNotification() {
int _runNumber = run->GetRunNumber();
delete run;
if (_runNumber == runNumber) {
for (int i = 0; i < fPlots.size(); i++) {
fPlots[i]->SetFile(message);
fPlots[i]->PlotCombinedCanvas();
for (auto& plot: fPlots) {
plot->SetFile(message);
plot->PlotCombinedCanvas();
}
} else {
// if the runnumber does not match, we put this message back to pool
Expand Down
2 changes: 1 addition & 1 deletion source/framework/core/inc/TRestRun.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class TRestRun : public TRestMetadata {
inline TString GetExperimentName() const { return fExperimentName; }

inline std::vector<TString> GetInputFileNames() const { return fInputFileNames; }
inline std::string GetInputFileName(int i) const {
inline std::string GetInputFileName(unsigned int i) const {
return i < fInputFileNames.size() ? (std::string)fInputFileNames[i] : "";
}
inline std::string GetInputFileNamePattern() const { return fInputFileName.Data(); }
Expand Down
2 changes: 1 addition & 1 deletion source/framework/core/inc/TRestTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TRestTask : public TRestMetadata {
protected:
TRestTask(TString TaskString, REST_TASKMODE mode = TASK_MACRO);

int fNRequiredArgument;
unsigned int fNRequiredArgument;
REST_TASKMODE fMode;
std::string fInvokeObject = "";
std::string fInvokeMethod = "";
Expand Down
2 changes: 0 additions & 2 deletions source/framework/core/inc/TRestThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ class TRestThread {
// Constructor & Destructor
TRestThread() { Initialize(); }
~TRestThread(){};

ClassDef(TRestThread, 1);
};

#endif
18 changes: 7 additions & 11 deletions source/framework/core/src/TRestAnalysisPlot.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ TRestAnalysisPlot::~TRestAnalysisPlot() {
}

void TRestAnalysisPlot::InitFromConfigFile() {
size_t position = 0;
if (fHostmgr->GetRunInfo() != nullptr) {
fRun = fHostmgr->GetRunInfo();
}
Expand Down Expand Up @@ -87,7 +86,6 @@ void TRestAnalysisPlot::InitFromConfigFile() {

#pragma region ReadLabels
RESTDebug << "TRestAnalysisPlot: Reading canvas settings" << RESTendl;
position = 0;
TiXmlElement* formatDefinition = GetElement("labels");
if (formatDefinition != nullptr) {
if (GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Debug) {
Expand Down Expand Up @@ -128,7 +126,6 @@ void TRestAnalysisPlot::InitFromConfigFile() {
#pragma endregion

#pragma region ReadLegend
position = 0;
TiXmlElement* legendDefinition = GetElement("legendPosition");
if (legendDefinition != nullptr) {
if (GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Debug) {
Expand Down Expand Up @@ -159,7 +156,6 @@ void TRestAnalysisPlot::InitFromConfigFile() {
#pragma endregion

#pragma region ReadCanvas
position = 0;
TiXmlElement* canvasdef = fElement->FirstChildElement("canvas");
if (canvasdef == nullptr) {
canvasdef = fElement;
Expand Down Expand Up @@ -336,9 +332,9 @@ void TRestAnalysisPlot::InitFromConfigFile() {
}
}

for (int n = 0; n < fPanels.size(); n++) {
for (unsigned int n = 0; n < fPanels.size(); n++) {
RESTExtreme << "Panel " << n << " with font size : " << fPanels[n].font_size << RESTendl;
for (int m = 0; m < fPanels[n].posX.size(); m++) {
for (unsigned int m = 0; m < fPanels[n].posX.size(); m++) {
RESTExtreme << "Label : " << fPanels[n].label[m] << RESTendl;
RESTExtreme << "Pos X : " << fPanels[n].posX[m] << RESTendl;
RESTExtreme << "Pos Y : " << fPanels[n].posY[m] << RESTendl;
Expand All @@ -353,7 +349,7 @@ TRestAnalysisPlot::HistoInfoSet TRestAnalysisPlot::SetupHistogramFromConfigFile(
hist.name = RemoveWhiteSpaces(GetParameter("name", histele, plot.name));
hist.drawOption = GetParameter("option", histele, "colz");

for (int n = 0; n < fPlotNamesCheck.size(); n++)
for (unsigned int n = 0; n < fPlotNamesCheck.size(); n++)
if (hist.name == fPlotNamesCheck[n]) {
RESTError
<< "Repeated plot/histo names were found! Please, use different names for different plots!"
Expand Down Expand Up @@ -401,7 +397,7 @@ TRestAnalysisPlot::HistoInfoSet TRestAnalysisPlot::SetupHistogramFromConfigFile(

// 2. construct plot name for the hist
string rangestr = "";
for (int i = 0; i < bins.size(); i++) {
for (unsigned int i = 0; i < bins.size(); i++) {
string binsStr = ToString(bins[i]);
if (bins[i] == -1) binsStr = " ";

Expand Down Expand Up @@ -590,7 +586,7 @@ TRestRun* TRestAnalysisPlot::GetRunInfo(TString fileName) {
}

bool TRestAnalysisPlot::IsDynamicRange(TString rangeString) {
return (string(rangeString)).find(", ") != -1;
return (string(rangeString)).find(", ") != string::npos;
}

Int_t TRestAnalysisPlot::GetColorIDFromString(string in) {
Expand Down Expand Up @@ -668,7 +664,7 @@ void TRestAnalysisPlot::PlotCombinedCanvas() {
runLength /= 3600.;

for (unsigned int n = 0; n < fPanels.size(); n++) {
TPad* targetPad = (TPad*)fCombinedCanvas->cd(n + 1);
fCombinedCanvas->cd(n + 1);
for (unsigned int m = 0; m < fPanels[n].posX.size(); m++) {
string label = fPanels[n].label[m];

Expand Down Expand Up @@ -885,7 +881,7 @@ void TRestAnalysisPlot::PlotCombinedCanvas() {
// draw to the pad
targetPad = (TPad*)fCombinedCanvas->cd(n + 1 + fPanels.size());
Double_t maxValue_Pad = 0;
int maxID = 0;
unsigned int maxID = 0;
for (unsigned int i = 0; i < plot.histos.size(); i++) {
// need to draw the max histogram first, in order to prevent peak hidden problem
if (plot.histos[i].ptr == nullptr) continue;
Expand Down
Loading

0 comments on commit 0e09164

Please sign in to comment.