100{
101
104
105 size_t nFirstBins = lBinUtility.max(0)+1;
106 size_t nSecondBins = lBinUtility.max(1)+1;
107
108 double x0min = 10e10;
109 double x0max = 0.;
110 double avZArhoMin = 10e10;
111 double avZArhoMax = 0.;
112
113 std::vector< std::vector<unsigned short int> > materialBins;
114
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);
119
120 for (size_t ifir = 0; ifir < nFirstBins; ++ifir) {
121
122 const Trk::MaterialProperties* matProp = materialProperties[isec][ifir];
123 if (matProp) {
126 x0min = tinX0 < x0min ? tinX0 : x0min;
127 x0max = tinX0 > x0max ? tinX0 : x0max;
128 avZArhoMin = avZArho < avZArhoMin ? avZArho : avZArhoMin;
129 avZArhoMax = avZArho > avZArhoMax ? avZArho : avZArhoMax;
130 }
131 }
132 }
133
136
137 std::vector< std::vector< std::vector< Trk::IndexedMaterial> > > materialHistogram;
139
141 std::vector< std::vector < Trk::IndexedMaterial > > x0materialbins;
144 std::vector < Trk::IndexedMaterial > materialBin;
145 x0materialbins.push_back( materialBin );
146 }
147 materialHistogram.push_back(x0materialbins);
148 }
149
150 for (size_t isec = 0; isec < nSecondBins; ++isec) {
151 for (size_t ifir = 0; ifir < nFirstBins; ++ifir) {
152
153 const Trk::MaterialProperties* matProp = dynamic_cast<const Trk::MaterialProperties*>(materialProperties[isec][ifir]);
154 if (matProp) {
155
158 int x0bin =
int( (tinX0-x0min)/stepX0 );
159 int zarhobin =
int( (avZArho-avZArhoMin)/stepZArho );
160
162 x0bin = x0bin < 0 ? 0 : x0bin;
164 zarhobin = zarhobin < 0 ? 0 : zarhobin;
165
166 Trk::IndexedMaterial idxMaterial{};
170
171 materialHistogram[zarhobin][x0bin].push_back(idxMaterial);
172 }
173 }
174 }
175
176 materialVector.push_back(nullptr);
177
180
181 std::vector< Trk::IndexedMaterial > indexedMaterial = materialHistogram[izarho][ix0];
182 if (!indexedMaterial.empty()) {
183 double avT = 0.;
184 double tinX0 = 0.;
185 double tinL0 = 0.;
186 double avA = 0.;
187 double avZ = 0.;
188 double avRho = 0.;
189 std::vector< Trk::IndexedMaterial >::iterator idmIter = indexedMaterial.begin();
190 std::vector< Trk::IndexedMaterial >::iterator idmIterEnd = indexedMaterial.end();
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();
197 }
198 double measure = 1./(indexedMaterial.size());
199
200 tinX0 *= measure;
201 tinL0 *= measure;
202 avA *= measure;
203 avZ *= measure;
204 avRho *= measure;
205 avT *= measure;
206
211 avA,
212 avZ,
213 avRho));
214
215 int matindex =
int(materialVector.size()-1);
216 idmIter = indexedMaterial.begin();
217 for ( ; idmIter != idmIterEnd; ++idmIter )
218 materialBins[(*idmIter).secondBin][(*idmIter).firstBin] = matindex;
219 }
220 }
221 }
222
223
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) {
229 std::vector<unsigned short int>::iterator binIter = (*binVecIter).begin();
230 std::vector<unsigned short int>::iterator binIterEnd = (*binVecIter).end();
231 for ( ; binIter != binIterEnd; ++binIter )
232 materialBinsVector.push_back(*binIter);
233 }
234
236
237
238 return new Trk::CompressedLayerMaterial(lBinUtility,materialVector,materialBinsVector);
239}
float thicknessInX0() const
Return the radiationlength fraction.
float zOverAtimesRho() const
Return the .
unsigned short int secondBin
const Trk::MaterialProperties * materialProperties
unsigned short int firstBin