42 double thickness,
const BinUtility* binutils,
double minfraction,
46 m_bins0(binutils ? (binutils->
max(0) + 1) : 1),
47 m_bins1(binutils && binutils->dimensions() > 1 ? (binutils->
max(1) + 1)
61 const auto zeroedVectorDbl = std::vector<double>(
m_bins0, 0.);
62 const auto zeroedVectorUInt = std::vector<unsigned int>(
m_bins0, 0);
63 const auto zeroedVectorVector3D = std::vector<Amg::Vector3D>(
m_bins0,
m_pos);
64 using Element_t = std::map<unsigned int, double>;
65 const auto zeroedVectorElements =
66 std::vector<Element_t>(
m_bins0, Element_t());
67 for (
int ibin = 0; ibin <
m_bins1; ++ibin) {
69 m_run_pos.push_back(zeroedVectorVector3D);
71 m_run_s.push_back(zeroedVectorDbl);
74 m_run_a.push_back(zeroedVectorDbl);
75 m_run_z.push_back(zeroedVectorDbl);
164 m_rho += mat.rho * s;
165 m_a += mat.A * s * mat.rho;
166 m_z += mat.Z * s * mat.rho;
172 for (
auto& it : (*mComposition)) {
211 hitPosition, hitPosition));
233 double nef = eIter.second * corrFactorInv /
m_s_in_l0;
244 double eventNorm = 1. / double(
m_run_events[rBin1][rBin0]);
248 double a =
m_run_a[rBin1][rBin0] * eventNorm;
249 double z =
m_run_z[rBin1][rBin0] * eventNorm;
250 double rho =
m_run_rho[rBin1][rBin0] * eventNorm;
263 hitPosition,
m_run_s[rBin1][rBin0] * eventNorm, x0, l0,
a,
z, rho,
280 return fullHitMaterial;
286 for (
int ibin1 = 0; ibin1 <
m_bins1; ++ibin1) {
291 for (
int ibin0 = 0; ibin0 <
m_bins0; ++ibin0) {
295 double eventNorm = 1. / double(
m_run_events[ibin1][ibin0]);
299 m_run_a[ibin1][ibin0] *= eventNorm;
300 m_run_z[ibin1][ibin0] *= eventNorm;
314 if (recordElements) {
316 double preTotalFraction = 0.;
317 std::map<unsigned int, double> binElements =
319 for (
auto& peIter : binElements) {
321 peIter.second *= eventNorm;
322 preTotalFraction += peIter.second;
324 if (preTotalFraction == 0.) [[
unlikely]]{
325 throw std::runtime_error(
"Trk::LayerMaterialRecord::finalizeRun: preTotalFraction is zero.");
328 std::map<double, unsigned int> probabilityOrdered;
329 double totalFraction = 0.;
330 for (
auto& eIter : binElements) {
332 double eFraction = eIter.second / preTotalFraction;
334 probabilityOrdered[eIter.second] = eIter.first;
335 totalFraction += eIter.second;
337 if (totalFraction == 0.) [[
unlikely]]{
338 throw std::runtime_error(
"Trk::LayerMaterialRecord::finalizeRun: totalFraction is zero.");
341 std::vector<Trk::ElementFraction> elementFractions;
342 elementFractions.reserve(binElements.size());
343 for (
auto& poEl : probabilityOrdered) {
344 double fracEl = poEl.first / totalFraction;
345 unsigned int fracEluChar = fracEl * UCHAR_MAX;
346 elementFractions.emplace_back(poEl.second, fracEluChar);
349 std::reverse(elementFractions.begin(), elementFractions.end());
359 matVector.push_back(binMaterial);
366 Trk::MaterialPropertiesMatrix::iterator matMatrixIter =
368 Trk::MaterialPropertiesMatrix::iterator matMatrixIterEnd =
370 for (; matMatrixIter != matMatrixIterEnd; ++matMatrixIter) {
372 std::vector<const Trk::MaterialProperties*>::iterator matIter =
373 (*matMatrixIter).begin();
374 std::vector<const Trk::MaterialProperties*>::iterator matIterEnd =
375 (*matMatrixIter).end();
376 for (; matIter != matIterEnd; ++matIter)
delete (*matIter);
386 Trk::MaterialPropertiesMatrix::const_iterator matMatrixIter =
387 materialMatrix.begin();
388 Trk::MaterialPropertiesMatrix::const_iterator matMatrixIterEnd =
389 materialMatrix.end();
390 for (; matMatrixIter != matMatrixIterEnd; ++matMatrixIter) {
393 std::vector<const Trk::MaterialProperties*>::const_iterator matIter =
394 (*matMatrixIter).begin();
395 std::vector<const Trk::MaterialProperties*>::const_iterator matIterEnd =
396 (*matMatrixIter).end();
397 for (; matIter != matIterEnd; ++matIter) {
399 matProp.push_back(((*matIter) ? (*matIter)->clone() :
nullptr));
#define uchar2uint(uchar)
#define uchar2dfrac(uchar)
It is used in the Mapping process ( using MaterialSteps ), the validation and recostruction ( using M...
A generic symmetric BinUtility, for fully symmetric binning in terms of binning grid and binning type...
BinUtility * clone() const
Implicit Constructor.
Helper Class to record the material during the GeantinoNtupleMappingProcess.
int m_bins1
number of bins in coordinate 2
std::vector< std::vector< unsigned int > > m_run_events
LayerMaterialRecord()
Default Constructor.
std::vector< std::vector< double > > m_run_s_in_x0
double m_layerThickness
record the layerThickness
std::vector< std::vector< double > > m_run_s
LayerMaterialRecord & operator=(const LayerMaterialRecord &lmr)
Assignment operator.
std::map< unsigned int, double > m_elements
Amg::Vector3D m_pos
event related information
std::vector< std::vector< double > > m_run_a
MaterialAssociationType m_assoc
type of hit association
void finalizeRun(bool recordElements=true)
finalize the Run
AssociatedMaterial * finalizeEvent(const Trk::Layer &lay, bool fullHit=false)
finalize the Event
std::vector< std::vector< Amg::Vector3D > > m_run_pos
MaterialPropertiesMatrix m_associatedLayerMaterial
clear the material -> calls delete
BinUtility * m_binUtility
record the BinnedArray
std::vector< std::vector< std::map< unsigned int, double > > > m_run_elements
the final material properties
void clearMaterial()
copy from another vector
void associateGeantinoHit(const Amg::Vector3D &pos, double s, const Trk::Material &mat)
adding the information about the Geantino hit
void copyMaterial(const MaterialPropertiesMatrix &mat)
~LayerMaterialRecord()
Destructor.
void associateEmptyHit(const Amg::Vector3D &pos)
adding the information about an empty hit scaling- particle crossed layer, but no mapping information
std::vector< std::vector< double > > m_run_s_in_l0
std::vector< std::vector< double > > m_run_z
double m_minFraction
minimum element fraction to be recorded
int m_bins0
number of bins in coordinate 1
std::vector< std::vector< double > > m_run_rho
Base Class for a Detector Layer in the Tracking realm.
virtual const Surface & surfaceRepresentation() const =0
Transforms the layer into a Surface representation for extrapolation.
const TrackingVolume * enclosingTrackingVolume() const
get the confining TrackingVolume
Material with information about thickness of material.
A common object to be contained by.
virtual double pathCorrection(const Amg::Vector3D &pos, const Amg::Vector3D &mom) const
the pathCorrection for derived classes with thickness - it reflects if the direction projection is po...
std::string find(const std::string &s)
return a remapped string
Definition of ATLAS Math & Geometry primitives (Amg).
Eigen::Matrix< double, 3, 1 > Vector3D
Ensure that the ATLAS eigen extensions are properly loaded.
@ z
global position (cartesian)
std::vector< const MaterialProperties * > MaterialPropertiesVector
Useful typedefs.
std::vector< std::vector< const MaterialProperties * > > MaterialPropertiesMatrix
void reverse(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of reverse for DataVector/List.