Skip to content

Commit

Permalink
Fix misalignment tool for more advanced phase-1 (and phase-2) configu…
Browse files Browse the repository at this point in the history
…rations.
  • Loading branch information
gregor-mittag committed Dec 5, 2016
1 parent 40afe9b commit 245d4b5
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 245d4b5

Please sign in to comment.