ATLAS Offline Software
Loading...
Searching...
No Matches
RenameHitCollectionsAlg.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef ISF_ALGORITHMS_RENAMEHITCOLLECTIONSALG_H
6#define ISF_ALGORITHMS_RENAMEHITCOLLECTIONSALG_H 1
7
8// STL includes
9#include <string>
10#include <memory>
11#include <type_traits>
12
13// Framework includes
17
22
23// SimHit EDM includes
24// InnerDetector
27// Calorimeter
30// Muon Spectrometer
37
38// forward declarations
39namespace ISFTesting {
40 class RenameHitCollectionsAlg_test;
41}
42
43
44namespace ISF {
45
53
56
57 public:
59 RenameHitCollectionsAlg( const std::string& name, ISvcLocator* pSvcLocator );
60
62 virtual ~RenameHitCollectionsAlg() = default;
63
65 virtual StatusCode initialize() override final;
66 virtual StatusCode execute(const EventContext &ctx) const override final;
67
68 private:
70 StatusCode initializeVarHandleKey( SG::VarHandleKey& varHandleKey ) const;
71
73 template <typename T>
74 StatusCode copyCollections( const SG::ReadHandleKey<T>& inputReadHandleKeys,
75 const SG::WriteHandleKey<T>& outputWriteHandleKey, const EventContext &ctx) const;
76
78 template <typename HitType_t, typename OutputType_t>
79 void insertCopy(const HitType_t& hit, OutputType_t& outputHandle) const;
80
83 template <typename HitType_t, typename OutputType_t>
84 void insertCopy(HitType_t * const hit, OutputType_t& outputHandle) const;
85
86
88 SG::ReadHandleKey<McEventCollection> m_inputMcEventCollection {this, "InputMcEventCollection", "", "Input truth collection name"};
94
95 SG::ReadHandleKey<LArHitContainer> m_inputLArEMBHits{this, "InputLArEMBHits", "", ""};
96 SG::ReadHandleKey<LArHitContainer> m_inputLArEMECHits{this, "InputLArEMECHits", "", ""};
97 SG::ReadHandleKey<LArHitContainer> m_inputLArFCALHits{this, "InputLArFCALHits", "", ""};
98 SG::ReadHandleKey<LArHitContainer> m_inputLArHECHits{this, "InputLArHECHits", "", ""};
102
103 SG::ReadHandleKey<TileHitVector> m_inputTileHits{this, "InputTileHits", "", ""};
104 SG::ReadHandleKey<TileHitVector> m_inputMBTSHits{this, "InputMBTSHits", "", ""};
108
113 SG::ReadHandleKey<MMSimHitCollection> m_inputMMHits{this, "InputMMHits", "", "Input MM hits name"};
114 SG::ReadHandleKey<sTGCSimHitCollection> m_inputsTGCHits{this, "InputsTGCHits", "", "Input TGC hits name"};
115
116 // Phase 2 Upgrade HitCollections
117 SG::ReadHandleKey<SiHitCollection> m_inputITkPixelHits{this, "InputITkPixelHits", "", ""};
118 SG::ReadHandleKey<SiHitCollection> m_inputITkStripHits{this, "InputITkStripHits", "", ""};
120
124
126 SG::WriteHandleKey<McEventCollection> m_outputMcEventCollection{this, "OutputMcEventCollection", "", ""};
132
140
146
151 SG::WriteHandleKey<MMSimHitCollection> m_outputMMHits{this, "OutputMMHits", "", "Output MM hits name"};
152 SG::WriteHandleKey<sTGCSimHitCollection> m_outputsTGCHits{this, "OutputsTGCHits", "", "Output sTGC hits name"};
153
154 // Phase 2 Upgrade HitCollections
158
162 };
163
164
165 //
166 // templated methods below
167 //
168
170 template <typename T>
171 inline StatusCode ISF::RenameHitCollectionsAlg::copyCollections( const SG::ReadHandleKey<T>& inputReadHandleKey,
172 const SG::WriteHandleKey<T>& outputWriteHandleKey, const EventContext &ctx ) const {
173 // skip if not input collection
174 if ( inputReadHandleKey.key().empty() ) {
175 return StatusCode::SUCCESS;
176 }
177 // TODO: is there a way to conveniently get the total number of hits in all inputReadHandleKeys
178 // and reserve the corresponding size in the outputHandle
179 SG::WriteHandle<T> outputHandle{outputWriteHandleKey, ctx};
180 ATH_CHECK( outputHandle.record(std::make_unique<T>()) );
181
182 SG::ReadHandle<T> inputHandle{inputReadHandleKey, ctx};
183 for ( const auto& hit: *inputHandle ) {
184 this->insertCopy(hit, outputHandle);
185 }
186
187 return StatusCode::SUCCESS;
188 }
189
190
191 template <>
193 const SG::WriteHandleKey<LArHitContainer>& outputWriteHandleKey, const EventContext &ctx ) const {
194 // skip if not input collection
195 if ( inputReadHandleKey.key().empty() ) {
196 return StatusCode::SUCCESS;
197 }
198 // TODO: is there a way to conveniently get the total number of hits in all inputReadHandleKeys
199 // and reserve the corresponding size in the outputHandle
200 SG::WriteHandle<LArHitContainer> outputHandle{outputWriteHandleKey, ctx};
201 ATH_CHECK( outputHandle.record(std::make_unique<LArHitContainer>()) );
202
203 SG::ReadHandle<LArHitContainer> inputHandle{inputReadHandleKey, ctx};
204 for ( const LArHit* hit: *inputHandle ) {
205 this->insertCopy(hit, outputHandle);
206 }
207 outputHandle->setName(inputHandle->Name());
208
209 return StatusCode::SUCCESS;
210 }
211
212
213 template <>
215 const SG::WriteHandleKey<TileHitVector>& outputWriteHandleKey, const EventContext &ctx ) const {
216 // skip if not input collection
217 if ( inputReadHandleKey.key().empty() ) {
218 return StatusCode::SUCCESS;
219 }
220 // TODO: is there a way to conveniently get the total number of hits in all inputReadHandleKeys
221 // and reserve the corresponding size in the outputHandle
222 SG::WriteHandle<TileHitVector> outputHandle{outputWriteHandleKey, ctx};
223 ATH_CHECK( outputHandle.record(std::make_unique<TileHitVector>()) );
224
225 SG::ReadHandle<TileHitVector> inputHandle{inputReadHandleKey, ctx};
226 for ( const auto& hit: *inputHandle ) {
227 this->insertCopy(hit, outputHandle);
228 }
229 outputHandle->setName(inputHandle->Name());
230
231 return StatusCode::SUCCESS;
232 }
233
234
235 template <>
237 const SG::WriteHandleKey<TrackRecordCollection>& outputWriteHandleKey, const EventContext &ctx ) const {
238 // skip if not input collection
239 if ( inputReadHandleKey.key().empty() ) {
240 return StatusCode::SUCCESS;
241 }
242 // TODO: is there a way to conveniently get the total number of hits in all inputReadHandleKeys
243 // and reserve the corresponding size in the outputHandle
244 SG::WriteHandle<TrackRecordCollection> outputHandle{outputWriteHandleKey, ctx};
245 ATH_CHECK( outputHandle.record(std::make_unique<TrackRecordCollection>()) );
246
247 SG::ReadHandle<TrackRecordCollection> inputHandle{inputReadHandleKey, ctx};
248 for ( const auto& hit: *inputHandle ) {
249 this->insertCopy(hit, outputHandle);
250 }
251 outputHandle->setName(inputHandle->Name());
252
253 return StatusCode::SUCCESS;
254 }
255
256
258 template <typename HitType_t, typename OutputType_t>
259 inline void ISF::RenameHitCollectionsAlg::insertCopy(const HitType_t& hit,
260 OutputType_t& outputHandle) const {
261 static_assert(!std::is_pointer<HitType_t>::value,
262 "The hit provided to ISF::RenameHitCollectionsAlg::insertCopy(..) must not be a pointer!");
263 outputHandle->Emplace( hit );
264 }
265
266
268 template <typename HitType_t, typename OutputType_t>
269 inline void ISF::RenameHitCollectionsAlg::insertCopy(HitType_t * const hit,
270 OutputType_t& outputHandle) const {
271 auto&& hitCopy = std::make_unique<std::remove_const_t<HitType_t> >(*hit);
272 outputHandle->push_back( hitCopy.release() );
273 }
274
275
276}
277
278#endif //> !ISF_ALGORITHMS_RENAMEHITCOLLECTIONSALG_H
#define ATH_CHECK
Evaluate an expression and check for errors.
Property holding a SG store/key/clid from which a ReadHandle is made.
Property holding a SG store/key/clid from which a WriteHandle is made.
An algorithm that can be simultaneously executed in multiple threads.
SG::WriteHandleKey< CSCSimHitCollection > m_outputCSCHits
SG::WriteHandleKey< CaloCalibrationHitContainer > m_outputTileActiveCalibHits
SG::ReadHandleKey< MDTSimHitCollection > m_inputMDTHits
SG::WriteHandleKey< CaloCalibrationHitContainer > m_outputTileDeadCalibHits
SG::WriteHandleKey< SiHitCollection > m_outputSCTHits
SG::WriteHandleKey< TrackRecordCollection > m_outputMuonEntryLayer
SG::WriteHandleKey< CaloCalibrationHitContainer > m_outputTileInactiveCalibHits
SG::ReadHandleKey< TrackRecordCollection > m_inputMuonExitLayer
SG::ReadHandleKey< SiHitCollection > m_inputITkStripHits
SG::ReadHandleKey< CaloCalibrationHitContainer > m_inputTileActiveCalibHits
SG::ReadHandleKey< SiHitCollection > m_inputITkPixelHits
SG::WriteHandleKey< LArHitContainer > m_outputLArFCALHits
virtual StatusCode initialize() override final
Athena algorithm's interface methods.
RenameHitCollectionsAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
SG::ReadHandleKey< CaloCalibrationHitContainer > m_inputTileInactiveCalibHits
SG::WriteHandleKey< TGCSimHitCollection > m_outputTGCHits
SG::WriteHandleKey< SiHitCollection > m_outputBLMHits
SG::WriteHandleKey< SiHitCollection > m_outputITkStripHits
SG::ReadHandleKey< CaloCalibrationHitContainer > m_inputTileDeadCalibHits
SG::ReadHandleKey< TRTUncompressedHitCollection > m_inputTRTUncompressedHits
SG::WriteHandleKey< TileHitVector > m_outputMBTSHits
void insertCopy(const HitType_t &hit, OutputType_t &outputHandle) const
Copy the given hit into the given output collection, container or DataHandle.
SG::WriteHandleKey< MMSimHitCollection > m_outputMMHits
SG::ReadHandleKey< LArHitContainer > m_inputLArEMECHits
SG::ReadHandleKey< SiHitCollection > m_inputPixelHits
SG::WriteHandleKey< TrackRecordCollection > m_outputCaloEntryLayer
SG::ReadHandleKey< sTGCSimHitCollection > m_inputsTGCHits
SG::ReadHandleKey< TrackRecordCollection > m_inputCaloEntryLayer
SG::ReadHandleKey< RPCSimHitCollection > m_inputRPCHits
SG::ReadHandleKey< TrackRecordCollection > m_inputMuonEntryLayer
SG::WriteHandleKey< SiHitCollection > m_outputPixelHits
SG::WriteHandleKey< RPCSimHitCollection > m_outputRPCHits
SG::WriteHandleKey< McEventCollection > m_outputMcEventCollection
Output collection WriteHandleKeys.
SG::ReadHandleKey< TileHitVector > m_inputTileHits
SG::ReadHandleKey< CaloCalibrationHitContainer > m_inputLArDeadCalibHits
SG::WriteHandleKey< CaloCalibrationHitContainer > m_outputLArActiveCalibHits
SG::ReadHandleKey< TileHitVector > m_inputMBTSHits
SG::WriteHandleKey< LArHitContainer > m_outputLArEMECHits
SG::ReadHandleKey< McEventCollection > m_inputMcEventCollection
Input collection ReadHandleKeys.
virtual StatusCode execute(const EventContext &ctx) const override final
Athena Algorithm execute.
SG::ReadHandleKey< CSCSimHitCollection > m_inputCSCHits
SG::WriteHandleKey< CaloCalibrationHitContainer > m_outputLArInactiveCalibHits
SG::ReadHandleKey< SiHitCollection > m_inputSCTHits
SG::ReadHandleKey< MMSimHitCollection > m_inputMMHits
SG::ReadHandleKey< TGCSimHitCollection > m_inputTGCHits
SG::WriteHandleKey< TRTUncompressedHitCollection > m_outputTRTUncompressedHits
SG::ReadHandleKey< SiHitCollection > m_inputBLMHits
SG::WriteHandleKey< TileHitVector > m_outputTileHits
SG::ReadHandleKey< CaloCalibrationHitContainer > m_inputLArInactiveCalibHits
SG::WriteHandleKey< sTGCSimHitCollection > m_outputsTGCHits
SG::WriteHandleKey< LArHitContainer > m_outputLArHECHits
SG::ReadHandleKey< SiHitCollection > m_inputBCMHits
StatusCode initializeVarHandleKey(SG::VarHandleKey &varHandleKey) const
Initialize the given VarHandleKey.
SG::WriteHandleKey< LArHitContainer > m_outputLArEMBHits
SG::ReadHandleKey< LArHitContainer > m_inputLArHECHits
SG::WriteHandleKey< CaloCalibrationHitContainer > m_outputLArDeadCalibHits
SG::ReadHandleKey< LArHitContainer > m_inputLArEMBHits
friend class ISFTesting::RenameHitCollectionsAlg_test
Allow the test class access to all methods.
StatusCode copyCollections(const SG::ReadHandleKey< T > &inputReadHandleKeys, const SG::WriteHandleKey< T > &outputWriteHandleKey, const EventContext &ctx) const
Merge all hits of inputReadHandleKeys's collections into outputWriteHandleKey.
virtual ~RenameHitCollectionsAlg()=default
Destructor.
SG::ReadHandleKey< CaloCalibrationHitContainer > m_inputLArActiveCalibHits
SG::ReadHandleKey< LArHitContainer > m_inputLArFCALHits
SG::WriteHandleKey< SiHitCollection > m_outputBCMHits
SG::ReadHandleKey< SiHitCollection > m_inputHGTDHits
SG::WriteHandleKey< MDTSimHitCollection > m_outputMDTHits
SG::WriteHandleKey< SiHitCollection > m_outputHGTDHits
SG::WriteHandleKey< TrackRecordCollection > m_outputMuonExitLayer
SG::WriteHandleKey< SiHitCollection > m_outputITkPixelHits
Class to store hit energy and time in LAr cell from G4 simulation.
Definition LArHit.h:25
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
Property holding a SG store/key/clid from which a ReadHandle is made.
const std::string & key() const
Return the StoreGate ID for the referenced object.
Property holding a SG store/key/clid from which a WriteHandle is made.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
Core Athena algorithm for the Integrated Simulation Framework.
ISFParticleOrderedQueue.
Forward declaration.
#define private