Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cbmroot
Manage
Activity
Members
Labels
Plan
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
Computing
cbmroot
Commits
f890cb30
Commit
f890cb30
authored
4 years ago
by
Sergey Gorbunov
Browse files
Options
Downloads
Patches
Plain Diff
CbmQaPie class as a TPie wrapper, which prevents crashes
parent
1189808e
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
core/qa/CMakeLists.txt
+1
-0
1 addition, 0 deletions
core/qa/CMakeLists.txt
core/qa/CbmQaBaseLinkDef.h
+2
-0
2 additions, 0 deletions
core/qa/CbmQaBaseLinkDef.h
core/qa/CbmQaPie.cxx
+111
-0
111 additions, 0 deletions
core/qa/CbmQaPie.cxx
core/qa/CbmQaPie.h
+72
-0
72 additions, 0 deletions
core/qa/CbmQaPie.h
with
186 additions
and
0 deletions
core/qa/CMakeLists.txt
+
1
−
0
View file @
f890cb30
...
...
@@ -20,6 +20,7 @@ link_directories( ${LINK_DIRECTORIES})
set
(
SRCS
CbmQaCanvas.cxx
CbmQaPie.cxx
)
set
(
LINKDEF CbmQaBaseLinkDef.h
)
...
...
This diff is collapsed.
Click to expand it.
core/qa/CbmQaBaseLinkDef.h
+
2
−
0
View file @
f890cb30
...
...
@@ -5,4 +5,6 @@
#pragma link off all functions;
#pragma link C++ class CbmQaCanvas - ;
#pragma link C++ class CbmQaPieSlice + ;
#pragma link C++ class CbmQaPie - ;
#endif
This diff is collapsed.
Click to expand it.
core/qa/CbmQaPie.cxx
0 → 100644
+
111
−
0
View file @
f890cb30
/// \file CbmQaPie.cxx
/// \brief Implementation of the CbmQaPie class
/// \author Sergey Gorbunov <se.gorbunov@gsi.de>
/// \date 07.11.2020
#include
"CbmQaPie.h"
#include
"TBrowser.h"
#include
"TBuffer.h"
#include
"TPad.h"
ClassImp
(
CbmQaPieSlice
);
ClassImp
(
CbmQaPie
);
void
CbmQaPieSlice
::
CopyFrom
(
const
TPieSlice
&
inp
)
{
const
CbmQaPieSlice
*
s
=
(
const
CbmQaPieSlice
*
)
(
&
inp
);
fPie
=
s
->
fPie
;
fValue
=
s
->
fValue
;
fRadiusOffset
=
s
->
fRadiusOffset
;
}
void
CbmQaPieSlice
::
CopyTo
(
TPieSlice
&
outp
)
const
{
CbmQaPieSlice
*
s
=
(
CbmQaPieSlice
*
)
(
&
outp
);
s
->
fPie
=
fPie
;
s
->
fValue
=
fValue
;
s
->
fRadiusOffset
=
fRadiusOffset
;
}
CbmQaPie
::
CbmQaPie
(
const
CbmQaPie
&
cpy
)
:
TPie
(
cpy
.
GetName
(),
cpy
.
GetTitle
(),
cpy
.
fNvals
)
{
/// Prevent original copy constructor from a crash
cpy
.
TAttText
::
Copy
(
*
this
);
fAngularOffset
=
cpy
.
fAngularOffset
;
fX
=
cpy
.
fX
;
fY
=
cpy
.
fY
;
fRadius
=
cpy
.
fRadius
;
for
(
Int_t
i
=
0
;
i
<
fNvals
;
++
i
)
{
*
fPieSlices
[
i
]
=
*
cpy
.
fPieSlices
[
i
];
((
CbmQaPieSlice
*
)
fPieSlices
[
i
])
->
SetPie
(
this
);
}
}
void
CbmQaPie
::
Browse
(
TBrowser
*
b
)
{
/// Draw CbmQaPie by a mouse click in the TBrowser
Draw
(
b
?
b
->
GetDrawOption
()
:
""
);
gPad
->
Update
();
}
void
CbmQaPie
::
Draw
(
Option_t
*
option
)
{
// Prevents original TPie::Draw() from crashing when there are no entries
double
sum
=
0.
;
for
(
int
i
=
0
;
i
<
fNvals
;
i
++
)
{
sum
+=
fabs
(
GetEntryVal
(
i
));
}
if
(
sum
<
1.e-20
)
{
for
(
int
i
=
0
;
i
<
fNvals
;
i
++
)
{
SetEntryVal
(
i
,
1.e-20
);
}
}
TPie
::
Draw
(
option
);
if
(
sum
<
1.e-20
)
{
for
(
int
i
=
0
;
i
<
fNvals
;
i
++
)
{
SetEntryVal
(
i
,
0.
);
}
}
}
void
CbmQaPie
::
Streamer
(
TBuffer
&
R__b
)
{
/// The Streamer is declared by ClassDef() macro
/// Stream an object of class CbmQaPie
///
if
(
R__b
.
IsReading
())
{
for
(
int
i
=
0
;
i
<
fNvals
;
i
++
)
{
if
(
gPad
&&
gPad
->
GetListOfPrimitives
())
{
gPad
->
GetListOfPrimitives
()
->
Remove
(
fPieSlices
[
i
]);
}
delete
fPieSlices
[
i
];
fPieSlices
[
i
]
=
nullptr
;
}
delete
[]
fPieSlices
;
fPieSlices
=
nullptr
;
fNvals
=
0
;
R__b
.
ReadClassBuffer
(
CbmQaPie
::
Class
(),
this
);
fNvals
=
fSliceStore
.
size
();
fPieSlices
=
new
TPieSlice
*
[
fNvals
];
for
(
int
i
=
0
;
i
<
fNvals
;
i
++
)
{
fPieSlices
[
i
]
=
new
TPieSlice
;
fSliceStore
[
i
].
SetPie
(
this
);
fSliceStore
[
i
].
CopyTo
(
*
fPieSlices
[
i
]);
}
fSliceStore
.
clear
();
}
else
{
fSliceStore
.
resize
(
fNvals
);
for
(
int
i
=
0
;
i
<
fNvals
;
i
++
)
{
fSliceStore
[
i
].
CopyFrom
(
*
fPieSlices
[
i
]);
fSliceStore
[
i
].
SetPie
(
nullptr
);
}
TPieSlice
**
tmp
=
fPieSlices
;
fPieSlices
=
nullptr
;
fNvals
=
0
;
R__b
.
WriteClassBuffer
(
CbmQaPie
::
Class
(),
this
);
fPieSlices
=
tmp
;
fNvals
=
fSliceStore
.
size
();
fSliceStore
.
clear
();
}
}
This diff is collapsed.
Click to expand it.
core/qa/CbmQaPie.h
0 → 100644
+
72
−
0
View file @
f890cb30
/// \file CbmQaPie.h
/// \brief Definition of the CbmQaPie class
/// \author Sergey Gorbunov <se.gorbunov@gsi.de>
/// \date 07.11.2020
#ifndef CbmQaPie_H
#define CbmQaPie_H
#include
"TPie.h"
#include
"TPieSlice.h"
#include
<vector>
class
TBrowser
;
/// A helper class for accessing protected members of TPieSlice
///
class
CbmQaPieSlice
:
public
TPieSlice
{
public:
/// copy data from TPieSlice
void
CopyFrom
(
const
TPieSlice
&
inp
);
/// copy data to TPieSlice
void
CopyTo
(
TPieSlice
&
outp
)
const
;
/// set a TPie pointer
void
SetPie
(
TPie
*
p
)
{
fPie
=
p
;
}
ClassDef
(
CbmQaPieSlice
,
1
);
};
/// A modification of TPie which fixes the following issues:
///
/// 1. When a TPie is read from a file as a part of TCanvas, it crashes at the destructor.
/// 2. When a TPie is created via copy constructor it crashes at the destructor.
/// 3. An empty TPie crashes at Draw()
/// 4. When one clicks on a TPie in the TBrowser, the TBrowser crashes.
/// 5. TBrowser dosen't draw a TPie by a mouse click.
///
class
CbmQaPie
:
public
TPie
{
public:
/// Reimplementation of any existing TPie constructor
template
<
typename
...
Types
>
CbmQaPie
(
Types
...
args
)
:
CbmQaPie
(
MyAuxiliaryType
{},
args
...)
{}
/// Prevent original copy constructor from a crash
CbmQaPie
(
const
CbmQaPie
&
cpy
);
/// Destructor
~
CbmQaPie
()
{}
/// Draw TPie by a mouse click in the TBrowser
void
Browse
(
TBrowser
*
b
);
// Prevents original TPie::Draw() from crashing when there are no entries
void
Draw
(
Option_t
*
option
=
"l"
);
private
:
std
::
vector
<
CbmQaPieSlice
>
fSliceStore
;
///< a vector for slice streaming.
///< it replaces the original array of pointers.
/// Use a specific type name in order to avoid ambiguities when unrolling
/// templates
enum
MyAuxiliaryType
:
int
;
/// Constructor which calls a TPie constructor
template
<
typename
...
Types
>
CbmQaPie
(
MyAuxiliaryType
,
Types
...
args
)
:
TPie
(
args
...)
{}
ClassDef
(
CbmQaPie
,
1
);
};
#endif
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