Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:01

0001 
0002 // This file is part of the Acts project.
0003 //
0004 // Copyright (C) 2022 CERN for the benefit of the Acts project
0005 //
0006 // This Source Code Form is subject to the terms of the Mozilla Public
0007 // License, v. 2.0. If a copy of the MPL was not distributed with this
0008 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
0009 
0010 #pragma once
0011 
0012 #include "ActsDD4hep/ActsExtension.hpp"
0013 
0014 #include <DD4hep/DetElement.h>
0015 #include <DD4hep/DetFactoryHelper.h>
0016 
0017 #include "XML/XMLElements.h"
0018 #include <boost/foreach.hpp>
0019 #include <boost/tokenizer.hpp>
0020 
0021 namespace Acts {
0022 
0023 /// Helper method that decorates an ActsExtension with proto material
0024 /// description for boundaries
0025 /// - it assigns bins for inner / representing / outer
0026 
0027 /// Helper method that decorates an ActsExtension with proto material
0028 /// description,
0029 /// - it assigns bins for inner / representing / outer
0030 ///
0031 /// @param x_material the material tag to be inspected
0032 /// @param actsExtension the extension that is augmented
0033 /// @param baseTag the xml tag to be checked
0034 void xmlToProtoSurfaceMaterial(const xml_comp_t& x_material,
0035                                ActsExtension& actsExtension,
0036                                const std::string& baseTag);
0037 }
0038 
0039 inline void Acts::xmlToProtoSurfaceMaterial(const xml_comp_t& x_material,
0040                                      ActsExtension& actsExtension,
0041                                      const std::string& baseTag) {
0042   // Add the layer material flag
0043   actsExtension.addType(baseTag);
0044   // prepare everything here
0045   std::string mSurface = x_material.attr<std::string>("surface");
0046   std::string mBinning = x_material.attr<std::string>("binning");
0047   boost::char_separator<char> sep(",");
0048   boost::tokenizer binTokens(mBinning, sep);
0049   const auto n = std::distance(binTokens.begin(), binTokens.end());
0050   if (n == 2) {
0051     // Fill the bins
0052     auto bin = binTokens.begin();
0053     std::string bin0 = *(bin);
0054     std::string bin1 = *(++bin);
0055     size_t nBins0 = x_material.attr<int>("bins0");
0056     size_t nBins1 = x_material.attr<int>("bins1");
0057     // Add the material tags
0058     std::string btmSurface = baseTag + std::string("_") + mSurface;
0059     actsExtension.addValue(nBins0, bin0, btmSurface);
0060     actsExtension.addValue(nBins1, bin1, btmSurface);
0061   }
0062 }