From fe913d8fed5d557febca6b4873ee9f9a0fb238a1 Mon Sep 17 00:00:00 2001 From: hristov Date: Wed, 13 Jul 2005 06:02:46 +0000 Subject: [PATCH] Renaming calibration classes (A.Colla) --- STEER/{AliRunDataFile.cxx => AliCDBDump.cxx} | 68 ++- STEER/AliCDBDump.h | 38 ++ STEER/{AliRunData.cxx => AliCDBEntry.cxx} | 35 +- STEER/{AliRunData.h => AliCDBEntry.h} | 28 +- STEER/AliCDBLocal.cxx | 513 ++++++++++++++++++ STEER/AliCDBLocal.h | 45 ++ STEER/{AliMetaData.cxx => AliCDBMetaData.cxx} | 101 ++-- STEER/AliCDBMetaData.h | 86 +++ ...tMetaData.cxx => AliCDBMetaDataSelect.cxx} | 93 +--- STEER/AliCDBMetaDataSelect.h | 30 + ...liRunDataStorage.cxx => AliCDBStorage.cxx} | 118 ++-- STEER/AliCDBStorage.h | 75 +++ STEER/AliMetaData.h | 72 --- STEER/AliObjectMetaData.h | 52 -- STEER/AliRunDataFile.h | 37 -- STEER/AliRunDataOrganizedFile.cxx | 366 ------------- STEER/AliRunDataOrganizedFile.h | 42 -- STEER/AliRunDataStorage.h | 64 --- STEER/AliRunLoader.cxx | 12 +- STEER/STEERLinkDef.h | 13 +- STEER/libSTEER.pkg | 6 +- macros/DBAccessTutorial.C | 63 ++- 22 files changed, 1036 insertions(+), 921 deletions(-) rename STEER/{AliRunDataFile.cxx => AliCDBDump.cxx} (76%) create mode 100644 STEER/AliCDBDump.h rename STEER/{AliRunData.cxx => AliCDBEntry.cxx} (77%) rename STEER/{AliRunData.h => AliCDBEntry.h} (53%) create mode 100644 STEER/AliCDBLocal.cxx create mode 100644 STEER/AliCDBLocal.h rename STEER/{AliMetaData.cxx => AliCDBMetaData.cxx} (74%) create mode 100644 STEER/AliCDBMetaData.h rename STEER/{AliObjectMetaData.cxx => AliCDBMetaDataSelect.cxx} (52%) create mode 100644 STEER/AliCDBMetaDataSelect.h rename STEER/{AliRunDataStorage.cxx => AliCDBStorage.cxx} (65%) create mode 100644 STEER/AliCDBStorage.h delete mode 100644 STEER/AliMetaData.h delete mode 100644 STEER/AliObjectMetaData.h delete mode 100644 STEER/AliRunDataFile.h delete mode 100644 STEER/AliRunDataOrganizedFile.cxx delete mode 100644 STEER/AliRunDataOrganizedFile.h delete mode 100644 STEER/AliRunDataStorage.h diff --git a/STEER/AliRunDataFile.cxx b/STEER/AliCDBDump.cxx similarity index 76% rename from STEER/AliRunDataFile.cxx rename to STEER/AliCDBDump.cxx index cfd906b6adb..ff0d675906c 100644 --- a/STEER/AliRunDataFile.cxx +++ b/STEER/AliCDBDump.cxx @@ -26,18 +26,17 @@ #include #include #include "AliLog.h" -#include "AliRunData.h" -#include "AliSelectionMetaData.h" -#include "AliObjectMetaData.h" -#include "AliRunDataFile.h" +#include "AliCDBEntry.h" +#include "AliCDBMetaData.h" +#include "AliCDBDump.h" -ClassImp(AliRunDataFile) +ClassImp(AliCDBDump) //_____________________________________________________________________________ -AliRunDataFile::AliRunDataFile(const char* fileName, Bool_t readOnly) : - AliRunDataStorage(), +AliCDBDump::AliCDBDump(const char* fileName, Bool_t readOnly) : + AliCDBStorage(), fFile(NULL) { // constructor @@ -56,7 +55,7 @@ AliRunDataFile::AliRunDataFile(const char* fileName, Bool_t readOnly) : } //_____________________________________________________________________________ -AliRunDataFile::~AliRunDataFile() +AliCDBDump::~AliCDBDump() { // destructor @@ -67,8 +66,8 @@ AliRunDataFile::~AliRunDataFile() } //_____________________________________________________________________________ -AliRunDataFile::AliRunDataFile(const AliRunDataFile& /*db*/) : - AliRunDataStorage(), +AliCDBDump::AliCDBDump(const AliCDBDump& /*db*/) : + AliCDBStorage(), fFile(NULL) { // copy constructor @@ -77,7 +76,7 @@ AliRunDataFile::AliRunDataFile(const AliRunDataFile& /*db*/) : } //_____________________________________________________________________________ -AliRunDataFile& AliRunDataFile::operator = (const AliRunDataFile& /*db*/) +AliCDBDump& AliCDBDump::operator = (const AliCDBDump& /*db*/) { // assignment operator @@ -87,7 +86,7 @@ AliRunDataFile& AliRunDataFile::operator = (const AliRunDataFile& /*db*/) //_____________________________________________________________________________ -AliRunData* AliRunDataFile::GetEntry(AliSelectionMetaData& selMetaData, Int_t runNumber) +AliCDBEntry* AliCDBDump::GetEntry(AliCDBMetaDataSelect& selMetaData, Int_t runNumber) { // get an object from the data base @@ -118,18 +117,18 @@ AliRunData* AliRunDataFile::GetEntry(AliSelectionMetaData& selMetaData, Int_t ru Int_t nCycles = key->GetCycle(); // find the closest entry - AliRunData* closestEntry = NULL; + AliCDBEntry* closestEntry = NULL; for (Int_t iCycle = nCycles; iCycle > 0; iCycle--) { key = dir->GetKey(name, iCycle); if (!key) continue; - AliRunData* entry = (AliRunData*) key->ReadObj(); + AliCDBEntry* entry = (AliCDBEntry*) key->ReadObj(); if (!entry) continue; - if (!entry->InheritsFrom(AliRunData::Class())) { - AliObjectMetaData objMetaData; - entry = new AliRunData(entry, objMetaData); + if (!entry->InheritsFrom(AliCDBEntry::Class())) { + AliCDBMetaData metaData; + entry = new AliCDBEntry(entry, metaData); } - if (!entry->GetObjectMetaData().IsValid(runNumber, &selMetaData) || + if (!entry->GetCDBMetaData().IsStrictlyValid(runNumber, &selMetaData) || (entry->Compare(closestEntry) <= 0)) { delete entry; continue; @@ -141,18 +140,20 @@ AliRunData* AliRunDataFile::GetEntry(AliSelectionMetaData& selMetaData, Int_t ru if(!closestEntry) AliError(Form("No valid entry found for: name %s, version %d, run %d!!!", selMetaData.GetName(),selMetaData.GetVersion(),runNumber)); if (!closestEntry) return NULL; - if(selMetaData.GetVersion() > -1 && (closestEntry->GetObjectMetaData()).GetVersion() != selMetaData.GetVersion()) - AliWarning(Form("Warning: selected version (%d) not found, got version %d instead", - selMetaData.GetVersion(),(closestEntry->GetObjectMetaData()).GetVersion())); + +// if(selMetaData.GetVersion() > -1 && (closestEntry->GetCDBMetaData()).GetVersion() != selMetaData.GetVersion()) +// AliWarning(Form("Warning: selected version (%d) not found, got version %d instead", +// selMetaData.GetVersion(),(closestEntry->GetCDBMetaData()).GetVersion())); + return closestEntry; } //_____________________________________________________________________________ -Bool_t AliRunDataFile::PutEntry(AliRunData* entry) +Bool_t AliCDBDump::PutEntry(AliCDBEntry* entry) { // puts an object into the database -// AliRunData entry is composed by the object and its MetaData +// AliCDBEntry entry is composed by the object and its MetaData // this method takes the metaData, reads the name, runRange and Version // creates the TDirectory structure into the file // looks for runs with same name, if exist increment version @@ -191,11 +192,11 @@ Bool_t AliRunDataFile::PutEntry(AliRunData* entry) for (Int_t iCycle = nCycles; iCycle > 0; iCycle--) { key = dir->GetKey(name, iCycle); if (!key) continue; - AliRunData* oldEntry = (AliRunData*) key->ReadObj(); + AliCDBEntry* oldEntry = (AliCDBEntry*) key->ReadObj(); if (!oldEntry) continue; - if (oldEntry->InheritsFrom(AliRunData::Class())) { - if (version <= oldEntry->GetObjectMetaData().GetVersion()) { - version = oldEntry->GetObjectMetaData().GetVersion()+1; + if (oldEntry->InheritsFrom(AliCDBEntry::Class())) { + if (version <= oldEntry->GetCDBMetaData().GetVersion()) { + version = oldEntry->GetCDBMetaData().GetVersion()+1; } } delete oldEntry; @@ -205,5 +206,18 @@ Bool_t AliRunDataFile::PutEntry(AliRunData* entry) Bool_t result = (entry->Write(name) != 0); if (saveDir) saveDir->cd(); else gROOT->cd(); + + if(result) { + AliInfo(Form("Run object %s",entry->GetName())); + AliInfo(Form("was successfully written into file %s",fFile->GetName())); + } + return result; } + +//_____________________________________________________________________________ +void AliCDBDump::TagForProduction + (const AliCDBMetaDataSelect& /* selMetaData */, UInt_t /* prodVers */){ + + AliError(Form("Not implemented in this case")); +} diff --git a/STEER/AliCDBDump.h b/STEER/AliCDBDump.h new file mode 100644 index 00000000000..a6dd471d4d1 --- /dev/null +++ b/STEER/AliCDBDump.h @@ -0,0 +1,38 @@ +#ifndef ALICDBDUMP_H +#define ALICDBDUMP_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +/// +/// access classes for a data base in a LOCAL file +/// + +#include "AliCDBStorage.h" +#include "AliCDBMetaDataSelect.h" + +class TFile; + + +class AliCDBDump: public AliCDBStorage { +public: + AliCDBDump(const char* fileName = "DB.root", Bool_t readOnly = kTRUE); + virtual ~AliCDBDump(); + void TagForProduction(const AliCDBMetaDataSelect& /* selMetaData */, UInt_t /* prodVers */); + +protected: + virtual AliCDBEntry* GetEntry(AliCDBMetaDataSelect& selMetaData, Int_t runNumber); + + virtual Bool_t PutEntry(AliCDBEntry* entry); + +private: + AliCDBDump(const AliCDBDump& db); + AliCDBDump& operator = (const AliCDBDump& db); + + TFile* fFile; //! the DB local file + + ClassDef(AliCDBDump, 0) // access classes for a data base in a LOCAL file +}; + +#endif diff --git a/STEER/AliRunData.cxx b/STEER/AliCDBEntry.cxx similarity index 77% rename from STEER/AliRunData.cxx rename to STEER/AliCDBEntry.cxx index c05fee0b524..b5fe1f8476c 100644 --- a/STEER/AliRunData.cxx +++ b/STEER/AliCDBEntry.cxx @@ -23,34 +23,33 @@ /////////////////////////////////////////////////////////////////////////////// -#include "AliRunData.h" -#include "AliObjectMetaData.h" +#include "AliCDBEntry.h" -ClassImp(AliRunData) +ClassImp(AliCDBEntry) //_____________________________________________________________________________ -AliRunData::AliRunData() : +AliCDBEntry::AliCDBEntry() : TObject(), fObject(NULL), - fObjMetaData() + fMetaData() { // default constructor } //_____________________________________________________________________________ -AliRunData::AliRunData(TObject* object, const AliObjectMetaData& objMetaData) : +AliCDBEntry::AliCDBEntry(const TObject* object, const AliCDBMetaData& metaData) : TObject(), - fObject(object), - fObjMetaData(objMetaData) + fObject(object->Clone()), + fMetaData(metaData) { // constructor } //_____________________________________________________________________________ -AliRunData::~AliRunData() +AliCDBEntry::~AliCDBEntry() { // destructor @@ -59,42 +58,42 @@ AliRunData::~AliRunData() //_____________________________________________________________________________ -AliRunData::AliRunData(const AliRunData& entry) : +AliCDBEntry::AliCDBEntry(const AliCDBEntry& entry) : TObject(entry), - fObjMetaData(entry.fObjMetaData) + fMetaData(entry.fMetaData) { // copy constructor } //_____________________________________________________________________________ -AliRunData& AliRunData::operator = (const AliRunData& entry) +AliCDBEntry& AliCDBEntry::operator = (const AliCDBEntry& entry) { // assignment operator delete fObject; fObject = entry.fObject->Clone(); - fObjMetaData = entry.fObjMetaData; + fMetaData = entry.fMetaData; return *this; } //_____________________________________________________________________________ -const char* AliRunData::GetName() const +const char* AliCDBEntry::GetName() const { // get the name - return fObjMetaData.GetName(); + return fMetaData.GetName(); } //_____________________________________________________________________________ -Int_t AliRunData::Compare(const TObject* object) const +Int_t AliCDBEntry::Compare(const TObject* object) const { // check whether this is preferred to object - if (!object || !object->InheritsFrom(AliRunData::Class())) return 1; - return fObjMetaData.Compare(&((AliRunData*)object)->GetObjectMetaData()); + if (!object || !object->InheritsFrom(AliCDBEntry::Class())) return 1; + return fMetaData.Compare(&((AliCDBEntry*)object)->GetCDBMetaData()); } diff --git a/STEER/AliRunData.h b/STEER/AliCDBEntry.h similarity index 53% rename from STEER/AliRunData.h rename to STEER/AliCDBEntry.h index b17e759994d..ba50cd4b84a 100644 --- a/STEER/AliRunData.h +++ b/STEER/AliCDBEntry.h @@ -1,5 +1,5 @@ -#ifndef ALIRUNDATA_H -#define ALIRUNDATA_H +#ifndef ALICDBENTRY_H +#define ALICDBENTRY_H /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * * See cxx source for full Copyright notice */ @@ -11,35 +11,35 @@ /// #include -#include "AliObjectMetaData.h" +#include "AliCDBMetaData.h" -class AliRunData: public TObject { +class AliCDBEntry: public TObject { public: - AliRunData(); - AliRunData(TObject* object, const AliObjectMetaData& objMetaData); - virtual ~AliRunData(); + AliCDBEntry(); + AliCDBEntry(const TObject* object, const AliCDBMetaData& metaData); + virtual ~AliCDBEntry(); - AliRunData(const AliRunData& entry); - AliRunData& operator = (const AliRunData& entry); + AliCDBEntry(const AliCDBEntry& entry); + AliCDBEntry& operator = (const AliCDBEntry& entry); void SetVersion(Int_t version = -1) - {fObjMetaData.SetVersion(version);} + {fMetaData.SetVersion(version);} void SetRunRange(Int_t firstRun = -1, Int_t lastRun=-1) - {fObjMetaData.SetRunRange(firstRun, lastRun);} + {fMetaData.SetRunRange(firstRun, lastRun);} virtual const char* GetName() const; const TObject* GetObject() const {return fObject;} - const AliObjectMetaData& GetObjectMetaData() const {return fObjMetaData;} + const AliCDBMetaData& GetCDBMetaData() const {return fMetaData;} virtual Int_t Compare(const TObject* object) const; private: TObject* fObject; // pointer to the data base entry obj. - AliObjectMetaData fObjMetaData; // object's meta data + AliCDBMetaData fMetaData; // object's meta data - ClassDef(AliRunData, 2) // container for a data base entry object + ClassDef(AliCDBEntry, 2) // container for a data base entry object }; #endif diff --git a/STEER/AliCDBLocal.cxx b/STEER/AliCDBLocal.cxx new file mode 100644 index 00000000000..736f91e66e1 --- /dev/null +++ b/STEER/AliCDBLocal.cxx @@ -0,0 +1,513 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ + +///////////////////////////////////////////////////////////////////////////////////////////////// +// // +// access class to a DB file inside an organized directory structure // +// file name = "DBFolder/detector/dbType/detSpecType/Run#firstRun-#lastRun _v#version.root" // +// // +///////////////////////////////////////////////////////////////////////////////////////////////// + + +#include +#include +#include +#include +#include +#include +#include + +#include "AliLog.h" +#include "AliCDBLocal.h" + + +ClassImp(AliCDBLocal) + +//_____________________________________________________________________________ +AliCDBLocal::AliCDBLocal(const char* DBFolder) : + AliCDBStorage(), + fDBFolder(DBFolder) +{ +// constructor + gSystem->ExpandPathName(fDBFolder); + void *dir=0; + if(!(dir=gSystem->OpenDirectory(fDBFolder))){ + AliFatal(Form("Path %s not a directory",fDBFolder.Data())); + } + gSystem->FreeDirectory(dir); + + while(fDBFolder.EndsWith("/")) fDBFolder.Remove(fDBFolder.Last('/')); + fDBFolder+="/"; +} + +//_____________________________________________________________________________ +AliCDBLocal::~AliCDBLocal() +{ + // destructor + +} + +//_____________________________________________________________________________ +AliCDBLocal::AliCDBLocal(const AliCDBLocal& /*db*/) : + AliCDBStorage(), + fDBFolder("") +{ + // copy constructor + + AliFatal("not implemented"); +} + +//_____________________________________________________________________________ +AliCDBLocal& AliCDBLocal::operator = (const AliCDBLocal& /*db*/) +{ +// assignment operator + + AliFatal("not implemented"); + return *this; +} + +//_____________________________________________________________________________ +AliCDBEntry* AliCDBLocal::GetEntry(AliCDBMetaDataSelect& selMetaData, Int_t runNumber) +{ +// get an object from the data base + + TDirectory* saveDir = gDirectory; + + // Find the right file in the directory + TString prefix="_v"; // development mode: fileName=Run#Run1-#Run2_v#Version.root + if(fStorageMode==kProduction) prefix="_Prod"; // production mode: fileName=Run#Run1-#Run2_Prod#Version.root + + TString buffer(fDBFolder); + TString name(selMetaData.GetName()); + buffer+=name; buffer+='/'; + + int selVersion = selMetaData.GetVersion(); + + void *dir = gSystem->OpenDirectory(buffer); + if(!dir) { + AliError(Form("Directory %s not found", name.Data())); + AliError(Form("in DB folder %s", fDBFolder.Data())); + return NULL; + } + + TString fileName=""; + TString levelContent=""; + int oldVers=-1; + // in this array the "numbers" of the retrieved fileName (Run1, Run2, Version) are stored for later usage + int fileNumbers[3]={-1,-1,-1}; + while(levelContent=gSystem->GetDirEntry(dir)){ + + if(levelContent=="." || levelContent=="..") continue; if(levelContent=="") break; + if(!levelContent.Contains("Run") || !levelContent.Contains(prefix)) continue; + + int numbers[3]={-1,-1,-1}; // numbers[0]=firstRun, numbers[1]=lastRun, numbers[2]=Version + // gets the 3 "numbers" in the file name + if(!DecodeFileName(levelContent,numbers, prefix)) continue; // wrong run filename format + if(numbers[0]>runNumber || numbers[1]= oldVers){ + if(numbers[2] == oldVers){ + // more than one file valid for the run -> error! + AliError(Form("More than one object valid for run %d, version %d!", runNumber, oldVers)); + AliError(Form("No object will be returned!")); + gSystem->FreeDirectory(dir); + return NULL; + } + fileName=levelContent; + oldVers=numbers[2]; + fileNumbers[0]=numbers[0]; fileNumbers[1]=numbers[1]; fileNumbers[2]=numbers[2]; + } + } else { + if(numbers[2] == selVersion){ + if(fileName != ""){ + // filename was already assigned, this means there is more than one file valid for the run -> error! + AliError(Form("More than one object valid for run %d, version %d!", runNumber, selVersion)); + AliError(Form("No object will be returned!")); + gSystem->FreeDirectory(dir); + return NULL; + } + fileName=levelContent; + fileNumbers[0]=numbers[0]; fileNumbers[1]=numbers[1]; fileNumbers[2]=numbers[2]; + } + } + + } // end loop on runs + + gSystem->FreeDirectory(dir); + buffer+=fileName; + if(!buffer.EndsWith(".root")){ + AliError(Form("No DB file matching criteria found!")); + return NULL; + } + + TFile *DBFile = new TFile(buffer.Data(),"READ"); + if(!DBFile || !DBFile->IsOpen()) { + AliError(Form("could not open file %s", buffer.Data())); + return NULL; + } + + AliInfo(Form("File %s succesfully opened", buffer.Data())); + +// get the only AliCDBEntry object from the file +// I assume that the object in the file is a AliCDBEntry entry with +// name="detSpecType" (set in CDBMetaDataSelect) + + DBFile->cd(); + + AliCDBEntry *entry = (AliCDBEntry*) DBFile->Get(selMetaData.GetDetSpecType()); + + if(!entry || !entry->InheritsFrom(AliCDBEntry::Class())) { + AliError(Form("No entry named %s found!",selMetaData.GetDetSpecType())); + DBFile->Close(); delete DBFile; DBFile=0; + if (saveDir) saveDir->cd(); else gROOT->cd(); + return NULL; + } + +// Version 1: +// set the run range and version got from the filename +// to the object's metadata! + +// entry->SetRunRange(fileNumbers[0],fileNumbers[1]); +// entry->SetVersion(fileNumbers[2]); + +// Version 2: The object's metadata are not reset during storage +// If object's metadata runRange or version do not match with filename, +// it means that someone renamed file by hand. In this case a warning msg is issued. + Int_t objFirstRun=(entry->GetCDBMetaData()).GetFirstRun(); + Int_t objLastRun=(entry->GetCDBMetaData()).GetLastRun(); + Int_t objVersion=(entry->GetCDBMetaData()).GetVersion(); + + if(objFirstRun != fileNumbers[0] || objLastRun != fileNumbers[1] || objVersion != fileNumbers[2]){ + AliWarning(Form("Either RunRange or Version in the object's metadata do noth match with fileName numbers:")); + AliWarning(Form("someone renamed file by hand!")); + } + +// close file, return retieved entry + + DBFile->Close(); delete DBFile; DBFile=0; + if (saveDir) saveDir->cd(); else gROOT->cd(); + +// if(selMetaData.GetVersion() > -1 && fileNumbers[2] != selMetaData.GetVersion()) +// AliWarning(Form("Warning: selected version (%d) not found, got version %d instead", +// selMetaData.GetVersion(),fileNumbers[2])); + + return entry; + +} + + +//_____________________________________________________________________________ +Bool_t AliCDBLocal::PutEntry(AliCDBEntry* entry) +{ +// puts an object into the database + +// AliCDBEntry entry is composed by the object and its MetaData +// this method takes the metaData, reads the name, runRange and Version +// creates the directory structure and the file name +// looks for runs with same or overlapping runrange, if exist increment version +// (therefore version should not be put in the metadata) +// if the runrange is different (but overlapping) from a preceding version, a warning message +// is issued. +// sets the runrange and version in the object metadata = -1 (to avoid inconsistencies) +// open the filem, write the entry in the file. +// Note: the key name of the entry is "detSpecType" +// return result + + if(!entry) return kFALSE; + TDirectory* saveDir = gDirectory; + + Int_t firstRun=entry->GetCDBMetaData().GetFirstRun(); + Int_t lastRun=entry->GetCDBMetaData().GetLastRun(); + if(firstRun<0 || lastRun<0 || lastRunGetName()); + + + TString detSpecType(name(name.Last('/')+1, name.Length()-name.Last('/'))); + TString buffer(fDBFolder); + + void *dir=0; + Int_t index = -1; + name+='/'; // name=detector/dbType/detSpecType/ + + while ((index = name.Index("/")) >= 0) { + TString dirName(name(0, index+1)); + buffer+=dirName; + dir=gSystem->OpenDirectory(buffer); + if (!dir) { + AliWarning(Form("Directory %s does not exist! It will be created...",buffer.Data())); + gSystem->mkdir(buffer.Data()); + } + name.Remove(0, index+1); + gSystem->FreeDirectory(dir); + } + + dir = gSystem->OpenDirectory(buffer); + TString levelContent=""; + Int_t maxVersion=-1, run1=-1, run2=-1; + int numbers[3]={-1,-1,-1}; // numbers[0]=firstRun, numbers[1]=lastRun, numbers[2]=Version + while(levelContent=gSystem->GetDirEntry(dir)){ + if(levelContent=="." || levelContent=="..") continue; if(levelContent=="") break; + if(levelContent.Contains("Run")){ + if(levelContent.Contains("_Prod")) continue; //skip "Production" links + if(!DecodeFileName(levelContent, numbers, "_v")) continue; + if((firstRun>=numbers[0] && firstRun<=numbers[1]) || + (lastRun>=numbers[0] && lastRun<=numbers[1]) || + (firstRun<=numbers[0] && lastRun>=numbers[1])) {// overlap! + if(numbers[2]>maxVersion) { + maxVersion=numbers[2]; + run1=numbers[0]; run2=numbers[1]; + } + } + } + } + gSystem->FreeDirectory(dir); + + if((run1!=-1 && run2!=-1) && (firstRun!=run1 || lastRun!=run2)) + AliWarning(Form("Run range modified w.r.t. preceding version (%d, %d)",run1, run2)); + + TString strfName=EncodeFileName(firstRun, lastRun, maxVersion+1); + buffer+=strfName; + + // opening file + TFile *DBFile = new TFile(buffer.Data(),"NEW"); + if(!DBFile || !DBFile->IsWritable()){ + AliError(Form("The data base file is not writable. " + "The object %s was not inserted", entry->GetName())); + if(!DBFile->IsWritable()) DBFile->Close(); DBFile->Delete(); delete DBFile; DBFile=0; + return kFALSE; + } + + DBFile->cd(); + + entry->SetVersion(maxVersion+1); + + // write object + Bool_t result = (entry->Write(detSpecType) != 0); + if (saveDir) saveDir->cd(); else gROOT->cd(); + DBFile->Close(); DBFile->Delete(); delete DBFile; DBFile=0; + if(result) { + AliInfo(Form("Run object %s",entry->GetName())); + AliInfo(Form("was successfully written into file %s",buffer.Data())); + } + + return result; + +} + +/*****************************************************************************/ +TObjArray* AliCDBLocal::FindDBFiles(const char* name, Int_t runNumber){ +// Find DataBase file name in a local directory. The filename must be in the form: Run#run1-#run2_v#version.root +// TRegexp allowed: name can be for example: "detector/*" !! + + TObjArray *FileNameColl=new TObjArray(); + + TString prefix="_v"; // development mode: fileName=Run#Run1-#Run2_v#Version.root + if(fStorageMode==kProduction) prefix="_Prod"; // production mode: fileName=Run#Run1-#Run2_Prod#Version.root + + TString buffer(fDBFolder); +// gSystem->ExpandPathName(buffer); + + TString bufftInit=buffer; // buffInit="$ALICE_ROOT/DB/ + TString levelContent=""; + + AliCDBMetaDataSelect selMetaData(name); + + TString detector(selMetaData.GetDetector()); + TString dbType(selMetaData.GetDBType()); + TString detSpecType(selMetaData.GetDetSpecType()); + int selVersion = selMetaData.GetVersion(); + + void *dirLevInit = gSystem->OpenDirectory(buffer); + while(levelContent=gSystem->GetDirEntry(dirLevInit)){ // lev0! In detector directory (ZDC, TPC...)!! + + if(levelContent=="." || levelContent=="..") continue; if(levelContent=="") break; + if(!(detector=="*") && !levelContent.Contains(TRegexp(detector)) ) continue; + + buffer=bufftInit+levelContent; buffer+='/'; // buffer="$ALICE_ROOT/DB/detector/ + TString bufft0=buffer; // bufft0="$ALICE_ROOT/DB/detector/ + + void *dirLev0 = gSystem->OpenDirectory(buffer); + while(levelContent=gSystem->GetDirEntry(dirLev0)){ // lev1! dbType directory (Calib, Align)!! + + if(levelContent=="." || levelContent=="..") continue; if(levelContent=="") break; + if(!(dbType=="*") && !levelContent.Contains(TRegexp(dbType))) continue; + + buffer=bufft0+levelContent;buffer+='/'; // buffer="$ALICE_ROOT/DB/detector/dbType/ + TString bufft1=buffer; // bufft1="$ALICE_ROOT/DB/detector/dbType/ + + void *dirLev1 = gSystem->OpenDirectory(buffer); + while(levelContent=gSystem->GetDirEntry(dirLev1)){ // lev2! detSpecType directory (Pedestals, gain....)!! + + if(levelContent=="." || levelContent=="..") continue; if(levelContent=="") break; + if(!(detSpecType=="*") && !levelContent.Contains(TRegexp(detSpecType))) continue; + + buffer=bufft1+levelContent;buffer+='/'; // buffer="$ALICE_ROOT/DB/detector/dbType/detSpecType/ + TString bufft2=buffer; // bufft2="$ALICE_ROOT/DB/detector/dbType/detSpecType/ + + void *dirLev2 = gSystem->OpenDirectory(buffer); + TObjString *str=0; + while(levelContent=gSystem->GetDirEntry(dirLev2)){ // lev3! Run directory (Run#XXX-#YYY_v#ZZ.root)!! + + if(levelContent=="." || levelContent=="..") continue; if(levelContent=="") break; + if(!levelContent.BeginsWith("Run")) continue; + if(!levelContent.Contains(prefix)) continue; + + int numbers[3]={-1,-1,-1}; // numbers[0]=firstRun, numbers[1]=lastRun, numbers[2]=Version + if(!DecodeFileName(levelContent,numbers, prefix)) continue; // wrong run filename format! + if(numbers[0]>runNumber || numbers[1]Add(str); + break; + } + if(selVersion == -1) { // if version is not specified, collect all versions + buffer=bufft2+levelContent; + str=new TObjString(buffer.Data()); + FileNameColl->Add(str); + } + } // end loop on runs + } // end loop in lev1 + } // end loop in lev0 + } // end loop in levInit + + AliInfo(Form("Found %d entries matching requirements", FileNameColl->GetEntriesFast())); + ToAliInfo(FileNameColl->ls()); + return FileNameColl; +} + +//_____________________________________________________________________________ +void AliCDBLocal::TagForProduction(const AliCDBMetaDataSelect& selMetaData, UInt_t prodVers){ + +TString workingDir=gSystem->pwd(); +//Build the file path +TString buffer(fDBFolder); //gSystem->ExpandPathName() already done in ctor +TString fName=""; + +buffer+=selMetaData.GetName(); buffer+='/'; +//gSystem->ExpandPathName(dirName); + +if(!gSystem->cd(buffer)) + {AliError(Form("Directory %s does not exist... check name!", buffer.Data())); gSystem->cd(workingDir.Data()); return;} + +// if version is not specified (=-1), then tag the highest version (BE CAREFUL!!) +if(selMetaData.GetVersion() != -1){ + //Build the filename + fName = EncodeFileName(selMetaData.GetFirstRun(), selMetaData.GetLastRun(), selMetaData.GetVersion()); +} else { + //look in directory for valid DB files, seek highest version + void *dir = gSystem->OpenDirectory(buffer); + TString levelContent=""; + int oldVers=-1; + while(levelContent=gSystem->GetDirEntry(dir)){ + + if(levelContent=="." || levelContent=="..") continue; if(levelContent=="") break; + if(!levelContent.Contains("Run") || !levelContent.Contains("_v")) continue; + + int numbers[3]={-1,-1,-1}; // numbers[0]=firstRun, numbers[1]=lastRun, numbers[2]=Version + // gets the 3 "numbers" in the file name + if(!DecodeFileName(levelContent,numbers, "_v")) continue; // wrong run filename format! + if(numbers[0] != selMetaData.GetFirstRun() || numbers[1] != selMetaData.GetLastRun()) continue; + if(numbers[2] >= oldVers) { + fName=levelContent; + oldVers=numbers[2]; + } + } // end loop on runs +} + + //check that the flename exists +if(!gSystem->IsFileInIncludePath(fName.Data())){ + AliError(Form("File name %s not found... check!", fName.Data())); + gSystem->cd(workingDir.Data()); + return; +} + +// file exists: make symbolic link! +TString prodfName=EncodeFileName(selMetaData.GetFirstRun(), selMetaData.GetLastRun(), prodVers, "_Prod"); +if(gSystem->Symlink(fName.Data(),prodfName.Data())<0){ + AliError(Form("Link name already existing (%s): linkage failed!",prodfName.Data())); +} else { + AliError(Form("File %s tagged for production with symlink %s",fName.Data(), prodfName.Data())); +} + +gSystem->cd(workingDir); +return; + +} + +//_____________________________________________________________________________ +Bool_t AliCDBLocal::DecodeFileName(const TString strName, int *numArray, TString prefix) +{ +// Gets the numbers (#Run1, #Run2, #Version) +// from the filename: Run#Run1-#Run2_v#Version.root or Run#Run1-#Run2_Prod#prodVers.root + + int indexMinus=strName.Last('-'); + int indexUScore=strName.Last('_'); + int indexPoint=strName.Last('.'); + + int nSkipChar=prefix.Length(); // prefix can be either "_v" or "_Prod" depending on fStorageMode + //if(prefix=="_v") {nSkipChar=2;} // development mode: _v# skip 2 characters + //else if(prefix=="_Prod") {nSkipChar=5;} // production mode: _Prod# skip 5 characters + + if(indexUScore<0 || indexPoint<0 ) + {AliDebug(2, Form("Check sintax %s",strName.Data())); return kFALSE;} + + if(indexMinus<0){ // only 1 Run number! + TString cRun=strName(3,indexUScore-3); + if(!(cRun.IsDigit())) + {AliDebug(2, Form("%s not a digit! Check sintax %s",cRun.Data(),strName.Data())); return kFALSE;} + numArray[0] = (int) strtol(cRun.Data(),0,10); + numArray[1] = numArray[0]; + }else{ + TString cFirstRun = strName(3,indexMinus-3); + TString cLastRun = strName(indexMinus+1,indexUScore-(indexMinus+1)); + if(!(cFirstRun.IsDigit()) || !(cLastRun.IsDigit())) + {AliDebug(2, Form("%s or %s are not digit! Check sintax %s", + cFirstRun.Data(), cLastRun.Data(), strName.Data())); return kFALSE;} + numArray[0] = (int) strtol(cFirstRun.Data(),0,10); + numArray[1] = (int) strtol(cLastRun.Data(),0,10); + } +// TString cVersion = strName(indexUScore+2,indexPoint-(indexUScore+2)); + TString cVersion = strName(indexUScore+nSkipChar,indexPoint-(indexUScore+nSkipChar)); + if(!(cVersion.IsDigit())){ + AliDebug(2, Form("%s not a digit! Check sintax %s",cVersion.Data(),strName.Data())); return kFALSE;} + numArray[2] = (int) strtol(cVersion.Data(),0,10); + + return kTRUE; +} + + +//_____________________________________________________________________________ +TString AliCDBLocal::EncodeFileName(int firstRun, int lastRun, int version, TString prefix){ +// Builds a file name of the form: Run#firstRun-#lastRun_v#Version.root + +TString fName="Run"; +if(firstRun==lastRun) { + fName+=firstRun; +}else{ + fName+=firstRun; fName+="-"; fName+=lastRun; +} +fName+=prefix; fName+=version; fName+=".root"; + +return fName; +} diff --git a/STEER/AliCDBLocal.h b/STEER/AliCDBLocal.h new file mode 100644 index 00000000000..26519f68c2f --- /dev/null +++ b/STEER/AliCDBLocal.h @@ -0,0 +1,45 @@ +#ifndef ALICDBLOCAL_H +#define ALICDBLOCAL_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +/// +/// access class to a DB file inside an organized directory structure +/// file name = "DBFolder/detector/dbType/detSpecType/Run#firstRun-#lastRun _v#version.root" +/// + +#include "AliCDBStorage.h" +#include "AliCDBMetaDataSelect.h" +#include "AliCDBMetaData.h" +#include "AliCDBEntry.h" + +class AliCDBLocal: public AliCDBStorage { + +public: +// AliCDBLocal(); + AliCDBLocal(const char* DBFolder = "$(ALICE_ROOT)/DB"); + virtual ~AliCDBLocal(); + + TObjArray* FindDBFiles(const char *name, Int_t runNumber); // return list of files valid for run number + void TagForProduction(const AliCDBMetaDataSelect& selMetaData, UInt_t prodVers); // tag a DB file for production mode + +protected: + virtual AliCDBEntry* GetEntry(AliCDBMetaDataSelect& selMetaData, Int_t runNumber); + virtual Bool_t PutEntry(AliCDBEntry* entry); + +private: + AliCDBLocal(const AliCDBLocal& db); + AliCDBLocal& operator = (const AliCDBLocal& db); + + Bool_t DecodeFileName(const TString strName, int *numArray, TString prefix="_v"); // Gets firstRun, lastRun, version from file name "strName" + TString EncodeFileName(int firstRun, int lastRun, int version, TString prefix="_v"); // returns file name from firstRun, lastRun, version + + TString fDBFolder; // the DB folder + +ClassDef(AliCDBLocal, 0) // access class to a DB file in an organized directory structure (DBFolder/detector/dbType/detSpecType) +}; + +#endif diff --git a/STEER/AliMetaData.cxx b/STEER/AliCDBMetaData.cxx similarity index 74% rename from STEER/AliMetaData.cxx rename to STEER/AliCDBMetaData.cxx index 06d1609f960..998db568f89 100644 --- a/STEER/AliMetaData.cxx +++ b/STEER/AliCDBMetaData.cxx @@ -17,28 +17,34 @@ /////////////////////////////////////////////////////////////////////////////// // // -// base class of the metadata of run dependent objects // -// Derived classes: AliObjectMetaData, AliSelectionMetaData // +// Object meta data: full description of a run dependent database object // // // /////////////////////////////////////////////////////////////////////////////// #include +#include +#include +#include -#include "AliMetaData.h" +#include "AliCDBMetaData.h" #include "AliLog.h" -ClassImp(AliMetaData) +ClassImp(AliCDBMetaData) //_____________________________________________________________________________ -AliMetaData::AliMetaData() : +AliCDBMetaData::AliCDBMetaData() : TObject(), fName(""), fFirstRun(-1), fLastRun(-1), - fVersion(-1) + fVersion(-1), + fPeriod(-1), + fFormat(""), + fResponsible("Duck, Donald"), + fExtraInfo("") { // default constructor // the default values mean no selection @@ -46,80 +52,58 @@ AliMetaData::AliMetaData() : } //_____________________________________________________________________________ -AliMetaData::AliMetaData(const char* name, Int_t firstRun, Int_t lastRun, - Int_t version) : +AliCDBMetaData::AliCDBMetaData + (const char* name, Int_t firstRun, Int_t lastRun, Int_t period, + const char* objFormat, const char* responsible, + const char* extraInfo): TObject(), fName(name), fFirstRun(firstRun), fLastRun(lastRun), - fVersion(version) + fVersion(-1), + fPeriod(period), + fFormat(objFormat), + fResponsible(responsible), + fExtraInfo(extraInfo) { // constructor DecodeName(); } - //_____________________________________________________________________________ -AliMetaData::AliMetaData(const AliMetaData& entry) : +AliCDBMetaData::AliCDBMetaData(const AliCDBMetaData& entry) : TObject(entry), fName(entry.fName), fFirstRun(entry.fFirstRun), fLastRun(entry.fLastRun), - fVersion(entry.fVersion) + fVersion(entry.fVersion), + fPeriod(entry.fPeriod), + fFormat(entry.fFormat), + fResponsible(entry.fResponsible), + fExtraInfo(entry.fExtraInfo) { // copy constructor DecodeName(); } //_____________________________________________________________________________ -AliMetaData& AliMetaData::operator = (const AliMetaData& entry) +AliCDBMetaData& AliCDBMetaData::operator = (const AliCDBMetaData& entry) { // assignment operator - fName = entry.fName; fFirstRun = entry.fFirstRun; fLastRun = entry.fLastRun; fVersion = entry.fVersion; + fPeriod=entry.fPeriod; + fFormat=entry.fFormat; + fResponsible=entry.fResponsible; + fExtraInfo=entry.fExtraInfo; DecodeName(); return *this; } - - //_____________________________________________________________________________ -const char* AliMetaData::GetName() const -{ -// get the name ("Detector/DBType/DetSpecType", example: "ZDC/Calib/Pedestals") - - return fName.Data(); -} - -//_____________________________________________________________________________ -const char* AliMetaData::GetDetector() const -{ -// get the detector's name (ZDC,ITS ...) - - return fDetector.Data(); -} - -//_____________________________________________________________________________ -const char* AliMetaData::GetDBType() const -{ -// get the database type (Calib, Align ...) - - return fDBType.Data(); -} - -//_____________________________________________________________________________ -const char* AliMetaData::GetDetSpecType() const -{ -// get the detector's specific type name (Pedestals, GainConst, DeadChannelMaps...) - - return fDetSpecType.Data(); -} - -//_____________________________________________________________________________ -void AliMetaData::EncodeName(){ +void AliCDBMetaData::EncodeName(){ // Encode name from single elements ("Detector", "DBType", "DetSpecType" -> "Detector/DBType/DetSpecType") fName = fDetector+'/'+fDBType+'/'+fDetSpecType; if(fDBType == "*" && fDetSpecType == "*") fName = fDetector+'/'+'*'; @@ -128,7 +112,7 @@ void AliMetaData::EncodeName(){ } //_____________________________________________________________________________ -void AliMetaData::DecodeName(){ +void AliCDBMetaData::DecodeName(){ // Decode name into single elements ("Detector/DBType/DetSpecType" -> "Detector", "DBType", "DetSpecType") if(fName==""){fDetector=""; fDBType=""; fDetSpecType=""; return;} @@ -161,7 +145,7 @@ void AliMetaData::DecodeName(){ } //_____________________________________________________________________________ -Bool_t AliMetaData::IsStrictlyValid(Int_t runNumber, AliMetaData* metaData) const +Bool_t AliCDBMetaData::IsStrictlyValid(Int_t runNumber, AliCDBMetaData* metaData) const { // check if the object is valid for runNumber. TRUE if metaData version is equal to this's version @@ -175,7 +159,7 @@ Bool_t AliMetaData::IsStrictlyValid(Int_t runNumber, AliMetaData* metaData) cons } //_____________________________________________________________________________ -Bool_t AliMetaData::IsValid(Int_t runNumber, AliMetaData* metaData) const +Bool_t AliCDBMetaData::IsValid(Int_t runNumber, AliCDBMetaData* metaData) const { // check if the object is valid for runNumber. TRUE if metaData version less or equal wrt to this's @@ -189,18 +173,18 @@ Bool_t AliMetaData::IsValid(Int_t runNumber, AliMetaData* metaData) const } //_____________________________________________________________________________ -Int_t AliMetaData::Compare(const TObject* object) const +Int_t AliCDBMetaData::Compare(const TObject* object) const { // check whether this is preferred to object - if (!object || !object->InheritsFrom(AliMetaData::Class())) return 1; - if (fVersion < ((AliMetaData*)object)->GetVersion()) return -1; - if (fVersion > ((AliMetaData*)object)->GetVersion()) return 1; + if (!object || !object->InheritsFrom(AliCDBMetaData::Class())) return 1; + if (fVersion < ((AliCDBMetaData*)object)->GetVersion()) return -1; + if (fVersion > ((AliCDBMetaData*)object)->GetVersion()) return 1; return 0; } //_____________________________________________________________________________ -Bool_t AliMetaData::Matches(const char* name, Int_t runNumber) const +Bool_t AliCDBMetaData::Matches(const char* name, Int_t runNumber) const { // check whether name and run number match with this meta data @@ -212,7 +196,7 @@ Bool_t AliMetaData::Matches(const char* name, Int_t runNumber) const //_____________________________________________________________________________ -Bool_t operator == (const AliMetaData& entry1, const AliMetaData& entry2) +Bool_t operator == (const AliCDBMetaData& entry1, const AliCDBMetaData& entry2) { // compare two DB entries @@ -223,3 +207,4 @@ Bool_t operator == (const AliMetaData& entry1, const AliMetaData& entry2) return kTRUE; } + diff --git a/STEER/AliCDBMetaData.h b/STEER/AliCDBMetaData.h new file mode 100644 index 00000000000..caf2e2486c3 --- /dev/null +++ b/STEER/AliCDBMetaData.h @@ -0,0 +1,86 @@ +#ifndef ALICDBMETADATA_H +#define ALICDBMETADATA_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +/// +/// CDB meta data: it fully describes a run dependent database object. +/// It is attached to the object to build an AliCDBEntry object +/// +/// + +#include +#include + +class AliCDBMetaData: public TObject { +public: + AliCDBMetaData(); // default constructor + AliCDBMetaData + (const char* name, Int_t firstRun = -1, Int_t lastRun = -1, Int_t period=-1, + const char* objFormat="", const char* responsible="Duck, Donald", + const char* extraInfo=""); // constructor + + virtual ~AliCDBMetaData() {}; // destructor + + AliCDBMetaData(const AliCDBMetaData& entry); // copy contructor + AliCDBMetaData& operator = (const AliCDBMetaData& entry); // assignment operator + + + void SetName(const char* name) {fName = name; DecodeName();} // object's name ("Detector/DBType/DetSpecType") + void SetDetector(const char* Detector) {fDetector = Detector; EncodeName();} // set the detector's name (ZDC,ITS ...) + void SetDBType(const char* DBType) {fDBType = DBType; EncodeName();} // set the database type (Calib, Align ...) + void SetDetSpecType(const char* DetSpecType) {fDetSpecType = DetSpecType; EncodeName();} // set the detector's specific type name (Pedestals, GainConst, DeadChannelMaps...) + void SetRunRange(Int_t firstRun = -1, Int_t lastRun = 1) + {fFirstRun = firstRun; fLastRun = lastRun;} // set the run validity range + void SetVersion(Int_t version = -1) {fVersion = version;} // object's version (automatically set during storage!) + void SetPeriod(Int_t period) {fPeriod = period;} // set number of beam period + void SetFormat(const char* objFormat) {fFormat = objFormat;} // set infos about object's format (array o floats, histos...) + void SetResponsible(const char* responsible) {fResponsible = responsible;} // who made the object? + void SetExtraInfo(const char* extraInfo) {fExtraInfo = extraInfo;} // something else you would like to know + + + const char* GetName() const {return fName.Data();} // get the name + const char* GetDetector() const {return fDetector.Data();} // get the detector's name + const char* GetDBType() const {return fDBType.Data();} // get the database type + const char* GetDetSpecType() const {return fDetSpecType.Data();} // get the detector's specific type name + + const Int_t GetFirstRun() const {return fFirstRun;} // get the first valid run + const Int_t GetLastRun() const {return fLastRun;} // get the last valid run + const Int_t GetVersion() const {return fVersion;} // get the version + const Int_t GetPeriod() const {return fPeriod;} // get the beam period + const char* GetFormat() const {return fFormat.Data();} // get the object's format + const char* GetResponsible() const {return fResponsible.Data();} // get the responsible's name + const char* GetExtraInfo() const {return fExtraInfo.Data();} // get the object's extra info + + Bool_t IsValid(Int_t runNumber, + AliCDBMetaData* metaData = NULL) const; + Bool_t IsStrictlyValid(Int_t runNumber, + AliCDBMetaData* metaData = NULL) const; + Int_t Compare(const TObject* object) const; + Bool_t Matches(const char* name, Int_t runNumber) const; + +protected: + TString fName; // name of the entry + TString fDetector; // name of the detector (ZDC, TPC, etc...) + TString fDBType; // name of the database type (Calib, Align) + TString fDetSpecType; // name of the detector's specific data type (pedestals, gain coeffs...) + Int_t fFirstRun; // index of first valid run + Int_t fLastRun; // index of last valid run + Int_t fVersion; // version of the entry + Int_t fPeriod; // beam period + TString fFormat; // object's format + TString fResponsible; // name of the person responsible for the object + TString fExtraInfo; // extra info about the object + + void EncodeName(); + void DecodeName(); + +ClassDef(AliCDBMetaData, 1) // CDB meta data: full description of a run dependent database object +}; + +extern Bool_t operator == (const AliCDBMetaData& entry1, + const AliCDBMetaData& entry2); + +#endif diff --git a/STEER/AliObjectMetaData.cxx b/STEER/AliCDBMetaDataSelect.cxx similarity index 52% rename from STEER/AliObjectMetaData.cxx rename to STEER/AliCDBMetaDataSelect.cxx index b10f5ba6c65..64b23b7683d 100644 --- a/STEER/AliObjectMetaData.cxx +++ b/STEER/AliCDBMetaDataSelect.cxx @@ -17,105 +17,66 @@ /////////////////////////////////////////////////////////////////////////////// // // -// Object meta data: full description of a run dependent database object // +// subsample of the CDB metadata, used to retrieve // +// a stored database object: // +// name="Detector/DBType/DetSpecType", run validity, version // // // /////////////////////////////////////////////////////////////////////////////// -#include -#include -#include #include -#include "AliObjectMetaData.h" -#include "AliMetaData.h" +#include "AliCDBMetaDataSelect.h" +#include "AliCDBMetaData.h" #include "AliLog.h" -ClassImp(AliObjectMetaData) +ClassImp(AliCDBMetaDataSelect) //_____________________________________________________________________________ -AliObjectMetaData::AliObjectMetaData() : - AliMetaData(), - fPeriod(-1), - fFormat(""), - fResponsible("Duck, Donald"), - fExtraInfo("") +AliCDBMetaDataSelect::AliCDBMetaDataSelect() : + AliCDBMetaData() { // default constructor // the default values mean no selection } //_____________________________________________________________________________ -AliObjectMetaData::AliObjectMetaData - (const char* name, Int_t firstRun, Int_t lastRun, Int_t period, - const char* objFormat, const char* responsible, - const char* extraInfo): - AliMetaData(name, firstRun, lastRun), - fPeriod(period), - fFormat(objFormat), - fResponsible(responsible), - fExtraInfo(extraInfo) +AliCDBMetaDataSelect::AliCDBMetaDataSelect(const char* name, Int_t firstRun, Int_t lastRun, Int_t Version) : + AliCDBMetaData(name, firstRun, lastRun) { // constructor + fVersion=Version; } //_____________________________________________________________________________ -AliObjectMetaData::AliObjectMetaData(const AliObjectMetaData& entry) : - AliMetaData(entry), - fPeriod(entry.fPeriod), - fFormat(entry.fFormat), - fResponsible(entry.fResponsible), - fExtraInfo(entry.fExtraInfo) +AliCDBMetaDataSelect::AliCDBMetaDataSelect(const AliCDBMetaDataSelect& entry) : + AliCDBMetaData(entry) { // copy constructor } //_____________________________________________________________________________ -AliObjectMetaData& AliObjectMetaData::operator = (const AliObjectMetaData& entry) +AliCDBMetaDataSelect::AliCDBMetaDataSelect(const AliCDBMetaData& entry) : + AliCDBMetaData(entry) { -// assignment operator - fName = entry.fName; - fFirstRun = entry.fFirstRun; - fLastRun = entry.fLastRun; - fPeriod=entry.fPeriod; - fFormat=entry.fFormat; - fResponsible=entry.fResponsible; - fExtraInfo=entry.fExtraInfo; - DecodeName(); - return *this; +// constructor of AliCDBMetaDataSelect from AliCDBMetaData + fPeriod=-1; + fFormat=""; + fResponsible="Duck, Donald"; + fExtraInfo=""; } -//_____________________________________________________________________________ -const int AliObjectMetaData::GetPeriod() const -{ -// get the beam period - - return fPeriod; -} //_____________________________________________________________________________ -const char* AliObjectMetaData::GetFormat() const +AliCDBMetaDataSelect& AliCDBMetaDataSelect::operator = (const AliCDBMetaDataSelect& entry) { -// get the object's format - - return fFormat.Data(); -} - -//_____________________________________________________________________________ -const char* AliObjectMetaData::GetResponsible() const -{ -// get the object's responsible (the person who made it) - - return fResponsible.Data(); -} - -//_____________________________________________________________________________ -const char* AliObjectMetaData::GetExtraInfo() const -{ -// get the object's extra info - - return fExtraInfo.Data(); +// assignment operator + fName = entry.fName, + fFirstRun = entry.fFirstRun; + fLastRun = entry.fLastRun; + fVersion = entry.fVersion; + return *this; } diff --git a/STEER/AliCDBMetaDataSelect.h b/STEER/AliCDBMetaDataSelect.h new file mode 100644 index 00000000000..4043a475ed7 --- /dev/null +++ b/STEER/AliCDBMetaDataSelect.h @@ -0,0 +1,30 @@ +#ifndef ALICDBMETADATASELECT_H +#define ALICDBMETADATASELECT_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +/// +/// subsample of the CDB object metadata, used to retrieve a stored database object: name="Detector/DBType/DetSpecType", run validity, version +/// + +#include + +#include "AliCDBMetaData.h" + + +class AliCDBMetaDataSelect: public AliCDBMetaData { +public: + AliCDBMetaDataSelect(); // default constructor + AliCDBMetaDataSelect(const char* name, Int_t firstRun = -1, Int_t lastRun = -1, Int_t version = -1); // constructor + virtual ~AliCDBMetaDataSelect() {}; // destructor + + AliCDBMetaDataSelect(const AliCDBMetaDataSelect& entry); // copy constructor + AliCDBMetaDataSelect(const AliCDBMetaData& entry); // selection metadata from base class + AliCDBMetaDataSelect& operator = (const AliCDBMetaDataSelect& entry); // assignment operator + + ClassDef(AliCDBMetaDataSelect, 1) // metadata used to retrieve a DB object +}; + +#endif diff --git a/STEER/AliRunDataStorage.cxx b/STEER/AliCDBStorage.cxx similarity index 65% rename from STEER/AliRunDataStorage.cxx rename to STEER/AliCDBStorage.cxx index 3fd1166b891..b5aa8cca0b3 100644 --- a/STEER/AliRunDataStorage.cxx +++ b/STEER/AliCDBStorage.cxx @@ -27,50 +27,48 @@ #include #include "AliLog.h" -#include "AliSelectionMetaData.h" -#include "AliObjectMetaData.h" -#include "AliRunData.h" -#include "AliRunDataStorage.h" +#include "AliCDBEntry.h" +#include "AliCDBStorage.h" -ClassImp(AliRunDataStorage) +ClassImp(AliCDBStorage) -AliRunDataStorage* AliRunDataStorage::fgInstance = NULL; +AliCDBStorage* AliCDBStorage::fgInstance = NULL; //_____________________________________________________________________________ -AliRunDataStorage::AliRunDataStorage() : +AliCDBStorage::AliCDBStorage() : TObject(), fSelection(), fEntries(), - fRecordFile(NULL) + fDumpFile(NULL) { // default constructor if (fgInstance) delete fgInstance; fgInstance = this; + fStorageMode=kDevelopment; } //_____________________________________________________________________________ -AliRunDataStorage::~AliRunDataStorage() +AliCDBStorage::~AliCDBStorage() { // destructor - fSelection.Delete(); fEntries.Delete(); - if (fRecordFile) { - fRecordFile->Close(); - delete fRecordFile; + if (fDumpFile) { + fDumpFile->Close(); + delete fDumpFile; } fgInstance = NULL; } //_____________________________________________________________________________ -AliRunDataStorage::AliRunDataStorage(const AliRunDataStorage& db) : +AliCDBStorage::AliCDBStorage(const AliCDBStorage& db) : TObject(db), fSelection(), fEntries(), - fRecordFile(NULL) + fDumpFile(NULL) { // copy constructor @@ -78,7 +76,7 @@ AliRunDataStorage::AliRunDataStorage(const AliRunDataStorage& db) : } //_____________________________________________________________________________ -AliRunDataStorage& AliRunDataStorage::operator = (const AliRunDataStorage& /*db*/) +AliCDBStorage& AliCDBStorage::operator = (const AliCDBStorage& /*db*/) { // assignment operator @@ -88,19 +86,19 @@ AliRunDataStorage& AliRunDataStorage::operator = (const AliRunDataStorage& /*db* //_____________________________________________________________________________ -const TObject* AliRunDataStorage::Get(const char* name, Int_t runNumber) +const TObject* AliCDBStorage::Get(const char* name, Int_t runNumber) { // get an object from the data base -// (AliRunDataStorage is NOT the owner of the returned object) +// (AliCDBStorage is NOT the owner of the returned object) // name must be in the form "Detector/DBType/DetSpecType" // es: "ZDC/Calib/Pedestals" - AliSelectionMetaData defaultMetaData; - AliSelectionMetaData* selectedMetaData = &defaultMetaData; + AliCDBMetaDataSelect defaultMetaData; + AliCDBMetaDataSelect* selectedMetaData = &defaultMetaData; // look for a meta data selection for (Int_t i = 0; i < fSelection.GetEntriesFast(); i++) { - AliSelectionMetaData* selection = (AliSelectionMetaData*) fSelection[i]; + AliCDBMetaDataSelect* selection = (AliCDBMetaDataSelect*) fSelection[i]; if (!selection) continue; if (selection->Matches(name, runNumber)) { selectedMetaData = selection; @@ -108,9 +106,9 @@ const TObject* AliRunDataStorage::Get(const char* name, Int_t runNumber) } // get the entry - AliSelectionMetaData selMetaData(*selectedMetaData); + AliCDBMetaDataSelect selMetaData(*selectedMetaData); selMetaData.SetName(name); - AliRunData* entry = GetEntry(selMetaData, runNumber); + AliCDBEntry* entry = GetEntry(selMetaData, runNumber); if (entry) { AliDebug(2, "got the entry:"); ToAliDebug(2, entry->Dump()); @@ -126,17 +124,17 @@ const TObject* AliRunDataStorage::Get(const char* name, Int_t runNumber) } fEntries.Add(entry); - // record entry to a file (in the same way as AliRunDataFile::PutEntry, - // so that the file can be opened as a AliRunDataFile!) + // Dump entry to a file (in the same way as AliCDBDump::PutEntry, + // so that the file can be opened as a AliCDBDump!) - if (fRecordFile) { - fRecordFile->cd(); + if (fDumpFile) { + fDumpFile->cd(); TDirectory* saveDir = gDirectory; // go to or create the directory TString strname(name); while (strname.BeginsWith("/")) strname.Remove(0); - TDirectory* dir = fRecordFile; + TDirectory* dir = fDumpFile; Int_t index = -1; while ((index = strname.Index("/")) >= 0) { TString dirName(strname(0, index)); @@ -155,29 +153,34 @@ const TObject* AliRunDataStorage::Get(const char* name, Int_t runNumber) } - //_____________________________________________________________________________ -Bool_t AliRunDataStorage::Put(const TObject* object, - const AliObjectMetaData& objMetaData) +Bool_t AliCDBStorage::Put(const TObject* object, + const AliCDBMetaData& metaData) { // put an object into the data base -// (AliRunDataStorage does not adopt the object) +// (AliCDBStorage does not adopt the object) // location of where the object is stored is defined by -// the AliObjectMetaData's name ("Detector/DBType/DetSpecType") +// the AliCDBMetaData's name ("Detector/DBType/DetSpecType") // and run Range. Storage is handled by the PutEntry method -// of the current AliRunDataStorage instance. +// of the current AliCDBStorage instance. if (!object) return kFALSE; - AliRunData entry(object->Clone(), objMetaData); - return PutEntry(&entry); + + AliCDBEntry *entry= new AliCDBEntry(object, metaData); + + Bool_t result = PutEntry(entry); + + delete entry; + + return result; } //_____________________________________________________________________________ -Bool_t AliRunDataStorage::PutEntry(AliRunData* entry) +Bool_t AliCDBStorage::PutEntry(AliCDBEntry* entry) { // put an object into the data base -// Refer to the specific method of the current AliRunDataStorage instance -// (AliRunDataFile, AliRunDataOrganizedFile, AliRunDataAlien) +// Refer to the specific method of the current AliCDBStorage instance +// (AliCDBDump, AliCDBLocalFile, AliCDBGrid) if (!entry) return kFALSE; AliError(Form("This is a read only data base. " @@ -187,31 +190,31 @@ Bool_t AliRunDataStorage::PutEntry(AliRunData* entry) //_____________________________________________________________________________ -void AliRunDataStorage::Select(const AliSelectionMetaData& selMetaData) +void AliCDBStorage::Select(const AliCDBMetaDataSelect& selMetaData) { // add some meta data selection criteria - fSelection.Add(new AliSelectionMetaData(selMetaData)); + fSelection.Add(new AliCDBMetaDataSelect(selMetaData)); } //_____________________________________________________________________________ -Bool_t AliRunDataStorage::RecordToFile(const char* fileName) +Bool_t AliCDBStorage::DumpToFile(const char* fileName) { -// record entries retrieved from the data base to a file with the given name +// Dump entries retrieved from the data base to a file with the given name - if (fRecordFile) { - fRecordFile->Close(); - delete fRecordFile; + if (fDumpFile) { + fDumpFile->Close(); + delete fDumpFile; } TDirectory* dir = gDirectory; - fRecordFile = TFile::Open(fileName, "UPDATE"); + fDumpFile = TFile::Open(fileName, "UPDATE"); if (dir) dir->cd(); else gROOT->cd(); - if (!fRecordFile || !fRecordFile->IsOpen()) { + if (!fDumpFile || !fDumpFile->IsOpen()) { AliError(Form("could not open file %s", fileName)); - delete fRecordFile; - fRecordFile = NULL; + delete fDumpFile; + fDumpFile = NULL; return kFALSE; } return kTRUE; @@ -219,27 +222,28 @@ Bool_t AliRunDataStorage::RecordToFile(const char* fileName) //_____________________________________________________________________________ -AliRunDataStorage* AliRunDataStorage::Instance() +AliCDBStorage* AliCDBStorage::Instance() { -// return the current instance of the DB (AliRunDataFile, AliRunOrganizedDataFile...) -// Example of usage: after creating an istance of AliRunDataStorage: -// AliRunDataStorage::Instance()->Get(...) +// return the current instance of the DB (AliCDBDump, AliCDBLocalFile...) +// Example of usage: after creating an istance of AliCDBStorage: +// AliCDBStorage::Instance()->Get(...) return fgInstance; } //_____________________________________________________________________________ -const AliObjectMetaData& AliRunDataStorage::GetObjectMetaData(const char* name) +const AliCDBMetaData& AliCDBStorage::GetCDBMetaData(const char* name) { // Returns the object's metadata of the already retrieved object // (useful, for example, if you want to know the format of the object you have // retrieved) -AliRunData *entry = (AliRunData*) fEntries.FindObject(name); +AliCDBEntry *entry = (AliCDBEntry*) fEntries.FindObject(name); if(!entry){ AliError(Form("Entry %s not found! You make me crash!",name)); } - return entry->GetObjectMetaData(); + return entry->GetCDBMetaData(); } + diff --git a/STEER/AliCDBStorage.h b/STEER/AliCDBStorage.h new file mode 100644 index 00000000000..c9421dd4fcb --- /dev/null +++ b/STEER/AliCDBStorage.h @@ -0,0 +1,75 @@ +#ifndef ALICDBSTORAGE_H +#define ALICDBSTORAGE_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +/// +/// base class for data base access classes +/// + +#include +#include +#include "AliCDBMetaDataSelect.h" +#include "AliCDBMetaData.h" + + +class TFile; +class AliCDBMetaDataSelect; +class AliCDBMetaData; +class AliCDBEntry; + +class AliCDBStorage: public TObject { +public: + +typedef enum {kDevelopment, kProduction} StorageMode_t; + + virtual ~AliCDBStorage(); + + const TObject* Get(const char* name, Int_t runNumber); // Gets an object from the database + + Bool_t Put(const TObject* object, + const AliCDBMetaData& metaData); // Put an object into the database + + void Select(const AliCDBMetaDataSelect& selMetaData); // Add a selection criterion + + Bool_t DumpToFile(const char* fileName = "DB.root"); // prepares to dump the retrieved entries to a local file + + const AliCDBMetaData& GetCDBMetaData(const char* name); // Gets the CDBMetaData of the retrieved entry (name=entry's name) + + virtual void TagForProduction(const AliCDBMetaDataSelect& selMetaData, UInt_t prodVers) = 0; + + static AliCDBStorage* Instance(); // Instance of the current AliCDBStorage object (AliCDBDump, AliCDBLocalFile etc...) + + void SetStorageMode(StorageMode_t mode) {fStorageMode = mode;} + StorageMode_t GetStorageMode() {return fStorageMode;} + + +protected: + AliCDBStorage(); + + virtual AliCDBEntry* GetEntry(AliCDBMetaDataSelect& selMetaData, Int_t runNumber) = 0; // virtual, see the correspondent method of the derived classes + + virtual Bool_t PutEntry(AliCDBEntry* entry); // virtual, see the correspondent method of the derived classes + + AliCDBEntry* GetCurrentEntry(const char* name) const + {return (AliCDBEntry*) fEntries.FindObject(name);} + + StorageMode_t fStorageMode; + +private: + AliCDBStorage(const AliCDBStorage& db); + AliCDBStorage& operator = (const AliCDBStorage& db); + + TObjArray fSelection; //! meta data selection + + TObjArray fEntries; //! array of current AliCDBEntry objects + TFile* fDumpFile; //! file for dumped entries + + static AliCDBStorage* fgInstance; //! pointer to the DB instance + + ClassDef(AliCDBStorage, 0) // base class for data base access classes +}; + +#endif diff --git a/STEER/AliMetaData.h b/STEER/AliMetaData.h deleted file mode 100644 index 3d99e08bb89..00000000000 --- a/STEER/AliMetaData.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef ALIMETADATA_H -#define ALIMETADATA_H -/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * - * See cxx source for full Copyright notice */ - -/* $Id$ */ - -/// -/// base class of the meta data of run dependent objects -/// Derived classes: AliObjectMetaData, AliSelectionMetaData -/// - -#include -#include - - -class AliMetaData: public TObject { -public: - AliMetaData(); - AliMetaData(const char* name, - Int_t firstRun = -1, Int_t lastRun = -1, Int_t version = -1); - virtual ~AliMetaData() {}; - - AliMetaData(const AliMetaData& entry); - AliMetaData& operator = (const AliMetaData& entry); - - virtual void SetName(const char* name) {fName = name; DecodeName();} - /*virtual*/ void SetRunRange(Int_t firstRun = -1, Int_t lastRun = 1) - {fFirstRun = firstRun; fLastRun = lastRun;} - /*virtual*/ void SetVersion(Int_t version = -1) {fVersion = version;} - - void SetDetector(const char* Detector) {fDetector = Detector; EncodeName();} - void SetDBType(const char* DBType) {fDBType = DBType; EncodeName();} - void SetDetSpecType(const char* DetSpecType) {fDetSpecType = DetSpecType; EncodeName();} - - const char* GetDetector() const; - const char* GetDBType() const; - const char* GetDetSpecType() const; - - - /*virtual*/ const char* GetName() const; - /*virtual*/ Int_t GetFirstRun() const {return fFirstRun;} - /*virtual*/ Int_t GetLastRun() const {return fLastRun;} - /*virtual*/ Int_t GetVersion() const {return fVersion;} - - /*virtual*/ Bool_t IsValid(Int_t runNumber, - AliMetaData* metaData = NULL) const; - /*virtual*/ Bool_t IsStrictlyValid(Int_t runNumber, - AliMetaData* metaData = NULL) const; - /*virtual*/ Int_t Compare(const TObject* object) const; - /*virtual*/ Bool_t Matches(const char* name, Int_t runNumber) const; - -protected: - TString fName; // name of the entry - TString fDetector; // name of the detector (ZDC, TPC, etc...) - TString fDBType; // name of the database type (Calib, Align) - TString fDetSpecType; // name of the detector's specific data type (pedestals, gain coeffs...) - Int_t fFirstRun; // index of first valid run - Int_t fLastRun; // index of last valid run - Int_t fVersion; // version of the entry - - void EncodeName(); - void DecodeName(); - - - ClassDef(AliMetaData, 2) // base class of the meta data of run dependent objects -}; - -extern Bool_t operator == (const AliMetaData& entry1, - const AliMetaData& entry2); - -#endif diff --git a/STEER/AliObjectMetaData.h b/STEER/AliObjectMetaData.h deleted file mode 100644 index c234a6a100b..00000000000 --- a/STEER/AliObjectMetaData.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef ALIOBJECTMETADATA_H -#define ALIOBJECTMETADATA_H -/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * - * See cxx source for full Copyright notice */ - -/* $Id$ */ - -/// -/// Object meta data: it fully describes a run dependent database object. -/// It is attached to the object to build an AliRunData object -/// -/// - -#include -#include - -#include "AliMetaData.h" - - -class AliObjectMetaData: public AliMetaData { -public: - AliObjectMetaData(); // default constructor - AliObjectMetaData - (const char* name, Int_t firstRun = -1, Int_t lastRun = -1, Int_t period=-1, - const char* objFormat="", const char* responsible="Duck, Donald", - const char* extraInfo=""); // constructor - virtual ~AliObjectMetaData() {}; // destructor - - AliObjectMetaData(const AliObjectMetaData& entry); // copy contructor - AliObjectMetaData& operator = (const AliObjectMetaData& entry); // assignment operator - - void SetFormat(const char* objFormat) {fFormat = objFormat;} // infos about object's format (array o floats, histos...) - void SetResponsible(const char* responsible) {fResponsible = responsible;} // who made the object? - void SetExtraInfo(const char* extraInfo) {fExtraInfo = extraInfo;} // something else you would like to know - void SetPeriod(Int_t period) {fPeriod = period;} // number of beam period - - const char* GetFormat() const; - const char* GetResponsible() const; - const char* GetExtraInfo() const; - const Int_t GetPeriod() const; - -private: - Int_t fPeriod; // beam period - TString fFormat; // object's format - TString fResponsible; // name of the person responsible for the object - TString fExtraInfo; // extra info about the object - - -ClassDef(AliObjectMetaData, 1) // Object meta data: full description of a run dependent database object -}; - -#endif diff --git a/STEER/AliRunDataFile.h b/STEER/AliRunDataFile.h deleted file mode 100644 index 3e8ad362f0d..00000000000 --- a/STEER/AliRunDataFile.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef ALIRUNDATAFILE_H -#define ALIRUNDATAFILE_H -/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * - * See cxx source for full Copyright notice */ - -/* $Id$ */ - -/// -/// access classes for a data base in a LOCAL file -/// - -#include "AliRunDataStorage.h" -#include "AliSelectionMetaData.h" - -class TFile; - - -class AliRunDataFile: public AliRunDataStorage { -public: - AliRunDataFile(const char* fileName = "DB.root", Bool_t readOnly = kTRUE); - virtual ~AliRunDataFile(); - -protected: - virtual AliRunData* GetEntry(AliSelectionMetaData& selMetaData, Int_t runNumber); - - virtual Bool_t PutEntry(AliRunData* entry); - -private: - AliRunDataFile(const AliRunDataFile& db); - AliRunDataFile& operator = (const AliRunDataFile& db); - - TFile* fFile; //! the DB local file - - ClassDef(AliRunDataFile, 0) // access classes for a data base in a LOCAL file -}; - -#endif diff --git a/STEER/AliRunDataOrganizedFile.cxx b/STEER/AliRunDataOrganizedFile.cxx deleted file mode 100644 index 94341403c11..00000000000 --- a/STEER/AliRunDataOrganizedFile.cxx +++ /dev/null @@ -1,366 +0,0 @@ -/************************************************************************** - * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * - * * - * Author: The ALICE Off-line Project. * - * Contributors are mentioned in the code where appropriate. * - * * - * Permission to use, copy, modify and distribute this software and its * - * documentation strictly for non-commercial purposes is hereby granted * - * without fee, provided that the above copyright notice appears in all * - * copies and that both the copyright notice and this permission notice * - * appear in the supporting documentation. The authors make no claims * - * about the suitability of this software for any purpose. It is * - * provided "as is" without express or implied warranty. * - **************************************************************************/ - -/* $Id$ */ - -/////////////////////////////////////////////////////////////////////////////// -// // -// access class to a DB file inside an organized directory structure // -// (DBFolder/detector/dbType/detSpecType) // -// // -/////////////////////////////////////////////////////////////////////////////// - - -#include -#include -#include -#include -#include -#include -#include - -#include "AliLog.h" -#include "AliRunData.h" -#include "AliSelectionMetaData.h" -#include "AliRunDataOrganizedFile.h" - - -ClassImp(AliRunDataOrganizedFile) - -//_____________________________________________________________________________ -AliRunDataOrganizedFile::AliRunDataOrganizedFile(const char* DBFolder) : - AliRunDataStorage(), - fDBFolder(DBFolder) -{ -// constructor - TString buffer(fDBFolder); - gSystem->ExpandPathName(buffer); - if(!gSystem->OpenDirectory(buffer)){ - AliError(Form("Path %s not a directory",fDBFolder.Data())); - } -} - -//_____________________________________________________________________________ -AliRunDataOrganizedFile::~AliRunDataOrganizedFile() -{ -// destructor - - if (fDBFolder) fDBFolder=""; -} - -//_____________________________________________________________________________ -AliRunDataOrganizedFile::AliRunDataOrganizedFile(const AliRunDataOrganizedFile& /*db*/) : - AliRunDataStorage(), - fDBFolder("") -{ -// copy constructor - - AliFatal("not implemented"); -} - -//_____________________________________________________________________________ -AliRunDataOrganizedFile& AliRunDataOrganizedFile::operator = (const AliRunDataOrganizedFile& /*db*/) -{ -// assignment operator - - AliFatal("not implemented"); - return *this; -} - -//_____________________________________________________________________________ -AliRunData* AliRunDataOrganizedFile::GetEntry(AliSelectionMetaData& selMetaData, Int_t runNumber) -{ -// get an object from the data base - - TDirectory* saveDir = gDirectory; - -// Find the right file in the directory - - TObjArray *objarr = FindDataBaseFile(selMetaData, runNumber); - if(!objarr || objarr->GetEntries()==0) return NULL; - if(objarr->GetEntries()>1) - AliWarning("Warning: more than 1 file match requirements, I will open the first found!"); - -// Open the file - - TObjString *objstr= (TObjString*) objarr->At(0); // there should be only one item - TString fileName(objstr->GetName()); - TFile *dbFile = new TFile(fileName.Data(),"READ"); - if (!dbFile || !dbFile->IsOpen()) { - AliError(Form("could not open file %s", fileName.Data())); - return NULL; - } - -// get the only AliRunData object from the file -// I suppose that the object in the file is a AliRunData entry with -// name="DetSpecType" (set in SelectionMetaData) - - dbFile->cd(); - - AliRunData *entry = (AliRunData*) dbFile->Get(selMetaData.GetDetSpecType()); - - if(!entry || !entry->InheritsFrom(AliRunData::Class())) { - AliError(Form("No entry named %s found!",selMetaData.GetDetSpecType())); - dbFile->Close(); delete dbFile; - if (saveDir) saveDir->cd(); else gROOT->cd(); - return NULL; - } - -// now set the run range and version got from the filename -// to the object's metadata! - - TString fileNameShort=fileName; - fileNameShort.Remove(0,fileNameShort.Last('/')+1); - int numbers[3]={-1,-1,-1}; // numbers[0]=firstRun, numbers[1]=lastRun, numbers[2]=Version - GetNumbers(fileNameShort, numbers); - entry->SetRunRange(numbers[0],numbers[1]); - entry->SetVersion(numbers[2]); - -// close file, return retieved entry - - dbFile->Close(); delete dbFile; - if (saveDir) saveDir->cd(); else gROOT->cd(); - - if(selMetaData.GetVersion() > -1 && numbers[2] != selMetaData.GetVersion()) - AliWarning(Form("Warning: selected version (%d) not found, got version %d instead", - selMetaData.GetVersion(),numbers[2])); - return entry; - -} - - -//_____________________________________________________________________________ -Bool_t AliRunDataOrganizedFile::PutEntry(AliRunData* entry) -{ -// puts an object into the database - -// AliRunData entry is composed by the object and its MetaData -// this method takes the metaData, reads the name, runRange and Version -// creates the directory structure and the file name -// looks for runs with same or overlapping runrange, if exist increment version -// (therefore version should not be put in the metadata) -// if the runrange is different (but overlapping) from a preceding version, a warning message -// is issued. -// sets the runrange and version in the object metadata = -1 (to avoid inconsistencies) -// open the filem, write the entry in the file. -// Note: the key name of the entry is "DetSpecType" -// return result - - if(!entry) return kFALSE; - TDirectory* saveDir = gDirectory; - - Int_t firstRun=entry->GetObjectMetaData().GetFirstRun(); - Int_t lastRun=entry->GetObjectMetaData().GetLastRun(); - if(firstRun<0 || lastRun<0 || lastRunGetObjectMetaData().GetName()); - - while(name.EndsWith("/")) name.Remove(name.Last('/')); - while(name.BeginsWith("/")) name.Remove(name.First('/'),1); - - TString detSpecType(name(name.Last('/')+1, name.Length()-name.Last('/'))); - - TString buffer(fDBFolder); - gSystem->ExpandPathName(buffer); - while(buffer.EndsWith("/")) buffer.Remove(buffer.Last('/')); - - void *dir=0; - Int_t index = -1; - name+='/'; // name=detector/dbType/detSpecType/ - - while ((index = name.Index("/")) >= 0) { - TString dirName(name(0, index)); - buffer+='/'; buffer+=dirName; - dir=gSystem->OpenDirectory(buffer); - if (!dir) { - AliWarning(Form("Directory %s does not exist! It will be created...",buffer.Data())); - TString command = "mkdir "+ buffer; - gSystem->Exec(command.Data()); - } - name.Remove(0, index+1); - } - - TString strfName="Run"; - - TString levelContent=""; - Int_t maxVersion=-1, run1=-1, run2=-1; - int numbers[3]={-1,-1,-1}; // numbers[0]=firstRun, numbers[1]=lastRun, numbers[2]=Version - while(levelContent=gSystem->GetDirEntry(dir)){ - if(levelContent=="." || levelContent=="..") continue; if(levelContent=="") break; - if(levelContent.Contains(strfName)){ - GetNumbers(levelContent, numbers); - if((firstRun>=numbers[0] && firstRun<=numbers[1]) || - (lastRun>=numbers[0] && lastRun<=numbers[1]) || - (firstRun<=numbers[0] && lastRun>=numbers[1])) {// overlap! - if(numbers[2]>maxVersion) { - maxVersion=numbers[2]; - run1=numbers[0]; run2=numbers[1]; - } - } - } - } - - if((run1!=-1 && run2!=-1) && (firstRun!=run1 || lastRun!=run2)) - AliWarning(Form("Run range modified w.r.t. preceding version (%d, %d)",run1, run2)); - - - if(firstRun==lastRun) { - strfName+=firstRun; - }else{ - strfName+=firstRun; strfName+="-"; strfName+=lastRun; - } - strfName+="_v"; strfName+=maxVersion+1; strfName+=".root"; - buffer+='/'; buffer+=strfName; - - // opening file - TFile *dbFile = new TFile(buffer.Data(),"NEW"); - if(!dbFile || !dbFile->IsWritable()){ - AliError(Form("The data base file is not writable. " - "The object %s was not inserted", entry->GetName())); - return kFALSE; - } - - dbFile->cd(); - - entry->SetRunRange(-1,-1); entry->SetVersion(-1); - - // write object - Bool_t result = (entry->Write(detSpecType) != 0); - if (saveDir) saveDir->cd(); else gROOT->cd(); - dbFile->Close(); delete dbFile; - - if(result) { - AliInfo(Form("Run object %s",entry->GetName())); - AliInfo(Form("was successfully written into file %s !",buffer.Data())); - } - - return result; -} - -/*****************************************************************************/ - -TObjArray* AliRunDataOrganizedFile::FindDataBaseFile(AliSelectionMetaData& selMetaData, Int_t runNumber){ -// Find DataBase file name in a local directory. The filename must be in the form: Run#run1-#run2_v#version.root -// TRegexp allowed: selMetaData's name can be for example: "detector/*" !! - - TObjArray *fileNameColl=new TObjArray(); - - TString buffer(fDBFolder); - if(!(buffer.EndsWith("/"))) buffer+="/"; - gSystem->ExpandPathName(buffer); - - TString bufftInit=buffer; // buffInit="$ALICE_ROOT/DB/ - TString levelContent=""; - - TString detector(selMetaData.GetDetector()); - TString dbType(selMetaData.GetDBType()); - TString detSpecType(selMetaData.GetDetSpecType()); - int selVersion = selMetaData.GetVersion(); - - void *dirLevInit = gSystem->OpenDirectory(buffer); - while(levelContent=gSystem->GetDirEntry(dirLevInit)){ // lev0! In Detector directory (ZDC, TPC...)!! - - if(levelContent=="." || levelContent=="..") continue; if(levelContent=="") break; - if(!(detector=="*") && !levelContent.Contains(TRegexp(detector)) ) continue; - - buffer=bufftInit+levelContent; buffer+='/'; // buffer="$ALICE_ROOT/DB/detector/ - TString bufft0=buffer; // bufft0="$ALICE_ROOT/DB/detector/ - - void *dirLev0 = gSystem->OpenDirectory(buffer); - while(levelContent=gSystem->GetDirEntry(dirLev0)){ // lev1! dbType directory (Calib, Align)!! - - if(levelContent=="." || levelContent=="..") continue; if(levelContent=="") break; - if(!(dbType=="*") && !levelContent.Contains(TRegexp(dbType))) continue; - - buffer=bufft0+levelContent;buffer+='/'; // buffer="$ALICE_ROOT/DB/detector/dbType/ - TString bufft1=buffer; // bufft1="$ALICE_ROOT/DB/detector/dbType/ - - void *dirLev1 = gSystem->OpenDirectory(buffer); - while(levelContent=gSystem->GetDirEntry(dirLev1)){ // lev2! detSpecType directory (Pedestals, gain....)!! - - if(levelContent=="." || levelContent=="..") continue; if(levelContent=="") break; - if(!(detSpecType=="*") && !levelContent.Contains(TRegexp(detSpecType))) continue; - - buffer=bufft1+levelContent;buffer+='/'; // buffer="$ALICE_ROOT/DB/detector/dbType/detSpecType/ - TString bufft2=buffer; // bufft2="$ALICE_ROOT/DB/detector/dbType/detSpecType/ - - void *dirLev2 = gSystem->OpenDirectory(buffer); - int oldVers=-1; - TObjString *str=0; - while(levelContent=gSystem->GetDirEntry(dirLev2)){ // lev3! Run directory (Run#XXX-#YYY_v#ZZ.root)!! - - if(levelContent=="." || levelContent=="..") continue; if(levelContent=="") break; - if(!levelContent.BeginsWith("Run")) continue; - - int numbers[3]={-1,-1,-1}; // numbers[0]=firstRun, numbers[1]=lastRun, numbers[2]=Version - GetNumbers(levelContent,numbers); - if(numbers[0]<0 || numbers[1]<0 || numbers[2]<0 ) continue; // wrong run filename format! - if(numbers[0]>runNumber || numbers[1]= oldVers) { - buffer=bufft2+levelContent; - str=new TObjString(buffer.Data()); - oldVers=numbers[2]; - if(numbers[2]==selVersion) break; - } - } // end loop on runs - if(str) fileNameColl->Add(str); - } // end loop in lev1 - } // end loop in lev0 - } // end loop in levInit - - AliInfo(Form("Found %d entries matching requirements", fileNameColl->GetEntriesFast())); - ToAliInfo(fileNameColl->ls()); - return fileNameColl; -} - -//_____________________________________________________________________________ - -void AliRunDataOrganizedFile::GetNumbers(const TString strName, int *numArray) -{ -// Gets the numbers (#Run1, #Run2, #Version) from the filename: Run#Run1-#Run2_v#Version.root - - int indexMinus=strName.Last('-'); - int indexUScore=strName.Last('_'); - int indexPoint=strName.Last('.'); - - if(indexUScore<0 || indexPoint<0 ) - {AliError(Form("Check sintax %s",strName.Data())); return;} - - if(indexMinus<0){ // only 1 Run number! - TString cRun=strName(3,indexUScore-3); - if(!(cRun.IsDigit())) - {AliError(Form("%s not a digit! Check sintax %s",cRun.Data(),strName.Data())); return;} - numArray[0] = (int) strtol(cRun.Data(),0,10); - numArray[1] = numArray[0]; - }else{ - TString cFirstRun = strName(3,indexMinus-3); - TString cLastRun = strName(indexMinus+1,indexUScore-(indexMinus+1)); - if(!(cFirstRun.IsDigit()) || !(cLastRun.IsDigit())) - {AliError(Form("%s or %s are not digit! Check sintax %s", - cFirstRun.Data(), cLastRun.Data(), strName.Data())); return;} - numArray[0] = (int) strtol(cFirstRun.Data(),0,10); - numArray[1] = (int) strtol(cLastRun.Data(),0,10); - } - TString cVersion = strName(indexUScore+2,indexPoint-(indexUScore+2)); - if(!(cVersion.IsDigit())){ - AliError(Form("%s not a digit! Check sintax %s",cVersion.Data(),strName.Data())); return;} - numArray[2] = (int) strtol(cVersion.Data(),0,10); - - return; -} diff --git a/STEER/AliRunDataOrganizedFile.h b/STEER/AliRunDataOrganizedFile.h deleted file mode 100644 index a89fb98ab89..00000000000 --- a/STEER/AliRunDataOrganizedFile.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef ALIRUNDATAORGANIZEDFILE_H -#define ALIRUNDATAORGANIZEDFILE_H - -/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * - * See cxx source for full Copyright notice */ - -/* $Id$ */ - -/// -/// access class to a DB file inside an organized directory structure -/// (DBFolder/Detector/DBType/DetSpecType) -/// - -#include "AliRunDataStorage.h" -#include "AliSelectionMetaData.h" -#include "AliObjectMetaData.h" - -class AliRunDataOrganizedFile: public AliRunDataStorage { - -public: -// AliRunDataOrganizedFile(); - AliRunDataOrganizedFile(const char* DBFolder = "$(ALICE_ROOT)/DB"); - virtual ~AliRunDataOrganizedFile(); - - TObjArray* FindDataBaseFile(AliSelectionMetaData& selMetaData, Int_t runNumber); - -protected: - virtual AliRunData* GetEntry(AliSelectionMetaData& selMetaData, Int_t runNumber); - virtual Bool_t PutEntry(AliRunData* entry); - -private: - AliRunDataOrganizedFile(const AliRunDataOrganizedFile& db); - AliRunDataOrganizedFile& operator = (const AliRunDataOrganizedFile& db); - - void GetNumbers(const TString strName, int *numArray); - - TString fDBFolder; // the DB folder - -ClassDef(AliRunDataOrganizedFile, 0) // access class to a DB file in an organized directory structure (DBFolder/Detector/DBType/DetSpecType) -}; - -#endif diff --git a/STEER/AliRunDataStorage.h b/STEER/AliRunDataStorage.h deleted file mode 100644 index 4fdf28a6d05..00000000000 --- a/STEER/AliRunDataStorage.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef ALIRUNDATASTORAGE_H -#define ALIRUNDATASTORAGE_H -/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * - * See cxx source for full Copyright notice */ - -/* $Id$ */ - -/// -/// base class for data base access classes -/// - -#include -#include - -class TFile; -class AliSelectionMetaData; -class AliObjectMetaData; -class AliRunData; - - -class AliRunDataStorage: public TObject { -public: - virtual ~AliRunDataStorage(); - - const TObject* Get(const char* name, Int_t runNumber); // Gets an object from the database - - Bool_t Put(const TObject* object, - const AliObjectMetaData& objMetaData); // Put an object into the database - - void Select(const AliSelectionMetaData& selMetaData); // Add a selection criterion - - Bool_t RecordToFile(const char* fileName = "DB.root"); // prepares to record the retrieved entries to a local file - - const AliObjectMetaData& GetObjectMetaData(const char* name); // Gets the ObjectMetaData of the retrieved entry (name=entry's name) - -// virtual void TagForProduction(const AliSelectionMetaData& selMetaData, Uint_t prodVers); - - static AliRunDataStorage* Instance(); // Instance of the current AliRunDataStorage object (AliRunDataFile, AliRunDataOrganizedFile etc...) - -protected: - AliRunDataStorage(); - - virtual AliRunData* GetEntry(AliSelectionMetaData& selMetaData, Int_t runNumber) = 0; // virtual, see the correspondent method of the derived classes - - virtual Bool_t PutEntry(AliRunData* entry); // virtual, see the correspondent method of the derived classes - - AliRunData* GetCurrentEntry(const char* name) const - {return (AliRunData*) fEntries.FindObject(name);} - -private: - AliRunDataStorage(const AliRunDataStorage& db); - AliRunDataStorage& operator = (const AliRunDataStorage& db); - - TObjArray fSelection; //! meta data selection - - TObjArray fEntries; //! array of current AliRunData objects - TFile* fRecordFile; //! file for recorded entries - - static AliRunDataStorage* fgInstance; //! pointer to the DB instance - - ClassDef(AliRunDataStorage, 0) // base class for data base access classes -}; - -#endif diff --git a/STEER/AliRunLoader.cxx b/STEER/AliRunLoader.cxx index 047a81e25e7..8be990d54f0 100644 --- a/STEER/AliRunLoader.cxx +++ b/STEER/AliRunLoader.cxx @@ -62,8 +62,8 @@ class TTask; #include "AliHeader.h" #include "AliStack.h" #include "AliDetector.h" -#include "AliRunDataStorage.h" -#include "AliRunDataOrganizedFile.h" +#include "AliCDBStorage.h" +#include "AliCDBLocal.h" ClassImp(AliRunLoader) @@ -354,11 +354,11 @@ const TObject* AliRunLoader::GetRunObject(const char* name) const { //Get an object from the run data storage - if (!AliRunDataStorage::Instance()) { - AliWarning("No run data storage defined. Using AliRunDataOrganizedFile."); - new AliRunDataOrganizedFile; + if (!AliCDBStorage::Instance()) { + AliWarning("No run data storage defined. Using AliCDBLocal."); + new AliCDBLocal; } - return AliRunDataStorage::Instance()->Get(name, GetHeader()->GetRun()); + return AliCDBStorage::Instance()->Get(name, GetHeader()->GetRun()); } /**************************************************************************/ diff --git a/STEER/STEERLinkDef.h b/STEER/STEERLinkDef.h index 675521dfbe3..362c29eed80 100644 --- a/STEER/STEERLinkDef.h +++ b/STEER/STEERLinkDef.h @@ -73,13 +73,12 @@ #pragma link C++ class AliReconstruction+; #pragma link C++ class AliVertexGenFile+; #pragma link C++ class AliVertexer+; -#pragma link C++ class AliMetaData+; -#pragma link C++ class AliObjectMetaData+; -#pragma link C++ class AliSelectionMetaData+; -#pragma link C++ class AliRunData+; -#pragma link C++ class AliRunDataStorage; -#pragma link C++ class AliRunDataFile; -#pragma link C++ class AliRunDataOrganizedFile; +#pragma link C++ class AliCDBMetaData+; +#pragma link C++ class AliCDBMetaDataSelect+; +#pragma link C++ class AliCDBEntry+; +#pragma link C++ class AliCDBStorage; +#pragma link C++ class AliCDBDump; +#pragma link C++ class AliCDBLocal; #pragma link C++ class AliDetectorEventHeader+; #pragma link C++ class TTreeDataElement+; diff --git a/STEER/libSTEER.pkg b/STEER/libSTEER.pkg index 81856e482c1..17d7f981ced 100644 --- a/STEER/libSTEER.pkg +++ b/STEER/libSTEER.pkg @@ -19,9 +19,9 @@ AliTrackMap.cxx AliTrackMapper.cxx AliCollisionGeometry.cxx \ AliMemoryWatcher.cxx \ AliVertexer.cxx \ AliMC.cxx AliSimulation.cxx AliReconstruction.cxx AliVertexGenFile.cxx \ -AliMetaData.cxx AliRunData.cxx AliRunDataStorage.cxx AliRunDataFile.cxx \ -AliRunDataOrganizedFile.cxx\ -AliReconstructor.cxx AliObjectMetaData.cxx AliSelectionMetaData.cxx \ +AliCDBMetaData.cxx AliCDBEntry.cxx AliCDBStorage.cxx AliCDBDump.cxx \ +AliCDBLocal.cxx\ +AliReconstructor.cxx AliCDBMetaDataSelect.cxx \ AliDetectorEventHeader.cxx TTreeStream.cxx HDRS:= $(SRCS:.cxx=.h) diff --git a/macros/DBAccessTutorial.C b/macros/DBAccessTutorial.C index 428269f4014..6208fa9c4aa 100644 --- a/macros/DBAccessTutorial.C +++ b/macros/DBAccessTutorial.C @@ -36,7 +36,7 @@ printf("PM0=%f; PM1=%f; PM2=%f; PM3=%f \n", ***************************************************************************************************************/ // a. Define the object's metadata (set of information which describes the object) -// AliObjectMetaData(char* name, int firstRun, int lastRun,int Period,char* ObjectFormat, char* ResponsibleName, char* extraInfo) +// AliCDBMetaData(char* name, int firstRun, int lastRun,int Period,char* ObjectFormat, char* ResponsibleName, char* extraInfo) // // name: Object's name ("Detector/DBType/DetSpecType") // firstRun: first run for which the object is valid @@ -46,59 +46,58 @@ printf("PM0=%f; PM1=%f; PM2=%f; PM3=%f \n", // ResponsibleName: name of the person who created and stored the object // extraInfo: anything else you may want to know -AliObjectMetaData omd("ZDC/Calib/GainFactors",1,10,1,"AliZDCCalibData: Pedestals (47 floats), En. calib factors (4 floats)","A. Colla", "Tutorial"); +AliCDBMetaData md("ZDC/Calib/GainFactors",1,10,1,"AliZDCCalibData: Pedestals (47 floats), En. calib factors (4 floats)","A. Colla", "Tutorial"); -// b. Create the specific AliRunDataStorage instance (AliRunDataOrganizedFile in this case) +// b. Create the specific AliCDBStorage instance (AliCDBLocal in this case) -AliRunDataOrganizedFile *orgf = new AliRunDataOrganizedFile(DBFolder.Data()); +AliCDBLocal *loc = new AliCDBLocal(DBFolder.Data()); -// c. Put the object in the database. Use Put method: AliRunDataStorage::Put(TObject object, AliObjectMetaData& metaData) +// c. Put the object in the database. Use Put method: AliCDBStorage::Put(TObject object, AliCDBMetaData& metaData) // // the object will be stored in the file DBFolder/ZDC/Calib/GainFactors/Run1-10_v0.root // Note that the version is automatically determined. -AliRunDataStorage::Instance()->Put(calibda, omd); // we could also type: orgf->Put(calibda, omd) +AliCDBStorage::Instance()->Put(calibda, md); // we could also type: loc->Put(calibda, md) -// delete the AliRunDataStorage instance and the object (optional) -AliRunDataStorage::Instance()->Delete(); +// delete the AliCDBStorage instance and the object (optional) +AliCDBStorage::Instance()->Delete(); /*************************************************************************************************************** Part 2: Now we want to retrieve the object valid, say, for run 5 from the database folder. - We will dump it in a local file called "dummyDBTutorail.root", for later usage. + We will dump it in a dump file called "dummyDBTutorail.root", for later usage. ***************************************************************************************************************/ -// a. Create the specific AliRunDataStorage instance (AliRunDataOrganizedFile in this case) -AliRunDataOrganizedFile *orgf = new AliRunDataOrganizedFile(DBFolder.Data()); +// a. Create the specific AliCDBStorage instance (AliCDBLocal in this case) +AliCDBLocal *loc = new AliCDBLocal(DBFolder.Data()); -// b. Prepare AliRunDataStorage to save the object in the local file -AliRunDataStorage::Instance()->RecordToFile("dummyDBTutorial.root"); +// b. Prepare AliCDBStorage to save the object in the dump file +AliCDBStorage::Instance()->DumpToFile("dummyDBTutorial.root"); // c. Get the object! -// TObject *AliRunDataStorage::Get(char* name, int runNumber) +// TObject *AliCDBStorage::Get(char* name, int runNumber) // if no selection criteria are specified, the highest version found is retrieved. -AliZDCCalibData *calibda2 = (AliZDCCalibData*) AliRunDataStorage::Instance()->Get("ZDC/Calib/GainFactors",5); +AliZDCCalibData *calibda2 = (AliZDCCalibData*) AliCDBStorage::Instance()->Get("ZDC/Calib/GainFactors",5); printf("\nI am in Part2. ZDC Energy calibration factors: \n"); printf("PM0=%f; PM1=%f; PM2=%f; PM3=%f \n", calibda2->GetEnCalib(0), calibda2->GetEnCalib(1), calibda2->GetEnCalib(2), calibda2->GetEnCalib(3) ); -AliRunDataStorage::Instance()->Delete(); +AliCDBStorage::Instance()->Delete(); /*************************************************************************************************************** - Part 3: Now we will retrieve the object from the local file. + Part 3: Now we will retrieve the object from the dump file. We will tune the energy calibration factors and we suppose that the new object is valid from run 1 to run 15. Finally we will store the object in DBFolder again with the new run range specified in the object's metadata. ***************************************************************************************************************/ -// a. Create the specific AliRunDataStorage instance (AliRunDataFile in this case) -AliRunDataFile *df = new AliRunDataFile("dummyDBTutorial.root"); -//AliRunDataOrganizedFile *orgf = new AliRunDataOrganizedFile(DBFolder.Data()); +// a. Create the specific AliCDBStorage instance (AliCDBDump in this case) +AliCDBDump *df = new AliCDBDump("dummyDBTutorial.root"); // b. Get the object. -AliZDCCalibData *calibda3 = (AliZDCCalibData*) AliRunDataStorage::Instance()->Get("ZDC/Calib/GainFactors",5); +AliZDCCalibData *calibda3 = (AliZDCCalibData*) AliCDBStorage::Instance()->Get("ZDC/Calib/GainFactors",5); //AliZDCCalibData calibda3copy=*calibda3; @@ -111,37 +110,37 @@ printf("PM0=%f; PM1=%f; PM2=%f; PM3=%f \n", calibda3->GetEnCalib(0), calibda3->GetEnCalib(1), calibda3->GetEnCalib(2), calibda3->GetEnCalib(3) ); // d. Get the object's metadata, set the new run range -AliObjectMetaData omd2 = AliRunDataStorage::Instance()->GetObjectMetaData("ZDC/Calib/GainFactors"); -omd2.SetRunRange(1,15); +AliCDBMetaData md2 = AliCDBStorage::Instance()->GetCDBMetaData("ZDC/Calib/GainFactors"); +md2.SetRunRange(1,15); // e. Store the object in the "organized" database. // the object will be stored in the file DBFolder/ZDC/Calib/GainFactors/Run1-15_v1.root // Note that, since there is an "overlap" of the new run range with the one specified // in the previous version, the version is automatically increased. -AliRunDataOrganizedFile *orgf = new AliRunDataOrganizedFile(DBFolder.Data()); -AliRunDataStorage::Instance()->Put(calibda3, omd2); +AliCDBLocal *loc = new AliCDBLocal(DBFolder.Data()); +AliCDBStorage::Instance()->Put(calibda3, md2); /*************************************************************************************************************** Part 3: Last act. We want to retrieve the object from the "organized" database folder again. This time, anyway, we don't want the highest version but version 0 instead. - Therefore we have to specify the version wanted using the "Select" method of AliRunDataStorage - and the aliSelectionMetaData object. + Therefore we have to specify the version wanted using the "Select" method of AliCDBStorage + and the aliCDBMetaDataSelect object. ***************************************************************************************************************/ -// a. Create the specific AliRunDataStorage instance (AliRunDataOrganizedFile in this case) -orgf = new AliRunDataOrganizedFile(DBFolder.Data()); +// a. Create the specific AliCDBStorage instance (AliCDBLocal in this case) +loc = new AliCDBLocal(DBFolder.Data()); // b. Specify the selection criterion. We want version 0 for the object valid for run range (1,100) // NOTE(1): TRegexp expression are valid! E.g. we could type "ZDC/Calib/*" if we want to specify version // for all the "ZDC/Calib" subsamples... // Note(2): we could also not specify the run range, if we want version 0 for any retrieved object -AliSelectionMetaData smd("ZDC/Calib/GainFactors",1,100,0); -AliRunDataStorage::Instance()->Select(smd); +AliCDBMetaDataSelect smd("ZDC/Calib/GainFactors",1,100,0); +AliCDBStorage::Instance()->Select(smd); // c. Get the object -AliZDCCalibData *calibda4 = (AliZDCCalibData*) AliRunDataStorage::Instance()->Get("ZDC/Calib/GainFactors",5); +AliZDCCalibData *calibda4 = (AliZDCCalibData*) AliCDBStorage::Instance()->Get("ZDC/Calib/GainFactors",5); printf("\nI am in Part4. I've just got \"ZDC/Calib/GainFactors\" object valid for run 5, version 0.\n"); printf("ZDC Energy calibration factors: \n"); printf("PM0=%f; PM1=%f; PM2=%f; PM3=%f \n", -- 2.39.3