+
+//______________________________________________________________________________
+const char* AliAnalysisManager::GetOADBPath()
+{
+// returns the path of the OADB
+// this static function just depends on environment variables
+
+ static TString oadbPath;
+
+ if (gSystem->Getenv("OADB_PATH"))
+ oadbPath = gSystem->Getenv("OADB_PATH");
+ else if (gSystem->Getenv("ALICE_ROOT"))
+ oadbPath.Form("%s/OADB", gSystem->Getenv("ALICE_ROOT"));
+ else
+ ::Fatal("AliAnalysisManager::GetOADBPath", "Cannot figure out AODB path. Define ALICE_ROOT or OADB_PATH!");
+
+ return oadbPath;
+}
+
+//______________________________________________________________________________
+void AliAnalysisManager::SetGlobalStr(const char *key, const char *value)
+{
+// Define a custom string variable mapped to a global unique name. The variable
+// can be then retrieved by a given analysis macro via GetGlobalStr(key).
+ AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+ if (!mgr) {
+ ::Error("AliAnalysisManager::SetGlobalStr", "No analysis manager defined");
+ return;
+ }
+ Bool_t valid = kFALSE;
+ TString existing = AliAnalysisManager::GetGlobalStr(key, valid);
+ if (valid) {
+ ::Error("AliAnalysisManager::SetGlobalStr", "Global %s = %s already defined.", key, existing.Data());
+ return;
+ }
+ mgr->GetGlobals()->Add(new TObjString(key), new TObjString(value));
+}
+
+//______________________________________________________________________________
+const char *AliAnalysisManager::GetGlobalStr(const char *key, Bool_t &valid)
+{
+// Static method to retrieve a global variable defined via SetGlobalStr.
+ valid = kFALSE;
+ AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+ if (!mgr) return 0;
+ TObject *value = mgr->GetGlobals()->GetValue(key);
+ if (!value) return 0;
+ valid = kTRUE;
+ return value->GetName();
+}
+
+//______________________________________________________________________________
+void AliAnalysisManager::SetGlobalInt(const char *key, Int_t value)
+{
+// Define a custom integer variable mapped to a global unique name. The variable
+// can be then retrieved by a given analysis macro via GetGlobalInt(key).
+ AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+ if (!mgr) {
+ ::Error("AliAnalysisManager::SetGlobalStr", "No analysis manager defined");
+ return;
+ }
+ Bool_t valid = kFALSE;
+ Int_t existing = AliAnalysisManager::GetGlobalInt(key, valid);
+ if (valid) {
+ ::Error("AliAnalysisManager::SetGlobalInt", "Global %s = %i already defined.", key, existing);
+ return;
+ }
+ mgr->GetGlobals()->Add(new TObjString(key), new TObjString(TString::Format("%i",value)));
+}
+
+//______________________________________________________________________________
+Int_t AliAnalysisManager::GetGlobalInt(const char *key, Bool_t &valid)
+{
+// Static method to retrieve a global variable defined via SetGlobalInt.
+ valid = kFALSE;
+ AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+ if (!mgr) return 0;
+ TObject *value = mgr->GetGlobals()->GetValue(key);
+ if (!value) return 0;
+ valid = kTRUE;
+ TString s = value->GetName();
+ return s.Atoi();
+}
+
+//______________________________________________________________________________
+void AliAnalysisManager::SetGlobalDbl(const char *key, Double_t value)
+{
+// Define a custom double precision variable mapped to a global unique name. The variable
+// can be then retrieved by a given analysis macro via GetGlobalInt(key).
+ AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+ if (!mgr) {
+ ::Error("AliAnalysisManager::SetGlobalStr", "No analysis manager defined");
+ return;
+ }
+ Bool_t valid = kFALSE;
+ Double_t existing = AliAnalysisManager::GetGlobalDbl(key, valid);
+ if (valid) {
+ ::Error("AliAnalysisManager::SetGlobalInt", "Global %s = %g already defined.", key, existing);
+ return;
+ }
+ mgr->GetGlobals()->Add(new TObjString(key), new TObjString(TString::Format("%f.16",value)));
+}
+
+//______________________________________________________________________________
+Double_t AliAnalysisManager::GetGlobalDbl(const char *key, Bool_t &valid)
+{
+// Static method to retrieve a global variable defined via SetGlobalDbl.
+ valid = kFALSE;
+ AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+ if (!mgr) return 0;
+ TObject *value = mgr->GetGlobals()->GetValue(key);
+ if (!value) return 0;
+ valid = kTRUE;
+ TString s = value->GetName();
+ return s.Atof();
+}
+
+//______________________________________________________________________________
+void AliAnalysisManager::AddClassDebug(const char *className, Int_t debugLevel)
+{
+// Sets Class debug level
+
+ if (!fDebugOptions) {
+ fDebugOptions = new TObjArray();
+ fDebugOptions->SetOwner(kTRUE);
+ }
+
+ // substracting DebugOffset, beacuse of AliLog::SetClassDebugLevel()
+ debugLevel -= AliLog::kDebug-1;
+
+ TNamed *debugOpt = (TNamed*)fDebugOptions->FindObject(className);
+ if (!debugOpt) {
+ AliInfo(TString::Format("Adding debug level %d for class %s",debugLevel+AliLog::kDebug-1,className).Data());
+ fDebugOptions->Add(new TNamed(className,TString::Format("%d",debugLevel).Data()));
+ } else {
+ TString oldDebugStr = debugOpt->GetTitle();
+ Int_t oldDebug = oldDebugStr.Atoi();
+ if (debugLevel > oldDebug) {
+ AliWarning(TString::Format("Overwriting debug level to %d class %s, because it is higher then previously set (%d).",debugLevel+AliLog::kDebug-1,className,oldDebug+AliLog::kDebug-1).Data());
+ debugOpt->SetTitle(TString::Format("%d",debugLevel).Data());
+ } else {
+ AliWarning(TString::Format("Ignoring debug level to %d class %s, because it is smaller then previously set (%d).",debugLevel+AliLog::kDebug-1,className,oldDebug+AliLog::kDebug-1).Data());
+ }
+ }
+}
+
+//______________________________________________________________________________
+void AliAnalysisManager::ApplyDebugOptions()
+{
+// Apply debug options
+
+ if (!fDebugOptions) return;
+
+ TIter next(fDebugOptions);
+ TNamed *debug;
+ TString debugLevel;
+ while ((debug=dynamic_cast<TNamed*>(next()))) {
+ debugLevel = debug->GetTitle();
+ AliInfo(TString::Format("ApplyDebugOptions : Class=%s debulLevel=%d",debug->GetName(),debugLevel.Atoi()+AliLog::kDebug-1).Data());
+ AliLog::SetClassDebugLevel(debug->GetName(), debugLevel.Atoi());
+ }
+}
+