30 :
WriterT(cfg.collection,
"RootMaterialTrackWriter", level),
32 m_outputFile(cfg.rootFile) {
35 throw std::invalid_argument(
"Missing input collection");
37 throw std::invalid_argument(
"Missing tree name");
44 throw std::ios_base::failure(
"Could not open '" +
m_cfg.
filePath);
49 new TTree(
m_cfg.
treeName.c_str(),
"TTree from RootMaterialTrackWriter");
51 throw std::bad_alloc();
100 m_outputFile->Close();
105 ACTS_INFO(
"Writing ROOT output File : " << m_cfg.filePath);
107 m_outputTree->Write();
113 const std::vector<Acts::RecordedMaterialTrack>& materialTracks) {
115 std::lock_guard<std::mutex> lock(m_writeMutex);
118 for (
auto& mtrack : materialTracks) {
132 m_step_length.clear();
144 m_sur_range_min.clear();
145 m_sur_range_max.clear();
150 size_t mints = mtrack.second.materialInteractions.size();
151 m_step_sx.reserve(mints);
152 m_step_sy.reserve(mints);
153 m_step_sz.reserve(mints);
154 m_step_x.reserve(mints);
155 m_step_y.reserve(mints);
156 m_step_z.reserve(mints);
157 m_step_ex.reserve(mints);
158 m_step_ey.reserve(mints);
159 m_step_ez.reserve(mints);
160 m_step_dx.reserve(mints);
161 m_step_dy.reserve(mints);
162 m_step_dz.reserve(mints);
163 m_step_length.reserve(mints);
164 m_step_X0.reserve(mints);
165 m_step_L0.reserve(mints);
166 m_step_A.reserve(mints);
167 m_step_Z.reserve(mints);
168 m_step_rho.reserve(mints);
170 m_sur_id.reserve(mints);
171 m_sur_type.reserve(mints);
172 m_sur_x.reserve(mints);
173 m_sur_y.reserve(mints);
174 m_sur_z.reserve(mints);
175 m_sur_range_min.reserve(mints);
176 m_sur_range_max.reserve(mints);
178 m_vol_id.reserve(mints);
181 if (m_cfg.recalculateTotals) {
185 m_tX0 = mtrack.second.materialInX0;
186 m_tL0 = mtrack.second.materialInL0;
190 m_v_x = mtrack.first.first.x();
191 m_v_y = mtrack.first.first.y();
192 m_v_z = mtrack.first.first.z();
193 m_v_px = mtrack.first.second.x();
194 m_v_py = mtrack.first.second.y();
195 m_v_pz = mtrack.first.second.z();
196 m_v_phi =
phi(mtrack.first.second);
197 m_v_eta =
eta(mtrack.first.second);
200 for (
auto& mint : mtrack.second.materialInteractions) {
202 m_step_x.push_back(mint.position.x());
203 m_step_y.push_back(mint.position.y());
204 m_step_z.push_back(mint.position.z());
205 m_step_dx.push_back(mint.direction.x());
206 m_step_dy.push_back(mint.direction.y());
207 m_step_dz.push_back(mint.direction.z());
209 if (m_cfg.prePostStep) {
211 mint.position - 0.5 * mint.pathCorrection * mint.direction;
213 mint.position + 0.5 * mint.pathCorrection * mint.direction;
214 m_step_sx.push_back(prePos.x());
215 m_step_sy.push_back(prePos.y());
216 m_step_sz.push_back(prePos.z());
217 m_step_ex.push_back(posPos.x());
218 m_step_ey.push_back(posPos.y());
219 m_step_ez.push_back(posPos.z());
223 if (m_cfg.storeSurface) {
227 auto sfIntersection = surface->
intersect(
228 ctx.
geoContext, mint.position, mint.direction,
true);
230 m_sur_id.push_back(slayerID.
value());
231 m_sur_type.push_back(surface->
type());
232 m_sur_x.push_back(sfIntersection.intersection.position.x());
233 m_sur_y.push_back(sfIntersection.intersection.position.y());
234 m_sur_z.push_back(sfIntersection.intersection.position.z());
243 m_sur_range_min.push_back(radialBounds->
rMin());
244 m_sur_range_max.push_back(radialBounds->
rMax());
245 }
else if (cylinderBounds) {
246 m_sur_range_min.push_back(
248 m_sur_range_max.push_back(
251 m_sur_range_min.push_back(0);
252 m_sur_range_max.push_back(0);
260 m_sur_id.push_back(slayerID.
value());
261 m_sur_type.push_back(-1);
263 m_sur_x.push_back(0);
264 m_sur_y.push_back(0);
265 m_sur_z.push_back(0);
266 m_sur_range_min.push_back(0);
267 m_sur_range_max.push_back(0);
272 if (m_cfg.storeVolume) {
277 m_vol_id.push_back(vlayerID.
value());
284 m_vol_id.push_back(vlayerID.
value());
289 const auto& mprops = mint.materialSlab;
290 m_step_length.push_back(mprops.thickness());
291 m_step_X0.push_back(mprops.material().X0());
292 m_step_L0.push_back(mprops.material().L0());
293 m_step_A.push_back(mprops.material().Ar());
294 m_step_Z.push_back(mprops.material().Z());
295 m_step_rho.push_back(mprops.material().massDensity());
297 if (m_cfg.recalculateTotals) {
298 m_tX0 += mprops.thicknessInX0();
299 m_tL0 += mprops.thicknessInL0();
303 m_outputTree->Fill();