Skip to content

Commit 3a77674

Browse files
FIT: graph helper (#2598)
* feat: add graph helper * chore: docstring changes * Install FITCommon headers --------- Co-authored-by: Andreas Molander <andreas.molander@cern.ch>
1 parent b1c5736 commit 3a77674

File tree

3 files changed

+95
-0
lines changed

3 files changed

+95
-0
lines changed

Modules/FIT/Common/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ set(SRCS
88
src/HelperHist.cxx
99
src/HelperLUT.cxx
1010
src/DigitSync.cxx
11+
src/HelperGraph.cxx
1112
)
1213

1314
set(HEADERS
@@ -18,6 +19,7 @@ set(HEADERS
1819
include/FITCommon/HelperLUT.h
1920
include/FITCommon/DigitSync.h
2021
include/FITCommon/PostProcHelper.h
22+
include/FITCommon/HelperGraph.h
2123
)
2224

2325
# ---- Library ----
@@ -48,3 +50,6 @@ install(
4850
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
4951
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
5052
)
53+
54+
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/FITCommon
55+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/QualityControl")
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
///
13+
/// \file HelperGraph.h
14+
/// \author Jakub Muszyński jakub.milosz.muszynski@cern.ch
15+
/// \brief Graph helper
16+
17+
#ifndef QC_MODULE_FIT_FITHELPERGRAPH_H
18+
#define QC_MODULE_FIT_FITHELPERGRAPH_H
19+
20+
#include <memory>
21+
#include <string>
22+
#include <type_traits>
23+
24+
#include <TGraph.h>
25+
#include "QualityControl/QcInfoLogger.h"
26+
27+
namespace o2::quality_control_modules::fit::helper
28+
{
29+
30+
/// \brief Factory that forwards ctor arguments to the chosen GraphType.
31+
/// Example:
32+
/// auto g = makeGraph<TGraphErrors>("name","title",n,x,y,ex,ey);
33+
/// \author Jakub Muszyński jakub.milosz.muszynski@cern.ch
34+
template <typename GraphType, typename... CtorArgs>
35+
inline auto makeGraph(const std::string& name,
36+
const std::string& title,
37+
CtorArgs&&... args)
38+
{
39+
static_assert(std::is_base_of_v<TObject, GraphType>,
40+
"GraphType must inherit from TObject / ROOT graph class");
41+
auto ptr = std::make_unique<GraphType>(std::forward<CtorArgs>(args)...);
42+
ptr->SetNameTitle(name.c_str(), title.c_str());
43+
return ptr;
44+
}
45+
46+
/// \brief Publishes graph through the QC ObjectsManager.
47+
/// \author Jakub Muszyński jakub.milosz.muszynski@cern.ch
48+
template <typename GraphType,
49+
typename ManagerType,
50+
typename PublicationPolicyType,
51+
typename... CtorArgs>
52+
inline auto registerGraph(ManagerType manager,
53+
PublicationPolicyType publicationPolicy,
54+
const std::string& defaultDrawOption,
55+
const std::string& name,
56+
const std::string& title,
57+
CtorArgs&&... args)
58+
{
59+
auto ptrGraph = makeGraph<GraphType>(name, title,
60+
std::forward<CtorArgs>(args)...);
61+
manager->startPublishing(ptrGraph.get(), publicationPolicy);
62+
63+
if (!defaultDrawOption.empty()) {
64+
manager->setDefaultDrawOptions(ptrGraph.get(), defaultDrawOption);
65+
}
66+
ILOG(Info, Support) << "Registered graph \"" << name
67+
<< "\" with publication policy " << int(publicationPolicy)
68+
<< ENDM;
69+
return ptrGraph;
70+
}
71+
72+
} // namespace o2::quality_control_modules::fit::helper
73+
#endif // QC_MODULE_FIT_FITHELPERGRAPH_H
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
///
13+
/// \file HelperGraph.h
14+
/// \author Jakub Muszynski jakub.milosz.muszynski@cern.ch
15+
/// \brief Graph helper
16+
17+
#include "FITCommon/HelperGraph.h"

0 commit comments

Comments
 (0)