Skip to content

Commit

Permalink
[QC-1176] added tools to QC to check whether objects is mergeable (#1…
Browse files Browse the repository at this point in the history
…3472)

* added tools to QC to check whether objects is mergeable

* fix copyright, fix comment

---------

Co-authored-by: Michal Tichák <michal.tichak@cern.ch>
  • Loading branch information
justonedev1 and Michal Tichák authored Oct 11, 2024
1 parent 6fbc0f9 commit 80195a0
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Utilities/Mergers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
# FIXME: the LinkDef should not be in the public area

o2_add_library(Mergers
SOURCES src/MergerAlgorithm.cxx src/IntegratingMerger.cxx src/MergerInfrastructureBuilder.cxx
src/MergerBuilder.cxx src/FullHistoryMerger.cxx src/ObjectStore.cxx
SOURCES src/FullHistoryMerger.cxx src/IntegratingMerger.cxx src/Mergeable.cxx
src/MergerAlgorithm.cxx src/MergerBuilder.cxx src/MergerInfrastructureBuilder.cxx
src/ObjectStore.cxx
PUBLIC_LINK_LIBRARIES O2::Framework AliceO2::InfoLogger)

o2_target_root_dictionary(
Expand Down
52 changes: 52 additions & 0 deletions Utilities/Mergers/include/Mergers/Mergeable.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright 2019-2024 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

#ifndef ALICEO2_MERGERS_H
#define ALICEO2_MERGERS_H

/// \file Mergeable.h
/// \brief Mergeable concept.
///
/// \author Michal Tichak, michal.tichak@cern.ch

#include <concepts>

class TObject;
class TH1;
class TCollection;
class TObjArray;
class TH1;
class TTree;
class THnBase;
class TEfficiency;
class TGraph;
class TCanvas;

namespace o2::mergers
{

class MergeInterface;

template <typename T, typename... Ts>
constexpr bool IsDerivedFrom = (std::derived_from<T, Ts> || ...);

// \brief Concept to be used to test if some parameter is mergeable
//
// \parameter T type to be restricted
template <typename T>
concept Mergeable = IsDerivedFrom<std::remove_pointer_t<T>, mergers::MergeInterface, TCollection, TH1, TTree, TGraph, TEfficiency, THnBase>;

// \brief runtime check whether TObject is mergeable
bool isMergeable(TObject* obj);

} // namespace o2::mergers

#endif
36 changes: 36 additions & 0 deletions Utilities/Mergers/src/Mergeable.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2019-2024 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

#include <TCollection.h>
#include <TEfficiency.h>
#include <TGraph.h>
#include <TH1.h>
#include <THnBase.h>
#include <TObject.h>
#include <TTree.h>
#include "Mergers/MergeInterface.h"
#include "Mergers/Mergeable.h"

namespace o2::mergers
{

bool isMergeable(TObject* obj)
{
return obj->InheritsFrom(mergers::MergeInterface::Class()) ||
obj->InheritsFrom(TCollection::Class()) ||
obj->InheritsFrom(TH1::Class()) ||
obj->InheritsFrom(THnBase::Class()) ||
obj->InheritsFrom(TTree::Class()) ||
obj->InheritsFrom(TGraph::Class()) ||
obj->InheritsFrom(TEfficiency::Class());
}

} // namespace o2::mergers

0 comments on commit 80195a0

Please sign in to comment.