ATLAS Offline Software
RenameHitCollectionsAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
8 ISF::RenameHitCollectionsAlg::RenameHitCollectionsAlg( const std::string& name, ISvcLocator* pSvcLocator ) :
9  ::AthReentrantAlgorithm( name, pSvcLocator )
10 {
11 }
12 
13 
16 {
17  ATH_CHECK( initializeVarHandleKey(m_inputMcEventCollection ) );
18  ATH_CHECK( initializeVarHandleKey(m_inputBCMHits ) );
19  ATH_CHECK( initializeVarHandleKey(m_inputBLMHits ) );
20  ATH_CHECK( initializeVarHandleKey(m_inputPixelHits ) );
21  ATH_CHECK( initializeVarHandleKey(m_inputSCTHits ) );
22  ATH_CHECK( initializeVarHandleKey(m_inputTRTUncompressedHits) );
23 
24  ATH_CHECK( initializeVarHandleKey(m_inputLArEMBHits ) );
25  ATH_CHECK( initializeVarHandleKey(m_inputLArEMECHits ) );
26  ATH_CHECK( initializeVarHandleKey(m_inputLArFCALHits ) );
27  ATH_CHECK( initializeVarHandleKey(m_inputLArHECHits ) );
28  ATH_CHECK( initializeVarHandleKey(m_inputLArActiveCalibHits ) );
29  ATH_CHECK( initializeVarHandleKey(m_inputLArInactiveCalibHits ) );
30  ATH_CHECK( initializeVarHandleKey(m_inputLArDeadCalibHits ) );
31 
32  ATH_CHECK( initializeVarHandleKey(m_inputTileHits ) );
33  ATH_CHECK( initializeVarHandleKey(m_inputMBTSHits ) );
34  ATH_CHECK( initializeVarHandleKey(m_inputTileActiveCalibHits ) );
35  ATH_CHECK( initializeVarHandleKey(m_inputTileInactiveCalibHits ) );
36  ATH_CHECK( initializeVarHandleKey(m_inputTileDeadCalibHits ) );
37 
38  ATH_CHECK( initializeVarHandleKey(m_inputCSCHits ) );
39  ATH_CHECK( initializeVarHandleKey(m_inputMDTHits ) );
40  ATH_CHECK( initializeVarHandleKey(m_inputRPCHits ) );
41  ATH_CHECK( initializeVarHandleKey(m_inputTGCHits ) );
42  ATH_CHECK( initializeVarHandleKey(m_inputMMHits ) );
43  ATH_CHECK( initializeVarHandleKey(m_inputsTGCHits ) );
44 
45  ATH_CHECK( initializeVarHandleKey(m_inputITkPixelHits ) );
46  ATH_CHECK( initializeVarHandleKey(m_inputITkStripHits ) );
47  ATH_CHECK( initializeVarHandleKey(m_inputHGTDHits) );
48 
49  ATH_CHECK( initializeVarHandleKey(m_inputCaloEntryLayer ) );
50  ATH_CHECK( initializeVarHandleKey(m_inputMuonEntryLayer) );
51  ATH_CHECK( initializeVarHandleKey(m_inputMuonExitLayer ) );
52 
53  ATH_CHECK( initializeVarHandleKey(m_outputMcEventCollection ) );
54  ATH_CHECK( initializeVarHandleKey(m_outputBCMHits ) );
55  ATH_CHECK( initializeVarHandleKey(m_outputBLMHits ) );
56  ATH_CHECK( initializeVarHandleKey(m_outputPixelHits ) );
57  ATH_CHECK( initializeVarHandleKey(m_outputSCTHits ) );
58  ATH_CHECK( initializeVarHandleKey(m_outputTRTUncompressedHits) );
59 
60  ATH_CHECK( initializeVarHandleKey(m_outputLArEMBHits ) );
61  ATH_CHECK( initializeVarHandleKey(m_outputLArEMECHits ) );
62  ATH_CHECK( initializeVarHandleKey(m_outputLArFCALHits ) );
63  ATH_CHECK( initializeVarHandleKey(m_outputLArHECHits ) );
64  ATH_CHECK( initializeVarHandleKey(m_outputLArActiveCalibHits ) );
65  ATH_CHECK( initializeVarHandleKey(m_outputLArInactiveCalibHits ) );
66  ATH_CHECK( initializeVarHandleKey(m_outputLArDeadCalibHits ) );
67 
68  ATH_CHECK( initializeVarHandleKey(m_outputTileHits ) );
69  ATH_CHECK( initializeVarHandleKey(m_outputMBTSHits ) );
70  ATH_CHECK( initializeVarHandleKey(m_outputTileActiveCalibHits ) );
71  ATH_CHECK( initializeVarHandleKey(m_outputTileInactiveCalibHits ) );
72  ATH_CHECK( initializeVarHandleKey(m_outputTileDeadCalibHits ) );
73 
74  ATH_CHECK( initializeVarHandleKey(m_outputCSCHits ) );
75  ATH_CHECK( initializeVarHandleKey(m_outputMDTHits ) );
76  ATH_CHECK( initializeVarHandleKey(m_outputRPCHits ) );
77  ATH_CHECK( initializeVarHandleKey(m_outputTGCHits ) );
78  ATH_CHECK( initializeVarHandleKey(m_outputMMHits ) );
79  ATH_CHECK( initializeVarHandleKey(m_outputsTGCHits ) );
80 
81  ATH_CHECK( initializeVarHandleKey(m_outputITkPixelHits ) );
82  ATH_CHECK( initializeVarHandleKey(m_outputITkStripHits ) );
83  ATH_CHECK( initializeVarHandleKey(m_outputHGTDHits) );
84 
85  ATH_CHECK( initializeVarHandleKey(m_outputCaloEntryLayer ) );
86  ATH_CHECK( initializeVarHandleKey(m_outputMuonEntryLayer) );
87  ATH_CHECK( initializeVarHandleKey(m_outputMuonExitLayer ) );
88 
89  return StatusCode::SUCCESS;
90 }
91 
92 
94 StatusCode ISF::RenameHitCollectionsAlg::execute(const EventContext &ctx) const
95 {
96  SG::ReadHandle<McEventCollection> inputMcEventCollection(m_inputMcEventCollection, ctx);
97  if (!inputMcEventCollection.isValid()) {
98  ATH_MSG_ERROR("Could not find input McEventCollection called " << inputMcEventCollection.name() << " in store " << inputMcEventCollection.store() << ".");
99  return StatusCode::FAILURE;
100  }
101  SG::WriteHandle<McEventCollection> outputMcEventCollection(m_outputMcEventCollection, ctx);
102  ATH_CHECK(outputMcEventCollection.record(std::make_unique<McEventCollection>(*inputMcEventCollection)));
103  if (!outputMcEventCollection.isValid()) {
104  ATH_MSG_ERROR("Could not record output McEventCollection called " << outputMcEventCollection.name() << " in store " << outputMcEventCollection.store() << ".");
105  return StatusCode::FAILURE;
106  }
107 
108  ATH_CHECK(copyCollections( m_inputBCMHits, m_outputBCMHits , ctx ));
109  ATH_CHECK(copyCollections( m_inputBLMHits, m_outputBLMHits , ctx ));
110  ATH_CHECK(copyCollections( m_inputPixelHits, m_outputPixelHits , ctx ));
111  ATH_CHECK(copyCollections( m_inputSCTHits, m_outputSCTHits , ctx ));
112  ATH_CHECK(copyCollections( m_inputTRTUncompressedHits, m_outputTRTUncompressedHits , ctx ));
113 
114  ATH_CHECK(copyCollections( m_inputLArEMBHits, m_outputLArEMBHits , ctx ));
115  ATH_CHECK(copyCollections( m_inputLArEMECHits, m_outputLArEMECHits , ctx ));
116  ATH_CHECK(copyCollections( m_inputLArFCALHits, m_outputLArFCALHits , ctx ));
117  ATH_CHECK(copyCollections( m_inputLArHECHits, m_outputLArHECHits , ctx ));
118  ATH_CHECK(copyCollections( m_inputLArActiveCalibHits, m_outputLArActiveCalibHits , ctx ));
119  ATH_CHECK(copyCollections( m_inputLArInactiveCalibHits,m_outputLArInactiveCalibHits, ctx ));
120  ATH_CHECK(copyCollections( m_inputLArDeadCalibHits, m_outputLArDeadCalibHits , ctx ));
121 
122  ATH_CHECK(copyCollections( m_inputTileHits, m_outputTileHits , ctx ));
123  ATH_CHECK(copyCollections( m_inputMBTSHits, m_outputMBTSHits , ctx ));
124  ATH_CHECK(copyCollections( m_inputTileActiveCalibHits, m_outputTileActiveCalibHits , ctx ));
125  ATH_CHECK(copyCollections( m_inputTileInactiveCalibHits,m_outputTileInactiveCalibHits, ctx ));
126  ATH_CHECK(copyCollections( m_inputTileDeadCalibHits, m_outputTileDeadCalibHits , ctx ));
127 
128  ATH_CHECK(copyCollections( m_inputCSCHits, m_outputCSCHits , ctx ));
129  ATH_CHECK(copyCollections( m_inputMDTHits, m_outputMDTHits , ctx ));
130  ATH_CHECK(copyCollections( m_inputRPCHits, m_outputRPCHits , ctx ));
131  ATH_CHECK(copyCollections( m_inputTGCHits, m_outputTGCHits , ctx ));
132  ATH_CHECK(copyCollections( m_inputMMHits, m_outputMMHits , ctx ));
133  ATH_CHECK(copyCollections( m_inputsTGCHits, m_outputsTGCHits , ctx ));
134 
135  ATH_CHECK(copyCollections( m_inputITkPixelHits, m_outputITkPixelHits , ctx ));
136  ATH_CHECK(copyCollections( m_inputITkStripHits, m_outputITkStripHits , ctx ));
137  ATH_CHECK(copyCollections( m_inputHGTDHits, m_outputHGTDHits , ctx ));
138 
139  ATH_CHECK(copyCollections(m_inputCaloEntryLayer ,m_outputCaloEntryLayer , ctx ));
140  ATH_CHECK(copyCollections(m_inputMuonEntryLayer,m_outputMuonEntryLayer, ctx ));
141  ATH_CHECK(copyCollections(m_inputMuonExitLayer ,m_outputMuonExitLayer , ctx ));
142 
143 
144 
145  return StatusCode::SUCCESS;
146 }
147 
148 
151  if ( varHandleKey.key().empty() )
152  return StatusCode::SUCCESS;
153 
154  return varHandleKey.initialize();
155 }
SG::ReadHandle< McEventCollection >
SG::VarHandleBase::name
const std::string & name() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:75
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
ISF::RenameHitCollectionsAlg::RenameHitCollectionsAlg
RenameHitCollectionsAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: RenameHitCollectionsAlg.cxx:8
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
SG::VarHandleBase::store
std::string store() const
Return the name of the store holding the object we are proxying.
Definition: StoreGate/src/VarHandleBase.cxx:376
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
ISF::RenameHitCollectionsAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Athena Algorithm execute.
Definition: RenameHitCollectionsAlg.cxx:94
SG::WriteHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ISF::RenameHitCollectionsAlg::initializeVarHandleKey
StatusCode initializeVarHandleKey(SG::VarHandleKey &varHandleKey) const
Initialize the given VarHandleKey.
Definition: RenameHitCollectionsAlg.cxx:150
SG::VarHandleKey
A property holding a SG store/key/clid from which a VarHandle is made.
Definition: StoreGate/StoreGate/VarHandleKey.h:62
SG::WriteHandle< McEventCollection >
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
RenameHitCollectionsAlg.h
ISF::RenameHitCollectionsAlg::initialize
virtual StatusCode initialize() override final
Athena algorithm's interface methods.
Definition: RenameHitCollectionsAlg.cxx:15