ATLAS Offline Software
CondWriterExtAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "CondWriterExtAlg.h"
6 
7 #include "StoreGate/ReadHandle.h"
8 
9 #include <stdlib.h>
10 
11 namespace DMTest {
12 
13 CondWriterExtAlg::CondWriterExtAlg(const std::string& name, ISvcLocator* pSvcLocator) :
14  AthAlgorithm(name, pSvcLocator),
15  m_iovSvc("IOVSvc", name)
16 {
17 }
18 
20 {
21  ATH_CHECK( m_iovSvc.retrieve() );
22 
23  return StatusCode::SUCCESS;
24 }
25 
27 {
28  const EventContext& context = getContext();
29  ATH_MSG_INFO ("Event " << context.eventID().event_number() <<
30  " LBN " << context.eventID().lumi_block());
31 
32  // Check if we need to execute a command
33  auto it = m_cmd.find(context.eventID().lumi_block());
34  if (it != m_cmd.end()) {
35  ATH_MSG_INFO("Executing: " << it->second);
36  if ( system(it->second.c_str()) != 0 ) {
37  ATH_MSG_ERROR("Error executing command");
38  return StatusCode::FAILURE;
39  }
40  // Remove this command
41  m_cmd.erase(it);
42 
43  ATH_MSG_INFO("Resetting and dropping payload of folder " << m_attrListKey.value());
44 
45  ATH_CHECK( m_iovSvc->dropObjectFromDB(detStore()->clid(m_attrListKey), m_attrListKey, "StoreGateSvc") );
46  }
47 
48  return StatusCode::SUCCESS;
49 }
50 
51 } // namespace DMTest
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
DMTest::CondWriterExtAlg::m_cmd
Gaudi::Property< std::map< int, std::string > > m_cmd
Definition: CondWriterExtAlg.h:30
skel.it
it
Definition: skel.GENtoEVGEN.py:396
DMTest::CondWriterExtAlg::m_iovSvc
ServiceHandle< IIOVSvc > m_iovSvc
Definition: CondWriterExtAlg.h:32
DMTest::CondWriterExtAlg::initialize
virtual StatusCode initialize() override
Definition: CondWriterExtAlg.cxx:19
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
CondWriterExtAlg.h
DMTest::CondWriterExtAlg::m_attrListKey
Gaudi::Property< std::string > m_attrListKey
Definition: CondWriterExtAlg.h:29
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
DMTest::CondWriterExtAlg::CondWriterExtAlg
CondWriterExtAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: CondWriterExtAlg.cxx:13
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthAlgorithm
Definition: AthAlgorithm.h:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ReadHandle.h
Handle class for reading from StoreGate.
DMTest::CondWriterExtAlg::execute
virtual StatusCode execute() override
Definition: CondWriterExtAlg.cxx:26
DMTest
Definition: B.h:23