27 :
WriterT(cfg.collection,
"RootMaterialTrackWriter", level),
29 m_outputFile(cfg.rootFile) {
32 throw std::invalid_argument(
"Missing input collection");
34 throw std::invalid_argument(
"Missing tree name");
41 throw std::ios_base::failure(
"Could not open '" +
m_cfg.
filePath);
46 new TTree(
m_cfg.
treeName.c_str(),
"TTree from RootMaterialTrackWriter");
48 throw std::bad_alloc();
91 m_outputFile->Close();
96 ACTS_INFO(
"Writing ROOT output File : " << m_cfg.filePath);
98 m_outputTree->Write();
104 const std::vector<Acts::RecordedMaterialTrack>& materialTracks) {
106 std::lock_guard<std::mutex> lock(m_writeMutex);
109 for (
auto& mtrack : materialTracks) {
120 m_step_length.clear();
132 m_sur_range_min.clear();
133 m_sur_range_max.clear();
136 size_t mints = mtrack.second.materialInteractions.size();
137 m_step_sx.reserve(mints);
138 m_step_sy.reserve(mints);
139 m_step_sz.reserve(mints);
140 m_step_x.reserve(mints);
141 m_step_y.reserve(mints);
142 m_step_ez.reserve(mints);
143 m_step_ex.reserve(mints);
144 m_step_ey.reserve(mints);
145 m_step_ez.reserve(mints);
146 m_step_length.reserve(mints);
147 m_step_X0.reserve(mints);
148 m_step_L0.reserve(mints);
149 m_step_A.reserve(mints);
150 m_step_Z.reserve(mints);
151 m_step_rho.reserve(mints);
153 m_sur_id.reserve(mints);
154 m_sur_type.reserve(mints);
155 m_sur_x.reserve(mints);
156 m_sur_y.reserve(mints);
157 m_sur_z.reserve(mints);
158 m_sur_range_min.reserve(mints);
159 m_sur_range_max.reserve(mints);
162 if (m_cfg.recalculateTotals) {
166 m_tX0 = mtrack.second.materialInX0;
167 m_tL0 = mtrack.second.materialInL0;
171 m_v_x = mtrack.first.first.x();
172 m_v_y = mtrack.first.first.y();
173 m_v_z = mtrack.first.first.z();
174 m_v_px = mtrack.first.second.x();
175 m_v_py = mtrack.first.second.y();
176 m_v_pz = mtrack.first.second.z();
177 m_v_phi =
phi(mtrack.first.second);
178 m_v_eta =
eta(mtrack.first.second);
181 for (
auto& mint : mtrack.second.materialInteractions) {
183 m_step_x.push_back(mint.position.x());
184 m_step_y.push_back(mint.position.y());
185 m_step_z.push_back(mint.position.z());
187 if (m_cfg.prePostStep) {
189 mint.position - 0.5 * mint.pathCorrection * mint.direction;
191 mint.position + 0.5 * mint.pathCorrection * mint.direction;
192 m_step_sx.push_back(prePos.x());
193 m_step_sy.push_back(prePos.y());
194 m_step_sz.push_back(prePos.z());
195 m_step_ex.push_back(posPos.x());
196 m_step_ey.push_back(posPos.y());
197 m_step_ez.push_back(posPos.z());
200 if (m_cfg.storesurface) {
205 ctx.
geoContext, mint.position, mint.direction,
true);
206 layerID = surface->
geoID();
207 m_sur_id.push_back(layerID.
value());
208 m_sur_type.push_back(surface->
type());
209 m_sur_x.push_back(intersection.
position.x());
210 m_sur_y.push_back(intersection.
position.y());
211 m_sur_z.push_back(intersection.
position.z());
220 m_sur_range_min.push_back(radialBounds->
rMin());
221 m_sur_range_max.push_back(radialBounds->
rMax());
222 }
else if (cylinderBounds) {
223 m_sur_range_min.push_back(
225 m_sur_range_max.push_back(
228 m_sur_range_min.push_back(0);
229 m_sur_range_max.push_back(0);
237 m_sur_id.push_back(layerID.
value());
238 m_sur_type.push_back(-1);
240 m_sur_x.push_back(0);
241 m_sur_y.push_back(0);
242 m_sur_z.push_back(0);
243 m_sur_range_min.push_back(0);
244 m_sur_range_max.push_back(0);
249 const auto& mprops = mint.materialProperties;
250 m_step_length.push_back(mprops.thickness());
251 m_step_X0.push_back(mprops.material().X0());
252 m_step_L0.push_back(mprops.material().L0());
253 m_step_A.push_back(mprops.material().Ar());
254 m_step_Z.push_back(mprops.material().Z());
255 m_step_rho.push_back(mprops.material().massDensity());
257 if (m_cfg.recalculateTotals) {
258 m_tX0 += mprops.thicknessInX0();
259 m_tL0 += mprops.thicknessInL0();
263 m_outputTree->Fill();