Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
ZX_PostProcessingPlotter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Christian Weber
ZX_PostProcessingPlotter
Commits
d50d1a29
Commit
d50d1a29
authored
6 years ago
by
Christian Weber
Browse files
Options
Downloads
Patches
Plain Diff
Fix: make plotPostProcess compatible with .root files that have TTree inside
parent
874332f2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
plotPostProcess.py
+12
-9
12 additions, 9 deletions
plotPostProcess.py
with
12 additions
and
9 deletions
plotPostProcess.py
+
12
−
9
View file @
d50d1a29
...
...
@@ -114,7 +114,7 @@ class DSIDHelper:
def
getTDirsAndContents
(
TDir
,
outputDict
=
{},
recursiveCounter
=
0
):
# for a given TDirectory (remember that a TFile is also a TDirectory) get
its contents
# for a given TDirectory (remember that a TFile is also a TDirectory) get
all TH1 (recursively if needed)
# output will be {TDirObject : names of objects that are not TDirs themselves}
# we can do this recursively up to a depth of 'recursiveCounter' (if it is set to >0)
# Then the output will be like
...
...
@@ -124,17 +124,21 @@ def getTDirsAndContents(TDir, outputDict = {}, recursiveCounter = 0):
TDirKeys
=
TDir
.
GetListOfKeys
()
# output is a TList
content
List
=
[]
# store the non-TDirecotry contents of the current dir here
TH1
List
=
[]
# store the non-TDirecotry contents of the current dir here
for
TKey
in
TDirKeys
:
# if current TKey refers to a dir, look recursively within (if ou
t
recursive counter is still not zero)
# if current TKey refers to a dir, look recursively within (if ou
r
recursive counter is still not zero)
# otherwise note the name of the contents
if
TKey
.
IsFolder
()
and
recursiveCounter
>=
1
:
if
TKey
.
IsFolder
()
:
if
isinstance
(
TDir
.
Get
(
TKey
.
GetName
())
,
ROOT
.
TTree
):
continue
# turns out TTrees are also folders, but they don't contain Hists that we are interested in
if
recursiveCounter
<
1
:
continue
# make sure we can exhaust our recursion counter
subdir
=
TDir
.
Get
(
TKey
.
GetName
())
outputDict
=
getTDirsAndContents
(
subdir
,
outputDict
,
recursiveCounter
=
recursiveCounter
-
1
)
else
:
contentList
.
append
(
TKey
.
GetName
())
elif
isinstance
(
TDir
.
Get
(
TKey
.
GetName
()),
ROOT
.
TH1
)
and
not
isinstance
(
TDir
.
Get
(
TKey
.
GetName
()),
ROOT
.
TH2
):
#check that the TKey indeed refers to a TH1
TH1List
.
append
(
TKey
.
GetName
())
outputDict
[
TDir
]
=
content
List
outputDict
[
TDir
]
=
TH1
List
return
outputDict
...
...
@@ -456,8 +460,7 @@ if __name__ == '__main__':
######################################################
# get the histograms in the diffrent TDirectories within the provided .root file
dirsAndContents
=
getTDirsAndContents
(
postProcessedData
,
recursiveCounter
=
1
)
dirsAndContents
=
getTDirsAndContents
(
postProcessedData
,
recursiveCounter
=
float
(
"
inf
"
))
######### get sumOfWeights #########
...
...
@@ -510,7 +513,7 @@ if __name__ == '__main__':
for
histName
in
histsByEnding
[
histEnding
]:
DSID
=
histName
.
split
(
"
_
"
)[
1
]
# get the DSID from the name of the histogram, which should be like bla_DSID_bla_...
currentTH1
=
TDir
.
Get
(
histName
).
Clone
()
# get a clone of the histogram, so that we can scale it, without changeing the original
currentTH1
=
TDir
.
Get
(
histName
)
#
.Clone() # get a clone of the histogram, so that we can scale it, without changeing the original
currentTH1
.
Rebin
(
1
)
if
int
(
DSID
)
>
0
:
# Signal & Background have DSID > 0
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment