Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
IPNL_GAMMA
gammaware
Commits
6ef7e04f
Commit
6ef7e04f
authored
Oct 08, 2021
by
Jérémie Dudouet
Browse files
Adapt BasicAFP to be able to take conf files with a list of input files
parent
8b9082ad
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
29 deletions
+55
-29
src/adf/BasicAFP.cpp
src/adf/BasicAFP.cpp
+53
-29
src/adf/BasicAFP.h
src/adf/BasicAFP.h
+2
-0
No files found.
src/adf/BasicAFP.cpp
View file @
6ef7e04f
...
...
@@ -67,17 +67,24 @@ Bool_t BasicAFP::NewFile()
fCurrentFile
=
0x0
;
std
::
cout
<<
" -BasicAFP: the input file has just been closed "
<<
fCurrentFileName
<<
std
::
endl
;
}
// open the first file to be ready to be run
std
::
string
tmp
=
fPath
;
if
(
tmp
.
size
()
>
0
&&
!
(
tmp
.
at
(
tmp
.
size
()
-
1
)
==
'/'
)
)
tmp
+=
'/'
;
std
::
ostringstream
filename
;
filename
<<
tmp
<<
fBaseForName
<<
std
::
setfill
(
'0'
)
<<
std
::
setw
(
4
)
<<
fCurrentFileNumber
++
<<
std
::
setfill
(
' '
)
<<
".adf"
;
fCurrentFileName
=
filename
.
str
();
if
(
fListOfIndividualFiles
.
size
())
{
if
(
fCurrentFileNumber
<
fListOfIndividualFiles
.
size
())
fCurrentFileName
=
fListOfIndividualFiles
.
at
(
fCurrentFileNumber
);
else
fCurrentFileName
.
clear
();
fCurrentFileNumber
++
;
}
else
{
// open the first file to be ready to be run
std
::
string
tmp
=
fPath
;
if
(
tmp
.
size
()
>
0
&&
!
(
tmp
.
at
(
tmp
.
size
()
-
1
)
==
'/'
)
)
tmp
+=
'/'
;
std
::
ostringstream
filename
;
filename
<<
tmp
<<
fBaseForName
<<
std
::
setfill
(
'0'
)
<<
std
::
setw
(
4
)
<<
fCurrentFileNumber
++
<<
std
::
setfill
(
' '
)
<<
".adf"
;
fCurrentFileName
=
filename
.
str
();
}
fCurrentFile
=
::
fopen
(
fCurrentFileName
.
c_str
(),
"rb"
);
if
(
fCurrentFile
!=
0x0
)
{
...
...
@@ -92,8 +99,8 @@ Bool_t BasicAFP::NewFile()
fCurrentName
=
fCurrentFileName
.
substr
(
lpt
+
1
,
len
-
lpt
-
1
);
ok
=
true
;
}
else
{
Log
<<
"Could not open input file "
<<
fCurrentFileName
<<
nline
;
else
{
if
(
fCurrentFileName
.
length
())
Log
<<
"Could not open input file "
<<
fCurrentFileName
<<
nline
;
GetFrameIO
().
SetStatus
(
BaseFrameIO
::
kFinished
);
ok
=
false
;
}
...
...
@@ -176,23 +183,40 @@ void BasicAFP::process_initialise (UInt_t *error_code)
*
error_code
=
0u
;
Log
.
ClearMessage
();
Log
.
SetProcessMethod
(
"process_initialise"
);
// read an input file to get the base filename and the path
std
::
string
conffile
=
GetConfPath
()
+
"BasicAFP.conf"
;
// read an input file to get the base filename and the path
std
::
string
conffile
=
GetConfPath
()
+
"BasicAFP.conf"
;
std
::
ifstream
filein
(
conffile
.
data
());
if
(
filein
.
is_open
()
==
true
)
{
std
::
string
pathforfiles
,
basename
;
UInt_t
starting_number
;
filein
>>
pathforfiles
>>
basename
>>
starting_number
;
if
(
filein
.
good
()
)
{
fPath
=
pathforfiles
;
fBaseForName
=
basename
;
fCurrentFileNumber
=
starting_number
;
std
::
cout
<<
"BasicAFP::process_initialise "
<<
pathforfiles
<<
" "
<<
basename
<<
" "
<<
starting_number
<<
std
::
endl
;
}
}
if
(
filein
.
is_open
()
==
true
)
{
// check with the first line if the files are given one by one
std
::
string
line
;
std
::
getline
(
filein
,
line
);
int
nblank
=
std
::
count
(
line
.
begin
(),
line
.
end
(),
' '
);
filein
.
seekg
(
0
);
// case where a list of files is given
if
(
nblank
==
0
)
{
while
(
filein
.
good
())
{
std
::
getline
(
filein
,
line
);
if
(
line
.
length
())
fListOfIndividualFiles
.
push_back
(
line
);
}
fCurrentFileNumber
=
0
;
std
::
cout
<<
"BasicAFP::process_initialise => list of files to process:"
<<
std
::
endl
;
for
(
auto
&
i
:
fListOfIndividualFiles
)
std
::
cout
<<
" -- "
<<
i
<<
std
::
endl
;
}
else
{
std
::
string
pathforfiles
,
basename
;
UInt_t
starting_number
;
filein
>>
pathforfiles
>>
basename
>>
starting_number
;
if
(
filein
.
good
()
)
{
fPath
=
pathforfiles
;
fBaseForName
=
basename
;
fCurrentFileNumber
=
starting_number
;
std
::
cout
<<
"BasicAFP::process_initialise "
<<
pathforfiles
<<
" "
<<
basename
<<
" "
<<
starting_number
<<
std
::
endl
;
}
}
}
filein
.
close
();
// open the first file
...
...
src/adf/BasicAFP.h
View file @
6ef7e04f
...
...
@@ -48,6 +48,8 @@ private:
std
::
string
fPath
;
//! base for all the files produced
std
::
string
fBaseForName
;
//! in case files are given one by one
std
::
vector
<
std
::
string
>
fListOfIndividualFiles
;
//! current file
FILE
*
fCurrentFile
;
//! current file number
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment