ATLAS Offline Software
LArConditionsMergerAlg.icc
Go to the documentation of this file.
1 //Dear emacs, this is -*- c++ -*-
2 
3 /*
4  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 template<class T, class T1>
8 StatusCode LArConditionsMergerAlg<T,T1>::initialize() {
9 
10  ATH_CHECK(m_readKeys.initialize(!m_readKeys.empty()));
11  //ATH_CHECK(m_detStoreKeys.initialize(!m_detStoreKeys.empty()));
12 
13  return StatusCode::SUCCESS;
14 }
15 
16 
17 template<class T, class T1>
18 StatusCode LArConditionsMergerAlg<T,T1>::execute() {
19 
20  if (m_readKeys.empty()) {
21  if(m_detStoreKeys.empty()) return StatusCode::FAILURE;
22 
23  std::unique_ptr<T1> out=std::make_unique<T1>();
24  ATH_CHECK(out->setGroupingType(m_groupingType,msg()));
25  ATH_CHECK(out->initialize());
26 
27  for (const auto & key : m_detStoreKeys){
28  //SG::ReadHandle<T1> calContainer(key);
29  const T1* t1Container = nullptr;
30  StatusCode sc = detStore()->retrieve(t1Container,key);
31  // Check that this container is present
32  if (sc.isFailure() || !t1Container) {
33  ATH_MSG_WARNING("No container found in storegate "<< key);
34  } else {
35  const T1 obj=*t1Container;
36  bool stat=out->merge(obj);
37  if (stat) {
38  ATH_MSG_ERROR("Channels were overwritten while merging " << key);
39  }
40  }
41  }
42 
43  ATH_CHECK(detStore()->record(std::move(out),m_writeKey));
44 
45  } else {
46  std::unique_ptr<T> out=std::make_unique<T>();
47  ATH_CHECK(out->setGroupingType(m_groupingType,msg()));
48  ATH_CHECK(out->initialize());
49 
50  for (const auto & key : m_readKeys) {
51  SG::ReadCondHandle<T> handle{key};
52  const T* obj=*handle;
53  bool stat=out->merge(*obj);
54  if (stat) {
55  ATH_MSG_ERROR("Channels were overwritten while merging " << key);
56  }
57  }
58 
59  ATH_CHECK(detStore()->record(std::move(out),m_writeKey));
60  }
61 
62  return StatusCode::SUCCESS;
63 }