31 :
WriterT(cfg.inputClusters,
"RootPlanarClusterWriter", lvl),
33 m_outputFile(cfg.rootFile) {
36 throw std::invalid_argument(
"Missing simulated hits input collection");
39 throw std::invalid_argument(
"Missing tree name");
45 throw std::ios_base::failure(
"Could not open '" +
m_cfg.
filePath);
50 new TTree(
m_cfg.
treeName.c_str(),
"TTree from RootPlanarClusterWriter");
52 throw std::bad_alloc();
83 if (m_cfg.rootFile ==
nullptr) {
84 m_outputFile->Close();
91 m_outputTree->Write();
92 ACTS_INFO(
"Wrote particles to tree '" << m_cfg.treeName <<
"' in '"
93 << m_cfg.filePath <<
"'");
102 const auto& simHits =
106 std::lock_guard<std::mutex> lock(m_writeMutex);
111 for (
const auto& entry : clusters) {
125 clusterSurface.localToGlobal(ctx.
geoContext, local, mom);
127 m_volumeID = geoId.
volume();
128 m_layerID = geoId.
layer();
141 clusterSurface.associatedDetectorElement());
142 for (
auto& cell : cells) {
144 m_cell_IDx.push_back(cell.channel0);
145 m_cell_IDy.push_back(cell.channel1);
146 m_cell_data.push_back(cell.data);
148 if (detectorElement && detectorElement->digitizationModule()) {
151 digitationModule->segmentation();
153 auto cellLocalPosition = segmentation.
cellPosition(cell);
154 m_cell_lx.push_back(cellLocalPosition.x());
155 m_cell_ly.push_back(cellLocalPosition.y());
160 for (
auto idx : cluster.
sourceLink().indices()) {
161 auto it = simHits.nth(idx);
162 if (
it == simHits.end()) {
163 ACTS_FATAL(
"Simulation hit with index " << idx <<
" does not exist");
164 return ProcessCode::ABORT;
166 const auto& simHit = *
it;
170 auto lpResult = clusterSurface.globalToLocal(
171 ctx.
geoContext, simHit.position(), simHit.unitDirection());
172 if (not lpResult.ok()) {
173 ACTS_FATAL(
"Global to local transformation did not succeed.");
174 return ProcessCode::ABORT;
176 lPosition = lpResult.value();
178 m_t_gx.push_back(simHit.position().x());
179 m_t_gy.push_back(simHit.position().y());
180 m_t_gz.push_back(simHit.position().z());
181 m_t_gt.push_back(simHit.time());
182 m_t_lx.push_back(lPosition.x());
183 m_t_ly.push_back(lPosition.y());
184 m_t_barcode.push_back(simHit.particleId().value());
187 m_outputTree->Fill();