GENIEGenerator
Loading...
Searching...
No Matches
GeomVolSelectorBasic.cxx
Go to the documentation of this file.
1//____________________________________________________________________________
2/*
3 Copyright (c) 2003-2025, The GENIE Collaboration
4 For the full text of the license visit http://copyright.genie-mc.org
5
6 Robert Hatcher <rhatcher@fnal.gov>
7*/
8//____________________________________________________________________________
9
14
15using namespace genie;
16using namespace genie::geometry;
17
18#include <TGeoVolume.h>
19#include <TGeoMaterial.h>
20#include <TGeoMedium.h>
21
22//____________________________________________________________________________
28
29//___________________________________________________________________________
34
35//___________________________________________________________________________
49{
51 if ( fRequiredPath.size() > 0 || fForbiddenPath.size() > 0 ) {
52#ifdef PATHSEG_KEEP_PATH
54#else
55 LOG("GeomVolSelectorBasic", pFATAL)
56 << "PathSegment is not defined to hold fPathString -- selectors can not cut on it";
57#endif
58 }
59}
60
61//___________________________________________________________________________
62// nothing special needs to be done at the beginning or end of a new PathSegmentList
63void GeomVolSelectorBasic::BeginPSList(const PathSegmentList* /* untrimmed */ ) const
64{ ; }
65
68
69//___________________________________________________________________________
71{
72 bool reject = false;
73
74 // not splitting PathSegment into 2 or more PathSegment elements
75 // so either
76 // - keep "as is"
77 // - adjust the low/high endpoints
78 // - not copy to output list (
79 // be careful about steps outside all the geometry that might not
80 // have an associated volume/media/material
81
82
83 if ( ! reject ) {
84 std::string volname = ( ps.fVolume) ? ps.fVolume->GetName() : "no-volume";
85 reject = RejectString(volname,fRequiredVol,fForbiddenVol);
86 }
87
88 if ( ! reject ) {
89 std::string medname = ( ps.fMedium) ? ps.fMedium->GetName() : "no-medium";
90 reject = RejectString(medname,fRequiredMed,fForbiddenMed);
91 }
92
93 if ( ! reject ) {
94 std::string matname = ( ps.fMaterial) ? ps.fMaterial->GetName() : "no-material";
95 reject = RejectString(matname,fRequiredMat,fForbiddenMat);
96 }
97
98#ifdef PATHSEG_KEEP_PATH
99 if ( ! reject ) {
101 }
102#endif
103
104 if ( reject ) ps.fStepRangeSet.clear();
105
106}
107
108//___________________________________________________________________________
109void GeomVolSelectorBasic::ParseSelection(const string& strall,
110 vector<string>& required,
111 vector<string>& forbidden)
112{
113 required.clear();
114 forbidden.clear();
115 vector<string> pieces = genie::utils::str::Split(strall,":;,");
116 size_t n = pieces.size();
117 for ( size_t i = 0; i < n; ++i ) {
118 string& strone = pieces[i];
119 if ( strone == "" ) continue; // reject null strings
120 if ( strone.find("-") == 0 ) forbidden.push_back(strone.substr(1,std::string::npos));
121 else if ( strone.find("+") == 0 ) required.push_back(strone.substr(1,std::string::npos));
122 else required.push_back(strone);
123 }
124}
125//___________________________________________________________________________
127 const vector<string>& required,
128 const vector<string>& forbidden) const
129{
130 bool reject = false;
131
132 // must have at least one of the required elements (if there are any)
133 size_t nrequired = required.size();
134 if ( nrequired > 0 ) {
135 bool found = false;
136 for (size_t jr = 0; jr < nrequired; ++jr) {
137 if ( str.find(required[jr]) != std::string::npos ) {
138 found = true;
139 break; // found at least one case, so we're good
140 }
141 }
142 if ( ! found ) reject = true;
143 }
144
145 // can not have any of the forbidden elements
146 size_t nforbidden = forbidden.size();
147 if ( nforbidden > 0 ) {
148 for (size_t jf = 0; jf < nforbidden; ++jf) {
149 if ( str.find(forbidden[jf]) != std::string::npos ) {
150 reject = true;
151 break; // found at least one case, so we can reject
152 }
153 }
154 }
155
156 return reject;
157}
158//___________________________________________________________________________
#define pFATAL
Definition Messenger.h:56
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
Definition Messenger.h:96
void ParseSelection(const string &str, vector< string > &required, vector< string > &forbidden)
void BeginPSList(const PathSegmentList *untrimmed) const
bool RejectString(const string &str, const vector< string > &required, const vector< string > &forbidden) const
void TrimSegment(PathSegment &segment) const
Object to be filled with the neutrino path-segments representing geometry volume steps (generally bou...
const TGeoMaterial * fMaterial
ref only ptr to TGeoMaterial
StepRangeSet fStepRangeSet
collection of {steplo,stephi} pairs
std::string fPathString
full path names
const TGeoVolume * fVolume
ref only ptr to TGeoVolume
const TGeoMedium * fMedium
ref only ptr to TGeoMedium
GENIE geometry drivers.
vector< string > Split(string input, string delim)
THE MAIN GENIE PROJECT NAMESPACE
Definition AlgCmp.h:25