return kTRUE;
}
+
//_____________________________________________________________________________
AliCDBId* AliCDBLocal::GetId(const AliCDBId& query) {
// look for filename matching query (called by GetEntryId)
// if querying for fRun and not specifying a version, look in the fValidFileIds list
- if(query.GetFirstRun() == fRun && !query.HasVersion()) {
+ if(!AliCDBManager::Instance()->GetCvmfsOcdbTag().IsNull() && query.GetFirstRun() == fRun && !query.HasVersion()) {
+ //if(query.GetFirstRun() == fRun && !query.HasVersion()) {
// get id from fValidFileIds
TIter iter(&fValidFileIds);
AliCDBId* result=0;
while((anIdPtr = dynamic_cast<AliCDBId*> (iter.Next()))){
- if(anIdPtr->GetPath() != query.GetPath()) continue;
- result = anIdPtr;
+ if(anIdPtr->GetPath() == query.GetPath()){
+ result = new AliCDBId(*anIdPtr);
+ break;
+ }
}
return result;
}
}
} else if (!query.HasSubVersion()) { // version specified but not subversion -> look for highest subVersion
-
result->SetVersion(query.GetVersion());
while ((filename = gSystem->GetDirEntry(dirPtr))) { // loop on files
TString aString(filename);
if (aString.BeginsWith('.')) continue;
- if (!FilenameToId(filename, aRunRange, aVersion, aSubVersion)) continue;
+ if (!FilenameToId(filename, aRunRange, aVersion, aSubVersion)){
+ AliDebug(5, Form("Could not make id from file: %s", filename));
+ continue;
+ }
// aRunRange, aVersion, aSubVersion filled from filename
if (!aRunRange.Comprises(query.GetAliCDBRunRange())) continue;
// aRunRange contains requested run!
- if(query.GetVersion() != aVersion || query.GetSubVersion() != aSubVersion) continue;
+ if(query.GetVersion() != aVersion || query.GetSubVersion() != aSubVersion){
+ continue;
+ }
// aVersion and aSubVersion are requested version and subVersion!
- if(result->GetVersion() == aVersion && result->GetSubVersion() == aSubVersion){
- AliError(Form("More than one object valid for run %d, version %d_%d!",
- query.GetFirstRun(), aVersion, aSubVersion));
- gSystem->FreeDirectory(dirPtr);
- delete result;
- return NULL;
- }
result->SetVersion(aVersion);
result->SetSubVersion(aSubVersion);
result->SetFirstRun(aRunRange.GetFirstRun());
result->SetLastRun(aRunRange.GetLastRun());
-
+ break;
}
}
AliCDBPath queryPath = queryId.GetAliCDBPath();
while((anIdPtr = dynamic_cast<AliCDBId*> (iter->Next()))){
AliCDBPath thisCDBPath = anIdPtr->GetAliCDBPath();
- if(!(queryPath.Comprises(thisCDBPath))) continue;
+ if(!(queryPath.Comprises(thisCDBPath))){
+ continue;
+ }
AliCDBId thisId(*anIdPtr);
dataId = GetId(thisId);
- if(dataId) selectedIds.Add(dataId);
+ if(dataId)
+ selectedIds.Add(dataId);
}
delete iter; iter=0;
const char* filename;
AliCDBRunRange aRunRange; // the runRange got from filename
+ AliCDBRunRange hvRunRange; // the runRange of the highest version valid file
Int_t aVersion, aSubVersion; // the version and subVersion got from filename
Int_t highestV=-1, highestSubV=-1; // the highest version and subVersion for this calibration type
}
AliCDBRunRange runrg(fRun, fRun);
- if (!aRunRange.Comprises(runrg)) continue;
+ if (!aRunRange.Comprises(runrg))
+ continue;
// check to keep the highest version/subversion (in case of more than one)
if (aVersion > highestV) {
highestV = aVersion;
highestSubV = aSubVersion;
+ hvRunRange = aRunRange;
} else {
if (aSubVersion > highestSubV) {
highestSubV = aSubVersion;
+ hvRunRange = aRunRange;
}
}
}
if(highestV >= 0){
AliCDBPath validPath(level0, level1, level2);
- AliCDBId validId(validPath, aRunRange, highestV, highestSubV);
- fValidFileIds.AddLast(validId.Clone());
+ AliCDBId *validId = new AliCDBId(validPath, hvRunRange, highestV, highestSubV);
+ fValidFileIds.AddLast(validId);
}
gSystem->FreeDirectory(dirPtr);
TString uri(GetURI());
uri.Remove(TString::kTrailing, '/');
TObjArray * osArr = uri.Tokenize('/');
- TObjString* mcdata_os = dynamic_cast<TObjString*>(osArr->At(osArr->GetEntries()-2));
+ TObjString* mcdata_os = dynamic_cast<TObjString*>(osArr->At(osArr->GetEntries()-3));
+ TObjString* yeartype_os = 0;
TString mcdata = mcdata_os->GetString();
- TObjString* yeartype_os = dynamic_cast<TObjString*>(osArr->At(osArr->GetEntries()-1));
+ if( mcdata == TString("data")) {
+ yeartype_os = dynamic_cast<TObjString*>(osArr->At(osArr->GetEntries()-2));
+ } else {
+ mcdata_os = dynamic_cast<TObjString*>(osArr->At(osArr->GetEntries()-2));
+ yeartype_os = dynamic_cast<TObjString*>(osArr->At(osArr->GetEntries()-1));
+ }
+ mcdata = mcdata_os->GetString();
TString yeartype = yeartype_os->GetString();
command += mcdata;
command += '/';
// We expect the file with valid paths for this run to be generated in the current directory
// and to be named as the CVMFS OCDB tag, without .gz, with '_runnumber' appended
// Fill fValidFileIds from file
- ifstream *file = new ifstream(runValidFile.Data());
- if (!*file) {
+ std::ifstream file (runValidFile.Data());
+ if (!file.is_open()) {
AliFatal(Form("Error opening file \"%s\"!", runValidFile.Data()));
- file->close();
- delete file;
}
TString filepath;
- while (filepath.ReadLine(*file)) {
+ while (filepath.ReadLine(file)) {
+ // skip line in case it is not a root file path
+ if(! filepath.EndsWith(".root")) {
+ continue;
+ }
//extract three-level path and basename
TObjArray *tokens = filepath.Tokenize('/');
+ if (tokens->GetEntries() < 5) {
+ AliError(Form("\"%s\" is not a valid cvmfs path for an OCDB object", filepath.Data()));
+ continue;
+ }
TObjString *baseNameOstr = (TObjString*) tokens->At(tokens->GetEntries()-1);
TString baseName(baseNameOstr->String());
TObjString *l0oStr = (TObjString*) tokens->At(tokens->GetEntries()-4);
AliCDBRunRange runrg(fRun,fRun);
if (!aRunRange.Comprises(runrg)) continue; // should never happen (would mean awk script wrong output)
// aRunRange contains requested run!
- AliCDBId validId(validPath,aRunRange,aVersion,aSubVersion);
- fValidFileIds.AddLast(validId.Clone());
+ AliCDBId *validId = new AliCDBId(validPath,aRunRange,aVersion,aSubVersion);
+ fValidFileIds.AddLast(validId);
}
- file->close();
- delete file;
+ file.close();
return;
}
-
-
/////////////////////////////////////////////////////////////////////////////////////////////////
// //
// AliCDBLocal factory //
return NULL;
}
-
//_____________________________________________________________________________
void AliCDBLocal::SetRetry(Int_t /* nretry */, Int_t /* initsec */) {