Skip to content

Commit

Permalink
Merge pull request #357 from rest-for-physics/fix_processes_streamer
Browse files Browse the repository at this point in the history
Fix processes streamer
  • Loading branch information
jgalan committed Dec 30, 2022
2 parents c9bd40c + cde114e commit 9bfed7c
Show file tree
Hide file tree
Showing 18 changed files with 100 additions and 24 deletions.
1 change: 1 addition & 0 deletions .github/workflows/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ jobs:
rm Signals_01928.root
root -b -q ../ValidateTrees.C'("validation.root")'
restRoot -b -q ValidateDetectorParams.C'("Hits_01928.root")'
python3 validateStreamer.py
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
Expand Down
30 changes: 30 additions & 0 deletions cmake/thisREST.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,33 @@ export LD_LIBRARY_PATH=\$GARFIELD_HOME/lib:\$LD_LIBRARY_PATH
set(Garfield_INCLUDE_ENV ":$ENV{GARFIELD_INSTALL}/include")
endif ()

file (STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/source/framework/core/inc/TRestVersion.h" lines)

message( STATUS "########## Latest release info #############" )

string(FIND "${lines}" "REST_RELEASE " FOUND_RELEASE )
string( SUBSTRING "${lines}" ${FOUND_RELEASE} 50 release)
string( SUBSTRING "${release}" 14 30 release)
string(FIND "${release}" "\"" FOUND_RELEASE )
string( SUBSTRING "${release}" 0 ${FOUND_RELEASE} release)
message (STATUS "Release version : ${release}" )

string(FIND "${lines}" "REST_RELEASE_NAME" FOUND_RELEASE_NAME )
string( SUBSTRING "${lines}" ${FOUND_RELEASE_NAME} 50 releaseName)
string( SUBSTRING "${releaseName}" 19 30 releaseName)
string(FIND "${releaseName}" "\"" FOUND_RELEASE_NAME )
string( SUBSTRING "${releaseName}" 0 ${FOUND_RELEASE_NAME} releaseName)
message (STATUS "Release name : ${releaseName}" )

string(FIND "${lines}" "REST_RELEASE_DATE" FOUND_RELEASE_DATE )
string( SUBSTRING "${lines}" ${FOUND_RELEASE_DATE} 50 releaseDate)
string( SUBSTRING "${releaseDate}" 19 30 releaseDate)
string(FIND "${releaseDate}" "\"" FOUND_RELEASE_DATE )
string( SUBSTRING "${releaseDate}" 0 ${FOUND_RELEASE_DATE} releaseDate)
message (STATUS "Release date : ${releaseDate}" )
message( STATUS "########## Latest release info #############" )
message( "" )

# install thisREST script, sh VERSION
install(CODE
"
Expand Down Expand Up @@ -259,6 +286,9 @@ echo \\\" \\\"
echo \\\" Commit : \${GIT_COMMIT} (\${GIT_DATE}) \\\"
echo \\\" Branch/Version : \${GIT_BRANCH}/\${GIT_TAG} \\\"
echo \\\" Compilation date : ${date} \\\"
echo \\\" \\\"
echo \\\" Latest release: : v${release} - ${releaseName} - ${releaseDate} \\\"
echo \\\" \\\"
echo \\\" Official release : \${REST_OFFICIAL_RELEASE} \\\"
echo \\\" Clean state : \${GIT_CLEANSTATE} \\\"
echo \\\" \\\"
Expand Down
8 changes: 8 additions & 0 deletions pipeline/trex/StreamerOutput.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Int_t StreamerOutput(std::string fname) {
TFile* f = TFile::Open((TString)fname);
f->ShowStreamerInfo();

f->Close();

return 0;
}
16 changes: 16 additions & 0 deletions pipeline/trex/validateStreamer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import os, sys

os.system("restRoot -b -q StreamerOutput.C'(\"Hits_01928.root\")' | grep Process | grep TRest | grep version | wc -l > output.log 2>&1")

with open('output.log') as f:
lines = f.readlines()

for line in lines:
if( line.find("9") == 0):
print ("The number of processes inside the event data chain is 9. Succeed!")
sys.exit(0)
else:
print ("The number of processes inside the event data chain is NOT 6! Fail!")
sys.exit(1)

sys.exit(0)
10 changes: 10 additions & 0 deletions pull-submodules.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def print_help():
print ( " --exclude:lib1,lib2 will prevent lib1,lib2 from being pulled" )
print ( " --onlylibs: It will pull only the REST library submodules" )
print ( " --data: It will pull also data based repositories" )
print ( " --only:restG4,geant4lib will pull only the selected repositories." )
print ( " " )

if( len(sys.argv ) <= 1 ):
Expand All @@ -54,6 +55,7 @@ def print_help():
sys.exit(1)

exclude_elems = ["userguide", "data"]
only_elems = []

for x in range(len(sys.argv) - 1):
if sys.argv[x + 1] == "--data":
Expand Down Expand Up @@ -102,6 +104,10 @@ def print_help():
elems = sys.argv[x + 1][10:].split(",")
for y in elems:
exclude_elems.append(y)
if sys.argv[x + 1].find("--only:") >= 0:
elems = sys.argv[x + 1][7:].split(",")
for y in elems:
only_elems.append(y)



Expand Down Expand Up @@ -156,6 +162,10 @@ def main():
exclude = True
if onlylibs and fullpath.lower().find("libraries") == -1:
exclude = True
for only_element in only_elems:
exclude = True
if fullpath.find(only_element) > 0:
exclude = False

if "url=" in line:
url = line.replace("url=", '').strip()
Expand Down
4 changes: 3 additions & 1 deletion scripts/generateVersionHeader.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
print("We will search for particle physicists, physicists, mathematicians or any other discipline in that order." )
print("We will then use the birthdate to decide which physicist or scientist deserves the name of the release.")
print("")
print("You may use the following website: https://www.bornglorious.com/world/birthday/?pf=169470" )
print("")
releaseName = input("Please, enter the name of the candidate!: ")

print( "Release name : " + str(releaseName) )
Expand Down Expand Up @@ -144,7 +146,7 @@
print('-----> git commit -m "Updated TRestVersion.h to v2.' + str(b)
+ '.' + str(c) + '" ')
print('\n')
print('You should generate a new Git tag now!\n')
print('Once your PR has been accepted and merged, you should generate a new Git tag at the master branch.\n')
print('-----> git tag -a v' + str(a) + '.' + str(b) + '.' + str(c)
+ ' -m "Update to version v' + str(a) + '.' + str(b) + '.'
+ str(c) + '"\n')
Expand Down
4 changes: 2 additions & 2 deletions source/framework/core/inc/TRestProcessRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class TRestProcessRunner : public TRestMetadata {
TFile* fOutputDataFile; //! the TFile pointer being used
TString fOutputDataFileName; //! indicates the name of the first file created as output data file. The
//! actual output file maybe changed if tree is too large
TTree* fEventTree; //!
TTree* fEventTree; //!
TRestAnalysisTree* fAnalysisTree; //!
ProcStatus fProcStatus; //!
Int_t fNBranches; //!
Expand Down Expand Up @@ -99,7 +99,7 @@ class TRestProcessRunner : public TRestMetadata {
void FillThreadEventFunc(TRestThread* t);
void ConfigOutputFile();
void MergeOutputFile();
void WriteMetadata();
void WriteProcessesMetadata();

// tools
void ResetRunTimes();
Expand Down
12 changes: 6 additions & 6 deletions source/framework/core/inc/TRestVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
* #endif
*
*/
#define REST_RELEASE "2.3.14"
#define REST_RELEASE_DATE "Thu 15 Dec"
#define REST_RELEASE_TIME "2022 10:01:56 AM CET"
#define REST_RELEASE_NAME "Henri Becquerel"
#define REST_GIT_COMMIT "81928e9f"
#define REST_VERSION_CODE 131854
#define REST_RELEASE "2.3.15"
#define REST_RELEASE_DATE "Fri 30 Dec"
#define REST_RELEASE_TIME "2022 08:49:05 AM CET"
#define REST_RELEASE_NAME "David R. Nygren"
#define REST_GIT_COMMIT "ed155a15"
#define REST_VERSION_CODE 131855
#define REST_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c))
#define REST_SCHEMA_EVOLUTION "ON"
#endif
21 changes: 15 additions & 6 deletions source/framework/core/src/TRestProcessRunner.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -882,11 +882,11 @@ void TRestProcessRunner::FillThreadEventFunc(TRestThread* t) {
fRunInfo->SetNFilesSplit(fNFilesSplit);
if (fOutputDataFile->GetName() != fOutputDataFileName) {
auto Mainfile = std::unique_ptr<TFile>{TFile::Open(fOutputDataFileName, "update")};
WriteMetadata();
WriteProcessesMetadata();
Mainfile->Write(0, TObject::kOverwrite);
Mainfile->Close();
} else {
WriteMetadata();
WriteProcessesMetadata();
}

TFile* newfile = new TFile(fOutputDataFileName + "." + ToString(fNFilesSplit), "recreate");
Expand Down Expand Up @@ -955,15 +955,23 @@ void TRestProcessRunner::ConfigOutputFile() {
fOutputDataFile = new TFile(fOutputDataFileName, "update");
}
// write metadata
WriteMetadata();
WriteProcessesMetadata();
}

void TRestProcessRunner::WriteMetadata() {
fOutputDataFile->cd();
void TRestProcessRunner::WriteProcessesMetadata() {
if (fRunInfo->GetInputFile() == nullptr) {
if (!fRunInfo->GetOutputFile()) {
// We are not ready yet to write
return;
}
fRunInfo->cd();
} else
fOutputDataFile->cd();

fRunInfo->SetNFilesSplit(fNFilesSplit);
fRunInfo->Write(nullptr, TObject::kOverwrite);
this->Write(nullptr, TObject::kWriteDelete);

if (fRunInfo->GetFileProcess() != nullptr) {
// std::cout << "Run. Process-0. " << fRunInfo->GetFileProcess()->GetName() << std::endl;
fRunInfo->GetFileProcess()->Write(nullptr, kOverwrite);
Expand Down Expand Up @@ -999,6 +1007,7 @@ void TRestProcessRunner::MergeOutputFile() {
fOutputDataFile->Write(nullptr, TObject::kOverwrite);
fOutputDataFile->Close();
fRunInfo->MergeToOutputFile(files_to_merge, fOutputDataFile->GetName());
if (fRunInfo->GetInputFile() == nullptr) WriteProcessesMetadata();
}

// tools
Expand Down
2 changes: 1 addition & 1 deletion source/libraries/legacy
2 changes: 1 addition & 1 deletion source/libraries/wimp

0 comments on commit 9bfed7c

Please sign in to comment.