LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
CheatingCosmicRayRemovalAlgorithm.cc
Go to the documentation of this file.
1 
9 #include "Pandora/AlgorithmHeaders.h"
10 #include "Helpers/MCParticleHelper.h"
11 
13 
15 
16 using namespace pandora;
17 
18 namespace lar_content
19 {
20 
21 StatusCode CheatingCosmicRayRemovalAlgorithm::Run()
22 {
23  const MCParticleList *pMCParticleList(nullptr);
24  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_mcParticleListName, pMCParticleList));
25 
26  const CaloHitList *pCaloHitList(nullptr);
27  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_inputCaloHitListName, pCaloHitList));
28 
29  CaloHitList outputCaloHitList;
30 
31  for (const CaloHit *pCaloHit : *pCaloHitList)
32  {
33  try
34  {
35  const MCParticle *const pMCParticle(MCParticleHelper::GetMainMCParticle(pCaloHit));
36  if (!LArMCParticleHelper::IsCosmicRay(LArMCParticleHelper::GetParentMCParticle(pMCParticle)))
37  outputCaloHitList.push_back(pCaloHit);
38  }
39  catch (const StatusCodeException &)
40  {
41  std::cout << "CheatingCosmicRayRemovalAlgorithm::Run - Unable to determine MCParticle origin for an input CaloHit, which will be skipped." << std::endl;
42  continue;
43  }
44  }
45 
46  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList(*this, outputCaloHitList, m_outputCaloHitListName));
47  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<CaloHit>(*this, m_outputCaloHitListName));
48 
49  return STATUS_CODE_SUCCESS;
50 }
51 
52 //------------------------------------------------------------------------------------------------------------------------------------------
53 
54 StatusCode CheatingCosmicRayRemovalAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
55 {
56  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputCaloHitListName", m_inputCaloHitListName));
57  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "MCParticleListName", m_mcParticleListName));
58  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "OutputCaloHitListName", m_outputCaloHitListName));
59 
60  return STATUS_CODE_SUCCESS;
61 }
62 
63 } // namespace lar_content
Header file for the cheating cosmic ray removal algorithm class.
Header file for the lar monte carlo particle helper helper class.