aRunRange.GetLastRun());
} else if (result.GetVersion() == aVersion
&& result.GetSubVersion() == aSubVersion){
- AliError(Form("More than one object valid for run %d, version %d_%d!",
+ AliDebug(2,Form("More than one object valid for run %d, version %d_%d!",
query.GetFirstRun(), aVersion, aSubVersion));
result.SetRunRange(-1,-1); result.SetVersion(-1); result.SetSubVersion(-1);
return kFALSE;
// aVersion is requested version!
if(result.GetSubVersion() == aSubVersion){
- AliError(Form("More than one object valid for run %d, version %d_%d!",
+ AliDebug(2,Form("More than one object valid for run %d, version %d_%d!",
query.GetFirstRun(), aVersion, aSubVersion));
result.SetRunRange(-1,-1); result.SetVersion(-1); result.SetSubVersion(-1);
return kFALSE;
// aVersion and aSubVersion are requested version and subVersion!
if(result.GetVersion() == aVersion && result.GetSubVersion() == aSubVersion){
- AliError(Form("More than one object valid for run %d, version %d_%d!",
+ AliDebug(2,Form("More than one object valid for run %d, version %d_%d!",
query.GetFirstRun(), aVersion, aSubVersion));
result.SetRunRange(-1,-1); result.SetVersion(-1); result.SetSubVersion(-1);
return kFALSE;
TString keyname;
if (!IdToKeyName(dataId.GetAliCDBRunRange(), dataId.GetVersion(),
dataId.GetSubVersion(), keyname)) {
- AliError("Bad ID encountered! Subnormal error!");
+ AliDebug(2,Form("Bad ID encountered! Subnormal error!"));
return NULL;
}
TObject* anObject = gDirectory->Get(keyname);
if (!anObject) {
- AliError("Bad storage data: NULL entry object!");
+ AliDebug(2,Form("Bad storage data: NULL entry object!"));
return NULL;
}
if (AliCDBEntry::Class() != anObject->IsA()) {
- AliError("Bad storage data: Invalid entry object!");
+ AliDebug(2,Form("Bad storage data: Invalid entry object!"));
return NULL;
}
/////////////////////////////////////////////////////////////////////
#include "AliCDBEntry.h"
+#include "AliLog.h"
ClassImp(AliCDBEntry)
}
}
+//_____________________________________________________________________________
+void AliCDBEntry::PrintId() const {
+
+ AliInfo(Form("%s",fId.ToString().Data()));
+
+}
void SetId(const AliCDBId& id) {fId = id;};
AliCDBId& GetId() {return fId;};
const AliCDBId& GetId() const {return fId;};
+ void PrintId() const;
void SetObject(TObject* object) {fObject = object;};
TObject* GetObject() {return fObject;};
void SetMetaData(AliCDBMetaData* metaData) {fMetaData = metaData;};
AliCDBMetaData* GetMetaData() {return fMetaData;};
const AliCDBMetaData* GetMetaData() const {return fMetaData;};
+ void PrintMetaData() const {fMetaData->PrintMetaData();}
void SetOwner(Bool_t owner) {fIsOwner = owner;};
Bool_t IsOwner() const {return fIsOwner;};
// if the same Grid is alreay active, skip connection
if (!gGrid || fGridUrl != gGrid->GridUrl()
- || fUser != gGrid->GetUser()) {
+ || (( fUser != "" ) && ( fUser != gGrid->GetUser() )) ) {
// connection to the Grid
+ AliInfo("Connection to the Grid!!!!");
+ if(gGrid){
+ AliInfo(Form("gGrid = %x; fGridUrl = %s; gGrid->GridUrl() = %s",gGrid,fGridUrl.Data(), gGrid->GridUrl()));
+ AliInfo(Form("fUser = %s; gGrid->GetUser() = %s",fUser.Data(), gGrid->GetUser()));
+ }
TGrid::Connect(fGridUrl.Data(),fUser.Data());
}
dirName += query.GetPath(); // dirName = fDBFolder/idPath
if (!gGrid->Cd(dirName,0)) {
- AliError(Form("Directory <%s> not found", (query.GetPath()).Data()));
- AliError(Form("in DB folder %s", fDBFolder.Data()));
+ AliDebug(2,Form("Directory <%s> not found", (query.GetPath()).Data()));
+ AliDebug(2,Form("in DB folder %s", fDBFolder.Data()));
return kFALSE;
}
if (!query.HasVersion()){ // look for highest version
if(result.GetVersion() > aVersion) continue;
if(result.GetVersion() == aVersion) {
- AliError(Form("More than one object valid for run %d, version %d!",
+ AliDebug(2,Form("More than one object valid for run %d, version %d!",
query.GetFirstRun(), aVersion));
return kFALSE;
}
} else { // look for specified version
if(query.GetVersion() != aVersion) continue;
if(result.GetVersion() == aVersion){
- AliError(Form("More than one object valid for run %d, version %d!",
+ AliDebug(2,Form("More than one object valid for run %d, version %d!",
query.GetFirstRun(), aVersion));
return kFALSE;
}
TString filename;
if (!IdToFilename(dataId.GetAliCDBRunRange(), dataId.GetVersion(),filename)) {
- AliError("Bad data ID encountered! Subnormal error!");
+ AliDebug(2,Form("Bad data ID encountered! Subnormal error!"));
return NULL;
}
filename.Prepend("/alien" + fDBFolder + queryId.GetPath() + '/');
filename += "?se="; filename += fSE.Data();
- AliInfo(Form("Opening file: %s",filename.Data()));
+ AliDebug(2,Form("Opening file: %s",filename.Data()));
TFile *file = TFile::Open(filename);
if (!file) {
- AliError(Form("Can't open file <%s>!", filename.Data()));
+ AliDebug(2,Form("Can't open file <%s>!", filename.Data()));
return NULL;
}
TObject* anObject = file->Get("AliCDBEntry");
if (!anObject) {
- AliError("Bad storage data: NULL entry object!");
+ AliDebug(2,Form("Bad storage data: NULL entry object!"));
return NULL;
}
if (AliCDBEntry::Class() != anObject->IsA()) {
- AliError("Bad storage data: Invalid entry object!");
+ AliDebug(2,Form("Bad storage data: Invalid entry object!"));
return NULL;
}
level0Dir += level0;
if (!gGrid->Cd(level0Dir,0)) {
- AliError(Form("Level0 directory <%s> not found", level0Dir.Data()));
+ AliDebug(2,Form("Level0 directory <%s> not found", level0Dir.Data()));
return;
}
level1Dir += level1;
if (!gGrid->Cd(level1Dir,0)) {
- AliError(Form("Level1 directory <%s> not found", level1Dir.Data()));
+ AliDebug(2,Form("Level1 directory <%s> not found", level1Dir.Data()));
return;
}
void* dirPtr = gSystem->OpenDirectory(dirName);
if (!dirPtr) {
- AliError(Form("Directory <%s> not found", (query.GetPath()).Data()));
- AliError(Form("in DB folder %s", fBaseDirectory.Data()));
+ AliDebug(2,Form("Directory <%s> not found", (query.GetPath()).Data()));
+ AliDebug(2,Form("in DB folder %s", fBaseDirectory.Data()));
return kFALSE;
}
aRunRange.GetLastRun());
} else if (result.GetVersion() == aVersion
&& result.GetSubVersion() == aSubVersion){
- AliError(Form("More than one object valid for run %d, version %d_%d!",
+ AliDebug(2,Form("More than one object valid for run %d, version %d_%d!",
query.GetFirstRun(), aVersion, aSubVersion));
gSystem->FreeDirectory(dirPtr);
return kFALSE;
// aVersion is requested version!
if(result.GetSubVersion() == aSubVersion){
- AliError(Form("More than one object valid for run %d, version %d_%d!",
+ AliDebug(2,Form("More than one object valid for run %d, version %d_%d!",
query.GetFirstRun(), aVersion, aSubVersion));
gSystem->FreeDirectory(dirPtr);
return kFALSE;
// aVersion and aSubVersion are requested version and subVersion!
if(result.GetVersion() == aVersion && result.GetSubVersion() == aSubVersion){
- AliError(Form("More than one object valid for run %d, version %d_%d!",
+ AliDebug(2,Form("More than one object valid for run %d, version %d_%d!",
query.GetFirstRun(), aVersion, aSubVersion));
gSystem->FreeDirectory(dirPtr);
return kFALSE;
if (!IdToFilename(dataId.GetAliCDBRunRange(), dataId.GetVersion(),
dataId.GetSubVersion(), filename)) {
- AliError("Bad data ID encountered! Subnormal error!");
+ AliDebug(2,Form("Bad data ID encountered! Subnormal error!"));
return NULL;
}
TFile file(filename, "READ"); // open file
if (!file.IsOpen()) {
- AliError(Form("Can't open file <%s>!", filename.Data()));
+ AliDebug(2,Form("Can't open file <%s>!", filename.Data()));
return NULL;
}
TObject* anObject = file.Get("AliCDBEntry");
if (!anObject) {
- AliError("Bad storage data: NULL entry object!");
+ AliDebug(2,Form("Bad storage data: NULL entry object!"));
return NULL;
}
if (AliCDBEntry::Class() != anObject->IsA()) {
- AliError("Bad storage data: Invalid entry object!");
+ AliDebug(2,Form("Bad storage data: Invalid entry object!"));
return NULL;
}
void* level0DirPtr = gSystem->OpenDirectory(level0Dir);
if (!level0DirPtr) {
- AliError(Form("Can't open level0 directory <%s>!",
+ AliDebug(2,Form("Can't open level0 directory <%s>!",
level0Dir.Data()));
return;
}
void* level1DirPtr = gSystem->OpenDirectory(level1Dir);
if (!level1DirPtr) {
- AliError(Form("Can't open level1 directory <%s>!",
+ AliDebug(2,Form("Can't open level1 directory <%s>!",
level1Dir.Data()));
return;
}
void* storageDirPtr = gSystem->OpenDirectory(fBaseDirectory);
if (!storageDirPtr) {
- AliError(Form("Can't open storage directory <%s>",
+ AliDebug(2,Form("Can't open storage directory <%s>",
fBaseDirectory.Data()));
return NULL;
}
if (!IdToFilename(id.GetAliCDBRunRange(), id.GetVersion(),
id.GetSubVersion(), filename)) {
- AliError("Bad ID encountered! Subnormal error!");
+ AliDebug(2,Form("Bad ID encountered! Subnormal error!"));
return kFALSE;
}
// write object (key name: "AliCDBEntry")
Bool_t result = file.WriteTObject(entry, "AliCDBEntry");
- if (!result) AliError(Form("Can't write entry to file: %s", filename.Data()));
+ if (!result) AliDebug(2,Form("Can't write entry to file: %s", filename.Data()));
file.Close();
if(result) AliInfo(Form("CDB object stored into file %s",filename.Data()));
}
//_____________________________________________________________________________
-void AliCDBManager::SetSpecificStorage(const char* detName, const char* dbString) {
-// sets storage specific for detector (works with AliCDBManager::Get(...))
+void AliCDBManager::SetSpecificStorage(const char* calibType, const char* dbString) {
+// sets storage specific for detector or calibration type (works with AliCDBManager::Get(...))
AliCDBParam *aPar = CreateParameter(dbString);
if(!aPar) return;
- SetSpecificStorage(detName, aPar);
+ SetSpecificStorage(calibType, aPar);
delete aPar;
}
//_____________________________________________________________________________
-void AliCDBManager::SetSpecificStorage(const char* detName, AliCDBParam* param) {
-// sets storage specific for detector (works with AliCDBManager::Get(...))
+void AliCDBManager::SetSpecificStorage(const char* calibType, AliCDBParam* param) {
+// sets storage specific for detector or calibration type (works with AliCDBManager::Get(...))
+// Default storage should be defined prior to any specific storages, e.g.:
+// AliCDBManager::instance()->SetDefaultStorage("alien://");
+// AliCDBManager::instance()->SetSpecificStorage("TPC","local://DB_TPC");
+// AliCDBManager::instance()->SetSpecificStorage("RICH/Align","local://DB_TPCAlign");
if(!fDefaultStorage) {
AliError("Please activate a default storage first!");
return;
}
- TObjString *objDetName = new TObjString(detName);
- AliCDBParam *checkPar = (AliCDBParam*) fSpecificStorages.GetValue(objDetName);
- if(checkPar){
- AliWarning(Form("%s storage already activated! It will be replaced by the new one",objDetName->String().Data()));
- fSpecificStorages.Remove(objDetName);
- delete checkPar;
+ TObjString *objCalibType = new TObjString(calibType);
+ if(fSpecificStorages.Contains(objCalibType)){
+ AliWarning(Form("%s storage already activated! It will be replaced by the new one",
+ calibType));
+ fSpecificStorages.Remove(objCalibType);
}
GetStorage(param);
- fSpecificStorages.Add(objDetName, param->CloneParam());
+ fSpecificStorages.Add(objCalibType, param->CloneParam());
}
//_____________________________________________________________________________
-AliCDBStorage* AliCDBManager::GetSpecificStorage(const char* detName) {
-// get storage specific for detector
+AliCDBStorage* AliCDBManager::GetSpecificStorage(const char* calibType) {
+// get storage specific for detector or calibration type
- AliCDBParam *checkPar = (AliCDBParam*) fSpecificStorages.GetValue(detName);
+ AliCDBParam *checkPar = (AliCDBParam*) fSpecificStorages.GetValue(calibType);
if(!checkPar){
- AliError(Form("%s storage not found!",detName));
+ AliError(Form("%s storage not found!",calibType));
return NULL;
} else {
return GetStorage(checkPar);
}
+//_____________________________________________________________________________
+AliCDBParam* AliCDBManager::SelectSpecificStorage(const TString& path) {
+// select storage valid for path from the list of specific storages
+
+ TIter iter(&fSpecificStorages);
+ TObjString *aCalibType;
+ AliCDBParam* aPar=0;
+ while((aCalibType = (TObjString*) iter.Next())){
+ if(path.Contains(aCalibType->String(), TString::kIgnoreCase)) {
+ aPar = (AliCDBParam*) fSpecificStorages.GetValue(aCalibType);
+ break;
+ }
+ }
+ return aPar;
+}
+
//_____________________________________________________________________________
AliCDBEntry* AliCDBManager::Get(const AliCDBPath& path, Int_t runNumber,
Int_t version, Int_t subVersion) {
// get an AliCDBEntry object from the database
+ if(runNumber < 0){
+ // RunNumber is not specified. Try with fRun
+ if (fRun < 0){
+ AliError("Run number neither specified in query nor set in AliCDBManager! Use AliCDBManager::SetRun.");
+ return NULL;
+ }
+ runNumber = fRun;
+ }
+
return Get(AliCDBId(path, runNumber, runNumber, version, subVersion));
}
AliError(Form("Invalid query: %s", query.ToString().Data()));
return NULL;
}
-
- // query is not specified if path contains wildcard or runrange = [-1,-1]
- if (!query.IsSpecified()) {
+
+ // query is not specified if path contains wildcard or run range= [-1,-1]
+ if (!query.IsSpecified()) {
AliError(Form("Unspecified query: %s",
query.ToString().Data()));
return NULL;
}
- TObjString objStrLev0(query.GetLevel0());
- AliCDBParam *aPar = (AliCDBParam*) fSpecificStorages.GetValue(&objStrLev0);
- AliCDBStorage *aStorage;
+ if(fCache && query.GetFirstRun() != fRun)
+ AliWarning("Run number explicitly set in query: CDB cache temporarily disabled!");
+
+
+ AliCDBEntry *entry=0;
+
+
+ // first look into map of cached objects
+ if(query.GetFirstRun() == fRun)
+ entry = (AliCDBEntry*) fEntryCache.GetValue(query.GetPath());
+
+ if(entry) {
+ AliInfo(Form("Object %s retrieved from cache !!",query.GetPath().Data()));
+ return entry;
+ }
+
+ // Entry is not in cache -> retrieve it from CDB and cache it!!
+ AliCDBStorage *aStorage=0;
+ AliCDBParam *aPar=SelectSpecificStorage(query.GetPath());
if(aPar) {
aStorage=GetStorage(aPar);
AliDebug(2,"Looking into default storage");
}
- return aStorage->Get(query);
+ entry = aStorage->Get(query);
+ if (!entry) return NULL;
+
+ if(fCache && (query.GetFirstRun() == fRun)){
+ AliInfo(Form("Caching entry %s !",query.GetPath().Data()));
+ CacheEntry(query.GetPath(), entry);
+ }
+
+ return entry;
+
}
//_____________________________________________________________________________
//_____________________________________________________________________________
TList* AliCDBManager::GetAll(const AliCDBId& query) {
// get multiple AliCDBEntry objects from the database
+// Warning: this method works correctly only for queries of the type "Detector/*"
+// and not for more specific queries e.g. "Detector/Calib/*" !
if(!fDefaultStorage) {
AliError("No storage set!");
TObjString objStrLev0(query.GetLevel0());
AliCDBParam *aPar = (AliCDBParam*) fSpecificStorages.GetValue(&objStrLev0);
- AliCDBStorage *aStorage;
-
+
+ AliCDBStorage *aStorage;
if(aPar) {
aStorage=GetStorage(aPar);
TString str = aPar->GetURI();
}
AliCDBId id = entry->GetId();
- TObjString objStrLev0(id.GetLevel0());
- AliCDBParam *aPar = (AliCDBParam*) fSpecificStorages.GetValue(&objStrLev0);
+ AliCDBParam *aPar = SelectSpecificStorage(id.GetPath());
+
AliCDBStorage *aStorage;
if(aPar) {
}
-//_____________________________________________________________________________
-AliCDBEntry* AliCDBManager::Get(const char* path)
-{
-// get an AliCDBEntry object from the database, using fRun as run number
-
- if (fRun < 0)
- {
- AliError("Run number not set! Use AliCDBManager::SetRun.");
- return 0;
- }
-
- AliCDBEntry *entry;
-
- // first look into map of cached objects
- entry = (AliCDBEntry*) fEntryCache.GetValue(path);
- if(entry) return entry;
-
- // Entry is not in cache -> retrieve it from CDB and cache it!!
- entry = Get(path, fRun);
- if (!entry) return 0;
-
- if(fCache) CacheEntry(path, entry);
-
- return entry;
-
-}
-
//_____________________________________________________________________________
void AliCDBManager::CacheEntry(const char* path, AliCDBEntry* entry)
{
//_____________________________________________________________________________
void AliCDBManager::SetRun(Long64_t run)
{
-//
// Sets current run number.
// When the run number changes the caching is cleared.
-//
if (fRun == run)
return;
AliCDBStorage* GetDefaultStorage() const {return fDefaultStorage;}
void UnsetDefaultStorage() {fDefaultStorage = 0x0;}
- void SetSpecificStorage(const char* detName, const char* dbString);
- void SetSpecificStorage(const char* detName, AliCDBParam* param);
+ void SetSpecificStorage(const char* calibType, const char* dbString);
+ void SetSpecificStorage(const char* calibType, AliCDBParam* param);
- AliCDBStorage* GetSpecificStorage(const char* detName);
+ AliCDBStorage* GetSpecificStorage(const char* calibType);
void SetDrain(const char* dbString);
void SetDrain(const AliCDBParam* param);
void UnsetDrain(){fDrainStorage = 0x0;}
AliCDBEntry* Get(const AliCDBId& query);
- AliCDBEntry* Get(const AliCDBPath& path, Int_t runNumber,
+ AliCDBEntry* Get(const AliCDBPath& path, Int_t runNumber=-1,
Int_t version = -1, Int_t subVersion = -1);
AliCDBEntry* Get(const AliCDBPath& path, const AliCDBRunRange& runRange,
Int_t version = -1, Int_t subVersion = -1);
TList* GetAll(const AliCDBId& query);
- TList* GetAll(const AliCDBPath& path, Int_t runNumber,
+ TList* GetAll(const AliCDBPath& path, Int_t runNumber=-1,
Int_t version = -1, Int_t subVersion = -1);
TList* GetAll(const AliCDBPath& path, const AliCDBRunRange& runRange,
Int_t version = -1, Int_t subVersion = -1);
void SetRun(Long64_t run);
Long64_t GetRun() {return fRun;}
- AliCDBEntry* Get(const char* path);
+ // AliCDBEntry* Get(const char* path);
void DestroyActiveStorages();
void DestroyActiveStorage(AliCDBStorage* storage);
void ClearCache();
void CacheEntry(const char* path, AliCDBEntry* entry);
+ AliCDBParam* SelectSpecificStorage(const TString& path);
+
void Init();
const char* AliReconstruction::fgkDetectorName[AliReconstruction::fgkNDetectors] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "RICH", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "START", "VZERO", "CRT", "HLT"};
//_____________________________________________________________________________
-AliReconstruction::AliReconstruction(const char* gAliceFilename,
+AliReconstruction::AliReconstruction(const char* gAliceFilename, const char* cdbUri,
const char* name, const char* title) :
TNamed(name, title),
fVertexer(NULL),
- fWriteAlignmentData(kFALSE)
+ fWriteAlignmentData(kFALSE),
+ fCDBUri(cdbUri)
{
// create reconstruction object with default parameters
fVertexer(NULL),
- fWriteAlignmentData(rec.fWriteAlignmentData)
+ fWriteAlignmentData(rec.fWriteAlignmentData),
+ fCDBUri(rec.fCDBUri)
{
// copy constructor
fOptions.Delete();
}
+//_____________________________________________________________________________
+void AliReconstruction::InitCDBStorage()
+{
+// activate a default CDB storage
+// First check if we have any CDB storage set, because it is used
+// to retrieve the calibration and alignment constants
+
+ AliCDBManager* man = AliCDBManager::Instance();
+ if (!man->IsDefaultStorageSet())
+ {
+ AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+ AliWarning("Default CDB storage not yet set");
+ AliWarning(Form("Using default storage declared in AliSimulation: %s",fCDBUri.Data()));
+ AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+ SetDefaultStorage(fCDBUri);
+ }
+
+}
+
+//_____________________________________________________________________________
+void AliReconstruction::SetDefaultStorage(const char* uri) {
+// activate a default CDB storage
+
+ AliCDBManager::Instance()->SetDefaultStorage(uri);
+
+}
+
+//_____________________________________________________________________________
+void AliReconstruction::SetSpecificStorage(const char* detName, const char* uri) {
+// activate a detector-specific CDB storage
+
+ AliCDBManager::Instance()->SetSpecificStorage(detName, uri);
+
+}
+
//_____________________________________________________________________________
void AliReconstruction::SetGAliceFile(const char* fileName)
{
// run the reconstruction
- // First check if we have any CDB storage set, because it is used
- // to retrieve the calibration and alignment constants
-
- AliCDBManager* man = AliCDBManager::Instance();
- if (!man->IsDefaultStorageSet())
- {
- AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
- AliWarning("No default CDB storage set, so I will use $ALICE_ROOT");
- AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
- man->SetDefaultStorage("local://$ALICE_ROOT");
- }
+ InitCDBStorage();
// set the input
if (!input) input = fInput.Data();
class AliReconstruction: public TNamed {
public:
AliReconstruction(const char* gAliceFilename = "galice.root",
+ const char* cdbUri = "local://$ALICE_ROOT",
const char* name = "AliReconstruction",
const char* title = "reconstruction");
AliReconstruction(const AliReconstruction& rec);
{fStopOnError = stopOnError;}
void SetCheckPointLevel(Int_t checkPointLevel)
{fCheckPointLevel = checkPointLevel;}
+
+ // CDB storage activation
+ void InitCDBStorage();
+ void SetDefaultStorage(const char* uri);
+ void SetSpecificStorage(const char* detName, const char* uri);
virtual Bool_t Run(const char* input,
Int_t firstEvent, Int_t lastEvent = -1);
Bool_t fWriteAlignmentData; // write track space-points flag
+ TString fCDBUri; // Uri of the default CDB storage
+
ClassDef(AliReconstruction, 6) // class for running the reconstruction
};
}
//_____________________________________________________________________________
-Bool_t AliRun::ApplyAlignObjsToGeom(TClonesArray* AlObjArray)
+Bool_t AliRun::ApplyAlignObjsToGeom(TObjArray* AlObjArray)
{
// Read collection of alignment objects (AliAlignObj derived) saved
// in the TClonesArray ClArrayName and apply them to the geometry
// Method to introduce the detector misliagnment
// It is called by AliSimulation
- static Bool_t ApplyAlignObjsToGeom(TClonesArray* AlObjArray);
+ static Bool_t ApplyAlignObjsToGeom(TObjArray* AlObjArray);
protected:
virtual void Tree2Tree(Option_t *option, const char *detector=0);
//_____________________________________________________________________________
-AliSimulation::AliSimulation(const char* configFileName,
+AliSimulation::AliSimulation(const char* configFileName, const char* cdbUri,
const char* name, const char* title) :
TNamed(name, title),
fRunGeneration(kTRUE),
fRunSimulation(kTRUE),
+ fLoadAlignFromCDB(kTRUE),
+ fLoadAlignData("ALL"),
fMakeSDigits("ALL"),
fMakeDigits("ALL"),
fMakeTrigger(""),
fBkgrdFileNames(NULL),
fAlignObjArray(NULL),
fUseBkgrdVertex(kTRUE),
- fRegionOfInterest(kFALSE)
+ fRegionOfInterest(kFALSE),
+ fCDBUri(cdbUri)
{
// create simulation object with default parameters
fRunGeneration(sim.fRunGeneration),
fRunSimulation(sim.fRunSimulation),
+ fLoadAlignFromCDB(sim.fLoadAlignFromCDB),
+ fLoadAlignData(sim.fLoadAlignData),
fMakeSDigits(sim.fMakeSDigits),
fMakeDigits(sim.fMakeDigits),
fMakeTrigger(sim.fMakeTrigger),
fBkgrdFileNames(NULL),
fAlignObjArray(NULL),
fUseBkgrdVertex(sim.fUseBkgrdVertex),
- fRegionOfInterest(sim.fRegionOfInterest)
+ fRegionOfInterest(sim.fRegionOfInterest),
+ fCDBUri(sim.fCDBUri)
{
// copy constructor
// clean up
fEventsPerFile.Delete();
+// if(fAlignObjArray) fAlignObjArray->Delete(); // fAlignObjArray->RemoveAll() ???
+// delete fAlignObjArray; fAlignObjArray=0;
if (fBkgrdFileNames) {
fBkgrdFileNames->Delete();
fNEvents = nEvents;
}
+//_____________________________________________________________________________
+void AliSimulation::InitCDBStorage(const char* uri)
+{
+// activate a default CDB storage
+// First check if we have any CDB storage set, because it is used
+// to retrieve the calibration and alignment constants
+
+ AliCDBManager* man = AliCDBManager::Instance();
+ if (!man->IsDefaultStorageSet())
+ {
+ AliWarningClass("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+ AliWarningClass("Default CDB storage not yet set");
+ AliWarningClass(Form("Using default storage declared in AliSimulation: %s",uri));
+ AliWarningClass("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+ SetDefaultStorage(uri);
+ }
+
+}
+
+//_____________________________________________________________________________
+void AliSimulation::SetDefaultStorage(const char* uri) {
+// activate a default CDB storage
+
+ AliCDBManager::Instance()->SetDefaultStorage(uri);
+
+}
+
+//_____________________________________________________________________________
+void AliSimulation::SetSpecificStorage(const char* detName, const char* uri) {
+// activate a detector-specific CDB storage
+
+ AliCDBManager::Instance()->SetSpecificStorage(detName, uri);
+
+}
+
//_____________________________________________________________________________
void AliSimulation::SetConfigFile(const char* fileName)
{
}
+//_____________________________________________________________________________
+Bool_t AliSimulation::ApplyAlignObjsToGeom(const char* detName, Int_t runnum, Int_t version, Int_t sversion)
+{
+ // read collection of alignment objects (AliAlignObj derived) saved
+ // in the TClonesArray ClArrayName in the AliCDBEntry identified by
+ // param (to get the AliCDBStorage) and Id; apply the alignment objects
+ // to the TGeo geometry passed as argument
+ //
+
+ InitCDBStorage("local://$ALICE_ROOT");
+ AliCDBPath path(detName,"Align","Data");
+ AliCDBEntry* entry = AliCDBManager::Instance()->Get(path.GetPath(),runnum,version,sversion);
+
+ if(!entry) return kFALSE;
+ TClonesArray* AlObjArray = ((TClonesArray*) entry->GetObject());
+
+ return gAlice->ApplyAlignObjsToGeom(AlObjArray);
+}
+
+
+//_____________________________________________________________________________
+void AliSimulation::SetAlignObjArray(const char* detectors)
+{
+ // Fills array of detectors' alignable objects from CDB
+ // detectors can be "ALL" or "ITS TPC ..."
+
+ AliRunLoader* runLoader = LoadRun();
+ if (!runLoader) return;
+
+ InitCDBStorage(fCDBUri);
+
+ if(!fAlignObjArray) fAlignObjArray = new TObjArray();
+ fAlignObjArray->SetOwner(0); // AliCDBEntry is owner of the align objects!
+ fAlignObjArray->Clear();
+
+ TString detStr = detectors;
+ TObjArray* detArray = runLoader->GetAliRun()->Detectors();
+ TString dataNotLoaded="";
+ TString dataLoaded="";
+
+ for (Int_t iDet = 0; iDet < detArray->GetEntriesFast(); iDet++) {
+ AliModule* det = (AliModule*) detArray->At(iDet);
+ if (!det || !det->IsActive()) continue;
+ if (IsSelected(det->GetName(), detStr)) {
+
+ if(!SetAlignObjArraySingleDet(det->GetName())){
+ dataNotLoaded += det->GetName();
+ dataNotLoaded += " ";
+ } else {
+ dataLoaded += det->GetName();
+ dataLoaded += " ";
+ }
+ }
+ } // end loop over all detectors
+
+ if ((detStr.CompareTo("ALL") == 0)) detStr = "";
+ dataNotLoaded += detStr;
+ AliInfo(Form("Alignment data loaded for: %s",
+ dataLoaded.Data()));
+ AliInfo(Form("Didn't/couldn't load alignment data for: %s",
+ dataNotLoaded.Data()));
+
+ AliDebug(2, Form("fAlignObjArray entries: %d",fAlignObjArray->GetEntries() ));
+ delete detArray;
+
+}
+
+//_____________________________________________________________________________
+Bool_t AliSimulation::SetAlignObjArraySingleDet(const char* detName)
+{
+ // Fills array of single detector's alignable objects from CDB
+
+ AliDebug(2, Form("Loading alignment data for detector: %s",detName));
+
+ AliCDBEntry *entry;
+
+ AliCDBPath path(detName,"Align","Data");
+
+ entry=AliCDBManager::Instance()->Get(path.GetPath());
+ if(!entry){
+ AliDebug(2,Form("Couldn't load alignment data for detector %s",detName));
+ return kFALSE;
+ }
+ entry->SetOwner(1);
+ TClonesArray *alignArray = (TClonesArray*) entry->GetObject();
+ alignArray->SetOwner(0);
+ AliDebug(2,Form("Found %d alignment objects for %s",
+ alignArray->GetEntries(),detName));
+
+ AliAlignObj *alignObj=0;
+ TIter iter(alignArray);
+
+ // loop over align objects in detector
+ while( ( alignObj=(AliAlignObj *) iter.Next() ) ){
+ fAlignObjArray->Add(alignObj);
+ }
+ // delete entry --- Don't delete, it is cached!
+
+ AliDebug(2, Form("fAlignObjArray entries: %d",fAlignObjArray->GetEntries() ));
+ return kTRUE;
+
+}
+
//_____________________________________________________________________________
void AliSimulation::MergeWith(const char* fileName, Int_t nSignalPerBkgrd)
{
{
// run the generation, simulation and digitization
- // First check if we have any CDB storage set, because it is used
- // to retrieve the calibration and alignment constants
-
- AliCDBManager* man = AliCDBManager::Instance();
- if (!man->IsDefaultStorageSet())
- {
- AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
- AliWarning("No default CDB storage set, so I will use $ALICE_ROOT");
- AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
- man->SetDefaultStorage("local://$ALICE_ROOT");
- }
+ InitCDBStorage(fCDBUri);
if (nEvents > 0) fNEvents = nEvents;
gAlice->Init(fConfigFileName.Data());
););
+ // Set run number in CDBManager (here????)
+ AliCDBManager::Instance()->SetRun(gAlice->GetRunNumber());
+ AliInfo(Form("Run number: %d",AliCDBManager::Instance()->GetRun()));
+
+ AliRunLoader* runLoader = gAlice->GetRunLoader();
+ if (!runLoader) {
+ AliError(Form("gAlice has no run loader object. "
+ "Check your config file: %s", fConfigFileName.Data()));
+ return kFALSE;
+ }
+ SetGAliceFile(runLoader->GetFileName());
+
+ // Load alignment data from CDB and fill fAlignObjArray
+
+ if(fLoadAlignFromCDB){
+ if(!fAlignObjArray) fAlignObjArray = new TObjArray();
+
+ //fAlignObjArray->RemoveAll();
+ fAlignObjArray->Clear();
+ fAlignObjArray->SetOwner(0);
+
+ TString detStr = fLoadAlignData;
+ TString dataNotLoaded="";
+ TString dataLoaded="";
+
+ TObjArray* detArray = runLoader->GetAliRun()->Detectors();
+ for (Int_t iDet = 0; iDet < detArray->GetEntriesFast(); iDet++) {
+ AliModule* det = (AliModule*) detArray->At(iDet);
+ if (!det || !det->IsActive()) continue;
+ if (IsSelected(det->GetName(), detStr)) {
+ if(!SetAlignObjArraySingleDet(det->GetName())){
+ dataNotLoaded += det->GetName();
+ dataNotLoaded += " ";
+ } else {
+ dataLoaded += det->GetName();
+ dataLoaded += " ";
+ }
+ }
+ } // end loop over detectors
+
+ if ((detStr.CompareTo("ALL") == 0)) detStr = "";
+ dataNotLoaded += detStr;
+ AliInfo(Form("Alignment data loaded for: %s",
+ dataLoaded.Data()));
+ AliInfo(Form("Didn't/couldn't load alignment data for: %s",
+ dataNotLoaded.Data()));
+ } // fLoadAlignFromCDB flag
+
// Check if the array with alignment objects was
// provided by the user. If yes, apply the objects
// to the present TGeo geometry
// Export TGeo geometry
if (gGeoManager) gGeoManager->Export("geometry.root");
- AliRunLoader* runLoader = gAlice->GetRunLoader();
- if (!runLoader) {
- AliError(Form("gAlice has no run loader object. "
- "Check your config file: %s", fConfigFileName.Data()));
- return kFALSE;
- }
- SetGAliceFile(runLoader->GetFileName());
+// AliRunLoader* runLoader = gAlice->GetRunLoader();
+// if (!runLoader) {
+// AliError(Form("gAlice has no run loader object. "
+// "Check your config file: %s", fConfigFileName.Data()));
+// return kFALSE;
+// }
+// SetGAliceFile(runLoader->GetFileName());
if (!gAlice->Generator()) {
AliError(Form("gAlice has no generator object. "
class AliSimulation: public TNamed {
public:
AliSimulation(const char* configFileName = "Config.C",
+ const char* cdbUri = "local://$ALICE_ROOT",
const char* name = "AliSimulation",
const char* title = "generation, simulation and digitization");
AliSimulation(const AliSimulation& sim);
void SetRunGeneration(Bool_t run) {fRunGeneration = run;};
void SetRunSimulation(Bool_t run) {fRunSimulation = run;};
+ void SetLoadAlignFromCDB(Bool_t load) {fLoadAlignFromCDB = load;};
+ void SetLoadAlignData(const char* detectors)
+ {fLoadAlignData = detectors;};
void SetMakeSDigits(const char* detectors)
{fMakeSDigits = detectors;};
void MergeWith(const char* fileName, Int_t nSignalPerBkgrd = 0);
static Bool_t ApplyAlignObjsToGeom(const char* uri, const char* path,
Int_t runnum, Int_t version,
Int_t sversion);
- void SetAlignObjArray(TClonesArray *array)
- {fAlignObjArray = array;}
+ static Bool_t ApplyAlignObjsToGeom(const char* detName, Int_t runnum, Int_t version,
+ Int_t sversion);
+ void SetAlignObjArray(TObjArray *array)
+ {fAlignObjArray = array;
+ fLoadAlignFromCDB = kFALSE;}
+
+ void SetAlignObjArray(const char* detectors="ALL");
+ Bool_t SetAlignObjArraySingleDet(const char* detName);
+
+ // CDB storage activation
+ static void InitCDBStorage(const char *uri);
+ static void SetDefaultStorage(const char* uri);
+ static void SetSpecificStorage(const char* detName, const char* uri);
virtual Bool_t Run(Int_t nEvents = 0);
Bool_t fRunGeneration; // generate prim. particles or not
Bool_t fRunSimulation; // simulate detectors (hits) or not
+ Bool_t fLoadAlignFromCDB; // Load alignment data from CDB and apply it to geometry or not
+ TString fLoadAlignData; // Load alignment data from CDB for these detectors
TString fMakeSDigits; // create sdigits for these detectors
TString fMakeDigits; // create digits for these detectors
TString fMakeTrigger; // run trigger for these descriptors
TObjArray fEventsPerFile; // number of events per file for given detectors and data types
TObjArray* fBkgrdFileNames; // names of background files for merging
- TClonesArray* fAlignObjArray; // array with the alignment objects to be applied to the geometry
+ TObjArray* fAlignObjArray; // array with the alignment objects to be applied to the geometry
Bool_t fUseBkgrdVertex; // use vertex from background in case of merging
Bool_t fRegionOfInterest; // digitization in region of interest
+ TString fCDBUri; // Uri of the default CDB storage
+
ClassDef(AliSimulation, 2) // class for running generation, simulation and digitization
};