21 m_compressedMaterialThickness(1.),
22 m_compressedMaterialX0Bins(256),
23 m_compressedMaterialZARhoBins(256)
25 declareInterface<Trk::ILayerMaterialCreator>(
this);
48 ATH_MSG_VERBOSE(
"Converting the MaterialPropertiesMatrix into a CompressedLayerMaterial.");
49 return createCompressedLayerMaterial(materialProperties,*lBinUtility);
66 size_t nBins0 = bUtility->
max(0)+1;
67 size_t nBins1 = bUtility->
max(1)+1;
70 materialMatrix.reserve(nBins1);
72 for (
size_t ibin1 = 0; ibin1 < nBins1; ++ibin1) {
75 materialVector.reserve(nBins0);
77 for (
size_t ibin0 = 0; ibin0 < nBins0; ++ibin0) {
80 materialVector.push_back(mProperties);
83 materialMatrix.push_back(materialVector);
87 ATH_MSG_VERBOSE(
"Converting the MaterialPropertiesMatrix into a CompressedLayerMaterial.");
88 bLayerMaterial = createCompressedLayerMaterial(materialMatrix,*bUtility);
92 ATH_MSG_DEBUG(
"No BinUtility provided - return a simple clone.");
93 bLayerMaterial = lmProperties.
clone();
96 return bLayerMaterial;
103 materialVector.reserve(m_compressedMaterialZARhoBins*m_compressedMaterialX0Bins);
105 size_t nFirstBins = lBinUtility.
max(0)+1;
106 size_t nSecondBins = lBinUtility.
max(1)+1;
108 double x0min = 10e10;
110 double avZArhoMin = 10e10;
111 double avZArhoMax = 0.;
113 std::vector< std::vector<unsigned short int> > materialBins;
115 materialBins.reserve(nSecondBins);
116 for (
size_t isec = 0; isec < nSecondBins; ++isec) {
117 std::vector<unsigned short int> firstbins(nFirstBins,0);
118 materialBins.push_back(firstbins);
120 for (
size_t ifir = 0; ifir < nFirstBins; ++ifir) {
126 x0min = tinX0 < x0min ? tinX0 : x0min;
127 x0max = tinX0 > x0max ? tinX0 : x0max;
128 avZArhoMin = avZArho < avZArhoMin ? avZArho : avZArhoMin;
129 avZArhoMax = avZArho > avZArhoMax ? avZArho : avZArhoMax;
134 double stepX0 = (x0max-x0min)/m_compressedMaterialX0Bins;
135 double stepZArho = (avZArhoMax-avZArhoMin)/m_compressedMaterialZARhoBins;
137 std::vector< std::vector< std::vector< Trk::IndexedMaterial> > > materialHistogram;
138 materialHistogram.reserve(m_compressedMaterialZARhoBins);
140 for (
size_t izarho = 0; izarho < m_compressedMaterialZARhoBins; ++izarho) {
141 std::vector< std::vector < Trk::IndexedMaterial > > x0materialbins;
142 x0materialbins.reserve(m_compressedMaterialX0Bins);
143 for (
size_t ix0 = 0; ix0 < m_compressedMaterialX0Bins; ++ix0) {
144 std::vector < Trk::IndexedMaterial > materialBin;
145 x0materialbins.push_back( materialBin );
147 materialHistogram.push_back(x0materialbins);
150 for (
size_t isec = 0; isec < nSecondBins; ++isec) {
151 for (
size_t ifir = 0; ifir < nFirstBins; ++ifir) {
158 int x0bin =
int( (tinX0-x0min)/stepX0 );
159 int zarhobin =
int( (avZArho-avZArhoMin)/stepZArho );
161 x0bin = ( (size_t)x0bin >= m_compressedMaterialX0Bins) ? m_compressedMaterialX0Bins-1 : x0bin;
162 x0bin = x0bin < 0 ? 0 : x0bin;
163 zarhobin = ( (size_t)zarhobin >= m_compressedMaterialZARhoBins) ? m_compressedMaterialZARhoBins-1 : zarhobin;
164 zarhobin = zarhobin < 0 ? 0 : zarhobin;
168 idxMaterial.firstBin = ifir;
169 idxMaterial.secondBin = isec;
171 materialHistogram[zarhobin][x0bin].push_back(idxMaterial);
176 materialVector.push_back(
nullptr);
178 for (
size_t izarho = 0; izarho < m_compressedMaterialZARhoBins; ++izarho) {
179 for (
size_t ix0 = 0; ix0 < m_compressedMaterialX0Bins; ++ix0) {
181 std::vector< Trk::IndexedMaterial > indexedMaterial = materialHistogram[izarho][ix0];
182 if (!indexedMaterial.empty()) {
191 for ( ; idmIter != idmIterEnd; ++idmIter ) {
192 tinX0 += (*idmIter).materialProperties->thicknessInX0();
193 tinL0 += (*idmIter).materialProperties->thicknessInL0();
194 avA += (*idmIter).materialProperties->averageA();
195 avZ += (*idmIter).materialProperties->averageZ();
196 avRho += (*idmIter).materialProperties->averageRho();
198 double measure = 1./(indexedMaterial.size());
207 avRho *= avT/m_compressedMaterialThickness;
209 m_compressedMaterialThickness/tinX0,
210 m_compressedMaterialThickness/tinL0,
215 int matindex =
int(materialVector.size()-1);
216 idmIter = indexedMaterial.begin();
217 for ( ; idmIter != idmIterEnd; ++idmIter )
218 materialBins[(*idmIter).secondBin][(*idmIter).firstBin] = matindex;
224 std::vector<unsigned short int> materialBinsVector;
225 materialBinsVector.reserve( (lBinUtility.
max(0)+1)*(lBinUtility.
max(1)+1) );
226 std::vector< std::vector<unsigned short int> >
::iterator binVecIter = materialBins.begin();
227 std::vector< std::vector<unsigned short int> >
::iterator binVecIterEnd = materialBins.end();
228 for ( ; binVecIter != binVecIterEnd; ++binVecIter) {
231 for ( ; binIter != binIterEnd; ++binIter )
232 materialBinsVector.push_back(*binIter);