4 #include "Pandora/AlgorithmHeaders.h" 5 #include "Helpers/XmlHelper.h" 12 namespace gar_pandora {
14 PseudoLayerPlugin::PseudoLayerPlugin()
15 : m_barrelInnerR(0.
f),
34 catch (StatusCodeException &statusCodeException)
36 std::cout <<
"PseudoLayerPlugin: Incomplete geometry - consider using a different PseudoLayerCalculator." <<
std::endl;
37 return statusCodeException.GetStatusCode();
40 return STATUS_CODE_SUCCESS;
47 const float zCoordinate(std::fabs(positionVector.GetZ()));
52 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
60 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
63 unsigned int pseudoLayer;
68 if (STATUS_CODE_SUCCESS != statusCode)
69 throw StatusCodeException(statusCode);
72 return (1 + pseudoLayer);
78 const float zCorrection,
const float barrelInnerR,
const float endCapInnerZ,
unsigned int &pseudoLayer)
const 80 if (zCoordinate < endCapInnerZ)
84 else if (rCoordinate < barrelInnerR)
90 unsigned int bestBarrelLayer(0);
93 unsigned int bestEndCapLayer(0);
96 if ((STATUS_CODE_SUCCESS != barrelStatusCode) && (STATUS_CODE_SUCCESS != endCapStatusCode))
97 return STATUS_CODE_NOT_FOUND;
99 pseudoLayer =
std::max(bestBarrelLayer, bestEndCapLayer);
100 return STATUS_CODE_SUCCESS;
107 unsigned int &layer)
const 111 if (layerPositionList.end() == upperIter)
113 return STATUS_CODE_NOT_FOUND;
116 if (layerPositionList.begin() == upperIter)
119 return STATUS_CODE_SUCCESS;
124 if (std::fabs(position - *lowerIter) < std::fabs(position - *upperIter))
133 return STATUS_CODE_SUCCESS;
140 const GeometryManager *
const pGeometryManager(this->GetPandora().
GetGeometry());
146 std::cout <<
"PseudoLayerPlugin: No layer positions specified." <<
std::endl;
147 throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
158 std::cout <<
"PseudoLayerPlugin: Duplicate layer position detected." <<
std::endl;
159 throw StatusCodeException(STATUS_CODE_FAILURE);
167 if (!subDetector.IsMirroredInZ())
169 std::cout <<
"PseudoLayerPlugin: Error, detector must be symmetrical about z=0 plane." <<
std::endl;
170 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
173 const SubDetector::SubDetectorLayerVector &subDetectorLayerVector(subDetector.GetSubDetectorLayerVector());
177 layerPositionList.push_back(iter->GetClosestDistanceToIp());
185 const GeometryManager *
const pGeometryManager(this->GetPandora().
GetGeometry());
187 m_barrelEdgeR = pGeometryManager->GetSubDetector(ECAL_BARREL).GetOuterRCoordinate();
189 m_endCapEdgeZ = std::fabs(pGeometryManager->GetSubDetector(ECAL_ENDCAP).GetOuterZCoordinate());
193 std::cout <<
"PseudoLayerPlugin: Layers specified outside detector edge." <<
std::endl;
194 throw StatusCodeException(STATUS_CODE_FAILURE);
205 const GeometryManager *
const pGeometryManager(this->GetPandora().
GetGeometry());
207 this->
FillAngleVector(pGeometryManager->GetSubDetector(ECAL_BARREL).GetInnerSymmetryOrder(),
215 const GeometryManager *
const pGeometryManager(this->GetPandora().
GetGeometry());
217 m_barrelInnerR = pGeometryManager->GetSubDetector(ECAL_BARREL).GetInnerRCoordinate();
218 m_endCapInnerZ = std::fabs(pGeometryManager->GetSubDetector(ECAL_ENDCAP).GetInnerZCoordinate());
220 const float barrelOuterZ = std::fabs(pGeometryManager->GetSubDetector(ECAL_BARREL).GetOuterZCoordinate());
221 const float endCapOuterR = pGeometryManager->GetSubDetector(ECAL_ENDCAP).GetOuterRCoordinate();
232 if (angleVector.size() <= 2)
233 return std::sqrt((x * x) + (y *
y));
238 const float radius((x * iter->first) + (y * iter->second));
240 if (radius > maxRadius)
251 const float twoPi =
static_cast<float>(2. * std::acos(-1.));
254 for (
unsigned int iSymmetry = 0; iSymmetry < symmetryOrder; ++iSymmetry)
256 const float phi = phi0 + ((twoPi *
static_cast<float>(iSymmetry)) /
static_cast<float>(symmetryOrder));
257 angleVector.push_back(std::make_pair(std::cos(phi), std::sin(phi)));
265 return STATUS_CODE_SUCCESS;
void StoreLayerPositions()
Store all revelevant barrel and endcap layer positions upon initialization.
void StoreDetectorOuterEdge()
Store positions of barrel and endcap outer edges upon initialization.
float m_barrelEdgeR
Extremal barrel r coordinate.
LayerPositionList m_barrelLayerPositions
List of barrel layer positions.
std::vector< std::pair< float, float > > AngleVector
LayerPositionList m_endCapLayerPositions
List of endcap layer positions.
float m_endCapEdgeZ
Extremal endcap z coordinate.
pandora::StatusCode Initialize()
float m_endCapInnerZ
Endcap inner z position.
unsigned int GetPseudoLayer(const pandora::CartesianVector &positionVector) const
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
void StoreOverlapCorrectionDetails()
Store all details revelevant to barrel/endcap overlap corrections upon initialization.
static int max(int a, int b)
pandora::StatusCode FindMatchingLayer(const float position, const LayerPositionList &layerPositionList, unsigned int &layer) const
Find the layer number corresponding to a specified position, via reference to a specified layer posit...
void FillAngleVector(const unsigned int symmetryOrder, const float phi0, AngleVector &angleVector) const
Fill a vector with sine/cosine values for relevant polygon angles.
float m_zCorrection
Barrel/endcap overlap z correction.
General GArSoft Utilities.
float GetMaximumRadius(const AngleVector &angleVector, const float x, const float y) const
Get the maximum polygon radius, with reference to cached sine/cosine values for relevant polygon angl...
void StorePolygonAngles()
Store sine and cosine of angles used to project hit positions onto polygonal calorimeter surfaces upo...
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
float m_barrelInnerR
Barrel inner radius.
AngleVector m_eCalBarrelAngleVector
The ecal barrel angle vector.
#define MF_LOG_WARNING(category)
float m_rCorrection
Barrel/endcap overlap r correction.
std::vector< float > LayerPositionList
QTextStream & endl(QTextStream &s)
GeomAnalyzerI * GetGeometry(void)