88{
89
92
93 size_t nFirstBins = lBinUtility.max(0)+1;
94 size_t nSecondBins = lBinUtility.max(1)+1;
95
96 double x0min = 10e10;
97 double x0max = 0.;
98 double avZArhoMin = 10e10;
99 double avZArhoMax = 0.;
100
101 std::vector< std::vector<unsigned short int> > materialBins;
102
103 materialBins.reserve(nSecondBins);
104 for (size_t isec = 0; isec < nSecondBins; ++isec) {
105 std::vector<unsigned short int> firstbins(nFirstBins,0);
106 materialBins.push_back(firstbins);
107
108 for (size_t ifir = 0; ifir < nFirstBins; ++ifir) {
109
110 const Trk::MaterialProperties* matProp = materialProperties[isec][ifir];
111 if (matProp) {
114 x0min = tinX0 < x0min ? tinX0 : x0min;
115 x0max = tinX0 > x0max ? tinX0 : x0max;
116 avZArhoMin = avZArho < avZArhoMin ? avZArho : avZArhoMin;
117 avZArhoMax = avZArho > avZArhoMax ? avZArho : avZArhoMax;
118 }
119 }
120 }
121
124
125 std::vector< std::vector< std::vector< Trk::IndexedMaterial> > > materialHistogram;
127
129 std::vector< std::vector < Trk::IndexedMaterial > > x0materialbins;
132 std::vector < Trk::IndexedMaterial > materialBin;
133 x0materialbins.push_back( materialBin );
134 }
135 materialHistogram.push_back(x0materialbins);
136 }
137
138 for (size_t isec = 0; isec < nSecondBins; ++isec) {
139 for (size_t ifir = 0; ifir < nFirstBins; ++ifir) {
140
141 const Trk::MaterialProperties* matProp = dynamic_cast<const Trk::MaterialProperties*>(materialProperties[isec][ifir]);
142 if (matProp) {
143
146 int x0bin =
int( (tinX0-x0min)/stepX0 );
147 int zarhobin =
int( (avZArho-avZArhoMin)/stepZArho );
148
150 x0bin = x0bin < 0 ? 0 : x0bin;
152 zarhobin = zarhobin < 0 ? 0 : zarhobin;
153
154 Trk::IndexedMaterial idxMaterial{};
158
159 materialHistogram[zarhobin][x0bin].push_back(idxMaterial);
160 }
161 }
162 }
163
164 materialVector.push_back(nullptr);
165
168
169 std::vector< Trk::IndexedMaterial > indexedMaterial = materialHistogram[izarho][ix0];
170 if (!indexedMaterial.empty()) {
171 double avT = 0.;
172 double tinX0 = 0.;
173 double tinL0 = 0.;
174 double avA = 0.;
175 double avZ = 0.;
176 double avRho = 0.;
177 std::vector< Trk::IndexedMaterial >::iterator idmIter = indexedMaterial.begin();
178 std::vector< Trk::IndexedMaterial >::iterator idmIterEnd = indexedMaterial.end();
179 for ( ; idmIter != idmIterEnd; ++idmIter ) {
180 tinX0 += (*idmIter).materialProperties->thicknessInX0();
181 tinL0 += (*idmIter).materialProperties->thicknessInL0();
182 avA += (*idmIter).materialProperties->averageA();
183 avZ += (*idmIter).materialProperties->averageZ();
184 avRho += (*idmIter).materialProperties->averageRho();
185 }
186 double measure = 1./(indexedMaterial.size());
187
188 tinX0 *= measure;
189 tinL0 *= measure;
190 avA *= measure;
191 avZ *= measure;
192 avRho *= measure;
193 avT *= measure;
194
199 avA,
200 avZ,
201 avRho));
202
203 int matindex =
int(materialVector.size()-1);
204 idmIter = indexedMaterial.begin();
205 for ( ; idmIter != idmIterEnd; ++idmIter )
206 materialBins[(*idmIter).secondBin][(*idmIter).firstBin] = matindex;
207 }
208 }
209 }
210
211
212 std::vector<unsigned short int> materialBinsVector;
213 materialBinsVector.reserve( (lBinUtility.max(0)+1)*(lBinUtility.max(1)+1) );
214 std::vector< std::vector<unsigned short int> >::iterator binVecIter = materialBins.begin();
215 std::vector< std::vector<unsigned short int> >::iterator binVecIterEnd = materialBins.end();
216 for ( ; binVecIter != binVecIterEnd; ++binVecIter) {
217 std::vector<unsigned short int>::iterator binIter = (*binVecIter).begin();
218 std::vector<unsigned short int>::iterator binIterEnd = (*binVecIter).end();
219 for ( ; binIter != binIterEnd; ++binIter )
220 materialBinsVector.push_back(*binIter);
221 }
222
224
225
226 return new Trk::CompressedLayerMaterial(lBinUtility,materialVector,materialBinsVector);
227}
Gaudi::Property< double > m_compressedMaterialThickness
Gaudi::Property< unsigned int > m_compressedMaterialZARhoBins
Gaudi::Property< unsigned int > m_compressedMaterialX0Bins
float thicknessInX0() const
Return the radiationlength fraction.
float zOverAtimesRho() const
Return the .
unsigned short int secondBin
const Trk::MaterialProperties * materialProperties
unsigned short int firstBin