LArPseudoLayerPlugin.cc
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArPlugins/LArPseudoLayerPlugin.cxx
3  *
4  * @brief Implementation of the LAr pseudo layer Plugin class.
5  *
6  * $Log: $
7  */
8 
9 #include "Geometry/LArTPC.h"
10 
11 #include "Helpers/XmlHelper.h"
12 
13 #include "Managers/GeometryManager.h"
14 
15 #include "Pandora/Pandora.h"
16 #include "Pandora/PandoraInputTypes.h"
17 
19 
20 #include <limits>
21 
22 namespace lar_content
23 {
24 
25 using namespace pandora;
26 
27 LArPseudoLayerPlugin::LArPseudoLayerPlugin() : m_zPitch(std::numeric_limits<float>::max()), m_zOffset(0.01f), m_zerothLayer(5000)
28 {
29 }
30 
31 //------------------------------------------------------------------------------------------------------------------------------------------
32 
33 unsigned int LArPseudoLayerPlugin::GetPseudoLayer(const pandora::CartesianVector &positionVector) const
34 {
35  const float zLayer((positionVector.GetZ() + m_zOffset) / m_zPitch + static_cast<float>(m_zerothLayer));
36 
37  if (zLayer < std::numeric_limits<float>::epsilon())
38  throw StatusCodeException(STATUS_CODE_FAILURE);
39 
40  return static_cast<unsigned int>(zLayer);
41 }
42 
43 //------------------------------------------------------------------------------------------------------------------------------------------
44 
46 {
47  const LArTPCMap &larTPCMap(this->GetPandora().GetGeometry()->GetLArTPCMap());
48 
49  if (larTPCMap.empty())
50  {
51  std::cout << "LArPseudoLayerPlugin::Initialize - LArTPC description not registered with Pandora as required " << std::endl;
52  return STATUS_CODE_NOT_INITIALIZED;
53  }
54 
55  const LArTPC *const pFirstLArTPC(larTPCMap.begin()->second);
56  m_zPitch = pFirstLArTPC->GetWirePitchW();
57 
58  for (const LArTPCMap::value_type &mapEntry : larTPCMap)
59  {
60  const LArTPC *const pLArTPC(mapEntry.second);
61 
62  if (std::fabs(m_zPitch - pLArTPC->GetWirePitchW()) > std::numeric_limits<float>::epsilon())
63  {
64  std::cout << "LArPseudoLayerPlugin::Initialize - Plugin does not support provided LArTPC configurations " << std::endl;
65  return STATUS_CODE_INVALID_PARAMETER;
66  }
67  }
68 
69  return STATUS_CODE_SUCCESS;
70 }
71 
72 //------------------------------------------------------------------------------------------------------------------------------------------
73 
74 pandora::StatusCode LArPseudoLayerPlugin::ReadSettings(const pandora::TiXmlHandle /*xmlHandle*/)
75 {
76  return STATUS_CODE_SUCCESS;
77 }
78 
79 } // namespace lar_content
unsigned int m_zerothLayer
The zeroth layer.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
STL namespace.
unsigned int GetPseudoLayer(const pandora::CartesianVector &positionVector) const
static int max(int a, int b)
Header file for the lar pseudo layer plugin class.
QTextStream & endl(QTextStream &s)
GeomAnalyzerI * GetGeometry(void)
Definition: gAtmoEvGen.cxx:433