From f2f88991d2c72dfe3e778d96141c6e2db7d78b68 Mon Sep 17 00:00:00 2001 From: David Nathan Brown Date: Mon, 11 May 2026 16:01:26 -0700 Subject: [PATCH 1/9] Add materials for DS --- GeometryService/src/KinKalGeomMaker.cc | 10 ++++++++++ TrackerConditions/data/MaterialsList.data | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/GeometryService/src/KinKalGeomMaker.cc b/GeometryService/src/KinKalGeomMaker.cc index 5c955ef72e..e05f1c128a 100644 --- a/GeometryService/src/KinKalGeomMaker.cc +++ b/GeometryService/src/KinKalGeomMaker.cc @@ -79,6 +79,16 @@ namespace mu2e { } void KinKalGeomMaker::makeDS() { + GeomHandle det; + GeomHandle ds; + std::cout << "DS Cryo or " << ds->rOut1() << "," << ds->rOut2() << " ir " << ds->rIn1()<<","<< ds->rIn2() << " halfl " << ds->halfLength() + << " zpos " << ds->position().z() << " material " << ds->material() << std::endl; + std::cout << "DS shield or " << ds->shield_rOut1() << "," << ds->shield_rOut2() << " ir " << ds->shield_rIn1()<<","<< ds->shield_rIn2() << " halfl " << ds->shield_halfLength() << " material " << ds->shield_material() << std::endl; + std::cout << "DS ncoils " << ds->nCoils() << std::endl; + for(size_t icoil = 0; icoil < static_cast(ds->nCoils()); icoil++){ + std::cout << "DS coil ir " << ds->coil_rIn() << " or " << ds->coil_rOut()[icoil] << " length " << ds->coil_zLength()[icoil] << " zpos " << ds->coil_zPosition()[icoil] + << " material " << ds->coil_materials()[icoil] << std::endl; + } // currently use hard-coded geometry auto inner= std::make_shared(VEC3(0.0,0.0,1.0),VEC3(0.0,0.0,-1482),950,5450); auto outer= std::make_shared(VEC3(0.0,0.0,1.0),VEC3(0.0,0.0,-1482),1328,5450); // bounding surfaces diff --git a/TrackerConditions/data/MaterialsList.data b/TrackerConditions/data/MaterialsList.data index 9d2b64e7e6..01b9b5451b 100644 --- a/TrackerConditions/data/MaterialsList.data +++ b/TrackerConditions/data/MaterialsList.data @@ -1,5 +1,5 @@ # -# This is an exhaustive list of materials for entry into the Conditions DB +# This is an exhaustive list of materials used in Mu2e KinKal # # Do not remove the following line it's a tag ! #Materials_list @@ -29,4 +29,9 @@ cathode 5.2 0. 0. +2 86.4e-2 Copper 0 13.6e-2 straw-wall 1 -10 # effective straw wall + gas material, assuming uniform mass distribution straw_15um 1.927e-2 0.0 0.0 +2 91.3e-2 straw-wall 1 8.7e-2 straw-gas 1 -10 -20 -30 20.0 1.0 solid straw_25um 3.068e-2 0.0 0.0 +2 94.6e-2 straw-wall 1 5.4e-2 straw-gas 1 -10 -20 -30 20.0 1.0 solid +# DS materials +NbTi 6.5 0.0 0.0 +2 0.65 Niobium 0.35 Titanium 0 -10 -20 -30 20.0 1.0 solid +DS1Coil 3.35 0.0 0.0 +2 0.67 Aluminum 0.33 NbTi 0 -10 -20 -30 20.0 1.0 solid +DS2Coil 3.031 0.0 0.0 +2 0.813 Aluminum 0.187 NbTi 0 -10 -20 -30 20.0 1.0 solid +DSSStainless 8.02 0.0 0.0 +5 0.02 Manganese 0.01 Silicon 0.19 Chromium 0.1 Nickel 0.68 Iron 0 -10 -20 -30 20.0 1.0 solid From bfc1fd998fd24e885f6b0527c38016350134af7b Mon Sep 17 00:00:00 2001 From: David Nathan Brown Date: Sat, 16 May 2026 10:32:20 -0700 Subject: [PATCH 2/9] Prep for moving KKMaterial to KinKalGeom --- GeometryService/src/KinKalGeomMaker.cc | 26 +++++++++++++++++++++++--- KinKalGeom/inc/DetectorSolenoid.hh | 4 ++-- KinKalGeom/inc/KinKalGeom.hh | 2 +- KinKalGeom/inc/ShellMaterial.hh | 21 +++++++++++++++++++++ Mu2eKinKal/inc/KKStrawMaterial.hh | 10 ++++------ Mu2eKinKal/inc/KKStrawXing.hh | 5 +++-- Mu2eKinKal/src/KKStrawMaterial.cc | 16 +++++++--------- RecoDataProducts/inc/TrkStraw.hh | 3 ++- 8 files changed, 63 insertions(+), 24 deletions(-) create mode 100644 KinKalGeom/inc/ShellMaterial.hh diff --git a/GeometryService/src/KinKalGeomMaker.cc b/GeometryService/src/KinKalGeomMaker.cc index e05f1c128a..9d33dbccdb 100644 --- a/GeometryService/src/KinKalGeomMaker.cc +++ b/GeometryService/src/KinKalGeomMaker.cc @@ -89,11 +89,31 @@ namespace mu2e { std::cout << "DS coil ir " << ds->coil_rIn() << " or " << ds->coil_rOut()[icoil] << " length " << ds->coil_zLength()[icoil] << " zpos " << ds->coil_zPosition()[icoil] << " material " << ds->coil_materials()[icoil] << std::endl; } - // currently use hard-coded geometry - auto inner= std::make_shared(VEC3(0.0,0.0,1.0),VEC3(0.0,0.0,-1482),950,5450); - auto outer= std::make_shared(VEC3(0.0,0.0,1.0),VEC3(0.0,0.0,-1482),1328,5450); // bounding surfaces + //DS Cryo or 1303,1328 ir 950,969.05 halfl 5450 zpos 8689 material StainlessSteel + //DS shield or 1237.3,1250 ir 1010,1022.7 halfl 5287.7 material G4_Al + //DS ncoils 11 + //DS coil ir 1050 or 1091 length 419.75 zpos 3539 material DS1CoilMix + //DS coil ir 1050 or 1091 length 419.75 zpos 3964 material DS1CoilMix + //DS coil ir 1050 or 1091 length 419.75 zpos 4389 material DS1CoilMix + //DS coil ir 1050 or 1091 length 419.75 zpos 5042 material DS1CoilMix + //DS coil ir 1050 or 1091 length 362.25 zpos 5699 material DS1CoilMix + //DS coil ir 1050 or 1091 length 362.25 zpos 6369 material DS1CoilMix + //DS coil ir 1050 or 1091 length 362.25 zpos 7176 material DS1CoilMix + //DS coil ir 1050 or 1070.5 length 1777.5 zpos 7949 material DS2CoilMix + //DS coil ir 1050 or 1070.5 length 1777.5 zpos 9761 material DS2CoilMix + //DS coil ir 1050 or 1070.5 length 1777.5 zpos 11544 material DS2CoilMix + //DS coil ir 1050 or 1091 length 362.25 zpos 13326 material DS1CoilMix + // + // + // + // + auto inner= std::make_shared(VEC3(0.0,0.0,1.0),VEC3(0.0,0.0,-1482),ds->rIn1(),ds->halfLength()); + auto outer= std::make_shared(VEC3(0.0,0.0,1.0),VEC3(0.0,0.0,-1482),ds->rOut2(),ds->halfLength()); // bounding surfaces auto front= std::make_shared(outer->frontDisk()); auto back= std::make_shared(outer->backDisk()); + + + // hard-coded for now auto ipa= std::make_shared(VEC3(0.0,0.0,1.0),VEC3(0.0,0.0,-2770),300.0,500.0); auto ipafront= std::make_shared(ipa->frontDisk()); auto ipaback= std::make_shared(ipa->backDisk()); diff --git a/KinKalGeom/inc/DetectorSolenoid.hh b/KinKalGeom/inc/DetectorSolenoid.hh index 7721710689..5fd98a55db 100644 --- a/KinKalGeom/inc/DetectorSolenoid.hh +++ b/KinKalGeom/inc/DetectorSolenoid.hh @@ -48,8 +48,8 @@ namespace mu2e { auto const& outerProtonAbsorberPtr() const { return opa_; } auto const& upstreamAbsorberPtr() const { return tsda_; } private: - CylPtr inner_; // inner cryostat cylinder - CylPtr outer_; // outer cryostat cylinder + CylPtr inner_; // inner cryostat cylinder boundary + CylPtr outer_; // outer cryostat cylinder boundary DiskPtr front_; // front (upstream) and back (downstream) of DS DiskPtr back_; CylPtr ipa_; // inner proton absorber diff --git a/KinKalGeom/inc/KinKalGeom.hh b/KinKalGeom/inc/KinKalGeom.hh index 05770e6730..3d9a7e7dc2 100644 --- a/KinKalGeom/inc/KinKalGeom.hh +++ b/KinKalGeom/inc/KinKalGeom.hh @@ -25,7 +25,7 @@ namespace mu2e { using SurfacePairCollection = std::vector; using SurfacePairIter = std::multimap::const_iterator; using KKGMap = std::multimap; - // default constructor, now using GeometryService + // default constructor, now using GeometryService to create content KinKalGeom(); // accessor to the raw map auto const& map() const { return map_; } diff --git a/KinKalGeom/inc/ShellMaterial.hh b/KinKalGeom/inc/ShellMaterial.hh new file mode 100644 index 0000000000..91a8338949 --- /dev/null +++ b/KinKalGeom/inc/ShellMaterial.hh @@ -0,0 +1,21 @@ +// +// Class modeling a thin material as a surface, material, and thickness. Can be used to create a ShellXing in KKTrack +// Original author: David Brown (LBNL) 5/26 +// +#ifndef KinKalGeom_ShellMaterial_hh +#define KinKalGeom_ShellMaterial_hh +#include "Offline/DataProducts/inc/SurfaceId.hh" +#include "KinKal/Geometry/Surface.hh" +#include "KinKal/MatEnv/DetMaterial.hh" + +namespace mu2e { + class ShellMaterial { + using SurfacePtr = std::shared_ptr; + public: + private: + + SurfacePtr surf_; // surface for this materia + + + }; +} diff --git a/Mu2eKinKal/inc/KKStrawMaterial.hh b/Mu2eKinKal/inc/KKStrawMaterial.hh index ab76fe02b1..d6cdc18381 100644 --- a/Mu2eKinKal/inc/KKStrawMaterial.hh +++ b/Mu2eKinKal/inc/KKStrawMaterial.hh @@ -6,7 +6,6 @@ // #include "KinKal/Trajectory/ClosestApproachData.hh" #include "Offline/TrackerGeom/inc/StrawProperties.hh" -#include "Offline/Mu2eKinKal/inc/StrawXingUpdater.hh" namespace MatEnv { class MatDBInfo; @@ -30,15 +29,14 @@ namespace mu2e { const std::shared_ptr gasmat_, const std::shared_ptr wiremat_); // construct using materials by name - KKStrawMaterial(MatDBInfo const& matdbinfo,StrawProperties const& sprops, - const std::string& wallmat="straw-wall", const std::string& gasmat="straw-gas", const std::string& wiremat="straw-wire"); + KKStrawMaterial(MatDBInfo const& matdbinfo,StrawProperties const& sprops); // pathlength through straw components, given closest approach. Return the method used to compute the paths - PathCalc pathLengths(ClosestApproachData const& cadata,StrawXingUpdater const& caconfig, double& wallpath, double& gaspath, double& wirepath) const; + PathCalc pathLengths(ClosestApproachData const& cadata,double nsig, double& wallpath, double& gaspath, double& wirepath,int diag=0) const; PathCalc averagePathLengths(double& wallpath, double& gaspath, double& wirepath) const; // transit length given closest approach double transitLength(ClosestApproachData const& cadata) const; - // find the material crossings given doca and error on doca. Should allow for straw and wire to have different axes TODO - PathCalc findXings(ClosestApproachData const& cadata,StrawXingUpdater const& caconfig, std::vector& mxings) const; + // find the material crossings given doca and error on doca. The CA object should be WRT the straw axis, not the wire axis + PathCalc findXings(ClosestApproachData const& cadata, double nsig, std::vector& mxings, int diag=0) const; DetMaterial const& wallMaterial() const { return *wallmat_; } DetMaterial const& gasMaterial() const { return *gasmat_; } DetMaterial const& wireMaterial() const { return *wiremat_; } diff --git a/Mu2eKinKal/inc/KKStrawXing.hh b/Mu2eKinKal/inc/KKStrawXing.hh index 4c09250ea3..e32f7e0239 100644 --- a/Mu2eKinKal/inc/KKStrawXing.hh +++ b/Mu2eKinKal/inc/KKStrawXing.hh @@ -7,10 +7,11 @@ #include "Offline/Mu2eKinKal/inc/KKStrawHit.hh" #include "Offline/Mu2eKinKal/inc/StrawXingUpdater.hh" #include "Offline/Mu2eKinKal/inc/KKStrawMaterial.hh" +#include "Offline/TrackerGeom/inc/Straw.hh" +#include "Offline/DataProducts/inc/StrawId.hh" #include "KinKal/Trajectory/ParticleTrajectory.hh" #include "KinKal/Trajectory/SensorLine.hh" #include "KinKal/Trajectory/PiecewiseClosestApproach.hh" -#include "Offline/DataProducts/inc/StrawId.hh" #include "cetlib_except/exception.h" namespace mu2e { using KinKal::SVEC3; @@ -164,7 +165,7 @@ namespace mu2e { varscale_ = 1.0; } // update the material xings from gas, straw wall, and wire - smat_.findXings(ca_.tpData(),sxconfig_,mxings_); + smat_.findXings(ca_.tpData(),sxconfig_.nsig_,mxings_,sxconfig_.diag_); // update the effect these have on the parameters fparams_ = this->parameterChange(varscale_); } diff --git a/Mu2eKinKal/src/KKStrawMaterial.cc b/Mu2eKinKal/src/KKStrawMaterial.cc index a79a54cef3..404ff4220d 100644 --- a/Mu2eKinKal/src/KKStrawMaterial.cc +++ b/Mu2eKinKal/src/KKStrawMaterial.cc @@ -35,11 +35,11 @@ namespace mu2e { return KKStrawMaterial::average; } - KKStrawMaterial::PathCalc KKStrawMaterial::pathLengths(ClosestApproachData const& cadata,StrawXingUpdater const& caconfig, - double& wallpath, double& gaspath, double& wirepath) const { + KKStrawMaterial::PathCalc KKStrawMaterial::pathLengths(ClosestApproachData const& cadata,double nsig, + double& wallpath, double& gaspath, double& wirepath,int diag) const { wallpath = gaspath = wirepath = 0.0; PathCalc retval = KKStrawMaterial::unknown; - double docarange = caconfig.nsig_*sqrt(std::max(0.0,cadata.docaVar())); + double docarange = nsig*sqrt(std::max(0.0,cadata.docaVar())); // if the doca range covers the straw, use the average double adoca = fabs(cadata.doca()); double mindoca = std::max(0.0,std::min(adoca,irad_)-docarange); @@ -58,10 +58,9 @@ namespace mu2e { if(awall>0.0)wallpath = awall/(omaxdoca-mindoca); retval = range; } - if(caconfig.diag_>0){ + if(diag>0){ std::cout << "KKStrawMaterial: DOCA " << fabs(cadata.doca()) << " DOCA Var " << cadata.docaVar() << " range [" << mindoca << "," << imaxdoca << "] wall path (mm)" << wallpath << " gas path " << gaspath << " retval " << retval << std::endl; } - // Model the wire as a diffuse gas, density constrained by DOCA TODO // 3D pathlength includes projection along straw double afac = angleFactor(cadata.dirDot()); @@ -79,15 +78,14 @@ namespace mu2e { return tlen; } - KKStrawMaterial::PathCalc KKStrawMaterial::findXings(ClosestApproachData const& cadata,StrawXingUpdater const& caconfig, - std::vector& mxings) const { + KKStrawMaterial::PathCalc KKStrawMaterial::findXings(ClosestApproachData const& cadata, double nsig, std::vector 0.0) mxings.push_back(MaterialXing(*wallmat_,wallpath)); if(gaspath > 0.0) mxings.push_back(MaterialXing(*gasmat_,gaspath)); if(wirepath > 0.0) mxings.push_back(MaterialXing(*wiremat_,wirepath)); - if(caconfig.diag_ > 1){ + if(diag > 1){ std::cout << "Ce wall dE/dx " << wallmat_->energyLoss(105,1.0,0.511) << std::endl; std::cout << "Ce gas dE/dx " << gasmat_->energyLoss(105,1.0,0.511) << std::endl; } diff --git a/RecoDataProducts/inc/TrkStraw.hh b/RecoDataProducts/inc/TrkStraw.hh index 3af028030b..59d4a6db99 100644 --- a/RecoDataProducts/inc/TrkStraw.hh +++ b/RecoDataProducts/inc/TrkStraw.hh @@ -9,6 +9,7 @@ #include "Offline/DataProducts/inc/StrawId.hh" #include "Offline/RecoDataProducts/inc/StrawFlag.hh" #include "Offline/Mu2eKinKal/inc/KKStrawMaterial.hh" +#include "Offline/Mu2eKinKal/inc/StrawXingUpdater.hh" #include "KinKal/Trajectory/ClosestApproachData.hh" namespace mu2e { @@ -25,7 +26,7 @@ namespace mu2e { _dmom(dmom) { double wallpath, gaspath, wirepath; - _pcalc = smat.pathLengths(pocadata,caconfig,wallpath,gaspath,wirepath); + _pcalc = smat.pathLengths(pocadata,caconfig.nsig_,wallpath,gaspath,wirepath); _wallpath = wallpath; _gaspath = gaspath; _wirepath = wirepath; From d792d4d8c8b5e485c079559ae971b7cf96b4d5e7 Mon Sep 17 00:00:00 2001 From: David Nathan Brown Date: Sat, 16 May 2026 10:52:41 -0700 Subject: [PATCH 3/9] Fix bugs --- Mu2eKinKal/inc/KKStrawMaterial.hh | 4 +++- Mu2eKinKal/src/KKStrawMaterial.cc | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Mu2eKinKal/inc/KKStrawMaterial.hh b/Mu2eKinKal/inc/KKStrawMaterial.hh index d6cdc18381..d29f153a12 100644 --- a/Mu2eKinKal/inc/KKStrawMaterial.hh +++ b/Mu2eKinKal/inc/KKStrawMaterial.hh @@ -6,6 +6,7 @@ // #include "KinKal/Trajectory/ClosestApproachData.hh" #include "Offline/TrackerGeom/inc/StrawProperties.hh" +#include namespace MatEnv { class MatDBInfo; @@ -29,7 +30,8 @@ namespace mu2e { const std::shared_ptr gasmat_, const std::shared_ptr wiremat_); // construct using materials by name - KKStrawMaterial(MatDBInfo const& matdbinfo,StrawProperties const& sprops); + KKStrawMaterial(MatDBInfo const& matdbinfo,StrawProperties const& sprops, + const std::string& wallmat, const std::string& gasmat, const std::string& wiremat); // pathlength through straw components, given closest approach. Return the method used to compute the paths PathCalc pathLengths(ClosestApproachData const& cadata,double nsig, double& wallpath, double& gaspath, double& wirepath,int diag=0) const; PathCalc averagePathLengths(double& wallpath, double& gaspath, double& wirepath) const; diff --git a/Mu2eKinKal/src/KKStrawMaterial.cc b/Mu2eKinKal/src/KKStrawMaterial.cc index 404ff4220d..003d878fd3 100644 --- a/Mu2eKinKal/src/KKStrawMaterial.cc +++ b/Mu2eKinKal/src/KKStrawMaterial.cc @@ -78,7 +78,7 @@ namespace mu2e { return tlen; } - KKStrawMaterial::PathCalc KKStrawMaterial::findXings(ClosestApproachData const& cadata, double nsig, std::vector& mxings, int diag) const { mxings.clear(); double wallpath, gaspath, wirepath; auto retval = pathLengths(cadata,nsig,wallpath, gaspath, wirepath,diag); From 3c30b9ccc5730e7fde3189a99ffc08a72edeb65c Mon Sep 17 00:00:00 2001 From: David Nathan Brown Date: Sat, 16 May 2026 11:31:38 -0700 Subject: [PATCH 4/9] Consolidate interfaces --- Mu2eKinKal/inc/KKFileFinder.hh | 48 ---------------------------------- Mu2eKinKal/inc/KKMaterial.hh | 22 +++++++++++++--- Mu2eKinKal/src/KKMaterial.cc | 13 ++++++--- 3 files changed, 28 insertions(+), 55 deletions(-) delete mode 100644 Mu2eKinKal/inc/KKFileFinder.hh diff --git a/Mu2eKinKal/inc/KKFileFinder.hh b/Mu2eKinKal/inc/KKFileFinder.hh deleted file mode 100644 index 67ab289602..0000000000 --- a/Mu2eKinKal/inc/KKFileFinder.hh +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef Mu2eKinKal_KKFileFinder_hh -#define Mu2eKinKal_KKFileFinder_hh - -#include "KinKal/MatEnv/FileFinderInterface.hh" -#include "Offline/ConfigTools/inc/ConfigFileLookupPolicy.hh" -#include - -namespace mu2e { - - class KKFileFinder : public MatEnv::FileFinderInterface { - - public: - KKFileFinder(std::string elementsBaseName, - std::string isotopesBaseName, - std::string materialsBaseName): - elementsBaseName_(elementsBaseName), - isotopesBaseName_(isotopesBaseName), - materialsBaseName_(materialsBaseName){} - - std::string matElmDictionaryFileName() const override { - return findFile(elementsBaseName_); - } - - std::string matIsoDictionaryFileName() const override { - return findFile(isotopesBaseName_); - } - - std::string matMtrDictionaryFileName() const override { - return findFile(materialsBaseName_); - } - - std::string findFile( std::string const& path ) const override { - return policy_( path ); - } - - private: - - mutable ConfigFileLookupPolicy policy_; - - std::string elementsBaseName_; - std::string isotopesBaseName_; - std::string materialsBaseName_; - - }; - -} - -#endif /* btrkHelper_KKFileFinder_hh */ diff --git a/Mu2eKinKal/inc/KKMaterial.hh b/Mu2eKinKal/inc/KKMaterial.hh index 127d59642d..fecefe8e04 100644 --- a/Mu2eKinKal/inc/KKMaterial.hh +++ b/Mu2eKinKal/inc/KKMaterial.hh @@ -8,14 +8,17 @@ #include "fhiclcpp/types/Tuple.h" // KinKal #include "KinKal/MatEnv/MatDBInfo.hh" +#include "KinKal/MatEnv/FileFinderInterface.hh" +// Mu2eKinKal: moveme! #include "Offline/Mu2eKinKal/inc/KKStrawMaterial.hh" -#include "Offline/Mu2eKinKal/inc/KKFileFinder.hh" +// mu2e +#include "Offline/ConfigTools/inc/ConfigFileLookupPolicy.hh" #include #include namespace mu2e { - class KKMaterial { + class KKMaterial : public MatEnv::FileFinderInterface { public: using Name = fhicl::Name; using Comment = fhicl::Comment; @@ -40,11 +43,22 @@ namespace mu2e { KKStrawMaterial const& strawMaterial() const; auto IPAMaterial() const { return matdbinfo_->findDetMaterial(ipamatname_); } auto STMaterial() const { return matdbinfo_->findDetMaterial(stmatname_); } + + // FileFinder interface + std::string matElmDictionaryFileName() const override; + std::string matIsoDictionaryFileName() const override; + std::string matMtrDictionaryFileName() const override; + std::string findFile( std::string const& path ) const override; private: - KKFileFinder filefinder_; // used to find material info + // material description files base names (not path) + std::string elementsBaseName_; + std::string isotopesBaseName_; + std::string materialsBaseName_; + mutable ConfigFileLookupPolicy policy_; + // specific material names std::string wallmatname_, gasmatname_, wirematname_,ipamatname_, stmatname_; mutable std::unique_ptr matdbinfo_; // material database - mutable std::unique_ptr smat_; // straw material + mutable std::unique_ptr smat_; // straw material; move to KinKalGeom }; } #endif diff --git a/Mu2eKinKal/src/KKMaterial.cc b/Mu2eKinKal/src/KKMaterial.cc index 126193fc9b..72ff52ac6c 100644 --- a/Mu2eKinKal/src/KKMaterial.cc +++ b/Mu2eKinKal/src/KKMaterial.cc @@ -2,14 +2,15 @@ #include "Offline/GeometryService/inc/GeomHandle.hh" #include "Offline/TrackerGeom/inc/Tracker.hh" #include "KinKal/MatEnv/DetMaterial.hh" -#include "Offline/GeometryService/inc/GeometryService.hh" namespace mu2e { using MatDBInfo = MatEnv::MatDBInfo; using MatEnv::DetMaterial; KKMaterial::KKMaterial(KKMaterial::Config const& matconfig) : - filefinder_(matconfig.elements(),matconfig.isotopes(),matconfig.materials()), + elementsBaseName_(matconfig.elements()), + isotopesBaseName_(matconfig.isotopes()), + materialsBaseName_(matconfig.materials()), wallmatname_(matconfig.strawWallMaterialName()), gasmatname_(matconfig.strawGasMaterialName()), wirematname_(matconfig.strawWireMaterialName()), @@ -20,7 +21,7 @@ namespace mu2e { dmconf.scatterfrac_solid_ = matconfig.solidScatter(); dmconf.scatterfrac_gas_ = matconfig.gasScatter(); dmconf.ebrehmsfrac_ = matconfig.eBrehms(); - matdbinfo_ = std::make_unique(filefinder_,dmconf); + matdbinfo_ = std::make_unique(*this,dmconf); } KKStrawMaterial const& KKMaterial::strawMaterial() const { @@ -36,4 +37,10 @@ namespace mu2e { } return *smat_; } + + std::string KKMaterial::findFile( std::string const& basename ) const { return policy_( basename ); } + std::string KKMaterial::matElmDictionaryFileName() const { return findFile(elementsBaseName_); } + std::string KKMaterial::matIsoDictionaryFileName() const { return findFile(isotopesBaseName_); } + std::string KKMaterial::matMtrDictionaryFileName() const { return findFile(materialsBaseName_); } + } From 3477b3e767231717f953a96156a8bfb1a8e25473 Mon Sep 17 00:00:00 2001 From: David Nathan Brown Date: Sat, 16 May 2026 12:28:52 -0700 Subject: [PATCH 5/9] Move KKMaterial and KKStrawMaterial to KinKalGeom --- KinKalGeom/CMakeLists.txt | 4 ++++ {Mu2eKinKal => KinKalGeom}/inc/KKMaterial.hh | 8 ++++---- {Mu2eKinKal => KinKalGeom}/inc/KKStrawMaterial.hh | 0 {Mu2eKinKal => KinKalGeom}/src/KKMaterial.cc | 2 +- {Mu2eKinKal => KinKalGeom}/src/KKStrawMaterial.cc | 3 +-- KinKalGeom/src/SConscript | 3 +++ Mu2eKinKal/CMakeLists.txt | 2 -- Mu2eKinKal/inc/KKExtrap.hh | 2 +- Mu2eKinKal/inc/KKFit.hh | 2 +- Mu2eKinKal/inc/KKStrawXing.hh | 2 +- Mu2eKinKal/src/CentralHelixFit_module.cc | 2 +- Mu2eKinKal/src/KinematicLineFit_module.cc | 2 +- Mu2eKinKal/src/LoopHelixFit_module.cc | 2 +- Mu2eKinKal/src/RegrowKinematicLine_module.cc | 2 +- Mu2eKinKal/src/RegrowLoopHelix_module.cc | 2 +- RecoDataProducts/inc/TrkStraw.hh | 2 +- 16 files changed, 22 insertions(+), 18 deletions(-) rename {Mu2eKinKal => KinKalGeom}/inc/KKMaterial.hh (95%) rename {Mu2eKinKal => KinKalGeom}/inc/KKStrawMaterial.hh (100%) rename {Mu2eKinKal => KinKalGeom}/src/KKMaterial.cc (97%) rename {Mu2eKinKal => KinKalGeom}/src/KKStrawMaterial.cc (97%) diff --git a/KinKalGeom/CMakeLists.txt b/KinKalGeom/CMakeLists.txt index c600163619..7bc59e97ac 100644 --- a/KinKalGeom/CMakeLists.txt +++ b/KinKalGeom/CMakeLists.txt @@ -2,7 +2,11 @@ cet_make_library( SOURCE src/CRV.cc src/KinKalGeom.cc + src/KKMaterial.cc + src/KKStrawMaterial.cc LIBRARIES PUBLIC + Offline::ConfigTools + KinKal::MatEnv KinKal::Geometry KinKal::Trajectory KinKal::General diff --git a/Mu2eKinKal/inc/KKMaterial.hh b/KinKalGeom/inc/KKMaterial.hh similarity index 95% rename from Mu2eKinKal/inc/KKMaterial.hh rename to KinKalGeom/inc/KKMaterial.hh index fecefe8e04..f9b304b49f 100644 --- a/Mu2eKinKal/inc/KKMaterial.hh +++ b/KinKalGeom/inc/KKMaterial.hh @@ -1,5 +1,5 @@ -#ifndef Mu2eKinKal_KKMaterial_hh -#define Mu2eKinKal_KKMaterial_hh +#ifndef KinKalGeom_KKMaterial_hh +#define KinKalGeom_KKMaterial_hh // // build KinKal DetMaterial objects from art parameter configuration // @@ -9,8 +9,8 @@ // KinKal #include "KinKal/MatEnv/MatDBInfo.hh" #include "KinKal/MatEnv/FileFinderInterface.hh" -// Mu2eKinKal: moveme! -#include "Offline/Mu2eKinKal/inc/KKStrawMaterial.hh" +// KKGeom +#include "Offline/KinKalGeom/inc/KKStrawMaterial.hh" // mu2e #include "Offline/ConfigTools/inc/ConfigFileLookupPolicy.hh" diff --git a/Mu2eKinKal/inc/KKStrawMaterial.hh b/KinKalGeom/inc/KKStrawMaterial.hh similarity index 100% rename from Mu2eKinKal/inc/KKStrawMaterial.hh rename to KinKalGeom/inc/KKStrawMaterial.hh diff --git a/Mu2eKinKal/src/KKMaterial.cc b/KinKalGeom/src/KKMaterial.cc similarity index 97% rename from Mu2eKinKal/src/KKMaterial.cc rename to KinKalGeom/src/KKMaterial.cc index 72ff52ac6c..e80edefdb5 100644 --- a/Mu2eKinKal/src/KKMaterial.cc +++ b/KinKalGeom/src/KKMaterial.cc @@ -1,4 +1,4 @@ -#include "Offline/Mu2eKinKal/inc/KKMaterial.hh" +#include "Offline/KinKalGeom/inc/KKMaterial.hh" #include "Offline/GeometryService/inc/GeomHandle.hh" #include "Offline/TrackerGeom/inc/Tracker.hh" #include "KinKal/MatEnv/DetMaterial.hh" diff --git a/Mu2eKinKal/src/KKStrawMaterial.cc b/KinKalGeom/src/KKStrawMaterial.cc similarity index 97% rename from Mu2eKinKal/src/KKStrawMaterial.cc rename to KinKalGeom/src/KKStrawMaterial.cc index 003d878fd3..22f0b808bb 100644 --- a/Mu2eKinKal/src/KKStrawMaterial.cc +++ b/KinKalGeom/src/KKStrawMaterial.cc @@ -1,5 +1,4 @@ -#include "Offline/Mu2eKinKal/inc/KKStrawMaterial.hh" -#include "Offline/Mu2eKinKal/inc/StrawXingUpdater.hh" +#include "Offline/KinKalGeom/inc/KKStrawMaterial.hh" #include "KinKal/MatEnv/DetMaterial.hh" #include "KinKal/MatEnv/MatDBInfo.hh" #include "KinKal/Detector/MaterialXing.hh" diff --git a/KinKalGeom/src/SConscript b/KinKalGeom/src/SConscript index decefd3fbe..325b8e8f5c 100644 --- a/KinKalGeom/src/SConscript +++ b/KinKalGeom/src/SConscript @@ -14,6 +14,8 @@ rootlibs = env['ROOTLIBS'] helper = mu2e_helper(env) mainlib = helper.make_mainlib([ + 'mu2e_ConfigTools', + 'KinKal_MatEnv', 'KinKal_Geometry', 'KinKal_Trajectory', 'KinKal_General', @@ -22,6 +24,7 @@ mainlib = helper.make_mainlib([ 'art_Framework_Services_Registry', 'art_Utilities', 'canvas', + 'cetlib', 'cetlib_except', 'CLHEP', 'Core', diff --git a/Mu2eKinKal/CMakeLists.txt b/Mu2eKinKal/CMakeLists.txt index 51fbad3f3e..3e1ae785bd 100644 --- a/Mu2eKinKal/CMakeLists.txt +++ b/Mu2eKinKal/CMakeLists.txt @@ -8,9 +8,7 @@ cet_make_library( src/KKConstantBField.cc src/KKFitSettings.cc src/KKFitUtilities.cc - src/KKMaterial.cc src/KKSHFlag.cc - src/KKStrawMaterial.cc src/StrawHitUpdaters.cc src/StrawXingUpdater.cc src/WHSIterator.cc diff --git a/Mu2eKinKal/inc/KKExtrap.hh b/Mu2eKinKal/inc/KKExtrap.hh index ab5a4205c7..6f67fc2a0c 100644 --- a/Mu2eKinKal/inc/KKExtrap.hh +++ b/Mu2eKinKal/inc/KKExtrap.hh @@ -13,7 +13,7 @@ #include "Offline/Mu2eKinKal/inc/ExtrapolateIPA.hh" #include "Offline/Mu2eKinKal/inc/ExtrapolateST.hh" #include "Offline/Mu2eKinKal/inc/KKShellXing.hh" -#include "Offline/Mu2eKinKal/inc/KKMaterial.hh" +#include "Offline/KinKalGeom/inc/KKMaterial.hh" #include "KinKal/Geometry/ParticleTrajectoryIntersect.hh" #include "Offline/GeometryService/inc/GeomHandle.hh" #include "Offline/GeometryService/inc/GeometryService.hh" diff --git a/Mu2eKinKal/inc/KKFit.hh b/Mu2eKinKal/inc/KKFit.hh index 5b5077d35b..20c3a09b21 100644 --- a/Mu2eKinKal/inc/KKFit.hh +++ b/Mu2eKinKal/inc/KKFit.hh @@ -7,7 +7,7 @@ #include "Offline/Mu2eKinKal/inc/KKStrawHitCluster.hh" #include "Offline/Mu2eKinKal/inc/KKTrack.hh" #include "Offline/Mu2eKinKal/inc/KKStrawXing.hh" -#include "Offline/Mu2eKinKal/inc/KKStrawMaterial.hh" +#include "Offline/KinKalGeom/inc/KKStrawMaterial.hh" #include "Offline/Mu2eKinKal/inc/KKCaloHit.hh" #include "Offline/Mu2eKinKal/inc/KKFitUtilities.hh" #include "Offline/Mu2eKinKal/inc/KKFitSettings.hh" diff --git a/Mu2eKinKal/inc/KKStrawXing.hh b/Mu2eKinKal/inc/KKStrawXing.hh index e32f7e0239..1cc2136616 100644 --- a/Mu2eKinKal/inc/KKStrawXing.hh +++ b/Mu2eKinKal/inc/KKStrawXing.hh @@ -6,7 +6,7 @@ #include "KinKal/Detector/ElementXing.hh" #include "Offline/Mu2eKinKal/inc/KKStrawHit.hh" #include "Offline/Mu2eKinKal/inc/StrawXingUpdater.hh" -#include "Offline/Mu2eKinKal/inc/KKStrawMaterial.hh" +#include "Offline/KinKalGeom/inc/KKStrawMaterial.hh" #include "Offline/TrackerGeom/inc/Straw.hh" #include "Offline/DataProducts/inc/StrawId.hh" #include "KinKal/Trajectory/ParticleTrajectory.hh" diff --git a/Mu2eKinKal/src/CentralHelixFit_module.cc b/Mu2eKinKal/src/CentralHelixFit_module.cc index d45316dd45..eec7358e5d 100644 --- a/Mu2eKinKal/src/CentralHelixFit_module.cc +++ b/Mu2eKinKal/src/CentralHelixFit_module.cc @@ -52,7 +52,7 @@ #include "Offline/Mu2eKinKal/inc/KKFit.hh" #include "Offline/Mu2eKinKal/inc/KKFitSettings.hh" #include "Offline/Mu2eKinKal/inc/KKTrack.hh" -#include "Offline/Mu2eKinKal/inc/KKMaterial.hh" +#include "Offline/KinKalGeom/inc/KKMaterial.hh" #include "Offline/Mu2eKinKal/inc/KKStrawHit.hh" #include "Offline/Mu2eKinKal/inc/KKStrawHitCluster.hh" #include "Offline/Mu2eKinKal/inc/KKStrawXing.hh" diff --git a/Mu2eKinKal/src/KinematicLineFit_module.cc b/Mu2eKinKal/src/KinematicLineFit_module.cc index 77cb6b665f..30e2079631 100644 --- a/Mu2eKinKal/src/KinematicLineFit_module.cc +++ b/Mu2eKinKal/src/KinematicLineFit_module.cc @@ -47,7 +47,7 @@ // Mu2eKinKal #include "Offline/Mu2eKinKal/inc/KKFit.hh" #include "Offline/Mu2eKinKal/inc/KKFitSettings.hh" -#include "Offline/Mu2eKinKal/inc/KKMaterial.hh" +#include "Offline/KinKalGeom/inc/KKMaterial.hh" #include "Offline/Mu2eKinKal/inc/KKStrawHit.hh" #include "Offline/Mu2eKinKal/inc/KKBField.hh" #include "Offline/Mu2eKinKal/inc/KKFitUtilities.hh" diff --git a/Mu2eKinKal/src/LoopHelixFit_module.cc b/Mu2eKinKal/src/LoopHelixFit_module.cc index 1ac78588e8..d44d92fcb8 100644 --- a/Mu2eKinKal/src/LoopHelixFit_module.cc +++ b/Mu2eKinKal/src/LoopHelixFit_module.cc @@ -52,7 +52,7 @@ #include "Offline/Mu2eKinKal/inc/KKFit.hh" #include "Offline/Mu2eKinKal/inc/KKFitSettings.hh" #include "Offline/Mu2eKinKal/inc/KKTrack.hh" -#include "Offline/Mu2eKinKal/inc/KKMaterial.hh" +#include "Offline/KinKalGeom/inc/KKMaterial.hh" #include "Offline/Mu2eKinKal/inc/KKStrawHit.hh" #include "Offline/Mu2eKinKal/inc/KKStrawHitCluster.hh" #include "Offline/Mu2eKinKal/inc/KKStrawXing.hh" diff --git a/Mu2eKinKal/src/RegrowKinematicLine_module.cc b/Mu2eKinKal/src/RegrowKinematicLine_module.cc index 451c6ecbe7..93d6e278d4 100644 --- a/Mu2eKinKal/src/RegrowKinematicLine_module.cc +++ b/Mu2eKinKal/src/RegrowKinematicLine_module.cc @@ -54,7 +54,7 @@ #include "Offline/Mu2eKinKal/inc/KKFit.hh" #include "Offline/Mu2eKinKal/inc/KKFitSettings.hh" #include "Offline/Mu2eKinKal/inc/KKTrack.hh" -#include "Offline/Mu2eKinKal/inc/KKMaterial.hh" +#include "Offline/KinKalGeom/inc/KKMaterial.hh" #include "Offline/Mu2eKinKal/inc/KKStrawHit.hh" #include "Offline/Mu2eKinKal/inc/KKStrawHitCluster.hh" #include "Offline/Mu2eKinKal/inc/KKStrawXing.hh" diff --git a/Mu2eKinKal/src/RegrowLoopHelix_module.cc b/Mu2eKinKal/src/RegrowLoopHelix_module.cc index e4771e5646..2f648f2b6a 100644 --- a/Mu2eKinKal/src/RegrowLoopHelix_module.cc +++ b/Mu2eKinKal/src/RegrowLoopHelix_module.cc @@ -54,7 +54,7 @@ #include "Offline/Mu2eKinKal/inc/KKFit.hh" #include "Offline/Mu2eKinKal/inc/KKFitSettings.hh" #include "Offline/Mu2eKinKal/inc/KKTrack.hh" -#include "Offline/Mu2eKinKal/inc/KKMaterial.hh" +#include "Offline/KinKalGeom/inc/KKMaterial.hh" #include "Offline/Mu2eKinKal/inc/KKStrawHit.hh" #include "Offline/Mu2eKinKal/inc/KKStrawHitCluster.hh" #include "Offline/Mu2eKinKal/inc/KKStrawXing.hh" diff --git a/RecoDataProducts/inc/TrkStraw.hh b/RecoDataProducts/inc/TrkStraw.hh index 59d4a6db99..306f2447e2 100644 --- a/RecoDataProducts/inc/TrkStraw.hh +++ b/RecoDataProducts/inc/TrkStraw.hh @@ -8,7 +8,7 @@ #define RecoDataProducts_TrkStraw_HH #include "Offline/DataProducts/inc/StrawId.hh" #include "Offline/RecoDataProducts/inc/StrawFlag.hh" -#include "Offline/Mu2eKinKal/inc/KKStrawMaterial.hh" +#include "Offline/KinKalGeom/inc/KKStrawMaterial.hh" #include "Offline/Mu2eKinKal/inc/StrawXingUpdater.hh" #include "KinKal/Trajectory/ClosestApproachData.hh" From e3dc0e0717d707b90d321b36da1d34e9f05b06bb Mon Sep 17 00:00:00 2001 From: David Nathan Brown Date: Sat, 16 May 2026 14:05:17 -0700 Subject: [PATCH 6/9] Put KKMaterial into GeometryService --- GeometryService/inc/GeometryService.hh | 4 + GeometryService/inc/KinKalGeomMaker.hh | 1 + GeometryService/src/GeometryService.cc | 375 +++++++++++++------------ KinKalGeom/inc/KKMaterial.hh | 4 +- KinKalGeom/src/KKMaterial.cc | 2 +- Mu2eKinKal/src/SConscript | 4 +- fcl/standardServices.fcl | 14 + 7 files changed, 215 insertions(+), 189 deletions(-) diff --git a/GeometryService/inc/GeometryService.hh b/GeometryService/inc/GeometryService.hh index 806c80d2e2..f184ec1b02 100644 --- a/GeometryService/inc/GeometryService.hh +++ b/GeometryService/inc/GeometryService.hh @@ -21,6 +21,7 @@ #include "fhiclcpp/types/Table.h" #include "cetlib_except/exception.h" +#include "Offline/KinKalGeom/inc/KKMaterial.hh" #include "Offline/ConfigTools/inc/SimpleConfig.hh" #include "Offline/Mu2eInterfaces/inc/Detector.hh" #include "boost/shared_ptr.hpp" @@ -48,6 +49,7 @@ public: fhicl::Atom tool_type{Name("tool_type"),"Mu2e"}; }; + using KKMaterialConfig = KKMaterial::Config; struct Config { using Name=fhicl::Name; using Comment=fhicl::Comment; @@ -60,6 +62,7 @@ public: fhicl::Atom printConfig{Name("printConfig"),false}; fhicl::Atom printConfigTopLevel{Name("printConfigTopLevel"),false}; fhicl::Table simulatedDetector{Name("simulatedDetector")}; + fhicl::Table matSettings{Name("KinKalMaterial")}; }; using Parameters= art::ServiceTable; @@ -129,6 +132,7 @@ private: std::unique_ptr _bfConfig; const fhicl::ParameterSet _simulatedDetector; + const KKMaterialConfig _kkMat; // Load G4 geometry options std::unique_ptr _g4GeomOptions; diff --git a/GeometryService/inc/KinKalGeomMaker.hh b/GeometryService/inc/KinKalGeomMaker.hh index d0adbe8dbc..9c89168c9b 100644 --- a/GeometryService/inc/KinKalGeomMaker.hh +++ b/GeometryService/inc/KinKalGeomMaker.hh @@ -5,6 +5,7 @@ // Original author: Dave Brown (LBNL) 4/2026 // #include "Offline/KinKalGeom/inc/KinKalGeom.hh" +#include "Offline/KinKalGeom/inc/KKMaterial.hh" namespace mu2e { class KinKalGeomMaker { public: diff --git a/GeometryService/src/GeometryService.cc b/GeometryService/src/GeometryService.cc index a6c2786a90..91fe096b58 100644 --- a/GeometryService/src/GeometryService.cc +++ b/GeometryService/src/GeometryService.cc @@ -61,6 +61,7 @@ #include "Offline/BeamlineGeom/inc/TSdA.hh" #include "Offline/TrackerGeom/inc/Tracker.hh" #include "Offline/KinKalGeom/inc/KinKalGeom.hh" +#include "Offline/KinKalGeom/inc/KKMaterial.hh" #include "Offline/CalorimeterGeom/inc/Calorimeter.hh" #include "Offline/GeometryService/inc/DiskCalorimeterMaker.hh" #include "Offline/CalorimeterGeom/inc/DiskCalorimeter.hh" @@ -96,7 +97,7 @@ using namespace std; namespace mu2e { GeometryService::GeometryService( const Parameters& pars, - art::ActivityRegistry&iRegistry) : + art::ActivityRegistry&iRegistry) : _inputfile( pars().inputFile()), _bFieldFile( pars().bFieldFile()), _allowReplacement( pars().allowReplacement()), @@ -107,6 +108,7 @@ namespace mu2e { _printTopLevel( pars().printConfigTopLevel()), _config(nullptr), _simulatedDetector( pars.get_PSet().get("simulatedDetector")), + _kkMat( pars().matSettings()), _standardMu2eDetector( _simulatedDetector.get("tool_type") == "Mu2e"), _detectors() { @@ -120,136 +122,136 @@ namespace mu2e { // This template can be defined here because this is a private method which is only // used by the code below in the same file. template - void GeometryService::addDetector(std::unique_ptr d) - { - if(_detectors.find(typeid(DET).name())!=_detectors.end()) { - throw cet::exception("GEOM") << "failed to install detector with type name " - << typeid(DET).name() << "\n"; - } + void GeometryService::addDetector(std::unique_ptr d) + { + if(_detectors.find(typeid(DET).name())!=_detectors.end()) { + throw cet::exception("GEOM") << "failed to install detector with type name " + << typeid(DET).name() << "\n"; + } DetectorPtr ptr(d.release()); _detectors[typeid(DET).name()] = ptr; - } + } template - void GeometryService::addDetectorAliasToBaseClass(std::unique_ptr d) - { + void GeometryService::addDetectorAliasToBaseClass(std::unique_ptr d) + { - std::string OriginalName = typeid(DET).name(); - DetMap::iterator it(_detectors.find(OriginalName)); + std::string OriginalName = typeid(DET).name(); + DetMap::iterator it(_detectors.find(OriginalName)); - if(it==_detectors.end()) - throw cet::exception("GEOM") - << "Can not alias an inexistant detector, detector " << OriginalName << "\n"; + if(it==_detectors.end()) + throw cet::exception("GEOM") + << "Can not alias an inexistant detector, detector " << OriginalName << "\n"; - std::string detectorName= typeid(DETALIAS).name() ; - _detectors[detectorName] = it->second; - } + std::string detectorName= typeid(DETALIAS).name() ; + _detectors[detectorName] = it->second; + } void - GeometryService::preBeginRun(art::Run const &) { - - if(++_run_count > 1) { - return; - } + GeometryService::preBeginRun(art::Run const &) { - _config = unique_ptr(new SimpleConfig(_inputfile, - _allowReplacement, - _messageOnReplacement, - _messageOnDefault )); - _config->printOpen(cout,"Geometry"); - - _bfConfig = unique_ptr(new SimpleConfig(_bFieldFile, - _allowReplacement, - _messageOnReplacement, - _messageOnDefault )); - _bfConfig->printOpen(cout,"BField"); - - - if(_printTopLevel) { - //print the top level geometry file contents - //the top level often contains a single named config file or a list of specific version files - ConfigFileLookupPolicy configFile; - std::string file = configFile(_inputfile); - std::ifstream in(file.c_str()); - if ( !in ) { - // No conf file for this test. - throw cet::exception("Geom") - << "GeometryService: Cannot open input file: " - << file - << endl; + if(++_run_count > 1) { + return; } - std::cout << "GeometryService: printing top level geometry file:\n"; - std::string line; - while ( in ){ - std::getline(in,line); - if ( !in ){ - break; - } - std::cout << line.c_str() << std::endl; + _config = unique_ptr(new SimpleConfig(_inputfile, + _allowReplacement, + _messageOnReplacement, + _messageOnDefault )); + _config->printOpen(cout,"Geometry"); + + _bfConfig = unique_ptr(new SimpleConfig(_bFieldFile, + _allowReplacement, + _messageOnReplacement, + _messageOnDefault )); + _bfConfig->printOpen(cout,"BField"); + + + if(_printTopLevel) { + //print the top level geometry file contents + //the top level often contains a single named config file or a list of specific version files + ConfigFileLookupPolicy configFile; + std::string file = configFile(_inputfile); + std::ifstream in(file.c_str()); + if ( !in ) { + // No conf file for this test. + throw cet::exception("Geom") + << "GeometryService: Cannot open input file: " + << file + << endl; + } + std::cout << "GeometryService: printing top level geometry file:\n"; + std::string line; + while ( in ){ + std::getline(in,line); + if ( !in ){ + break; + } + + std::cout << line.c_str() << std::endl; + } + std::cout << "GeometryService: finished printing top level geometry file.\n"; } - std::cout << "GeometryService: finished printing top level geometry file.\n"; - } - // Print final state of file after all substitutions. - if ( _printConfig ){ _config->print(cout, "Geom: "); } + // Print final state of file after all substitutions. + if ( _printConfig ){ _config->print(cout, "Geom: "); } - // 2019-03-24 P.M. : *not needed* decide if this is standard Mu2e detector or something else ... + // 2019-03-24 P.M. : *not needed* decide if this is standard Mu2e detector or something else ... - if (!isStandardMu2eDetector() || - !_config->getBool("mu2e.standardDetector",true)) { - cout << "Non-standard mu2e configuration, assuming it is intentional" << endl; - return; - } + if (!isStandardMu2eDetector() || + !_config->getBool("mu2e.standardDetector",true)) { + cout << "Non-standard mu2e configuration, assuming it is intentional" << endl; + return; + } - // Initialize geometry options - _g4GeomOptions = unique_ptr( new G4GeometryOptions( *_config ) ); + // Initialize geometry options + _g4GeomOptions = unique_ptr( new G4GeometryOptions( *_config ) ); - // Throw if the configuration is not self consistent. - checkConfig(); + // Throw if the configuration is not self consistent. + checkConfig(); - // This must be the first detector added since other makers may wish to use it. - std::unique_ptr tmpDetSys(DetectorSystemMaker::make(*_config)); - const DetectorSystem& detSys = *tmpDetSys.get(); - addDetector(std::move(tmpDetSys)); + // This must be the first detector added since other makers may wish to use it. + std::unique_ptr tmpDetSys(DetectorSystemMaker::make(*_config)); + const DetectorSystem& detSys = *tmpDetSys.get(); + addDetector(std::move(tmpDetSys)); - // Make a detector for every component present in the configuration. + // Make a detector for every component present in the configuration. - std::unique_ptr tmpBeamline(BeamlineMaker::make(*_config)); - const Beamline& beamline = *tmpBeamline.get(); - addDetector(std::move(tmpBeamline)); + std::unique_ptr tmpBeamline(BeamlineMaker::make(*_config)); + const Beamline& beamline = *tmpBeamline.get(); + addDetector(std::move(tmpBeamline)); - std::unique_ptr tmpProdTgt(ProductionTargetMaker::make(*_config, beamline.solenoidOffset())); - const ProductionTarget& prodTarget = *tmpProdTgt.get(); - addDetector(std::move(tmpProdTgt)); + std::unique_ptr tmpProdTgt(ProductionTargetMaker::make(*_config, beamline.solenoidOffset())); + const ProductionTarget& prodTarget = *tmpProdTgt.get(); + addDetector(std::move(tmpProdTgt)); - std::unique_ptr - tmpProductionSolenoid(ProductionSolenoidMaker(*_config, beamline.solenoidOffset()).getProductionSolenoidPtr()); + std::unique_ptr + tmpProductionSolenoid(ProductionSolenoidMaker(*_config, beamline.solenoidOffset()).getProductionSolenoidPtr()); - const ProductionSolenoid& ps = *tmpProductionSolenoid.get(); - addDetector(std::move(tmpProductionSolenoid)); + const ProductionSolenoid& ps = *tmpProductionSolenoid.get(); + addDetector(std::move(tmpProductionSolenoid)); - std::unique_ptr - tmpPSE(PSEnclosureMaker::make(*_config, ps.psEndRefPoint())); - const PSEnclosure& pse = *tmpPSE.get(); - addDetector(std::move(tmpPSE)); + std::unique_ptr + tmpPSE(PSEnclosureMaker::make(*_config, ps.psEndRefPoint())); + const PSEnclosure& pse = *tmpPSE.get(); + addDetector(std::move(tmpPSE)); - // The Z coordinate of the boundary between PS and TS vacua - StraightSection const * ts1vac = beamline.getTS().getTSVacuum( TransportSolenoid::TSRegion::TS1 ); - const double vacPS_TS_z = ts1vac->getGlobal().z() - ts1vac->getHalfLength(); + // The Z coordinate of the boundary between PS and TS vacua + StraightSection const * ts1vac = beamline.getTS().getTSVacuum( TransportSolenoid::TSRegion::TS1 ); + const double vacPS_TS_z = ts1vac->getGlobal().z() - ts1vac->getHalfLength(); - addDetector(PSVacuumMaker::make(*_config, ps, pse, vacPS_TS_z)); + addDetector(PSVacuumMaker::make(*_config, ps, pse, vacPS_TS_z)); - //addDetector(PSShieldMaker::make(*_config, ps.psEndRefPoint(), prodTarget.position())); + //addDetector(PSShieldMaker::make(*_config, ps.psEndRefPoint(), prodTarget.position())); - if (_config->getString("targetPS_model") == "MDC2018"){ - // std::cout << "adding Tier1 in GeometryService" << std::endl; - addDetector(PSShieldMaker::make(*_config, ps.psEndRefPoint(), prodTarget.position())); + if (_config->getString("targetPS_model") == "MDC2018"){ + // std::cout << "adding Tier1 in GeometryService" << std::endl; + addDetector(PSShieldMaker::make(*_config, ps.psEndRefPoint(), prodTarget.position())); + } else + if (_config->getString("targetPS_model") == "Hayman_v_2_0"){ + // std::cout << " adding Hayman in GeometryService" << std::endl; + addDetector(PSShieldMaker::make(*_config, ps.psEndRefPoint(), prodTarget.haymanProdTargetPosition())); } else - if (_config->getString("targetPS_model") == "Hayman_v_2_0"){ - // std::cout << " adding Hayman in GeometryService" << std::endl; - addDetector(PSShieldMaker::make(*_config, ps.psEndRefPoint(), prodTarget.haymanProdTargetPosition())); - } else {throw cet::exception("GEOM") << " " << static_cast(__func__) << " illegal production target version specified in GeometryService_service = " << _config->getString("targetPS_model") << std::endl;} @@ -257,118 +259,121 @@ namespace mu2e { - // Construct building solids - std::unique_ptr tmphall(Mu2eHallMaker::makeBuilding(*_g4GeomOptions,*_config)); - const Mu2eHall& hall = *tmphall.get(); + // Construct building solids + std::unique_ptr tmphall(Mu2eHallMaker::makeBuilding(*_g4GeomOptions,*_config)); + const Mu2eHall& hall = *tmphall.get(); - // Determine Mu2e envelope from building solids - std::unique_ptr mu2eEnv (new Mu2eEnvelope(hall,*_config)); + // Determine Mu2e envelope from building solids + std::unique_ptr mu2eEnv (new Mu2eEnvelope(hall,*_config)); - // Make dirt based on Mu2e envelope - Mu2eHallMaker::makeDirt( *tmphall.get(), *_g4GeomOptions, *_config, *mu2eEnv.get() ); - Mu2eHallMaker::makeRotated( *tmphall.get(), *_g4GeomOptions, *_config, *mu2eEnv.get() ); - Mu2eHallMaker::makeTrapDirt( *tmphall.get(), *_g4GeomOptions, *_config, *mu2eEnv.get() ); + // Make dirt based on Mu2e envelope + Mu2eHallMaker::makeDirt( *tmphall.get(), *_g4GeomOptions, *_config, *mu2eEnv.get() ); + Mu2eHallMaker::makeRotated( *tmphall.get(), *_g4GeomOptions, *_config, *mu2eEnv.get() ); + Mu2eHallMaker::makeTrapDirt( *tmphall.get(), *_g4GeomOptions, *_config, *mu2eEnv.get() ); - addDetector(std::move( tmphall ) ); - addDetector(std::move( mu2eEnv ) ); + addDetector(std::move( tmphall ) ); + addDetector(std::move( mu2eEnv ) ); - std::unique_ptr tmpDump(ProtonBeamDumpMaker::make(*_config, hall)); - const ProtonBeamDump& dump = *tmpDump.get(); - addDetector(std::move(tmpDump)); + std::unique_ptr tmpDump(ProtonBeamDumpMaker::make(*_config, hall)); + const ProtonBeamDump& dump = *tmpDump.get(); + addDetector(std::move(tmpDump)); - // beamline info used to position DS - std::unique_ptr tmpDS( DetectorSolenoidMaker::make( *_config, beamline ) ); - const DetectorSolenoid& ds = *tmpDS.get(); - addDetector(std::move(tmpDS)); + // beamline info used to position DS + std::unique_ptr tmpDS( DetectorSolenoidMaker::make( *_config, beamline ) ); + const DetectorSolenoid& ds = *tmpDS.get(); + addDetector(std::move(tmpDS)); - // DS info used to position DS downstream shielding - addDetector( DetectorSolenoidShieldingMaker::make( *_config, ds ) ); + // DS info used to position DS downstream shielding + addDetector( DetectorSolenoidShieldingMaker::make( *_config, ds ) ); - std::unique_ptr tmptgt(StoppingTargetMaker(detSys.getOrigin(), *_config).getTargetPtr()); - const StoppingTarget& target = *tmptgt.get(); - addDetector(std::move(tmptgt)); + std::unique_ptr tmptgt(StoppingTargetMaker(detSys.getOrigin(), *_config).getTargetPtr()); + const StoppingTarget& target = *tmptgt.get(); + addDetector(std::move(tmptgt)); - if (_config->getBool("hasTracker",false)){ - TrackerMaker ttm( *_config ); - addDetector( ttm.getTrackerPtr() ); - } + if (_config->getBool("hasTracker",false)){ + TrackerMaker ttm( *_config ); + addDetector( ttm.getTrackerPtr() ); + } - if(_config->getBool("hasMBS",false)){ - MBSMaker mbs( *_config, beamline.solenoidOffset() ); - addDetector( mbs.getMBSPtr() ); - } + if(_config->getBool("hasMBS",false)){ + MBSMaker mbs( *_config, beamline.solenoidOffset() ); + addDetector( mbs.getMBSPtr() ); + } - if(_config->getBool("hasDiskCalorimeter",false)){ - DiskCalorimeterMaker calorm( *_config, beamline.solenoidOffset() ); - addDetector( calorm.calorimeterPtr() ); - addDetectorAliasToBaseClass( calorm.calorimeterPtr() ); //add an alias to detector list - } + if(_config->getBool("hasDiskCalorimeter",false)){ + DiskCalorimeterMaker calorm( *_config, beamline.solenoidOffset() ); + addDetector( calorm.calorimeterPtr() ); + addDetectorAliasToBaseClass( calorm.calorimeterPtr() ); //add an alias to detector list + } - if(_config->getBool("hasCosmicRayShield",false)){ - CosmicRayShieldMaker crs( *_config, beamline.solenoidOffset() ); - addDetector( crs.getCosmicRayShieldPtr() ); - } + if(_config->getBool("hasCosmicRayShield",false)){ + CosmicRayShieldMaker crs( *_config, beamline.solenoidOffset() ); + addDetector( crs.getCosmicRayShieldPtr() ); + } - if(_config->getBool("hasTSdA",false)){ - addDetector( TSdAMaker::make(*_config,ds) ); - } + if(_config->getBool("hasTSdA",false)){ + addDetector( TSdAMaker::make(*_config,ds) ); + } - if(_config->getBool("hasExternalShielding",false)) { - addDetector( ExtShieldUpstreamMaker::make(*_config) ); - addDetector( ExtShieldDownstreamMaker::make(*_config)); - addDetector( SaddleMaker::make(*_config)); - addDetector( PipeMaker::make(*_config)); - addDetector( ElectronicRackMaker::make(*_config)); - } + if(_config->getBool("hasExternalShielding",false)) { + addDetector( ExtShieldUpstreamMaker::make(*_config) ); + addDetector( ExtShieldDownstreamMaker::make(*_config)); + addDetector( SaddleMaker::make(*_config)); + addDetector( PipeMaker::make(*_config)); + addDetector( ElectronicRackMaker::make(*_config)); + } - std::unique_ptr tmpemb(ExtMonFNALBuildingMaker::make(*_config, hall, dump)); - const ExtMonFNALBuilding& emfb = *tmpemb.get(); - addDetector(std::move(tmpemb)); - if(_config->getBool("hasExtMonFNAL",false)){ - addDetector(ExtMonFNAL::ExtMonMaker::make(*_config, emfb)); - } + std::unique_ptr tmpemb(ExtMonFNALBuildingMaker::make(*_config, hall, dump)); + const ExtMonFNALBuilding& emfb = *tmpemb.get(); + addDetector(std::move(tmpemb)); + if(_config->getBool("hasExtMonFNAL",false)){ + addDetector(ExtMonFNAL::ExtMonMaker::make(*_config, emfb)); + } - if (_config->getBool("hasPTM",false) ){ - std::unique_ptr ptmon(PTMMaker::make(*_config)); - addDetector(std::move(ptmon)); - } + if (_config->getBool("hasPTM",false) ){ + std::unique_ptr ptmon(PTMMaker::make(*_config)); + addDetector(std::move(ptmon)); + } - if(_config->getBool("hasSTM",false)){ - STMMaker stm( *_config, beamline.solenoidOffset() ); - addDetector( stm.getSTMPtr() ); - } + if(_config->getBool("hasSTM",false)){ + STMMaker stm( *_config, beamline.solenoidOffset() ); + addDetector( stm.getSTMPtr() ); + } - if(_config->getBool("hasVirtualDetector",false)){ - addDetector(VirtualDetectorMaker::make(*_config)); - } + if(_config->getBool("hasVirtualDetector",false)){ + addDetector(VirtualDetectorMaker::make(*_config)); + } - if(_bfConfig->getBool("hasBFieldManager",false)){ - std::unique_ptr bfc( BFieldConfigMaker(*_bfConfig, beamline).getBFieldConfig() ); - BFieldManagerMaker bfmgr(*bfc); - addDetector(std::move(bfc)); - addDetector(bfmgr.getBFieldManager()); - } + if(_bfConfig->getBool("hasBFieldManager",false)){ + std::unique_ptr bfc( BFieldConfigMaker(*_bfConfig, beamline).getBFieldConfig() ); + BFieldManagerMaker bfmgr(*bfc); + addDetector(std::move(bfc)); + addDetector(bfmgr.getBFieldManager()); + } - if(_config->getBool("hasProtonAbsorber",false) && !_config->getBool("protonabsorber.isHelical", false) ){ - MECOStyleProtonAbsorberMaker mecopam( *_config, ds, target); - addDetector( mecopam.getMECOStyleProtonAbsorberPtr() ); - } + if(_config->getBool("hasProtonAbsorber",false) && !_config->getBool("protonabsorber.isHelical", false) ){ + MECOStyleProtonAbsorberMaker mecopam( *_config, ds, target); + addDetector( mecopam.getMECOStyleProtonAbsorberPtr() ); + } - // This class has a default c'tor with all available information internally. - std::unique_ptr dusafMu2e{ std::make_unique() }; - addDetector( std::move(dusafMu2e) ); + // This class has a default c'tor with all available information internally. + std::unique_ptr dusafMu2e{ std::make_unique() }; + addDetector( std::move(dusafMu2e) ); - // build KinKalGeom, used in track reconstruction and extrapolation - KinKalGeomMaker kkgm; - addDetector( std::move(kkgm.makeKKG()) ); + // build KinKalGeom, used in track reconstruction and extrapolation + KinKalGeomMaker kkgm; + addDetector( std::move(kkgm.makeKKG()) ); + // directly build KKMaterial; it's constructor does everything + addDetector( std::make_unique(_kkMat)); + return ; - } // preBeginRun() + } // preBeginRun() // Check that the configuration is self consistent. void GeometryService::checkConfig(){ diff --git a/KinKalGeom/inc/KKMaterial.hh b/KinKalGeom/inc/KKMaterial.hh index f9b304b49f..13b83d62eb 100644 --- a/KinKalGeom/inc/KKMaterial.hh +++ b/KinKalGeom/inc/KKMaterial.hh @@ -13,12 +13,14 @@ #include "Offline/KinKalGeom/inc/KKStrawMaterial.hh" // mu2e #include "Offline/ConfigTools/inc/ConfigFileLookupPolicy.hh" +#include "Offline/Mu2eInterfaces/inc/Detector.hh" +#include "Offline/Mu2eInterfaces/inc/ProditionsEntity.hh" #include #include namespace mu2e { - class KKMaterial : public MatEnv::FileFinderInterface { + class KKMaterial : public MatEnv::FileFinderInterface, public Detector, public ProditionsEntity { public: using Name = fhicl::Name; using Comment = fhicl::Comment; diff --git a/KinKalGeom/src/KKMaterial.cc b/KinKalGeom/src/KKMaterial.cc index e80edefdb5..8c390445d6 100644 --- a/KinKalGeom/src/KKMaterial.cc +++ b/KinKalGeom/src/KKMaterial.cc @@ -7,7 +7,7 @@ namespace mu2e { using MatDBInfo = MatEnv::MatDBInfo; using MatEnv::DetMaterial; - KKMaterial::KKMaterial(KKMaterial::Config const& matconfig) : + KKMaterial::KKMaterial(KKMaterial::Config const& matconfig) : ProditionsEntity("KKMaterial"), elementsBaseName_(matconfig.elements()), isotopesBaseName_(matconfig.isotopes()), materialsBaseName_(matconfig.materials()), diff --git a/Mu2eKinKal/src/SConscript b/Mu2eKinKal/src/SConscript index 33a145e8e5..1419c781cc 100644 --- a/Mu2eKinKal/src/SConscript +++ b/Mu2eKinKal/src/SConscript @@ -20,6 +20,7 @@ mainlib = helper.make_mainlib([ 'mu2e_GeometryService', 'mu2e_BFieldGeom', 'mu2e_CalorimeterGeom', + 'mu2e_KinKalGeom', 'mu2e_TrackerGeom', 'mu2e_RecoDataProducts', 'mu2e_GlobalConstantsService', @@ -40,7 +41,6 @@ mainlib = helper.make_mainlib([ 'tbb', 'cetlib', 'cetlib_except', - 'mu2e_KinKalGeom', 'KinKal_Fit', 'KinKal_Trajectory', 'KinKal_Geometry', @@ -62,6 +62,7 @@ helper.make_plugins([mainlib, 'mu2e_GeometryService', 'mu2e_BFieldGeom', 'mu2e_CalorimeterGeom', + 'mu2e_KinKalGeom', 'mu2e_TrackerGeom', 'mu2e_RecoDataProducts', 'mu2e_GlobalConstantsService', @@ -87,7 +88,6 @@ helper.make_plugins([mainlib, 'cetlib', 'cetlib_except', 'CLHEP', - 'mu2e_KinKalGeom', 'KinKal_Fit', 'KinKal_Trajectory', 'KinKal_Geometry', diff --git a/fcl/standardServices.fcl b/fcl/standardServices.fcl index bbbc18dbab..96191e747b 100644 --- a/fcl/standardServices.fcl +++ b/fcl/standardServices.fcl @@ -42,6 +42,20 @@ Services : { inputFile : "Offline/Mu2eG4/geom/geom_common.txt" bFieldFile : "Offline/Mu2eG4/geom/bfgeom_v01.txt" simulatedDetector : { tool_type: "Mu2e" } + KinKalMaterial : { + elements : "Offline/TrackerConditions/data/ElementsList.data" + isotopes : "Offline/TrackerConditions/data/IsotopesList.data" + materials : "Offline/TrackerConditions/data/MaterialsList.data" + strawGasMaterialName : "straw-gas" + strawWallMaterialName : "straw-wall" + strawWireMaterialName : "straw-wire" + IPAMaterialName : "HDPE" + STMaterialName : "Target" + IonizationEnergyLossMode : 1 # Moyal mean + SolidScatteringFraction : 0.999999 + GasScatteringFraction : 0.9999999 + ElectronBrehmsFraction : 0.04 + } } GlobalConstantsService : { inputFile : "Offline/GlobalConstantsService/data/globalConstants_01.txt" } DbService : @local::DbEmpty From 3dbe69724abb1b97a0d8a7b7dc94ca2546574cc9 Mon Sep 17 00:00:00 2001 From: David Nathan Brown Date: Sat, 16 May 2026 14:35:20 -0700 Subject: [PATCH 7/9] Convert to using KKMaterial from GeometryService --- Mu2eKinKal/fcl/prolog.fcl | 20 -------- Mu2eKinKal/inc/KKExtrap.hh | 49 +++++++++----------- Mu2eKinKal/src/CentralHelixFit_module.cc | 9 ++-- Mu2eKinKal/src/KinematicLineFit_module.cc | 17 +++---- Mu2eKinKal/src/LoopHelixFit_module.cc | 15 ++---- Mu2eKinKal/src/RegrowKinematicLine_module.cc | 12 ++--- Mu2eKinKal/src/RegrowLoopHelix_module.cc | 10 ++-- 7 files changed, 43 insertions(+), 89 deletions(-) diff --git a/Mu2eKinKal/fcl/prolog.fcl b/Mu2eKinKal/fcl/prolog.fcl index c827389d0f..808ff07c56 100644 --- a/Mu2eKinKal/fcl/prolog.fcl +++ b/Mu2eKinKal/fcl/prolog.fcl @@ -3,20 +3,6 @@ BEGIN_PROLOG Mu2eKinKal : { # general configuration # - MAT: { - elements : "Offline/TrackerConditions/data/ElementsList.data" - isotopes : "Offline/TrackerConditions/data/IsotopesList.data" - materials : "Offline/TrackerConditions/data/MaterialsList.data" - strawGasMaterialName : "straw-gas" - strawWallMaterialName : "straw-wall" - strawWireMaterialName : "straw-wire" - IPAMaterialName : "HDPE" - STMaterialName : "Target" - IonizationEnergyLossMode : 1 # Moyal mean - SolidScatteringFraction : 0.999999 - GasScatteringFraction : 0.9999999 - ElectronBrehmsFraction : 0.04 - } KKFIT: { PrintLevel : 0 TPOCAPrecision : 1e-4 # mm @@ -446,7 +432,6 @@ Mu2eKinKal : { LHSeedFit : { module_type : LoopHelixFit - MaterialSettings : @local::Mu2eKinKal.MAT KKFitSettings: { @table::Mu2eKinKal.KKFIT SampleSurfaces : ["TT_Mid"] @@ -468,7 +453,6 @@ Mu2eKinKal : { LHDriftFit : { module_type : LoopHelixFit - MaterialSettings : @local::Mu2eKinKal.MAT KKFitSettings : { @table::Mu2eKinKal.KKFIT SampleSurfaces : ["ST_Outer","ST_Front","ST_Back"] # these are additional surfaces; surfaces used in extrapolation are also sampled @@ -493,7 +477,6 @@ Mu2eKinKal : { KLSeedFit : { module_type : KinematicLineFit - MaterialSettings : @local::Mu2eKinKal.MAT KKFitSettings: @local::Mu2eKinKal.KKFIT FitSettings : @local::Mu2eKinKal.CHSEEDFIT ExtensionSettings : { @@ -508,7 +491,6 @@ Mu2eKinKal : { KLDriftFit : { module_type : KinematicLineFit - MaterialSettings : @local::Mu2eKinKal.MAT KKFitSettings: { @table::Mu2eKinKal.KKFIT # DNB I don't know where this time offset difference WRT helical fits comes from. If it's physical, we will need a better @@ -531,7 +513,6 @@ Mu2eKinKal : { CHSeedFit : { module_type : CentralHelixFit - MaterialSettings : @local::Mu2eKinKal.MAT KKFitSettings: { @table::Mu2eKinKal.KKFIT SaveTrajectory : T0 @@ -547,7 +528,6 @@ Mu2eKinKal : { CHDriftFit : { module_type : CentralHelixFit - MaterialSettings : @local::Mu2eKinKal.MAT KKFitSettings: { @table::Mu2eKinKal.KKFIT SaveTrajectory : Detector diff --git a/Mu2eKinKal/inc/KKExtrap.hh b/Mu2eKinKal/inc/KKExtrap.hh index 6f67fc2a0c..f46290275d 100644 --- a/Mu2eKinKal/inc/KKExtrap.hh +++ b/Mu2eKinKal/inc/KKExtrap.hh @@ -30,7 +30,7 @@ namespace mu2e { class KKExtrap { public: - explicit KKExtrap(KKExtrapConfig const& exconfig,KKMaterial const& kkmat); + explicit KKExtrap(KKExtrapConfig const& exconfig); // extrapolation functions; these are templated on the type of trajectory template void extrapolate(KKTrack& ktrk) const; template void toTrackerEnds(KKTrack& ktrk) const; @@ -43,18 +43,16 @@ namespace mu2e { private: int debug_; double btol_, intertol_, maxdt_; - KKMaterial const& kkmat_; bool backToTracker_, toOPA_, toTrackerEnds_, upstream_; double ipathick_ = 0.511; // ipa thickness: should come from geometry service TODO double stthick_ = 0.1056; // st foil thickness: should come from geometry service TODO }; - KKExtrap::KKExtrap(KKExtrapConfig const& extrapconfig,KKMaterial const& kkmat) : + KKExtrap::KKExtrap(KKExtrapConfig const& extrapconfig) : debug_(extrapconfig.Debug()), btol_(extrapconfig.btol()), intertol_(extrapconfig.interTol()), maxdt_(extrapconfig.MaxDt()), - kkmat_(kkmat), backToTracker_(extrapconfig.BackToTracker()), toOPA_(extrapconfig.ToOPA()), toTrackerEnds_(extrapconfig.ToTrackerEnds()), @@ -63,8 +61,7 @@ namespace mu2e { template void KKExtrap::extrapolate(KKTrack& ktrk) const { GeomHandle kkg_h; - auto const& kkg = *kkg_h; - ExtrapolateToZ trackerFront(maxdt_,btol_,kkg.tracker()->front().center().Z(),debug_); + ExtrapolateToZ trackerFront(maxdt_,btol_,kkg_h->tracker()->front().center().Z(),debug_); // define the time direction according to the fit direction inside the tracker auto const& ftraj = ktrk.fitTraj(); @@ -103,10 +100,9 @@ namespace mu2e { template void KKExtrap::toTrackerEnds(KKTrack& ktrk) const { GeomHandle kkg_h; - auto const& kkg = *kkg_h; - ExtrapolateToZ trackerFront(maxdt_,btol_,kkg.tracker()->front().center().Z(),debug_); - ExtrapolateToZ trackerBack(maxdt_,btol_,kkg.tracker()->back().center().Z(),debug_); + ExtrapolateToZ trackerFront(maxdt_,btol_,kkg_h->tracker()->front().center().Z(),debug_); + ExtrapolateToZ trackerBack(maxdt_,btol_,kkg_h->tracker()->back().center().Z(),debug_); // time direction to reach the bounding surfaces from the active region depends on the z momentum. This calculation assumes the particle doesn't // reflect inside the tracker volume auto const& ftraj = ktrk.fitTraj(); @@ -121,18 +117,18 @@ namespace mu2e { static const SurfaceId tt_back("TT_Back"); // start with the middle - auto midinter = KinKal::intersect(ftraj,kkg.tracker()->middle(),ftraj.range(),intertol_); + auto midinter = KinKal::intersect(ftraj,kkg_h->tracker()->middle(),ftraj.range(),intertol_); if(midinter.good()) ktrk.addIntersection(tt_mid,midinter); if(tofront){ // check the front piece first; that is usually correct // track extrapolation to the front succeeded, but the intersection failed. Use the last trajectory to force an intersection auto fhel = fronttdir == TimeDir::forwards ? ftraj.back() : ftraj.front(); - auto frontinter = KinKal::intersect(fhel,kkg.tracker()->front(),fhel.range(),intertol_,fronttdir); + auto frontinter = KinKal::intersect(fhel,kkg_h->tracker()->front(),fhel.range(),intertol_,fronttdir); if(!frontinter.good()){ // start from the middle TimeRange frange = ftraj.range(); if(midinter.good())frange = fronttdir == TimeDir::forwards ? TimeRange(midinter.time_,ftraj.range().end()) : TimeRange(ftraj.range().begin(),midinter.time_); - frontinter = KinKal::intersect(ftraj,kkg.tracker()->front(),frange,intertol_,fronttdir); + frontinter = KinKal::intersect(ftraj,kkg_h->tracker()->front(),frange,intertol_,fronttdir); } if(frontinter.good()) ktrk.addIntersection(tt_front,frontinter); } @@ -140,19 +136,19 @@ namespace mu2e { // start from the middle TimeRange brange = ftraj.range(); if(midinter.good())brange = backtdir == TimeDir::forwards ? TimeRange(midinter.time_,ftraj.range().end()) : TimeRange(ftraj.range().begin(),midinter.time_); - auto backinter = KinKal::intersect(ftraj,kkg.tracker()->back(),brange,intertol_,backtdir); + auto backinter = KinKal::intersect(ftraj,kkg_h->tracker()->back(),brange,intertol_,backtdir); if(backinter.good())ktrk.addIntersection(tt_back,backinter); } } template bool KKExtrap::extrapolateIPA(KKTrack& ktrk,TimeDir tdir) const { GeomHandle kkg_h; - auto const& kkg = *kkg_h; + GeomHandle kkmat_h; using KKIPAXING = KKShellXing; using KKIPAXINGPTR = std::shared_ptr; // extraplate the fit through the IPA. This will add material effects for each intersection. It will continue till the // track exits the IPA - ExtrapolateIPA extrapIPA(maxdt_,btol_,intertol_,kkg.DS()->innerProtonAbsorberPtr(),debug_); + ExtrapolateIPA extrapIPA(maxdt_,btol_,intertol_,kkg_h->DS()->innerProtonAbsorberPtr(),debug_); if(extrapIPA.debug() > 0)std::cout << "extrapolating to IPA " << std::endl; auto const& ftraj = ktrk.fitTraj(); static const SurfaceId IPASID("IPA"); @@ -163,8 +159,8 @@ namespace mu2e { if(extrapIPA.intersection().good()){ // we have a good intersection. Use this to create a Shell material Xing auto const& reftrajptr = tdir == TimeDir::backwards ? ftraj.frontPtr() : ftraj.backPtr(); - auto const& IPA = kkg.DS()->innerProtonAbsorberPtr(); - KKIPAXINGPTR ipaxingptr = std::make_shared(IPA,IPASID,*kkmat_.IPAMaterial(),extrapIPA.intersection(),reftrajptr,ipathick_,extrapIPA.interTolerance()); + auto const& IPA = kkg_h->DS()->innerProtonAbsorberPtr(); + KKIPAXINGPTR ipaxingptr = std::make_shared(IPA,IPASID,*kkmat_h->IPAMaterial(),extrapIPA.intersection(),reftrajptr,ipathick_,extrapIPA.interTolerance()); if(extrapIPA.debug() > 0){ double dmom, paramomvar, perpmomvar; ipaxingptr->materialEffects(dmom,paramomvar,perpmomvar); @@ -191,11 +187,11 @@ namespace mu2e { using KKSTXING = KKShellXing; using KKSTXINGPTR = std::shared_ptr; GeomHandle kkg_h; - auto const& kkg = *kkg_h; + GeomHandle kkmat_h; // extraplate the fit through the ST. This will add material effects for each foil intersection. It will continue till the // track exits the ST in Z - ExtrapolateST extrapST(maxdt_,btol_,intertol_,*kkg.ST(),debug_); + ExtrapolateST extrapST(maxdt_,btol_,intertol_,*kkg_h->ST(),debug_); auto const& ftraj = ktrk.fitTraj(); double starttime = tdir == TimeDir::forwards ? ftraj.range().end() : ftraj.range().begin(); auto startdir = ftraj.direction(starttime); @@ -205,7 +201,7 @@ namespace mu2e { if(extrapST.intersection().good()){ // we have a good intersection. Use this to create a Shell material Xing auto const& reftrajptr = tdir == TimeDir::backwards ? ftraj.frontPtr() : ftraj.backPtr(); - KKSTXINGPTR stxingptr = std::make_shared(extrapST.foil(),extrapST.foilId(),*kkmat_.STMaterial(),extrapST.intersection(),reftrajptr,stthick_,extrapST.interTolerance()); + KKSTXINGPTR stxingptr = std::make_shared(extrapST.foil(),extrapST.foilId(),*kkmat_h->STMaterial(),extrapST.intersection(),reftrajptr,stthick_,extrapST.interTolerance()); if(extrapST.debug() > 0){ double dmom, paramomvar, perpmomvar; stxingptr->materialEffects(dmom,paramomvar,perpmomvar); @@ -231,15 +227,14 @@ namespace mu2e { template bool KKExtrap::extrapolateTracker(KKTrack& ktrk,TimeDir tdir) const { GeomHandle kkg_h; - auto const& kkg = *kkg_h; - ExtrapolateToZ trackerFront(maxdt_,btol_,kkg.tracker()->front().center().Z(),debug_); + ExtrapolateToZ trackerFront(maxdt_,btol_,kkg_h->tracker()->front().center().Z(),debug_); if(trackerFront.debug() > 0)std::cout << "extrapolating to Tracker " << std::endl; auto const& ftraj = ktrk.fitTraj(); static const SurfaceId TrackerSID("TT_Front"); ktrk.extrapolate(tdir,trackerFront); // the last piece appended should cover the necessary range auto const& ktraj = tdir == TimeDir::forwards ? ftraj.back() : ftraj.front(); - auto trkfrontinter = KinKal::intersect(ftraj,kkg.tracker()->front(),ktraj.range(),intertol_,tdir); + auto trkfrontinter = KinKal::intersect(ftraj,kkg_h->tracker()->front(),ktraj.range(),intertol_,tdir); if(trkfrontinter.onsurface_){ // dont worry about bounds here ktrk.addIntersection(TrackerSID,trkfrontinter); return true; @@ -249,8 +244,7 @@ namespace mu2e { template bool KKExtrap::extrapolateTSDA(KKTrack& ktrk,TimeDir tdir) const { GeomHandle kkg_h; - auto const& kkg = *kkg_h; - ExtrapolateToZ TSDA(maxdt_,btol_,kkg.DS()->upstreamAbsorber().center().Z(),debug_); + ExtrapolateToZ TSDA(maxdt_,btol_,kkg_h->DS()->upstreamAbsorber().center().Z(),debug_); if(TSDA.debug() > 0)std::cout << "extrapolating to TSDA " << std::endl; auto const& ftraj = ktrk.fitTraj(); static const SurfaceId TSDASID("TSDA"); @@ -261,7 +255,7 @@ namespace mu2e { bool retval = epos.Z() < TSDA.zVal(); if(retval){ auto const& ktraj = tdir == TimeDir::forwards ? ftraj.back() : ftraj.front(); - auto tsdainter = KinKal::intersect(ftraj,kkg.DS()->upstreamAbsorber(),ktraj.range(),intertol_,tdir); + auto tsdainter = KinKal::intersect(ftraj,kkg_h->DS()->upstreamAbsorber(),ktraj.range(),intertol_,tdir); if(tsdainter.onsurface_)ktrk.addIntersection(TSDASID,tsdainter); } return retval; @@ -269,11 +263,10 @@ namespace mu2e { template void KKExtrap::toOPA(KKTrack& ktrk, double tstart, TimeDir tdir) const { GeomHandle kkg_h; - auto const& kkg = *kkg_h; auto const& ftraj = ktrk.fitTraj(); static const SurfaceId OPASID("OPA"); TimeRange trange = tdir == TimeDir::forwards ? TimeRange(tstart,ftraj.range().end()) : TimeRange(ftraj.range().begin(),tstart); - auto opainter = KinKal::intersect(ftraj,kkg.DS()->outerProtonAbsorber(),trange,intertol_,tdir); + auto opainter = KinKal::intersect(ftraj,kkg_h->DS()->outerProtonAbsorber(),trange,intertol_,tdir); if(opainter.good()){ ktrk.addIntersection(OPASID,opainter); } diff --git a/Mu2eKinKal/src/CentralHelixFit_module.cc b/Mu2eKinKal/src/CentralHelixFit_module.cc index eec7358e5d..f6cef066ed 100644 --- a/Mu2eKinKal/src/CentralHelixFit_module.cc +++ b/Mu2eKinKal/src/CentralHelixFit_module.cc @@ -102,7 +102,6 @@ namespace mu2e { using KKFitConfig = Mu2eKinKal::KKFitConfig; using KKModuleConfig = Mu2eKinKal::KKModuleConfig; - using KKMaterialConfig = KKMaterial::Config; using Name = fhicl::Name; using Comment = fhicl::Comment; using KinKal::DVEC; @@ -128,7 +127,6 @@ namespace mu2e { fhicl::Table kkfitSettings { Name("KKFitSettings") }; fhicl::Table fitSettings { Name("FitSettings") }; fhicl::Table extSettings { Name("ExtensionSettings") }; - fhicl::Table matSettings { Name("MaterialSettings") }; // helix module specific config }; @@ -155,7 +153,6 @@ namespace mu2e { int print_; PDGCode::type fpart_; KKFIT kkfit_; // fit helper - KKMaterial kkmat_; // material helper DMAT seedcov_; // seed covariance matrix double mass_; // particle mass int PDGcharge_; // PDG particle charge @@ -184,7 +181,6 @@ namespace mu2e { print_(settings().modSettings().printLevel()), fpart_(static_cast(settings().modSettings().fitParticle())), kkfit_(settings().kkfitSettings()), - kkmat_(settings().matSettings()), config_(Mu2eKinKal::makeConfig(settings().fitSettings())), exconfig_(Mu2eKinKal::makeConfig(settings().extSettings())), fixedfield_(false), @@ -246,6 +242,7 @@ namespace mu2e { void CentralHelixFit::produce(art::Event& event ) { GeomHandle calo_h; GeomHandle nominalTracker_h; + GeomHandle kkmat_h; // find current proditions auto const& strawresponse = strawResponse_h_.getPtr(event.id()); auto const& tracker = alignedTracker_h_.getPtr(event.id()).get(); @@ -319,7 +316,7 @@ namespace mu2e { strawhits.reserve(strawHitIdxs.size()); KKSTRAWXINGCOL strawxings; strawxings.reserve(strawHitIdxs.size()); - kkfit_.makeStrawHits(*tracker, *strawresponse, *kkbf_, kkmat_.strawMaterial(), pseedtraj, chcol, strawHitIdxs, strawhits, strawxings); + kkfit_.makeStrawHits(*tracker, *strawresponse, *kkbf_, kkmat_h->strawMaterial(), pseedtraj, chcol, strawHitIdxs, strawhits, strawxings); // optionally (and if present) add the CaloCluster as a constraint // verify the cluster looks physically reasonable before adding it TODO! Or, let the KKCaloHit updater do it TODO KKCALOHITCOL calohits; @@ -335,7 +332,7 @@ namespace mu2e { // if we have an extension schedule, extend. if(goodfit && exconfig_.schedule().size() > 0) { // std::cout << "EXTENDING TRACK " << event.id() << " " << index << std::endl; - kkfit_.extendTrack(exconfig_,*kkbf_, *tracker,*strawresponse, kkmat_.strawMaterial(), chcol, *calo_h, cc_H, *kktrk ); + kkfit_.extendTrack(exconfig_,*kkbf_, *tracker,*strawresponse, kkmat_h->strawMaterial(), chcol, *calo_h, cc_H, *kktrk ); goodfit = goodFit(*kktrk); } diff --git a/Mu2eKinKal/src/KinematicLineFit_module.cc b/Mu2eKinKal/src/KinematicLineFit_module.cc index 30e2079631..60f135404c 100644 --- a/Mu2eKinKal/src/KinematicLineFit_module.cc +++ b/Mu2eKinKal/src/KinematicLineFit_module.cc @@ -103,7 +103,6 @@ namespace mu2e { using KKConfig = Mu2eKinKal::KinKalConfig; using KKFitConfig = Mu2eKinKal::KKFitConfig; using KKModuleConfig = Mu2eKinKal::KKModuleConfig; - using KKMaterialConfig = KKMaterial::Config; class KinematicLineFit : public art::EDProducer { using Name = fhicl::Name; @@ -133,7 +132,6 @@ namespace mu2e { fhicl::Table mu2eSettings { Name("KKFitSettings") }; fhicl::Table fitSettings { Name("FitSettings") }; fhicl::Table extSettings { Name("ExtensionSettings") }; - fhicl::Table matSettings { Name("MaterialSettings") }; fhicl::OptionalTable Extrapolation { Name("Extrapolation") }; fhicl::OptionalAtom fitDirection { Name("FitDirection"), Comment("Particle direction to fit, either \"upstream\" or \"downstream\"")}; }; @@ -163,7 +161,6 @@ namespace mu2e { PDGCode::type fpart_; TrkFitDirection fdir_; KKFIT kkfit_; // fit helper - KKMaterial kkmat_; // material helper DMAT seedcov_; // seed covariance matrix std::array paramconstraints_; double mass_; // particle mass @@ -191,7 +188,6 @@ namespace mu2e { seedmom_(settings().modSettings().seedmom()), fpart_(static_cast(settings().modSettings().fitParticle())), kkfit_(settings().mu2eSettings()), - kkmat_(settings().matSettings()), intertol_(settings().modSettings().interTol()), sampletbuff_(settings().modSettings().sampleTBuff()), sampleinrange_(settings().modSettings().sampleInRange()), @@ -257,8 +253,7 @@ namespace mu2e { kkbf_ = std::make_unique(*bfmgr,*det); // translate the sample surface names to actual surfaces using the KinKalGeom. This must be done after construction as the KKGeom object now comes from GeometryService GeomHandle kkg_h; - auto const& kkg = *kkg_h; - kkg.surfaces(ssids_,surfacess_to_sample_); + kkg_h->surfaces(ssids_,surfacess_to_sample_); } void KinematicLineFit::produce(art::Event& event ) { @@ -303,7 +298,7 @@ namespace mu2e { KKSTRAWXINGCOL strawxings; strawhits.reserve(strawHitIdxs.size()); strawxings.reserve(strawHitIdxs.size()); - kkfit_.makeStrawHits(*tracker, *strawresponse, *kkbf_, kkmat_.strawMaterial(), pseedtraj, *chcolptr, strawHitIdxs, strawhits, strawxings); + kkfit_.makeStrawHits(*tracker, *strawresponse, *kkbf_, kkmat_h->strawMaterial(), pseedtraj, *chcolptr, strawHitIdxs, strawhits, strawxings); //here KKCALOHITCOL calohits; @@ -324,7 +319,7 @@ namespace mu2e { auto kktrk = make_unique(config_,*kkbf_,seedtraj,fpart_,kkfit_.strawHitClusterer(),strawhits,strawxings,calohits,paramconstraints_); auto goodfit = goodFit(*kktrk); if(goodfit && exconfig_.schedule().size() > 0){ - kkfit_.extendTrack(exconfig_,*kkbf_, *tracker,*strawresponse, kkmat_.strawMaterial(), chcol, *calo_h, cc_H, *kktrk ); + kkfit_.extendTrack(exconfig_,*kkbf_, *tracker,*strawresponse, kkmat_h->strawMaterial(), chcol, *calo_h, cc_H, *kktrk ); } goodfit = goodFit(*kktrk); // extrapolate as required @@ -412,9 +407,9 @@ namespace mu2e { void KinematicLineFit::extrapolate(KKTRK& ktrk) const { GeomHandle kkg_h; - auto const& kkg = *kkg_h; + GeomHandle kkmat_h; // extrapolate to the extracted CRV. This function should be migrated to KKExtrap TODO - auto TCRV = ExtrapolateTCRV(maxdt_,btol_,intertol_,minv_,*kkg.TCRV(),extrapdebug_); + auto TCRV = ExtrapolateTCRV(maxdt_,btol_,intertol_,minv_,*kkg_h->TCRV(),extrapdebug_); auto const& ftraj = ktrk.fitTraj(); static const SurfaceId TCRVSID("TCRV"); @@ -437,7 +432,7 @@ namespace mu2e { // we have a good intersection. Use this to create a Shell material Xing auto const& reftrajptr = tdir == TimeDir::backwards ? ftraj.frontPtr() : ftraj.backPtr(); // TODO add DS and shielding material - KKCRVXINGPTR crvxingptr = std::make_shared(TCRV.module(), TCRVSID, *kkmat_.STMaterial(),TCRV.intersection(),reftrajptr,tcrvthick_,TCRV.interTolerance()); + KKCRVXINGPTR crvxingptr = std::make_shared(TCRV.module(), TCRVSID, *kkmat_h->STMaterial(),TCRV.intersection(),reftrajptr,tcrvthick_,TCRV.interTolerance()); ktrk.addTCRVXing(crvxingptr,tdir); } } while(hadintersection); diff --git a/Mu2eKinKal/src/LoopHelixFit_module.cc b/Mu2eKinKal/src/LoopHelixFit_module.cc index d44d92fcb8..e386deaa0a 100644 --- a/Mu2eKinKal/src/LoopHelixFit_module.cc +++ b/Mu2eKinKal/src/LoopHelixFit_module.cc @@ -108,7 +108,6 @@ namespace mu2e { using EXINGPTR = std::shared_ptr; using EXINGCOL = std::vector; - using KKMaterialConfig = KKMaterial::Config; using Name = fhicl::Name; using Comment = fhicl::Comment; @@ -125,7 +124,6 @@ namespace mu2e { fhicl::Table kkfitSettings { Name("KKFitSettings") }; fhicl::Table fitSettings { Name("FitSettings") }; fhicl::Table extSettings { Name("ExtensionSettings") }; - fhicl::Table matSettings { Name("MaterialSettings") }; fhicl::OptionalTable finalSettings { Name("FinalSettings") }; fhicl::OptionalTable extrapSettings { Name("ExtrapolationSettings") }; // LoopHelix module specific config @@ -167,7 +165,6 @@ namespace mu2e { TrkFitDirection fdir_; bool usePDGCharge_; // use the pdg particle charge: otherwise use the helicity and direction to determine the charge KKFIT kkfit_; // fit helper - KKMaterial kkmat_; // material helper DMAT seedcov_; // seed covariance matrix double mass_; // particle mass int PDGcharge_; // PDG particle charge @@ -198,7 +195,6 @@ namespace mu2e { useHelixSlope_(settings().slopeSigThreshold(slopeSigThreshold_)), usePDGCharge_(settings().pdgCharge()), kkfit_(settings().kkfitSettings()), - kkmat_(settings().matSettings()), config_(Mu2eKinKal::makeConfig(settings().fitSettings())), exconfig_(Mu2eKinKal::makeConfig(settings().extSettings())), fixedfield_(false) @@ -224,7 +220,7 @@ namespace mu2e { kkbf_ = std::move(std::make_unique(VEC3(0.0,0.0,bz))); } // setup extrapolation - if(settings().extrapSettings())extrap_ = make_unique(*settings().extrapSettings(),kkmat_); + if(settings().extrapSettings())extrap_ = make_unique(*settings().extrapSettings()); // setup optional fit finalization; this just updates the internals, not the fit result itself if(settings().finalSettings()){ @@ -288,10 +284,9 @@ namespace mu2e { // check the input if(fdir.fitDirection() != TrkFitDirection::FitDirection::downstream && fdir.fitDirection() != TrkFitDirection::FitDirection::upstream) throw cet::exception("RECO") << "mu2e::LoopHelixFit: Unknown helix propagation direction " << fdir.name(); - - // Retrieve event information - // calo geom + // geom GeomHandle calo_h; + GeomHandle kkmat_h; // find current proditions auto const& strawresponse = strawResponse_h_.getPtr(event.id()); auto const& tracker = alignedTracker_h_.getPtr(event.id()).get(); @@ -336,7 +331,7 @@ namespace mu2e { strawhits.reserve(strawHitIdxs.size()); KKSTRAWXINGCOL strawxings; strawxings.reserve(strawHitIdxs.size()); - if(!kkfit_.makeStrawHits(*tracker, *strawresponse, *kkbf_, kkmat_.strawMaterial(), pseedtraj, chcol, strawHitIdxs, strawhits, strawxings)) { + if(!kkfit_.makeStrawHits(*tracker, *strawresponse, *kkbf_, kkmat_h->strawMaterial(), pseedtraj, chcol, strawHitIdxs, strawhits, strawxings)) { if(print_>0) printf("[LoopHelixFit::%s] Failed to create a track\n", __func__); return nullptr; } @@ -358,7 +353,7 @@ namespace mu2e { __func__, goodfit, ktrk->fitStatus().chisq_.probability(), ktrk->strawHits().size(), ktrk->caloHits().size()); // if we have an extension schedule, extend. if(goodfit && exconfig_.schedule().size() > 0) { - kkfit_.extendTrack(exconfig_,*kkbf_, *tracker,*strawresponse, kkmat_.strawMaterial(), chcol, *calo_h, cc_H, *ktrk ); + kkfit_.extendTrack(exconfig_,*kkbf_, *tracker,*strawresponse, kkmat_h->strawMaterial(), chcol, *calo_h, cc_H, *ktrk ); goodfit = goodFit(*ktrk,seedtraj); // if finalizing, apply that now. if(goodfit && fconfig_.schedule().size() > 0){ diff --git a/Mu2eKinKal/src/RegrowKinematicLine_module.cc b/Mu2eKinKal/src/RegrowKinematicLine_module.cc index 93d6e278d4..179331d13c 100644 --- a/Mu2eKinKal/src/RegrowKinematicLine_module.cc +++ b/Mu2eKinKal/src/RegrowKinematicLine_module.cc @@ -79,7 +79,6 @@ namespace mu2e { using Mu2eKinKal::KKFinalConfig; using KKFitConfig = Mu2eKinKal::KKFitConfig; using KKModuleConfig = Mu2eKinKal::KKModuleConfig; - using KKMaterialConfig = KKMaterial::Config; using SDIS = std::set; using Name = fhicl::Name; @@ -91,7 +90,6 @@ namespace mu2e { fhicl::Atom indexMap {Name("StrawDigiIndexMap"), Comment("Map between original and reduced ComboHits") }; fhicl::OptionalAtom kalSeedMCAssns {Name("KalSeedMCAssns"), Comment("Association to KalSeedMC. If set, regrown KalSeeds will be associated with the same KalSeedMC as the original") }; fhicl::Table kkfitSettings { Name("KKFitSettings") }; - fhicl::Table matSettings { Name("MaterialSettings") }; fhicl::Table fitSettings { Name("RefitSettings") }; fhicl::OptionalTable extrapSettings { Name("ExtrapolationSettings") }; }; @@ -130,8 +128,6 @@ namespace mu2e { using DOMAINPTR = std::shared_ptr; using DOMAINCOL = std::set; - using KKMaterialConfig = KKMaterial::Config; - explicit RegrowKinematicLine(const Parameters& settings); void beginRun(art::Run& run) override; void produce(art::Event& event) override; @@ -143,7 +139,6 @@ namespace mu2e { std::unique_ptr kkbf_; Config config_; // refit configuration object, containing the fit schedule KKFIT kkfit_; - KKMaterial kkmat_; art::ProductToken kseedcol_T_; art::ProductToken chcol_T_; art::ProductToken indexmap_T_; @@ -156,7 +151,6 @@ namespace mu2e { debug_(settings().debug()), config_(Mu2eKinKal::makeConfig(settings().fitSettings())), kkfit_(settings().kkfitSettings()), - kkmat_(settings().matSettings()), kseedcol_T_(consumes(settings().kalSeedCollection())), chcol_T_(consumes(settings().comboHitCollection())), indexmap_T_(consumes(settings().indexMap())), @@ -164,7 +158,7 @@ namespace mu2e { { produces(); produces(); - if(settings().extrapSettings())extrap_ = make_unique(*settings().extrapSettings(),kkmat_); + if(settings().extrapSettings())extrap_ = make_unique(*settings().extrapSettings()); if( fillMCAssns_){ consumes(ksmca_T_); produces (); @@ -185,6 +179,8 @@ namespace mu2e { auto const& tracker = alignedTracker_h_.getPtr(event.id()).get(); GeomHandle nominalTracker_h; GeomHandle calo_h; + GeomHandle kkmat_h; + // find input event data auto kseed_H = event.getValidHandle(kseedcol_T_); const auto& kseedcol = *kseed_H; @@ -218,7 +214,7 @@ namespace mu2e { DOMAINCOL domains; // create the trajectory. This is done here to be strongly typed auto goodhits = kkfit_.regrowComponents(kseed, chcol, indexmap, - *tracker,*calo_h,*strawresponse,*kkbf_, kkmat_.strawMaterial(), + *tracker,*calo_h,*strawresponse,*kkbf_, kkmat_h->strawMaterial(), trajptr, strawhits, calohits, strawxings, domains); if(debug_ > 0){ std::cout << "Regrew " << strawhits.size() << " straw hits, " << strawxings.size() << " straw xings, " << calohits.size() << " CaloHits and " << domains.size() << " domains, status = " << goodhits << std::endl; diff --git a/Mu2eKinKal/src/RegrowLoopHelix_module.cc b/Mu2eKinKal/src/RegrowLoopHelix_module.cc index 2f648f2b6a..a4584dfe52 100644 --- a/Mu2eKinKal/src/RegrowLoopHelix_module.cc +++ b/Mu2eKinKal/src/RegrowLoopHelix_module.cc @@ -92,7 +92,6 @@ namespace mu2e { fhicl::Atom indexMap {Name("StrawDigiIndexMap"), Comment("Map between original and reduced ComboHits") }; fhicl::OptionalAtom kalSeedMCAssns {Name("KalSeedMCAssns"), Comment("Association to KalSeedMC. If set, regrown KalSeeds will be associated with the same KalSeedMC as the original") }; fhicl::Table kkfitSettings { Name("KKFitSettings") }; - fhicl::Table matSettings { Name("MaterialSettings") }; fhicl::Table fitSettings { Name("RefitSettings") }; fhicl::Atom extend {Name("Extend"), Comment("Extend the fit") }; @@ -146,7 +145,6 @@ namespace mu2e { std::unique_ptr kkbf_; Config config_; // refit configuration object, containing the fit schedule KKFIT kkfit_; - KKMaterial kkmat_; art::ProductToken kseedcol_T_; art::ProductToken chcol_T_; art::ProductToken cccol_T_; @@ -161,7 +159,6 @@ namespace mu2e { debug_(settings().debug()), config_(Mu2eKinKal::makeConfig(settings().fitSettings())), kkfit_(settings().kkfitSettings()), - kkmat_(settings().matSettings()), kseedcol_T_(consumes(settings().kalSeedCollection())), chcol_T_(consumes(settings().comboHitCollection())), cccol_T_(mayConsume(settings().caloClusterCollection())), @@ -171,7 +168,7 @@ namespace mu2e { { produces(); produces(); - if(settings().extrapSettings())extrap_ = make_unique(*settings().extrapSettings(),kkmat_); + if(settings().extrapSettings())extrap_ = make_unique(*settings().extrapSettings()); if( fillMCAssns_){ consumes(ksmca_T_); produces (); @@ -192,6 +189,7 @@ namespace mu2e { auto const& tracker = alignedTracker_h_.getPtr(event.id()).get(); GeomHandle nominalTracker_h; GeomHandle calo_h; + GeomHandle kkmat_h; // find input event data auto kseed_H = event.getValidHandle(kseedcol_T_); const auto& kseedcol = *kseed_H; @@ -226,7 +224,7 @@ namespace mu2e { DOMAINCOL domains; // create the trajectory. This is done here to be strongly typed auto goodhits = kkfit_.regrowComponents(kseed, chcol, indexmap, - *tracker,*calo_h,*strawresponse,*kkbf_, kkmat_.strawMaterial(), + *tracker,*calo_h,*strawresponse,*kkbf_, kkmat_h->strawMaterial(), trajptr, strawhits, calohits, strawxings, domains); if(debug_ > 1){ std::cout << "Regrew " << strawhits.size() << " straw hits, " << strawxings.size() << " straw xings, " << calohits.size() << " CaloHits and " << domains.size() << " domains, status = " << goodhits << std::endl; @@ -245,7 +243,7 @@ namespace mu2e { auto ktrk = std::make_unique(config_,*kkbf_,kseed.particle(),trajptr,strawhits,strawxings,calohits,domains); if(ktrk && ktrk->fitStatus().usable()){ if(debug_ > 0) std::cout << "RegrowLoopHelix: successful track refit" << std::endl; - if(extend_)kkfit_.extendTrack(config_,*kkbf_, *tracker,*strawresponse, kkmat_.strawMaterial(), chcol, *calo_h, cc_H , *ktrk ); + if(extend_)kkfit_.extendTrack(config_,*kkbf_, *tracker,*strawresponse, kkmat_h->strawMaterial(), chcol, *calo_h, cc_H , *ktrk ); if(ktrk->fitStatus().usable()){ // extrapolate as requested if(extrap_)extrap_->extrapolate(*ktrk); From 0004c25f1e9e5693fd09e8fe61f99f3298450bf9 Mon Sep 17 00:00:00 2001 From: David Nathan Brown Date: Sat, 16 May 2026 14:44:55 -0700 Subject: [PATCH 8/9] Fix --- Mu2eKinKal/src/KinematicLineFit_module.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Mu2eKinKal/src/KinematicLineFit_module.cc b/Mu2eKinKal/src/KinematicLineFit_module.cc index 60f135404c..a2143c706b 100644 --- a/Mu2eKinKal/src/KinematicLineFit_module.cc +++ b/Mu2eKinKal/src/KinematicLineFit_module.cc @@ -259,6 +259,8 @@ namespace mu2e { void KinematicLineFit::produce(art::Event& event ) { GeomHandle calo_h; GeomHandle nominalTracker_h; + GeomHandle kkmat_h; + // find current proditions auto const& strawresponse = strawResponse_h_.getPtr(event.id()); auto const& tracker = alignedTracker_h_.getPtr(event.id()).get(); From 9edc8a0bfdde16faa0d619677818cc4982dd1bc7 Mon Sep 17 00:00:00 2001 From: David Nathan Brown Date: Mon, 18 May 2026 11:14:39 -0700 Subject: [PATCH 9/9] Remove unneeded ProditionsEntity dependency. Cleanup fcl --- GeometryService/src/KinKalGeomMaker.cc | 16 ++++++++-------- KinKalGeom/fcl/prolog.fcl | 18 ++++++++++++++++++ KinKalGeom/inc/KKMaterial.hh | 4 +--- KinKalGeom/inc/KinKalGeom.hh | 5 ++--- KinKalGeom/src/KKMaterial.cc | 2 +- KinKalGeom/src/KinKalGeom.cc | 1 - Mu2eKinKal/fcl/prolog.fcl | 1 + TrackerConditions/fcl/prolog.fcl | 14 -------------- fcl/standardServices.fcl | 26 +++++++------------------- 9 files changed, 38 insertions(+), 49 deletions(-) create mode 100644 KinKalGeom/fcl/prolog.fcl diff --git a/GeometryService/src/KinKalGeomMaker.cc b/GeometryService/src/KinKalGeomMaker.cc index 9d33dbccdb..683b22a997 100644 --- a/GeometryService/src/KinKalGeomMaker.cc +++ b/GeometryService/src/KinKalGeomMaker.cc @@ -81,14 +81,14 @@ namespace mu2e { void KinKalGeomMaker::makeDS() { GeomHandle det; GeomHandle ds; - std::cout << "DS Cryo or " << ds->rOut1() << "," << ds->rOut2() << " ir " << ds->rIn1()<<","<< ds->rIn2() << " halfl " << ds->halfLength() - << " zpos " << ds->position().z() << " material " << ds->material() << std::endl; - std::cout << "DS shield or " << ds->shield_rOut1() << "," << ds->shield_rOut2() << " ir " << ds->shield_rIn1()<<","<< ds->shield_rIn2() << " halfl " << ds->shield_halfLength() << " material " << ds->shield_material() << std::endl; - std::cout << "DS ncoils " << ds->nCoils() << std::endl; - for(size_t icoil = 0; icoil < static_cast(ds->nCoils()); icoil++){ - std::cout << "DS coil ir " << ds->coil_rIn() << " or " << ds->coil_rOut()[icoil] << " length " << ds->coil_zLength()[icoil] << " zpos " << ds->coil_zPosition()[icoil] - << " material " << ds->coil_materials()[icoil] << std::endl; - } +// std::cout << "DS Cryo or " << ds->rOut1() << "," << ds->rOut2() << " ir " << ds->rIn1()<<","<< ds->rIn2() << " halfl " << ds->halfLength() +// << " zpos " << ds->position().z() << " material " << ds->material() << std::endl; +// std::cout << "DS shield or " << ds->shield_rOut1() << "," << ds->shield_rOut2() << " ir " << ds->shield_rIn1()<<","<< ds->shield_rIn2() << " halfl " << ds->shield_halfLength() << " material " << ds->shield_material() << std::endl; +// std::cout << "DS ncoils " << ds->nCoils() << std::endl; +// for(size_t icoil = 0; icoil < static_cast(ds->nCoils()); icoil++){ +// std::cout << "DS coil ir " << ds->coil_rIn() << " or " << ds->coil_rOut()[icoil] << " length " << ds->coil_zLength()[icoil] << " zpos " << ds->coil_zPosition()[icoil] +// << " material " << ds->coil_materials()[icoil] << std::endl; +// } //DS Cryo or 1303,1328 ir 950,969.05 halfl 5450 zpos 8689 material StainlessSteel //DS shield or 1237.3,1250 ir 1010,1022.7 halfl 5287.7 material G4_Al //DS ncoils 11 diff --git a/KinKalGeom/fcl/prolog.fcl b/KinKalGeom/fcl/prolog.fcl new file mode 100644 index 0000000000..ddf2db8258 --- /dev/null +++ b/KinKalGeom/fcl/prolog.fcl @@ -0,0 +1,18 @@ +BEGIN_PROLOG +KinKalGeom : { + KKMaterial : { + elements : "Offline/TrackerConditions/data/ElementsList.data" + isotopes : "Offline/TrackerConditions/data/IsotopesList.data" + materials : "Offline/TrackerConditions/data/MaterialsList.data" + strawGasMaterialName : "straw-gas" + strawWallMaterialName : "straw-wall" + strawWireMaterialName : "straw-wire" + IPAMaterialName : "HDPE" + STMaterialName : "Target" + IonizationEnergyLossMode : 1 # Moyal mean + SolidScatteringFraction : 0.999999 + GasScatteringFraction : 0.9999999 + ElectronBrehmsFraction : 0.04 + } +} +END_PROLOG diff --git a/KinKalGeom/inc/KKMaterial.hh b/KinKalGeom/inc/KKMaterial.hh index 13b83d62eb..ef8a221ea8 100644 --- a/KinKalGeom/inc/KKMaterial.hh +++ b/KinKalGeom/inc/KKMaterial.hh @@ -14,13 +14,12 @@ // mu2e #include "Offline/ConfigTools/inc/ConfigFileLookupPolicy.hh" #include "Offline/Mu2eInterfaces/inc/Detector.hh" -#include "Offline/Mu2eInterfaces/inc/ProditionsEntity.hh" #include #include namespace mu2e { - class KKMaterial : public MatEnv::FileFinderInterface, public Detector, public ProditionsEntity { + class KKMaterial : public MatEnv::FileFinderInterface, public Detector { public: using Name = fhicl::Name; using Comment = fhicl::Comment; @@ -29,7 +28,6 @@ namespace mu2e { fhicl::Atom isotopes { Name("isotopes"), Comment("Filename for istotopes information")}; fhicl::Atom elements { Name("elements"), Comment("Filename for elements information") }; fhicl::Atom materials { Name("materials"), Comment("Filename for materials information") }; - fhicl::Atom eloss { Name("ELossMode"), Comment("Energy Loss model (0=MPV, 1=Moyal"),MatEnv::DetMaterial::moyalmean }; fhicl::Atom strawGasMaterialName{ Name("strawGasMaterialName"), Comment("strawGasMaterialName") }; fhicl::Atom strawWallMaterialName{ Name("strawWallMaterialName"), Comment("strawWallMaterialName") }; fhicl::Atom strawWireMaterialName{ Name("strawWireMaterialName"), Comment("strawWireMaterialName") }; diff --git a/KinKalGeom/inc/KinKalGeom.hh b/KinKalGeom/inc/KinKalGeom.hh index 3d9a7e7dc2..87c04e790e 100644 --- a/KinKalGeom/inc/KinKalGeom.hh +++ b/KinKalGeom/inc/KinKalGeom.hh @@ -13,12 +13,11 @@ #include "Offline/DataProducts/inc/SurfaceId.hh" #include "KinKal/Geometry/Surface.hh" #include "Offline/Mu2eInterfaces/inc/Detector.hh" -#include "Offline/Mu2eInterfaces/inc/ProditionsEntity.hh" #include #include #include namespace mu2e { - class KinKalGeom : public Detector, public ProditionsEntity { + class KinKalGeom : public Detector { public: using SurfacePtr = std::shared_ptr; using SurfacePair =std::pair; @@ -26,7 +25,7 @@ namespace mu2e { using SurfacePairIter = std::multimap::const_iterator; using KKGMap = std::multimap; // default constructor, now using GeometryService to create content - KinKalGeom(); + KinKalGeom(){} // accessor to the raw map auto const& map() const { return map_; } // find all surfaces that match an Id. Return vector can have >1 entry if the wildcard index (-1) is provided diff --git a/KinKalGeom/src/KKMaterial.cc b/KinKalGeom/src/KKMaterial.cc index 8c390445d6..e80edefdb5 100644 --- a/KinKalGeom/src/KKMaterial.cc +++ b/KinKalGeom/src/KKMaterial.cc @@ -7,7 +7,7 @@ namespace mu2e { using MatDBInfo = MatEnv::MatDBInfo; using MatEnv::DetMaterial; - KKMaterial::KKMaterial(KKMaterial::Config const& matconfig) : ProditionsEntity("KKMaterial"), + KKMaterial::KKMaterial(KKMaterial::Config const& matconfig) : elementsBaseName_(matconfig.elements()), isotopesBaseName_(matconfig.isotopes()), materialsBaseName_(matconfig.materials()), diff --git a/KinKalGeom/src/KinKalGeom.cc b/KinKalGeom/src/KinKalGeom.cc index e6c21fd2cd..13bf8adcff 100644 --- a/KinKalGeom/src/KinKalGeom.cc +++ b/KinKalGeom/src/KinKalGeom.cc @@ -1,7 +1,6 @@ #include "Offline/KinKalGeom/inc/KinKalGeom.hh" #include "cetlib_except/exception.h" namespace mu2e { - KinKalGeom::KinKalGeom() : ProditionsEntity("KinKalGeom") {} void KinKalGeom::surfaces(SurfaceId const& id, SurfacePairCollection& surfs) const { // find all surfaces that match the input, including index wildcard diff --git a/Mu2eKinKal/fcl/prolog.fcl b/Mu2eKinKal/fcl/prolog.fcl index 808ff07c56..03fc9879a2 100644 --- a/Mu2eKinKal/fcl/prolog.fcl +++ b/Mu2eKinKal/fcl/prolog.fcl @@ -1,6 +1,7 @@ #include "Offline/TrkReco/fcl/Particle.fcl" BEGIN_PROLOG Mu2eKinKal : { + # # general configuration # KKFIT: { diff --git a/TrackerConditions/fcl/prolog.fcl b/TrackerConditions/fcl/prolog.fcl index edc76089bd..2fb1239208 100644 --- a/TrackerConditions/fcl/prolog.fcl +++ b/TrackerConditions/fcl/prolog.fcl @@ -1,18 +1,4 @@ BEGIN_PROLOG -Mu2eMaterial : { - verbose : 0 - # Location of dictionary files for the material model. - elements : "Offline/TrackerConditions/data/ElementsList.data" - isotopes : "Offline/TrackerConditions/data/IsotopesList.data" - materials : "Offline/TrackerConditions/data/MaterialsList.data" - strawGasMaterialName : "straw-gas" - strawWallMaterialName : "straw-wall" - strawWireMaterialName : "straw-wire" - dahlLynchScatteringFraction : 0.995 - intersectionTolerance : 0.001 - strawElementOffset : 0.25 - maximumIntersectionRadiusFraction : 0.96 -} Mu2eDetector : { verbose : 0 diff --git a/fcl/standardServices.fcl b/fcl/standardServices.fcl index 5f121f475e..bea908f6c4 100644 --- a/fcl/standardServices.fcl +++ b/fcl/standardServices.fcl @@ -5,6 +5,7 @@ #include "Offline/fcl/minimalMessageService.fcl" #include "Offline/DbService/fcl/prolog.fcl" #include "Offline/ProditionsService/fcl/prolog.fcl" +#include "Offline/KinKalGeom/fcl/prolog.fcl" BEGIN_PROLOG @@ -37,25 +38,12 @@ Services : { # define services for specific tasks: these are components needed for # a complete job Core : { - message : @local::default_message - GeometryService : { - inputFile : "Offline/Mu2eG4/geom/geom_common.txt" - bFieldFile : "Offline/Mu2eG4/geom/bfgeom_v01.txt" - simulatedDetector : { tool_type: "Mu2e" } - KinKalMaterial : { - elements : "Offline/TrackerConditions/data/ElementsList.data" - isotopes : "Offline/TrackerConditions/data/IsotopesList.data" - materials : "Offline/TrackerConditions/data/MaterialsList.data" - strawGasMaterialName : "straw-gas" - strawWallMaterialName : "straw-wall" - strawWireMaterialName : "straw-wire" - IPAMaterialName : "HDPE" - STMaterialName : "Target" - IonizationEnergyLossMode : 1 # Moyal mean - SolidScatteringFraction : 0.999999 - GasScatteringFraction : 0.9999999 - ElectronBrehmsFraction : 0.04 - } + message : @local::default_message + GeometryService : { + inputFile : "Offline/Mu2eG4/geom/geom_common.txt" + bFieldFile : "Offline/Mu2eG4/geom/bfgeom_v01.txt" + simulatedDetector : { tool_type: "Mu2e" } + KinKalMaterial : @local::KinKalGeom.KKMaterial } GlobalConstantsService : { inputFile : "Offline/GlobalConstantsService/data/globalConstants_01.txt" } DbService : @local::DbEmpty