Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
JZCaPA
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Riccardo Longo
JZCaPA
Commits
8a61f0d1
Commit
8a61f0d1
authored
6 years ago
by
Riccardo Longo
Browse files
Options
Downloads
Patches
Plain Diff
PlotManyPads added
parent
cf6a35ec
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Analysis/include/Visualizer.h
+9
-4
9 additions, 4 deletions
Analysis/include/Visualizer.h
Analysis/src/Visualizer.cpp
+47
-1
47 additions, 1 deletion
Analysis/src/Visualizer.cpp
with
56 additions
and
5 deletions
Analysis/include/Visualizer.h
+
9
−
4
View file @
8a61f0d1
...
...
@@ -21,17 +21,20 @@ class Visualizer {
//Styles (so fa only ATLAS)
TStyle
*
AtlasStyle
();
//Methods to set a give style
//Methods to set a give
n
style
void
SetAtlasStyle
();
/** @brief allow the user to define the extension of the plots once they're printed. ".pdf" by default */
void
SetPlotExtension
(
std
::
string
_extension
)
{
m_extension
=
_extension
;
}
/** @brief make the argument true to activate the debug mode. False to deactivate it*/
void
SetDebugMode
(
bool
_isDebugon
)
{
m_debug
=
_isDebugon
;
}
void
SetDebugMode
(
bool
_isDebugon
)
{
m_debug
=
_isDebugon
;
}
//Special plot treatments
void
OverlayHistos
(
TH1
D
*
h1
,
TH1
D
*
h2
,
TVirtualPad
*
pad
);
void
OverlayHistos
(
TH1
*
h1
,
TH1
*
h2
,
TVirtualPad
*
pad
);
//Main visualization methods
void
ManyPadsPlot
(
std
::
vector
<
TH1
>
raw
_form
,
std
::
vector
<
TH1
>
der
_form
,
int
nx
,
int
ny
,
std
::
string
out_name
,
std
::
string
treatment
);
void
ManyPadsPlot
(
std
::
vector
<
TH1
*
>
_first
_form
,
std
::
vector
<
TH1
*
>
_second
_form
,
int
_ncol
,
int
_nrow
,
std
::
string
_
out_name
,
std
::
string
_
treatment
);
private
:
...
...
@@ -39,6 +42,8 @@ class Visualizer {
std
::
string
m_style
;
/** Debug flag */
bool
m_debug
=
false
;
/** String defining the extension used to print the plots */
std
::
string
m_extension
=
".pdf"
;
};
#endif
This diff is collapsed.
Click to expand it.
Analysis/src/Visualizer.cpp
+
47
−
1
View file @
8a61f0d1
...
...
@@ -12,6 +12,7 @@
#include
<TAxis.h>
#include
<TGaxis.h>
#include
<TPad.h>
#include
<TCanvas.h>
#include
<iostream>
...
...
@@ -125,7 +126,7 @@ void Visualizer::SetAtlasStyle(){
* @param3 Address of a pad (TPad or TCanvas) to be drawn on
* @param4 Save option. If true, save a .pdf
*/
void
Visualizer
::
OverlayHistos
(
TH1
D
*
h1
,
TH1
D
*
h2
,
TVirtualPad
*
pad
){
void
Visualizer
::
OverlayHistos
(
TH1
*
h1
,
TH1
*
h2
,
TVirtualPad
*
pad
){
// If there is no pad or no data in the histograms, return
if
(
pad
==
nullptr
)
{
std
::
cerr
<<
"WARNING: No pad to overlay histos onto"
<<
std
::
endl
;
return
;}
...
...
@@ -155,3 +156,48 @@ void Visualizer::OverlayHistos( TH1D *h1, TH1D *h2 , TVirtualPad* pad){
if
(
m_debug
)
pad
->
Print
(
Form
(
"%s_Overlay.pdf"
,
h1
->
GetTitle
()
)
)
;
}
/**
* @brief Implementation of Visualizer::ManyPadsPlot. This method takes two vector of histograms that needs to be treated in a peculiar way and
* takes care of plot those together in a canvas with a given number of columns and rows.
* @param _first_form - vector of the first type of histograms to be plotted
* @param _second_form - vector of the second type of histograms to be plotted s
* @param _ncol - number of columns of the canvas
* @param _nrow - number of rows of the canvas
* @param _out_name - name of the plot (w/o extension, that's defined by a data member [ .pdf by default ]
* @param _treatment - treatment of the plots (at the moment only one available, overlay)
*/
void
Visualizer
::
ManyPadsPlot
(
std
::
vector
<
TH1
*
>
_first_form
,
std
::
vector
<
TH1
*
>
_second_form
,
int
_ncol
,
int
_nrow
,
std
::
string
_out_name
,
std
::
string
_treatment
){
if
(
_treatment
!=
"overlay"
&&
_treatment
!=
"OVERLAY"
&&
_treatment
!=
"Overlay"
){
std
::
cerr
<<
"WARNING!!! You're looking for a treatment that has not been implemented yet! Please check it carefully"
<<
std
::
endl
;
std
::
cerr
<<
"Exiting w/o doing anything .."
<<
std
::
endl
;
return
;
}
if
(
_first_form
.
size
()
!=
_second_form
.
size
())
std
::
cerr
<<
"WARNING!!! The two vectors of histograms "
"have different size. May result in a crash..."
<<
std
::
endl
;
if
(
_first_form
.
size
()
<
_ncol
*
_nrow
||
_second_form
.
size
()
<
_ncol
*
_nrow
)
std
::
cerr
<<
"WARNING!!! You have selected a vector of histrograms that will not fill all your pads"
"This may result in a crash..."
<<
std
::
endl
;
if
(
_first_form
.
size
()
>
_ncol
*
_nrow
||
_second_form
.
size
()
>
_ncol
*
_nrow
)
std
::
cerr
<<
"WARNING!!! You have selected a vector of histrograms that is bigger than the number of requested pads"
"This may result in histograms lost w/o plotting..."
<<
std
::
endl
;
//This for the moment is hardcoded. Maybe can be moved to data member to have more general usage also for single plots.
int
squared_pad_size
=
300
;
TCanvas
*
canv
=
new
TCanvas
(
_out_name
.
c_str
(),
_out_name
.
c_str
(),
squared_pad_size
*
_ncol
,
squared_pad_size
*
_nrow
);
canv
->
Divide
(
_ncol
,
_nrow
);
for
(
int
idraw
=
0
;
idraw
<
_first_form
.
size
();
idraw
++
){
canv
->
cd
(
idraw
+
1
);
if
(
_treatment
==
"overlay"
||
_treatment
!=
"OVERLAY"
||
_treatment
!=
"Overlay"
){
OverlayHistos
(
_first_form
.
at
(
idraw
),
_second_form
.
at
(
idraw
),
gPad
);
}
}
canv
->
Print
((
_out_name
+
m_extension
).
c_str
());
}
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