Skip to content

Commit

Permalink
added tools to QC to check whether objects is mergeable
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Tichák committed Sep 3, 2024
1 parent 7ce6af5 commit e8bc3ca
Show file tree
Hide file tree
Showing 3 changed files with 92 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

Check failure on line 17 in Utilities/Mergers/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / PR formatting / whitespace

Trailing spaces

Remove the trailing spaces at the end of the line.
PUBLIC_LINK_LIBRARIES O2::Framework AliceO2::InfoLogger)

o2_target_root_dictionary(
Expand Down
53 changes: 53 additions & 0 deletions Utilities/Mergers/include/Mergers/Mergeable.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright 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.

Check failure on line 10 in Utilities/Mergers/include/Mergers/Mergeable.h

View workflow job for this annotation

GitHub Actions / PR formatting / copyright headers

Missing or malformed copyright notice

This source file is missing the correct copyright notice.

#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 Ignore can disable whole concept, if user is really sure that he wants to pass anything into this
// \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 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.

Check failure on line 10 in Utilities/Mergers/src/Mergeable.cxx

View workflow job for this annotation

GitHub Actions / PR formatting / copyright headers

Missing or malformed copyright notice

This source file is missing the correct copyright notice.

#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 e8bc3ca

Please sign in to comment.