ATLAS Offline Software
Loading...
Searching...
No Matches
MuonDetailedTrackTruthMaker.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Algorithm producing truth info for PrepRawData, keeping all MC particles contributed to a PRD.
6// A. Gaponenko, 2006
7
9
10#include <iterator>
11#include <vector>
12
14 ATH_MSG_DEBUG("MuonDetailedTrackTruthMaker::initialize()");
15
16 if (m_PRD_TruthNames.empty()) {
17 ATH_MSG_FATAL("No PRD truth collections have been configured for processing");
18 return StatusCode::FAILURE;
19 }
20 //----------------
21 ATH_CHECK(m_truthTool.retrieve());
22 ATH_MSG_DEBUG("Retrieved tool " << m_truthTool);
23
25 for (unsigned int i = 0; i < m_trackCollectionNames.size(); i++) {
26 m_detailedTrackTruthNames.at(i)=m_trackCollectionNames.at(i).key() + "DetailedTruth";;
27 ATH_MSG_INFO("process " << m_trackCollectionNames.at(i).key() << " for detailed truth collection "
28 << m_detailedTrackTruthNames.at(i).key());
29 }
30
32 ATH_CHECK(m_PRD_TruthNames.initialize());
34
35 //----------------
36 return StatusCode::SUCCESS;
37}
38
39// -----------------------------------------------------------------------------------------------------
40StatusCode MuonDetailedTrackTruthMaker::execute(const EventContext& ctx) const {
41 ATH_MSG_DEBUG("MuonDetailedTrackTruthMaker::execute()");
42
43 //----------------------------------------------------------------
44 // Retrieve prep raw data truth
45 std::vector<const PRD_MultiTruthCollection*> prdCollectionVector;
46 for (const auto& truthKey : m_PRD_TruthNames){
47 prdCollectionVector.emplace_back(nullptr);
48 ATH_CHECK(SG::get(prdCollectionVector.back(), truthKey, ctx));
49 }
50
51 ATH_MSG_DEBUG("Loaded in total "<<prdCollectionVector.size()<<" prd truth collections");
52 //----------------------------------------------------------------
53 // Retrieve track collections
54
55 int i = 0;
56 for (const auto& trkKey : m_trackCollectionNames) {
57 const TrackCollection* tcol{nullptr};
58 ATH_CHECK(SG::get(tcol, trkKey, ctx));
59
60 //----------------------------------------------------------------
61 // Produce and store the output.
62
64 ATH_MSG_DEBUG("Write detailed collection "<<m_detailedTrackTruthNames.at(i).fullKey());
65 ATH_CHECK(dttc.record(std::make_unique<DetailedTrackTruthCollection>()));
66 dttc->setTrackCollection(tcol);
67 m_truthTool->buildDetailedTrackTruth(dttc.ptr(), *tcol, prdCollectionVector, ctx);
68 i++;
69 }
70 return StatusCode::SUCCESS;
71}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
DataVector< Trk::Track > TrackCollection
This typedef represents a collection of Trk::Track objects.
SG::WriteHandleKeyArray< DetailedTrackTruthCollection > m_detailedTrackTruthNames
ToolHandle< Trk::IDetailedTrackTruthBuilder > m_truthTool
virtual StatusCode initialize() override
SG::ReadHandleKeyArray< PRD_MultiTruthCollection > m_PRD_TruthNames
virtual StatusCode execute(const EventContext &ctx) const override
SG::ReadHandleKeyArray< TrackCollection > m_trackCollectionNames
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.