Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[90X] Fix misalignment tool for phase-1 (and phase-2) configurations. #16860

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 8 additions & 9 deletions Alignment/CommonAlignment/src/MisalignmentScenarioBuilder.cc
Expand Up @@ -366,25 +366,24 @@ bool MisalignmentScenarioBuilder::possiblyPartOf(const std::string & /*sub*/, co
const std::string
MisalignmentScenarioBuilder::rootName_( const std::string& parameterSetName ) const
{
std::string result{parameterSetName}; // Initialise to full string

std::string result = parameterSetName; // Initialise to full string

// Check if string ends with 's'
const int lastChar = parameterSetName.length()-1;
const auto lastChar = parameterSetName.length()-1;
if ( parameterSetName[lastChar] == 's' ) {
result = parameterSetName.substr( 0, lastChar );
} else {
// Otherwise, look for numbers (assumes names have no numbers inside...)
for ( unsigned int ichar = 0; ichar<parameterSetName.length(); ichar++ ) {
if ( isdigit(parameterSetName[ichar]) ) {
result = parameterSetName.substr( 0, ichar );
break; // Stop at first digit
// Otherwise, look for numbers at the end
// (assumes that numbers at the end are not part of the name)
for (auto ichar = lastChar; ichar != 0; --ichar) {
if (!isdigit(parameterSetName[ichar])) {
result = parameterSetName.substr(0, ichar + 1);
break; // Stop at first non-digit
}
}
}

LogDebug("PrintParameters") << "Name was " << parameterSetName << ", root is " << result;

return result;

}