Skip to content
Snippets Groups Projects
Commit 803ad821 authored by Stephen A. Wood's avatar Stephen A. Wood Committed by Stephen Wood
Browse files

Allow lists of run numbers and run ranges in THcParmList::Load

  When Load is called with a run number, then the input file is ignored
  until a line with a list of run numbers or run number ranges is found.
  For example:
     44,50-90,113
  If the run number matches one of these run numbers or ranges,
  parameter definitions after the match are loaded.  (Until the next
  list of run numbers and ranges.)
  Before this commit, only a single run number or a single range of
  run numbers was allowed.
parent 0319672e
No related branches found
No related tags found
No related merge requests found
...@@ -241,20 +241,30 @@ The ENGINE CTP support parameter "blocks" which were marked with ...@@ -241,20 +241,30 @@ The ENGINE CTP support parameter "blocks" which were marked with
// If RunNumber>0 and first line we encounter is not a run range, need to // If RunNumber>0 and first line we encounter is not a run range, need to
// print an error // print an error
if(RunNumber>0) { if(RunNumber>0) {
if(line.find_first_not_of("0123456789-")==string::npos) { // Interpret as runnum range if(line.find_first_not_of("0123456789-,")==string::npos) { // Interpret as runnum range
if( (pos=line.find_first_of("-")) != string::npos) { // Interpret line as a list of comma separated run numbers or ranges
Int_t RangeStart=atoi(line.substr(0,pos).c_str()); TString runnums(line.c_str());
Int_t RangeEnd=atoi(line.substr(pos+1,string::npos).c_str()); TObjArray *runnumarr = runnums.Tokenize(",");
if(RunNumber >= RangeStart && RunNumber <= RangeEnd) { Int_t nranges=runnumarr->GetLast()+1;
InRunRange = 1;
} else { InRunRange = 0;
InRunRange = 0; Int_t ind;
} for(Int_t i=0;i<nranges;i++) {
} else { // A single number. Run TString runstr = ((TObjString *)runnumarr->At(i))->GetString();
if(atoi(line.c_str()) == RunNumber) { if(runstr.IsDec()) { // A single run number
InRunRange = 1; if(RunNumber == runstr.Atoi()) {
} else { InRunRange = 1;
InRunRange = 0; break;
}
} else if ((ind=runstr.First('-'))>=0) { // A run range
TString start=runstr(0,ind);
TString end=runstr(ind+1,runstr.Length());
if(start.IsDec() && end.IsDec()) {
if((RunNumber >= start.Atoi()) && (RunNumber <= end.Atoi())) {
InRunRange = 1;
break;
}
}
} }
} }
continue; // Skip to next line continue; // Skip to next line
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment