Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Gaudi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
atlas
Gaudi
Merge requests
!177
GMR 652: THistSvc bugfix
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
GMR 652: THistSvc bugfix
leggett/AtlasGaudi:dev/GMR-652
into
atlas/v30r2
Overview
0
Commits
3
Changes
2
Merged
Charles Leggett
requested to merge
leggett/AtlasGaudi:dev/GMR-652
into
atlas/v30r2
6 years ago
Overview
0
Commits
3
Changes
2
Expand
applies
gaudi/Gaudi!652 (merged)
0
0
Merge request reports
Compare
atlas/v30r2
atlas/v30r2 (base)
and
latest version
latest version
0cdd2724
3 commits,
6 years ago
2 files
+
81
−
83
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
GaudiSvc/src/THistSvc/THistSvc.cpp
+
79
−
75
Options
@@ -1219,35 +1219,35 @@ StatusCode THistSvc::io_reinit()
}
// loop over all uids and migrate them to the new file
// XXX FIXME: this double loop sucks...
for
(
auto
&
u
id
:
m_
uid
sX
)
{
THistID
&
hid
=
uid
.
second
;
if
(
hid
.
file
!=
f
)
continue
;
TDirectory
*
olddir
=
this
->
changeDir
(
hid
)
;
hid
.
file
=
newfile
;
// side-effect: create needed directories...
TDirectory
*
newdir
=
t
hi
s
->
changeDir
(
hid
);
TClass
*
cl
=
hid
.
obj
->
IsA
();
//
migrate
the object
s to the new file
.
// thanks to the object model of ROOT, it is super easy.
if
(
cl
->
InheritsFrom
(
"TTree"
)
)
{
dynamic_cast
<
TTree
*>
(
hid
.
obj
)
->
SetDirectory
(
newdir
);
dynamic_cast
<
TTree
*>
(
hid
.
obj
)
->
Reset
();
}
else
if
(
cl
->
InheritsFrom
(
"TH1"
)
)
{
dynamic_cast
<
TH1
*>
(
hid
.
obj
)
->
SetDirectory
(
newdir
);
dynamic_cast
<
TH1
*>
(
hid
.
obj
)
->
Reset
();
}
else
if
(
cl
->
InheritsFrom
(
"TGraph"
)
)
{
olddir
->
Remove
(
hid
.
obj
);
newdir
->
Append
(
hid
.
obj
);
}
else
{
error
()
<<
"id:
\"
"
<<
hid
.
id
<<
"
\"
is not a inheriting from a class
"
<<
"
we know how to handle (received ["
<<
cl
->
GetName
()
<<
"], "
<<
"expected [TTree, TH1 or TGraph]) !"
<<
endmsg
<<
"attaching to current dir ["
<<
newdir
->
GetPath
()
<<
"
] "
<<
"nonetheless..."
<<
endmsg
;
olddir
->
Remove
(
hid
.
obj
);
newdir
->
Append
(
hid
.
obj
);
for
(
auto
&
uid
:
m_uids
)
{
for
(
auto
&
h
id
:
*
uid
.
second
)
{
if
(
hid
.
file
!=
f
)
continue
;
TDirectory
*
olddir
=
this
->
changeDir
(
hid
)
;
hid
.
file
=
newfile
;
// side-effect: create needed directories...
TDirectory
*
newdir
=
this
->
changeDir
(
hid
);
TClass
*
cl
=
hi
d
.
obj
->
IsA
(
);
// migrate the objects to the new file.
//
thanks to
the object
model of ROOT, it is super easy
.
if
(
cl
->
InheritsFrom
(
"TTree"
)
)
{
dynamic_cast
<
TTree
*>
(
hid
.
obj
)
->
SetDirectory
(
newdir
);
dynamic_cast
<
TTree
*>
(
hid
.
obj
)
->
Reset
(
);
}
else
if
(
cl
->
InheritsFrom
(
"TH1"
)
)
{
dynamic_cast
<
TH1
*>
(
hid
.
obj
)
->
SetDirectory
(
newdir
);
dynamic_cast
<
TH1
*>
(
hid
.
obj
)
->
Reset
(
);
}
else
if
(
cl
->
InheritsFrom
(
"TGraph"
)
)
{
olddir
->
Remove
(
hid
.
obj
);
newdir
->
Append
(
hid
.
obj
);
}
else
{
error
()
<<
"id:
\"
"
<<
hid
.
id
<<
"
\"
is not a inheriting from a class "
<<
"we know how to handle (received ["
<<
cl
->
GetName
()
<<
"],
"
<<
"
expected [TTree, TH1 or TGraph]) !"
<<
endmsg
<<
"attaching to current dir ["
<<
newdir
->
GetPath
()
<<
"] "
<<
"
nonetheless..."
<<
endmsg
;
olddir
->
Remove
(
hid
.
obj
)
;
newdir
->
Append
(
hid
.
obj
);
}
}
}
f
->
ReOpen
(
"READ"
);
@@ -1293,69 +1293,73 @@ void THistSvc::updateFiles()
if
(
msgLevel
(
MSG
::
DEBUG
)
)
debug
()
<<
"updateFiles()"
<<
endmsg
;
for
(
auto
uitr
=
m_uidsX
.
begin
();
uitr
!=
m_uidsX
.
end
();
++
uitr
)
{
for
(
auto
uitr
=
m_uids
.
begin
();
uitr
!=
m_uids
.
end
();
++
uitr
)
{
for
(
auto
&
hid
:
*
(
uitr
->
second
)
)
{
#ifndef NDEBUG
if
(
msgLevel
(
MSG
::
VERBOSE
)
)
verbose
()
<<
" update: "
<<
uitr
->
first
<<
" "
<<
uitr
->
secon
d
.
id
<<
" "
<<
uitr
->
secon
d
.
mode
<<
endmsg
;
if
(
msgLevel
(
MSG
::
VERBOSE
)
)
verbose
()
<<
" update: "
<<
uitr
->
first
<<
" "
<<
hi
d
.
id
<<
" "
<<
hi
d
.
mode
<<
endmsg
;
#endif
TObject
*
to
=
uitr
->
secon
d
.
obj
;
TFile
*
oldFile
=
uitr
->
secon
d
.
file
;
if
(
!
to
)
{
warning
()
<<
uitr
->
first
<<
": TObject == 0"
<<
endmsg
;
}
else
if
(
uitr
->
second
.
temp
||
uitr
->
secon
d
.
mode
==
READ
)
{
TObject
*
to
=
hi
d
.
obj
;
TFile
*
oldFile
=
hi
d
.
file
;
if
(
!
to
)
{
warning
()
<<
uitr
->
first
<<
": TObject == 0"
<<
endmsg
;
}
else
if
(
hid
.
temp
||
hi
d
.
mode
==
READ
)
{
// do nothing - no need to check how big the file is since we
// are just reading it.
#ifndef NDEBUG
if
(
msgLevel
(
MSG
::
VERBOSE
)
)
verbose
()
<<
" skipping"
<<
endmsg
;
if
(
msgLevel
(
MSG
::
VERBOSE
)
)
verbose
()
<<
" skipping"
<<
endmsg
;
#endif
}
else
if
(
to
->
IsA
()
->
InheritsFrom
(
"TTree"
)
)
{
TTree
*
tr
=
dynamic_cast
<
TTree
*>
(
to
);
TFile
*
newFile
=
tr
->
GetCurrentFile
();
if
(
oldFile
!=
newFile
)
{
std
::
string
newFileName
=
newFile
->
GetName
();
std
::
string
oldFileName
,
streamName
,
rem
;
TFile
*
dummy
=
nullptr
;
findStream
(
uitr
->
second
.
id
,
streamName
,
rem
,
dummy
);
for
(
auto
&
itr
:
m_files
)
{
if
(
itr
.
second
.
first
==
oldFile
)
{
itr
.
second
.
first
=
newFile
;
}
else
if
(
to
->
IsA
()
->
InheritsFrom
(
"TTree"
)
)
{
TTree
*
tr
=
dynamic_cast
<
TTree
*>
(
to
);
TFile
*
newFile
=
tr
->
GetCurrentFile
();
if
(
oldFile
!=
newFile
)
{
std
::
string
newFileName
=
newFile
->
GetName
();
std
::
string
oldFileName
,
streamName
,
rem
;
TFile
*
dummy
=
nullptr
;
findStream
(
hid
.
id
,
streamName
,
rem
,
dummy
);
for
(
auto
&
itr
:
m_files
)
{
if
(
itr
.
second
.
first
==
oldFile
)
{
itr
.
second
.
first
=
newFile
;
}
}
}
for
(
auto
uitr2
=
uitr
;
uitr2
!=
m_uidsX
.
end
();
++
uitr2
)
{
if
(
uitr2
->
second
.
file
==
oldFile
)
{
uitr2
->
second
.
file
=
newFile
;
for
(
auto
uitr2
=
uitr
;
uitr2
!=
m_uids
.
end
();
++
uitr2
)
{
for
(
auto
&
hid2
:
*
(
uitr2
->
second
)
)
{
if
(
hid2
.
file
==
oldFile
)
{
hid2
.
file
=
newFile
;
}
}
}
}
auto
sitr
=
std
::
find_if
(
std
::
begin
(
m_fileStreams
),
std
::
end
(
m_fileStreams
),
[
&
](
streamMap
::
const_reference
s
)
{
return
s
.
second
==
streamName
;
}
);
if
(
sitr
!=
std
::
end
(
m_fileStreams
)
)
oldFileName
=
sitr
->
first
;
auto
sitr
=
std
::
find_if
(
std
::
begin
(
m_fileStreams
),
std
::
end
(
m_fileStreams
),
[
&
](
streamMap
::
const_reference
s
)
{
return
s
.
second
==
streamName
;
}
);
if
(
sitr
!=
std
::
end
(
m_fileStreams
)
)
oldFileName
=
sitr
->
first
;
#ifndef NDEBUG
if
(
msgLevel
(
MSG
::
DEBUG
)
)
{
debug
()
<<
"migrating uid: "
<<
uitr
->
secon
d
.
id
<<
" stream: "
<<
streamName
<<
" oldFile: "
<<
oldFileName
<<
" newFile: "
<<
newFileName
<<
endmsg
;
}
if
(
msgLevel
(
MSG
::
DEBUG
)
)
{
debug
()
<<
"migrating uid: "
<<
hi
d
.
id
<<
" stream: "
<<
streamName
<<
" oldFile: "
<<
oldFileName
<<
" newFile: "
<<
newFileName
<<
endmsg
;
}
#endif
if
(
!
oldFileName
.
empty
()
)
{
auto
i
=
m_fileStreams
.
lower_bound
(
oldFileName
);
while
(
i
!=
std
::
end
(
m_fileStreams
)
&&
i
->
first
==
oldFileName
)
{
if
(
!
oldFileName
.
empty
()
)
{
auto
i
=
m_fileStreams
.
lower_bound
(
oldFileName
);
while
(
i
!=
std
::
end
(
m_fileStreams
)
&&
i
->
first
==
oldFileName
)
{
#ifndef NDEBUG
if
(
msgLevel
(
MSG
::
DEBUG
)
)
{
debug
()
<<
"changing filename
\"
"
<<
i
->
first
<<
"
\"
to
\"
"
<<
newFileName
<<
"
\"
for stream
\"
"
<<
i
->
second
<<
"
\"
"
<<
endmsg
;
}
if
(
msgLevel
(
MSG
::
DEBUG
)
)
{
debug
()
<<
"changing filename
\"
"
<<
i
->
first
<<
"
\"
to
\"
"
<<
newFileName
<<
"
\"
for stream
\"
"
<<
i
->
second
<<
"
\"
"
<<
endmsg
;
}
#endif
std
::
string
nm
=
std
::
move
(
i
->
second
);
i
=
m_fileStreams
.
erase
(
i
);
m_fileStreams
.
emplace
(
newFileName
,
std
::
move
(
nm
)
);
std
::
string
nm
=
std
::
move
(
i
->
second
);
i
=
m_fileStreams
.
erase
(
i
);
m_fileStreams
.
emplace
(
newFileName
,
std
::
move
(
nm
)
);
}
}
else
{
error
()
<<
"Problems updating fileStreams with new file name"
<<
endmsg
;
}
}
else
{
error
()
<<
"Problems updating fileStreams with new file name"
<<
endmsg
;
}
}
}
Loading