ATLAS Offline Software
LArSymConditionsAlg.icc
Go to the documentation of this file.
1 //dear emacs, this is -*-c++-*-
2 
3 /*
4  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 template<class MC_t, class SYM_t>
8 StatusCode LArSymConditionsAlg<MC_t,SYM_t>::initialize() {
9 
10  // Read Handles
11  ATH_CHECK( m_readKey.initialize() );
12  ATH_CHECK( m_mcSymKey.initialize() );
13  ATH_CHECK( m_writeKey.initialize() );
14 
15  return StatusCode::SUCCESS;
16 }
17 
18 
19 template<class MC_t, class SYM_t>
20 StatusCode LArSymConditionsAlg<MC_t,SYM_t>::execute() {
21 
22  SG::WriteCondHandle<SYM_t> writeHandle{m_writeKey};
23 
24  if (writeHandle.isValid()) {
25  ATH_MSG_DEBUG("Found valid write handle");
26  return StatusCode::SUCCESS;
27  }
28 
29  SG::ReadCondHandle<MC_t> readHandle{m_readKey};
30  const MC_t* mcClass{*readHandle};
31  if (mcClass==nullptr) {
32  ATH_MSG_ERROR("Failed to retrieve input object with key " << m_readKey.key());
33  return StatusCode::FAILURE;
34  }
35  writeHandle.addDependency(readHandle);
36 
37 
38  SG::ReadCondHandle<LArMCSym> mcSymHdl{m_mcSymKey};
39  const LArMCSym* mcSym={*mcSymHdl};
40  if (mcSym==nullptr) {
41  ATH_MSG_ERROR("Failed to retrieve LArMCSym object with key " << m_mcSymKey.key());
42  return StatusCode::FAILURE;
43  }
44  writeHandle.addDependency(mcSymHdl);
45 
46 
47  std::unique_ptr<SYM_t> sym=std::make_unique<SYM_t>(mcSym,mcClass);
48 
49  if(writeHandle.record(std::move(sym)).isFailure()) {
50  ATH_MSG_ERROR("Could not record LArSymCond object with "
51  << writeHandle.key()
52  << " with EventRange " << writeHandle.getRange()
53  << " into Conditions Store");
54  return StatusCode::FAILURE;
55  }
56  ATH_MSG_INFO("recorded new " << writeHandle.key() << " with range " <<
57  writeHandle.getRange() << " into Conditions Store");
58 
59 
60  return StatusCode::SUCCESS;
61 }
62