An example implementation used in the past is also attached
GainPlotter.txt. See for lines 555-570.
For this would suggest to add a new struct to PlotterUtilityTypes.h found here. This struct should be something like:
InfoAxis{
bool bAxisInfoSet;
//Additional axis related parameters found here
...
//Constructor
InfoAxis(){
bAxisInfoSet = false;
//Additional axis related parameters found here
....
}
//Destructor
~InfoAxis(){
....
}
}
Then instances of this object called m_infoAxisX, m_infoAxisY, and m_infoAxisZ should be added to InfoCanvas to represent the X, Y and Z-axes respectively. Then all data members related to the axis be moved from InfoCanvas struct to InfoAxis.
Then the appropriate changes to ParameterLoaderPlottershould be made to now store these items into the InfoAxis objects found in InfoCanvas; see ParameterLoaderPlotter::loadParametersCanvas(). Note this method should set this info InfoAxis::bAxisInfoSet to True before completion.
Then the InfoPlot struct should have a data member for InfoAxis added, let's start with just one representing the Y-axis called m_infoAxisY. The user will then be optionally allowed to supply a Y-axis for this plot. To do this changes will again be required to ParameterLoaderPlotter in ParameterLoaderPlotter::loadParametersPlot(). If the user supplies any of the plot specific y-axis information then InfoAxis::bAxisInfoSet for only this plot should be set to True. Otherwise this parameter should remain at it's default from construction, e.g. False.
Then following the implementation shown above in GainPlotter modify the plotting base class PlotterGeneric by adding a new method PlotterGeneric::drawAdditionalAxes(). This method should look something like:
PlotterGeneric::drawAdditionalAxes(){
//Loop over all plots
for (auto iterPlot = m_canvInfo.m_map_infoPlot.begin(); iterPlot != m_canvInfo.m_map_infoPlot.end(); ++iterPlot) {
if !(*iterPlot).second.m_infoAxisY.bAxisInfoSet{
continue;
}
//Draw the additional axis following the example shown in GainPlotter
} //End Loop Over Input Plots
return;
}
Then this method should be called by PlotterGeneric:: plotAndStore() shown here after line 67. One should check to make sure the user is using 1D plots. For example:
if canvSetup.m_strPlotType compares to 1D types{
drawAdditionalAxes();
}
The 1D types are shown in the PlotTypesPlotter struct of QualityControlSectionNames.h available here
Brief summary of issue
Right now
genericPlotter
only supports drawing a single axis and plots on that primary axis. Suggest to change this.Types of issue
Expected Behavior
Allow support for an arbitrary number of additional y-axes using the trick of a transparent pad in ROOT as shown here:
https://root.cern.ch/root/html/tutorials/hist/transpad.C.html
An example implementation used in the past is also attached GainPlotter.txt. See for lines 555-570.
For this would suggest to add a new struct to
PlotterUtilityTypes.h
found here. This struct should be something like:Then instances of this object called
m_infoAxisX
,m_infoAxisY
, andm_infoAxisZ
should be added toInfoCanvas
to represent the X, Y and Z-axes respectively. Then all data members related to the axis be moved fromInfoCanvas
struct toInfoAxis
.Then the appropriate changes to
ParameterLoaderPlotter
should be made to now store these items into theInfoAxis
objects found inInfoCanvas
; see ParameterLoaderPlotter::loadParametersCanvas(). Note this method should set this infoInfoAxis::bAxisInfoSet
toTrue
before completion.Then the
InfoPlot
struct should have a data member forInfoAxis
added, let's start with just one representing the Y-axis calledm_infoAxisY
. The user will then be optionally allowed to supply a Y-axis for this plot. To do this changes will again be required toParameterLoaderPlotter
in ParameterLoaderPlotter::loadParametersPlot(). If the user supplies any of the plot specific y-axis information thenInfoAxis::bAxisInfoSet
for only this plot should be set toTrue
. Otherwise this parameter should remain at it's default from construction, e.g.False
.Then following the implementation shown above in GainPlotter modify the plotting base class
PlotterGeneric
by adding a new methodPlotterGeneric::drawAdditionalAxes()
. This method should look something like:Then this method should be called by
PlotterGeneric:: plotAndStore()
shown here after line 67. One should check to make sure the user is using 1D plots. For example:The 1D types are shown in the
PlotTypesPlotter
struct ofQualityControlSectionNames.h
available hereThey are:
PlotTypesPlotter::m_strGraph
PlotTypesPlotter::m_strGraphErrors
PlotTypesPlotter::m_strHisto
An example to do this comparison correctly is shown in genericPlotter.cpp [Lines 218-257] (https://github.com/bdorney/CMS_GEM_Analysis_Framework/blob/e9492333fb9ff769a2b258c0240e9ed3bead14e5/src/genericPlotter.cpp#L218). However here you don't need separate if statements, just need to do an OR over the possibilities.
In this way changes to the base class will ensure all inherited classes are able to add additional y-axes for plots
Current Behavior
Additional Y-axes are not supported by genericPlotter
Context (for feature requests)
Will allow user to draw additional plots with multiple y-axes rather than doing it by hand.