Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
gar::gar_pandora::CaloHitCreator Class Reference

#include <CaloHitCreator.h>

Classes

class  Settings
 

Public Types

typedef std::vector< float > FloatVector
 

Public Member Functions

 CaloHitCreator (const Settings &settings, const pandora::Pandora *const pPandora, const RotationTransformation *const pRotation)
 
 ~CaloHitCreator ()
 
pandora::StatusCode CreateCaloHits (const art::Event &pEvent)
 
const CalorimeterHitVectorGetCalorimeterHitVector () const
 
void Reset ()
 

Private Member Functions

pandora::StatusCode CreateECalCaloHits () const
 
void GetCommonCaloHitProperties (const gar::rec::CaloHit *const pCaloHit, PandoraApi::CaloHit::Parameters &caloHitParameters) const
 
void GetEndCapCaloHitProperties (const gar::rec::CaloHit *const pCaloHit, const std::vector< gar::geo::LayeredCalorimeterStruct::Layer > &layers, PandoraApi::CaloHit::Parameters &caloHitParameters, float &absorberCorrection) const
 
void GetBarrelCaloHitProperties (const gar::rec::CaloHit *const pCaloHit, const std::vector< gar::geo::LayeredCalorimeterStruct::Layer > &layers, unsigned int barrelSymmetryOrder, PandoraApi::CaloHit::Parameters &caloHitParameters, FloatVector const &normalVector, float &absorberCorrection) const
 
int GetNLayersFromEdge (const gar::rec::CaloHit *const pCaloHit) const
 
float GetMaximumRadius (const gar::rec::CaloHit *const pCaloHit, const unsigned int symmetryOrder, const float phi0) const
 
pandora::StatusCode CollectECALCaloHits (const art::Event &pEvent, const std::string &label, const std::string &instanceName, CalorimeterHitVector &ecalCaloHitVector)
 

Private Attributes

const Settings m_settings
 The calo hit creator settings. More...
 
const pandora::Pandora & m_pandora
 Reference to the pandora object to create calo hits. More...
 
const geo::GeometryCorefGeo
 
gar::geo::BitFieldCoder const * m_fieldDecoder
 
float m_origin [3] = {0, 0, 0}
 
const RotationTransformationm_rotation
 
float m_eCalBarrelLayerThickness
 ECal barrel layer thickness. More...
 
float m_eCalEndCapLayerThickness
 ECal endcap layer thickness. More...
 
CalorimeterHitVector artCalorimeterHitVector
 

Detailed Description

Definition at line 20 of file CaloHitCreator.h.

Member Typedef Documentation

Definition at line 23 of file CaloHitCreator.h.

Constructor & Destructor Documentation

gar::gar_pandora::CaloHitCreator::CaloHitCreator ( const Settings settings,
const pandora::Pandora *const  pPandora,
const RotationTransformation *const  pRotation 
)

Take thicknesses from last layer (was like that before with gear)

Definition at line 14 of file CaloHitCreator.cxx.

15  : m_settings(settings),
16  m_pandora(*pPandora),
17  m_rotation(*pRotation),
21  {
22  fGeo = gar::providerFrom<geo::GeometryGAr>();
23  std::string fEncoding = fGeo->GetECALCellIDEncoding();
24  m_fieldDecoder = new gar::geo::BitFieldCoder( fEncoding );
25  m_origin[0] = fGeo->GetOriginX();
26  m_origin[1] = fGeo->GetOriginY();
27  m_origin[2] = fGeo->GetOriginZ();
28 
29  const std::vector<gar::geo::LayeredCalorimeterStruct::Layer> &barrelLayers = (fGeo->GetECALLayeredCalorimeterData()[gar::geo::LayeredCalorimeterData::BarrelLayout].get())->layers;
30 
31  const std::vector<gar::geo::LayeredCalorimeterStruct::Layer> &endcapLayers = (fGeo->GetECALLayeredCalorimeterData()[gar::geo::LayeredCalorimeterData::EndcapLayout].get())->layers;
32 
33  ///Take thicknesses from last layer (was like that before with gear)
34  m_eCalEndCapLayerThickness = (endcapLayers.back().inner_thickness + endcapLayers.back().outer_thickness) * CLHEP::cm;
35  m_eCalBarrelLayerThickness = (barrelLayers.back().inner_thickness + barrelLayers.back().outer_thickness) * CLHEP::cm;
36 
37  if ( (m_eCalEndCapLayerThickness < std::numeric_limits<float>::epsilon()) || (m_eCalBarrelLayerThickness < std::numeric_limits<float>::epsilon()) )
38  throw pandora::StatusCodeException(pandora::STATUS_CODE_INVALID_PARAMETER);
39  }
static constexpr double cm
Definition: Units.h:68
std::string string
Definition: nybbler.cc:12
float GetOriginX() const
Definition: GeometryCore.h:548
gar::geo::BitFieldCoder const * m_fieldDecoder
float GetOriginZ() const
Definition: GeometryCore.h:552
Helper class for decoding and encoding a bit field of 64bits for convenient declaration.
const geo::GeometryCore * fGeo
float GetOriginY() const
Definition: GeometryCore.h:550
const Settings m_settings
The calo hit creator settings.
CalorimeterHitVector artCalorimeterHitVector
const RotationTransformation & m_rotation
const pandora::Pandora & m_pandora
Reference to the pandora object to create calo hits.
const std::string GetECALCellIDEncoding() const
float m_eCalBarrelLayerThickness
ECal barrel layer thickness.
float m_eCalEndCapLayerThickness
ECal endcap layer thickness.
std::map< gar::geo::LayeredCalorimeterData::LayoutType, std::shared_ptr< gar::geo::LayeredCalorimeterData > > GetECALLayeredCalorimeterData() const
Definition: GeometryCore.h:628
gar::gar_pandora::CaloHitCreator::~CaloHitCreator ( )

Definition at line 43 of file CaloHitCreator.cxx.

44  {
45  if ( m_fieldDecoder ) delete m_fieldDecoder;
46  }
gar::geo::BitFieldCoder const * m_fieldDecoder

Member Function Documentation

pandora::StatusCode gar::gar_pandora::CaloHitCreator::CollectECALCaloHits ( const art::Event pEvent,
const std::string label,
const std::string instanceName,
CalorimeterHitVector ecalCaloHitVector 
)
private

Definition at line 356 of file CaloHitCreator.cxx.

357  {
358  art::InputTag itag(label, instanceName);
359  auto theHits = pEvent.getHandle< RawCalorimeterHitVector >(itag);
360  if (!theHits)
361  {
362  MF_LOG_WARNING("CaloHitCreator::CreateECalCaloHits") << " Failed to find ecal hits for label " << label << std::endl;
363  return pandora::STATUS_CODE_NOT_FOUND;
364  }
365 
366  MF_LOG_DEBUG("CaloHitCreator::CreateECalCaloHits") << " Found: " << theHits->size() << " Hits " << std::endl;
367 
368  for (unsigned int i = 0; i < theHits->size(); ++i)
369  {
370  const art::Ptr<gar::rec::CaloHit> hit(theHits, i);
371  ecalCaloHitVector.push_back(hit);
372  }
373 
374  return pandora::STATUS_CODE_SUCCESS;
375  }
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
std::vector< gar::rec::CaloHit > RawCalorimeterHitVector
Detector simulation of raw signals on wires.
#define MF_LOG_DEBUG(id)
#define MF_LOG_WARNING(category)
QTextStream & endl(QTextStream &s)
pandora::StatusCode gar::gar_pandora::CaloHitCreator::CreateCaloHits ( const art::Event pEvent)

Definition at line 50 of file CaloHitCreator.cxx.

51  {
52  PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, this->CollectECALCaloHits(pEvent, m_settings.m_CaloHitCollection, m_settings.m_CaloHitInstanceName, artCalorimeterHitVector));
53  PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, this->CreateECalCaloHits());
54 
55  return pandora::STATUS_CODE_SUCCESS;
56  }
std::string m_CaloHitCollection
The calorimeter hit collection.
std::string m_CaloHitInstanceName
The calorimeter hit instance name.
const Settings m_settings
The calo hit creator settings.
CalorimeterHitVector artCalorimeterHitVector
pandora::StatusCode CollectECALCaloHits(const art::Event &pEvent, const std::string &label, const std::string &instanceName, CalorimeterHitVector &ecalCaloHitVector)
pandora::StatusCode CreateECalCaloHits() const
pandora::StatusCode gar::gar_pandora::CaloHitCreator::CreateECalCaloHits ( ) const
private

Definition at line 60 of file CaloHitCreator.cxx.

61  {
62  const std::vector<gar::geo::LayeredCalorimeterStruct::Layer> &barrelLayers = (fGeo->GetECALLayeredCalorimeterData()[gar::geo::LayeredCalorimeterData::BarrelLayout].get())->layers;
63 
64  const std::vector<gar::geo::LayeredCalorimeterStruct::Layer> &endcapLayers = (fGeo->GetECALLayeredCalorimeterData()[gar::geo::LayeredCalorimeterData::EndcapLayout].get())->layers;
65 
66  for (CalorimeterHitVector::const_iterator iter = artCalorimeterHitVector.begin(), iterEnd = artCalorimeterHitVector.end(); iter != iterEnd; ++iter)
67  {
68  try
69  {
70  art::Ptr<gar::rec::CaloHit> artPtrCaloHit = *iter;
71  const gar::rec::CaloHit *pCaloHit = artPtrCaloHit.get();
72 
73  if (nullptr == pCaloHit)
74  throw;
75 
76  PandoraApi::CaloHit::Parameters caloHitParameters;
77  caloHitParameters.m_hitType = pandora::ECAL;
78  caloHitParameters.m_isDigital = false;
79  caloHitParameters.m_layer = m_fieldDecoder->get(pCaloHit->CellID(), "layer");
80  caloHitParameters.m_isInOuterSamplingLayer = (this->GetNLayersFromEdge(pCaloHit) <= m_settings.m_nOuterSamplingLayers);
81  this->GetCommonCaloHitProperties(pCaloHit, caloHitParameters);
82 
83  float absorberCorrection(1.);
84 
85  //Need to use X instead of Z
86  if (std::fabs( (pCaloHit->Position()[0] - m_origin[0]) * CLHEP::cm) < m_settings.m_eCalBarrelOuterZ)
87  {
88  this->GetBarrelCaloHitProperties(pCaloHit, barrelLayers, m_settings.m_eCalBarrelInnerSymmetry, caloHitParameters, m_settings.m_eCalBarrelNormalVector, absorberCorrection);
89  caloHitParameters.m_hadronicEnergy = m_settings.m_eCalToHadGeVBarrel * pCaloHit->Energy();
90  }
91  else
92  {
93  this->GetEndCapCaloHitProperties(pCaloHit, endcapLayers, caloHitParameters, absorberCorrection);
94  caloHitParameters.m_hadronicEnergy = m_settings.m_eCalToHadGeVEndCap * pCaloHit->Energy();
95  }
96 
97  caloHitParameters.m_mipEquivalentEnergy = pCaloHit->Energy() * m_settings.m_eCalToMip * absorberCorrection;
98 
99  if (caloHitParameters.m_mipEquivalentEnergy.Get() < m_settings.m_eCalMipThreshold)
100  continue;
101 
102  caloHitParameters.m_electromagneticEnergy = m_settings.m_eCalToEMGeV * pCaloHit->Energy();
103 
104  //Check if the hit is inside the calo... could be SSA reco problems....
105  const float rCoordinate( std::sqrt( (pCaloHit->Position()[1] - m_origin[1]) * (pCaloHit->Position()[1] - m_origin[1]) + (pCaloHit->Position()[2] - m_origin[2]) * (pCaloHit->Position()[2] - m_origin[2]) ) * CLHEP::cm );
106  if( rCoordinate > m_settings.m_eCalBarrelOuterR )
107  {
108  MF_LOG_WARNING("CaloHitCreator::CreateECalCaloHits")
109  << " Position x: " << pCaloHit->Position()[0] * CLHEP::cm
110  << " y: " << pCaloHit->Position()[1] * CLHEP::cm
111  << " z: " << pCaloHit->Position()[2] * CLHEP::cm
112  << " rCoordinate " << rCoordinate << " > " << " m_settings.m_eCalBarrelOuterR " << m_settings.m_eCalBarrelOuterR
113  << " caloHitParameters.m_hitType = " << caloHitParameters.m_hitType.Get()
114  << " caloHitParameters.m_isDigital = " << caloHitParameters.m_isDigital.Get()
115  << " caloHitParameters.m_layer = " << caloHitParameters.m_layer.Get()
116  << " caloHitParameters.m_isInOuterSamplingLayer = " << caloHitParameters.m_isInOuterSamplingLayer.Get()
117  << " caloHitParameters.m_cellGeometry = " << caloHitParameters.m_cellGeometry.Get()
118  << " caloHitParameters.m_expectedDirection = " << caloHitParameters.m_expectedDirection.Get()
119  << " caloHitParameters.m_inputEnergy = " << caloHitParameters.m_inputEnergy.Get()
120  << " caloHitParameters.m_time = " << caloHitParameters.m_time.Get()
121  << " caloHitParameters.m_cellSize0 = " << caloHitParameters.m_cellSize0.Get()
122  << " caloHitParameters.m_cellSize1 = " << caloHitParameters.m_cellSize1.Get()
123  << " caloHitParameters.m_cellThickness = " << caloHitParameters.m_cellThickness.Get()
124  << " caloHitParameters.m_nCellRadiationLengths = " << caloHitParameters.m_nCellRadiationLengths.Get()
125  << " caloHitParameters.m_nCellInteractionLengths = " << caloHitParameters.m_nCellInteractionLengths.Get()
126  << " caloHitParameters.m_hadronicEnergy = " << caloHitParameters.m_hadronicEnergy.Get()
127  << " caloHitParameters.m_mipEquivalentEnergy = " << caloHitParameters.m_mipEquivalentEnergy.Get()
128  << " caloHitParameters.m_electromagneticEnergy = " << caloHitParameters.m_electromagneticEnergy.Get();
129  continue;
130  }
131 
132  PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, PandoraApi::CaloHit::Create(m_pandora, caloHitParameters));
133  }
134  catch (pandora::StatusCodeException &statusCodeException)
135  {
136  MF_LOG_ERROR("CaloHitCreator::CreateECalCaloHits()")
137  << "Failed to extract ecal calo hit: " << statusCodeException.ToString();
138  }
139  catch (std::exception &exception)
140  {
141  MF_LOG_WARNING("CaloHitCreator::CreateECalCaloHits()")
142  << "Failed to extract ecal calo hit: " << exception.what();
143  }
144  }
145 
146  return pandora::STATUS_CODE_SUCCESS;
147  }
static constexpr double cm
Definition: Units.h:68
float m_eCalToHadGeVEndCap
The calibration from deposited ECal endcap energy to hadronic energy.
float m_eCalMipThreshold
Threshold for creating calo hits in the ECal, units mip.
void GetBarrelCaloHitProperties(const gar::rec::CaloHit *const pCaloHit, const std::vector< gar::geo::LayeredCalorimeterStruct::Layer > &layers, unsigned int barrelSymmetryOrder, PandoraApi::CaloHit::Parameters &caloHitParameters, FloatVector const &normalVector, float &absorberCorrection) const
raw::CellID_t CellID() const
Definition: CaloHit.h:72
float m_eCalToEMGeV
The calibration from deposited ECal energy to EM energy.
#define MF_LOG_ERROR(category)
gar::geo::BitFieldCoder const * m_fieldDecoder
int m_nOuterSamplingLayers
Number of layers from edge for hit to be flagged as an outer layer hit.
intermediate_table::const_iterator const_iterator
float m_eCalToHadGeVBarrel
The calibration from deposited ECal barrel energy to hadronic energy.
float m_eCalBarrelOuterZ
ECal barrel outer z coordinate.
float Energy() const
Definition: CaloHit.h:69
int GetNLayersFromEdge(const gar::rec::CaloHit *const pCaloHit) const
float m_eCalBarrelOuterR
ECal barrel outer r coordinate.
const geo::GeometryCore * fGeo
const Settings m_settings
The calo hit creator settings.
CalorimeterHitVector artCalorimeterHitVector
FloatVector m_eCalBarrelNormalVector
ECal barrel normal vector.
void GetEndCapCaloHitProperties(const gar::rec::CaloHit *const pCaloHit, const std::vector< gar::geo::LayeredCalorimeterStruct::Layer > &layers, PandoraApi::CaloHit::Parameters &caloHitParameters, float &absorberCorrection) const
long64 get(long64 bitfield, size_t index) const
const float * Position() const
Definition: CaloHit.h:70
float m_eCalToMip
The calibration from deposited ECal energy to mip.
const pandora::Pandora & m_pandora
Reference to the pandora object to create calo hits.
void GetCommonCaloHitProperties(const gar::rec::CaloHit *const pCaloHit, PandoraApi::CaloHit::Parameters &caloHitParameters) const
#define MF_LOG_WARNING(category)
T const * get() const
Definition: Ptr.h:149
unsigned int m_eCalBarrelInnerSymmetry
ECal barrel inner symmetry order.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::map< gar::geo::LayeredCalorimeterData::LayoutType, std::shared_ptr< gar::geo::LayeredCalorimeterData > > GetECALLayeredCalorimeterData() const
Definition: GeometryCore.h:628
void gar::gar_pandora::CaloHitCreator::GetBarrelCaloHitProperties ( const gar::rec::CaloHit *const  pCaloHit,
const std::vector< gar::geo::LayeredCalorimeterStruct::Layer > &  layers,
unsigned int  barrelSymmetryOrder,
PandoraApi::CaloHit::Parameters &  caloHitParameters,
FloatVector const &  normalVector,
float &  absorberCorrection 
) const
private

Definition at line 221 of file CaloHitCreator.cxx.

223  {
224  caloHitParameters.m_hitRegion = pandora::BARREL;
225 
226  const int physicalLayer(std::min(static_cast<int>(caloHitParameters.m_layer.Get()), static_cast<int>(layers.size()-1)));
227  caloHitParameters.m_cellSize0 = layers[physicalLayer].cellSize0 * CLHEP::cm;
228  caloHitParameters.m_cellSize1 = layers[physicalLayer].cellSize1 * CLHEP::cm;
229 
230  double thickness = (layers[physicalLayer].inner_thickness+layers[physicalLayer].sensitive_thickness/2.0) * CLHEP::cm;
231  double nRadLengths = layers[physicalLayer].inner_nRadiationLengths;
232  double nIntLengths = layers[physicalLayer].inner_nInteractionLengths;
233 
234  double layerAbsorberThickness = (layers[physicalLayer].inner_thickness-layers[physicalLayer].sensitive_thickness/2.0) * CLHEP::cm;
235  if(physicalLayer>0){
236  thickness += (layers[physicalLayer-1].outer_thickness -layers[physicalLayer].sensitive_thickness/2.0) * CLHEP::cm;
237  nRadLengths += layers[physicalLayer-1].outer_nRadiationLengths;
238  nIntLengths += layers[physicalLayer-1].outer_nInteractionLengths;
239  layerAbsorberThickness += (layers[physicalLayer-1].outer_thickness -layers[physicalLayer].sensitive_thickness/2.0) * CLHEP::cm;
240  }
241 
242  caloHitParameters.m_cellThickness = thickness;
243  caloHitParameters.m_nCellRadiationLengths = nRadLengths;
244  caloHitParameters.m_nCellInteractionLengths = nIntLengths;
245 
246  if (caloHitParameters.m_nCellRadiationLengths.Get() < std::numeric_limits<float>::epsilon() || caloHitParameters.m_nCellInteractionLengths.Get() < std::numeric_limits<float>::epsilon())
247  {
248  MF_LOG_ERROR("CaloHitCreator::GetBarrelCaloHitProperties")
249  << "Calo hit has 0 radiation length or interaction length: not creating a Pandora calo hit.";
250  throw pandora::StatusCodeException(pandora::STATUS_CODE_INVALID_PARAMETER);
251  }
252 
253  absorberCorrection = 1.;
254  for (unsigned int i = 0, iMax = layers.size(); i < iMax; ++i)
255  {
256  float absorberThickness((layers[i].inner_thickness - layers[i].sensitive_thickness/2.0 ) * CLHEP::cm);
257 
258  if (i>0)
259  absorberThickness += (layers[i-1].outer_thickness - layers[i-1].sensitive_thickness/2.0) * CLHEP::cm;
260 
261  if (absorberThickness < std::numeric_limits<float>::epsilon())
262  continue;
263 
264  if (layerAbsorberThickness > std::numeric_limits<float>::epsilon())
265  absorberCorrection = absorberThickness / layerAbsorberThickness;
266 
267  break;
268  }
269 
270  if (barrelSymmetryOrder > 2)
271  {
272  const double phi = atan2( pCaloHit->Position()[2], pCaloHit->Position()[1] );
273 
274  MF_LOG_DEBUG( "CaloHitCreator::GetBarrelCaloHitProperties" )
275  << "This hit does not have any cellIDs set, will use phi-direction for normal vector "
276  << " phi:" << std::setw(15) << phi*180/M_PI;
277 
278  caloHitParameters.m_cellNormalVector = pandora::CartesianVector(0, std::cos(phi), std::sin(phi));
279  }
280  else
281  {
282  const float *pCaloHitPosition( pCaloHit->Position() );
283  const float phi = std::atan2( pCaloHitPosition[2], pCaloHitPosition[1] );
284  caloHitParameters.m_cellNormalVector = pandora::CartesianVector(0, std::cos(phi), std::sin(phi));
285  }
286  }
static constexpr double cm
Definition: Units.h:68
#define MF_LOG_ERROR(category)
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
#define M_PI
Definition: includeROOT.h:54
const float * Position() const
Definition: CaloHit.h:70
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
#define MF_LOG_DEBUG(id)
const CalorimeterHitVector & gar::gar_pandora::CaloHitCreator::GetCalorimeterHitVector ( ) const
inline

Definition at line 93 of file CaloHitCreator.h.

94  {
96  }
CalorimeterHitVector artCalorimeterHitVector
void gar::gar_pandora::CaloHitCreator::GetCommonCaloHitProperties ( const gar::rec::CaloHit *const  pCaloHit,
PandoraApi::CaloHit::Parameters &  caloHitParameters 
) const
private

Definition at line 151 of file CaloHitCreator.cxx.

152  {
153  const float *pCaloHitPosition(pCaloHit->Position());
154  //Inverse X and Z for pandora to cope with the change in beam axis
155  const pandora::CartesianVector positionVector( (pCaloHitPosition[0] - m_origin[0]) * CLHEP::cm, (pCaloHitPosition[1] - m_origin[1]) * CLHEP::cm, (pCaloHitPosition[2] - m_origin[2]) * CLHEP::cm);
156  const pandora::CartesianVector newPositionVector = m_rotation.MakeRotation(positionVector);
157 
158  caloHitParameters.m_cellGeometry = pandora::RECTANGULAR;
159  caloHitParameters.m_positionVector = newPositionVector;
160  caloHitParameters.m_expectedDirection = newPositionVector.GetUnitVector();
161  caloHitParameters.m_pParentAddress = (void*)pCaloHit;
162  caloHitParameters.m_inputEnergy = pCaloHit->Energy();
163  caloHitParameters.m_time = pCaloHit->Time().first;
164  }
static constexpr double cm
Definition: Units.h:68
std::pair< float, float > Time() const
Definition: CaloHit.h:71
float Energy() const
Definition: CaloHit.h:69
const RotationTransformation & m_rotation
const pandora::CartesianVector MakeRotation(const pandora::CartesianVector &initialVec) const
const float * Position() const
Definition: CaloHit.h:70
void gar::gar_pandora::CaloHitCreator::GetEndCapCaloHitProperties ( const gar::rec::CaloHit *const  pCaloHit,
const std::vector< gar::geo::LayeredCalorimeterStruct::Layer > &  layers,
PandoraApi::CaloHit::Parameters &  caloHitParameters,
float &  absorberCorrection 
) const
private

Definition at line 168 of file CaloHitCreator.cxx.

169  {
170  caloHitParameters.m_hitRegion = pandora::ENDCAP;
171 
172  const int physicalLayer(std::min(static_cast<int>(caloHitParameters.m_layer.Get()), static_cast<int>(layers.size()-1)));
173  caloHitParameters.m_cellSize0 = layers[physicalLayer].cellSize0 * CLHEP::cm;
174  caloHitParameters.m_cellSize1 = layers[physicalLayer].cellSize1 * CLHEP::cm;
175 
176  double thickness = (layers[physicalLayer].inner_thickness+layers[physicalLayer].sensitive_thickness/2.0) * CLHEP::cm;
177  double nRadLengths = layers[physicalLayer].inner_nRadiationLengths;
178  double nIntLengths = layers[physicalLayer].inner_nInteractionLengths;
179  double layerAbsorberThickness = (layers[physicalLayer].inner_thickness-layers[physicalLayer].sensitive_thickness/2.0) * CLHEP::cm;
180 
181  if(physicalLayer>0){
182  thickness += (layers[physicalLayer-1].outer_thickness -layers[physicalLayer].sensitive_thickness/2.0) * CLHEP::cm;
183  nRadLengths += layers[physicalLayer-1].outer_nRadiationLengths;
184  nIntLengths += layers[physicalLayer-1].outer_nInteractionLengths;
185  layerAbsorberThickness += (layers[physicalLayer-1].outer_thickness -layers[physicalLayer].sensitive_thickness/2.0) * CLHEP::cm;
186  }
187 
188  caloHitParameters.m_cellThickness = thickness;
189  caloHitParameters.m_nCellRadiationLengths = nRadLengths;
190  caloHitParameters.m_nCellInteractionLengths = nIntLengths;
191 
192  if (caloHitParameters.m_nCellRadiationLengths.Get() < std::numeric_limits<float>::epsilon() || caloHitParameters.m_nCellInteractionLengths.Get() < std::numeric_limits<float>::epsilon())
193  {
194  MF_LOG_ERROR("CaloHitCreator::GetEndcapCaloHitProperties")
195  << "Calo hit has 0 radiation length or interaction length: not creating a Pandora calo hit.";
196  throw pandora::StatusCodeException(pandora::STATUS_CODE_INVALID_PARAMETER);
197  }
198 
199  absorberCorrection = 1.;
200  for (unsigned int i = 0, iMax = layers.size(); i < iMax; ++i)
201  {
202  float absorberThickness((layers[i].inner_thickness - layers[i].sensitive_thickness/2.0 ) * CLHEP::cm);
203 
204  if (i>0)
205  absorberThickness += (layers[i-1].outer_thickness - layers[i-1].sensitive_thickness/2.0) * CLHEP::cm;
206 
207  if (absorberThickness < std::numeric_limits<float>::epsilon())
208  continue;
209 
210  if (layerAbsorberThickness > std::numeric_limits<float>::epsilon())
211  absorberCorrection = absorberThickness / layerAbsorberThickness;
212 
213  break;
214  }
215 
216  caloHitParameters.m_cellNormalVector = (pCaloHit->Position()[0] * CLHEP::cm > 0) ? pandora::CartesianVector(1, 0, 0) : pandora::CartesianVector(-1, 0, 0);
217  }
static constexpr double cm
Definition: Units.h:68
#define MF_LOG_ERROR(category)
const float * Position() const
Definition: CaloHit.h:70
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
float gar::gar_pandora::CaloHitCreator::GetMaximumRadius ( const gar::rec::CaloHit *const  pCaloHit,
const unsigned int  symmetryOrder,
const float  phi0 
) const
private

Definition at line 332 of file CaloHitCreator.cxx.

333  {
334  const float *pCaloHitPosition(pCaloHit->Position());
335 
336  if (symmetryOrder <= 2)
337  return std::sqrt((pCaloHitPosition[1] * pCaloHitPosition[1]) + (pCaloHitPosition[2] * pCaloHitPosition[2]) * CLHEP::cm);
338 
339  float maximumRadius(0.f);
340  const float twoPi(2.f * M_PI);
341 
342  for (unsigned int i = 0; i < symmetryOrder; ++i)
343  {
344  const float phi = phi0 + i * twoPi / static_cast<float>(symmetryOrder);
345  float radius = pCaloHitPosition[2] * std::cos(phi) + pCaloHitPosition[1] * std::sin(phi);
346 
347  if (radius > maximumRadius)
348  maximumRadius = radius;
349  }
350 
351  return maximumRadius * CLHEP::cm;
352  }
static constexpr double cm
Definition: Units.h:68
#define M_PI
Definition: includeROOT.h:54
const float * Position() const
Definition: CaloHit.h:70
int gar::gar_pandora::CaloHitCreator::GetNLayersFromEdge ( const gar::rec::CaloHit *const  pCaloHit) const
private

Definition at line 290 of file CaloHitCreator.cxx.

291  {
292  // Calo hit coordinate calculations
293  const float barrelMaximumRadius(this->GetMaximumRadius(pCaloHit, m_settings.m_eCalBarrelOuterSymmetry, m_settings.m_eCalBarrelOuterPhi0));
295  const float caloHitAbsZ(std::fabs(pCaloHit->Position()[0]) * CLHEP::cm);
296 
297  // Distance from radial outer
298  float radialDistanceToEdge(std::numeric_limits<float>::max());
299 
300  if (caloHitAbsZ < m_settings.m_eCalBarrelOuterZ)
301  {
302  radialDistanceToEdge = (m_settings.m_eCalBarrelOuterR - barrelMaximumRadius) / m_eCalBarrelLayerThickness;
303  }
304  else
305  {
306  radialDistanceToEdge = (m_settings.m_eCalEndCapOuterR - endCapMaximumRadius) / m_eCalEndCapLayerThickness;
307  }
308 
309  // Distance from rear of endcap outer
310  float rearDistanceToEdge(std::numeric_limits<float>::max());
311 
312  if (caloHitAbsZ >= m_settings.m_eCalBarrelOuterZ)
313  {
314  rearDistanceToEdge = (m_settings.m_eCalEndCapOuterZ - caloHitAbsZ) / m_eCalEndCapLayerThickness;
315  }
316  else
317  {
318  const float rearDistance((m_settings.m_eCalBarrelOuterZ - caloHitAbsZ) / m_eCalBarrelLayerThickness);
319 
320  if (rearDistance < m_settings.m_layersFromEdgeMaxRearDistance)
321  {
322  const float overlapDistance((m_settings.m_eCalEndCapOuterR - endCapMaximumRadius) / m_eCalEndCapLayerThickness);
323  rearDistanceToEdge = std::max(rearDistance, overlapDistance);
324  }
325  }
326 
327  return static_cast<int>(std::min(radialDistanceToEdge, rearDistanceToEdge));
328  }
static constexpr double cm
Definition: Units.h:68
float m_eCalEndCapOuterR
ECal endcap outer r coordinate.
float m_eCalEndCapOuterZ
ECal endcap outer z coordinate.
float GetMaximumRadius(const gar::rec::CaloHit *const pCaloHit, const unsigned int symmetryOrder, const float phi0) const
float m_eCalBarrelOuterZ
ECal barrel outer z coordinate.
float m_eCalBarrelOuterPhi0
ECal barrel outer phi0 coordinate.
float m_eCalBarrelOuterR
ECal barrel outer r coordinate.
const Settings m_settings
The calo hit creator settings.
static int max(int a, int b)
const float * Position() const
Definition: CaloHit.h:70
unsigned int m_eCalEndCapInnerSymmetryOrder
ECal endcap inner symmetry.
unsigned int m_eCalBarrelOuterSymmetry
ECal barrel outer symmetry order.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
float m_layersFromEdgeMaxRearDistance
Maximum number of layers from candidate outer layer hit to rear of detector.
float m_eCalBarrelLayerThickness
ECal barrel layer thickness.
float m_eCalEndCapLayerThickness
ECal endcap layer thickness.
float m_eCalEndCapInnerPhiCoordinate
ECal endcap inner phi.
void gar::gar_pandora::CaloHitCreator::Reset ( )
inline

Definition at line 100 of file CaloHitCreator.h.

101  {
102  artCalorimeterHitVector.clear();
103  }
CalorimeterHitVector artCalorimeterHitVector

Member Data Documentation

CalorimeterHitVector gar::gar_pandora::CaloHitCreator::artCalorimeterHitVector
private

Definition at line 88 of file CaloHitCreator.h.

const geo::GeometryCore* gar::gar_pandora::CaloHitCreator::fGeo
private

Definition at line 79 of file CaloHitCreator.h.

float gar::gar_pandora::CaloHitCreator::m_eCalBarrelLayerThickness
private

ECal barrel layer thickness.

Definition at line 85 of file CaloHitCreator.h.

float gar::gar_pandora::CaloHitCreator::m_eCalEndCapLayerThickness
private

ECal endcap layer thickness.

Definition at line 86 of file CaloHitCreator.h.

gar::geo::BitFieldCoder const* gar::gar_pandora::CaloHitCreator::m_fieldDecoder
private

Definition at line 80 of file CaloHitCreator.h.

float gar::gar_pandora::CaloHitCreator::m_origin[3] = {0, 0, 0}
private

Definition at line 81 of file CaloHitCreator.h.

const pandora::Pandora& gar::gar_pandora::CaloHitCreator::m_pandora
private

Reference to the pandora object to create calo hits.

Definition at line 78 of file CaloHitCreator.h.

const RotationTransformation& gar::gar_pandora::CaloHitCreator::m_rotation
private

Definition at line 83 of file CaloHitCreator.h.

const Settings gar::gar_pandora::CaloHitCreator::m_settings
private

The calo hit creator settings.

Definition at line 77 of file CaloHitCreator.h.


The documentation for this class was generated from the following files: