Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:09:36

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2016-2018 CERN for the benefit of the Acts project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
0008 
0009 #include "Acts/Geometry/GlueVolumesDescriptor.hpp"
0010 
0011 #include "Acts/Geometry/TrackingVolume.hpp"
0012 
0013 #include <ostream>
0014 #include <utility>
0015 
0016 Acts::GlueVolumesDescriptor::GlueVolumesDescriptor(
0017     const std::map<BoundarySurfaceFace,
0018                    std::shared_ptr<const TrackingVolumeArray>>& gvs)
0019     : m_glueVolumes(gvs) {
0020   // fill the available faces
0021   for (auto& gvIter : m_glueVolumes) {
0022     m_glueFaces.push_back(gvIter.first);
0023   }
0024 }
0025 
0026 void Acts::GlueVolumesDescriptor::registerGlueVolumes(
0027     Acts::BoundarySurfaceFace bsf,
0028     std::shared_ptr<const TrackingVolumeArray> gvs) {
0029   // register the face
0030   auto searchIter = m_glueVolumes.find(bsf);
0031   if (searchIter == m_glueVolumes.end()) {
0032     m_glueFaces.push_back(bsf);
0033   }
0034   // simple assignment overwrites already existing entries
0035   m_glueVolumes[bsf] =
0036       std::move(gvs);  //!< @todo change to addGlueVolumes principle
0037 }
0038 
0039 std::shared_ptr<const Acts::TrackingVolumeArray>
0040 Acts::GlueVolumesDescriptor::glueVolumes(Acts::BoundarySurfaceFace bsf) const {
0041   // searching for the glue volumes according
0042   auto searchIter = m_glueVolumes.find(bsf);
0043   if (searchIter != m_glueVolumes.end()) {
0044     return searchIter->second;
0045   }
0046   return nullptr;
0047 }
0048 
0049 std::string Acts::GlueVolumesDescriptor::screenOutput() const {
0050   std::stringstream sl;
0051   sl << "Acts::GlueVolumesDescriptor: " << std::endl;
0052   const std::vector<Acts::BoundarySurfaceFace>& glueFaceVector = glueFaces();
0053   sl << "     has Tracking Volumes registered for : " << glueFaceVector.size()
0054      << " Volume faces." << std::endl;
0055   // loop over the faces
0056   for (auto& gFace : glueFaceVector) {
0057     const std::vector<TrackingVolumePtr>& glueVolumesVector =
0058         glueVolumes(gFace)->arrayObjects();
0059     // loop over the TrackingVolumes
0060     sl << "        -----> Processing Face: " << int(gFace) << " - has ";
0061     sl << glueVolumesVector.size()
0062        << " TrackingVolumes marked as 'GlueVolumes' " << std::endl;
0063     for (auto& glueVolume : glueVolumesVector) {
0064       sl << "             - TrackingVolume: " << glueVolume->volumeName()
0065          << std::endl;
0066     }
0067   }
0068   return sl.str();
0069 }
0070 
0071 std::ostream& Acts::operator<<(std::ostream& sl,
0072                                const GlueVolumesDescriptor& gvd) {
0073   sl << gvd.screenOutput();
0074   return sl;
0075 }