GeometryCreator.cxx
Go to the documentation of this file.
1 #include "GeometryCreator.h"
2 
3 #include "CoreUtils/ServiceUtil.h"
5 
6 #include <exception>
7 
8 namespace gar {
9  namespace gar_pandora {
10 
11  GeometryCreator::GeometryCreator(const Settings &settings, const pandora::Pandora *const pPandora)
12  : m_settings(settings),
13  m_pPandora(*pPandora)
14  {
15  fGeo = gar::providerFrom<geo::GeometryGAr>();
16  }
17 
18  //------------------------------------------------------------------------------------------------------------------------------------------
19 
21  {
22  }
23 
24  //------------------------------------------------------------------------------------------------------------------------------------------
25 
26  pandora::StatusCode GeometryCreator::CreateGeometry() const
27  {
28  try
29  {
30  SubDetectorTypeMap subDetectorTypeMap;
31  this->SetMandatorySubDetectorParameters(subDetectorTypeMap);
32 
33  SubDetectorNameMap subDetectorNameMap;
34  this->SetAdditionalSubDetectorParameters(subDetectorNameMap);
35 
36  std::string detectorName = "NDGAr";
37 
38  MF_LOG_INFO( "GeometryCreator::CreateGeometry()" ) << "Creating geometry for detector " << detectorName << std::endl;
39 
40  for (SubDetectorTypeMap::const_iterator iter = subDetectorTypeMap.begin(), iterEnd = subDetectorTypeMap.end(); iter != iterEnd; ++iter)
41  PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, PandoraApi::Geometry::SubDetector::Create(m_pPandora, iter->second));
42 
43  for (SubDetectorNameMap::const_iterator iter = subDetectorNameMap.begin(), iterEnd = subDetectorNameMap.end(); iter != iterEnd; ++iter){
44  MF_LOG_INFO( "GeometryCreator::CreateGeometry()" ) << "Creating geometry for additional subdetector " << iter->first << std::endl;
45  PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, PandoraApi::Geometry::SubDetector::Create(m_pPandora, iter->second));
46  }
47  }
48  catch (std::exception &exception)
49  {
50  MF_LOG_ERROR( "GeometryCreator::CreateGeometry()" ) << "Failure in pandora geometry creator, exception: " << exception.what() << std::endl;
51  throw exception;
52  }
53 
54  return pandora::STATUS_CODE_SUCCESS;
55  }
56 
57  //------------------------------------------------------------------------------------------------------------------------------------------
58 
60  {
61  PandoraApi::Geometry::SubDetector::Parameters eCalBarrelParameters, eCalEndCapParameters,
62  muonBarrelParameters, muonEndCapParameters;
63 
64  this->SetDefaultSubDetectorParameters(*const_cast<gar::geo::LayeredCalorimeterData*>(fGeo->GetECALLayeredCalorimeterData()[gar::geo::LayeredCalorimeterData::BarrelLayout].get()), "ECalBarrel", pandora::ECAL_BARREL, eCalBarrelParameters);
65  this->SetDefaultSubDetectorParameters(*const_cast<gar::geo::LayeredCalorimeterData*>(fGeo->GetECALLayeredCalorimeterData()[gar::geo::LayeredCalorimeterData::EndcapLayout].get()), "ECalEndcap", pandora::ECAL_ENDCAP, eCalEndCapParameters);
66 
67  subDetectorTypeMap[pandora::ECAL_BARREL] = eCalBarrelParameters;
68  subDetectorTypeMap[pandora::ECAL_ENDCAP] = eCalEndCapParameters;
69 
70  PandoraApi::Geometry::SubDetector::Parameters trackerParameters;
71 
72  trackerParameters.m_subDetectorName = "Tracker";
73  trackerParameters.m_subDetectorType = pandora::INNER_TRACKER;
74  trackerParameters.m_innerRCoordinate = 0.f; // inner R of TPC
75  trackerParameters.m_innerZCoordinate = 0.f;
76  trackerParameters.m_innerPhiCoordinate = 0.f;
77  trackerParameters.m_innerSymmetryOrder = 0;
78  trackerParameters.m_outerRCoordinate = fGeo->TPCRadius() * CLHEP::cm; // outer R of TPC
79  trackerParameters.m_outerZCoordinate = fGeo->TPCLength() / 2. * CLHEP::cm; // outer X of TPC
80  trackerParameters.m_outerPhiCoordinate = 0.f;
81  trackerParameters.m_outerSymmetryOrder = 0;
82  trackerParameters.m_isMirroredInZ = true;
83  trackerParameters.m_nLayers = 0;
84  subDetectorTypeMap[pandora::INNER_TRACKER] = trackerParameters;
85  }
86 
87  //------------------------------------------------------------------------------------------------------------------------------------------
88 
90  {
91 
92  }
93 
94  //------------------------------------------------------------------------------------------------------------------------------------------
95 
96  void GeometryCreator::SetDefaultSubDetectorParameters(const gar::geo::LayeredCalorimeterData &inputParameters, const std::string &subDetectorName, const pandora::SubDetectorType subDetectorType, PandoraApi::Geometry::SubDetector::Parameters &parameters) const
97  {
98  const std::vector<gar::geo::LayeredCalorimeterStruct::Layer> &layers = inputParameters.layers;
99 
100  parameters.m_subDetectorName = subDetectorName;
101  parameters.m_subDetectorType = subDetectorType;
102  parameters.m_innerRCoordinate = inputParameters.extent[0] * CLHEP::cm;
103  parameters.m_innerZCoordinate = inputParameters.extent[2] * CLHEP::cm;
104  parameters.m_innerSymmetryOrder = inputParameters.inner_symmetry;
105  parameters.m_outerRCoordinate = inputParameters.extent[1] * CLHEP::cm;
106  parameters.m_outerZCoordinate = inputParameters.extent[3] * CLHEP::cm;
107  parameters.m_innerPhiCoordinate = inputParameters.inner_phi0;
108  parameters.m_outerPhiCoordinate = inputParameters.outer_phi0;
109  parameters.m_outerSymmetryOrder = inputParameters.outer_symmetry;
110  parameters.m_isMirroredInZ = true;
111  parameters.m_nLayers = layers.size();
112 
113  MF_LOG_DEBUG("GeometryCreator::SetDefaultSubDetectorParameters")
114  << " parameters.m_subDetectorName = " << parameters.m_subDetectorName.Get()
115  << " parameters.m_subDetectorType = " << parameters.m_subDetectorType.Get()
116  << " parameters.m_innerRCoordinate = " << parameters.m_innerRCoordinate.Get()
117  << " parameters.m_innerZCoordinate = " << parameters.m_innerZCoordinate.Get()
118  << " parameters.m_innerSymmetryOrder = " << parameters.m_innerSymmetryOrder.Get()
119  << " parameters.m_outerRCoordinate = " << parameters.m_outerRCoordinate.Get()
120  << " parameters.m_outerZCoordinate = " << parameters.m_outerZCoordinate.Get()
121  << " parameters.m_innerPhiCoordinate = " << parameters.m_innerPhiCoordinate.Get()
122  << " parameters.m_outerPhiCoordinate = " << parameters.m_outerPhiCoordinate.Get()
123  << " parameters.m_nLayers = " << parameters.m_nLayers.Get();
124 
125  for (size_t i = 0; i < layers.size(); i++)
126  {
127  const gar::geo::LayeredCalorimeterStruct::Layer &theLayer = layers.at(i);
128  PandoraApi::Geometry::LayerParameters layerParameters;
129 
130  double totalNumberOfRadLengths = theLayer.inner_nRadiationLengths;
131  double totalNumberOfIntLengths = theLayer.inner_nInteractionLengths;
132 
133  if(i>0) {
134  //Add the numbers from previous layer's outer side
135  totalNumberOfRadLengths += layers.at(i-1).outer_nRadiationLengths;
136  totalNumberOfIntLengths += layers.at(i-1).outer_nInteractionLengths;
137  }
138 
139  layerParameters.m_closestDistanceToIp = (theLayer.distance + theLayer.inner_thickness) * CLHEP::cm; //Distance to center of sensitive element
140  layerParameters.m_nRadiationLengths = totalNumberOfRadLengths;
141  layerParameters.m_nInteractionLengths = totalNumberOfIntLengths;
142 
143  MF_LOG_DEBUG("GeometryCreator::SetDefaultSubDetectorParameters")
144  << " layer " << i
145  << " layerParameters.m_closestDistanceToIp = " << layerParameters.m_closestDistanceToIp.Get()
146  << " layerParameters.m_nRadiationLengths = " << layerParameters.m_nRadiationLengths.Get()
147  << " layerParameters.m_nInteractionLengths = " << layerParameters.m_nInteractionLengths.Get();
148 
149  parameters.m_layerParametersVector.push_back(layerParameters);
150  }
151  }
152 
153  //------------------------------------------------------------------------------------------------------------------------------------------
154 
156  {
157  }
158  }
159 }
static constexpr double cm
Definition: Units.h:68
GeometryCreator(const Settings &settings, const pandora::Pandora *const pPandora)
std::string string
Definition: nybbler.cc:12
void SetAdditionalSubDetectorParameters(SubDetectorNameMap &subDetectorNameMap) const
#define MF_LOG_ERROR(category)
intermediate_table::const_iterator const_iterator
void SetDefaultSubDetectorParameters(const gar::geo::LayeredCalorimeterData &inputParameters, const std::string &subDetectorName, const pandora::SubDetectorType subDetectorType, PandoraApi::Geometry::SubDetector::Parameters &parameters) const
float TPCRadius() const
Returns the radius of the TPC (y or z direction)
Definition: GeometryCore.h:755
const pandora::Pandora & m_pPandora
Address of the pandora object to create the geometry.
#define MF_LOG_INFO(category)
void SetMandatorySubDetectorParameters(SubDetectorTypeMap &subDetectorTypeMap) const
std::map< pandora::SubDetectorType, PandoraApi::Geometry::SubDetector::Parameters > SubDetectorTypeMap
General GArSoft Utilities.
std::map< std::string, PandoraApi::Geometry::SubDetector::Parameters > SubDetectorNameMap
#define MF_LOG_DEBUG(id)
float TPCLength() const
Returns the length of the TPC (x direction)
Definition: GeometryCore.h:763
const geo::GeometryCore * fGeo
Geometry provider.
pandora::StatusCode CreateGeometry() const
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
std::map< gar::geo::LayeredCalorimeterData::LayoutType, std::shared_ptr< gar::geo::LayeredCalorimeterData > > GetECALLayeredCalorimeterData() const
Definition: GeometryCore.h:628