ATLAS Offline Software
MuonPatternCombinationDetailedTrackTruthMaker.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 // Algorithm producing truth info for PrepRawData, keeping all MC particles contributed to a PRD.
6 // A. Gaponenko, 2006
7 
9 
10 #include <iterator>
11 
16 
17 //================================================================
19  ISvcLocator *pSvcLocator) :
20  AthAlgorithm(name, pSvcLocator) {
22 }
23 
24 // -----------------------------------------------------------------------------------------------------
26  ATH_MSG_DEBUG("MuonPatternCombinationDetailedTrackTruthMaker::initialize()");
27  ATH_CHECK(m_truthTool.retrieve());
28  return StatusCode::SUCCESS;
29 }
30 
31 // -----------------------------------------------------------------------------------------------------
33  ATH_MSG_DEBUG("MuonPatternCombinationDetailedTrackTruthMaker::execute()");
34 
35  StatusCode sc;
36 
37  //----------------------------------------------------------------
38  // Retrieve prep raw data truth
39  std::vector<const PRD_MultiTruthCollection *> prdCollectionVector;
40  for (std::vector<std::string>::const_iterator ikey = m_PRD_TruthNames.begin(); ikey != m_PRD_TruthNames.end(); ++ikey) {
41  prdCollectionVector.push_back(nullptr);
42  sc = evtStore()->retrieve(*prdCollectionVector.rbegin(), *ikey);
43  if (!sc.isSuccess()) {
44  ATH_MSG_WARNING("PRD_MultiTruthCollection " << *ikey << " NOT found");
45  } else {
46  ATH_MSG_DEBUG("Got PRD_MultiTruthCollection " << *ikey);
47  }
48  }
49 
50  //----------------------------------------------------------------
51  // Retrieve track collections
52 
53  const TrackCollection *tracks = nullptr;
54  if (evtStore()->contains<TrackCollection>(m_trackCollectionName) && evtStore()->retrieve(tracks, m_trackCollectionName).isSuccess()) {
55  ATH_MSG_DEBUG("Got TrackCollection " << m_trackCollectionName);
56  } else {
57  ATH_MSG_VERBOSE("TrackCollection " << m_trackCollectionName << " NOT found");
58  return StatusCode::FAILURE;
59  }
60 
61  const MuonPatternCombinationCollection *muPatternCombinations = nullptr;
62  if (evtStore()->contains<MuonPatternCombinationCollection>(m_collection) &&
63  evtStore()->retrieve(muPatternCombinations, m_collection).isSuccess()) {
64  ATH_MSG_DEBUG("Got MuonPatternCombinationCollection " << m_collection);
65  } else {
66  ATH_MSG_VERBOSE("MuonpatternCombinationCollection " << m_collection << " NOT found");
67  return StatusCode::FAILURE;
68  }
69 
70  //----------------------------------------------------------------
71  // Produce and store the output.
72 
73  // DetailedTrackTruthCollection *dttc = new DetailedTrackTruthCollection(tracks);
74  // m_truthTool->buildDetailedTrackTruth(dttc, *tracks, prdCollectionVector);
75 
76  //(DetailedMuonPatternTruthCollection *output, const MuonPatternCombinationCollection& tracks, const std::vector<const
77  // PRD_MultiTruthCollection*>& prdTruth);
78 
80  m_truthTool->buildDetailedMuonPatternTruth(dmptc, *muPatternCombinations, prdCollectionVector);
81 
82  sc = evtStore()->record(dmptc, m_detailedTrackTruthName);
83  if (sc.isFailure()) {
84  ATH_MSG_WARNING("DetailedMuonPatternTrackTruthCollection '" << m_detailedTrackTruthName
85  << "' could not be registered in StoreGate !");
86  return StatusCode::SUCCESS;
87  } else {
88  ATH_MSG_DEBUG("DetailedMuonPatternTrackTruthCollection '" << m_detailedTrackTruthName
89  << "' is registered in StoreGate, size=" << dmptc->size());
90  std::cout << "Debug 7.0: DetailedTrackTruthCollection is registered in storegate." << std::endl;
91  }
92 
93  return StatusCode::SUCCESS;
94 }
95 
96 //================================================================
97 // EOF
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
DetailedMuonPatternTruthCollection
Definition: DetailedMuonPatternTruthCollection.h:21
DetailedMuonPatternTruthCollection.h
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
MuonPatternCombinationDetailedTrackTruthMaker::execute
virtual StatusCode execute()
Definition: MuonPatternCombinationDetailedTrackTruthMaker.cxx:32
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
MuonPatternCombinationDetailedTrackTruthMaker::initialize
virtual StatusCode initialize()
Definition: MuonPatternCombinationDetailedTrackTruthMaker.cxx:25
DetailedTrackTruthCollection.h
MuonPatternCombinationDetailedTrackTruthMaker::m_collection
Gaudi::Property< std::string > m_collection
Definition: MuonPatternCombinationDetailedTrackTruthMaker.h:35
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TrackCollection.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector< Trk::Track >
AthAlgorithm
Definition: AthAlgorithm.h:47
MuonPatternCombinationDetailedTrackTruthMaker::m_trackCollectionName
Gaudi::Property< std::string > m_trackCollectionName
Definition: MuonPatternCombinationDetailedTrackTruthMaker.h:33
MuonPatternCombinationDetailedTrackTruthMaker.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
MuonPatternCombinationDetailedTrackTruthMaker::MuonPatternCombinationDetailedTrackTruthMaker
MuonPatternCombinationDetailedTrackTruthMaker(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MuonPatternCombinationDetailedTrackTruthMaker.cxx:18
MuonPatternCombinationDetailedTrackTruthMaker::m_truthTool
ToolHandle< Trk::IDetailedMuonPatternTruthBuilder > m_truthTool
Definition: MuonPatternCombinationDetailedTrackTruthMaker.h:40
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
MuonPatternCombinationDetailedTrackTruthMaker::m_detailedTrackTruthName
Gaudi::Property< std::string > m_detailedTrackTruthName
Definition: MuonPatternCombinationDetailedTrackTruthMaker.h:38
PRD_MultiTruthCollection.h
MuonPatternCombinationDetailedTrackTruthMaker::m_PRD_TruthNames
Gaudi::Property< std::vector< std::string > > m_PRD_TruthNames
Definition: MuonPatternCombinationDetailedTrackTruthMaker.h:30