Skip to content

Commit

Permalink
Merge pull request #16860 from ghellwig/fix-misalignment-tool-phase-1…
Browse files Browse the repository at this point in the history
…_90X

[90X] Fix misalignment tool for phase-1 (and phase-2) configurations.
  • Loading branch information
davidlange6 committed Dec 6, 2016
2 parents db64131 + 245d4b5 commit a69fe89
Showing 1 changed file with 8 additions and 9 deletions.
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;

}

0 comments on commit a69fe89

Please sign in to comment.