1616
1717#include " QualityControl/MonitorObjectCollection.h"
1818#include " QualityControl/MonitorObject.h"
19- #include " QualityControl/QcInfoLogger.h"
2019
20+ #include < TH1.h>
2121#include < TH1I.h>
2222#include < TH2I.h>
2323#include < TH2I.h>
2424#include < Mergers/CustomMergeableTObject.h>
2525#include < Mergers/MergerAlgorithm.h>
2626
2727#include < catch_amalgamated.hpp>
28+ #include < iostream>
2829
2930using namespace o2 ::mergers;
3031
@@ -96,6 +97,46 @@ TEST_CASE("monitor_object_collection_merge")
9697 delete target;
9798}
9899
100+ TEST_CASE (" monitor_object_collection_merge_different_id" )
101+ {
102+
103+ auto toHisto = [](std::unique_ptr<MonitorObjectCollection>& collection) -> TH1I* {
104+ return dynamic_cast <TH1I*>(dynamic_cast <MonitorObject*>(collection->At (0 ))->getObject ());
105+ };
106+
107+ const size_t bins = 10 ;
108+ const size_t min = 0 ;
109+ const size_t max = 10 ;
110+
111+ // Setting up the target. Histo 1D
112+ auto target = std::make_unique<MonitorObjectCollection>();
113+
114+ auto * targetTH1I = new TH1I (" histo 1d" , " original" , bins, min, max);
115+ targetTH1I->Fill (5 );
116+ targetTH1I->Print ();
117+ auto * targetMoTH1I = new MonitorObject (targetTH1I, " histo 1d" , " class" , " DET" );
118+ targetMoTH1I->setActivity ({ 123 , " PHYSICS" , " LHC32x" , " apass2" , " qc_async" , gInvalidValidityInterval });
119+ targetMoTH1I->setIsOwner (true );
120+ target->Add (targetMoTH1I);
121+
122+ // Setting up the other. Histo 1D + Histo 2D
123+ auto other = std::make_unique<MonitorObjectCollection>();
124+ other->SetOwner (true );
125+
126+ auto * otherTH1I = new TH1I (" histo 1d" , " input" , bins, min, max);
127+ otherTH1I->Fill (2 );
128+ auto * otherMoTH1I = new MonitorObject (otherTH1I, " histo 1d" , " class" , " DET" );
129+ otherMoTH1I->setActivity ({ 1234 , " PHYSICS" , " LHC32x" , " apass2" , " qc_async" , { 43 , 60 } });
130+ otherMoTH1I->setIsOwner (true );
131+ other->Add (otherMoTH1I);
132+
133+ std::cout << toHisto (target)->GetTitle () << " \n " ;
134+ std::cout << toHisto (other)->GetTitle () << " \n " ;
135+ CHECK_NOTHROW (algorithm::merge (target.get (), other.get ()));
136+ std::cout << toHisto (target)->GetTitle () << " \n " ;
137+ std::cout << toHisto (other)->GetTitle () << " \n " ;
138+ }
139+
99140TEST_CASE (" monitor_object_collection_post_deserialization" )
100141{
101142 const size_t bins = 10 ;
@@ -171,4 +212,4 @@ TEST_CASE("monitor_object_collection_clone_mw")
171212 delete mwMOC2;
172213}
173214
174- } // namespace o2::quality_control::core
215+ } // namespace o2::quality_control::core
0 commit comments