Skip to content

Commit 9bfed7c

Browse files
authored
Merge pull request #357 from rest-for-physics/fix_processes_streamer
Fix processes streamer
2 parents c9bd40c + cde114e commit 9bfed7c

File tree

18 files changed

+100
-24
lines changed

18 files changed

+100
-24
lines changed

.github/workflows/validation.yml

+1
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ jobs:
323323
rm Signals_01928.root
324324
root -b -q ../ValidateTrees.C'("validation.root")'
325325
restRoot -b -q ValidateDetectorParams.C'("Hits_01928.root")'
326+
python3 validateStreamer.py
326327
- name: Upload Artifacts
327328
uses: actions/upload-artifact@v3
328329
with:

cmake/thisREST.cmake

+30
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,33 @@ export LD_LIBRARY_PATH=\$GARFIELD_HOME/lib:\$LD_LIBRARY_PATH
5050
set(Garfield_INCLUDE_ENV ":$ENV{GARFIELD_INSTALL}/include")
5151
endif ()
5252

53+
file (STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/source/framework/core/inc/TRestVersion.h" lines)
54+
55+
message( STATUS "########## Latest release info #############" )
56+
57+
string(FIND "${lines}" "REST_RELEASE " FOUND_RELEASE )
58+
string( SUBSTRING "${lines}" ${FOUND_RELEASE} 50 release)
59+
string( SUBSTRING "${release}" 14 30 release)
60+
string(FIND "${release}" "\"" FOUND_RELEASE )
61+
string( SUBSTRING "${release}" 0 ${FOUND_RELEASE} release)
62+
message (STATUS "Release version : ${release}" )
63+
64+
string(FIND "${lines}" "REST_RELEASE_NAME" FOUND_RELEASE_NAME )
65+
string( SUBSTRING "${lines}" ${FOUND_RELEASE_NAME} 50 releaseName)
66+
string( SUBSTRING "${releaseName}" 19 30 releaseName)
67+
string(FIND "${releaseName}" "\"" FOUND_RELEASE_NAME )
68+
string( SUBSTRING "${releaseName}" 0 ${FOUND_RELEASE_NAME} releaseName)
69+
message (STATUS "Release name : ${releaseName}" )
70+
71+
string(FIND "${lines}" "REST_RELEASE_DATE" FOUND_RELEASE_DATE )
72+
string( SUBSTRING "${lines}" ${FOUND_RELEASE_DATE} 50 releaseDate)
73+
string( SUBSTRING "${releaseDate}" 19 30 releaseDate)
74+
string(FIND "${releaseDate}" "\"" FOUND_RELEASE_DATE )
75+
string( SUBSTRING "${releaseDate}" 0 ${FOUND_RELEASE_DATE} releaseDate)
76+
message (STATUS "Release date : ${releaseDate}" )
77+
message( STATUS "########## Latest release info #############" )
78+
message( "" )
79+
5380
# install thisREST script, sh VERSION
5481
install(CODE
5582
"
@@ -259,6 +286,9 @@ echo \\\" \\\"
259286
echo \\\" Commit : \${GIT_COMMIT} (\${GIT_DATE}) \\\"
260287
echo \\\" Branch/Version : \${GIT_BRANCH}/\${GIT_TAG} \\\"
261288
echo \\\" Compilation date : ${date} \\\"
289+
echo \\\" \\\"
290+
echo \\\" Latest release: : v${release} - ${releaseName} - ${releaseDate} \\\"
291+
echo \\\" \\\"
262292
echo \\\" Official release : \${REST_OFFICIAL_RELEASE} \\\"
263293
echo \\\" Clean state : \${GIT_CLEANSTATE} \\\"
264294
echo \\\" \\\"

pipeline/trex/StreamerOutput.C

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Int_t StreamerOutput(std::string fname) {
2+
TFile* f = TFile::Open((TString)fname);
3+
f->ShowStreamerInfo();
4+
5+
f->Close();
6+
7+
return 0;
8+
}

pipeline/trex/validateStreamer.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import os, sys
2+
3+
os.system("restRoot -b -q StreamerOutput.C'(\"Hits_01928.root\")' | grep Process | grep TRest | grep version | wc -l > output.log 2>&1")
4+
5+
with open('output.log') as f:
6+
lines = f.readlines()
7+
8+
for line in lines:
9+
if( line.find("9") == 0):
10+
print ("The number of processes inside the event data chain is 9. Succeed!")
11+
sys.exit(0)
12+
else:
13+
print ("The number of processes inside the event data chain is NOT 6! Fail!")
14+
sys.exit(1)
15+
16+
sys.exit(0)

pull-submodules.py

+10
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def print_help():
4545
print ( " --exclude:lib1,lib2 will prevent lib1,lib2 from being pulled" )
4646
print ( " --onlylibs: It will pull only the REST library submodules" )
4747
print ( " --data: It will pull also data based repositories" )
48+
print ( " --only:restG4,geant4lib will pull only the selected repositories." )
4849
print ( " " )
4950

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

5657
exclude_elems = ["userguide", "data"]
58+
only_elems = []
5759

5860
for x in range(len(sys.argv) - 1):
5961
if sys.argv[x + 1] == "--data":
@@ -102,6 +104,10 @@ def print_help():
102104
elems = sys.argv[x + 1][10:].split(",")
103105
for y in elems:
104106
exclude_elems.append(y)
107+
if sys.argv[x + 1].find("--only:") >= 0:
108+
elems = sys.argv[x + 1][7:].split(",")
109+
for y in elems:
110+
only_elems.append(y)
105111

106112

107113

@@ -156,6 +162,10 @@ def main():
156162
exclude = True
157163
if onlylibs and fullpath.lower().find("libraries") == -1:
158164
exclude = True
165+
for only_element in only_elems:
166+
exclude = True
167+
if fullpath.find(only_element) > 0:
168+
exclude = False
159169

160170
if "url=" in line:
161171
url = line.replace("url=", '').strip()

scripts/generateVersionHeader.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
print("We will search for particle physicists, physicists, mathematicians or any other discipline in that order." )
2828
print("We will then use the birthdate to decide which physicist or scientist deserves the name of the release.")
2929
print("")
30+
print("You may use the following website: https://www.bornglorious.com/world/birthday/?pf=169470" )
31+
print("")
3032
releaseName = input("Please, enter the name of the candidate!: ")
3133

3234
print( "Release name : " + str(releaseName) )
@@ -144,7 +146,7 @@
144146
print('-----> git commit -m "Updated TRestVersion.h to v2.' + str(b)
145147
+ '.' + str(c) + '" ')
146148
print('\n')
147-
print('You should generate a new Git tag now!\n')
149+
print('Once your PR has been accepted and merged, you should generate a new Git tag at the master branch.\n')
148150
print('-----> git tag -a v' + str(a) + '.' + str(b) + '.' + str(c)
149151
+ ' -m "Update to version v' + str(a) + '.' + str(b) + '.'
150152
+ str(c) + '"\n')

source/framework/core/inc/TRestProcessRunner.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class TRestProcessRunner : public TRestMetadata {
3939
TFile* fOutputDataFile; //! the TFile pointer being used
4040
TString fOutputDataFileName; //! indicates the name of the first file created as output data file. The
4141
//! actual output file maybe changed if tree is too large
42-
TTree* fEventTree; //!
42+
TTree* fEventTree; //!
4343
TRestAnalysisTree* fAnalysisTree; //!
4444
ProcStatus fProcStatus; //!
4545
Int_t fNBranches; //!
@@ -99,7 +99,7 @@ class TRestProcessRunner : public TRestMetadata {
9999
void FillThreadEventFunc(TRestThread* t);
100100
void ConfigOutputFile();
101101
void MergeOutputFile();
102-
void WriteMetadata();
102+
void WriteProcessesMetadata();
103103

104104
// tools
105105
void ResetRunTimes();

source/framework/core/inc/TRestVersion.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
* #endif
1212
*
1313
*/
14-
#define REST_RELEASE "2.3.14"
15-
#define REST_RELEASE_DATE "Thu 15 Dec"
16-
#define REST_RELEASE_TIME "2022 10:01:56 AM CET"
17-
#define REST_RELEASE_NAME "Henri Becquerel"
18-
#define REST_GIT_COMMIT "81928e9f"
19-
#define REST_VERSION_CODE 131854
14+
#define REST_RELEASE "2.3.15"
15+
#define REST_RELEASE_DATE "Fri 30 Dec"
16+
#define REST_RELEASE_TIME "2022 08:49:05 AM CET"
17+
#define REST_RELEASE_NAME "David R. Nygren"
18+
#define REST_GIT_COMMIT "ed155a15"
19+
#define REST_VERSION_CODE 131855
2020
#define REST_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c))
2121
#define REST_SCHEMA_EVOLUTION "ON"
2222
#endif

source/framework/core/src/TRestProcessRunner.cxx

+15-6
Original file line numberDiff line numberDiff line change
@@ -882,11 +882,11 @@ void TRestProcessRunner::FillThreadEventFunc(TRestThread* t) {
882882
fRunInfo->SetNFilesSplit(fNFilesSplit);
883883
if (fOutputDataFile->GetName() != fOutputDataFileName) {
884884
auto Mainfile = std::unique_ptr<TFile>{TFile::Open(fOutputDataFileName, "update")};
885-
WriteMetadata();
885+
WriteProcessesMetadata();
886886
Mainfile->Write(0, TObject::kOverwrite);
887887
Mainfile->Close();
888888
} else {
889-
WriteMetadata();
889+
WriteProcessesMetadata();
890890
}
891891

892892
TFile* newfile = new TFile(fOutputDataFileName + "." + ToString(fNFilesSplit), "recreate");
@@ -955,15 +955,23 @@ void TRestProcessRunner::ConfigOutputFile() {
955955
fOutputDataFile = new TFile(fOutputDataFileName, "update");
956956
}
957957
// write metadata
958-
WriteMetadata();
958+
WriteProcessesMetadata();
959959
}
960960

961-
void TRestProcessRunner::WriteMetadata() {
962-
fOutputDataFile->cd();
961+
void TRestProcessRunner::WriteProcessesMetadata() {
962+
if (fRunInfo->GetInputFile() == nullptr) {
963+
if (!fRunInfo->GetOutputFile()) {
964+
// We are not ready yet to write
965+
return;
966+
}
967+
fRunInfo->cd();
968+
} else
969+
fOutputDataFile->cd();
970+
963971
fRunInfo->SetNFilesSplit(fNFilesSplit);
964972
fRunInfo->Write(nullptr, TObject::kOverwrite);
965973
this->Write(nullptr, TObject::kWriteDelete);
966-
974+
967975
if (fRunInfo->GetFileProcess() != nullptr) {
968976
// std::cout << "Run. Process-0. " << fRunInfo->GetFileProcess()->GetName() << std::endl;
969977
fRunInfo->GetFileProcess()->Write(nullptr, kOverwrite);
@@ -999,6 +1007,7 @@ void TRestProcessRunner::MergeOutputFile() {
9991007
fOutputDataFile->Write(nullptr, TObject::kOverwrite);
10001008
fOutputDataFile->Close();
10011009
fRunInfo->MergeToOutputFile(files_to_merge, fOutputDataFile->GetName());
1010+
if (fRunInfo->GetInputFile() == nullptr) WriteProcessesMetadata();
10021011
}
10031012

10041013
// tools

source/libraries/wimp

0 commit comments

Comments
 (0)